- Create a new Github repository on your account, say TestRepo
- Create SSH public and private keys for your machine, and add that SSH key to your Github account
- Go to your project directory and create a .gitignore file for files and folders you do not want to publicly upload to your Github repository
- Open the command prompt, by pressing the Window and R keyboard buttons at the same time, typing in cmd, and pressing Enter
- In the command prompt, go to the root of your project code, say cd C:\Users\Your_Machine_Name\Test_Project
- Run git init
- Run git add .
- Run git commit -m ‘Initial commit’. You can replace the commit message with a desired message if you want to.
- Go to your newly created Github repo and copy its SSH address, i.e. firstname.lastname@example.org:github_username/TestRepo
- Back to the command prompt, run git remote add origin email@example.com:github_username/TestRepo
- Run git push -u origin master
Update: Pushing latest changes to the repository
- Back on the command prompt, run git status to display the files where changes were last made
- Copy the path of the file you want to commit, then run git add <filename> for each file. Run git add -u if you want to include everything except the new files. Run git add -A if literally all files needed to be committed.
- Run git commit -m <commit message> to ready the files for transfer to your repository
- Run git push -u origin master to push these changes
Update: Creating and/or Moving to a particular branch of code
- On the command prompt, run git branch to display all the branches available to you locally. By default, there is only one branch, aptly named as master.
- If you want to build a new branch from master, run git checkout -b <branch_name>. This creates and automatically moves you to the new branch.
- If you want to move to another branch, run git checkout <branch_name>.
Update: Merging Branches
- Run git merge <branch_name> if you want to merge that branch to the branch where you are currently in.
Update: Deleting branches
- Run git branch -d <branch_name> if you want to delete a branch. This will delete that branch in your local repository.
- Run git push origin –delete <branch_name>. This will delete the selected branch in the remote repository.
Update: Retrieving latest version of code
- Run git fetch origin.
- Run git reset –hard origin/master. Note that this will effectively remove all files locally and replace them with the latest files found in the remote repository.