Differences between revisions 1 and 2
Revision 1 as of 2020-06-11 18:10:45
Size: 1129
Comment:
Revision 2 as of 2020-06-11 18:11:35
Size: 1136
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
<<TableOfContents> <<TableOfContents>>
Line 38: Line 38:


Git Branches


Renaming Branches

A local-only branch can be renamed easily. Given a repository named my-repo:

# ensure that you are in the repository directory and checked into the target branch
cd path/to/my-repo
git checkout master

# to rename branch 'master' to 'dev'...
git branch -m master dev

To rename a remote branch, first follow the above process. The remaining steps can produce errors.

git push -u origin dev
git push origin --delete master

If git returns an error like  ! [remote rejected] master (deletion of the current branch prohibited), then you need to adjust the HEAD of the remote repository. This determines what branch a new repository clone will start on. The 'default' branch cannot be deleted for obvious reasons.

Keeping with the example above, access the bare remote repository my-repo.git and edit my-repo.git/HEAD such that it points to the new branch's head.

ref: refs/heads/dev

Valid values correspond to the branch references in my-repo.git/refs/heads/.


CategoryRicottone

Git/Branches (last edited 2023-10-11 14:03:04 by DominicRicottone)