Gitosis
.7 Git on the Server – Gitosis
gitosis 使用笔记
权限管理工具,通过一个特殊的仓库(gitosis-admin.git)对 Git 权限进行管理;
# git stash
git-stash,暂存当前工作目录中的修改;
当切换分支时,提示 error Your local changes to the following files would be overwritten by checkout …
git stash git checkout mBranch git stash pop
只暂存部分文件
Stash only one file out of multiple files that have changed with Git? – Stack Overflow
# 1) 将无需暂存的文件保存到索引中 git add 'file1' # 2)执行 stash 命令,并保存索引 git stash --keep-index
# git merge
分支与合并
Why does pulling sometimes make me create a commit?
Git Merge Strategy Options and Examples
git pull = git fetch + git merge,如果无法 fast-forwarding,则进行传统合并(提交具有两个父提交),此时则会要去输入合并说明;
处理 Git 冲突
日常处理冲突的办法是手动修改冲突文件,Git/Resolve Merge Conflicts 解释了如何处理大批量的冲突问题;
合并:两个无关分支的合并
Git refusing to merge unrelated histories on rebase – Stack Overflow
使用 –allow-unrelated-histories 选项,可以合并两个无关分支;
# git rebase
很并多个提交为单个提交(以简化变更历史)
rebase – Squash my last X commits together using Git – Stack Overflow
git rebase -i '<after-this-commit>' # <after-this-commit> is commit X+1 i.e. parent of the oldest commit you want to squash # 根据提示修改前缀为 fixup 或 sqaush 以进行“合并”
# git cherry-pick
Intro to Cherry Picking with Git
从其他分支复制提交,到当前分支
git – How to copy commits from one branch to another? – Stack Overflow
git checkout "target-branch" git cherry-pick '<commit id from other branch>' git push origin "target-branch"
# git show
git-show – Show various types of objects
显示已经删除文件的内容:
git show HEAD^:path/to/file
替换 git:// 为 https:// 协议
npm git protocol dependencies – Stack Overflow
git config --global url."https://github.com/".insteadOf git@github.com: git config --global url."https://".insteadOf git://
# R100
git diff –name-status : What does R100 mean?
在终端显示 Unicode 字符
How to make Git properly display UTF-8 encoded pathnames in the console window?
在 Git 中,通常是用八进制来显示 Unicode 字符,形如”\nnn\nnn…“,使用过 Git Bash 的人应该会遇到这种情况;
在 Git 1.7.10 中,开始支持 Unicode 字符。执行如下命令来显示 Unicode 字符(禁止以八进制来显示 Unicode 字符):
# git config core.quotepath off # 作用于当前仓库 # git config --global core.quotepath off # 作用于全局,即所有仓库
注意事项,虽然如上设置能够使 Git 输出中文,但是中文的显示还要终端的支持;
待办事项
TODO 同分支的多个提交是如何排序的
应该是我理解错了,虽然分支之间可以合并,但是提交并没有合并(就是说「提交」没有合入「分支」,「提交」的之间的引用关系是保持不变的。)。而「合并」这一动作只是为了生成新的文件,同时创建了一个「提交」;
TODO ! 如何将提交插入指定的位置
参考文献
Create a tag in a GitHub repository
How to view a file at a specific commit in git? – SysTutorials