• 0

Local branch, remote tracking branch and remote branches in git

I just put together a simple visual model for the different kinds of branches it git. You are likely to find this information the most useful when you are dealing with git pull and git fetch.

enter image description here

As you can see, there are not just two but three kinds of branches in GIT.

1 : Local branches This is what you get when you run the the git branch command. You can also find them in the .git/refs/heads/ directory.

2 : Remote Tracking branches As implied by the name, these branches track remote branches. Some of your local branches also map directly to these branches. Think of these are a route through which data on the remote branches are accessed.

3 : Remote branches These are branches that live on a remote machine( or in a different directory in the same machine in case you configured one directory to act as a central point). All your remotes are listed in the .git/refs/remotes/ directory but you can also list them using the command git remote -v which is much more convenient since it also shows you the url for each remote.