(1) Download first
git clone URL
(2) Switch to branch Jarsample
git checkout Jarsample
(3) Download the code from the master branch of the remote Origin repository to the local Origin jarsample
Git fetch Origin Jarsample
(4) Force update to remotely overwrite local
git checkout--force
"The following is a reference to the reproduced article"
How to update download to code locally, see Ice's Blog Open source Project Guide based on GitHub participation in EoE
Way One
1. View Remote repositories
1
2
3
4
5
6
|
$ git remote-v
EOECN https://github.com/eoecn/android-app.git (fetch)
EOECN https:// Github.com/eoecn/android-app.git (push)
origin Https://github.com/com360/android-app.git (fetch)
Origin Https://github.com/com360/android-app.git (push)
Su@suchangli/e/eoe_client/android-app (Master)
|
As can be seen from the above results, there are two remote warehouses, one is EOECN, the other is Origin
2, get the latest version from remote to local
1
2
3
4
|
$ Git fetch origin master from
Https://github.com/com360/android-app
* Branch Master-- Fetch_head
Su@suchangli/e/eoe_client/android-app (Master)
|
$ Git fetch origin master This means: download code from the master branch of the remote Origin repository to the native Origin master
3. Compare the differences between local warehouses and remote references
1
2
|
$ git log-p master: Origin/master
Su@suchangli/e/eoe_client/android-app (Master)
|
Because my local warehouse and remote warehouse code are the same, there is no other information
4. Merge remote downloaded code into local repository, remote and local merge
1
2
3
|
$ git merge Origin/master
already up-to-date.
Su@suchangli/e/eoe_client/android-app (Master)
|
My local reference code is the same as the remote code, so it's already up-to-date
The above way a little bit difficult to understand, we can use the following way, and very safe
Way Two
1. View the remote branch, same as the first step above
2. Get the latest version from remote to local
1
2
3
4
|
$ GIT fetch origin master:temp from
https://github.com/com360/android-app
* [New branch] master - > Temp
su@suchangli/e/eoe_client/android-app (Master)
|
Git fetch Origin master:temp This command means: Download from the master branch of the remote Origin repository to local and create a new branch temp comparison of local repositories and remote reference differences
1
2
|
$ git diff temp
su@suchangli/e/eoe_client/android-app (Master)
|
The command means: Compare the difference between the master branch and the temp branch
No other information is displayed because of my no difference
4. Merging the temp branch to the master branch
1
2
3
|
$ git Merge temp
already up-to-date.
su@suchangli/e/ |