Placing Local Code Under Git Source Control
Manually
¶
Create repo on GitHub
File Explorer: Navigate to source code root folder
Rename folder
Create new folder with old name
Open a Command Window
Navigate to NEW source code root folder, then up one level
Command: git clone
repo-url
Move files from original folder into new folder
Add a .GITIGNORE file -
GitIgnore Files
Change directory to the folder with the Git repo
git add .
git commit -m "Initial commit"
git push
With Visual Studio 2019
¶
Open project/solution in Visual Studio 2019
File > Add to Source Control
Team Explorer > Sync > Push > Publish To GitHub
Be sure to select the owner user/organization!
Be sure to select "Private Repository" checkbox as appropriate!
With Visual Studio 2017
¶
Open project in VS 2017
Open solution/project folder in File Explorer
Close project in VS 2017
Rename folder
Create new folder with original name
Create repo in new empty folder: VS > Team Explorer > Connect page > Local Git Repositories > New
(No need to update .GITIGNORE file - VS creates it correctly)
Move code from renamed folder into new folder
Delete old (now empty) folder
Open repo: VS > Team Explorer > Connect page > Local Git Repositories > (double click new repo)
Commit changes to repo
Create remote repo on GitHub
Push to remote repo: VS > Team Explorer > Sync page > Publish > specify GitHub repo URL
With SourceTree
¶
Add a .GITIGNORE file. (See
this page - GitIgnore Files
)
Create a new Git Repository in the local folder
Commit code to the local repository
Create a new repository on GitHub
Source Tree > Repository > Repository Settings > Add a new remote path (Remote name = "GitHub")
Push local repository to GitHub