Reputation: 20882
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?
Upvotes: 111
Views: 190218
Reputation: 1202
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.
Upvotes: 3
Reputation: 503
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."
Upvotes: 13
Reputation: 803
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
Upvotes: 4
Reputation: 904
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
Upvotes: 33
Reputation: 11
git commit -m "first commit"
git remote add origin <linkyourrepository>
git push -u origin master
will works!
Upvotes: -1
Reputation: 7373
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.
Upvotes: 4
Reputation: 397
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!
Upvotes: 7
Reputation: 28875
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".
Upvotes: 2
Reputation: 41
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.
Upvotes: 4
Reputation: 2239
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. :)
Upvotes: 146
Reputation: 20882
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!
Upvotes: 69