-
Notifications
You must be signed in to change notification settings - Fork 104
Git Cookbook
This document contains recipes for how to do specific tasks with Git that students may/will need to do while participating in CodeU. Rather than a general tutorial on how to use Git, this document provides specific step-by-step explanations on how handle specific scenarios.
Every recipe will have a descriptive name followed by a verbose description. Instructions are required and should be verbose and all inclusive. No recipe should assume any understand of any other Git concepts. There is an optional notes section for each recipe that will contain further contextual notes about the recipe.
When you fork a repo, you create a copy of a GitHub repo and named it something else. When there is an update to the origin, you may want that update in your repo too. You will need to merge the changes from that repo into your repo.
Now you need to fetch the changes from the original repo. To do this run:
git fetch <remote-repo-url> <remote-branch-name>
This will copy the branch from the remote server to your local machine but will save it behind the scenes with the name FETCH_HEAD.
Now you are going to apply your changes on top of the remotes changes. To do this run:
git rebase FETCH_HEAD
This will find the changes in your current branch and apply them on top of the changes in the remote’s branch. If there are any conflicts, for example you and the remote changed the same code, the rebase will stop and you can edit the file before continuing the rebase.
Now that the rebase is done, you may want to verify that it all works. To do this run:
git log
This will show you the history of changes. You should see all of your changes on top of the changes from the remote.
This will copy all changes from the remote to your local copy. This should only be done if you want all the changes from the remote.