Giter Site home page Giter Site logo

git-masterclass-activity-2's Introduction

Git Master Class Activity 2

This is simple repository to practice some of the concepts taught in Common Code's Git Master Class training course.

Here we look at the effect on commit ID (SHA-1 hashing) of various types of commits.

We look at what the dependencies of the hash operation are and see if we can re-create a certain commit SHA-1.

There is chance to practice undoing commits.

The only file (apart from this one) is manuscript.md which is a plain text passage of English.

There is a series of branches already created to set the scene for this activity.

Try to perform the tasks using commands in your computer terminal - if you get stuck then click 'Show me how'

Setup

First off, clone and/or fork this repository locally.

Show me how
mkdir commoncode
cd commoncode
git clone [email protected]:commoncode/git-masterclass-activity-2.git
cd git-masterclass-activity-2

To restart the exercise at any time just rm -Rf git-masterclass-activity-2 and re-clone.


This repo has a couple of branches with a sequence of commits resulting in a tree like this:

                E --- F --- K --- L     feature_2
               /
        C --- D --- I --- J             feature_1
       /
A --- B --- G --- H                     master

In this exercise we will simply look at the tip of the feature_2 branch.

Task

Verify if the same file change on a branch results in the same commit ID. Do this by undoing and then re-applying commit L.

Show me how
git checkout feature_2

# Copy the last commit info
git log -n 1 > L.txt

# See the last change
git diff HEAD~1

# Undo the last commit
git reset --hard HEAD~1

# Manually redo the commit - s/George/Gary in vim manuscript.md
# check the unstaged change then check in
git diff
git add manuscript.md
git commit -m "L - Gary"

# Compare the changes
git log -n 1 > L1.txt
diff L1.txt L.txt

Task

Verify if a cherry-picked commit results in the same commit ID by undoing and reapplying commit L.

Show me how
git checkout feature_2

# Copy the last commit info
git log -n 1 > L.txt

# See the last change
git diff HEAD~1

# Undo the last commit
git reset --hard HEAD~1

git cherry-pick 324c9754d092a8a279714be5bf015ffbcf659c3a

# Compare the changes
git log -n 1 > L2.txt
diff L2.txt L.txt

Task

Generate a commit with the same SHA-1 as a previous commit - recreate commit L perfectly

To do so we will need to ensure all these are the identical: - commit message - committer - commit date - author - authoring date - parent tree

Show me how
# reclone the repo
cd ..
rm -rf git-masterclass-activity-2
git clone [email protected]:commoncode/git-masterclass-activity-2.git
cd git-masterclass-activity-2

git checkout feature_2

# Copy the last commit info with full details
git log --pretty=fuller -n 1 > LF.txt

# Undo the last commit
git reset --hard HEAD~1

# Manually redo the commit - s/George/Gary in vim manuscript.md
# check the unstaged change then check in
git diff
git add manuscript.md

# see https://git-scm.com/docs/git-commit-tree
GIT_COMMITTER_DATE="Fri May 31 17:09:41 2019 +1000" GIT_AUTHOR_DATE="Fri May 31 17:09:41 2019 +1000" GIT_COMMITTER_NAME="Justin Hopkins" GIT_COMMITTER_EMAIL="[email protected]" GIT_AUTHOR_NAME="Justin Hopkins" GIT_AUTHOR_EMAIL="[email protected]" git commit -m "L - Gary"
# Compare the changes
git log --pretty=fuller -n 1 > LF1.txt
diff LF1.txt LF.txt

git-masterclass-activity-2's People

Contributors

darrenfrenkel avatar lomaxontherun avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.