Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: change HEAD

I have a repository on Bitbuket with two branches:

 $ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/ng-1

master contains old tool code, and ng-1 - new.

What I want to do - is switch master to ng-1 so when git pull will be executed - it will pull code from "master" - but with new code.

Let's say - I want "move" code from master to ng-1 - and from ng-1 to master.

As I googled - this can be done with:

$ git update-ref HEAD ng-1

Thus - "main default" branch will became ng-1 and master will be saved as my "backup".

If something will go wrong - I'll can just do vice versa:

$ git update-ref HEAD master

Am I correct?

like image 775
setevoy Avatar asked Mar 11 '26 04:03

setevoy


1 Answers

What I want to do - is switch master to ng-1

// Checkout the new branch
git checkout ng-1

... when git pull will be executed - it will pull code from "master" - but with new code

// Pull "old" changes - if ng-1 is forked from master no update should be pulled
git pull origin master

// Now you ng-1 contains the "new" code as well.
like image 132
CodeWizard Avatar answered Mar 13 '26 17:03

CodeWizard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!