Using git with GitHub

We will create a new GitHub repository and simulate its use by two different users A and B to illustrate how to use a shared repository to collaborate and issues that might arise.

See Git’s extensive documentation

Atlassian provides a detailed tutorial

Git cheat sheet

Cheat sheet

Cheat sheet

Getting help

In [1]:
git help
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone      Clone a repository into a new directory
   init       Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add        Add file contents to the index
   mv         Move or rename a file, a directory, or a symlink
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect     Use binary search to find the commit that introduced a bug
   grep       Print lines matching a pattern
   log        Show commit logs
   show       Show various types of objects
   status     Show the working tree status

grow, mark and tweak your common history
   branch     List, create, or delete branches
   checkout   Switch branches or restore working tree files
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   merge      Join two or more development histories together
   rebase     Reapply commits on top of another base tip
   tag        Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch      Download objects and refs from another repository
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
In [2]:
git help log | head -20
GIT-LOG(1)                        Git Manual                        GIT-LOG(1)



NNAAMMEE
       git-log - Show commit logs

SSYYNNOOPPSSIISS
       _g_i_t _l_o_g [<options>] [<revision range>] [[--] <path>...]


DDEESSCCRRIIPPTTIIOONN
       Shows the commit logs.

       The command takes options applicable to the ggiitt rreevv--lliisstt command to
       control what is shown and how, and options applicable to the ggiitt ddiiffff--**
       commands to control how the changes each commit introduces are shown.

OOPPTTIIOONNSS
       --follow
In [3]:
git log --help | head -20
GIT-LOG(1)                        Git Manual                        GIT-LOG(1)



NNAAMMEE
       git-log - Show commit logs

SSYYNNOOPPSSIISS
       _g_i_t _l_o_g [<options>] [<revision range>] [[--] <path>...]


DDEESSCCRRIIPPTTIIOONN
       Shows the commit logs.

       The command takes options applicable to the ggiitt rreevv--lliisstt command to
       control what is shown and how, and options applicable to the ggiitt ddiiffff--**
       commands to control how the changes each commit introduces are shown.

OOPPTTIIOONNSS
       --follow
In [4]:
git help tutorial | head -20
GITTUTORIAL(7)                    Git Manual                    GITTUTORIAL(7)



NNAAMMEE
       gittutorial - A tutorial introduction to Git

SSYYNNOOPPSSIISS
       git *


DDEESSCCRRIIPPTTIIOONN
       This tutorial explains how to import a new project into Git, make
       changes to it, and share changes with other developers.

       If you are instead primarily interested in using Git to fetch a
       project, for example, to test the latest version, you may prefer to
       start with the first two chapters of TThhee GGiitt UUsseerr''ss MMaannuuaall[1].

       First, note that you can get documentation for a command such as ggiitt

Tutorial of using git with GitHub

  • Set up a student account with GitHub and get free stuff
  • Create a public repository on GitHub called bios-821-git-lesson
  • Add a README, and a BSD-3 license

Note

We are doing this in a Jupyter notebook with the bash kernel purely for illustration. More typically, you will be giving git commands in the bash shell.

Cloning

  • User A Clone the repository you have just created to your local machine as bios-821-a
In [5]:
git clone https://github.com/cliburn/bios-821-git-lesson.git bios-821-a
Cloning into 'bios-821-a'...
remote: Counting objects: 43, done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 43 (delta 18), reused 31 (delta 9), pack-reused 0
Unpacking objects: 100% (43/43), done.
  • User B Clone a second copy of the repository as bios-821-b
In [6]:
git clone https://github.com/cliburn/bios-821-git-lesson.git bios-821-b
Cloning into 'bios-821-b'...
remote: Counting objects: 43, done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 43 (delta 18), reused 31 (delta 9), pack-reused 0
Unpacking objects: 100% (43/43), done.

User A - Change directory to bios-821-a - Check the status of the repository

Git basics

add, commit, push, pull, status

In [7]:
cd bios-821-a
git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working tree clean
  • Create the following file as first.txt
This is my first file.
I am so proud of it.
Some day, this file will make me famous.
It is my most favorite file.
In [8]:
cat > first.txt << 'EOF'
This is my first file.
I am so proud of it.
Some day, this file will make me famous.
It is my most favorite file.
EOF

User A - Add the file to the repository - Check the status

In [9]:
git add first.txt
git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   first.txt

  • Remove the file from the staging area
  • Check the status
In [10]:
git reset HEAD first.txt
git status
Unstaged changes after reset:
M       first.txt
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   first.txt

no changes added to commit (use "git add" and/or "git commit -a")

User A - Add and commit the file with a commit message My first upload - Check the status

In [11]:
git add first.txt
git commit -m "My first upload"
git status
[master 3662e27] My first upload
 1 file changed, 1 insertion(+), 5 deletions(-)
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean
  • Push the file to GitHub
In [12]:
git push
Counting objects: 3, done.
Delta compression using up to 24 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 300 bytes | 300.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/cliburn/bios-821-git-lesson.git
   fc67fde..3662e27  master -> master
  • Go to the GitHub web page for this repository and look around

User A - Create the following files

As second.txt

This is my second file. Bugs.
I am so proud of it. Bugs.
Some day, this file will make me rich. Bugs.
It is my second favorite file. Bugs.
In [13]:
cat > second.txt << 'EOF'
This is my second file. Bugs.
I am so proud of it. Bugs.
Some day, this file will make me rich. Bugs.
It is my second favorite file. Bugs.
EOF

As third.txt

This is my third file.
I am so proud of it.
Some day, this file will make me fat.
It is my third favorite file.
In [14]:
cat > third.txt << 'EOF'
This is my third file.
I am so proud of it.
Some day, this file will make me fat.
It is my third favorite file.
EOF

User A

  • Add both files to the repository at once by adding the current directory
  • Check the status
In [15]:
git add .
git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   second.txt
        modified:   third.txt

  • Commit both files. Write the commit message.
More files uploaded.

Feeling super-productive.
This will make me famous, rich and fat.
  • Check the status

Note:

-F means read from file and the trailing - means use standard input as file

In [16]:
git commit -F- <<'EOF'
More files uploaded.

Feeling super-productive.
This will make me famous, rich and fat.
EOF
[master d538742] More files uploaded.
 2 files changed, 5 insertions(+), 5 deletions(-)
In [17]:
git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean
  • Push to GitHub
In [18]:
git push
Counting objects: 4, done.
Delta compression using up to 24 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 473 bytes | 473.00 KiB/s, done.
Total 4 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/cliburn/bios-821-git-lesson.git
   3662e27..d538742  master -> master

Using git log

User A

  • View the log messages
In [19]:
git log
commit d5387425ec72a57f0b685c7e261eff7e0be362f8 (HEAD -> master, origin/master, origin/HEAD)
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:27 2017 -0500

    More files uploaded.

    Feeling super-productive.
    This will make me famous, rich and fat.

commit 3662e27656c244def3c65d1a42d055b2fd759899
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:23 2017 -0500

    My first upload

commit fc67fdee4537834118b2ce50547ad31d1a406545 (tag: V1.0)
Merge: 0bacfb5 b2464e6
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:54:48 2017 -0500

    Merge with bugfix branch

commit 0bacfb5344ec21ab59117406d16ce38abf05328a
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:54:37 2017 -0500

    Fat people are often wise people

commit b2464e6bab93b84eac63605cb8fa59917034d268
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:54:29 2017 -0500

    Bug fix

commit 15cd8250daab709bc220071d15824fc9bc07d6a0
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:54:17 2017 -0500

    I hate everybody

commit 2096e145bcc8765dec5e0cbc3d65cea50f7c2aa5
Merge: a9d9c71 dd9cd18
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:53:23 2017 -0500

    Use User B version

commit a9d9c713d623de7c3fa3be4befe97d572573bb16
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:53:11 2017 -0500

    Winter blues setting in

commit dd9cd187ea184143a122976679b8b0f8db0d05ff
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:53:08 2017 -0500

    Attack of the Grammar Nazi

commit 6d1edb114b31cc64df85171a93a961772bec2167
Merge: becbf45 79e4af4
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:53:05 2017 -0500

    Manual merge

commit becbf45e89f4f68dba3e76a93eadd89381b03d91
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:52:56 2017 -0500

    No Pokemon allowed in here

commit 79e4af4e4d83290f2c58add6aa63d0480618e889
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:52:52 2017 -0500

    Exclude junk

commit b77242296b3726f1395feee1dbdb46257cfd9144
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:52:48 2017 -0500

    Updates on the way to becoming famous

commit 8155670f3c5fd0299de33f22d6cc49070b892c8a
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:52:44 2017 -0500

    More files uploaded.

    Feeling super-productive.
    This will make me famous, rich and fat.

commit 1727fba0d7cda6399a008c2392bd91586b4e7579
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:52:42 2017 -0500

    My first upload

commit ceb833976c04ff2fe78338a48e295cb34b53e198
Author: cliburn <cliburn.chan@duke.edu>
Date:   Sat Nov 11 07:52:23 2017 -0500

    Initial commit
  • View the log messages showing only one line
In [20]:
git log --oneline
d538742 (HEAD -> master, origin/master, origin/HEAD) More files uploaded.
3662e27 My first upload
fc67fde (tag: V1.0) Merge with bugfix branch
0bacfb5 Fat people are often wise people
b2464e6 Bug fix
15cd825 I hate everybody
2096e14 Use User B version
a9d9c71 Winter blues setting in
dd9cd18 Attack of the Grammar Nazi
6d1edb1 Manual merge
becbf45 No Pokemon allowed in here
79e4af4 Exclude junk
b772422 Updates on the way to becoming famous
8155670 More files uploaded.
1727fba My first upload
ceb8339 Initial commit
  • view only the log message for the second commit
In [21]:
git log -1
commit d5387425ec72a57f0b685c7e261eff7e0be362f8 (HEAD -> master, origin/master, origin/HEAD)
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:27 2017 -0500

    More files uploaded.

    Feeling super-productive.
    This will make me famous, rich and fat.
  • View what files were added or modified in the second commit
In [22]:
git log --stat -1
commit d5387425ec72a57f0b685c7e261eff7e0be362f8 (HEAD -> master, origin/master, origin/HEAD)
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:27 2017 -0500

    More files uploaded.

    Feeling super-productive.
    This will make me famous, rich and fat.

 second.txt | 8 ++++----
 third.txt  | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

User A

Now edit first.txt to read

This is my first file.
I am so proud of it.
Some day, this file will make me famous.
It is my most favorite file.
Ed Sheeran likes this file.
Taylor Swift mentioned this file in her new album.
President Trump tweeted about this file.
In [23]:
cat > first.txt <<'EOF'
This is my first file.
I am so proud of it.
Some day, this file will make me famous.
It is my most favorite file.
Ed Sheeran likes this file.
Taylor Swift mentioned this file in her new album.
President Trump tweeted about this file.
EOF

User A

  • Add the revised file to the repository
  • Check the status
In [24]:
git add first.txt
git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   first.txt

Using git diff

  • Find out what the differences are between the version in the staging area and the version in the repository
In [25]:
git diff --staged
diff --git a/first.txt b/first.txt
index 78f164d..b14c5a7 100644
--- a/first.txt
+++ b/first.txt
@@ -2,3 +2,6 @@ This is my first file.
 I am so proud of it.
 Some day, this file will make me famous.
 It is my most favorite file.
+Ed Sheeran likes this file.
+Taylor Swift mentioned this file in her new album.
+President Trump tweeted about this file.
  • Commit the file with the log message Updates on the way to becoming famous
  • Push to GitHub
In [26]:
git commit -m "Updates on the way to becoming famous"
git push
[master 0c9eafe] Updates on the way to becoming famous
 1 file changed, 3 insertions(+)
Counting objects: 3, done.
Delta compression using up to 24 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 417 bytes | 417.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/cliburn/bios-821-git-lesson.git
   d538742..0c9eafe  master -> master

User B

  • Change directory to bios-821-b
  • Pull from GitHub
In [27]:
cd ../bios-821-b
git pull
remote: Counting objects: 10, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 10 (delta 6), reused 9 (delta 5), pack-reused 0
Unpacking objects: 100% (10/10), done.
From https://github.com/cliburn/bios-821-git-lesson
   fc67fde..0c9eafe  master     -> origin/master
Updating fc67fde..0c9eafe
Fast-forward
 first.txt  | 9 ++++-----
 second.txt | 8 ++++----
 third.txt  | 2 +-
 3 files changed, 9 insertions(+), 10 deletions(-)
  • List the files in the directory - You should have the changes made in bios-821-a
  • Check the log messages
In [28]:
ls
LICENSE         README.md       first.txt       second.txt      third.txt
In [29]:
git log
commit 0c9eafe9be9e0fa74c1568702755e992da408a29 (HEAD -> master, origin/master, origin/HEAD)
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:31 2017 -0500

    Updates on the way to becoming famous

commit d5387425ec72a57f0b685c7e261eff7e0be362f8
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:27 2017 -0500

    More files uploaded.

    Feeling super-productive.
    This will make me famous, rich and fat.

commit 3662e27656c244def3c65d1a42d055b2fd759899
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:23 2017 -0500

    My first upload

commit fc67fdee4537834118b2ce50547ad31d1a406545 (tag: V1.0)
Merge: 0bacfb5 b2464e6
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:54:48 2017 -0500

    Merge with bugfix branch

commit 0bacfb5344ec21ab59117406d16ce38abf05328a
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:54:37 2017 -0500

    Fat people are often wise people

commit b2464e6bab93b84eac63605cb8fa59917034d268
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:54:29 2017 -0500

    Bug fix

commit 15cd8250daab709bc220071d15824fc9bc07d6a0
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:54:17 2017 -0500

    I hate everybody

commit 2096e145bcc8765dec5e0cbc3d65cea50f7c2aa5
Merge: a9d9c71 dd9cd18
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:53:23 2017 -0500

    Use User B version

commit a9d9c713d623de7c3fa3be4befe97d572573bb16
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:53:11 2017 -0500

    Winter blues setting in

commit dd9cd187ea184143a122976679b8b0f8db0d05ff
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:53:08 2017 -0500

    Attack of the Grammar Nazi

commit 6d1edb114b31cc64df85171a93a961772bec2167
Merge: becbf45 79e4af4
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:53:05 2017 -0500

    Manual merge

commit becbf45e89f4f68dba3e76a93eadd89381b03d91
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:52:56 2017 -0500

    No Pokemon allowed in here

commit 79e4af4e4d83290f2c58add6aa63d0480618e889
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:52:52 2017 -0500

    Exclude junk

commit b77242296b3726f1395feee1dbdb46257cfd9144
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:52:48 2017 -0500

    Updates on the way to becoming famous

commit 8155670f3c5fd0299de33f22d6cc49070b892c8a
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:52:44 2017 -0500

    More files uploaded.

    Feeling super-productive.
    This will make me famous, rich and fat.

commit 1727fba0d7cda6399a008c2392bd91586b4e7579
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:52:42 2017 -0500

    My first upload

commit ceb833976c04ff2fe78338a48e295cb34b53e198
Author: cliburn <cliburn.chan@duke.edu>
Date:   Sat Nov 11 07:52:23 2017 -0500

    Initial commit

User B

  • Add a new file stuff.junk containing
junk junk junk junk junk
junk junk junk junk
junk junk junk
junk junk
junk
In [30]:
cat > stuff.junk <<'EOF'
junk junk junk junk junk
junk junk junk junk
junk junk junk
junk junk
junk
EOF

User B

  • Add a filter to .gitignore to exclude any file with extension .junk
In [31]:
echo "*.junk" >> .gitignore
  • Add the current directory to the Git staging area
In [32]:
git add .
  • Check the status - only the .gitignore file should be added and not stuff.junk
In [33]:
git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   .gitignore

  • Commit and push to GitHub with message Exclude junk
In [34]:
git commit -m "Exclude junk"
git push
[master c714516] Exclude junk
 1 file changed, 1 insertion(+)
Counting objects: 3, done.
Delta compression using up to 24 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 275 bytes | 275.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/cliburn/bios-821-git-lesson.git
   0c9eafe..c714516  master -> master

User A

  • Change directory to bios-821-a
  • Make a new direcotry called data and download the following files into it
https://upload.wikimedia.org/wikipedia/en/a/a5/Pokémon_Charmander_art.png
https://vignette.wikia.nocookie.net/pokemon/images/b/b1/393Piplup.png
https://vignette3.wikia.nocookie.net/pokemon/images/4/44/167Spinarak_OS_anime.png
In [35]:
cd ../bios-821-a
mkdir data
cd data
wget -q https://upload.wikimedia.org/wikipedia/en/a/a5/Pokémon_Charmander_art.png
wget -q https://vignette.wikia.nocookie.net/pokemon/images/b/b1/393Piplup.png
wget -q https://vignette3.wikia.nocookie.net/pokemon/images/4/44/167Spinarak_OS_anime.png
cd ..
  • Check that the 3 image files are in the data directory
In [36]:
ls data
167Spinarak_OS_anime.png        Pokémon_Charmander_art.png
393Piplup.png
  • Edit .gitignore so that the entire data directory is excluded
In [37]:
echo "data/" >> .gitignore
  • Add all contents in bios-821-a and check status
  • Make sure data and the downloaded content are not in the staging area, only the revised .gitignore
In [38]:
git add .
In [39]:
git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   .gitignore

  • Commit with a message No Pokemon allowed in here
In [40]:
git commit -m "No Pokemon allowed in here"
[master 5209501] No Pokemon allowed in here
 1 file changed, 1 insertion(+)

Working with merge conflicts

  • Try to push to GitHub. This should fail. Fix and re-push.
In [41]:
git push
To https://github.com/cliburn/bios-821-git-lesson.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/cliburn/bios-821-git-lesson.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

  • Fixing failure to push to remote
In [42]:
git pull
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/cliburn/bios-821-git-lesson
   0c9eafe..c714516  master     -> origin/master
Auto-merging .gitignore
CONFLICT (content): Merge conflict in .gitignore
Automatic merge failed; fix conflicts and then commit the result.

  • See merge conflicts (normally done in text editor or merge-tool)
In [43]:
cat .gitignore
data/
*.junk
<<<<<<< HEAD
data/
=======
*.junk
>>>>>>> c714516dcc0da8421418d6dbd45ff86fd7f7c8c2
  • Fix the merge conflcits manually
In [44]:
cat > .gitignore <<'EOF'
data/
*.junk
EOF
  • Add, commit and push the fixed file
In [45]:
git add .gitignore
In [46]:
git commit -m "Manual merge"
[master e3ca964] Manual merge
In [47]:
git push
Counting objects: 4, done.
Delta compression using up to 24 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 463 bytes | 463.00 KiB/s, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/cliburn/bios-821-git-lesson.git
   c714516..e3ca964  master -> master

User A

  • Edit first.txt to read (deleting the word most)
This is my first file.
I am so proud of it.
Some day, this file will make me famous.
It is my favorite file.
Ed Sheeran likes this file!
Taylor Swift mentioned this file in her new album!
President Trump tweeted about this file!
In [48]:
cat > first.txt <<'EOF'
This is my first file.
I am so proud of it.
Some day, this file will make me famous.
It is my favorite file.
Ed Sheeran likes this file!
Taylor Swift mentioned this file in her new album!
President Trump tweeted about this file!
EOF
  • Add and commit the file wiht message Attack of the Grammar Nazi
  • Push to GitHub
In [49]:
git add first.txt
git commit -m "Attack of the Grammar Nazi"
git push
[master b9cb6c6] Attack of the Grammar Nazi
 1 file changed, 4 insertions(+), 4 deletions(-)
Counting objects: 3, done.
Delta compression using up to 24 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 303 bytes | 303.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/cliburn/bios-821-git-lesson.git
   e3ca964..b9cb6c6  master -> master

User B

  • Change directory to bios-821-b
  • Edit first.txt to read
This is my first file.
I am so sick of it.
Some day, this file will make me notorious.
It is my least favorite file.
Ed Sheeran hates this file!
Who is Taylor Swift?
President Trump tweeted about this file!
In [50]:
cd ../bios-821-b
In [51]:
cat > first.txt <<'EOF'
This is my first file.
I am so sick of it.
Some day, this file will make me notorious.
It is my least favorite file.
Ed Sheeran hates this file!
Who is Taylor Swift?
President Trump tweeted about this file!
EOF
  • Add and commit the file with the message Winter blues setting in
  • Try to push to GtiHub
  • What happens?
  • Fix it so that the version in bios-821-b is used and push to GitHub with message “Use User B version”
In [52]:
git add first.txt
git commit -m "Winter blues setting in"
git push
[master 99ef696] Winter blues setting in
 1 file changed, 6 insertions(+), 6 deletions(-)
To https://github.com/cliburn/bios-821-git-lesson.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/cliburn/bios-821-git-lesson.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

  • Fixing failure to push to remote
In [53]:
git pull
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 7 (delta 3), reused 7 (delta 3), pack-reused 0
Unpacking objects: 100% (7/7), done.
From https://github.com/cliburn/bios-821-git-lesson
   c714516..b9cb6c6  master     -> origin/master
Auto-merging first.txt
CONFLICT (content): Merge conflict in first.txt
Automatic merge failed; fix conflicts and then commit the result.

In [54]:
cat first.txt
This is my first file.
<<<<<<< HEAD
I am so sick of it.
Some day, this file will make me notorious.
It is my least favorite file.
Ed Sheeran hates this file!
Who is Taylor Swift?
=======
I am so proud of it.
Some day, this file will make me famous.
It is my favorite file.
Ed Sheeran likes this file!
Taylor Swift mentioned this file in her new album!
>>>>>>> b9cb6c6971cc0b568f0ec4dc96beac7196aeaaaa
President Trump tweeted about this file!
In [55]:
cat > first.txt <<'EOF'
This is my first file.
I am so sick of it.
Some day, this file will make me notorious.
It is my least favorite file.
Ed Sheeran hates this file!
Who is Taylor Swift?
President Trump tweeted about this file!
EOF
In [56]:
git add first.txt
In [57]:
git commit -m "Use User B version"
[master aa59382] Use User B version
In [58]:
git push
Counting objects: 5, done.
Delta compression using up to 24 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 629 bytes | 629.00 KiB/s, done.
Total 5 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 1 local object.
To https://github.com/cliburn/bios-821-git-lesson.git
   b9cb6c6..aa59382  master -> master

User A

  • Change directory to bios-802-a
  • Pull from GitHub
  • Look at the text of first.txt
In [59]:
cd ../bios-821-a
In [60]:
git pull
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 5 (delta 2), reused 5 (delta 2), pack-reused 0
Unpacking objects: 100% (5/5), done.
From https://github.com/cliburn/bios-821-git-lesson
   b9cb6c6..aa59382  master     -> origin/master
Updating b9cb6c6..aa59382
Fast-forward
 first.txt | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
In [61]:
cat first.txt
This is my first file.
I am so sick of it.
Some day, this file will make me notorious.
It is my least favorite file.
Ed Sheeran hates this file!
Who is Taylor Swift?
President Trump tweeted about this file!

Git as a time machine

User A

  • The file looks strangely sad and unfamiliar
  • Look for a commit message with the word ‘Nazi’ in it
In [62]:
git log --grep 'Nazi'
commit b9cb6c6971cc0b568f0ec4dc96beac7196aeaaaa
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:43 2017 -0500

    Attack of the Grammar Nazi

commit dd9cd187ea184143a122976679b8b0f8db0d05ff
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:53:08 2017 -0500

    Attack of the Grammar Nazi
  • Use your time machine to rest the world to what it looked like when you made the ‘Nazi’ commit
In [63]:
git checkout <COMMIT>
bash: syntax error near unexpected token `newline'

  • Display first.txt
In [64]:
cat first.txt
This is my first file.
I am so sick of it.
Some day, this file will make me notorious.
It is my least favorite file.
Ed Sheeran hates this file!
Who is Taylor Swift?
President Trump tweeted about this file!
  • Show the log file (one line per commit)
In [65]:
git log --oneline
aa59382 (HEAD -> master, origin/master, origin/HEAD) Use User B version
99ef696 Winter blues setting in
b9cb6c6 Attack of the Grammar Nazi
e3ca964 Manual merge
5209501 No Pokemon allowed in here
c714516 Exclude junk
0c9eafe Updates on the way to becoming famous
d538742 More files uploaded.
3662e27 My first upload
fc67fde (tag: V1.0) Merge with bugfix branch
0bacfb5 Fat people are often wise people
b2464e6 Bug fix
15cd825 I hate everybody
2096e14 Use User B version
a9d9c71 Winter blues setting in
dd9cd18 Attack of the Grammar Nazi
6d1edb1 Manual merge
becbf45 No Pokemon allowed in here
79e4af4 Exclude junk
b772422 Updates on the way to becoming famous
8155670 More files uploaded.
1727fba My first upload
ceb8339 Initial commit
  • Go back to the original HEAD in master
In [66]:
git checkout master
Already on 'master'
Your branch is up-to-date with 'origin/master'.
  • Show the log file (one line per commit)
In [67]:
git log --oneline
aa59382 (HEAD -> master, origin/master, origin/HEAD) Use User B version
99ef696 Winter blues setting in
b9cb6c6 Attack of the Grammar Nazi
e3ca964 Manual merge
5209501 No Pokemon allowed in here
c714516 Exclude junk
0c9eafe Updates on the way to becoming famous
d538742 More files uploaded.
3662e27 My first upload
fc67fde (tag: V1.0) Merge with bugfix branch
0bacfb5 Fat people are often wise people
b2464e6 Bug fix
15cd825 I hate everybody
2096e14 Use User B version
a9d9c71 Winter blues setting in
dd9cd18 Attack of the Grammar Nazi
6d1edb1 Manual merge
becbf45 No Pokemon allowed in here
79e4af4 Exclude junk
b772422 Updates on the way to becoming famous
8155670 More files uploaded.
1727fba My first upload
ceb8339 Initial commit

User B

  • Pull from GitHub
  • Your doctor gave you happy drugs
  • You decide to revise first.txt again
This is my first file.
I am so proud of it.
Some day, this file will make me famous.
It is my favorite file.
Ed Sheeran likes this file!
Taylor Swift mentioned this file in her new album!
President Trump tweeted about this file!
What a wonderful world.
In [68]:
cd ../bios-821-b
In [69]:
cat > first.txt <<'EOF'
This is my first file.
I am so proud of it.
Some day, this file will make me famous.
It is my favorite file.
Ed Sheeran likes this file!
Taylor Swift mentioned this file in her new album!
President Trump tweeted about this file!
What a wonderful world.
EOF
  • Add and commit with the message “I love everybody”
In [70]:
git add first.txt
git commit -m "I love everybody"
[master b54aacc] I love everybody
 1 file changed, 6 insertions(+), 5 deletions(-)

Changing commit messages

Do not do this once the commit is pushed. Once pushed, log messages are public and should not be edited.

User B

  • Your drugs run out
  • Edit the last commit message so that it says I hate everybody
  • Push to GitHub
In [71]:
git commit --amend -m "I hate everybody"
git push
[master d2c9ff9] I hate everybody
 Date: Mon Nov 13 09:02:52 2017 -0500
 1 file changed, 6 insertions(+), 5 deletions(-)
Counting objects: 3, done.
Delta compression using up to 24 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 415 bytes | 415.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/cliburn/bios-821-git-lesson.git
   aa59382..d2c9ff9  master -> master

Git for disaster recovery

User A

  • Delete the directory bios-821-a with rm -rf to simulate your laptop being lost
  • Recover bios-821-a by cloning from GitHub
In [72]:
cd ..
rm -rf bios-821-a
git clone https://github.com/cliburn/bios-821-git-lesson.git bios-821-a
Cloning into 'bios-821-a'...
remote: Counting objects: 60, done.
remote: Compressing objects: 100% (43/43), done.
remote: Total 60 (delta 23), reused 45 (delta 11), pack-reused 0
Unpacking objects: 100% (60/60), done.

Branching and merging

User A

  • Change directory to bios-821-a
  • View second.txt and see that it has bugs
In [73]:
cd bios-821-a
cat second.txt
This is my second file. Bugs.
I am so proud of it. Bugs.
Some day, this file will make me rich. Bugs.
It is my second favorite file. Bugs.
  • Create a new branch called bugfix
In [74]:
git checkout -b bugfix
Switched to a new branch 'bugfix'
  • In the bugfix branch, edit second.txt to remove all bugs.
In [75]:
cat > second.txt <<'EOF'
This is my second file.
I am so proud of it.
Some day, this file will make me rich.
It is my second favorite file.
EOF
  • Add and commit the file with message Bug fix
  • Push to GitHub
In [76]:
git commit -a -m "Bug fix"
[bugfix 8f66033] Bug fix
 1 file changed, 4 insertions(+), 4 deletions(-)
In [77]:
git push
fatal: The current branch bugfix has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin bugfix


In [78]:
git push --set-upstream origin bugfix
Counting objects: 3, done.
Delta compression using up to 24 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 333 bytes | 333.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/cliburn/bios-821-git-lesson.git
 * [new branch]      bugfix -> bugfix
Branch bugfix set up to track remote branch bugfix from origin.
  • In the master branch, edit third.txt to read
This is my third file.
I am so proud of it.
Some day, this file will make me wise.
It is my third favorite file.
In [79]:
git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
In [80]:
cat > third.txt <<'EOF'
This is my third file.
I am so proud of it.
Some day, this file will make me wise.
It is my third favorite file.
EOF
  • Add and commit the file with message Fat people are often wise people
  • Push to GitHub
In [81]:
git commit -a -m "Fat people are often wise people"
git push
[master eb96e34] Fat people are often wise people
 1 file changed, 1 insertion(+), 1 deletion(-)
Counting objects: 3, done.
Delta compression using up to 24 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 289 bytes | 289.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/cliburn/bios-821-git-lesson.git
   d2c9ff9..eb96e34  master -> master

User B

  • Change directory to bios-821-b
  • Pull from GitHub
In [82]:
cd ../bios-821-b
git pull
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 3), reused 6 (delta 3), pack-reused 0
Unpacking objects: 100% (6/6), done.
From https://github.com/cliburn/bios-821-git-lesson
   d2c9ff9..eb96e34  master     -> origin/master
 * [new branch]      bugfix     -> origin/bugfix
Updating d2c9ff9..eb96e34
Fast-forward
 third.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  • Do you have the master and bugfix branhces?
In [83]:
git branch
* master
In [84]:
git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/bugfix
  remotes/origin/master
  • Merge the bugfix branch back into master
In [85]:
git checkout bugfix
Branch bugfix set up to track remote branch bugfix from origin.
Switched to a new branch 'bugfix'
In [86]:
git branch
* bugfix
  master
In [87]:
git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
In [88]:
git merge bugfix -m "Merge with bugfix branch"
Merge made by the 'recursive' strategy.
 second.txt | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  • Delete the bugfix branch both locally and on remote
In [89]:
git branch -d bugfix
Deleted branch bugfix (was 8f66033).
In [90]:
git push -d origin bugfix
To https://github.com/cliburn/bios-821-git-lesson.git
 - [deleted]         bugfix

Tagging

  • Tag the master branch as “V1.0” with the message “Version 1.0” and push to remote
In [91]:
git tag -a V1.0 -m "Version 1.0"
fatal: tag 'V1.0' already exists

In [92]:
git push origin V1.0
Everything up-to-date
In [93]:
git push
Counting objects: 5, done.
Delta compression using up to 24 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 555 bytes | 555.00 KiB/s, done.
Total 5 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 1 local object.
To https://github.com/cliburn/bios-821-git-lesson.git
   eb96e34..558ad3a  master -> master

User A

  • Change directory to bios-821-a
  • Pull the changes
  • Check that the bugfix branch has been deleted
In [94]:
cd ../bios-821-a
In [95]:
git pull
git branch -r
remote: Counting objects: 2, done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 2 (delta 1), reused 2 (delta 1), pack-reused 0
Unpacking objects: 100% (2/2), done.
From https://github.com/cliburn/bios-821-git-lesson
   eb96e34..558ad3a  master     -> origin/master
Updating eb96e34..558ad3a
Fast-forward
 second.txt | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  origin/HEAD -> origin/master
  origin/bugfix
  origin/master

Mining the log file

In [96]:
git log
commit 558ad3a066161f0c7b988490687e91f0a0e58867 (HEAD -> master, origin/master, origin/HEAD)
Merge: eb96e34 8f66033
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:03:02 2017 -0500

    Merge with bugfix branch

commit eb96e3427d5cee5e63a28e5225203570dfb1caeb
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:58 2017 -0500

    Fat people are often wise people

commit 8f66033a29fa0cf2d85ff8fa1578e6888cecaeba (origin/bugfix, bugfix)
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:56 2017 -0500

    Bug fix

commit d2c9ff9aac07293dbd3e39f5d533a9e4128bb85d
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:52 2017 -0500

    I hate everybody

commit aa593826ab9ff14f0c6089c3ee37a49afc123ffc
Merge: 99ef696 b9cb6c6
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:48 2017 -0500

    Use User B version

commit 99ef6966e4bd469a14b57ff1c19babe56d849b75
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:46 2017 -0500

    Winter blues setting in

commit b9cb6c6971cc0b568f0ec4dc96beac7196aeaaaa
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:43 2017 -0500

    Attack of the Grammar Nazi

commit e3ca964dd153de6da835650ca9bba0ffe4056814
Merge: 5209501 c714516
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:40 2017 -0500

    Manual merge

commit 520950165d645b60baaa80fbadcdeb9ef0677d97
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:39 2017 -0500

    No Pokemon allowed in here

commit c714516dcc0da8421418d6dbd45ff86fd7f7c8c2
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:34 2017 -0500

    Exclude junk

commit 0c9eafe9be9e0fa74c1568702755e992da408a29
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:31 2017 -0500

    Updates on the way to becoming famous

commit d5387425ec72a57f0b685c7e261eff7e0be362f8
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:27 2017 -0500

    More files uploaded.

    Feeling super-productive.
    This will make me famous, rich and fat.

commit 3662e27656c244def3c65d1a42d055b2fd759899
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:23 2017 -0500

    My first upload

commit fc67fdee4537834118b2ce50547ad31d1a406545 (tag: V1.0)
Merge: 0bacfb5 b2464e6
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:54:48 2017 -0500

    Merge with bugfix branch

commit 0bacfb5344ec21ab59117406d16ce38abf05328a
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:54:37 2017 -0500

    Fat people are often wise people

commit b2464e6bab93b84eac63605cb8fa59917034d268
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:54:29 2017 -0500

    Bug fix

commit 15cd8250daab709bc220071d15824fc9bc07d6a0
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:54:17 2017 -0500

    I hate everybody

commit 2096e145bcc8765dec5e0cbc3d65cea50f7c2aa5
Merge: a9d9c71 dd9cd18
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:53:23 2017 -0500

    Use User B version

commit a9d9c713d623de7c3fa3be4befe97d572573bb16
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:53:11 2017 -0500

    Winter blues setting in

commit dd9cd187ea184143a122976679b8b0f8db0d05ff
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:53:08 2017 -0500

    Attack of the Grammar Nazi

commit 6d1edb114b31cc64df85171a93a961772bec2167
Merge: becbf45 79e4af4
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:53:05 2017 -0500

    Manual merge

commit becbf45e89f4f68dba3e76a93eadd89381b03d91
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:52:56 2017 -0500

    No Pokemon allowed in here

commit 79e4af4e4d83290f2c58add6aa63d0480618e889
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:52:52 2017 -0500

    Exclude junk

commit b77242296b3726f1395feee1dbdb46257cfd9144
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:52:48 2017 -0500

    Updates on the way to becoming famous

commit 8155670f3c5fd0299de33f22d6cc49070b892c8a
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:52:44 2017 -0500

    More files uploaded.

    Feeling super-productive.
    This will make me famous, rich and fat.

commit 1727fba0d7cda6399a008c2392bd91586b4e7579
Author: ccc14 <ccc14@duke.edu>
Date:   Sat Nov 11 07:52:42 2017 -0500

    My first upload

commit ceb833976c04ff2fe78338a48e295cb34b53e198
Author: cliburn <cliburn.chan@duke.edu>
Date:   Sat Nov 11 07:52:23 2017 -0500

    Initial commit
In [97]:
git log --stat -5
commit 558ad3a066161f0c7b988490687e91f0a0e58867 (HEAD -> master, origin/master, origin/HEAD)
Merge: eb96e34 8f66033
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:03:02 2017 -0500

    Merge with bugfix branch

commit eb96e3427d5cee5e63a28e5225203570dfb1caeb
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:58 2017 -0500

    Fat people are often wise people

 third.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

commit 8f66033a29fa0cf2d85ff8fa1578e6888cecaeba (origin/bugfix, bugfix)
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:56 2017 -0500

    Bug fix

 second.txt | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

commit d2c9ff9aac07293dbd3e39f5d533a9e4128bb85d
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:52 2017 -0500

    I hate everybody

 first.txt | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

commit aa593826ab9ff14f0c6089c3ee37a49afc123ffc
Merge: 99ef696 b9cb6c6
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:02:48 2017 -0500

    Use User B version
In [98]:
git log --oneline
558ad3a (HEAD -> master, origin/master, origin/HEAD) Merge with bugfix branch
eb96e34 Fat people are often wise people
8f66033 (origin/bugfix, bugfix) Bug fix
d2c9ff9 I hate everybody
aa59382 Use User B version
99ef696 Winter blues setting in
b9cb6c6 Attack of the Grammar Nazi
e3ca964 Manual merge
5209501 No Pokemon allowed in here
c714516 Exclude junk
0c9eafe Updates on the way to becoming famous
d538742 More files uploaded.
3662e27 My first upload
fc67fde (tag: V1.0) Merge with bugfix branch
0bacfb5 Fat people are often wise people
b2464e6 Bug fix
15cd825 I hate everybody
2096e14 Use User B version
a9d9c71 Winter blues setting in
dd9cd18 Attack of the Grammar Nazi
6d1edb1 Manual merge
becbf45 No Pokemon allowed in here
79e4af4 Exclude junk
b772422 Updates on the way to becoming famous
8155670 More files uploaded.
1727fba My first upload
ceb8339 Initial commit
In [99]:
git log --name-only --oneline
558ad3a (HEAD -> master, origin/master, origin/HEAD) Merge with bugfix branch
eb96e34 Fat people are often wise people
third.txt
8f66033 (origin/bugfix, bugfix) Bug fix
second.txt
d2c9ff9 I hate everybody
first.txt
aa59382 Use User B version
99ef696 Winter blues setting in
first.txt
b9cb6c6 Attack of the Grammar Nazi
first.txt
e3ca964 Manual merge
5209501 No Pokemon allowed in here
.gitignore
c714516 Exclude junk
.gitignore
0c9eafe Updates on the way to becoming famous
first.txt
d538742 More files uploaded.
second.txt
third.txt
3662e27 My first upload
first.txt
fc67fde (tag: V1.0) Merge with bugfix branch
0bacfb5 Fat people are often wise people
third.txt
b2464e6 Bug fix
second.txt
15cd825 I hate everybody
first.txt
2096e14 Use User B version
a9d9c71 Winter blues setting in
first.txt
dd9cd18 Attack of the Grammar Nazi
first.txt
6d1edb1 Manual merge
becbf45 No Pokemon allowed in here
.gitignore
79e4af4 Exclude junk
.gitignore
b772422 Updates on the way to becoming famous
first.txt
8155670 More files uploaded.
second.txt
third.txt
1727fba My first upload
first.txt
ceb8339 Initial commit
LICENSE
README.md
In [100]:
git log --oneline --graph
*   558ad3a (HEAD -> master, origin/master, origin/HEAD) Merge with bugfix branch
|\
| * 8f66033 (origin/bugfix, bugfix) Bug fix
* | eb96e34 Fat people are often wise people
|/
* d2c9ff9 I hate everybody
*   aa59382 Use User B version
|\
| * b9cb6c6 Attack of the Grammar Nazi
| *   e3ca964 Manual merge
| |\
| * | 5209501 No Pokemon allowed in here
* | | 99ef696 Winter blues setting in
| |/
|/|
* | c714516 Exclude junk
|/
* 0c9eafe Updates on the way to becoming famous
* d538742 More files uploaded.
* 3662e27 My first upload
*   fc67fde (tag: V1.0) Merge with bugfix branch
|\
| * b2464e6 Bug fix
* | 0bacfb5 Fat people are often wise people
|/
* 15cd825 I hate everybody
*   2096e14 Use User B version
|\
| * dd9cd18 Attack of the Grammar Nazi
| *   6d1edb1 Manual merge
| |\
| * | becbf45 No Pokemon allowed in here
* | | a9d9c71 Winter blues setting in
| |/
|/|
* | 79e4af4 Exclude junk
|/
* b772422 Updates on the way to becoming famous
* 8155670 More files uploaded.
* 1727fba My first upload
* ceb8339 Initial commit
In [101]:
git log --grep 'love'
In [102]:
git show
commit 558ad3a066161f0c7b988490687e91f0a0e58867 (HEAD -> master, origin/master, origin/HEAD)
Merge: eb96e34 8f66033
Author: ccc14 <ccc14@duke.edu>
Date:   Mon Nov 13 09:03:02 2017 -0500

    Merge with bugfix branch

In [103]:
git tag
V1.0
In [104]:
git remote show origin
* remote origin
  Fetch URL: https://github.com/cliburn/bios-821-git-lesson.git
  Push  URL: https://github.com/cliburn/bios-821-git-lesson.git
  HEAD branch: master
  Remote branches:
    master                     tracked
    refs/remotes/origin/bugfix stale (use 'git remote prune' to remove)
  Local branches configured for 'git pull':
    bugfix merges with remote bugfix
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)