I have a file which I've been working on for quite some time. My boss had me working on a branch that other people have been working on. There have been several commits to a file which I've been working on. How do I merge my changes into the file since it's had several commits now?
I have not pulled the recent commits yet.,
Asked
Active
Viewed 43 times
1

somejkuser
- 8,856
- 20
- 64
- 130
-
Are you asking for the command (`git merge`) or a strategy to deal with conflicts? – Stephen Newell Mar 19 '18 at 15:10
-
The answer is in your comment, `git merge` is your friend here. You can check the [community guide](https://stackoverflow.com/questions/315911/git-for-beginners-the-definitive-practical-guide/816636#816636) for more questions that you may have: – dubes Mar 19 '18 at 15:10
-
@dubes Im merging same files on same branch thouhg.. – somejkuser Mar 19 '18 at 15:24
-
2`git pull --rebase`? This would put your changes on top of everything else. You will probably still need to resolve conflicts. – lukas-reineke Mar 19 '18 at 15:45
-
You could test using git fetch and git merge --no-ff --no-commit. – Christoph Mar 19 '18 at 16:04
1 Answers
0
If you haven't already.. I'd make sure to branch off of this shared branch (let's call it develop
) your coworkers are working on.
Re-apply your changes on top of the latest commits from the shared develop
branch
git pull --rebase origin develop
Check for any conflicts your change may have made, resolve them.
git status
If there are conflicts you will need to add them back to staging, and continue the rebase. Depending on the conflicts and how far you are behind, you may need to do this step several times.
git add <files_with_conflicts>
git rebase --continue
At this point, you are good to merge, and share your changes.
git checkout develop
git merge <your_local_branch>
git push origin develop

Max Friederichs
- 569
- 3
- 13