Editing Git branch

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 6: Line 6:
 
  * [[main]]
 
  * [[main]]
  
List all branches:
 
[[git branch --list]] or [[-l]]
 
 
  [[git branch -a]]
 
  [[git branch -a]]
[[git branch -d]]
 
[[git branch -r]]
 
  
[[git branch --merged]] master
+
[[Create a new branch]]:  
[[git branch --merged]]
+
git branch new_branch  
[[git branch --no-merged]]
+
git checkout new_branch
 
 
 
 
[[Create a new branch]] or change branch:  
 
* <code>git branch new_branch</code>
 
* <code>[[git checkout]] new_branch</code>
 
* <code>git branch your-existing-branch</code>
 
 
or
 
or
 
* <code>[[git checkout -b]]</code>
 
* <code>[[git checkout -b]]</code>
Line 28: Line 18:
 
   [[master]]
 
   [[master]]
  
  [[git branch --list]] or git branch -l
+
  git branch --list or git branch -l
 
  * [[main]]
 
  * [[main]]
  
Line 35: Line 25:
 
  [[git branch --all]]
 
  [[git branch --all]]
  
  [[git branch -r]]
+
  git branch -r
 
   origin/HEAD -> origin/main
 
   origin/HEAD -> origin/main
 
   origin/[[main]]
 
   origin/[[main]]
Line 48: Line 38:
  
 
=== [[Rename branch]] ===
 
=== [[Rename branch]] ===
{{rename branch}}
+
[[git checkout]] -f yourbranch
 +
[[git branch -M]] yourNewBranch
  
 
=== Delete branch ===
 
=== Delete branch ===
Line 58: Line 49:
  
 
  [[git branch]]
 
  [[git branch]]
 
 
== Change to a branch ==
 
* <code>[[git checkout]] your-existing-branch</code>
 
 
== Activities ==
 
* [[Create git branch with current changes]]
 
  
 
== Related commands ==
 
== Related commands ==
Line 75: Line 59:
 
* [[git show-branch]]
 
* [[git show-branch]]
 
* <code>[[git clone]]</code>
 
* <code>[[git clone]]</code>
* [[git merge-base]]
 
  
 
== See also ==
 
== See also ==
* {{git switch}}
 
 
* {{git branch}}
 
* {{git branch}}
 +
* {{git}}
 +
  
 
[[Category:Git]]
 
[[Category:Git]]

Please note that all contributions to wikieduonline may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Wikieduonline:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Advertising: