简体   繁体   中英

Updating my modifications with each git pull?

I use github to update a repository using git or composer. But there are some small parts I need to "patch"/modify to the core every time I do a git pull.

What is the best way to manage this so I can always apply my changes on every update, and also keep my changes stored somewhere in my forked repository if I accidently delete everything on local? ONly storing these changes on local and just denying the overwrite does not seem secure in case of local data loss.

This is a common situation: Maintaining local changes while regularly updating with remote changes. The standard way to handle this is:

  • clone the repo
  • check out the branch you want to use (unless it is master)
  • make your local modifications, and commit them
  • set up git to automatically rebase when pulling: git config branch.BRANCHNAME.rebase true , where BRANCHNAME is the local branch you use

Now, everytime you run git pull , git will rebase your branch onto the new state of the remote branch. This means in detail it will:

  • put aside your local commit
  • pull down the remote changes
  • try to apply your commit on top of the remote changes

The last step may fail with a merge conflict if there are conflicting changes - then you'll have to resolve by hand.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM