Difference between revisions of "Git Cheat Sheet"
From Genome Analysis Wiki
Jump to navigationJump to search (Created page with '{| style="border-collapse: collapse" border="1" align="left" |+ Git CheatSheet |- ! colspan="2" | Help |- | Get Help || git help ''command'' |- ! colspan="2" | Clone/Copy Repo |…') |
|||
Line 1: | Line 1: | ||
− | {| style="border-collapse: collapse" border="1" align="left" | + | {| style="border-collapse: collapse font-size:10pt" border="1" align="left" |
|+ Git CheatSheet | |+ Git CheatSheet | ||
|- | |- |
Revision as of 18:28, 7 July 2011
Help | |
---|---|
Get Help | git help command |
Clone/Copy Repo | |
Copy Repo | git clone source [destName] |
Checking what has Changed | |
What files changed? | git status |
What changed in a file? | git diff fileName |
What changed in a file between commits? | git diff commit1 commit2 fileName |
Check History Logs | git log [fileName] |
Saving Changes (2 step process) | |
1) Stage Changes | git add fileName1 fileName2 |
2) Commit Changes | git commit -m “commit message” |
Undoing Things | |
Undo staging | git reset HEAD fileName |
Undo unstaged changes | git checkout -- fileName |
Working with a Remote | |
Get the latest updates | git pull |
Share your Changes | git push |
1st time pushing branch | git push origin branchName |
Push to Remote | git push origin tagName |
See all branches including remotes | git branch -a |
Base work on a remote branch/merge back to it | git checkout --track origin/branchName |
Tags | |
Create a tag | git tag -a tagName -m "tag description" |
List Tags | git tag |
List tags with certain name | git tag -l partialName* |
Get info on a tag | git show tagName |
Push to Remote | git push origin tagName |
Branches | |
See what branches exist (current marked with *) | git branch |
Switch branch | git checkout branchName |
Create & switch to branch (branches from current one) | git checkout -b branchName |
Merge from another branch to this one | git merge branchMergingFrom |
See all branches including remotes | git branch -a |
Base work on a remote branch/merge back to it | git checkout --track origin/branchName |
1st time pushing branch | git push origin branchName |
Delete Local Branch | git branch -d branchName |
Delete Remote Branch | git push origin :branchName |
Resolving Merge Conflicts | |
1) Make changes | use your favorite text editor |
2) Delete <<<<<<<, =======, and >>>>>>> | use your favorite text editor |
3) Stage the conflict resolution | git add nowMergedFile |
4) Commit the merge | git commit |
Create New “Remote” Repo | |
Create Repo with only the database info (no source) | git init --bare --shared myRepoName |
Push to Remote for the first time | git push origin master |