Outils pour utilisateurs

Outils du site


issue77:c_c

Ceci est une ancienne révision du document !


Last month, I introduced readers to the newly minted github repository that contained the CLI Cookbook I put together with input from our readers. Since then, I've had some activity from readers – fixing mistakes and adding content. However, in doing so, I realized I never included information on keeping your local fork synchronized with my master branch – which makes handling pull requests very difficult for me, as I have to manually carry over any changes. As such, I will briefly cover fetching upstream changes.

Steps 1-3 are required when you first set up your repository on the local system. Step 4 is the command you want to run for pulling in upstream updates. As such, the first time you do this, follow all 4 steps, but after that you can jump right to Step 4.

Step 1 Fork the repository (on github simply click the fork button on the repository you want to fork).

Step 2 Get a local copy of the fork going.

git clone https://github.com/<username>/<repo name>.git

Replace <username> with your actual user name, and <repo name> with the name of the repository.

Step 3 Configure upstream (remote repository).

cd <repo name>

git remote add upstream https://github.com/lswest/cli-cookbook.git

Replace <repo name> with the name of your local fork. The second command creates a new repository alias in the configuration file for the local fork (located in the .git folder). The URL will need to be changed according to what repository it is you forked.

Step 4 Now if you want to pull in any new changes from the original repository, all you need to do is this:

git fetch upstream

git merge upstream/master

This fetches any commits to the original repository, and the second command merges them into your local copy. If you have changes going in your local fork that don't exist in the original, and try to fetch updates, it will result in conflicts. The easiest way to resolve these is to use the following command:

git mergetool

This should take you through each conflict step by step (it's extremely useful to have some knowledge of diff, as it is the general format used for conflicts).

As you can see – this isn't an extremely complicated process. The key point is how to register the original repository as upstream, after which it progresses as you might imagine. Unfortunately, this won't completely negate the need to resolve conflicts; however, it will cut down on the amount of conflicts I will have to manage on the master branch, and should therefore allow me to handle any pull requests quickly.

I hope this has helped explain how to keep your forks up to date – and is the start of plenty more additions to the CLI Cookbook! Thanks to anyone who has contributed so far (either in the Google Doc or the Github repository). If you have any questions, or suggestions, feel free to email me at lswest34+fcm@gmail.com.

issue77/c_c.1380639081.txt.gz · Dernière modification : 2013/10/01 16:51 de andre_domenech