How can I create a git dev branch with the same name as the previously deleted dev branch?

I need to rename the dev branch, let's say testing on tom . After renaming, I have to create a dev branch with the same name as testing , and it should point to a specific master commit.

I renamed the branch as:

git branch -m testing tom // renamed the branch locally

git push -set-upstream origin tom // Push the new branch, set the local branch to track the new remote

git push origin: testing // Removing the old branch

  • I can't figure out which branch should I be on with this: master or dev branch?
  • Now, to create a dev branch, I have to just use: git testing branches.
  • After testing is created, branches will have the same data as master, or do I need git pull
+3


source to share


1 answer


Try the following:

git branch -m testing tom             # rename local branch 'testing' to 'tom'

git push origin tom                   # push 'tom' out to the repository

git checkout master                   # switch to the 'master' branch

git branch testing                    # create a new 'testing' branch based on 'master'

git push origin testing --force       # overwrite the 'testing' branch on remote

      



If you follow this set of commands, you don't need to explicitly delete the branch testing

from the remote, because it is being overwritten.

+1


source







All Articles