thisEric
thisEric

Reputation: 526

how to track android branch using git

all

I have downloaded source code from google android website following google's guide. My purpose is to create a local branch to track remote branch

take framework/media for example, you can see .git under this directory, but when you run

git branch

the output is

*no branch

I crate my local branch using

git checkout -b local

then I have the problem, how can I switch back to track remote branch, I cannot pull updated source code from google for this .git again. There is only one local branch.

I also tried

git remote

and get

aosp https://android.googlesource.com/platform/frameworks/base (fetch)

aosp https://android.googlesource.com/platform/frameworks/base (push)

git branch --track local aosp

but I get the error

fatal: Not a valid object name: aosp

Anybody can give me some advice and guide? thanks very much.

Upvotes: 1

Views: 455

Answers (2)

VonC
VonC

Reputation: 1324228

As mentioned in "How do you make an existing git branch track a remote branch?"

As of Git 1.7.0:

 git branch --set-upstream local aosp/local

will work too.
Note that for git 1.8+, discussions are in progress in order to make aosp/local an argument of --set-upstream (instead of a separate parameter).

In order to make its usage unambiguous, and to allow it to be used w/o specifying the current branch, require it to take an argument like so:

(master)$ git branch --set-upstream=origin/master 

Upvotes: 1

Amber
Amber

Reputation: 526593

You can use...

git branch --track local aosp/master

(The reason you're getting an error is because aosp is a remote, not a specific thing on that remote. aosp/master refers to the master branch on that remote, and thus can be tracked.)

Upvotes: 2

Related Questions