Git 常用command简介(git解决冲突)

Git is a distributed version control system originally developed to manage Linux source codes.

Using Git, you can easily view the revision history of your source code to track changes and easily go back in time to learn about the differences between different versions of your files.

Gerrit provides web based code review and repository management for the Git version control system.

git cloneClones a repository into a newly created directory

git push and git pull: 

git push updates remote refs using local refs, while sending objects necessary to complete the given refs.

git pull incorporates changes from a remote repository into the current branch

git pull = git fetch + git merge

git add, git commit, git reset, git checkout

git mergeJoin two or more development histories together

git rebase:  Reapply commits on top of another base tip

Git merge VS git rebase

 

特别说明一下git cherry-pick命令:

cherry-pick可以将一个git patch cherry-pick到另外一个分支(branch),另外如果gerrit上有很多还没有merge的gerrit的时候,你想在你的本地获取这个patch的时候可以用cherry-pick命令。git pull不仅会把当前patch的内容抓取下来,还会把其parent的内容也会抓下来。

最后说一下如何解决conflict,场景

A提交了一笔gerrit 1在review,B提交了一笔gerrit 2也在review,但是A和B同时修改了文件x.java的同一行,且gerrit1先于gerrit 2 merge了,此时gerrit 2是无法merge的,因为有conflict。为了解决冲突,B需要现在本地用git pull把server上的commit抓取下来,此时gerrit 1会被抓取到本地,然后打开gerrit 2,选择download-> cherry-pick,复制该命令,然后将patch抓取到本地,再用git status查看哪些文件有冲突,然后用编辑工具搜索=======,找打冲突点,fix 所有的冲突后,git add filename,然后用git commit,接着用git push

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值