How to overwrite a remote branch with another local branch using git

I have a remote branch, which is the basis for pullrequest.

I mainly worked in another branch, but now I have to replace the old branch.

I tried to do it git push remote oldBranch -f, but it only pushes my last local oldBranchto git server instead of the current branch - regardless of which branch I am in now.

How to replace a remote branch with my local branch?

EDIT: If anyone is interested, here is how I got this to work:

git checkout oldBranch
git branch -m 'oldBranchToBeReplaced'
git checkout newBranch
git branch -m oldBranch
git push myrepo oldBranch -f
+4
source share
2 answers

You can use the syntax local-name:remote-namefor git push:

git push origin newBranch:oldBranch

This pushes newBranch, but uses the name oldBranchin the source.

oldBranch, , , :

git push origin +newBranch:oldBranch

( + -f, -f )

, " " :

git push origin :deleteMe
+21

: https://deltacloud.apache.org/send-pull-request.html

 $ git checkout -b my branch
  Coding your changes
 $ git commit -m "Commit message"

.

$ git checkout master
$ git pull

.

 $ git checkout my_work_topic
 $ git rebase -i master (Tip: You can rename/squash commits at this point)
 $ git push origin my_work_topic

Pull

Github : https://github.com/your /deltacloud -core.git " " (. ) . : GitHub

0

Source: https://habr.com/ru/post/1654001/


All Articles