-
Notifications
You must be signed in to change notification settings - Fork 278
Working with both BN and DDA in git
Sometimes you may need to port some changes from DDA. It could be done via adding remote and cherry-picking.
git remote add bn https://github.com/cataclysmbnteam/Cataclysm-BN.git
git fetch bn
git checkout -b upload bn/upload
git checkout upload && git pull
Assuming you have a directory with DDA named Cataclysm-DDA
, open a terminal there.
Add the remote tracking branch for BN. Let's name the branch bn
(doesn't need to be bn
):
git remote add bn https://github.com/cataclysmbnteam/Cataclysm-BN.git
To download the contents of the new branch, it has to be fetched:
git fetch bn
This downloads all the content from the remote tracking branch. It shouldn't take very long, because it doesn't download the things common to both repos.
Once fetched, you can merge
, pull
, checkout
etc. the branches on the remote, but you have to prepend them with bn/
, for example bn/upload
. It's useful to have a local branch pointing to the remote tracking one:
git checkout -b upload bn/upload
This creates an upload
branch, which is basically BN's master
branch.
The simplest way is:
git checkout upload
git pull
This shouldn't result in any conflicts. If it did, you probably committed changes to the upload branch. In this case you may want to back them up:
git checkout -b temp-branch-name
And reset the upload branch to the remote:
git branch -f upload bn/upload
# Switch to BN branch
git checkout upload
# Update local content
git pull
# Create new branch for your changes
git checkout -b chainsaw-toothbrush-rebalance
# [do stuff with files]
...
# Commit the changes
git commit -a
# Upload your changes to your fork of Cataclysm (assuming its branch is named origin)
git push -u origin chainsaw-toothbrush-rebalance
# Go to BN's github and make a pull request
Porting is done with git cherry-pick
.
First, you need to find the hash of the merge commit, or the first and the last of the commits from the range you want to port. On github, those are on the right side of commit descriptions in a PR. You can use the full hash or the shortened version.
In the examples, fafafaf
is the merge commit, while a0a0a0a
and b1b1b1b
are the first and last commit from a range (order is important).
Then, from a branch you are porting to, cherry-pick the merge commit or the range of commits:
# Merge commit
git cherry-pick fafafaf
# Commit range
git cherry-pick a0a0a0a..b1b1b1b
Resolve the conflicts (there will be many for non-trivial PRs and you'll have to resolve most of them manually):
git mergetool
The above may require setting up a merge conflict resolving tool (TODO: describe how to do that). Then commit and push, as usual.