Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens if I mistakenly push a local branch to master

Tags:

git

I made a mistake just now by mistakenly issued the command:

   git push origin master

on a local branch, say, mybranch. This branch is branched from master and contains some local changes that master does not have.

The message I get is:

   Everything up-to-date

I checked the master log there is nothing abnormal. My question is that:

  1. Did I mess master branch?
  2. Why does it says "Everything up-to-date" even if mybranch contains something that master does not have?

Thanks.

like image 441
Kevin Avatar asked Jan 12 '23 11:01

Kevin


1 Answers

If you don't specify the source(local) and destination(remote) branches, push uses the specified spec as both source and destination. So, basically, when you did

git push origin master

you just pushed your local master branch to the remote master branch.

To actually push your branch into master you should do

git push origin mybranch:master
like image 139
asermax Avatar answered Jan 19 '23 13:01

asermax