Update branch (pull) in VSC : Pull latest files
This guide describes using the Visual Studio Code (VSC) editor to get (or pull) the latest files from GitHub/ AzDevOps.
Prerequisites
Before you proceed complete the following:
- Install Visual Studio Code
- Install Docs Authoring Pack
- Install Word Count extension
- Install Pull Requests extension
- Install Azure Repos extension
- Install Git client
- Set Git credentials
- Terminology and concepts
- General project workflow
- Download course files (clone repo)
- Project branching policies
- Create new branch in VSC
Topics in this guide
Overview of the Git pull command
Git branching makes it possible for multiple contributors to edit the same files in a GitHub/ AzDevOps repository (remote repo). Other contributors might update the files in a remote repo at any time, so it’s important to keep the files in your local repo up to date with the remote repo.
Update your local repo when you begin your working day, throughout the day, and whenever you need a file or feature from the remote repo that you don’t have locally. Keeping your local repo up to date helps to avoid “merge conflicts”, which arise from attempts to merge incompatible versions of the same file.
Git pull
The git pull
command gets information about the latest files from the remote repo and merges the files from the remote repo with the files in your local repo. The git pull
command can retrieve and send files to and from different branches.
Note: Whenever you pull files into a specific branch, you must ensure that VSC is switched to the correct branch to avoid inadvertently overwriting files. The VSC status bar, at the bottom of the editor, indicates the name of branch that VSC is currently switched to.
Save any changes you make to your local repo regularly (using Git stage and commit). For details about Git terminology and file saving actions visit the guides Terminology and concepts and send (push) files.
Get the latest files from GitHub/ AzDevOps with VSC
Complete the following steps to get the latest files from GitHub/ AzDevOps into your local repo using git pull
in VSC.
-
In VSC, open your local repo (File > Open Folder), and select the VSC Explorer icon (left sidebar).
-
Switch VSC to the branch you want to update.
The VSC status bar, at the bottom of the editor, indicates the name of branch that VSC is currently switched to.
For example, in the following image, the VSC status bar indicates that VSC is currently switched to the master branch. Switching VSC to a different branch is described in the guide Switch branch. The local repo’s folders and files are accessible from the VSC Explorer pane (on the left side).
-
Go to Terminal > New Terminal.
-
Type git pull into the resulting terminal window, select git pull, and press Enter.
The command
git pull
will commence retrieving files from GitHub/ AzDevOps. The spinning arrows in the status bar, beside the branch name, indicate the progress of the pull command.Note: You must always use the VSC Terminal to perform
git pull
actions. Running thegit pull
command from the VSC Command Palette will not always update the files in your local repo correctly. -
When a message indicating that the
git pull
command has completed appears in the VSC terminal, close the terminal window using theX
(upper right side corner of the terminal window).Note: If there are changes pending in your local branch, and you run the Git pull command, you may receive the message cannot overwrite existing changes. To pull the latest files from GitHub/ AzDevOps successfully, save the changes first then run the Git pull command again.
Appendices
Check the following supplementary Appendices for more details and context.