Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pulling down latest code from github to Android Studio

How to sync my local Android Studio project with the latest code on github?
I want to download all the latest changes but I don't want my local changes overwritten.
If there is a conflict, it should ask me to resolve those particular files.
Is there a way to achieve this?

like image 242
DGT Avatar asked Jun 10 '15 20:06

DGT


People also ask

How do I pull the latest code from GitHub?

This can be done using git reset . First, make sure you have the most recent copy of that remote tracking branch by fetching. Then, use git reset --hard to move the HEAD pointer and the current branch pointer to the most recent commit as it exists on that remote tracking branch.

How do I get my Android code from GitHub?

You can directly import GitHub projects into Android Studio. File -> New -> Project from Version Control -> GitHub. Then enter your GitHub username and password. Select the repository and hit clone.

How do you retrieve previous commit in Git project explain all steps with Android Studio?

In android studio 4.0, go to version control -> Log. Then select the commit you want to revert to. Choose Reset current branch to here. You ll see a popup, select Hard and its done.


2 Answers

"I want to download all the latest changes but I don't want my local changes overwritten"

You probably want to 'fetch' the upstream before merging your changes then.

VCS -> Git -> Fetch, this will update all your branches, so you can check them and later use VCS -> Git -> Merge Changes to update your local code.

That's what fits your needs the best, I think. Normally, I would just pull the changes and resolve the conflicts.

like image 70
Eduardo Naveda Avatar answered Sep 25 '22 08:09

Eduardo Naveda


First, you can import your project on the main menu using the check out project form Version Control. Then you can use the VCS->Update Project to download all the changes. This will leave your local changes and show you conflicts.

like image 23
mattfred Avatar answered Sep 26 '22 08:09

mattfred