简体   繁体   中英

Keep local changes to forked git repository out of github pull request

I'm currently working with a local copy of a forked repository from a large open-source project. I've had to make a couple of changes to the local development copy for ease of importing without having the stable version of the code on my path interfere -- basically I made a couple of imports relative instead of absolute.

When I'm doing my pull request to upstream, they're not going to want the local changes I made to import lines, but I do want to commit them for the sake of my working copy of the fork. What is the best way to handle this situation?

You only need to worry about the relative/absolute paths problem when you are actually making your pull request.

You can keep working on your local repository and you can push to the forked repository too with those relative paths. But the second you are ready to make a pull request, you'll have to make a commit which changes those relative paths to absolute paths, and then push those changes to your forked repository, and you can then make your pull request with the absolute paths.

Afterwards, you can do a git revert which adds another commit to undo the previous one - basically to undo those changes you made (so you can go back to using relative paths rather than absolute paths).

This is probably the simplest way. You might be able to write a script which does this sort of thing automatically every time you push, but I think that's overkill for this problem. Pls also note that I'm not a git expert, so perhaps consider what others say on this topic too.

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