如何查看一个文件的历史记录:
gitk filename //调用外部工具查看历史,非常详细
git diff filename //查看文件的改动
git log filename //只能查看这个文件的log
如何设置自动merge:
当向Xcode添加,删除文件时,.pbxproj文件总是需要手动merge,而且一般是同时留下双方的改动。我们可以可以设置自动merge来解决这个问题。
在git的root文件夹下增加后缀为..gitattributes的文件,在文件中添加
*.pbxproj binary merge=union
则,git会自动以二进制的方式把双方的改动同时保存下来,这会大大减少手动merge的时间。
同时,如果双方同时改动.pbxproj文件的相同字段时也没有问题。(亲测过-- 好像有问题,不推荐使用)
Ref: Xcode and git: bridging the gap
- git fetch --prune -p, --prune After fetching, remove any remote-tracking branches which no longer exist on the remote.
修改最近一次的commit message:
git commit --amend -m "new message"
查看最近修改的branch:
git for-each-ref --sort=-committerdate --format='%(committerdate:short) %(refname)' refs/heads refs/remotes