[[git]]
 

Differences

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

Link to this comparison view

todo-git [2015/11/08 08:27]
dblume [git at dlma.com]
todo-git [2018/11/16 08:59] (current)
dblume [Changing a local branch without regard to remote branch]
Line 101: Line 101:
 ====== Renaming branches ====== ====== Renaming branches ======
  
-To rename a remote branch (where "origin" is the name of the remote repo):+To rename a remote branch:
  
   - Rename the local one.   - Rename the local one.
Line 115: Line 115:
 </code> </code>
  
-Now I should see "remotes/origin/roku_dev" gone, and "remotes/origin/SDK_4.2.P2_Roku" appear. 
  
-I still have local branch called "roku_devand it's set to track  &quot;remotes/origin/roku_dev&quot;.  Since &quot;remotes/origin/roku_dev&quotis no longer there, if I try &quot;git pull&quoton that branch it will say remote reference doesn't exist.+==== Creating a branch (and possibly pushing to upstream origin) ==== 
 + 
 +  $ git checkout -b new_branch 
 +  Switched to a new branch 'new_branch' 
 + 
 +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 ==== 
 + 
 +This'll work if you don't have a local branch with that name already. 
 + 
 +&lt;code> 
 +$ git checkout --track origin/branch_name 
 +&lt;/code&gt; 
 + 
 +==== Making the current local branch track a new remote branch ==== 
 + 
 +&lt;code&gt; 
 +git branch -u origin/branch_name 
 +&lt;/code> 
  
-Since I don't have any changes on that local branch that I haven't pushed up to the server before the name change, I can safely delete this local branch, and create a new local branch from "remotes/origin/SDK_4.2.P2_Roku". 
  
 ====== git at dlma.com ====== ====== git at dlma.com ======
todo-git.1447000031.txt.gz · Last modified: 2015/11/08 08:27 by dblume
 
Recent changes RSS feed Driven by DokuWiki