1

While working with Gerrit, I created a new feature branch from master locally and then pushed it to the remote repository. That part works fine and the new branch can be seen on the remote.

But when I commit to that feature branch and try to push it, all my changes go to master branch. I don't understand why?

I double checked my location by running git branch (it is pointing to my feature branch)

Please explain what's going on here.

Błażej Michalik
  • 4,474
  • 40
  • 55
keepmoving
  • 1,813
  • 8
  • 34
  • 74

1 Answers1

1

git branch is not enough: try and check the output of git branch -avv to see local and remote tracking branches.

Combine that with git status, to check which branch you are currently using.

Then you can make sure:

  • you actually are using feature branch
  • feature branch is indeed linked to an upstream branch.

But in the case of Gerrit, make sure to push using the right URL: see Gerrit push.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks a lot. its working as I mentioned full address on push. :) – keepmoving Oct 10 '21 at 04:59
  • addition to last question I am facing one more issue. So now changes are pushed to gerrit and they are visible for review. But what I want here is, 2 different person will be working on this feature branch and they will be pulling changes to each other to completed feature. But when someone is trying to clone/pull my feature branch my commit is not visible to them. how these changes will be visible which is in review state in gerrit. – keepmoving Oct 11 '21 at 04:57
  • @StillLearning You might consider pushing to two different remotes (https://stackoverflow.com/a/14290145/6309): one being Gerrit, the other a repository from which you can both exchange commits. – VonC Oct 11 '21 at 05:19
  • I guess no, there is no push for 2 different locations. Let me ask question again. So as I mentioned, I am successfully able to push my changes to Gerrit feature branch with 1 test commit. this change is visible on Gerrit web and its not merged yet. Now another developer pulled this feature branch locally and I was expecting that my unmerged changes should be pulled into his local machine. But its not like. this. – keepmoving Oct 11 '21 at 05:28
  • @StillLearning "I guess no, there is no push for 2 different locations": exactly: make a second one. Does the developer pull the branch from the Gerrit repository? – VonC Oct 11 '21 at 05:31
  • @StillLearning Gerrit will store patches to be reviewed in their own namespace: https://stackoverflow.com/a/28372991/6309. Your developer might need to adlust its refspecs. – VonC Oct 11 '21 at 05:33
  • Its working now, as mentioned in Download section, command can be easily found. thanks a ton for this help. It saved my whole day. – keepmoving Oct 11 '21 at 07:35
  • @StillLearning Perfect, well done! – VonC Oct 11 '21 at 08:19