简体   繁体   中英

Github: Keep a local file un-changed when merging github repositories

I have access to a public repository that is frequently updated. On my local merged repository, I have to make some changes to some specific files in order to meet my requirements.

My problem is, every time I make a pull of the original repository, my local changed files are also lost.

How can I keep my local repository updated and do not allow my "local changed files" to be updated?

Basically I need to get the new files that have been changed only at remote repository and not the one changed on my side.

UPDATED: The proposed solution ( Git Pull While Ignoring Local Changes? ) is different from my actual requirement, since the user from the linked post wants to git pull the full repository and "override" any local changes he made. In my case, I want to define some files changed locally to not be changed by the git pull.

I want to keep some files changed locally unchanged and git pull the remaining repository

A way to do this cleanly would be to use git-rebase.

Essentially you would reset your local repo to the (updated) version of the remote public repo and then apply your changes again on top. This way your changes will always be on top of a copy of master from the remote repo.

Assuming you have a repo with your changes on top currently, the workflow would look like this:

git fetch
git rebase origin/master
... [fixup any conflicts you see when trying to reapply your changes]

See a description of rebase for more details.

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