How to resolve git pull code conflicts in open source projects?
仅有的幸福
仅有的幸福 2017-05-02 09:50:07
0
2
653

Suppose I am using an open source project. In order to keep the root official github synchronized at all times, I use git clone the project locally and perform secondary development. Most of my secondary development will not conflict with the official core files. Yes, but individual files will still conflict. .

For example, after a period of time, I made some modifications to my local computer. This is the official repository that also made some modifications and released a small version

At this time, I want to update the latest official version. When using git pull, a conflict will be prompted. Then a problem arises

Secondary development of open source projects. How to get the latest version via git pull at any time and keep local modifications?

What I’m doing now

If there is a conflict when git pull gets the latest official update

Use git stash to cache local changes.
Then git pull to download the latest official version
Then git stash pop to merge local changes into the code and manually resolve conflicts

I briefly tested it and found no problem, because I don’t need to push the code to the official warehouse, so I usually don’t add, but after this experience, I made some modifications, and the official updated it again Something

Using git pull still doesn’t work. I need to use local git add . Then repeat the above stash steps to keep updates and merge conflicts,

I don’t know if what I did is correct, or is there a better way?

仅有的幸福
仅有的幸福

reply all(2)
阿神

No need to stash, just commit the changes first, and then pull to resolve the conflict.

刘奇

In fact, if you have already made a local commit (git commit), it would be perfect if you don’t need to git stash,直接git pull或者先git fetchgit merge就可以了。
当然,如果你在拉取之前,本地并没有提交(git commit)的话,你的上述操作也是没有问题的,但是,你也可以先将本地的修改做完然后提交了再拉取(git pull)。
其实,你的git stash应用的场合不太合适,git stash一般用于你在某一分支工作做了一半(还不值得做一次提交或者压根还不想提交)时,你突然想切换到其他分支做一点儿别的事。这时,用git stash first before pulling the remote changes.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template