记录git用的比较少容易忘的命令
为空目录批量添加.gitignore
find $DESTDIR -type d -empty -exec touch {}/.gitignore \;
查看\修改文件权限
查看当前权限
[localhost]$ git ls-files --stage run.sh
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 run.sh
增加可执行权限
[localhost]$ git update-index --chmod +x run.sh
查看当前权限
[localhost]$ git ls-files --stage run.sh
100755 79faae1187e6b365412bb30d4146007c3e8f2abe 0 run.sh
补丁
基于暂存区:
生成补丁
git diff > test.patch
合入补丁
git apply test.patch
基于commit
git format-patch
git am
分支
推送本地分支到远程分支
git push <远程主机名> <本地分支名>:<远程分支名>
git push origin master:master
关联远程分支
git branch --set-upstream-to=origin/<远程分支名> <本地分支名>
修改分支名称
git branch -m br_rename_old br_rename_new
合并
从另一分支合并commit到当前分支
git cherry-pick 要合并的commit ID
将当前分支的多个commit合并为一个,有几个commit要合并n就是几
git rebase -i HEAD~n
持续更新?