Git Basics: How to retrieve from remote repository using Git fetch/pull?
In the last article, we discussed about " Git Tags ". Today we are going to discuss another topic "Git Fetch" and "...- Article authored by Kunal Chowdhury on .
In the last article, we discussed about " Git Tags ". Today we are going to discuss another topic "Git Fetch" and "...- Article authored by Kunal Chowdhury on .
In the last article, we discussed about "Git Tags". Today we are going to discuss another topic "Git Fetch" and "Git Pull", which I hope, will help you to easily work with Git Bash commands to download code from repository.
Let's continue learning about "git fetch" and "git pull" today with the commands that you need to know. Stay tuned to read more and more posts on this topic.
The "git fetch" command imports commits from a remote repository to your local. The resulting commits are stored as remote branches instead of the normal local branches. This gives you chance to review the changes before integrating them.
Fetching is generally done when you want to see other's changes. As fetched content is represented as a remote branch, it has actually no effect on your local dev branch.
Fetch all branches from remote repository:
$ git fetch <remote>
Fetch from a specific remote branch:
$ git fetch <remote> <branch>
Fetch all tags from the remote:
$ git fetch -t
Merging the upstream changes into your local repository is a common task in Git based workflows. The "git pull" command does the same thing that you do with the commands "git fetch" and "git merge" together. That means, it fetches the specified remote’s copy of the current branch and immediately merges it into the local copy. It’s an easy way to synchronize your local repository with upstream changes.
$ git pull <remote>
$ git pull --rebase <remote>
The --rebase option can be used to ensure a linear history by preventing unnecessary merge commits. Many developers prefer rebasing over merging, as it puts the changes on top of other's changes.
Was this post useful? If you came to this page by searching online about git basics, please have a look into my other blog posts. Subscribe to the RSS feed or the email newsletter to keep yourself updated.
Thank you for visiting our website!
We value your engagement and would love to hear your thoughts. Don't forget to leave a comment below to share your feedback, opinions, or questions.
We believe in fostering an interactive and inclusive community, and your comments play a crucial role in creating that environment.