I had git cloned the MapBox-ios-sdk project. I've made a few ugly hack changes to the code that was not appropriate to contribute back. But MapBox-ios-sdk changed recently. If I want to merge their latest changes to my project while still maintaining my hack, what's the best practice about doing that with Git? Should I have branched initially when I cloned? Or should I just modify in the master branch and just git pull from the official source and resolve conflict, and keep it at that for future sdk version as well?
I'm going to assume that your hack has been committed to your local master
branch. You can move it to a branch by doing something like:
git branch -m master myhack
git branch myhack^ master
This will give you a myhack
branch with your one commit on it (adjust myhack^
if there is more than one commit), and a master
branch that matches the original master from the project.
At this point, you can pull new code into your local master
branch without conflict. Then, switch to your myhack
branch and merge the new master in:
git checkout myhack
git merge master
由于您没有先分支,所以最好的做法就是您描述的内容: 在master分支中进行修改,然后从正式来源进行git pull并解决冲突 。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.