4/7/2014 - 7:58 AM


git ref

fork项目 同步 upstream 分支

  • git fetch upstream
  • git checkout upstream/big/develop
  • git checkout -b big/develop

fork 项目 rebase 分支

  • 每次提交pr前进行下面操作.
  • git remote update upstream
  • git rebase upstream/{branch name} 一定要切换到到{branch name}所指定的branch

维护自己的 nginx fork

  1. nginx 直接用官方 git 镜像 base, master/develop
  2. 我们修改的代码按不同特性建立特性分支, 基于 develop 开 feature 分支出来(如果特性长期存在, 就需要一直维护这些分支)
  3. 升级 nginx 代码也单独从 develop 开分支出来, 进行兼容性升级. (其他特性分支后续开发, 反向从 develop merge 进行融合继续开发).
  4. 如果后续某个特性要产生 patch 直接切换到那个特性分支下, 和 nginx 某个官方 tag 版本进行 diff 就能出来.
  5. 特性分支也可以有 tag, 表示对应哪个 nginx 主版本, 这样方便产生不同版本对应的 patch.



首先维护的 NGINX 分支是 OpenResty 支持的最新的 NGINX 分支,目前是 release-1.9.15,从此分支 checkout 出来作为咱们要进行二次开发的主分支




  1. merge 需要升级到的 NGINX release
  2. 必要时要进行单元测试


  1. merge 需要升级到的 NGINX release
  2. merge 特性分支



删除最近3次 commit

  • git reset --hard HEAD~3



  1. 切换到develop分支
  2. 如果本地有未提交的修改, 那么git stash.
  3. git br aa
  4. git flow init -> branch name for production releases: aa, 后面全回车, 使用默认值.
  5. git flow feature start srs_meta
  6. git stash pop
  7. do some changes
  8. git push
  9. 页面上提交合并到develop分支.

git rebase 2

  • 切到在我的分支.
  • tig 查看我的分支有哪些我的修改. 查看有多少commit
  • git rebase -i HEAD~12
  • 将第一行前面加r, 后面前面加f
  • git fetch origin -p
  • git rebase origin/develop
  • tig 我的在 develop 最前
  • git push -f

git rebase

  • git fetch origin -p
  • git log
  • git rebase origin/develop
  • git rebase -i HEAD~19
  • git reflog
  • tig
  • git diff origin/feature/srs_meta
  • git diff origin/feature/srs_meta nginx/app
  • git push origin feature/srs_meta:feature/srs


  • vim ~/.gitignore_global
  • git config --global core.excludesfile ~/.gitignore_global

git commit log


  • git remote set-url origin xxx


  • git tag -l 显示所有tag名称
  • git checkout tags/<tag_name> 切换到<tag_name>


  • git checkout -- hello.rb


  1. repo - Android的git多版本库管理
  2. Gerrit - Android的集中式管理
  3. Topgit - 定制开发, git相比Mercurial的优势
  4. git svn -
  5. Mercurial - go语言使用的分布式管理工具
  6. Gitosis
  7. Gitolite
  8. Gistore
  9. tig



  1. pySvnManager
  2. Freemind-MMX


  • Git is at its heart very stupid simple.

the name

  • Linux Torvalds has quipped about the name "git", which is British English slang for a stupid or unpleasant person.
  • I'm an egotistical bastard, and I name all my projects after myself. Fist Linux, now git.
  • In many ways you can just see git as a filesystem - it's content-addressable, and it has a notion of versioning, but I really designed it coming at the problem from the viewpoint of a filesystem person(hey, kernels is what I do), and I actually have absolutely zero interest in creating a traditional SCM system.



  • linux下 sha1 filename
  • mac下 shasum filename




1. 创建~/.gitignore
2. git config --global core.excludesfile ~/.gitignore


20:12 Seveas: Akagi201: likely !newline crap
20:12 Seveas: hmm !crlf
20:12 gitinfo: to fix problems with line endings on different platforms, check out http://line-endings.gitrecipes.de/
20:12 Akagi201: thans both!
20:13 jast: unfortunately the solution outlined there really only works if you've got push access (and can make decisions about stuff like this)
20:13 Seveas: isn't there some global config you can use?
20:14 Seveas: (not on windows, so I've never had problems with this myself)
20:14 jast: another option is to stick your fingers in your ears and go "LALALALA" by doing something like 'git config core.autocrlf false'
20:14 jast: (which is the right setting anyway, IMO)
20:14 Virox: Jusat tried a merge and I got a few conflicts. One of them is "both modified:      someFile.txt" I've tried git checkout --ours someFile.txt with but it's still listed there. What should I do to basically use my version?
20:15 jast: Virox: just do a 'git add' on the file to confirm you consider it resolved
20:15 Virox: I was just a bit worried about that. I'll give it a shot though
20:15 jast: if you're satisfied with what's in the file now, that is absolutely the right thing to do
20:15 jast: it's just bad if the file(s) you're adding contain garbage :)

git clone 失败