0

I have a use case in gitlab where I have to create a branch say testdemo from master, since master is default branch, we are making master protected.

A team of 6 developers is working on testdemo branch (which is feature branch),

Developer A does some commit to branch using git push -u origin HEAD:ref/for/testdemo where the merge request is yet to raised by Developer A. Parallely, Developer B adds new file and tries to push to the same branch using git push -u origin HEAD:ref/for/testdemo .

I am getting the below error :

hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart. Check out this branch and integrate the remote changes

How can I solve this? My use-case is that developers commit to ref/for/testdemo and code review happens and then it is merged to testdemobranch. How can I achieve this when two developers make a parallel commit or developer does amend to current commit?

Thanks,

Saikrishna

Saurabh P Bhandari
  • 6,014
  • 1
  • 19
  • 50
saikrishna
  • 111
  • 1
  • 7
  • Does this answer your question? [How to resolve git error: "Updates were rejected because the tip of your current branch is behind"](https://stackoverflow.com/questions/22532943/how-to-resolve-git-error-updates-were-rejected-because-the-tip-of-your-current) – phd Dec 22 '19 at 14:33
  • https://stackoverflow.com/search?q=%5Bgit%5D+Updates+were+rejected+because+a+pushed+branch+tip+is+behind – phd Dec 22 '19 at 14:33

2 Answers2

0

Looks like you just moved from Gerrit to gitlab.

When working with Gitlab each developer should use his own branch for development and then merge only his work to master or feature branch. So instead pushing to HEAD:ref/for/testdemo push to separate branch git push -u origin task-123 or git push -u origin whatever-description-fits-your-branch-best.

Couple of useful things I'd suggest to get familiar with when starting to work with gitlab: Gerrit vs gitlab, gitlab workflow overview, gitlab flow.

makozaki
  • 3,772
  • 4
  • 23
  • 47
0

for developer#2 to push to the same branch

git add <localfilename>
git commit -m"commit message"
git pull origin testdemo
git push origin testdemo


Chenna
  • 52
  • 6