Command line tools
Download git command line tools for Windows: https://msysgit.github.io/
Command line tips
Create a branch and switch to it
git checkout -b branchname
Switch branches
git checkout branchname
Push to remote repo
git push origin branchname
Merging branches
Be sure to commit and push branch to remote repo first for completeness
git checkout master
git merge branchname
Delete local branch
git branch -d branchname
Delete remote branch
git push origin :branchname (watch for the colon)
Undo a branch merge
git reset --hard SHA1__Commit_Prior_to_Merge
Sync all remote branches
git remote update
git fetch --all
git pull --all
If that fails, do it one-by-one manually:
git checkout -b <local branch> <remote>/<remote branch>
Saving Credentials
git config credential.helper store
Cloning a Remote Git Repo
git clone <remote_git_url>
Cloning from SVN with Commit History
git svn clone <svn-url>
git remote add origin <remote_git_url>
git push origin master
Remember to add a .gitignore file
Reverting the current repo back to a previous commit
git reset --hard <commit-id>
(reset without –hard only resets the history. –hard also resets the files)
Reverting a single file from a known specific commit
git checkout <commit-id> <file-path-to-restore>
Reverting a specified single file or all files in the path back to the last commit
git checkout -- full-file-path-to-restore>
git checkout -- full-path-to-folder-restore>
To revert ALL uncommitted changes:
git checkout -- .
GitHub.com CheatSheet
https://education.github.com/git-cheat-sheet-education.pdf
Leave a Reply