Skip to content
Merged
Show file tree
Hide file tree
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
60 changes: 60 additions & 0 deletions book/06-github/sections/2-contributing.asc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Here's how it generally works:
5. Open a Pull Request on GitHub.
6. Discuss, and optionally continue committing.
7. The project owner merges or closes the Pull Request.
8. Put the changes back in your GitHub public repository.

This is basically the Integration Manager workflow covered in <<ch05-distributed-git#_integration_manager>>, but instead of using email to communicate and review changes, teams use GitHub's web based tools.

Expand Down Expand Up @@ -417,3 +418,62 @@ This isn't technically GitHub Flavored Markdown, but it is incredibly useful. In
image::images/markdown-08-drag-drop.png[Drag and drop images]

If you look at <<_md_drag>>, you can see a small ``Parsed as Markdown'' hint above the text area. Clicking on that will give you a full cheat sheet of everything you can do with Markdown on GitHub.

[[_fetch_and_push_on_different_repositories]]
==== Keep your GitHub public repository up-to-date

Once you forked from a GitHub repository, your forked repository lives alone and is autonomous regarding the original one.
In particular, when the original repository has new commits, GitHub informs you by a message like:
[source,text]
----
This branch is X commits behind <organization>:master.
----
For example:
[source,text]
----
This branch is 5 commits behind progit:master.
----

But your GitHub repository will never be automatically updated by GitHub; this is something that you must do yourself.
Fortunately, this is very easy to do.

One possibility to do this requires no configuration.
For example, if you forked from `https://github.com/progit/progit2.git`, you can keep your `master` branch up-to-date like this:

[source,console]
----
$ git checkout master <1>
$ git pull https://github.com/progit/progit2.git <2>
$ git push origin master <3>
----
<1> If you were on another branch, return to `master`.
<2> Fetch changes from `https://github.com/progit/progit2.git` and merge them into `master`.
<3> Push your `master` branch to `origin`.

This just works but it is a little verbose.
Another possibility allows to do the same thing without the need to precise the repositories to pull from and push to.
To do so, you need a few configuration:

[source,console]
----
$ git remote add progit https://github.com/progit/progit2.git <1>
$ git branch --set-upstream-to=progit/master master <2>
$ git config --local remote.pushDefault origin <3>
----
<1> Add the source repository and give it a name.
Here, I have chosen to call it `progit`.
<2> Set your `master` branch follow `progit`.
Then your future fetches will fetch from `progit`.
<3> Define the default push repository to `origin`.

Now you can fetch from `progit` and push to `origin` as simply as:

[source,console]
----
$ git checkout master <1>
$ git pull <2>
$ git push <3>
----
<1> If you were on another branch, return to `master`.
<2> Fetch changes from `progit` and merge changes into `master`.
<3> Push your `master` branch to `origin`.
6 changes: 6 additions & 0 deletions book/10-git-internals/sections/refspec.asc
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ If they want Git to do that automatically each time they run `git push origin`,

Again, this will cause a `git push origin` to push the local `master` branch to the remote `qa/master` branch by default.

[NOTE]
====
You cannot use the refspec to fetch from one repository and push to another one.
For an example to do so, refer to <<ch06-github#_fetch_and_push_on_different_repositories>>.
====

==== Deleting References

You can also use the refspec to delete references from the remote server by running something like this:
Expand Down