Skip to content

Latest commit

 

History

History
50 lines (33 loc) · 1.27 KB

16_helpful_git_commands.md

File metadata and controls

50 lines (33 loc) · 1.27 KB

Helpful Git commands

In this section, we will explore some helpful Git commands.

Moving and renaming files with Git

  1. Create a new branch named slow-down.

  2. On line 9 of the index.html file, change the background URL to images/texture.jpg.

  3. On line 78, change the timing for the game to speed it up or slow it down.

  4. Save your changes.

  5. See what git is tracking:

    git status
  6. Create a new, empty directory:

    mkdir images
  7. Move the texture file into the directory with git:

    git mv texture.jpg images/texture.jpg

Staging hunks of changes

Crafting atomic commits is an important part of creating a readable and informative history of the project.

  1. See what git is tracking:

    git status
  2. Move some parts of some files to the staging area with the --patch flag:

    git add -p
  3. Stage the hunk related to the image move: y

  4. Leave the hunk related to the speed change in the working area: n

?> Wondering what all of those other options are for the hunks? Use ? to see a list of options above the hunk.

git config --global alias.cm "!git add -A && git commit -m" could be helpful here. Check out the appendix to see how!