Sumod
Sumod

Reputation: 3846

Git pushing a branch to remote not working

I created a local branch by using

git checkout -b mybranch

Then I made certain changes to it and pushed to remote with

git push origin mybranch

However, I cannot see my local changes in the remote mybranch. Therefore, I tried to push again:

git push origin mybranch:mybranch

Now I get message that everything is up-to-date, but I can see that there are changes in the local branch. Running git branch shows mybranch as the local selected branch. I have done this operation in the past, but somehow, not able to recollect how I did that.

Can someone please help?

Upvotes: 1

Views: 78

Answers (1)

jub0bs
jub0bs

Reputation: 66422

In your question, you write that, after you created mybranch, you

made certain changes to it and pushed to remote.

But did you actually stage your changes and create a commit before attempting to push? It seems that you didn't because, in one of your comments, you also write

if I run git diff, I see the changes made.

The git diff command shows the differences between your working tree and the staging area. The fact that git diff outputs something (instead of nothing) can mean only one thing: you have a dirty working tree. In other words, there are discrepancies between your working tree and the staging area.

You won't be able to push those changes to remote until you stage them, with

git add <paths>

and create a commit, for instance with

git commit -m "descriptive message"

Then, you should be able to push your branch (whose tip will be that new commit) to remote origin:

git push origin mybranch

Upvotes: 2

Related Questions