1

I did some changes in dev branch , committed and pushed (git push origin dev)and created a new merge request from gitlab frontend . But now i want to modify 1 file in same merge request without raising new one . Can I delete dev branch on remote and change that file on local, commit and push again as git push origin dev . Will this harm my current merge request ?

Prashant Singh
  • 426
  • 7
  • 17
  • Does this answer your question? [Can I still add commit on branch after created merge request?](https://stackoverflow.com/questions/58046505/can-i-still-add-commit-on-branch-after-created-merge-request) – lcnicolau Dec 23 '20 at 19:49

1 Answers1

5

If that modification should be part of your MR (Merge Request), you can simply commit on your MR branch (dev), and push: that will update your MR.

If it is not part of your MR, you should create a new branch from dev, commit there and push that new branch.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Yes , I did you are mentioning but getting below error : `hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. ` – Prashant Singh Jun 10 '20 at 05:42
  • @PrashantSingh Are other developers contributing to dev as well? Or are you the only one pushing to it? – VonC Jun 10 '20 at 05:53
  • Only i am pushing or using dev branch and it needs to to be merged in master branch . – Prashant Singh Jun 10 '20 at 06:04
  • @PrashantSingh If your local history for `dev` branch is correct, you can `git push --force` to the remote: it will update the remote `dev` branch and your MR as well, since your MR was raised from `dev`. – VonC Jun 10 '20 at 06:14
  • so doing `git push --force` will update the branch content. And the link https://dummy.com/backend/-/merge_requests/662 of that MR will not change , right ? Basically I don't want to raise another MR and again send mail to manager , since I have already given him the link https://dummy.com/backend/-/merge_requests/662 . – Prashant Singh Jun 10 '20 at 06:21
  • @PrashantSingh Yes, the link will not change, but its content will, if you did raise the MR 662 from the dev branch. Updating that dev branch will update MR 662 (without changing its link) – VonC Jun 10 '20 at 06:23
  • 1
    I first thought that the MR is a new entity apart from the branch, but if you commit to the branch and push you will automatically update the MR with that. – questionto42 Dec 14 '21 at 10:54