0% found this document useful (0 votes)
53 views

Git Notes

The document describes the process of collaboratively editing a website using Git version control. It shows how multiple developers can make changes to the code on their local repositories, then push those changes to a remote repository to be merged together. Edits like adding text, changing styles and fixing bugs are displayed from several developers' local versions over time.

Uploaded by

d.chakol
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Git Notes

The document describes the process of collaboratively editing a website using Git version control. It shows how multiple developers can make changes to the code on their local repositories, then push those changes to a remote repository to be merged together. Edits like adding text, changing styles and fixing bugs are displayed from several developers' local versions over time.

Uploaded by

d.chakol
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 177

Git

Home Contact Abbout

Explore nature
in Canada.
See more

👩🏼‍💻
www.mywebsite.com local

Home Contact Abbout Home Contact Abbout

Explore nature Explore nature


in Canada. in Canada.
See more See more

👩🏼‍💻
www.mywebsite.com local

Home Contact Abbout Home Contact About

Explore nature
Explore nature in Canada.
Visit Canada’s lakes and mountains.
in Canada.
See more See more

👩🏼‍💻
www.mywebsite.com local

Home Contact Abbout Home Contact About

Explore nature
Explore nature in Canada.
Visit Canada’s lakes and mountains.
in Canada.
See more See more

👩🏼‍💻♀️
🤦🏼‍
Git
Content tracker

Distributed Version Control System

Git
Home Contact About

Explore nature
in Canada. New state of your website with
Visit Canada’s lakes and mountains. the local changes
See more

Home Contact Abbout

Explore nature
Hosted state of your website
in Canada.
See more
Fixed button CSS @max 🙋🏽‍♂️ 12.23AM

Changed background image @sara 🙋🏼‍♀️ 11.15AM

Added sub title @tim 💁🏼‍♂️ 11.05AM

Fixed buttons in navigation @max 🙋🏽‍♂️ 10.45AM

Added front page @sara 🙋🏼‍♀️ 10.24AM


Home Contact Abbout

Explore nature
in Canada.
Visit Canada’s lakes and mountains.

See more
Change background

Home Contact Abbout

Explore nature
in Canada.
Added front page
See more
Home Contact Abbout

Explore nature
in Canada.
Visit Canada’s lakes and mountains.

See more
Change background

Home Contact Abbout

Explore nature
in Canada.
Added front page
See more
Home Contact Abbout

Explore nature
in Canada.
Visit Canada’s lakes and mountains.

See more
Change background

Home Contact Abbout

Explore nature
in Canada.
Added front page
See more
www.mywebsite.com

Home Contact About

Explore nature
in Canada.
See more

Home Contact Abbout Home Contact About

Explore nature
in Canada. Explore nature
Visit Canada’s lakes and mountains.

See more
Change background Fixed button typo in Canada.
See more

Home Contact Abbout

Explore nature
in Canada.
Added front page
See more
www.mywebsite.com

Home Contact About

Explore nature
in Canada.
See more

Home Contact Abbout Home Contact About

Explore nature
in Canada. Explore nature
Visit Canada’s lakes and mountains.

See more
Change background Fixed button typo in Canada.
See more

Home Contact Abbout

Explore nature
in Canada.
Added front page
See more
Remote Repository

Local Repository

<html>
<body>
👩🏽
<h1>My Website!</h1>
</body>
</html>
Remote Repository

<html>
<body>
<h1>My Website!</h1>
</body>
</html>

Local Repository Local Repository

<html>
<body>
👩🏽 👱🏾‍♂️
<h1>My Website!</h1>
</body>
</html>
Remote Repository

<html>
<body>
<h1>My Website!</h1>
</body>
</html>

Local Repository Local Repository

<html>
<body>
👩🏽 👱🏾‍♂️
<h1>My Website!</h1>
</body>
</html>
Remote Repository

<html>
<body>
<h1>My Website!</h1>
</body>
</html>

Local Repository Local Repository

<html>
<body>
👩🏽 <html>
<body>
👱🏾‍♂️
<h1>My Website!</h1>
<h1>My Website!</h1>
<p>This is some more text!</p>
</body>
</body>
</html>
</html>
Remote Repository

<html>
<body>
<h1>My Website!</h1>
</body>
</html>

Local Repository Local Repository

<html>
<body>
👩🏽 <html>
<html>
<body>
<body>
👱🏾‍♂️
<h1>My
<h1>MyWebsite!</h1>
Website!</h1>
<h1>My Website!</h1>
<p>This
<p>Thisisissome
somemore
moretext!</p>
text!</p>
</body>
</body>
</body>
</html>
</html>
</html>
Remote Repository

<html>
<html>
<body>
<body>
<h1>My Website!</h1>
<h1>My Website!</h1>
<p>This is some more text!</p>
</body>
</body>
</html>
</html>

Local Repository Local Repository

<html>
<body>
👩🏽 <html>
<html>
<body>
<body>
👱🏾‍♂️
<h1>My
<h1>MyWebsite!</h1>
Website!</h1>
<h1>My Website!</h1>
<p>This
<p>Thisisissome
somemore
moretext!</p>
text!</p>
</body>
</body>
</body>
</html>
</html>
</html>
Local Repository

Working Area Staging Area Committed Files


Fixed button CSS @max 🙋🏽‍♂️ commit

Changed background image @sara 🙋🏼‍♀️ commit

Added sub title @tim 💁🏼‍♂️ commit

Fixed buttons in navigation @max 🙋🏽‍♂️ commit

Added front page @sara 🙋🏼‍♀️ commit


Local Repository

Working Area Staging Area Committed Files

story2.txt

story1.txt
Initialize Git Repo
bash

$ git init
Initialized empty Git repository in
/Users/lydiahallie/Desktop/myproject/.git/
bash

$ ls -a
. .. .git
bash

$ touch story1.txt
$ echo "This is a beautiful story" >> story1.txt
bash

$ git status
On branch master

No commits yet

Untracked files:
story1.txt

nothing added to commit but untracked files present


bash

Working Area Staging Area Committed Files

story1.txt
bash

$ git add story1.txt

Working Area Staging Area Committed Files

story1.txt
bash

$ git commit -m "Added first story"

Working Area Staging Area Committed Files

story1.txt
Added first story @me 🙋🏼‍♀️
Git log
bash

$ git log
commit 67c833e3…ecb7df62f (HEAD -> master)

Author: John Doe <john@doe>

Date: Sun Jun 14 14:45:07 2020 -0700

Added first story


bash

$ git log —-oneline


67c833e (HEAD -> master) Added first story
Initializing a remote repo
Connection String

https://.../.../[name].git
bash

$ git remote add origin https://.../.../[name].git


Local Repository

Working Area Staging Area Committed Files


https://.../.../[name].git
Remote Repository

Local Repository

Working Area Staging Area Committed Files


bash

$ git remote -v
origin https://.../.../[name].git (fetch)
origin https://.../.../[name].git (push)
Pushing
Remote Repository

Local Repository

<html>
<body>
👩🏽
<h1>My Website!</h1>
</body>
</html>
bash

$ git push origin master


Added fifth story @me 🙋🏼‍♀️

Added fourth story @me 🙋🏼‍♀️

Added third story @me 🙋🏼‍♀️

Added second story @me 🙋🏼‍♀️ local remote

Added first story @me 🙋🏼‍♀️


Cloning
bash

$ git clone <ssh link>


bash

$ git clone [email protected]:….…git


Cloning into 'remote-repo'...
remote: Enumerating objects: 59, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (43/43), done.
remote: Total 2948 (delta 28), reused 18 (delta 6)
Receiving objects: 100% (2948/2948), 1.93 MiB | 2.53 MiB/s, done.
Resolving deltas: 100% (1526/1526), done.
bash

$ cd remote-repo
$ git log
commit 67c833e3…ecb7df62f (HEAD -> origin/master)

Author: John Doe <john@doe>

Date: Sun Jun 14 14:45:07 2020 -0700

Added first story


Branches
Added fifth story @me 🙋🏼‍♀️

Added fourth story @me 🙋🏼‍♀️

Added third story @me 🙋🏼‍♀️

Added second story @me 🙋🏼‍♀️

Added first story @me 🙋🏼‍♀️


👨🏼‍💻 Added seventh story @friend

👨🏼‍💻 Added sixth story @friend

Added fifth story @me 🙋🏼‍♀️ 👨🏼‍💻 Fixed fourth story @friend

Added fifth story @me 🙋🏼‍♀️

Added fourth story @me 🙋🏼‍♀️


Merged branch Dave @friend 👨🏼‍💻

👨🏼‍💻 Added seventh story @friend

👨🏼‍💻 Added sixth story @friend

Added fifth story @me 🙋🏼‍♀️ 👨🏼‍💻 Fixed fourth story @friend

Added fifth story @me 🙋🏼‍♀️

Added fourth story @me 🙋🏼‍♀️


🙋🏼‍♀️Updated tests

🙋🏼‍♀️ Added cool new feature


🙋🏼‍♀️Updated tests

🙋🏼‍♀️ Added cool new feature


bash

$ git checkout -b sarah


Switched to a new branch 'sarah'

$ git branch
master
* sarah
Added first story @me 🙋🏼‍♀️ master sarah
Added second story @sarah 👩🏽‍💻

Added first story @me 🙋🏼‍♀️ master sarah


Added second story @sarah 👩🏽‍💻 sarah

Added first story @me 🙋🏼‍♀️ master


Added second story @sarah 👩🏽‍💻 sarah

Added first story @me 🙋🏼‍♀️ master max


Added second story @sarah 👩🏽‍💻 sarah

Added first story @me 🙋🏼‍♀️ master max


sarah

Added second story @sarah 👩🏽‍💻 Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️ master max


Merging
sarah max

Added second story @sarah 👩🏽‍💻 Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️ master


bash

$ git checkout master

sarah max

Added second story @sarah 👩🏽‍💻 Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️ master


bash

$ git checkout master


$ git merge max

sarah max

Added second story @sarah 👩🏽‍💻 Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️ master


bash

$ git checkout master


$ git merge max

sarah max master

Added second story @sarah 👩🏽‍💻 Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️


bash

$ git merge sarah

sarah max master

Added second story @sarah 👩🏽‍💻 Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️


bash

$ git merge sarah

Merge sarah into master @sarah 👩🏽‍💻


sarah max master

Added second story @sarah 👩🏽‍💻 Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️


bash

$ git merge sarah

Merge sarah into master @sarah 👩🏽‍💻


sarah max master

Added second story @sarah 👩🏽‍💻 Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️


Merge Conflicts
Merge sarah into master @sarah 👩🏽‍💻
sarah max master

Added second story @sarah 👩🏽‍💻 Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️


fourth_story.md fourth_story.md

## Fourth Story ## Fourth Story

This is Sarah’s version This is Max’s version


of the fourth story! of the fourth story!

Some extra stuff Sarah


added

sarah max

Started fourth story @sarah 👩🏽‍💻 Started fourth story @max 🧔🏻

master
sarah max

Started fourth story @sarah 👩🏽‍💻 Started fourth story @max 🧔🏻

master
master sarah max

Started fourth story @sarah 👩🏽‍💻 Started fourth story @max 🧔🏻


fourth_story.md fourth_story.md

## Fourth Story ## Fourth Story

This is Sarah’s version This is Max’s version


of the fourth story! of the fourth story!

master sarah max

Started fourth story @sarah 👩🏽‍💻 Started fourth story @max 🧔🏻


fourth_story.md

## Fourth Story
<<<<<<<< HEAD
This is Sarah’s version
=======
This is Max’s version
>>>>>>> max
of the fourth story!

Some extra stuff Sarah


added
fourth_story.md

## Fourth Story
<<<<<<<< HEAD
This is Sarah’s version
=======
This is Max’s version
>>>>>>> max
of the fourth story!

Some extra stuff Sarah


added
bash

$ git add fourth_story.txt


$ git merge

master sarah max

Started fourth story @sarah 👩🏽‍💻 Started fourth story @max 🧔🏻


bash

$ git add fourth_story.txt


$ git merge

Merge max into master @max 🧔🏻


master sarah max

Started fourth story @sarah 👩🏽‍💻 Started fourth story @max 🧔🏻


Pull Request
sarah max

Added second story @sarah 👩🏽‍💻 Added third story @max 🧔🏻


🧔🏻

Added first story @me 🙋🏼‍♀️ master origin/master


bash

$ git push origin sarah

origin/sarah sarah max

Added second story @sarah 👩🏽‍💻 Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️ master origin/master


Fetching and Pulling
bash

$ git fetch origin master

origin/sarah sarah max

Added second story @sarah 👩🏽‍💻 Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️ master origin/master


bash

$ git merge origin/master

origin/master

origin/sarah sarah max

Added second story @sarah 👩🏽‍💻 Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️ master


bash

$ git pull origin master

origin/sarah sarah max

Added second story @sarah 👩🏽‍💻 Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️ master origin/master


Rebasing
bash

$ git merge sarah

Merge sarah into master @sarah 👩🏽‍💻


sarah max master

Added second story @sarah 👩🏽‍💻 Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️


bash

$ git rebase sarah

sarah max master

Added second story @sarah 👩🏽‍💻 Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️


bash

$ git rebase sarah

sarah
master
Added second story @sarah 👩🏽‍💻
max

Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️


bash

sarah max master

Added second story @sarah 👩🏽‍💻 jf79w 7wtf78


Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️


89fej
bash

$ git merge sarah

90f7d
Merge sarah into master @sarah 👩🏽‍💻
sarah max master

Added second story @sarah 👩🏽‍💻 jf79w 7wtf78


Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️


89fej
bash

$ git rebase sarah

sarah max master

Added second story @sarah 👩🏽‍💻 jf79w 7wtf78


Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️


89fej
bash

$ git rebase sarah

sarah
master
Added second story @sarah 👩🏽‍💻 890sf

max

7wtf78
Added third story @max 🧔🏻

Added first story @me 🙋🏼‍♀️


89fej
Interactive Rebasing
bash

More changes to second story @sarah 👩🏽‍💻 sarah

6a6f6

Oops more changes to second story @sarah 👩🏽‍💻


8ad5d

Changes to second story @sarah 👩🏽‍💻


aaba5

Added second story @sarah 👩🏽‍💻


fb9f1
bash

$ git rebase -i HEAD~4

More changes to second story @sarah 👩🏽‍💻 sarah

6a6f6

Oops more changes to second story @sarah 👩🏽‍💻


8ad5d

Changes to second story @sarah 👩🏽‍💻


aaba5

Added second story @sarah 👩🏽‍💻


fb9f1
bash

$ git rebase -i HEAD~4


pick fb9f191 Added second story
pick aaba5e7 Changes to second story
pick 8ad5d7b Oops more changes to second story
pick 6a6f68b More changes to second story
# Rebase dc9ad3c..6a6f68b onto 6a6f68b (4 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
#. create a merge commit using the original merge commit's
#. message (or the oneline, if no original merge commit was
#. specified). Use -c <commit> to reword the commit message.
bash

$ git rebase -i HEAD~4


pick fb9f191 Added second story
pick aaba5e7 Changes to second story
pick 8ad5d7b Oops more changes to second story
pick 6a6f68b More changes to second story
# Rebase dc9ad3c..6a6f68b onto 6a6f68b (4 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
#. create a merge commit using the original merge commit's
#. message (or the oneline, if no original merge commit was
#. specified). Use -c <commit> to reword the commit message.
bash

$ git rebase -i HEAD~4


pick fb9f191 Added second story
squash aaba5e7 Changes to second story
squash 8ad5d7b Oops more changes to second story
squash 6a6f68b More changes to second story
# Rebase dc9ad3c..6a6f68b onto 6a6f68b (4 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
#. create a merge commit using the original merge commit's
#. message (or the oneline, if no original merge commit was
#. specified). Use -c <commit> to reword the commit message.
bash

$ git rebase -i HEAD~4

More changes to second story @sarah 👩🏽‍💻 sarah

6a6f6

Oops more changes to second story @sarah 👩🏽‍💻


8ad5d

Changes to second story @sarah 👩🏽‍💻


aaba5

Added second story @sarah 👩🏽‍💻


fb9f1
bash

$ git rebase -i HEAD~4

Added second story sarah


Changes to second story
@sarah 👩🏽‍💻
81h48
Oops more changes to second story
More changes to second story
Cherry-Picking
bash

sarah

Changed second story @sarah 👩🏽‍💻 8ad5d

Changed first story @sarah 👩🏽‍💻


aaba5

Added second story @sarah 👩🏽‍💻


jf79w

Added first story @me 🙋🏼‍♀️


89fej
bash

$ git cherry-pick aaba5

sarah

Changed second story @sarah 👩🏽‍💻 8ad5d

Changed first story @sarah 👩🏽‍💻


aaba5

Added second story @sarah 👩🏽‍💻


jf79w

Added first story @me 🙋🏼‍♀️


89fej
bash

$ git cherry-pick aaba5

sarah

Changed second story @sarah 👩🏽‍💻 8ad5d

Changed first story @sarah 👩🏽‍💻


aaba5

Added second story @sarah 👩🏽‍💻


jf79w 89hd8

Added first story @me 🙋🏼‍♀️


89fej
bash

$ git cherry-pick aaba5

sarah

Changed second story @sarah 👩🏽‍💻 8ad5d

Changed first story @sarah 👩🏽‍💻


aaba5

Added second story @sarah 👩🏽‍💻


jf79w 89hd8

Added first story @me 🙋🏼‍♀️


89fej
bash

$ echo "This is my first story" >> first_story.txt


Porcelain Commands Plumbing Commands

git add git hash-object


git status git ls-files
git commit git rev-parse
git stash git ls-remote
… …
bash

$ git hash-object first_story.txt


bea8d7fee8e7b11c2235ca623935e6ccccd8bac3
bash

$ git hash-object first_story.txt


bea8d7fee8e7b11c2235ca623935e6ccccd8bac3
bash

$ git add first_story.txt


$ git commit -m "First story"
$ ls ./.git/objects
26 be a0 info pack
bash

$ git add first_story.txt


$ git commit -m "First story"
$ ls ./.git/objects
26 be a0 info pack
$ ls ./.git/objects/be
a8d7fee8e7b11c2235ca623935e6ccccd8bac3
bash

$ git add first_story.txt


$ git commit -m "First story"
$ ls ./.git/objects
26 be a0 info pack
$ ls ./.git/objects/be
a8d7fee8e7b11c2235ca623935e6ccccd8bac3
$ git cat-file -p bea8d7
"This is my first story"
bash

$ git cat-file -p 4cdf4


tree 2ea7de7ff3bd48cbb020b215b36feb67ee7f9a30
parent f4e830485cc852686cf115e75a79cbb41a0de713
author Lydia Hallie <[email protected]> 1594547678 +0200
committer Lydia Hallie <[email protected]> 1594547678 +0200

First story
bash

$ git cat-file -p 4cdf4


tree 2ea7de7ff3bd48cbb020b215b36feb67ee7f9a30
parent f4e830485cc852686cf115e75a79cbb41a0de713
author Lydia Hallie <[email protected]> 1594547678 +0200
committer Lydia Hallie <[email protected]> 1594547678 +0200

First story
Git Object Contents

commit
tree
blob
Added third story @sarah 👩🏽‍💻
8ad5d

Changes to second story @sarah 👩🏽‍💻


aaba5

Added second story @sarah 👩🏽‍💻


fb9f1
Added third story @sarah 👩🏽‍💻
8ad5d

Changes to second story @sarah 👩🏽‍💻


aaba5

Added second story @sarah 👩🏽‍💻


fb9f1
Added third story @sarah 👩🏽‍💻
8ad5d

Changes to second story @sarah 👩🏽‍💻


aaba5

Added second story @sarah 👩🏽‍💻


fb9f1
blob

commit tree blob

8ad5d

commit tree blob

aaba5

commit tree blob

fb9f1
blob

commit tree blob

8ad5d

commit tree blob

aaba5

commit tree blob

fb9f1
blob

commit tree blob

8ad5d

commit tree blob

aaba5

commit tree blob

fb9f1
blob

commit tree blob

8ad5d

commit tree blob

aaba5

commit tree blob

fb9f1
Resetting and Reverting
bash

Added third story @sarah 👩🏽‍💻 sarah

8ad5d

Changes to second story @sarah 👩🏽‍💻


aaba5

Added second story @sarah 👩🏽‍💻


fb9f1
bash

$ git revert 8ad5d

Added third story @sarah 👩🏽‍💻 sarah + third_story.md

8ad5d

Changes to second story @sarah 👩🏽‍💻


aaba5

Added second story @sarah 👩🏽‍💻


fb9f1
bash

$ git revert 8ad5d

Reverted “Added third story” @sarah 👩🏽‍💻 sarah - third_story.md

890hs

Added third story @sarah 👩🏽‍💻 + third_story.md

8ad5d

Changes to second story @sarah 👩🏽‍💻


aaba5

Added second story @sarah 👩🏽‍💻


fb9f1
bash

Added third story @sarah 👩🏽‍💻 sarah

8ad5d

Changes to second story @sarah 👩🏽‍💻


aaba5

Added second story @sarah 👩🏽‍💻


fb9f1
bash

$ git reset —-soft HEAD~1

Added third story @sarah 👩🏽‍💻 sarah

8ad5d

Changes to second story @sarah 👩🏽‍💻


aaba5

Added second story @sarah 👩🏽‍💻


fb9f1
bash

$ git reset —-soft HEAD~1

Changes to second story @sarah 👩🏽‍💻 sarah

aaba5

Added second story @sarah 👩🏽‍💻


fb9f1
bash

$ git reset —-soft HEAD~1


$ git status
On branch sarah
Changes to be committed:
added: third_story.md

Changes to second story @sarah 👩🏽‍💻 sarah

aaba5

Added second story @sarah 👩🏽‍💻


fb9f1
bash

$ git reset —-hard HEAD~1

Added third story @sarah 👩🏽‍💻 sarah

8ad5d

Changes to second story @sarah 👩🏽‍💻


aaba5

Added second story @sarah 👩🏽‍💻


fb9f1
bash

$ git reset —-hard HEAD~1

Changes to second story @sarah 👩🏽‍💻 sarah

aaba5

Added second story @sarah 👩🏽‍💻


fb9f1
bash

$ git reset —-hard HEAD~1


$ git status
On branch sarah
Nothing to commit

Changes to second story @sarah 👩🏽‍💻 sarah

aaba5

Added second story @sarah 👩🏽‍💻


fb9f1
Git Stash
Working Area Staging Area Committed Files

+ third_story.md

bash

sarah
$ git stash
Added second story @sarah 👩🏽‍💻

Added first story @me 🙋🏼‍♀️


Working Area Staging Area Committed Files Stash

+ third_story.md

bash

sarah
$ git stash
Added second story @sarah 👩🏽‍💻

Added first story @me 🙋🏼‍♀️


Working Area Staging Area Committed Files Stash

+ third_story.md

WIP on sarah:
f4e8304 Added second story
bash

sarah
$ git stash
Added second story @sarah 👩🏽‍💻

Added first story @me 🙋🏼‍♀️


Working Area Staging Area Committed Files Stash

+ third_story.md

WIP on sarah:
f4e8304 Added second story
bash

sarah
$ git stash pop
Added second story @sarah 👩🏽‍💻

Added first story @me 🙋🏼‍♀️


Working Area Staging Area Committed Files Stash

+ third_story.md

WIP on sarah:
f4e8304 Added second story
bash

sarah
$ git stash pop
Added second story @sarah 👩🏽‍💻

Added first story @me 🙋🏼‍♀️


Working Area Staging Area Committed Files Stash

+ third_story.md

WIP on sarah:
f4e8304 Added second story
bash

sarah
$ git stash pop
Added second story @sarah 👩🏽‍💻

Added first story @me 🙋🏼‍♀️


bash

$ git stash

Staging Area Stash

+ third_story.md
bash

$ git stash

Staging Area Stash

+ third_story.md
bash

$ git stash

Staging Area Stash

+ fourth_story.md

+ third_story.md
bash

$ git stash

Staging Area Stash

+ fourth_story.md

+ third_story.md
bash

$ git stash

Staging Area Stash

+ fifth_story.md

+ fourth_story.md

+ third_story.md
bash

$ git stash

Staging Area Stash

+ fifth_story.md

+ fourth_story.md

+ third_story.md
bash

$ git stash list


stash@{0}: WIP on sarah: f4e8304 Added second story
stash@{1}: WIP on sarah: f4e8304 Added second story
stash@{2}: WIP on sarah: f4e8304 Added second story
bash

$ git stash list


stash@{0}: WIP on sarah: f4e8304 Added second story
stash@{1}: WIP on sarah: f4e8304 Added second story
stash@{2}: WIP on sarah: f4e8304 Added second story
$ git stash show stash@{1}
fourth_story.md | 1 +
1 file changed, 1 addition(+)
bash

$ git stash list


stash@{0}: WIP on sarah: f4e8304 Added second story
stash@{1}: WIP on sarah: f4e8304 Added second story
stash@{2}: WIP on sarah: f4e8304 Added second story
$ git stash show stash@{1}
fourth_story.md | 1 +
1 file changed, 1 addition(+)
$ git stash pop stash@{1}
Dropped stash@{1} (2cfe…)

You might also like