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