Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions book/02-git-basics/sections/remotes.asc
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ Collaborating with others involves managing these remote repositories and pushin
Managing remote repositories includes knowing how to add remote repositories, remove remotes that are no longer valid, manage various remote branches and define them as being tracked or not, and more.
In this section, we'll cover some of these remote-management skills.

[NOTE]
.Remote repositories can be on your local machine.
====
It is entirely possible that you can be working with a ``remote'' repository that is, in fact, on the same host you are.
The word ``remote'' does not necessarily imply that the repository is somewhere else on the network or Internet, only that it is elsewhere.
Working with such a remote repository would still involve all the standard pushing, pulling and fetching operations as with any other remote.
====

==== Showing Your Remotes

To see which remote servers you have configured, you can run the `git remote` command.(((git commands, remote)))
It lists the shortnames of each remote handle you've specified.
If you've cloned your repository, you should at least see `origin` that is the default name Git gives to the server you cloned from:
If you've cloned your repository, you should at least see `origin` -- that is the default name Git gives to the server you cloned from:

[source,console]
----
Expand Down Expand Up @@ -94,7 +102,7 @@ From https://github.com/paulboone/ticgit
* [new branch] ticgit -> pb/ticgit
----

Paul's master branch is now accessible locally as `pb/master` you can merge it into one of your branches, or you can check out a local branch at that point if you want to inspect it.
Paul's master branch is now accessible locally as `pb/master` -- you can merge it into one of your branches, or you can check out a local branch at that point if you want to inspect it.
(We'll go over what branches are and how to use them in much more detail in <<_git_branching>>.)

[[_fetching_and_pulling]]
Expand All @@ -112,7 +120,7 @@ After you do this, you should have references to all the branches from that remo

If you clone a repository, the command automatically adds that remote repository under the name ``origin''.
So, `git fetch origin` fetches any new work that has been pushed to that server since you cloned (or last fetched from) it.
It's important to note that the `git fetch` command only downloads the data to your local repository it doesn't automatically merge it with any of your work or modify what you're currently working on.
It's important to note that the `git fetch` command only downloads the data to your local repository -- it doesn't automatically merge it with any of your work or modify what you're currently working on.
You have to merge it manually into your work when you're ready.

If your current branch is set up to track a remote branch (see the next section and <<_git_branching>> for more information), you can use the `git pull` command to automatically fetch and then merge that remote branch into your current branch.(((git commands, pull)))
Expand Down Expand Up @@ -208,7 +216,7 @@ paul
It's worth mentioning that this changes all your remote-tracking branch names, too.
What used to be referenced at `pb/master` is now at `paul/master`.

If you want to remove a remote for some reason you've moved the server or are no longer using a particular mirror, or perhaps a contributor isn't contributing anymore you can either use `git remote remove` or `git remote rm`:
If you want to remove a remote for some reason -- you've moved the server or are no longer using a particular mirror, or perhaps a contributor isn't contributing anymore -- you can either use `git remote remove` or `git remote rm`:

[source,console]
----
Expand Down