git pull master without overwriting my files on the local branch

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?

Upvotes: 2

Views: 59

Answers (2)

tmaj
tmaj

Reputation: 35075

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.

Upvotes: 1

Maik Lowrey
Maik Lowrey

Reputation: 17586

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.

Upvotes: 3

Related Questions