简体   繁体   中英

Merge branches in git on Android Studio

I have a problem with merging branches in Android Studio. If I want to merge my local master with my remote master, the Android Studio alerts me that there were changes between the remote and the local, and asks me to commit and push the changes. but when I try to push the changes it says that I need to save or stash the changes. Is there an easy way to work with the git in Android Studio?

It sounds like you have unstaged changes. I don't know about how to do this from android studio, git status should show you what state things are in. If you have unstaged changes, first you need to 'stage' or add your changes ( git add . ) then create a commit from the changes you added ( git commit ).

Next, it sounds like there are changes in the remote master that you want to incorporate into your local state. Before you do, if it's been a while since you fetched/pulled, you might want to get the latest master from the server using git fetch . Then you either need to combine your changes with the changes from the remote master ( git merge origin/master ), or re-apply your changes on top of the remote master ( git rebase origin/master ).

Alternatively, if you haven't made any commits yet, and all your work is in the form of unstaged changes, you can stash them ( git stash ) to temporarily store them away, then use git pull to update to the latest version of master, followed by git stash pop to apply the changes you previous stored.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM