User Tools

Site Tools


todo-git

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
todo-git [2017/03/10 23:31] – [Renaming branches] dblumetodo-git [2021/11/14 00:23] – [Updating a local repo after remote's already renamed its branch] dblume
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' +
-</code>+
  
-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 --all --prune
 +git branch -u origin/main main
 +git remote set-head origin -a
 +</code>
  
 ====== git at dlma.com ====== ====== git at dlma.com ======