可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I am on Android Studio (Preview) 0.6.0 on Windows and was trying to share my project on GitHub. I used Git Shell to initialize, add, commit and push the project to GitHub. But when I tried to update my project from within Android Studio

, I got this error:
Can't update: no tracked branch No tracked branch configured for branch master. To make your branch track a remote branch call, for example, git branch --set-upstream master origin/master
It does provide this suggestion but I am not sure what to do at this point. Is there a way to fix this from within Android Studio?
回答1:
If I'm not mislead, you just need to set your local branches to track their pairs in the origin server.
Using your command line, you can try
git checkout mybranch git branch --set-upstream-to=origin/mybranch
That will configure something as an equivalent of your local branch in the server. I'll bet that Android Studio is complaining about the lack of that.
If someone knows how to do this using the GUI of that IDE, that would be interesting to read. :)
回答2:
So after reading a bit on how git sets up the repo. I realized that I ran the command
git push origin master
but instead for the first time I should have ran
git push -u origin master
which sets up the upstream initially. Way to go!
回答3:
Create a new folder and run git init in it.
Then try git remote add origin <your-repository-url>.
Copy all the files in your project folder to the new folder, except the .git folder (it may be invisible).
Then you can push your code by doing:
git add --all; or git add -A;
git commit -m "YOUR MESSAGE";
git push -u origin master.
I think it will work!
回答4:
In the same case this works for me:
< git checkout Branch_name > Switched to branch 'Branch_name' < git fetch > [Branch_name] Branch_name -> origin/Branch_name < git branch --set-upstream-to origin/Branch_name Branch_name > Branch Branch_name set up to track remote branch <New_Branch> from origin.
回答5:
Assume you have a local branch "Branch-200" (or other name) and server repository contains "origin/Branch-1". If you have local "Branch-1" not linked with "origin/Branch-1", rename it to "Branch-200".
In Android Studio checkout to "origin/Branch-1" creating a new local branch "Branch-1", then merge with you local branch "Branch-200".