I find it little confusing to know the difference between git branch --set-upstream-to vs git remote add origin or even git remote add upstream
Basically I have a bare repository created with git init --bare which is shared on network so that other developers could also push to it so that we have our projects versioned locally but not sure which command should I run amongst above three (or if there is some other) to track that central repo eg we push our changes from all projets to that central bare repo and pull/fetch from it too.
Can anyone please enlighten on this?
git remote addcreates a remote, which is a shorthand name for another repository.git branch --set-upstream-tosets a branch to be tracked by the branch in the remote repository specified.What you are wanting to do is track a remote branch, which is done with
git branch --set-upstream-toor more simplygit branch -u.when you clone a repository from another, a remote is created named
originand the branchmasteris checked out. The command to have your local branch master track the remote branch master isgit branch -u origin/master, and is executed from the local master branch.