Can't update: no tracked branch

GitGithubAndroid Studio

Git Problem Overview


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 enter image description here, 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?

Git Solutions


Solution 1 - Git

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

Solution 2 - Git

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!

Solution 3 - Git

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

Solution 4 - Git

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

Solution 5 - Git

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!

Solution 6 - Git

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.

Solution 7 - Git

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.

Solution 8 - Git

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

Solution 9 - Git

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.

Solution 10 - Git

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

Solution 11 - Git

 git commit -m "first commit"

 git remote add origin <linkyourrepository>
 
 git push -u origin master

will works!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPrinceView Question on Stackoverflow
Solution 1 - GitD. MeloView Answer on Stackoverflow
Solution 2 - GitPrinceView Answer on Stackoverflow
Solution 3 - GitRaedView Answer on Stackoverflow
Solution 4 - GitStan QuinnView Answer on Stackoverflow
Solution 5 - Gitjoao.arrudaView Answer on Stackoverflow
Solution 6 - GitAlexandr SpodinView Answer on Stackoverflow
Solution 7 - GitNic ScozzaroView Answer on Stackoverflow
Solution 8 - GitHossam AliView Answer on Stackoverflow
Solution 9 - GitSaeed Zahedian AbroodiView Answer on Stackoverflow
Solution 10 - GitCoolMindView Answer on Stackoverflow
Solution 11 - GitDanúbia BarretoView Answer on Stackoverflow