In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Most people don't understand the knowledge points of this article "What are the differences between push and pull in git", so Xiaobian summarizes the following contents for everyone. The contents are detailed, the steps are clear, and they have certain reference value. I hope everyone can gain something after reading this article. Let's take a look at this article "What are the differences between push and pull in git".
The difference between push and pull in git: 1. The "git push" command sends the latest information in the local repository to the remote repository, which is used to push the updates of the local branch to the remote host;2. The "git pull" command obtains the latest version from the remote to the local repository, which is used to obtain and integrate from another repository or local branch.
Operating environment: Windows 10 system, Git version 2.30.0, Dell G3 computer.
What is the difference between push and pull in git?
git push and git pull are a pair of push/pull git commands.
git push uses the local branch to update the remote branch
$ git push :
Note: The local branch in the command refers to the branch to be pushed to the far end, while the remote branch refers to the target branch of the push, i.e., merging the local branch into the remote branch.
Omitting the remote branch name means pushing the local branch to a remote branch (usually with the same name) with which it has a "tracing relationship"; if the remote branch does not exist, it is created.
$ git push origin master
The above command means pushing the local master branch to the master branch of the origin host. If the latter does not exist, it will be created.
origin is a remote repository address.
Omitting the local branch name means deleting the specified remote branch, because this is equivalent to pushing an empty local branch to the remote branch. This command deletes the remote master branch.
$ git push origin :master#equals $ git push origin --delete master
The above command means deleting the master branch of the origin host.
Both local and remote branches can be omitted if there is a trace relationship between the current branch and the remote branch (i.e., the branch name is the same).
$ git push origin
The above command means pushing the current branch to the corresponding branch of the origin host.
If the current branch has only one trace branch, the hostname can be omitted.
$ git push
If the current branch has trace relationships with multiple hosts, you can specify a default host using the-u option, so that you can use git push later without any parameters.
$ git push -u origin master
The above command pushes the local master branch to the origin host, specifying origin as the default host, and then you can use git push without any parameters.
Git push without any parameters, by default only push the current branch, this is called simple mode. In addition, there is a matching method that pushes all local branches with corresponding remote branches. Before Git version 2.0, the default matching method was used, but now it is changed to simple by default. If you want to modify this setting, you can use the git config command.
$ git config --global push.default matching#or $ git config --global push.default simple
There is also a case where all local branches are pushed to the remote host regardless of whether there is a corresponding remote branch, in which case the-all option is used.
$ git push --all origin
The above command indicates that all local branches are pushed to the origin host.
If the remote host version is newer than the local version, Git will report an error when pushing, requiring git pull to merge differences locally before pushing to the remote host. At this point, if you must push, you can use the-force option.
$ git push --force origin
The above command uses the-force option, which results in a "non-fast-forward merge" on the remote host. Unless you are absolutely sure you want to do so, you should avoid using the-force option.
Finally, git push does not push tags unless you use the-tags option.
$ git push origin --tags
git pull gets and merges other repositories, or other branches locally.
Git pull and git push have the same purpose, but the opposite goal. The command format is as follows:
git pull :
For example:
git pull origin master:my_test
The above command pulls and merges the master branch of origin into the local my_test branch.
If the local branch is omitted, it is automatically merged into the current branch. As follows:
git pull origin master
Note: If you want to participate in some of the great projects on github, here is a generic example:
First, you need a github account and fork a repository of interest.
The following description involves two remote main branches. For good distinction, we call the main branch from the fork remote A repository and the branch from this fork remote B repository.
$git clone #clone your fork $git remote add git@github.com:XXXX/ceph.git #add remote repository tag $git pull master:master #pull the latest objects from the master branch of the remote repository merge them into the local master branch $git checkout YYYY #switch to the branch you want to modify $git branch develop; git checkout develop #create a development branch based on the current branch and switch to that branch where you will code coding... #coding$git add in workspace.# save changes to index $git commit -a #commit changes to local partition $git push origin my_test:my_test #commit local branch my_test to remote A repository my_test branch
Then merge the my_test branch into the remote B repository branch you want to change in the github web interface. Wait for administrator review, if there is a problem, continue on the develop branch when modifying, and commit-amend, modifying on the previous commit. I know it's meger.
The above is the content of this article about "what is the difference between push and pull in git". I believe everyone has a certain understanding. I hope the content shared by Xiaobian will be helpful to everyone. If you want to know more relevant knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.