I've been doing a lot of reading, but am still not too clear on how to work on a git branch in different places. How to do that?
First of all, the reason that I have to work in a branch is that I do have an "upstream" repo, which I need to rebase into my master
from time to time. So to keep my addons clean from upstream, I need to work on a git branch.
UPDATE2:
Ok. It's far more complicated than I thought now. The way I did from the source location was, git checkout -b newfeature
then pushed wth git push -u origin newfeature
, which was done on top of a "upstream" repo, plus my own master
repo, setup following the direction of
The problem is that I want to work on such git branch just as working in a normal git -- i.e., when I do some kind of git push
, I'm expecting to do some kind of git pull
from another location to get the latest updates.
When I'm doing git pull
from my second place, I got Already up-to-date
. I.e., the remote branch that I want to work on is not available for me.
PS. Info I've found, from http://longair.net/blog/2009/04/16/git-fetch-and-merge/
If you want to create a local branch based on a remote-tracking branch (i.e. in order to actually work on it) you can do that with git branch –track or git checkout –track -b, which is similar but it also switches your working tree to the newly created local branch. For example, if you see in git branch -r that there’s a remote-tracking branch called origin/refactored that you want, you would use the command:
git checkout --track -b refactored origin/refactored
However, this is what I got from git branch -r
on the source location.
$ git branch -r
origin/HEAD -> origin/master
origin/master
I.e., there is no remote-tracking branch called origin/something, but I'm clearly working in a branch:
$ git status .
On branch newfeature
nothing to commit, working directory clean
$ git branch -vv
master 55e1d6f [origin/master] Remove ...
* newfeature 8c4266a - [+] add ...
Since that -r
means for remote-tracking branches, I got same result for git branch -r
from my second place as well.
According to
checkout tracked remote branch, I think the problem is at my source end, I.e., I don't see my branch listed in the tracked remote branch section. Here is mine:
$ git remote show origin
* remote origin
Fetch URL: git@github.com:me/myproj.git
Push URL: git@github.com:me/myproj.git
HEAD branch: master
Remote branch:
master tracked
Local branches configured for 'git pull':
master merges with remote master
newfeature merges with remote newfeature
Local refs configured for 'git push':
master pushes to master (up to date)
newfeature pushes to newfeature (up to date)
When I do git remote show origin
from my second place, I don't see the newfeature listed there.
UPDATE: According to “Tracking Branches” And “Remote-Tracking Branches”,
Remote Tracking Branches should not be modified by users (don’t set your git branch to a remote tracking branch via git checkout and then try to modify the remote tracking branch).
So I shouldn't use the Remote Tracking Branches for my case?
Confused. Please help.
UPDATE:
I see the newfeature
in the git ls-remote
from my second place:
$ git ls-remote
From git@github.com:me/myproj.git
55e1d6fd9048336c7f0b178fbbf78231ca28ff06 HEAD
55e1d6fd9048336c7f0b178fbbf78231ca28ff06 refs/heads/master
8c4266a6a98f498c129a2a9e806e00e6c6d196b1 refs/heads/newfeature
8c4266a6a98f498c129a2a9e806e00e6c6d196b1 refs/tags/v1
However, I don't know how to use it from my second place:
$ git checkout --track -b newfeature
Branch newfeature set up to track local branch master.
Switched to a new branch 'newfeature'
and git log
is not showing the commits I've published to github.
Maybe I shouldn't have used the -b
? Well, I must:
$ git checkout --track newfeature
fatal: Missing branch name; try -b
$ git checkout newfeature
error: pathspec 'newfeature' did not match any file(s) known to git.
Aucun commentaire:
Enregistrer un commentaire