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:
Step 2: List All Existing Branches
Now, list all existing remote and local branches through the provided command:
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:
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:
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:
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.