Skip to content

Instantly share code, notes, and snippets.

@scott-joe
Last active June 21, 2016 17:46

Revisions

  1. scott-joe revised this gist Jun 21, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion useful git commands.md
    Original file line number Diff line number Diff line change
    @@ -46,7 +46,7 @@
    `git push --follow-tags`

    ###Checkout [latest tag](http://stackoverflow.com/questions/17414104/git-checkout-latest-tag)
    git checkout $(git describe --tags `git rev-list --tags --max-count=1`)
    git checkout $(git describe --tags `git rev-list --tags --max-count=1`)

    ###Remove a remote tag
    git tag -d [tagName]
  2. scott-joe revised this gist Jun 21, 2016. 1 changed file with 14 additions and 4 deletions.
    18 changes: 14 additions & 4 deletions useful git commands.md
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@
    `git reset --hard origin/master`

    ###Push non-master branch to Heroku
    `git push heroku branchName:master`
    `git push heroku [branchName]:master`

    `git push heroku +HEAD:master`

    @@ -38,6 +38,16 @@
    git commit -C ORIG_HEAD

    ###Rename branch locally and remote
    git branch -m old_branch new_branch
    git push origin :old_branch
    git push --set-upstream origin new_branch
    git branch -m old_branch [newBranchName]
    git push origin :[oldBranchName]
    git push --set-upstream origin [newBranchName]

    ###Push both commits and [annotated tags](http://stackoverflow.com/questions/5195859/push-a-tag-to-a-remote-repository-using-git)
    `git push --follow-tags`

    ###Checkout [latest tag](http://stackoverflow.com/questions/17414104/git-checkout-latest-tag)
    git checkout $(git describe --tags `git rev-list --tags --max-count=1`)

    ###Remove a remote tag
    git tag -d [tagName]
    git push origin :refs/tags/[tagName]
  3. scott-joe revised this gist Jun 20, 2016. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion useful git commands.md
    Original file line number Diff line number Diff line change
    @@ -35,4 +35,9 @@
    git reset --soft HEAD~
    << edit files as necessary >>
    git add [yourFiles]
    git commit -C ORIG_HEAD
    git commit -C ORIG_HEAD

    ###Rename branch locally and remote
    git branch -m old_branch new_branch
    git push origin :old_branch
    git push --set-upstream origin new_branch
  4. scott-joe revised this gist Jun 17, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion useful git commands.md
    Original file line number Diff line number Diff line change
    @@ -28,7 +28,7 @@
    `git push heroku +HEAD:master`

    ###Set a Heroku remote to an existing repo
    `heroku git:remote -a fuelux-components-staging`
    `heroku git:remote -a [heroku app name]`

    ###fix a local commit
    git commit -m "Something terribly misguided"
  5. scott-joe revised this gist Jun 16, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions useful git commands.md
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,7 @@

    ###Delete remote branch
    `git push origin --delete [branchName]`

    `git push origin :[branchName]`

    ###Prune local branches
  6. scott-joe revised this gist Jun 16, 2016. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions useful git commands.md
    Original file line number Diff line number Diff line change
    @@ -16,13 +16,19 @@

    ###Various resets
    `git reset --soft HEAD^`

    `git reset --hard HEAD`

    `git reset --hard origin/master`

    ###Push non-master branch to Heroku
    `git push heroku branchName:master`

    `git push heroku +HEAD:master`

    ###Set a Heroku remote to an existing repo
    `heroku git:remote -a fuelux-components-staging`

    ###fix a local commit
    git commit -m "Something terribly misguided"
    git reset --soft HEAD~
  7. scott-joe revised this gist Oct 27, 2015. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions useful git commands.md
    Original file line number Diff line number Diff line change
    @@ -24,8 +24,8 @@
    `git push heroku +HEAD:master`

    ###fix a local commit
    git commit -m "Something terribly misguided"
    git reset --soft HEAD~
    << edit files as necessary >>
    git add [yourFiles]
    git commit -C ORIG_HEAD
    git commit -m "Something terribly misguided"
    git reset --soft HEAD~
    << edit files as necessary >>
    git add [yourFiles]
    git commit -C ORIG_HEAD
  8. scott-joe revised this gist Oct 27, 2015. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions useful git commands.md
    Original file line number Diff line number Diff line change
    @@ -24,8 +24,8 @@
    `git push heroku +HEAD:master`

    ###fix a local commit
    ```git commit -m "Something terribly misguided"
    git reset --soft HEAD~
    << edit files as necessary >>
    git add [yourFiles]
    git commit -C ORIG_HEAD```
    git commit -m "Something terribly misguided"
    git reset --soft HEAD~
    << edit files as necessary >>
    git add [yourFiles]
    git commit -C ORIG_HEAD
  9. scott-joe revised this gist Oct 27, 2015. 1 changed file with 21 additions and 21 deletions.
    42 changes: 21 additions & 21 deletions useful git commands.md
    Original file line number Diff line number Diff line change
    @@ -1,31 +1,31 @@
    #Create and checkout a new branch
    git checkout -b [branchName]
    ###Create and checkout a new branch
    `git checkout -b [branchName]`

    #Checkout a remote branch
    git checkout -b [localBranchName] origin/[remoteBranchName]
    ###Checkout a remote branch
    `git checkout -b [localBranchName] origin/[remoteBranchName]`

    #Push local branch to remote
    git push -u origin [branchName]
    ###Push local branch to remote
    `git push -u origin [branchName]`

    #Delete remote branch
    git push origin --delete [branchName]
    git push origin :[branchName]
    ###Delete remote branch
    `git push origin --delete [branchName]`
    `git push origin :[branchName]`

    #Prune local branches
    git remote prune origin
    ###Prune local branches
    `git remote prune origin`

    #Various resets
    git reset --soft HEAD^
    git reset --hard HEAD
    git reset --hard origin/master
    ###Various resets
    `git reset --soft HEAD^`
    `git reset --hard HEAD`
    `git reset --hard origin/master`

    #Push non-master branch to Heroku
    git push heroku branchName:master
    git push heroku +HEAD:master
    ###Push non-master branch to Heroku
    `git push heroku branchName:master`
    `git push heroku +HEAD:master`

    #fix a local commit
    git commit -m "Something terribly misguided"
    ###fix a local commit
    ```git commit -m "Something terribly misguided"
    git reset --soft HEAD~
    << edit files as necessary >>
    git add [yourFiles]
    git commit -C ORIG_HEAD
    git commit -C ORIG_HEAD```
  10. scott-joe renamed this gist Oct 27, 2015. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions useful git commands.sh → useful git commands.md
    Original file line number Diff line number Diff line change
    @@ -24,8 +24,8 @@ git push heroku branchName:master
    git push heroku +HEAD:master

    #fix a local commit
    $ git commit -m "Something terribly misguided"
    $ git reset --soft HEAD~
    git commit -m "Something terribly misguided"
    git reset --soft HEAD~
    << edit files as necessary >>
    $ git add [yourFiles]
    $ git commit -C ORIG_HEAD
    git add [yourFiles]
    git commit -C ORIG_HEAD
  11. scott-joe revised this gist Oct 27, 2015. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion useful git commands.sh
    Original file line number Diff line number Diff line change
    @@ -21,4 +21,11 @@ git reset --hard origin/master

    #Push non-master branch to Heroku
    git push heroku branchName:master
    git push heroku +HEAD:master
    git push heroku +HEAD:master

    #fix a local commit
    $ git commit -m "Something terribly misguided"
    $ git reset --soft HEAD~
    << edit files as necessary >>
    $ git add [yourFiles]
    $ git commit -C ORIG_HEAD
  12. scott-joe revised this gist Jan 28, 2015. 2 changed files with 24 additions and 20 deletions.
    20 changes: 0 additions & 20 deletions Useful git commands
    Original file line number Diff line number Diff line change
    @@ -1,20 +0,0 @@
    # Git commands I always forget

    - Create and checkout a new branch
    - `git checkout -b branchName`
    - Checkout a remote branch
    - `git checkout -b localBranchName origin/remoteBranchName`
    - Push local branch to remote
    - `git push -u origin branchName`
    - Delete remote branch
    - `git push origin --delete branchName`
    - `git push origin :branchName`
    - Prune local branches
    - `git remote prune origin`
    - Various resets
    - `git reset --soft HEAD^`
    - `git reset --hard HEAD`
    - `git reset --hard origin/master`
    - Push non-master branch to Heroku
    - `git push heroku branchName:master`
    - `git push heroku +HEAD:master`
    24 changes: 24 additions & 0 deletions useful git commands.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #Create and checkout a new branch
    git checkout -b [branchName]

    #Checkout a remote branch
    git checkout -b [localBranchName] origin/[remoteBranchName]

    #Push local branch to remote
    git push -u origin [branchName]

    #Delete remote branch
    git push origin --delete [branchName]
    git push origin :[branchName]

    #Prune local branches
    git remote prune origin

    #Various resets
    git reset --soft HEAD^
    git reset --hard HEAD
    git reset --hard origin/master

    #Push non-master branch to Heroku
    git push heroku branchName:master
    git push heroku +HEAD:master
  13. scott-joe created this gist Jan 28, 2015.
    20 changes: 20 additions & 0 deletions Useful git commands
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    # Git commands I always forget

    - Create and checkout a new branch
    - `git checkout -b branchName`
    - Checkout a remote branch
    - `git checkout -b localBranchName origin/remoteBranchName`
    - Push local branch to remote
    - `git push -u origin branchName`
    - Delete remote branch
    - `git push origin --delete branchName`
    - `git push origin :branchName`
    - Prune local branches
    - `git remote prune origin`
    - Various resets
    - `git reset --soft HEAD^`
    - `git reset --hard HEAD`
    - `git reset --hard origin/master`
    - Push non-master branch to Heroku
    - `git push heroku branchName:master`
    - `git push heroku +HEAD:master`