diff --git a/materials/2-Git.md b/materials/2-Git.md index b302f48..a7326d4 100644 --- a/materials/2-Git.md +++ b/materials/2-Git.md @@ -107,45 +107,68 @@ Sometimes we accidentally add a file(s) to be committed by mistake. We can reset ``` +## Collaboration - Sharing Your Work on Github -## Advanced +Now that you have a git repository with some work. Let's share our icecream shop with the world. -### Creating a branch +Let's first visit Github.com and choose to create a "New Repository" by selecting it from the plus icon in the upper right corner. -Often, we might be working with others but don't want to step on each others toes and cause conflicts. In git, we use branches to work in parallel and then merge our code together. +Next on the "Create a new repository" screen, let's: -``` +- Make the respository name "ice-cream-shop" +- Press the "Create repository" Button - $ git branch - $ git branch add-some-gelato - $ git branch - $ git checkout add-some-gelato - $ git branch - $ touch gelato.txt - $ git add gelato.txt - $ git status - $ git commit -m 'adding gelato to the shop' -``` +#### Congrats, you've created your first repository +Now let's share your icecream show with the world. -### Merge A Branch +## Exercise -Now that we have added some gelato in a separate branch (body of work) of our code, let's merge it into the master branch. +Follow the instructions in this section "…or push an existing repository from the command line" -``` - $ git checkout master - $ git merge add-some-gelato - $ ls +## Deep Dive Into Collaboration with Git -``` +Now that you've set up your `ice-cream-shop` repository on github, let's explore the how and why that worked. + +#### What is a remote in git? + +Type in your terminal: + +`git remote` + +Let's use the commandline to learn a little more about `git remote` + +`git remote --verbose` + + +### Exercise + +1) Can you figure out what is the command to "show remote url after name?" +2) What is url for `origin` in your git repository? + +Bonus: +3) Can you figure out how to remove and add a remote to this repository? +4) Add nathan's (ice-cream-shop)[https://github.com/ndanielsen/ice-cream-shop.git] as a remote named `ndanielsen` + + +#### What is `git push`? + +Typical Format: `git push ` + +The `git push` command is used to transfer your git commits on your working branch (ie master) to a remote location such as github. +See "4-Git-Advanced.md" for more on branches. -### Resources +In another sense, `git push` is used to syncronize your work on local computer with that on the github website server. -Here are a few other resources that might be helpful for diving deeper into git. +### Exercise -- [The `Pro Git` e-book](https://git-scm.com/book/en/v2) -- [What is a commit?](https://chris.beams.io/posts/git-commit/) -- [Atlassian Git Tutorial](https://www.atlassian.com/git/tutorials) +- Create a file named `house_special.txt` +- In that file, write down a special dessert that is contains icecream! +- Add and commit that file to git +- Send that file up to github (hint: how did you originally send up your repo to github?) +### Further Reading +- [Atlassian - git syncing](https://www.atlassian.com/git/tutorials/syncing) +- [The `Pro Git` e-book](https://git-scm.com/book/en/v2) \ No newline at end of file diff --git a/materials/4-Git-Advanced.md b/materials/4-Git-Advanced.md new file mode 100644 index 0000000..e990763 --- /dev/null +++ b/materials/4-Git-Advanced.md @@ -0,0 +1,90 @@ + +# Advanced + +## Git Branches + +A branch represents a different line or work that is separated from the `main` or `master` branch. It is a helpful mechanism for allowing multiple people to work on the same git repository (and github project) in potentially overlapping locations without stepping on too many toes. + +In git, we use branches to work in parallel and then merge our code together. + + + +Check out your current branch for your `ice-cream-shop` project. + +``` + $ git branch +``` + +You should only have the master branch. + + +### Creating a branch + +Let's create a branch to add in some gelato to our iceceam shop. + +``` + $ git branch add-some-gelato + $ git branch + +``` + +Let's now move into that branch and add a file named 'gelato.txt' + +``` + $ git checkout add-some-gelato + $ git branch + $ touch gelato.txt + $ git add gelato.txt + $ git status + $ git commit -m 'adding gelato to the shop' + +``` + +Exercise: +1) Let's `push` these changes up to our github for this. +hint: `git push ` +2) Checkout your github `ice-cream-shop` repo to make sure that it made it. +3) On github, make a pull request into your `master` branch and then merge it in. + +#### Protip: +You can create and checkout a branch in one command. +``` + $ git checkout -b some-branch` +``` + + + +### Pulling Down a Branch + +Now that we have an updated `master` branch. Let's get the same copy of it on our local computer + +``` + $ git checkout master + $ git pull + +``` + +Exercise: +1) How can you confirm that your gelato commits have made it down? +2) Can you figure out how to delete your old branch `add-some-gelato`? +hint: `git branch --help` + + +### Merge A Branch + +Now that we have added some gelato in a separate branch (body of work) of our code, let's merge it into the master branch. + +``` + $ git checkout master + $ git merge add-some-gelato + $ ls + +``` + +### Resources + +Here are a few other resources that might be helpful for diving deeper into git. + +- [What is a commit?](https://chris.beams.io/posts/git-commit/) +- [Atlassian Git Tutorial](https://www.atlassian.com/git/tutorials) +