Skip to content

Instantly share code, notes, and snippets.

@jairzh
Created May 26, 2013 09:19
Show Gist options
  • Save jairzh/5652183 to your computer and use it in GitHub Desktop.
Save jairzh/5652183 to your computer and use it in GitHub Desktop.
Git Useful commands
  1. 比较两次提交之间的文件,只显示文件名

    $ git diff --stat
  2. Git cherry-pick 和 rebase 的混合用法

    $ git checkout master
    $ git cherry-pick D
    $ git cherry-pick F
    $ git checkout topic
    $ git rebase master
  3. Removing Git Tag On Remote Repository

    $ git push origin :refs/tags/<mytag>
  4. Check the conflict, but do not merge branch

    # In the master branch
    $ git merge dev --no-ff --no-commit  git merge —abort
  5. Removing the Remote Branch

    $ git push origin :branch_name
  6. How many lines of code were added/changed by one person

    $ git log --shortstat --author "jair" --since "2012-01-01" --until "2013-09-01" | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}’
  7. Change commit author at one specific commit

    $ git commit --amend --author="Author Name <email@address.com>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment