I added files to git git->add in android studio, files were added successfully. When I pressed commit and push, it was interrupted due to network issue. And nothing was pushed to git.
Now When I'm trying to add and commit, it ways nothing to push.
Kindly advise how to fix this in android studio.
Thanks in advance.
Your files already committed in your local system. Thats why you are unable to see any files when committing again.
To push the committed code, Goto VCS -> Git -> Push, You will see all the committed files, So you can push it to repository.
Alternative Terminal way,
You can also execute this command in terminal to push your code to master
git push -u origin master
Hope this helps.
Related
I created a new project in Android Studio. But I can not push it to bitbucket (I fight with it for all day, nothing works).
I get this error:
Push to origin/master was rejected
error: failed to push some refs to 'https://aaa#bitbucket.org/bbb/ccc.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
! refs/heads/master:refs/heads/master [rejected] (fetch first)
hint: (e.g., 'git pull ...') before pushing again.
Done
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
And this is what I do:
Android Studio (AS) -> New project
AS -> VCS -> Enable Version Control integration -> Git
AS -> VCS -> Git -> Remotes -> I added URL of repository I created in bitbucket
AS -> Right click on project => Git => Commit & Push - > ERROR
What is the problem? I dont understand the error message, I do not have any "another repository", it is just me working on this project, and it is newly created.
When I try to follow advice to PULL changes, it also does not work (I get another error). And when I try to google that one, I get another one and another one and I soon I get lost...its very complicated.
What am I doing wrong? All I want is just to push a new project to bitbucket...
Ok, I solved it. I have no idea why git kept giving me those random errors (when both repo and project were fresh and just minutes old, those error messages ddint make much sense), but this is what helped:
git push -f --set-upstream origin master
I guess it is just another proof how complicated, and unintuitive git is.
So I have an android studio project that I'm syncing between my laptop and my computer with git. Every time I push with one and pull with the other when I try to pull I get error refusing to merge unrelated histories
I tried using --allow-unrelated-histories but that causes a ton of merge conflicts.
I need to be able to sync between the two because my computer supports the emulator and my laptop is portable.
This happens because your repositories was initialized independly.
You should create the repository only in one location, and clone it to the other.
If the other repository already exists and you have there some change which you don't want to lose, you could do the following:
(from location2, commit all uncommitted changes first!)
git fetch location1
git branch save_location2
git reset --hard origin/location1
So you switch to the history started at location1, and would not lose your history started at location2, and will be able to look up stuff from there.
There are exceptional cases where you should use --allow-unrelated-histories, but I'm sure it is not your case.
I had same problem. Try this:
git pull origin master --allow-unrelated-histories
git push origin master
Reference:- Github unrelated histories issue
I'm stumped.
My project has it's original GitHub repository.
I will have to push the Android project to a second repository.
How to do push code to a second and separate GitHub repository in Android Studio?
I see hints that it's possible, but I don't know how to initiate to new repository.
Regards,
You can do so by either editing or adding remote URL from terminal.
To add:
git remote add origin2 https://github.com/user/repo.git
To edit:
git remote set-url origin https://github.com/user/repo.git
Then you can push to another remote repository.
In Android studio, you can press Ctrl+Shift+K and choose where to push the commits.
Follow these steps:
Go to the android project directory and open terminal then.
1.git init
2.git remote add bitbucket https://github.com/xxx/yyy.git (bitbucket is name i have given. you can use anything like origin2 etc.)
3.git add .
4.git commit -m "first commit"
5.git push -f bitbucket master
I'm not new to using GitHub on Android Studio, but:
This is my first try to contribute to a sample project for Android on GitHub.
I did the following
I cloned the repository:
I made my changes
I committed my changes
I pushed my commit
And baam (here is the problem):
Why? What things did I miss?
(Don't forget, I have never contributed on GitHub, and this is my first time.)
403 indicates that you are not allowed to access the resource - you aren't authenticated with GitHub. To fix this, you should change your remote URL to a repository you have access to, then push your changes:
https://myusername#github.com/user/repo.git
From the command line you would need to do the following (Android Studio should automatically detect the changes):
git remote remove origin
git remote add origin https://myusername#github.com/user/repo.git
git push -u origin --all // prompts for authentication, pushes your changes to github
Your question has nothing to do with Android Studio, I guess if you try to push your changes through command line you'll get the same result. Read about Contributing to Open Source on GitHub.
First of all, to do a contribution:
You must fork the repository
Clone your fork version of that repository
Through the command line, navigate to your clone directory then add upstream version (original repository):
$ git remote add upstream https://github.com/fcannizzaro/material-stepper.git
You can check it using the line $ git remote, and you will see origin and upstream.
Make changes → commit them → then push (all of this happen on your repository (forked one), not the upstream).
Go and check the network graph for both the forked and original repositories.
Go to the GitHub original repository's link and click pull request.
Do as described in this image:
And fill the others field and click Create pull request
Thanks for Erik Carlsten's tutorials.
Please can any one help me how to change commit message after push from inside the android studio.I am using android studio in the windows OS.I know there is git push -f origin command but as I already told you I am pushing and making changes from android studio itself.It would be great if anyone can help me with this.
Thanks in advance!
Once you push the changes its considered final.
So if you have already pushed you can do this.
git reset --soft HEAD~1 (Pushes back head 1 back with you changes in the current head as uncommited change)
Now do a commit(appropriate message, no push) from android studio.
Now do a
git push -f origin branch
from the folder.