Skip to content

Instantly share code, notes, and snippets.

@yar
Last active August 29, 2015 13:58
Show Gist options
  • Save yar/10023078 to your computer and use it in GitHub Desktop.
Save yar/10023078 to your computer and use it in GitHub Desktop.
Simple GIT usage for tracking changes in an important local file

Simple GIT usage for tracking changes in an important local file

Preparation (just once)

  • Install homebrew: http://brew.sh

  • Update homebrew. For that, in terminal, run:

brew update
  • Install git via homebrew:
brew install git

Alternatively, if homebrew is causing a difficulty, install git directly, as suggested at http://rogerdudler.github.io/git-guide/.

  • Install Gitx, a visual tool helping with git: http://gitx.frim.nl

  • Create a working directory, move the working files into it. Switch to that directory in terminal:

mkdir my-project
mv my-file.txt my-project/
cd my-project
  • Initialise a new git repository in that directory:
git init

Git has created a hidden subdirectory my-project/.git where its data files will live. Remember to not delete it accidentally.

The preparation is finished. Now all that follows is the eternal cycle of making changes.

Recording ongoing changes

  • Switch to the working directory, run gitx:
cd my-project
gitx
  • You are in the history tree view, good for reviewing, well, history. Change to the commit-making view by pressing Cmd-2. You can always return to history by pressing Cmd-1.

  • In commit-making view, use the interface to "stage" the changes. Stage all changes in a file by double-clicking the filename, or stage only some edited fragments if you like. Review the modifications. You can unstage a change too.

  • When happy with the edit, write a commit message (comment) and click "Commit". The message need to exist, but you can make it as short as you like.

More information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment