Android project code cloud hosting

First created in the cloud remote code repository, and then create a local project in Android Studio, these two steps are not described in detail.

  1. AndroidStudio following Terminal switch to the directory this project (if already, would not have switched), or right-Git Bash Here in the project directory, and then execute git initthe command to initialize
  2. Add all of the files in the project to the local repository cache them (if you want to add to a document, you keep in the back of this document can git add, if you add more than one file, multiple files with a space between intervals. Express Add all the files to the workspace cache)
    Here Insert Picture Description
  3. Submission
    Here Insert Picture Description
  4. Pushed to the remote repository
    Here Insert Picture Description
    Tip: Some references will not be pushed to the remote repository, the update was rejected because the remote does not contain your local job done, first of all you want to change to a local integrated remote, for example: git pulland then try to push again.
    This problem occurs because the code I created a remote repository containing readme.md cloud and .gitignore files, create local projects have different .gitignore file and no readme.md files, remote file repository updates should first reach a local push again .
  5. git pull
    Here Insert Picture Description
    Tip: The current branch is no tracking information. Please specify the branch to use.
    If you want to set up tracking information for this branch, you can use the following command:git branch --set-upstream-to=origin/<branch> master
  6. git branch --set-upstream-to=origin/master masterHere Insert Picture Description
  7. Git pull again, suggesting refused to merge unrelated to history
    Here Insert Picture Description
    the question is irrelevant because the two fundamental git repository, a local library, a distal library, go to the local then pushed to the distal end of the distal feel that with their local library irrelevant, so the merger can not be told.
    There are two ways to solve:
    The first method: Kula down from the remote codes that start with git clone remote repository to local, then copy the code to be added to the local library clone distal to the local library, and then submit up , because in that case, your library is based on a remote database, this is the first update.
    The second method: using the force command git pull origin master --allow-unrelated-histories, followed by --allow-unrelated-histories, to two unrelated branches merging force. And then push it back.
  8. git pull origin master --allow-unrelated-histories
    Here Insert Picture Description
    We should resolve the conflict .gitignore file
  9. After the file is to resolve the conflict, the conflict submitted to the cache file, as follows
    Here Insert Picture Description
  10. Then run the commit command, as
    Here Insert Picture Description
    this time the local repository is the latest, and then execute git pull check, you do not need to update the local repository
    Here Insert Picture Description
  11. The last successful push to a remote repository, as follows:
    Here Insert Picture Description
Published 18 original articles · won praise 1 · views 780

Guess you like

Origin blog.csdn.net/aha_jasper/article/details/104766030