Home > Enterprise >  git pull master without overwriting my files on the local branch
git pull master without overwriting my files on the local branch

Time:01-11

Some files that were in the master branch were deleted by another dev, in my local branch I had already committed the changes and now I want to pull from the master and keep my files in the local branch, how to do that?

CodePudding user response:

If another user has deleted a file and moved it to the remote branch, this operation cannot be undone and you cannot ignore it!

But you can move your local master to a new local branch with git checkout -b "localMasterBackup". Make a commit! and then do the git pull origin master and you can afterwards merge the localMasterBackup into the current master.

CodePudding user response:

You'll have to deal with the merge conflict(s) whichever path you choose for this situation (delete & change).

git pull (--rebase) resolving conflicts is entirely normal here.


If you have multiple people working on a long-lived branch you may want to switch to the industry standard of protected branches pull requests.

  •  Tags:  
  • git
  • Related