Skip to content

Instantly share code, notes, and snippets.

@lixit
Created November 21, 2019 07:42
Show Gist options
  • Save lixit/85560fcf9a9f12953129a818843b180b to your computer and use it in GitHub Desktop.
Save lixit/85560fcf9a9f12953129a818843b180b to your computer and use it in GitHub Desktop.
git config --global user.name "Your Name Comes Here"
git config --global user.email you@yourdomain.example.com

git log --graph

man git-log
git help log

git init
git add .
# This snapshot is now stored in a temporary staging area which Git calls the "index".
git commit

git diff
git add file1 file2 file3
git diff --cached
git status

git commit
git commit -a

git log
git log -p
git log --stat --summary

git branch experimental
git branch
git switch experimental

(edit file)
git commit -a
git switch master

(edit file)
git commit -a

# To merge the changes made in experimental into master
git merge experimental
git diff
git commit -a
gitk

# delete the experimental branch
git branch -d experimental
git branch -D crazy-idea

For collaboraion

bob$ git clone ./alice bob
bob$ cd bob
(edit files)
bob$ git commit -a

(edit files)
alice$ git commit -a
# merge the changes from Bob's "master" branch into Alice's current branch
# pull command: 1. fetch 2. merge
alice$ git pull ../bob master

# peek at what Bob did without merging first
alice$ git fetch ../bob master
alice$ git log -p HEAD..FETCH_HEAD

alice$ git remote add bob ../bob/
alice$ git fetch bob
alice$ git log -p master..bob/master
alice$ git merge bob/master

bob$ git pull
bob$ git config --get remote.origin.url
bob$ git config -l
bob$ git branch -r

Exploring History

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