Fetch vs Pull with Visual Studio Code

There comes a time when you have others with access to modify or add to your repository that changes occur from the central repo and your workstation repo.  In this article, I will quickly show how to use the fetch and pull commands to update your local repo with modifications made to the central repo.

If you are looking for an example of how to do this in Git Bash please go to this URL:
https://digitalthoughtdisruption.com/2020/09/09/fetch-vs-pull-with-git-bash/

In my example I have modified one of the examplefiles in GitHub and added a new file called filesavedtogithub.txt.

Fetch vs Pull:

fetch

Downloads new data from a remote repository (GitHub in our examples).  However, it doesn’t integrate any of the new data into the working files. Fetch is ideal for receiving a view of the modifications that has occurred at the remote repo.

pull

Updates your current head branch with the latest modifications from the remote repo.  As part of the pull process and pulling down of new data, it also merges the new data into your current files, which can have negative outcomes.

Windows File Explorer showing the local repository before newer files and changes are pulled from the remote GitHub repository.

As you can see from my local workstation the new file isn’t here and the date modified for the sample text file is earlier today

Screenshot from the Git Fetch Versus Pull in Visual Studio Code walkthrough showing J File Edit Selection View Go Run Terminal.

As you can see from the explorer none of the changes made to the GitHub have been updated in VS Code.

Visual Studio Code status bar indicating that two remote changes are available to pull into the local repository.

As you can see it is indicating there are two changes that need to be pulled down from the remote repo

Now you can click on the synchronize button

Screenshot from the Git Fetch Versus Pull in Visual Studio Code walkthrough at step 4, showing Visual Studio Code; the adjacent article text explains that you can click on the synchronize button.

Press OK

Screenshot from the Git Fetch Versus Pull in Visual Studio Code walkthrough at step 5; the adjacent article text explains that you can click on the synchronize button.

As you can see the addition line of information was added to the sample text.ps1 file and the new filesavedtohithub,txt is in the folder

Summary:
As you can see it is not hard to push and pull data via VS Code.  This is one reason why it is my preferred editor.  As always, I hope y’all found this article useful.

Keep exploring

Choose your next step

Continue with the path that best matches the architecture or operating challenge in front of you.

2 thoughts on “Fetch vs Pull with Visual Studio Code”

Leave a Reply

Discover more from Digital Thought Disruption

Subscribe now to keep reading and get access to the full archive.

Continue reading