简体   繁体   中英

not able to push changes to a remote branch in github

I am a bit new in github and I am seeing something which never happened to me when using gerrit. I have a repo with three branches, let's call them ==> a,b,c. When I type

git branch -a

I can see:

  remotes/origin/HEAD -> origin/master
  remotes/origin/a
  remotes/origin/master
  remotes/origin/b
  remotes/origin/c

Imagine I want to change something in b. I do the following:

 git checkout -b b_branch remotes/origin/b

Then I do the change. Add it and commit it. When I check the logs of git, I can see that there is one extra commit compared to the list of commits in the remore repo. Then, I do:

git push origin remotes/origin/b

However, nothing gets uploaded and I can see that it says:

Total 0 (delta 0), reused 0 (delta 0)

And if I do a simple push, it says: Everything up-to-date. However, the git log shows one extra commit.

Am I doing anything wrong? Why I can't commit my changes to the branch?

To push the local b_branch to the remote b branch, write like this:

git push origin b_branch:b

When the name of the local branch is the same as the name of the remote branch, the syntax is simply:

git push origin branchname

When the names are different, you need to use the more verbose but explicit syntax with : separating the local and remote branch names.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM