Skip to content

Instantly share code, notes, and snippets.

@dmi3y
Last active May 21, 2021 16:49
Show Gist options
  • Select an option

  • Save dmi3y/7679280 to your computer and use it in GitHub Desktop.

Select an option

Save dmi3y/7679280 to your computer and use it in GitHub Desktop.

Revisions

  1. dmi3y revised this gist Nov 29, 2018. 1 changed file with 9 additions and 9 deletions.
    18 changes: 9 additions & 9 deletions gittipsandtricks.md
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ git update-index --assume-unchanged config/database.yml
    git update-index --skip-worktree


    #[ Change previous commit author](http://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit)
    # [Change previous commit author](http://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit)
    git rebase -i <earliercommit>
    git commit --amend --author="Author Name <[email protected]>"

    @@ -19,42 +19,42 @@ git checkout --track origin/daves_branch

    git push -u origin experimental

    #[Copy-paste from one branch to another](http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/)
    # [Copy-paste from one branch to another](http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/)

    git checkout source_branch <paths>...

    #[Rename local branch](http://stackoverflow.com/questions/6591213/how-to-rename-local-branch)
    # [Rename local branch](http://stackoverflow.com/questions/6591213/how-to-rename-local-branch)

    git branch -m <oldname> <newname>
    git branch -m <newname>


    #[Add remote repo](http://stackoverflow.com/questions/15010973/adding-a-remote-repo-git-add-remote-beanstalk)
    # [Add remote repo](http://stackoverflow.com/questions/15010973/adding-a-remote-repo-git-add-remote-beanstalk)

    git remote add &lt;alias&gt; &lt;remote path&gt;
    git remote -v

    ##[Add upstream](https://help.github.com/articles/fork-a-repo/)
    ## [Add upstream](https://help.github.com/articles/fork-a-repo/)

    git remote add upstream &lt;path&gt;

    #[Remove commit](http://stackoverflow.com/questions/4850717/how-to-cancel-a-local-git-commit)
    # [Remove commit](http://stackoverflow.com/questions/4850717/how-to-cancel-a-local-git-commit)

    git reset --hard HEAD~1
    git reset HEAD^

    HEAD^ same as HEAD~1

    #[Update branchs list from the remote](https://junaidpven.wordpress.com/2011/12/29/how-to-update-remote-branch-list-on-local-machine/)
    # [Update branchs list from the remote](https://junaidpven.wordpress.com/2011/12/29/how-to-update-remote-branch-list-on-local-machine/)

    git remote update origin --prune

    #[Delete remote branch](http://stackoverflow.com/questions/2003505/delete-a-git-branch-both-locally-and-remotely)
    # [Delete remote branch](http://stackoverflow.com/questions/2003505/delete-a-git-branch-both-locally-and-remotely)

    git push <remote> --delete <branchName>
    git push <remote> :<branchName>

    #[Cherry piking](http://stackoverflow.com/questions/1670970/how-to-cherry-pick-multiple-commits)
    # [Cherry piking](http://stackoverflow.com/questions/1670970/how-to-cherry-pick-multiple-commits)

    git cherry-pick X
    git cherry-pick A..B #A should be older than B, A is excluded B is included
  2. dmi3y revised this gist Nov 29, 2018. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions gittipsandtricks.md
    Original file line number Diff line number Diff line change
    @@ -1,21 +1,21 @@
    #[Ignore tracked files](http://stackoverflow.com/questions/655243/ignore-modified-but-not-committed-files-in-git)
    # [Ignore tracked files](http://stackoverflow.com/questions/655243/ignore-modified-but-not-committed-files-in-git)

    git update-index --assume-unchanged dir-im-removing/
    git update-index --assume-unchanged config/database.yml
    git update-index --skip-worktree


    #[Change previous commit author](http://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit)
    #[ Change previous commit author](http://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit)
    git rebase -i &lt;earliercommit&gt;
    git commit --amend --author="Author Name &lt;[email protected]&gt;"

    https://groups.google.com/forum/#!topic/git-users/a6zEdEQSpHw
    git commit --amend -C HEAD --reset-author

    #[Fetch branch from remote repo](http://stackoverflow.com/questions/9537392/git-fetch-remote-branch)
    # [Fetch branch from remote repo](http://stackoverflow.com/questions/9537392/git-fetch-remote-branch)
    git checkout --track origin/daves_branch

    #[Push local branch to remote repo](http://stackoverflow.com/questions/805222/how-to-copy-a-local-git-branch-to-a-remote-repo)
    # [Push local branch to remote repo](http://stackoverflow.com/questions/805222/how-to-copy-a-local-git-branch-to-a-remote-repo)

    git push -u origin experimental

  3. dmi3y revised this gist Jun 1, 2015. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion gittipsandtricks.md
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,6 @@ git checkout source_branch &lt;paths&gt;...
    #[Rename local branch](http://stackoverflow.com/questions/6591213/how-to-rename-local-branch)

    git branch -m <oldname> <newname>
    or for current working branch
    git branch -m <newname>


  4. dmi3y revised this gist Jun 1, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gittipsandtricks.md
    Original file line number Diff line number Diff line change
    @@ -25,8 +25,8 @@ git checkout source_branch &lt;paths&gt;...

    #[Rename local branch](http://stackoverflow.com/questions/6591213/how-to-rename-local-branch)

    git branch -m <oldname> <newname>
    or for current working branch
    git branch -m <oldname> <newname>
    or for current working branch
    git branch -m <newname>


  5. dmi3y revised this gist Jun 1, 2015. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions gittipsandtricks.md
    Original file line number Diff line number Diff line change
    @@ -23,6 +23,13 @@ git push -u origin experimental

    git checkout source_branch &lt;paths&gt;...

    #[Rename local branch](http://stackoverflow.com/questions/6591213/how-to-rename-local-branch)

    git branch -m <oldname> <newname>
    or for current working branch
    git branch -m <newname>


    #[Add remote repo](http://stackoverflow.com/questions/15010973/adding-a-remote-repo-git-add-remote-beanstalk)

    git remote add &lt;alias&gt; &lt;remote path&gt;
  6. dmi3y revised this gist Apr 2, 2015. 1 changed file with 12 additions and 1 deletion.
    13 changes: 12 additions & 1 deletion gittipsandtricks.md
    Original file line number Diff line number Diff line change
    @@ -41,4 +41,15 @@ HEAD^ same as HEAD~1

    #[Update branchs list from the remote](https://junaidpven.wordpress.com/2011/12/29/how-to-update-remote-branch-list-on-local-machine/)

    git remote update origin --prune
    git remote update origin --prune

    #[Delete remote branch](http://stackoverflow.com/questions/2003505/delete-a-git-branch-both-locally-and-remotely)

    git push <remote> --delete <branchName>
    git push <remote> :<branchName>

    #[Cherry piking](http://stackoverflow.com/questions/1670970/how-to-cherry-pick-multiple-commits)

    git cherry-pick X
    git cherry-pick A..B #A should be older than B, A is excluded B is included
    git cherry-pick A^..B # including A
  7. dmi3y revised this gist Feb 20, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gittipsandtricks.md
    Original file line number Diff line number Diff line change
    @@ -39,6 +39,6 @@ git reset HEAD^

    HEAD^ same as HEAD~1

    #[Update branch lists from the remote](https://junaidpven.wordpress.com/2011/12/29/how-to-update-remote-branch-list-on-local-machine/)
    #[Update branchs list from the remote](https://junaidpven.wordpress.com/2011/12/29/how-to-update-remote-branch-list-on-local-machine/)

    git remote update origin --prune
  8. dmi3y revised this gist Feb 20, 2015. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion gittipsandtricks.md
    Original file line number Diff line number Diff line change
    @@ -37,4 +37,8 @@ git remote add upstream &lt;path&gt;
    git reset --hard HEAD~1
    git reset HEAD^

    HEAD^ same as HEAD~1
    HEAD^ same as HEAD~1

    #[Update branch lists from the remote](https://junaidpven.wordpress.com/2011/12/29/how-to-update-remote-branch-list-on-local-machine/)

    git remote update origin --prune
  9. dmi3y revised this gist Nov 19, 2014. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions gittipsandtricks.md
    Original file line number Diff line number Diff line change
    @@ -28,6 +28,10 @@ git checkout source_branch &lt;paths&gt;...
    git remote add &lt;alias&gt; &lt;remote path&gt;
    git remote -v

    ##[Add upstream](https://help.github.com/articles/fork-a-repo/)

    git remote add upstream &lt;path&gt;

    #[Remove commit](http://stackoverflow.com/questions/4850717/how-to-cancel-a-local-git-commit)

    git reset --hard HEAD~1
  10. dmi3y revised this gist May 12, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gittipsandtricks.md
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ git checkout --track origin/daves_branch

    #[Push local branch to remote repo](http://stackoverflow.com/questions/805222/how-to-copy-a-local-git-branch-to-a-remote-repo)

    git push origin experimental
    git push -u origin experimental

    #[Copy-paste from one branch to another](http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/)

  11. dmi3y revised this gist Apr 14, 2014. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gittipsandtricks.md
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,9 @@ git commit --amend --author="Author Name &lt;[email protected]&gt;"
    https://groups.google.com/forum/#!topic/git-users/a6zEdEQSpHw
    git commit --amend -C HEAD --reset-author

    #[Fetch branch from remote repo](http://stackoverflow.com/questions/9537392/git-fetch-remote-branch)
    git checkout --track origin/daves_branch

    #[Push local branch to remote repo](http://stackoverflow.com/questions/805222/how-to-copy-a-local-git-branch-to-a-remote-repo)

    git push origin experimental
  12. dmi3y revised this gist Mar 16, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gittipsandtricks.md
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,7 @@ git remote -v

    #[Remove commit](http://stackoverflow.com/questions/4850717/how-to-cancel-a-local-git-commit)

    git reset --hard HEAD~1
    git reset --hard HEAD~1
    git reset HEAD^

    HEAD^ same as HEAD~1
  13. dmi3y revised this gist Mar 16, 2014. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion gittipsandtricks.md
    Original file line number Diff line number Diff line change
    @@ -23,4 +23,11 @@ git checkout source_branch &lt;paths&gt;...
    #[Add remote repo](http://stackoverflow.com/questions/15010973/adding-a-remote-repo-git-add-remote-beanstalk)

    git remote add &lt;alias&gt; &lt;remote path&gt;
    git remote -v
    git remote -v

    #[Remove commit](http://stackoverflow.com/questions/4850717/how-to-cancel-a-local-git-commit)

    git reset --hard HEAD~1
    git reset HEAD^

    HEAD^ same as HEAD~1
  14. dmi3y revised this gist Dec 16, 2013. 1 changed file with 7 additions and 2 deletions.
    9 changes: 7 additions & 2 deletions gittipsandtricks.md
    Original file line number Diff line number Diff line change
    @@ -16,6 +16,11 @@ git commit --amend -C HEAD --reset-author

    git push origin experimental

    #[Copy Paste from one branch to another](http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/)
    #[Copy-paste from one branch to another](http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/)

    git checkout source_branch &lt;paths&gt;...
    git checkout source_branch &lt;paths&gt;...

    #[Add remote repo](http://stackoverflow.com/questions/15010973/adding-a-remote-repo-git-add-remote-beanstalk)

    git remote add &lt;alias&gt; &lt;remote path&gt;
    git remote -v
  15. dmi3y revised this gist Dec 12, 2013. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions gittipsandtricks.md
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,10 @@ git commit --amend --author="Author Name &lt;[email protected]&gt;"
    https://groups.google.com/forum/#!topic/git-users/a6zEdEQSpHw
    git commit --amend -C HEAD --reset-author

    #[Push local branch to remote repo](http://stackoverflow.com/questions/805222/how-to-copy-a-local-git-branch-to-a-remote-repo)

    git push origin experimental

    #[Copy Paste from one branch to another](http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/)

    git checkout source_branch &lt;paths&gt;...
  16. dmi3y renamed this gist Dec 12, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  17. dmi3y renamed this gist Dec 12, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  18. dmi3y revised this gist Dec 12, 2013. No changes.
  19. dmi3y revised this gist Dec 12, 2013. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -10,4 +10,8 @@ git rebase -i &lt;earliercommit&gt;
    git commit --amend --author="Author Name &lt;[email protected]&gt;"

    https://groups.google.com/forum/#!topic/git-users/a6zEdEQSpHw
    git commit --amend -C HEAD --reset-author
    git commit --amend -C HEAD --reset-author

    #[Copy Paste from one branch to another](http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/)

    git checkout source_branch &lt;paths&gt;...
  20. dmi3y revised this gist Dec 6, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -6,8 +6,8 @@ git update-index --skip-worktree


    #[Change previous commit author](http://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit)
    git rebase -i &gt;earliercommit&lt;
    git commit --amend --author="Author Name &gt;[email protected]&lt;"
    git rebase -i &lt;earliercommit&gt;
    git commit --amend --author="Author Name &lt;[email protected]&gt;"

    https://groups.google.com/forum/#!topic/git-users/a6zEdEQSpHw
    git commit --amend -C HEAD --reset-author
  21. dmi3y revised this gist Dec 6, 2013. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,8 @@ git update-index --skip-worktree


    #[Change previous commit author](http://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit)
    git rebase -i &gt;earliercommit&lt;
    git commit --amend --author="Author Name &gt;[email protected]&lt;"

    https://groups.google.com/forum/#!topic/git-users/a6zEdEQSpHw
    git rebase -i /earliercommit/
    git commit --amend --author="Author Name <&lt;>[email protected]<&gt;>"
    git commit --amend -C HEAD --reset-author
  22. dmi3y revised this gist Dec 6, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,6 @@ git update-index --skip-worktree


    #[Change previous commit author](http://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit)

    https://groups.google.com/forum/#!topic/git-users/a6zEdEQSpHw
    git rebase -i /earliercommit/
    git commit --amend --author="Author Name <[email protected]>"
    git commit --amend --author="Author Name <&lt;>[email protected]<&gt;>"
  23. dmi3y revised this gist Dec 6, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -7,5 +7,5 @@ git update-index --skip-worktree

    #[Change previous commit author](http://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit)

    git rebase -i <earliercommit>
    git rebase -i /earliercommit/
    git commit --amend --author="Author Name <[email protected]>"
  24. dmi3y revised this gist Dec 6, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ git update-index --assume-unchanged config/database.yml
    git update-index --skip-worktree


    #[Change Previous Commit Author](http://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit)
    #[Change previous commit author](http://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit)

    git rebase -i <earliercommit>
    git commit --amend --author="Author Name <[email protected]>"
  25. dmi3y revised this gist Dec 6, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -7,5 +7,5 @@ git update-index --skip-worktree

    #[Change Previous Commit Author](http://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit)

    git rebase -i <earliercommit>
    git rebase -i <earliercommit>
    git commit --amend --author="Author Name <[email protected]>"
  26. dmi3y revised this gist Dec 6, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ git update-index --assume-unchanged config/database.yml
    git update-index --skip-worktree


    #[Change Previous Commit Author}(http://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit)
    #[Change Previous Commit Author](http://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit)

    git rebase -i <earliercommit>
    git commit --amend --author="Author Name <[email protected]>"
  27. dmi3y revised this gist Dec 6, 2013. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,10 @@

    git update-index --assume-unchanged dir-im-removing/
    git update-index --assume-unchanged config/database.yml
    git update-index --skip-worktree
    git update-index --skip-worktree


    #[Change Previous Commit Author}(http://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit)

    git rebase -i <earliercommit>
    git commit --amend --author="Author Name <[email protected]>"
  28. dmi3y revised this gist Nov 27, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #[Ignore already commited files](http://stackoverflow.com/questions/655243/ignore-modified-but-not-committed-files-in-git)
    #[Ignore tracked files](http://stackoverflow.com/questions/655243/ignore-modified-but-not-committed-files-in-git)

    git update-index --assume-unchanged dir-im-removing/
    git update-index --assume-unchanged config/database.yml
  29. dmi3y revised this gist Nov 27, 2013. 1 changed file with 4 additions and 5 deletions.
    9 changes: 4 additions & 5 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    #Ignore already commited files
    #[Ignore already commited files](http://stackoverflow.com/questions/655243/ignore-modified-but-not-committed-files-in-git)

    http://stackoverflow.com/questions/655243/ignore-modified-but-not-committed-files-in-git
    git update-index --assume-unchanged dir-im-removing/
    git update-index --assume-unchanged config/database.yml
    git update-index --skip-worktree
    git update-index --assume-unchanged dir-im-removing/
    git update-index --assume-unchanged config/database.yml
    git update-index --skip-worktree
  30. dmi3y created this gist Nov 27, 2013.
    6 changes: 6 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    #Ignore already commited files

    http://stackoverflow.com/questions/655243/ignore-modified-but-not-committed-files-in-git
    git update-index --assume-unchanged dir-im-removing/
    git update-index --assume-unchanged config/database.yml
    git update-index --skip-worktree