Recent Changes - Search:

Basics

Languages

Tools

OS

Resources

PmWiki

pmwiki.org

edit SideBar

Git /

Tracking remote repos

After setting up a repo, there might come an occasion to track other repos for their progress.

To define a new remote repository (or a "remote" for short), use the git remote command:

git remote add options NameOfRepo LocationOfRepo

where options will modify how the remote is added, especially interesting is the -f option which will download the information from the new remote at once. The NameOfRepo is a name you define, ideally pretty short so it is easy to add to commands. LocationOfRepo is the url or ssh location of the remote repo, either user@server:Path/To/Repo or https://github.com/Someone/RepoName.

Once the remote has been added this way, typing:

git branch -a

will show all branches from the remote repo, in red to represent that git is aware of them, but they are not in use. These branches can be accessed through normal checkout, however they will be accessed in detached head. You can then create the local branch version in the usual fashion:

git checkout -b BranchName

Tracking branches

To set a local branch to track a remote branch, so that pushing and pulling interacts with that branch in a remote repo, you need to set the "upstream" (ie the reference) to the remote branch, using:

git branch --set-upstream-to=RemoteRepo/RemoteBranch LocalBranch

where RemoteRepo is the name of the remote repo (setup as above), RemoteBranch is the name of the branch in the remote repo and LocalBranch is the local branch that will be tracking the remote one. If LocalBranch is not specified, git will apply the change to the currently checked-out branch.

Edit - History - Print - Recent Changes - Search
Page last modified on November 21, 2017, at 05:44 PM