![]() Think of them as bookmarks, to remind you where the branches in your remote repositories were the last time you connected to them. They’re local references that you can’t move Git moves them for you whenever you do any network communication, to make sure they accurately represent the state of the remote repository. Remote-tracking branches are one of the remote references to the state of remote branches. # cd git-exercise/ # git ls-remoteĥdcc5f579f26dd160acf1e8d2b457d072e6f4579 refs/heads/master # git remote showĪbove marked bold letters sentence are remote reference and will see in details as we progress. You can get a full list of remote references explicitly running command git ls-remote, or git remote show for remote branches as well as more information. Remote: Total 9 (delta 2), reused 0 (delta 0) Remote: Compressing objects: 100% (8/8), done. Let’s do a git clone to local machine, # git clone into 'git-exercise'. I have forked one of my repository to demonstrate and named the new repository as “git-exercise”. I’m going to deal with remote reference taking a public remote repository clone to my local machine and manipulate to understand the version transition between my machine to origin remote repository. Remote references are reference in the form of branches,tags and so on to a simple pointer on your remote repositories. ![]() So, from the above output we can see that we have switched to master branch and then pulled the remote's master branch using the git pull origin command and merged it into local master branch.Īfter the pull operation both the local master branch pointer and the remote master branch ( origin/master) pointer will point at the same commit as shown in the above image.In the follow of git articles,this one to take more new git terms and ideas that git offers to stand as being the best version system designed by Linus Torvalds.īefore discussing git fetch and git pull,i would take a chance to say about remote reference and how to deal with it. Remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Remote: Compressing objects: 100% (2/2), done. Now we will run the git pull command which will fetch and merge remote master branch into local master branch. Your branch is up-to-date with 'origin/master'. So, first we will checkout the master branch. ![]() We can see that the local master branch is behind the remote master branch and so, we will pull the commits from remote to local. In the above image our local master branch is represented in blue and the remote master branch is represented in pink. And those changes are now merged into the master branch of the central repository. Lets say, other developers of our team have committed and pushed their changes to the central repository. Note! We have named the remote central repository connection as origin in our previous tutorial Git Remote - Connecting with repository. So, basically we are running two commands git fetch and git merge using git pull command. So, if we want to fetch and merge master branch from a remote repository into our local repository master branch then, we will first checkout master branch and we will run the git pull command and it will fetch the master branch from the remote repository and will merge it into the master branch of our local repository. We use the git pull command to fetch the commits from a remote repository to our local branch on which we are currently on and then merge the changes. So we fetch and merge commits using one command. The git pull command puts the two into one single command. So in the previous tutorial Git Fetch - Import commits from remote repository we learned how to fetch commits from remote repository using git fetch command and then merge the changes using git merge command. In this tutorial we will learn about Git pull which helps to fetch and merge changes.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |