Prior to completing the module below it is highly recommended that you look at the following learning material. Even if you consider yourself a Git expert, there is material in the resources below that even seasoned users are unaware of.
Login creds for the following tutorials can be found here. Email your team lead or department head if you have any questions.
Official Documentation
Code School
Tuts+
Note: This module primarily assumes you are using Terminal, and may not cover necessary or extra steps you might need to take when using Git client (such as SourceTree or Tower).
- Init a new
localgit repo calledgit_test. - Create a
remoterepository in your personal GitHub namespace calledgit_test, and add it as a remote repo (in Terminal or your Git client). - Create a new file called
friends.txtwith the first and last name of 5 people on lines 1-5. - Add the file to the local repo.
- Commit the file to the repo with a message of, "these are my friends".
- Push your changes to the
remoterepo. - Go into GitHub, view the
friends.txtfile, edit it to add a 6th friend, and commit it in the browser with the message, "added another friend". - Next, pull the code to your
localrepo. - Create a branch in
localcalledparty, and switch to it (checkout). - Now, in the
partybranch, add 4 more friends' names tofriends.txt(for a total of 10). Commit those changes with a message of, "adding more friends for the party". - Next, switch back to the
masterbranch, edit thefriends.txtfile (which has 6 friends) and add 9 more friends (for a total of 15). Make sure you include some of the friends you added in thepartybranch, but not all of them. Commit this with a message of, "new friends". - Now, merge the
partybranch into themasterbranch. This should cause a CONFLICT. Edit thefriends.txtfile and fix the merge conflict, removing any duplicate names. The total number of names you'll have at the end of this process will depend on the number of people you duplicated between themasterandpartybranches. - Commit the changes using the default merge message.
- Push all branches to the
remoterepository. - Switch to the
partybranch (inlocal) and rebase it from themasterbranch. Push thepartybranch updates to theremoterepo. - In the
partybranch (inlocal), create a new file calledfamily.txtwith 2 family member's names on line 1 and 2. - Add the
family.txtfile, then stash it. Switch to themasterbranch, pop the stash, and stage the file in the repo. - Now create another file called
pets.txtwith 2 names of your pets. If you don't have any, make them up. - Commit that file (there should now be two), with the message "some of my family and pets".
- Edit the current staged commit and split it into 2 separate commits, 1 for each file with messages, "my family", for family.txt and, "my pets", for pets.txt. Then, push to the remote repo.
- Look at the git log in
onelineand verify your commit messages. - In a new working (
local) directory, create a totally new git repo calledcommunity. Create a new repo of the same name in your GitHub (remote) account (in your own namespace). Add theremoteto yourlocalgit repo. - Create a new file (in
local) called,address.txtwith your address in it. Stage, commit, and push the changes with a relevant commit message. - Next, bring in your
git_testrepo to thecommunityrepo as a submodule. Stage your changes and commit with a relevant commit message. - Now, go into the
git_testsubmodule folder, add a file calledtodo.txtand put a todo item in it. Stage, commit, and push the file (to thegit_testrepo). - Exit out of the
git_testfolder/submodule and go into to yourcommunityrepo's root. Stage thegit_testfolder/submodule, add a commit with the message "first commit with submodule" and push to the remote repo.
When you are done, verify you have pushed your changes to GitHub. Please create a tag called v1.0 with a message of "ready for review" in both the git_test and community repos. Be sure your tags are pushed to the remote repository and are visible in GitHub.
In the community repo, create an issue titled Review Module 1 - Git Basics and @mention your mentor and team leader.