Git

How Do You Stop Tracking a Remote Branch in Git?

To connect the local repository with the GitHub server for updating other project members, they can set the remote URL. Additionally, to push local branch content to the remote branch, they need to set the desired local branch as a tracking branch, which means it will track a remote branch. However, sometimes they want to keep the settle tracking local branch and remove it from the remote server. In that case, they can use the “git branch -d -r <remote-tracking-branch>” command.

This post will explain the method to stop tracking a Centralized server branch in Git.

How Do You Stop Tracking a GitHub Branch in Git?

Implement the following steps to stop the tracking branches in Git:

  • Go to the Git root directory.
  • List all existing remote tracking branches.
  • Run the “git branch -d -r <remote-tracking-branch>” command.

Step 1: Move to Git Root Repository

At first, execute the “cd” command with the root directory path and navigate to it:

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

Step 2: List All Tracking Branches

Then, use the “git branch” command along with the “-vv” option to display the list of all branches with commit detail including tracking:

$ git branch -vv

It can be seen in the below-given output, the highlighted branch “origin/master” is set as a tracking branch:

Step 3: Delete Tracking a Remote Branch

Now, run the following command to stop the tracking of a remote branch process in Git:

$ git branch -d -r origin/master

Here, the “-d” indicates the “delete”, the “-r” is used for recursively and “origin/master” is the remote tracking branch:

Step 4: Verification

Lastly, to ensure that the tracking of a remote branch is stopped or not, use the below-stated command:

$ git branch -vv

According to the provided output, the previously settle tracking a remote branch procedure stopped successfully:

That’s all! We have explained the method to end tracking a remote branch in Git.

Conclusion

To stop the tracking remote branch in Git, first, move to the Git root directory and list the remote tracking branches. Then, execute the “git branch -d -r <remote-tracking-branch>” command. This post illustrated the way to stop tracking GitHub branches in Git.

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.