无法更新,没有追踪到分支

我使用的是 Windows 上的 Android Studio (Preview)0.6.0,正在尝试在 GitHub 上分享我的项目。我使用 GitShell 来初始化、添加、提交和将项目推送到 GitHub。但是当我试图在 Android Studio < img src = “ https://i.stack.imgur.com/SS9e6.png”alt = “ enter image description here”> 中更新我的项目时,我得到了这个错误:

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

它确实提供了这个建议,但我不确定在这一点上该怎么做。有没有办法从 Android Studio 内部解决这个问题?

154448 次浏览

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!

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. :)

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!

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.

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".

I got the same error but in PyCharm because I accidentally deleted my VCS origin. After re-adding my origin I ran:

git fetch

which reloaded all of my branches. I then clicked the button to update the project, and I was back to normal.

 git commit -m "first commit"


git remote add origin <linkyourrepository>


git push -u origin master

will works!

I had the same problem when I transferred the ownership of my repository to another user, at first I tried to use git branch --set-upstream-to origin/master master but the terminal complained so after a little bit of looking around I used the following commands
git fetch
git branch --set-upstream-to origin/master master
git pull
and everything worked again

I have faced The same problem So I used the Git directly to push the project to GitHub.

In your android studio

Go to VCS=>Git=> Push: use the Branch Name You Commit and hit Push Button

Note: tested for android studio version 3.3

git branch --set-upstream-to=origin/master master

Worked for me....where I have a single branch in my repo called master. The response was "Branch master set up to track remote branch master from origin."

This isuse because of coflict merge. If you have new commit in origin and not get those files; also you have changed the local master branch files then you got this error. You should fetch again to a new directory and copy your files into that path. Finally, you should commit and push your changes.