ramashish tomar
ramashish tomar

Reputation: 873

git push without any issue

I have 3 branches on the remote namely

* master
* feature1
* feature2

on local, I work on feature2 and some other developer work on feature1 he has pushed his changes on the feature 1 and merged it to master.

master is the branch where we keep our final code. now I want to push my local changes on to master also but I fear that the changes which are not pulled after the other developer pushed on to master may cause some issue. what is the best way to achieve all the changes done by him and I should reflect on the master?

Upvotes: 2

Views: 74

Answers (2)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522386

This is a completely normal scenario/problem, and the two general ways you would handle this would be to first merge master into your feature2 branch, then push, or rebase your branch on the remote master, and then push. Something like this:

# from feature2
git fetch
git merge origin/master
git push origin feature2

# or, again, from feature2
git fetch
git rebase origin/master
git push origin feature2

You may get merge conflicts from either of the two above options, but again, this is also a normal part of any Git workflow.

Upvotes: 2

zanseb
zanseb

Reputation: 1435

In order to be sure nothing breakes master, I think you have to introduce an additional branch. Most of the time its called develop. You can find more about the git flow strategy here: https://datasift.github.io/gitflow/IntroducingGitFlow.html

There are of course multiple solutions to this problem, but for me this one works just fine.

Hope this helps.

Upvotes: 1

Related Questions