I have a project in a Git repo and I have been sent changes that have been made outside of Git. These changes are based on an earlier version that I have been making changes to myself. What is the best way to merge these external files with mine?
Many thanks!
First we run git checkout master to change the active branch back to the master branch. Then we run the command git merge new-branch to merge the new feature into the master branch. Note: git merge merges the specified branch into the currently active branch. So we need to be on the branch that we are merging into.
Merging Branches in a Local Repository To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch.
The best way is to tell git what commit they were based off of, to give you the best chance of an automatic merge.
git checkout <sha1 of the old commit> -b mybranch
, to rewind your work tree and start a new branch.git-apply
to apply them to the work tree, otherwise just put the updated files in.git checkout master
, then git merge mybranch
.You'll want to act exactly as if you were working with these files, so commit them from the state of the earlier version you're talking about:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With