Branch A series of commits representing development on one set of functionality in parallel with other sets of functionalities.

Commit An isolated change to source code.

FETCH_HEAD A reference to .git/FETCH_HEAD, a file in which references and the object names of fetched references are stored during a git fetch.

git checkout . Undo all unstaged changes in the current folder.

git checkout <file> Undo changes to a tracked, unstaged file.

git cherry-pick Apply the changes introduced by some existing commits.

git clean -f Remove all untracked files.

git clone <ssh-path> <destination> Clone a repository into a new directory.

git config —global alias.<alias> <command> Define a new alias on the fly.

git diff-index Compares content and mode of blobs between the index and repository.

git fetch <remote> <branch> Fetches the code but does not merge it into your working directory.

git init —bare Initialize a bare repository.

git merge Join two or more development histories together.

git pull <remote> <branch> Fetches the code and merges it into your working directory.

git push <remote> <branch> Push local branch into remote branch with the same name.

git push <remote> :<remotebranch> Delete branch from remote repositiory.

git rebase Take the patch of the change that was introduced in one commit and reapplying it on top of another commit.

git reflog Log of commit and HEAD references on the current branch.

git reset Reset current HEAD to the specified state.

git revert <commit> Revert an existing commit.

git rev-list List commit objects in reverse chronological order.

git rev-parse <branch> Return SHA of last commit on branch.

git show Show information about an object.

git stash Record the current state of the working directory and the index, and go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.

HEAD Pointer to the current branch.

Index The virtual staging area where the user places files that are to be committed.

Remote Git repository on another server.

Repository A place where large amounts of source code are kept, either publicly or privately.

tracking branch A local branch that has a direct relationship to a remote branch.

Working Directory The directory in which one is currently doing work.

Facts, Thoughts and Opinions

Commiting files to git, best practice

  1. git status # Confirm that the stage doesn't contain files that you don't want to commit.
  2. git add <file> # Add the files to the stage.
  3. git diff -b —cached # Show the changes that are staged. Confirm that these differences, and only these differences, are what you want to put in the current commit.
  4. git commit

Git Commit and Merge Master

git checkout master
git pull
git checkout -
git merge master

git newbranch

Creates a branch, checks it out, and pushes it to the git server in one command.

!f(){ git branch $1 && git checkout $1 && git push -u origin $1; };f

git pull

git pull <remote> <branch> = git fetch <remote> <branch>; git merge FETCH_HEAD;

Git: Rebase versus merge

Git rebase followed by git merge with fast-forward produces the same result as a git merge. The difference is a cleaner history. If you examine the log of a rebased branch, it looks like a linear history: it appears that all the work happened in series, even when it originally happened in parallel.


Git Data Transport Commands