Reference Links: https://blog.csdn.net/chailyuan/article/details/53292031
Handling from: https://www.cnblogs.com/zhaijiahui/p/9006816.html
Downloading a large github project later, when after the project code updates, we want to update the contents of the local code synchronization. The finally found a method available, and quickly recorded it.
1 View remote branch
Use the following command to view the remote repository (I have a warehouse origin)
$ git remote -v origin [email protected]:username/Animations.git (fetch) origin [email protected]:username/Animations.git (push)
2 get the latest version from remote to local
Use the following command can create a temp local branch and a remote branch code origin master repository downloaded to the local branch temp
$ git fetch origin master:temp remote: Counting objects: 18, done. remote: Compressing objects: 100% (6/6), done. remote: Total 11 (delta 3), reused 0 (delta 0) Unpacking objects: 100% (11/11), done. From github.com:username/Animations * [new branch] master -> temp c07bdc7..40f902d master -> origin/master
3 compares the local repository and download the temp branch
Use the following command to compare the difference between native code and just download the code from the remote down:
$ git diff temp diff --git a/README.md b/README.md deleted file mode 100644 index 76699ed..0000000 --- a/README.md +++ /dev/null @@ -1,6 +0,0 @@ -Animations
4 branches to merge temp master branch
After comparing the difference, if they feel there is no problem, you can use the following command to merge the code:
$ git merge temp Updating c07bdc7..40f902d Fast-forward README.md | 6 ++++++ src/cn/exercise/animations/MainActivity.java | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 README.md
5 delete temp branch
If the temp branch does not want to keep, you can use the following command to delete the branch:
$ git branch -d temp
Deleted branch temp (was 40f902d).
If you do not merge before the branch code to the local branch will then delete the error, you can use git branch -D temp forcibly remove the branch.
Reference Links: https://blog.csdn.net/chailyuan/article/details/53292031
Handling from: https://www.cnblogs.com/zhaijiahui/p/9006816.html
Downloading a large github project later, when after the project code updates, we want to update the contents of the local code synchronization. The finally found a method available, and quickly recorded it.
1 View remote branch
Use the following command to view the remote repository (I have a warehouse origin)
$ git remote -v origin [email protected]:username/Animations.git (fetch) origin [email protected]:username/Animations.git (push)
2 get the latest version from remote to local
Use the following command can create a temp local branch and a remote branch code origin master repository downloaded to the local branch temp
$ git fetch origin master:temp remote: Counting objects: 18, done. remote: Compressing objects: 100% (6/6), done. remote: Total 11 (delta 3), reused 0 (delta 0) Unpacking objects: 100% (11/11), done. From github.com:username/Animations * [new branch] master -> temp c07bdc7..40f902d master -> origin/master
3 compares the local repository and download the temp branch
Use the following command to compare the difference between native code and just download the code from the remote down:
$ git diff temp diff --git a/README.md b/README.md deleted file mode 100644 index 76699ed..0000000 --- a/README.md +++ /dev/null @@ -1,6 +0,0 @@ -Animations
4 branches to merge temp master branch
After comparing the difference, if they feel there is no problem, you can use the following command to merge the code:
$ git merge temp Updating c07bdc7..40f902d Fast-forward README.md | 6 ++++++ src/cn/exercise/animations/MainActivity.java | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 README.md
5 delete temp branch
If the temp branch does not want to keep, you can use the following command to delete the branch:
$ git branch -d temp
Deleted branch temp (was 40f902d).
If you do not merge before the branch code to the local branch will then delete the error, you can use git branch -D temp forcibly remove the branch.