What Is the Difference Between Pull and Fetch in Git? Then, your local branch is compared to the remote-tracking branch and receives the new commits so it can catch up to the current state of the remote branch. First, your remote-tracking branch is synced with the “true” branch in the remote repository. Git pull, in a nutshell, is a two-part process. What Is Git Pull, Really? How Does It Work? Time to understand git pull more in-depth. You can think of remote-tracking branches as “read-only” branches that mirror the state of the actual remote branches. Remote-tracking branches are references that live in your local repositories. Your remote repositories also have their branches, which are appropriately called “remote branches.” The last part of this tripod is what makes the whole thing possible: remote-tracking branches. How does that work in practice? For starters, you have your local branches in which you do your work. As soon as you get your remotes configured, you can send and get commits from the branches in your remotes. And, despite being common for projects to have a main remote playing the role of a “central server,” you can also have other remotes configured.įor instance, you can add your coworker’s repository as a remote so both of you can collaborate. As we’ve mentioned, you can have any number of remotes. You collaborate in Git by exchanging information with your remotes. You Collaborate in Git by Sending to and Getting From Remotes In practice, however, most projects will have a “main” remote, which acts as the de facto central server. Instead, in Git you can have any number of remote repositories, or simply remotes. Git is a decentralized VCS, which means there’s no central server. Git commits are identified by a unique-ish identifier, which is calculated based on their data, including the name and email of the author, time stamp, commit message and the commit’s parents. Instead of storing the patch-that is, the actual changes introduced-they store a whole snapshot of the project in a specific instant. Unlike in other VCSs, commits in Git aren’t deltas. To better understand git pull, you need to understand how network operations work in Git. What is git pull? In a nutshell, it’s the command you use to update your repository with new changes. Git Pull 101: Understanding Git Networking As is usual for these tutorials, we assume you have Git installed and are at least familiar with working with the command line. You’ll learn what this command does and how to use it, in addition to learning useful fundamentals about network operations in Git. This post will explain git pull in detail. To sync with remote repositories, you’ll need to master Git network operations, including git pull. Most of the time, however, you’ll be collaborating with other people. You can learn more about tracking connections in our free online book.If you’re working alone on a project, you can use Git locally just fine. This means that, if a tracking connection has been set up, you can simply omit naming the remote repository and branch: $ git pull This configuration provides default values so that the pull command already knows where to pull from without any additional options. In most cases, your local HEAD branch will already have a proper tracking connection set up with a remote branch. $ git fetch origin Using the Plain git pull Command If you don't want to integrate new changes directly, then you can instead use git fetch: this will only download new changes, but leave your HEAD branch and working copy files untouched. By default, this integration will happen through a "merge", but you can also choose a "rebase": $ git pull origin master -rebase It will also directly integrate them into your local HEAD branch. Using git pull (and git pull origin master is no exception) will not only download new changes from the remote repository.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |