User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
todo-git [2017/03/10 23:31]
dblume [Renaming branches]
todo-git [2021/11/02 21:48]
Line 100: Line 100:
 ====== Renaming branches ====== ====== Renaming branches ======
 +===== Updating both local and remote repos =====
 To rename a remote branch: To rename a remote branch:
Line 116: Line 118:
-==== Changing local branch without regard to remote branch ====+==== Creating a branch (and possibly pushing to upstream origin) ====
-<code> +  $ git checkout -b new_branch 
-$ git checkout -b branch_name +  Switched to a new branch 'new_branch'
-Switched to a new branch 'branch_name' +
-That was the same as "git branch branch_name; git checkout branch_name"+That was the same as "''git branch new_branch; git checkout new_branch''" 
 +And now if you want to create that branch name at the remote branch, then: 
 +  $ git push --set-upstream origin new_branch
 ==== Changing a local branch to a new remote branch ==== ==== Changing a local branch to a new remote branch ====
Line 139: Line 143:
 </code> </code>
 +===== Updating a local repo after remote's already renamed its branch =====
 +<code bash>
 +git branch -m master main
 +git fetch origin
 +git branch -u origin/main main
 +git remote set-head origin -a
 ====== git at ====== ====== git at ======