Zakoff
Zakoff

Reputation: 12995

Forgot to do 'git push' on previous branch and started new branch

On branch 'first' I did:

git add .
git commit -m "Finished first changes"
git checkout master
git merge first

But I forgot to do:

git push

To push the changes to github. I then created a new branch 'second' that I need to commit. Will there be any issues if I do the following:

git add .
git commit -m "Finished second changes"
git checkout master
git merge second
git push

Will my first branch cause any conflicts or can I just 'push' them together?

Upvotes: 0

Views: 976

Answers (2)

CharlesB
CharlesB

Reputation: 90276

git push will just send commits to GitHub, nothing more. It can't cause any conflict. So yes, you can merge your second branch and push the changes, or even checkout master, push changes, and work on your second branch.

Upvotes: 1

Schwern
Schwern

Reputation: 164659

It is not necessary to push after each merge. You can push master without any consequences. When you push master Git will know to also push the changes in first and second. Though it will push the contents of first and second, because they make up part of master now, it is not necessary to push the branches themselves. Branches in git are just labels.

As long as you're adding changes (commit or merge) and not altering exiting ones (rebase or commit --amend) a push is safe. If a push would cause a conflict, git will not allow you to push.

In fact, you should not push habitually. You should only push when you are ready to share your work with others.

Upvotes: 2

Related Questions