Git: change HEAD
10,442
Solution 1
Found answer here:
https://stackoverflow.com/a/2862938/2720802
$ git fetch && git checkout ng-1
$ git branch
master
* ng-1
$ git merge -s ours master
Already up-to-date.
$ git checkout master
$ git merge ng-1
Already up-to-date.
$ git branch
* master
ng-1
$ git add -A
$ git commit -m "Merged"
$ git push origin
Seems all done.
Solution 2
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.
Author by
setevoy
Updated on June 14, 2022Comments
-
setevoy almost 2 years
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, andng-1
- new.What I want to do - is switch
master
tong-1
so whengit pull
will be executed - it will pull code from"master"
- but with new code.Let's say - I want "move" code from
master
tong-1
- and fromng-1
tomaster
.As I googled - this can be done with:
$ git update-ref HEAD ng-1
Thus - "main default" branch will became
ng-1
andmaster
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?