Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Branch and Remote in GIT?

Tags:

git

github

I am currently taking the course GIT and GITHUB from udacity. One thing I'm really confused is what is the difference between remote and branch as both makes the same sense to me, as per my understanding.

like image 464
raju jha Avatar asked Oct 17 '22 21:10

raju jha


2 Answers

To be precise here, let's use Git's own documentation on What a Branch Is:

A branch in Git is simply a lightweight movable pointer to one of these commits.

A branch in Git is just a pointer to a commit. Typically, this commit will in turn be connected with other commits in a chain or branching chain structure. When we usually think of branches, we think of collections of commits logically ordered in some way, but technically speaking a branch is just a pointer to a commit.

Again, from the documentation on Working with Remotes:

Remote repositories are versions of your project that are hosted on the Internet or network somewhere

The remote, which is really just short for remote repository, is a central place where branches and their commits are stored. The remote can also have branches, but typically you don't interact directly with these remote branches. Instead, there are local remote tracking branches, which, as their name implies, track the true state of the branches on the actual remote.

like image 160
Tim Biegeleisen Avatar answered Oct 21 '22 04:10

Tim Biegeleisen


They are totally different concepts.

A remote is basically a location where a copy of the repository is stored. So for example you could have one remote in GitHub, another in BitBucket, another in Kelly's PC, etc.

A branch in your repository means that you have temporarily made some changes that you don't want to put into the main branch just yet because you aren't done with it (or for other reasons). They can be local, so that your remotes never see them, or you can push the branch to the remotes.

like image 30
Maria Ines Parnisari Avatar answered Oct 21 '22 06:10

Maria Ines Parnisari