1. Switch to the branch which is used as a main developer/release branch.
This is the branch which contains the latest changes to the system. Can be master
, core
, dev
, it depends on the company. In your case it is probably master
directly.
git checkout master
git pull
Pull to make sure you have the latest version of the main development branch aquired.
2. Checkout and pull the branch which contains the work you are supposed to finish.
You pull to make sure you indeed have the latest contents of the branch. By checking it out directly, without creating it locally first, you ensure not to have the new contents from master
(or the main dev branch respectively) in it.
git checkout <name of the obsolete branch>
git pull origin <name of the obsolete branch>
3. Merge the main development branch to the obsolete branch.
Before running the following command, make sure, either by typing git
branch
or git status
that you are on the obsolete branch.
git merge master
The git merge
command will try to merge the contents from the specified branch, in this case master
, to the branch you are currently at.
Emphasis on will try to. There might be merge conflicts, which will need to be resolved by you and you only.
4. Fix the merge conflicts, commit and push the conflict fix
After fixing the merge conflict in all the files where there is, stage, commit and push the conflict resolution to origin
.
git add .
git commit -m "fixed the merge conflict from the past year to update the branch"
git push
You can generally call git add .
to stage all the files for commit. When dealing with merge conflicts, you want all the necessary files to be updated.
Additional note
Resolving merge conflict can be a tedious work. Especially if you are new at a company. You might not even have the proper knowledge to resolve all the merge conflicts alone, yet.
Take your time to carefully inspect all the conflicts that have occured and fix them appropriately, before continuing your work.
It can happen so, you start working on an one year old branch, merge the current development state into it and won't have any merge conflicts at all.
This happens when even though the system has changed a lot in the year, nobody has touched the files which were actually altered in the one year old branch.