-
-
Save lizzies/df520ea3e5dbe4a3e33c1bb0458bd7a9 to your computer and use it in GitHub Desktop.
Revisions
-
davfre revised this gist
Jul 8, 2021 . 1 changed file with 11 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,17 +28,17 @@ http://git-scm.com/book/en/Git-Tools-Rewriting-History `git rebase --onto <commit-id>\^ <commit-id> HEAD` remove specific commit from repository. the \ in \^ is just an escape char to make zsh play nice and is not necessary if using bash. ### Remote repositories `git remote add origin [email protected]:example/petshop.git` add a remote repository `git push -u origin master` push current local repo to remote. -u sets it to default for the future `git remote -v show` show the available remote repositories that have been added `git remote show origin` show local<->remote branch tracking and sync status `git remote -v update` bring remote refs up to date (and -v show which branches were updated) `git pull` checkout and merge remote changes in one go `git fetch origin` update the local cache of the remote repository `git status -uno` will tell you whether the branch you are tracking is ahead, behind or has diverged. If it says nothing, the local and remote are the same. `git show-branch *master` will show you the commits in all of the branches whose names end in master (eg master and origin/master). `git log HEAD..origin/master --oneline` shows commit messages `git diff HEAD..origin/master` shows all changes on remote compared to local HEAD ### Branches -
davfre revised this gist
Jul 8, 2021 . 1 changed file with 22 additions and 26 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,18 +6,18 @@ http://steveko.wordpress.com/2012/02/24/10-things-i-hate-about-git/ A GUI like http://sourcetreeapp.com is often helpful, but staying on the command line usually quicker. This is a list of the commands I use most frequently, listed by functional category: ### Current state `git status` list which (unstaged) files have changed `git diff` list (unstaged) changes to files `git log` list recent commits ### Adding files to repo `git add fn` stage file `git commit -m 'message'` commit file `git commit -am 'message'` add/commit all changes from all tracked files (no untracked files) in one go ### Undoing previous actions http://git-scm.com/book/en/Git-Tools-Rewriting-History `git reset filename` unstage file `git commit --amend -m 'message'` alter the last commit (add any staged files, new comment) @@ -27,22 +27,18 @@ http://git-scm.com/book/en/Git-Tools-Rewriting-History `git checkout -- cats.html index.html` Undo all changes that were made to files cats.html and index.html `git rebase --onto <commit-id>\^ <commit-id> HEAD` remove specific commit from repository. the \ in \^ is just an escape char to make zsh play nice and is not necessary if using bash. ### Remote repositories `git remote add origin [email protected]:example/petshop.git` add a remote repository `git push -u origin master` push current local repo to remote. -u sets it to default for the future `git remote -v show` show the available remote repositories that have been added `git remote show origin` show local<->remote branch tracking and sync status `git remote -v update` bring remote refs up to date (and -v show which branches were updated) `git pull` checkout and merge remote changes in one go `git fetch origin` update the local cache of the remote repository `git status -uno` will tell you whether the branch you are tracking is ahead, behind or has diverged. If it says nothing, the local and remote are the same. `git show-branch *master` will show you the commits in all of the branches whose names end in master (eg master and origin/master). `git log HEAD..origin/master --oneline` shows commit messages `git diff HEAD..origin/master` shows all changes on remote compared to local HEAD ### Branches @@ -52,27 +48,27 @@ http://git-scm.com/book/en/Git-Tools-Rewriting-History `git checkout -b branchname` create and checkout new branch in one go `git branch -d branchname` remove branch #### Merging branch back to master `git checkout master; git merge branchname;` conditions for fast-forward merge - nothing new on master between branch start/end points #### Branches on remote `git fetch origin``git branch -r` list remote branches (after a fetch) `git push origin :branchname` delete remote branch 'branchname' `git remote prune origin` clean up deleted remote branches (let's say someone else deleted a branch on the remote) `git remote show origin` show local<->remote branch tracking and sync status (duplicate info under "remote repositories") #### Push local branch to differently named remote branch. Eg Heroku only deploys master `git push heroku yourbranch:master` simple form `git push heroku-staging staging:master` (localBranchName:remoteBranchName) ### Tagging `git tag` list all tags `git checkout v0.0.1` checkout code `git tag -a v0.0.3` -m 'Version 0.0.3' add new tag `git push --tags` push new tags to remote ### Dealing with large files - keep them outside the repo on an ssh machine. http://stackoverflow.com/questions/540535/managing-large-binary-files-with-git http://git-annex.branchable.com/walkthrough/ #see ssh section -
davfre revised this gist
Jul 7, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,7 +36,7 @@ http://git-scm.com/book/en/Git-Tools-Rewriting-History `git remote -v update` bring remote refs up to date (and -v show which branches were updated) `git status -uno` will tell you whether the branch you are tracking is ahead, behind or has diverged. If it says nothing, the local and remote are the same. `git show-branch *master` will show you the commits in all of the branches whose names end in master (eg master and origin/master). `git remote show origin` show local<->remote branch tracking and sync status ### Examine changes on remote, without pulling them -
davfre revised this gist
Sep 27, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ The git command-line utility has plenty of inconsistencies http://steveko.wordpress.com/2012/02/24/10-things-i-hate-about-git/ A GUI like http://sourcetreeapp.com is often helpful, but staying on the command line usually quicker. This is a list of the commands I use most frequently, listed by functional category: ### current state `git status` list which (unstaged) files have changed -
davfre revised this gist
Sep 27, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -59,7 +59,7 @@ http://git-scm.com/book/en/Git-Tools-Rewriting-History `git fetch origin``git branch -r` list remote branches (after a fetch) `git push origin :branchname` delete remote branch 'branchname' `git remote prune origin` clean up deleted remote branches (let's say someone else deleted a branch on the remote) `git remote show origin` show local<->remote branch tracking and sync status (duplicate info under "remote repositories") #### push local branch to differently named remote branch. Eg Heroku only deploys master -
davfre renamed this gist
Jan 24, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
davfre renamed this gist
Jan 10, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
davfre revised this gist
Jan 8, 2014 . 1 changed file with 71 additions and 72 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,82 +6,81 @@ http://steveko.wordpress.com/2012/02/24/10-things-i-hate-about-git/ A GUI like http://sourcetreeapp.com is often helpful, but staying on the command line usually quicker. This is a list of the commands I use most frequently, listed by funcional category: ### current state `git status` list which (unstaged) files have changed `git diff` list (unstaged) changes to files `git log` list recent commits ### adding files to repo `git add fn` stage file `git commit -m 'message'` commit file `git commit -am 'message'` add/commit all changes from all tracked files (no untracked files) in one go ### undoing previous actions http://git-scm.com/book/en/Git-Tools-Rewriting-History `git reset filename` unstage file `git commit --amend -m 'message'` alter the last commit (add any staged files, new comment) `git reset --soft HEAD^` undo previous commit, put changes in staging `git reset --hard HEAD^` Undo last commit and all changes `git reset --hard HEAD^^` Undo two (^^) last commits and all changes `git checkout -- cats.html index.html` Undo all changes that were made to files cats.html and index.html `git rebase --onto <commit-id>\^ <commit-id> HEAD` remove specific commit from repository. the \ in \^ is just an escape char to make zsh play nice and is not necessary if using bash. ### remote repositories `git remote add origin [email protected]:example/petshop.git` add a remote repository `git push -u origin master` push current local repo to remote. -u sets it to default for the future `git remote -v show` show the available remote repositories that have been added `git pull` checkout and merge remote changes in one go `git fetch origin` update the local cache of the remote repository `git remote -v update` bring remote refs up to date (and -v show which branches were updated) `git status -uno` will tell you whether the branch you are tracking is ahead, behind or has diverged. If it says nothing, the local and remote are the same. `git show-branch *master` will show you the commits in all of the branches whose names end in master (eg master and origin/master). `git show remote origin` show local<->remote branch tracking and sync status ### Examine changes on remote, without pulling them `git fetch origin` `git log HEAD..origin/master --oneline` shows commit messages `git diff HEAD..origin/master` shows all changes on remote compared to local HEAD ### Branches `git branch` list currently existing branches `git branch [branchname]` create new branch `git checkout branchname` move to that branch `git checkout -b branchname` create and checkout new branch in one go `git branch -d branchname` remove branch #### merging branch back to master `git checkout master; git merge branchname;` conditions for fast-forward merge - nothing new on master between branch start/end points ### branches on remote `git fetch origin``git branch -r` list remote branches (after a fetch) `git push origin :branchname` delete remote branch 'branchname' `git remote prune origin` clean up deleted remote branches (let's say someone else deleted a branch on the remote) `git show remote origin` show local<->remote branch tracking and sync status (duplicate info under "remote repositories") #### push local branch to differently named remote branch. Eg Heroku only deploys master `git push heroku yourbranch:master` simple form `git push heroku-staging staging:master` (localBranchName:remoteBranchName) ### tagging `git tag` list all tags `git checkout v0.0.1` checkout code `git tag -a v0.0.3` -m 'Version 0.0.3' add new tag `git push --tags` push new tags to remote ### dealing with large files - keep them outside the repo on an ssh machine. http://stackoverflow.com/questions/540535/managing-large-binary-files-with-git http://git-annex.branchable.com/walkthrough/ #see ssh section `git annex add mybigfile` `git commit -m 'add mybigfile'` `git push myremote` `git annex copy --to myremote mybigfile` this command copies the actual content to myremote `git annex drop mybigfile` remove content from local repo `git annex get mybigfile` retrieve the content `git annex copy --from myremote mybigfile`specify the remote from which to get the file -
davfre revised this gist
Jan 8, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,9 +7,9 @@ A GUI like http://sourcetreeapp.com is often helpful, but staying on the command This is a list of the commands I use most frequently, listed by funcional category: ## current state `git status` list which (unstaged) files have changed `git diff` list (unstaged) changes to files `git log` list recent commits # adding files to repo -
davfre revised this gist
Jan 8, 2014 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,9 +8,7 @@ This is a list of the commands I use most frequently, listed by funcional catego ## current state `git status` list which (unstaged) files have changed `git diff` list (unstaged) changes to files `git log` list recent commits -
davfre revised this gist
Jan 8, 2014 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,10 +6,12 @@ http://steveko.wordpress.com/2012/02/24/10-things-i-hate-about-git/ A GUI like http://sourcetreeapp.com is often helpful, but staying on the command line usually quicker. This is a list of the commands I use most frequently, listed by funcional category: ## current state `git status` list which (unstaged) files have changed `git diff` list (unstaged) changes to files `git log` list recent commits # adding files to repo -
davfre revised this gist
Jan 8, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,9 +7,9 @@ A GUI like http://sourcetreeapp.com is often helpful, but staying on the command This is a list of the commands I use most frequently, listed by funcional category: # current state * `git status` list which (unstaged) files have changed - `git diff` list (unstaged) changes to files - `git log` list recent commits # adding files to repo -
davfre renamed this gist
Jan 8, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
davfre created this gist
Jan 8, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,87 @@ # git cheat-sheet The git command-line utility has plenty of inconsistencies http://steveko.wordpress.com/2012/02/24/10-things-i-hate-about-git/ A GUI like http://sourcetreeapp.com is often helpful, but staying on the command line usually quicker. This is a list of the commands I use most frequently, listed by funcional category: # current state `git status` list which (unstaged) files have changed `git diff` list (unstaged) changes to files `git log` list recent commits # adding files to repo `git add fn` stage file `git commit -m 'message'` commit file `git commit -am 'message'` add/commit all changes from all tracked files (no untracked files) in one go #undoing previous actions http://git-scm.com/book/en/Git-Tools-Rewriting-History `git reset filename` unstage file `git commit --amend -m 'message'` alter the last commit (add any staged files, new comment) `git reset --soft HEAD^` undo previous commit, put changes in staging `git reset --hard HEAD^` Undo last commit and all changes `git reset --hard HEAD^^` Undo two (^^) last commits and all changes `git checkout -- cats.html index.html` Undo all changes that were made to files cats.html and index.html git rebase --onto <commit-id>\^ <commit-id> HEAD remove specific commit from repository. the \ in \^ is just an escape char to make zsh play nice and is not necessary if using bash. # remote repositories `git remote add origin [email protected]:example/petshop.git` add a remote repository `git push -u origin master` push current local repo to remote. -u sets it to default for the future `git remote -v show` show the available remote repositories that have been added `git pull` checkout and merge remote changes in one go `git fetch origin` update the local cache of the remote repository `git remote -v update` bring remote refs up to date (and -v show which branches were updated) `git status -uno` will tell you whether the branch you are tracking is ahead, behind or has diverged. If it says nothing, the local and remote are the same. `git show-branch *master` will show you the commits in all of the branches whose names end in master (eg master and origin/master). `git show remote origin` show local<->remote branch tracking and sync status # Examine changes on remote, without pulling them git fetch origin `git log HEAD..origin/master --oneline` shows commit messages `git diff HEAD..origin/master` shows all changes on remote compared to local HEAD # Branches `git branch` list currently existing branches `git branch [branchname]` create new branch `git checkout branchname` move to that branch `git checkout -b branchname` create and checkout new branch in one go `git branch -d branchname` remove branch ## merging branch back to master git checkout master; git merge branchname; #conditions for fast-forward merge - nothing new on master between branch start/end points # branches on remote `git fetch origin``git branch -r` list remote branches (after a fetch) `git push origin :branchname` delete remote branch 'branchname' `git remote prune origin` clean up deleted remote branches (let's say someone else deleted a branch on the remote) `git show remote origin` show local<->remote branch tracking and sync status (duplicate info under "remote repositories") ## push local branch to differently named remote branch. Eg Heroku only deploys master `git push heroku yourbranch:master` simple form `git push heroku-staging staging:master` (localBranchName:remoteBranchName) # tagging `git tag` list all tags `git checkout v0.0.1` checkout code `git tag -a v0.0.3` -m 'Version 0.0.3' add new tag `git push --tags` push new tags to remote # dealing with large files - keep them outside the repo on an ssh machine. http://stackoverflow.com/questions/540535/managing-large-binary-files-with-git http://git-annex.branchable.com/walkthrough/ #see ssh section `git annex add mybigfile` `git commit -m 'add mybigfile'` `git push myremote` `git annex copy --to myremote mybigfile` this command copies the actual content to myremote `git annex drop mybigfile` remove content from local repo `git annex get mybigfile` retrieve the content `git annex copy --from myremote mybigfile`specify the remote from which to get the file