{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Git in class" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Automated Version Control\n", "Read https://swcarpentry.github.io/git-novice/01-basics/index.html\n", "\n", "\n", "## Create a Repository\n", "Follow https://swcarpentry.github.io/git-novice/03-create/index.html with some changes\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/home/jovyan/work/planets\n" ] } ], "source": [ "rm -rf /home/jovyan/work/planets/\n", "mkdir -p /home/jovyan/work/planets/\n", "cd /home/jovyan/work/planets/\n", "pwd" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Initialized empty Git repository in /home/jovyan/work/planets/.git/\n" ] } ], "source": [ "git init" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setting Up Git" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "git config user.name \"Vlad Dracula\"\n", "git config user.email \"vlad@tran.sylvan.ia\"" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "ls" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[0m\u001b[01;34m.\u001b[0m \u001b[01;34m..\u001b[0m \u001b[01;34m.git\u001b[0m\n" ] } ], "source": [ "ls -a" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "\n", "Initial commit\n", "\n", "nothing to commit (create/copy files and use \"git add\" to track)\n" ] } ], "source": [ "git status" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[0m\u001b[01;34mmoons\u001b[0m\n" ] } ], "source": [ "mkdir moons\n", "ls" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "\n", "Initial commit\n", "\n", "nothing to commit (create/copy files and use \"git add\" to track)\n" ] } ], "source": [ "git status" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Tracking Changes" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/home/jovyan/work/planets\n" ] } ], "source": [ "pwd" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "cat > mars.txt << EOF\n", "Cold and dry, but everything is my favorite color\n", "The two moons may be a problem for Wolfman\n", "EOF" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "mars.txt \u001b[0m\u001b[01;34mmoons\u001b[0m\n", "Cold and dry, but everything is my favorite color\n", "The two moons may be a problem for Wolfman\n" ] } ], "source": [ "ls\n", "cat mars.txt" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "\n", "Initial commit\n", "\n", "Untracked files:\n", " (use \"git add ...\" to include in what will be committed)\n", "\n", "\t\u001b[31mmars.txt\u001b[m\n", "\n", "nothing added to commit but untracked files present (use \"git add\" to track)\n" ] } ], "source": [ "git status" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "git add mars.txt" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "\n", "Initial commit\n", "\n", "Changes to be committed:\n", " (use \"git rm --cached ...\" to unstage)\n", "\n", "\t\u001b[32mnew file: mars.txt\u001b[m\n", "\n" ] } ], "source": [ "git status" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[master (root-commit) 1fbe642] Start notes on Mars as a base\n", " 1 file changed, 2 insertions(+)\n", " create mode 100644 mars.txt\n" ] } ], "source": [ "git commit -m \"Start notes on Mars as a base\"" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "nothing to commit, working tree clean\n" ] } ], "source": [ "git status" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[33mcommit 1fbe6424cf9dc240f2540ce6877646467214bca6\u001b[m\n", "Author: Vlad Dracula \n", "Date: Wed Jun 26 08:04:25 2019 +0000\n", "\n", " Start notes on Mars as a base\n" ] } ], "source": [ "git log" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "echo 'The two moons may be a problem for Wolfman' >> mars.txt" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "Changes not staged for commit:\n", " (use \"git add ...\" to update what will be committed)\n", " (use \"git checkout -- ...\" to discard changes in working directory)\n", "\n", "\t\u001b[31mmodified: mars.txt\u001b[m\n", "\n", "no changes added to commit (use \"git add\" and/or \"git commit -a\")\n" ] } ], "source": [ "git status" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1mdiff --git a/mars.txt b/mars.txt\u001b[m\n", "\u001b[1mindex 315bf3a..6b1d81a 100644\u001b[m\n", "\u001b[1m--- a/mars.txt\u001b[m\n", "\u001b[1m+++ b/mars.txt\u001b[m\n", "\u001b[36m@@ -1,2 +1,3 @@\u001b[m\n", " Cold and dry, but everything is my favorite color\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", "\u001b[32m+\u001b[m\u001b[32mThe two moons may be a problem for Wolfman\u001b[m\n" ] } ], "source": [ "git diff" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "Changes not staged for commit:\n", "\t\u001b[31mmodified: mars.txt\u001b[m\n", "\n", "no changes added to commit\n" ] }, { "ename": "", "evalue": "1", "output_type": "error", "traceback": [] } ], "source": [ "git commit -m \"Add concerns about effects of Mars' moons on Wolfman\"" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "Changes not staged for commit:\n", " (use \"git add ...\" to update what will be committed)\n", " (use \"git checkout -- ...\" to discard changes in working directory)\n", "\n", "\t\u001b[31mmodified: mars.txt\u001b[m\n", "\n", "no changes added to commit (use \"git add\" and/or \"git commit -a\")\n" ] } ], "source": [ "git status" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[master bbb518b] Add concerns about effects of Mars' moons on Wolfman\n", " 1 file changed, 1 insertion(+)\n" ] } ], "source": [ "git add mars.txt\n", "git commit -m \"Add concerns about effects of Mars' moons on Wolfman\"" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "echo But the Mummy will appreciate the lack of humidity >> mars.txt" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1mdiff --git a/mars.txt b/mars.txt\u001b[m\n", "\u001b[1mindex 6b1d81a..9ceb94e 100644\u001b[m\n", "\u001b[1m--- a/mars.txt\u001b[m\n", "\u001b[1m+++ b/mars.txt\u001b[m\n", "\u001b[36m@@ -1,3 +1,4 @@\u001b[m\n", " Cold and dry, but everything is my favorite color\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", "\u001b[32m+\u001b[m\u001b[32mBut the Mummy will appreciate the lack of humidity\u001b[m\n" ] } ], "source": [ "git diff" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "git add mars.txt" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "git diff" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1mdiff --git a/mars.txt b/mars.txt\u001b[m\n", "\u001b[1mindex 6b1d81a..9ceb94e 100644\u001b[m\n", "\u001b[1m--- a/mars.txt\u001b[m\n", "\u001b[1m+++ b/mars.txt\u001b[m\n", "\u001b[36m@@ -1,3 +1,4 @@\u001b[m\n", " Cold and dry, but everything is my favorite color\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", "\u001b[32m+\u001b[m\u001b[32mBut the Mummy will appreciate the lack of humidity\u001b[m\n" ] } ], "source": [ "git diff --staged" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[master 12100d9] Discuss concerns about Mars' climate for Mummy\n", " 1 file changed, 1 insertion(+)\n" ] } ], "source": [ "git commit -m \"Discuss concerns about Mars' climate for Mummy\"" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "nothing to commit, working tree clean\n" ] } ], "source": [ "git status" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[33mcommit 12100d9076a11b9b9c14b74f89e35f37b17d2290\u001b[m\n", "Author: Vlad Dracula \n", "Date: Wed Jun 26 08:04:37 2019 +0000\n", "\n", " Discuss concerns about Mars' climate for Mummy\n", "\n", "\u001b[33mcommit bbb518b1021fa00ce43649ae1536929eafe08f8d\u001b[m\n", "Author: Vlad Dracula \n", "Date: Wed Jun 26 08:04:33 2019 +0000\n", "\n", " Add concerns about effects of Mars' moons on Wolfman\n", "\n", "\u001b[33mcommit 1fbe6424cf9dc240f2540ce6877646467214bca6\u001b[m\n", "Author: Vlad Dracula \n", "Date: Wed Jun 26 08:04:25 2019 +0000\n", "\n", " Start notes on Mars as a base\n" ] } ], "source": [ "git log" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "nothing to commit, working tree clean\n" ] } ], "source": [ "mkdir spaceships\n", "git status" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "nothing to commit, working tree clean\n" ] } ], "source": [ "git add spaceships\n", "git status" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "Untracked files:\n", " (use \"git add ...\" to include in what will be committed)\n", "\n", "\t\u001b[31mspaceships/\u001b[m\n", "\n", "nothing added to commit but untracked files present (use \"git add\" to track)\n" ] } ], "source": [ "touch spaceships/apollo-11 spaceships/sputnik-1\n", "git status" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [], "source": [ "git add spaceships/apollo-11" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "Changes to be committed:\n", " (use \"git reset HEAD ...\" to unstage)\n", "\n", "\t\u001b[32mnew file: spaceships/apollo-11\u001b[m\n", "\t\u001b[32mnew file: spaceships/sputnik-1\u001b[m\n", "\n" ] } ], "source": [ "git add spaceships/sputnik-1\n", "git status" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[master b84b48a] Add some initial thoughts on spaceships\n", " 2 files changed, 0 insertions(+), 0 deletions(-)\n", " create mode 100644 spaceships/apollo-11\n", " create mode 100644 spaceships/sputnik-1\n" ] } ], "source": [ "git commit -m \"Add some initial thoughts on spaceships\"" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "apollo-11 sputnik-1\n" ] } ], "source": [ "ls spaceships" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exploring History" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [], "source": [ "echo An ill-considered change >> mars.txt" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1mdiff --git a/mars.txt b/mars.txt\u001b[m\n", "\u001b[1mindex 9ceb94e..0fee1c3 100644\u001b[m\n", "\u001b[1m--- a/mars.txt\u001b[m\n", "\u001b[1m+++ b/mars.txt\u001b[m\n", "\u001b[36m@@ -2,3 +2,4 @@\u001b[m \u001b[mCold and dry, but everything is my favorite color\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", " But the Mummy will appreciate the lack of humidity\u001b[m\n", "\u001b[32m+\u001b[m\u001b[32mAn ill-considered change\u001b[m\n" ] } ], "source": [ "git diff HEAD " ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1mdiff --git a/mars.txt b/mars.txt\u001b[m\n", "\u001b[1mindex 6b1d81a..0fee1c3 100644\u001b[m\n", "\u001b[1m--- a/mars.txt\u001b[m\n", "\u001b[1m+++ b/mars.txt\u001b[m\n", "\u001b[36m@@ -1,3 +1,5 @@\u001b[m\n", " Cold and dry, but everything is my favorite color\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", "\u001b[32m+\u001b[m\u001b[32mBut the Mummy will appreciate the lack of humidity\u001b[m\n", "\u001b[32m+\u001b[m\u001b[32mAn ill-considered change\u001b[m\n" ] } ], "source": [ "git diff HEAD~2 mars.txt" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1mdiff --git a/mars.txt b/mars.txt\u001b[m\n", "\u001b[1mindex 315bf3a..0fee1c3 100644\u001b[m\n", "\u001b[1m--- a/mars.txt\u001b[m\n", "\u001b[1m+++ b/mars.txt\u001b[m\n", "\u001b[36m@@ -1,2 +1,5 @@\u001b[m\n", " Cold and dry, but everything is my favorite color\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", "\u001b[32m+\u001b[m\u001b[32mThe two moons may be a problem for Wolfman\u001b[m\n", "\u001b[32m+\u001b[m\u001b[32mBut the Mummy will appreciate the lack of humidity\u001b[m\n", "\u001b[32m+\u001b[m\u001b[32mAn ill-considered change\u001b[m\n" ] } ], "source": [ "git diff HEAD~3 mars.txt" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[33mcommit bbb518b1021fa00ce43649ae1536929eafe08f8d\u001b[m\n", "Author: Vlad Dracula \n", "Date: Wed Jun 26 08:04:33 2019 +0000\n", "\n", " Add concerns about effects of Mars' moons on Wolfman\n", "\n", "\u001b[1mdiff --git a/mars.txt b/mars.txt\u001b[m\n", "\u001b[1mindex 315bf3a..6b1d81a 100644\u001b[m\n", "\u001b[1m--- a/mars.txt\u001b[m\n", "\u001b[1m+++ b/mars.txt\u001b[m\n", "\u001b[36m@@ -1,2 +1,3 @@\u001b[m\n", " Cold and dry, but everything is my favorite color\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", "\u001b[32m+\u001b[m\u001b[32mThe two moons may be a problem for Wolfman\u001b[m\n", "\u001b[33mcommit 1fbe6424cf9dc240f2540ce6877646467214bca6\u001b[m\n", "Author: Vlad Dracula \n", "Date: Wed Jun 26 08:04:25 2019 +0000\n", "\n", " Start notes on Mars as a base\n", "\n", "\u001b[1mdiff --git a/mars.txt b/mars.txt\u001b[m\n", "\u001b[1mnew file mode 100644\u001b[m\n", "\u001b[1mindex 0000000..315bf3a\u001b[m\n", "\u001b[1m--- /dev/null\u001b[m\n", "\u001b[1m+++ b/mars.txt\u001b[m\n", "\u001b[36m@@ -0,0 +1,2 @@\u001b[m\n", "\u001b[32m+\u001b[m\u001b[32mCold and dry, but everything is my favorite color\u001b[m\n", "\u001b[32m+\u001b[m\u001b[32mThe two moons may be a problem for Wolfman\u001b[m\n" ] } ], "source": [ "git show HEAD~2 mars.txt\n", "git show HEAD~3 mars.txt" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1mdiff --git a/mars.txt b/mars.txt\u001b[m\n", "\u001b[1mindex 6b1d81a..315bf3a 100644\u001b[m\n", "\u001b[1m--- a/mars.txt\u001b[m\n", "\u001b[1m+++ b/mars.txt\u001b[m\n", "\u001b[36m@@ -1,3 +1,2 @@\u001b[m\n", " Cold and dry, but everything is my favorite color\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", "\u001b[31m-The two moons may be a problem for Wolfman\u001b[m\n" ] } ], "source": [ "git diff HEAD~2 HEAD~3" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1mdiff --git a/mars.txt b/mars.txt\u001b[m\n", "\u001b[1mindex 6b1d81a..315bf3a 100644\u001b[m\n", "\u001b[1m--- a/mars.txt\u001b[m\n", "\u001b[1m+++ b/mars.txt\u001b[m\n", "\u001b[36m@@ -1,3 +1,2 @@\u001b[m\n", " Cold and dry, but everything is my favorite color\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", "\u001b[31m-The two moons may be a problem for Wolfman\u001b[m\n" ] } ], "source": [ "git diff bbb51 1fbe64" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1mdiff --git a/mars.txt b/mars.txt\u001b[m\n", "\u001b[1mindex 6b1d81a..0fee1c3 100644\u001b[m\n", "\u001b[1m--- a/mars.txt\u001b[m\n", "\u001b[1m+++ b/mars.txt\u001b[m\n", "\u001b[36m@@ -1,3 +1,5 @@\u001b[m\n", " Cold and dry, but everything is my favorite color\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", "\u001b[32m+\u001b[m\u001b[32mBut the Mummy will appreciate the lack of humidity\u001b[m\n", "\u001b[32m+\u001b[m\u001b[32mAn ill-considered change\u001b[m\n" ] } ], "source": [ "git diff bbb51 mars.txt" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "Changes not staged for commit:\n", " (use \"git add ...\" to update what will be committed)\n", " (use \"git checkout -- ...\" to discard changes in working directory)\n", "\n", "\t\u001b[31mmodified: mars.txt\u001b[m\n", "\n", "no changes added to commit (use \"git add\" and/or \"git commit -a\")\n" ] } ], "source": [ "git status" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [], "source": [ "git checkout -- mars.txt" ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Cold and dry, but everything is my favorite color\n", "The two moons may be a problem for Wolfman\n", "The two moons may be a problem for Wolfman\n", "But the Mummy will appreciate the lack of humidity\n" ] } ], "source": [ "cat mars.txt" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [], "source": [ "git checkout bbb51 mars.txt" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Cold and dry, but everything is my favorite color\n", "The two moons may be a problem for Wolfman\n", "The two moons may be a problem for Wolfman\n" ] } ], "source": [ "cat mars.txt" ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "Changes to be committed:\n", " (use \"git reset HEAD ...\" to unstage)\n", "\n", "\t\u001b[32mmodified: mars.txt\u001b[m\n", "\n" ] } ], "source": [ "git status" ] }, { "cell_type": "code", "execution_count": 53, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1mdiff --git a/mars.txt b/mars.txt\u001b[m\n", "\u001b[1mindex 9ceb94e..6b1d81a 100644\u001b[m\n", "\u001b[1m--- a/mars.txt\u001b[m\n", "\u001b[1m+++ b/mars.txt\u001b[m\n", "\u001b[36m@@ -1,4 +1,3 @@\u001b[m\n", " Cold and dry, but everything is my favorite color\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", " The two moons may be a problem for Wolfman\u001b[m\n", "\u001b[31m-But the Mummy will appreciate the lack of humidity\u001b[m\n" ] } ], "source": [ "git diff --staged mars.txt" ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "outputs": [], "source": [ "git checkout HEAD mars.txt" ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "nothing to commit, working tree clean\n" ] } ], "source": [ "git status" ] }, { "cell_type": "code", "execution_count": 56, "metadata": {}, "outputs": [], "source": [ "git checkout 1fbe64 mars.txt" ] }, { "cell_type": "code", "execution_count": 57, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Note: checking out '1fbe64'.\n", "\n", "You are in 'detached HEAD' state. You can look around, make experimental\n", "changes and commit them, and you can discard any commits you make in this\n", "state without impacting any branches by performing another checkout.\n", "\n", "If you want to create a new branch to retain commits you create, you may\n", "do so (now or later) by using -b with the checkout command again. Example:\n", "\n", " git checkout -b \n", "\n", "HEAD is now at 1fbe642... Start notes on Mars as a base\n" ] } ], "source": [ "git checkout 1fbe64" ] }, { "cell_type": "code", "execution_count": 58, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Previous HEAD position was 1fbe642... Start notes on Mars as a base\n", "Switched to branch 'master'\n" ] } ], "source": [ "git checkout master" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "On branch master\n", "nothing to commit, working tree clean\n" ] } ], "source": [ "git status" ] } ], "metadata": { "kernelspec": { "display_name": "Bash", "language": "bash", "name": "bash" }, "language_info": { "codemirror_mode": "shell", "file_extension": ".sh", "mimetype": "text/x-sh", "name": "bash" } }, "nbformat": 4, "nbformat_minor": 2 }