Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 2 Making Simple Commits Sign in on the attendance sheet! credit: https://xkcd.com/1296/

Similar presentations


Presentation on theme: "Lecture 2 Making Simple Commits Sign in on the attendance sheet! credit: https://xkcd.com/1296/"— Presentation transcript:

1 Lecture 2 Making Simple Commits Sign in on the attendance sheet! credit: https://xkcd.com/1296/

2 Review of Last Lecture Alt Text: If that doesn't fix it, git.txt contains the phone number of a friend of mine who understands git. Just wait through a few minutes of 'It's really pretty simple, just think of branches as...' and eventually you'll learn the commands that will fix everything.

3 Review of Last Lecture What is a commit? - A snapshot of all the files in a project at a particular time. When we compare commits, it is often more helpful to consider the changes made between two commits – i.e. the commits’ diff.

4 Review of Last Lecture git init – creates a git repo in the current directory git clone – copies the remote git repo into the current directory git log [ --oneline ] – lists all commits in the git repo, starting with the most recent one git help, git --help, man git – brings up the man help page for the git command

5 Leftover topics from last lecture The.git folder

6 Every git repository has a.git directory in the toplevel project directory This is where all git commit objects and metadata are stored Don’t delete it! Doing so deletes the repository

7 The Simple Git Commit Workflow 1.Inside the working directory, edit your project’s files as needed. 2.Add files with changes you’d like to commit to the staging area. 3.Commit the snapshot of files in the staging area. Edit-Add-Commit

8 git add Example use: git add scavhunt.c0 puzzle.c0 Updates a file (or files) in the staging area with the version in the working directory.

9 git commit Example use: git commit (or) git commit –m “commit message goes here” Creates a commit out of a snapshot of the staging area, and updates HEAD.

10 Aside: commit HEAD The “most recent commit” has a special name: HEAD

11 git status Example use: git status Shows files differing between the staging area and the working directory (i.e. unstaged changes), the staging area and HEAD (i.e. changes ready to commit), and untracked files

12 Example – initial state

13 Example – after autogen.ml edit

14 Example – after magic.rs edit

15 Example – after `git add magic.rs`

16 Example – after making commit (HEAD contains magic.rs (v6), Makefile (v5), autogen.ml (v5))

17 Example – after `git add autogen.ml` (HEAD contains magic.rs (v6), Makefile (v5), autogen.ml (v5))

18 Example – after a second git commit (HEAD~1 contains magic.rs (v6), Makefile (v5), autogen.ml (v5), HEAD contains magic.rs (v6), Makefile (v5), autogen.ml (v6))

19 Good commit messages Good: Build: Don't install jsdom3 on Node.js 0.10 & 0.12 by default Bad: bugfix lol get rekt https://whatthecommit.com

20 git diff Example use: (show unstaged changes) git diff (show staged changes) git diff --cached Shows unstaged changes or staged changes

21 .gitignore List of files and directories that git should ignore Store in toplevel project directory


Download ppt "Lecture 2 Making Simple Commits Sign in on the attendance sheet! credit: https://xkcd.com/1296/"

Similar presentations


Ads by Google