Remote and local synchronization of GitHub

1, a remote warehouse behind a local warehouse

 Local repository of files through git add. Git add + or by file name submitted to the staging area

  git commit command opens the editor to enter this information changes

  git remote + remote repository address to connect warehouse

  git remote -v view

Finally, git push origin (defined remote repository name) master (branch)

To complete the update of a remote repository

 

 

2, local warehouse behind a remote repository

  Remote repository because he knew the reason of the combined application for consent, their local warehouse behind a remote repository

(1) Go to the location where the local repository

PC@▒▒▒▒▒▒▒▒▒ MINGW64 ~/Desktop
$ cd G:\
> four-mixed-operations

 

(2) fetch a link to your remote repository

PC@▒▒▒▒▒▒▒▒▒ MINGW64 /g/four-mixed-operations (master)
$ git fetch https://github.com/Blueming-scy/four-mixed-operations
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 7 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (7/7), 2.31 KiB | 4.00 KiB/s, done.
From https://github.com/Blueming-scy/four-mixed-operations
* branch HEAD -> FETCH_HEAD

 

Main (3) fetch branch to the warehouse read changes

PC@▒▒▒▒▒▒▒▒▒ MINGW64 /g/four-mixed-operations (master)
$ git fetch origin master
From https://github.com/Blueming-scy/four-mixed-operations
* branch master -> FETCH_HEAD
806b292..ff233e2 master -> origin/master

 

(4) merger with the local information repository update ( before the merger can be viewed correctly )

PC@▒▒▒▒▒▒▒▒▒ MINGW64 /g/four-mixed-operations (master)
$ git merge origin/master
Updating 806b292..ff233e2
Fast-forward
1.cpp | 22 +++++++++++++++++++++-
README.md | 4 ++++
2 files changed, 25 insertions(+), 1 deletion(-)
create mode 100644 README.md

 

3, others change their main warehouse synchronize

(1) First, enter the command to the location where the local repository

(2) adding a source repository location git remote add upstream (usually this) + original URL warehouse

(3) to crawl git fetch upstream of file changes

(4) to update the local files are combined pulling git merge upstream / master ( this step to be carried out after the master branch, can be ignored if the master branch )

 

 

Please point out any errors, thank you! !

 

Guess you like

Origin www.cnblogs.com/scy2020/p/12577298.html