2016-05-28

2016-05-28

[16-10-17]ignore已经被git track的文件,并删除远程分支上对应的文件
[16-7-12]fork的项目如何与原项目的保持一致更新改动
[16-7-10]以某一分支为基础创建新分支
[16-5-28]避免merge commit

[16-10-17]ignore已经被git track的文件,并删除远程分支上对应的文件
git rm --cached file-name-should-be.ignote
git commit -m "删除文件"
# 别忘了改动.gitignore文件
[16-7-12]fork的项目如何与原项目的保持一致更新改动

在github上fork项目之后做了自己的改动,或会提交pull request给原项目,也有可能不会提交,但是是用fork的项目进行开发时,希望时刻能把原项目的更新到fork项目,可以用以下方法,看这个stackover的问题有更加详细的说明

# Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git

# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:
git fetch upstream

# Make sure that you're on your master branch:
git checkout master

# Rewrite your master branch so that any commits of yours that
# aren't already in upstream/master are replayed on top of that
# other branch:
git rebase upstream/master
# push the update to your repo after resolve the CONFLICT
git push -f origin master
[16-7-10]以某一分支为基础创建新分支
git checkout -b branch_base_on_b1 b1
[16-5-28]避免merge commit

每次本地分支与远程分支发生冲突时,如果简单通过git pull -> git push的步骤来提交改动,不管两个版本有没有冲突,都会产生一个merge commit,一般来说,当两个版本直接没有冲突时,使用git pull -rebase就可以避免merge commit

关于使用git pull -rebase还有小技巧,详细可以看看这篇文章