Git

When Does Git Refresh the List of Remote Branches

Nowadays, Git is the most demanding software among developers for large projects. Additionally, it can be operated by several users simultaneously. It facilitates the developers with unique features that become difficult to handle but distinctive from other software in the technology.

Developers work on local repository branches and push them into the GitHub repository after completing them. Sometimes, after working on remote branches, they delete them from the GitHub repository. After that, they are required to refresh the remote branches list.

This write-up will provide the procedure for refreshing the list of remote branches.

When Does Git Refresh the List of Remote Branches?

To refresh the list of remote branches, follow the below-given steps:

  • Navigate to the Git particular repository.
  • View the list of all Git branches, including the remote and local branches, and check the remote URLs.
  • Go to the GitHub hosting service and view the list of all remote branches.
  • Execute the “$ git remote update <remote-name> –prune” command.

Step 1: Move to Git Directory

Go to the Git particular directory by providing its path with the “cd” command:

$ cd "C:\Users\nazma\Git\Test_12"

Step 2: List All Existing Branches

Now, list all existing remote and local branches through the provided command:

$ git branch -a

Here, highlighted branches are all fetched remote branches, and the rest of them are the local branches. The asterisk “*” symbol beside the local branch name indicates that it is the current working branch:

Step 3: Display List of Remote URLs

Next, shows the list of all existing remote URLs by running the “git remote” command with the “-v” option:

$ git remote -v

Step 4: View Present GitHub Remote Repository Branches

Then, go to GitHub remote repository and check all the existing remote branches:

Step 5: Refresh Remote Repository Branches

After that, run the “git remote update” command with the remote name and “–prune” option:

$ git remote update origin --prune

As a result, the particular remote branch that was deleted from GitHub will also be pruned from the local repository, and the list of remote branches will refresh:

Step 6: Verify Refresh Remote Branches List

Lastly, run the “git branch” command to ensure that the list of remote branches is refreshed:

$ git branch -a

That’s all! We have efficiently explained the process of refreshing the list of remote branches.

Conclusion

To refresh the list of remote branches, first, move to the Git particular repository. Then, view the list of all Git branches, including the remote and local branches. After that, check the remote URL, go to the GitHub hosting service, and view the list of all remote branches. Next, run the “$ git remote update <remote-name> –prune” command. This write-up demonstrated the procedure of refreshing the list of remote branches.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.