0
What is the use of Staging area or Indexing in Git?

Open 1 Answers 20 Views Technology

 What is the use of Staging area or Indexing in Git?

1 Answer

0
Git pull command pulls all new commits from a specific branch in the central repository and makes the target branch in your local repository up-to-date.

Git fetch also aims at the same thing, however, its underlying functionality is a bit different. When you do a git fetch, all the new commits from a specific branch will be pulled in your central repository and these changes will be stored in a new branch in your local repository. This is called a fetched branch.

If you wish to see these changes in your target branch, then you need to perform a git merge after git fetch. The target branch will be updated with the latest changes only after merging it with the fetched branch.

So, a git pull brings the local branch up-to-date with its remote version, whereas a git fetch does not directly change your own local branch or working copy under refs/heads. Git fetch can be used to update your remote-tracking branches under refs/remotes/<remote>/.

In simple words, git pull is equal to git fetch followed by a git merge.
by (274k points)
...