Tuesday, 13 June 2023

GIT 2023 update remote branches, delete local/remote branches, set HEAD ref

 GIT update remote branches :

https://stackoverflow.com/questions/36358265/when-does-git-refresh-the-list-of-remote-branches

git remote update origin --prune

GIT delete local and remote branches:
https://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-locally-and-remotely

Deleting a remote branch

git push origin --delete <branch>  # Git version 1.7.0 or newer
git push origin -d <branch>        # Shorter version (Git 1.7.0 or newer)
git push origin :<branch>          # Git versions older than 1.7.0

Deleting a local branch

git branch --delete <branch>
git branch -d <branch> # Shorter version
git branch -D <branch> # Force-delete un-merged branches

GIT set head:
https://stackoverflow.com/questions/45811971/warning-ignoring-broken-ref-refs-remotes-origin-head

git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/new_dev

to check 
git symbolic-ref refs/remotes/origin/HEAD

also use git branch -a to check
if did not change use :
https://stackoverflow.com/questions/1485578/change-a-git-remote-head-to-point-to-something-besides-master
git remote set-head origin develop

Force delete remote:
https://superuser.com/questions/748058/how-do-i-delete-origin-master-in-git
git push origin otherbranch:master -f

That will replace master with the contents of otherbranch, but it'll still be called master on the remote.


otherbranch should be checked out locally



No comments:

Post a Comment