Home
Welcome
About This Wiki
sandbox (play here)
This shows you the differences between two versions of the page.
todo-git [2015/11/07 22:26] dblume |
todo-git [2017/03/10 23:31] (current) dblume [Renaming branches] |
||
---|---|---|---|
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 a local branch called "roku_dev" and it's set to track "remotes/origin/roku_dev". Since "remotes/origin/roku_dev" is no longer there, if I try "git pull" on that branch it will say remote reference doesn't exist. | + | ==== Changing a local branch without regard to remote branch ==== |
+ | |||
+ | <code> | ||
+ | $ git checkout -b branch_name | ||
+ | Switched to a new branch 'branch_name' | ||
+ | </code> | ||
+ | |||
+ | That was the same as "git branch branch_name; git checkout branch_name" | ||
+ | |||
+ | ==== Changing a local branch to a new remote branch ==== | ||
+ | |||
+ | This'll work if you don't have a local branch with that name already. | ||
+ | |||
+ | <code> | ||
+ | $ git checkout --track origin/branch_name | ||
+ | </code> | ||
+ | |||
+ | ==== Making the current local branch track a new remote branch ==== | ||
+ | |||
+ | <code> | ||
+ | $ git branch -u origin/branch_name | ||
+ | </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 ====== | ||
Line 128: | Line 148: | ||
<code bash> | <code bash> | ||
- | ~$ mkdir testcode.git | + | git$ mkdir testcode.git |
- | ~$ cd testcode.git/ | + | git$ cd testcode.git/ |
testcode.git$ git init --bare | testcode.git$ git init --bare | ||
</code> | </code> | ||
Line 141: | Line 161: | ||
testcode$ git commit -m "first commit" | testcode$ git commit -m "first commit" | ||
... | ... | ||
- | testcode$ git remote add origin ssh://dblume@dlma.com/~/testcode.git | + | testcode$ git remote add origin ssh://USERNAME@dlma.com/~/git/testcode.git |
testcode$ git push origin master | testcode$ git push origin master | ||
</code> | </code> | ||
+ | |||
+ | I could've use gitweb but I used GitHub-like [[https://github.com/klaussilveira/gitlist|gitlist]] at http://git.dlma.com. | ||
+ | |||