Skip to content

Instantly share code, notes, and snippets.

@ogryzek
Last active August 29, 2015 13:57

Revisions

  1. ogryzek revised this gist Oct 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -47,7 +47,7 @@ Here, I've added a link to a stylesheet. I've also omitted some [optional tags](

    <title>Drew's Site</title>

    <link rel="stylesheet" src="assets/stylesheets/styles.css">
    <link rel="stylesheet" href="assets/stylesheets/styles.css">

    <h1>Drew's Site</h1>

  2. ogryzek revised this gist Mar 17, 2014. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -174,7 +174,7 @@ h1 {
    text-shadow: 2px 2px #444;
    }
    ```
    This gives us the opportunity to review the conflicts and decide what should be done. You can see the HEAD shows what is currently in the branch you are on, and bellow the ======= it shows the changes trying to be merged in. Perhaps, in this case, we want the body to have color *and* background-color defined in the stylesheet. Correct the conflict as appropriate, save the file, add it to the staging area, and make a commit.
    This gives us the opportunity to review the conflicts and decide what should be done. You can see the HEAD shows what is currently in the branch you are on, and bellow the ======= it shows the changes trying to be merged in. Perhaps, in this case, we want the body to have color *and* background-color defined in the stylesheet.
    ```css
    body{
    color: #888;
    @@ -185,7 +185,8 @@ h1 {
    color: #cee;
    text-shadow: 2px 2px #444;
    }
    ```
    ```
    Correct the conflict as appropriate, save the file, add it to the staging area, and make a commit.
    ```bash
    git add .
    git commit -m "Merge conflict_styles"
  3. ogryzek revised this gist Mar 17, 2014. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -174,7 +174,7 @@ h1 {
    text-shadow: 2px 2px #444;
    }
    ```
    This gives us the opportunity to review the conflicts and decide what should be done. You can see the HEAD shows what is currently in the branch you are on, and bellow the ======= it shows the changes trying to be merged in. Perhaps, in this case, we want the body to have color *and* background-color defined in the stylesheet. Correct the conflict as appropriate.
    This gives us the opportunity to review the conflicts and decide what should be done. You can see the HEAD shows what is currently in the branch you are on, and bellow the ======= it shows the changes trying to be merged in. Perhaps, in this case, we want the body to have color *and* background-color defined in the stylesheet. Correct the conflict as appropriate, save the file, add it to the staging area, and make a commit.
    ```css
    body{
    color: #888;
    @@ -186,6 +186,10 @@ h1 {
    text-shadow: 2px 2px #444;
    }
    ```
    ```bash
    git add .
    git commit -m "Merge conflict_styles"
    ```
    You should now have a sense of why it's important to commit often (to prevent an abunadance of conflicts!), and it may be starting to make sense that we should always be up to date with *master*, so we do not overwrite newer revisions with code that was current when we created our branch. If this isn't all clear yet, don't worry! It will make much more sense very soon.


  4. ogryzek revised this gist Mar 17, 2014. 1 changed file with 59 additions and 1 deletion.
    60 changes: 59 additions & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -129,5 +129,63 @@ Fast-forward
    It looks like there were no conflicts, and everything is working fine, so we can delete the branch *my_styles*
    ```bash
    git branch -d my_styles
    ```
    ```
    __Resolving Merge Conflicts__
    Sometimes, when we merge there are conflicts. We should always resolve the conflicts locally, before making a pull request for our remote repositories (more on this, when we cover Github!)

    Make a new branch called *conflict_styles* and switch to it
    ```bash
    git checkout -b conflict_styles
    ```
    Open up assets/stylesheets/styles.css in your preferred editor, change the body *color* to *background-color*, save it, add the changes to the git staging area, and make a commit
    ```css
    /* assets/stylesheets/styles.css */
    body {
    background-color: blue;
    }
    ```
    ```bash
    git add .
    git commit -m "Change body background color to blue"
    ```
    Checkout the master branch `git checkout master`, and merge conflict_styles
    ```bash
    git checkout master
    git merge conflict_styles
    ```
    This should give some output warning of *CONFLICT*
    ```bash
    Auto-merging assets/stylesheets/styles.css
    CONFLICT (add/add): Merge conflict in assets/stylesheets/styles.css
    Automatic merge failed; fix conflicts and then commit the result.
    ```
    Open up the styles.css in your editor and notice how the conflicts are indicated
    ```css
    body{
    <<<<<<< HEAD
    color: #888;
    =======
    background-color: blue;
    >>>>>>> conflict_styles
    }

    h1 {
    color: #cee;
    text-shadow: 2px 2px #444;
    }
    ```
    This gives us the opportunity to review the conflicts and decide what should be done. You can see the HEAD shows what is currently in the branch you are on, and bellow the ======= it shows the changes trying to be merged in. Perhaps, in this case, we want the body to have color *and* background-color defined in the stylesheet. Correct the conflict as appropriate.
    ```css
    body{
    color: #888;
    background-color: blue;
    }

    h1 {
    color: #cee;
    text-shadow: 2px 2px #444;
    }
    ```
    You should now have a sense of why it's important to commit often (to prevent an abunadance of conflicts!), and it may be starting to make sense that we should always be up to date with *master*, so we do not overwrite newer revisions with code that was current when we created our branch. If this isn't all clear yet, don't worry! It will make much more sense very soon.


  5. ogryzek revised this gist Mar 17, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -99,6 +99,7 @@ git commit -m "Add stylesheet and assets directories"

    You should now have 3 commits in your `git log`, and be starting to get comfortable with adding files and making commits.

    __Merging Branches__
    Let's move back to the master branch then list the folders and files in our working directory
    ```bash
    git checkout master
    @@ -130,4 +131,3 @@ It looks like there were no conflicts, and everything is working fine, so we can
    git branch -d my_styles
    ```

    __Merging Branches__
  6. ogryzek revised this gist Mar 17, 2014. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -124,6 +124,10 @@ Fast-forward
    index.html | 4 ++--
    2 files changed, 10 insertions(+), 2 deletions(-)
    create mode 100644 assets/stylesheets/styles.css
    ```
    ```
    It looks like there were no conflicts, and everything is working fine, so we can delete the branch *my_styles*
    ```bash
    git branch -d my_styles
    ```

    __Merging Branches__
  7. ogryzek revised this gist Mar 17, 2014. 1 changed file with 27 additions and 0 deletions.
    27 changes: 27 additions & 0 deletions git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -99,4 +99,31 @@ git commit -m "Add stylesheet and assets directories"

    You should now have 3 commits in your `git log`, and be starting to get comfortable with adding files and making commits.

    Let's move back to the master branch then list the folders and files in our working directory
    ```bash
    git checkout master
    ls
    ```
    You may notice that there is only 1 file: index.html. Try going back to the *my_styles* branch and listing the files
    ```bash
    git checkout my_styles
    ls
    ```
    Now, you should notice the assets folder. The changes we made on the *my_styles* branch have not yet been merged to *master*. Once we're comfortable with our changes, and don't feel anything is broken, we can switch back to *master* and merge in the changes from *my_styles*

    ```bash
    git checkout master
    git merge my_styles
    ```
    This should give some output like so
    ```bash
    $ git merge my_styles
    Updating bea8dd6..60197f1
    Fast-forward
    assets/stylesheets/styles.css | 8 ++++++++
    index.html | 4 ++--
    2 files changed, 10 insertions(+), 2 deletions(-)
    create mode 100644 assets/stylesheets/styles.css
    ```

    __Merging Branches__
  8. ogryzek revised this gist Mar 17, 2014. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -95,4 +95,8 @@ Add all the files to the staging area, check git status, and make a commit.
    git add .
    git status
    git commit -m "Add stylesheet and assets directories"
    ```
    ```

    You should now have 3 commits in your `git log`, and be starting to get comfortable with adding files and making commits.

    __Merging Branches__
  9. ogryzek revised this gist Mar 17, 2014. 1 changed file with 9 additions and 2 deletions.
    11 changes: 9 additions & 2 deletions git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -85,7 +85,14 @@ body {
    color: #888;
    }

    p {
    color: #ece;
    h1 {
    color: #cee;
    text-shadow: 2px 2px #444;
    }
    ```
    Add all the files to the staging area, check git status, and make a commit.
    ```bash
    git add .
    git status
    git commit -m "Add stylesheet and assets directories"
    ```
  10. ogryzek revised this gist Mar 17, 2014. 1 changed file with 12 additions and 2 deletions.
    14 changes: 12 additions & 2 deletions git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -76,6 +76,16 @@ git checkout my_styles
    Make a directory called assets that contains a styles directory. Then create a styles.css file inside the styles directory.
    ```bash
    mkdir assets
    mkdir assets/styles
    touch assets/styles/styles.css
    mkdir assets/stylesheets
    touch assets/stylesheets/styles.css
    ```
    Open the styles.css in your preferred editor, and add some styles for your page.
    ```css
    body {
    color: #888;
    }

    p {
    color: #ece;
    }
    ```
  11. ogryzek revised this gist Mar 17, 2014. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -70,5 +70,12 @@ Create a new branch called *my_styles*
    ```bash
    git branch my_styles
    git checkout my_styles
    git branch
    ```
    **Note**:these two steps can be accomplished in one command, `git checkout -b my_styles`

    Make a directory called assets that contains a styles directory. Then create a styles.css file inside the styles directory.
    ```bash
    mkdir assets
    mkdir assets/styles
    touch assets/styles/styles.css
    ```
  12. ogryzek revised this gist Mar 17, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -66,7 +66,7 @@ When we want to make changes, rather than make them on the main working copy (ma

    `git branch` will display the local branches, with an asterisk on the current branch.

    Create a new branch called _my_styles_
    Create a new branch called *my_styles*
    ```bash
    git branch my_styles
    git checkout my_styles
  13. ogryzek revised this gist Mar 17, 2014. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -60,3 +60,15 @@ git commit -m "Add content to homepage"
    git status
    git log
    ```

    __Branches__
    When we want to make changes, rather than make them on the main working copy (master), we can create a new branch. It's a good idea to create a new branch, make some changes, merge the changes into master, then delete the branch, rather than continue working on a branch that you have already merged. Remember to commit often. This will make much more sense as it sinks in, and we will cover it in depth shortly.

    `git branch` will display the local branches, with an asterisk on the current branch.

    Create a new branch called _my_styles_
    ```bash
    git branch my_styles
    git checkout my_styles
    git branch
    ```
  14. ogryzek revised this gist Mar 17, 2014. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -52,4 +52,11 @@ Here, I've added a link to a stylesheet. I've also omitted some [optional tags](
    <h1>Drew's Site</h1>

    <p>This is my site, yo!
    ```
    ```

    After saving, run `git status` and see the changes made are not yet staged for commit. `git add .` will add all changes to the staging area. Commit changes that have been added to the staging area, then check the status and the logs.
    ```bash
    git commit -m "Add content to homepage"
    git status
    git log
    ```
  15. ogryzek revised this gist Mar 17, 2014. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -38,7 +38,8 @@ Now if we try `git status` we can see there is nothing to commit. Try `git log`
    __Build Out the Site__
    Open up index.html in your favorite editor ([sublime](https://www.sublimetext.com/docs/2/osx_command_line.html), [etc.](http://www.vim.org/)), and fill in some [valid HTML](http://validator.w3.org/).
    **note**: Open the file with Chrome from the command line, using `open -a "google chrome" index.html`
    I've added a link to a stylesheet.

    Here, I've added a link to a stylesheet. I've also omitted some [optional tags](https://google-styleguide.googlecode.com/svn/trunk/htmlcssguide.xml); feel free to include them, if it's more comfortable.
    ```html
    <!DOCTYPE html>

    @@ -50,5 +51,5 @@ I've added a link to a stylesheet.

    <h1>Drew's Site</h1>

    <p>This is my site, yo!</p>
    <p>This is my site, yo!
    ```
  16. ogryzek revised this gist Mar 17, 2014. 1 changed file with 15 additions and 1 deletion.
    16 changes: 15 additions & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -37,4 +37,18 @@ Now if we try `git status` we can see there is nothing to commit. Try `git log`

    __Build Out the Site__
    Open up index.html in your favorite editor ([sublime](https://www.sublimetext.com/docs/2/osx_command_line.html), [etc.](http://www.vim.org/)), and fill in some [valid HTML](http://validator.w3.org/).
    **note**: Open the file with Chrome from the command line, using `open -a "google chrome" index.html`
    **note**: Open the file with Chrome from the command line, using `open -a "google chrome" index.html`
    I've added a link to a stylesheet.
    ```html
    <!DOCTYPE html>

    <meta charset="UTF-8">

    <title>Drew's Site</title>

    <link rel="stylesheet" src="assets/stylesheets/styles.css">

    <h1>Drew's Site</h1>

    <p>This is my site, yo!</p>
    ```
  17. ogryzek revised this gist Mar 17, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -36,4 +36,5 @@ git commit -m "Add index file for site homepage"
    Now if we try `git status` we can see there is nothing to commit. Try `git log` to see a log of the commits in this repo. This is useful for git commands such as [revert, reset, and checkout](http://schacon.github.io/gitbook/4_undoing_in_git_-_reset,_checkout_and_revert.html).

    __Build Out the Site__
    Open up index.html in your favorite editor ([sublime](https://www.sublimetext.com/docs/2/osx_command_line.html), [etc.](http://www.vim.org/)). Open the file with Chrome from the command line, using `open -a "google chrome" index.html`
    Open up index.html in your favorite editor ([sublime](https://www.sublimetext.com/docs/2/osx_command_line.html), [etc.](http://www.vim.org/)), and fill in some [valid HTML](http://validator.w3.org/).
    **note**: Open the file with Chrome from the command line, using `open -a "google chrome" index.html`
  18. ogryzek revised this gist Mar 17, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -36,4 +36,4 @@ git commit -m "Add index file for site homepage"
    Now if we try `git status` we can see there is nothing to commit. Try `git log` to see a log of the commits in this repo. This is useful for git commands such as [revert, reset, and checkout](http://schacon.github.io/gitbook/4_undoing_in_git_-_reset,_checkout_and_revert.html).

    __Build Out the Site__
    Open up index.html in your favorite editor ([sublime](https://www.sublimetext.com/docs/2/osx_command_line.html), [etc.](http://www.vim.org/))
    Open up index.html in your favorite editor ([sublime](https://www.sublimetext.com/docs/2/osx_command_line.html), [etc.](http://www.vim.org/)). Open the file with Chrome from the command line, using `open -a "google chrome" index.html`
  19. ogryzek revised this gist Mar 17, 2014. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -33,4 +33,7 @@ You should now see that index.html a _change to be committed_. So far, we have i
    ```bash
    git commit -m "Add index file for site homepage"
    ```
    Now if we try `git status` we can see there is nothing to commit. Try `git log` to see a log of the commits in this repo. This is useful for git commands such as [revert, reset, and checkout](http://schacon.github.io/gitbook/4_undoing_in_git_-_reset,_checkout_and_revert.html).
    Now if we try `git status` we can see there is nothing to commit. Try `git log` to see a log of the commits in this repo. This is useful for git commands such as [revert, reset, and checkout](http://schacon.github.io/gitbook/4_undoing_in_git_-_reset,_checkout_and_revert.html).

    __Build Out the Site__
    Open up index.html in your favorite editor ([sublime](https://www.sublimetext.com/docs/2/osx_command_line.html), [etc.](http://www.vim.org/))
  20. ogryzek revised this gist Mar 17, 2014. 1 changed file with 13 additions and 1 deletion.
    14 changes: 13 additions & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -21,4 +21,16 @@ Create a file called index from the command line, then check its git status.
    ```bash
    touch index.html
    git status
    ```
    ```
    You should notice that index.html is in 'untracked files'. In order to add this file to be tracked, we can run `git add index.html`. If you have changed several files and want to add them all, you can add all files with `git add .`

    When we add files, we say they are _staged_ or have been _added to the staging area_. Add the index to the staging area and check the status again.
    ```bash
    git add index.html
    git status
    ```
    You should now see that index.html a _change to be committed_. So far, we have initialized a git repository, created a file, and added it to be staged. We can now 'commit' to make a saved point we can revert back to later, if we wish. When we create a git commit, we should give it a message (preferably a meaningful message).
    ```bash
    git commit -m "Add index file for site homepage"
    ```
    Now if we try `git status` we can see there is nothing to commit. Try `git log` to see a log of the commits in this repo. This is useful for git commands such as [revert, reset, and checkout](http://schacon.github.io/gitbook/4_undoing_in_git_-_reset,_checkout_and_revert.html).
  21. ogryzek revised this gist Mar 17, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,8 @@

    [Try Git](http://try.github.io/levels/1/challenges/1) |
    [Markdown Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#links) |
    [Pro Git](http://git-scm.com/book)
    [Pro Git](http://git-scm.com/book) |
    [Git Config](http://cheat.errtheblog.com/s/git)

    __Getting Started__
    In the terminal start by creating a new directory, then run `git init` to initialize a git repository
  22. ogryzek revised this gist Mar 17, 2014. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -13,8 +13,9 @@ git init
    ```
    Now that we have initialized a git repo, we can add files, and make edits, while trackin changes along the way. We can also revert back to previous 'commits' and merge branches. We'll go into detail about these terms mean and do shortly.

    For this example, let's create a static website with a couple of pages, stylesheets, javascripts, and maybe even some fonts.
    __Tracking Changes__
    For this example, let's create a static website with a couple of pages, stylesheets, javascripts, and maybe even some fonts.

    __Tracking Changes__
    Create a file called index from the command line, then check its git status.
    ```bash
    touch index.html
  23. ogryzek revised this gist Mar 17, 2014. 1 changed file with 10 additions and 2 deletions.
    12 changes: 10 additions & 2 deletions git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -10,5 +10,13 @@ In the terminal start by creating a new directory, then run `git init` to initia
    mkdir my_new_directory
    ck my_new_directory
    git init
    ```

    ```
    Now that we have initialized a git repo, we can add files, and make edits, while trackin changes along the way. We can also revert back to previous 'commits' and merge branches. We'll go into detail about these terms mean and do shortly.

    For this example, let's create a static website with a couple of pages, stylesheets, javascripts, and maybe even some fonts.
    __Tracking Changes__
    Create a file called index from the command line, then check its git status.
    ```bash
    touch index.html
    git status
    ```
  24. ogryzek revised this gist Mar 17, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@
    [Try Git](http://try.github.io/levels/1/challenges/1) |
    [Markdown Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#links) |
    [Pro Git](http://git-scm.com/book)

    __Getting Started__
    In the terminal start by creating a new directory, then run `git init` to initialize a git repository
    ```bash
  25. ogryzek revised this gist Mar 17, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -8,5 +8,6 @@ In the terminal start by creating a new directory, then run `git init` to initia
    ```bash
    mkdir my_new_directory
    ck my_new_directory
    git init```
    git init
    ```

  26. ogryzek revised this gist Mar 17, 2014. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,11 @@

    [Try Git](http://try.github.io/levels/1/challenges/1) |
    [Markdown Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#links) |
    [Pro Git](http://git-scm.com/book)
    [Pro Git](http://git-scm.com/book)
    __Getting Started__
    In the terminal start by creating a new directory, then run `git init` to initialize a git repository
    ```bash
    mkdir my_new_directory
    ck my_new_directory
    git init```
  27. ogryzek revised this gist Mar 17, 2014. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # Introduction to Git & Github

    [try git](http://try.github.io/levels/1/challenges/1)
    [Try Git](http://try.github.io/levels/1/challenges/1) |
    [Markdown Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#links) |
    [Pro Git](http://git-scm.com/book)
  28. ogryzek revised this gist Mar 17, 2014. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion git_and_github.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,3 @@
    # Introduction to Git & Github
    # Introduction to Git & Github

    [try git](http://try.github.io/levels/1/challenges/1)
  29. ogryzek renamed this gist Mar 17, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  30. ogryzek created this gist Mar 17, 2014.
    1 change: 1 addition & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    # Introduction to Git & Github