几条很有用的git命令

上帝让好孩子成为好孩子,本身就是对好孩子的最佳奖赏

导出最后一次提交修改过的文件

1
git archive -o ../updated.zip HEAD $(git diff --name-only HEAD^)

导出两次提交之间修改过的文件

1
git archive -o ../latest.zip NEW_COMMIT_ID_HERE $(git diff --name-only OLD_COMMIT_ID_HERE NEW_COMMIT_ID_HERE)
1
git archive -o ../latest.zip 4c1ed49e9be1223d6c22e65fa6fc10e5fbe46441 $(git diff --name-only 192f0de1dda8b194c8d75c1bd6c6cab3154de1ad 4c1ed49e9be1223d6c22e65fa6fc10e5fbe46441)

克隆一个特定的远程分支

1
2
3
git init 
git remote add -t BRANCH_NAME_HERE -f origin REMOTE_REPO_URL_PATH_HERE
git checkout BRANCH_NAME_HERE

启动一个无历史的新分支

1
git checkout --orphan NEW_BRANCH_NAME_HERE

http://www.cnblogs.com/lhb25/p/10-useful-advanced-git-commands.html