Terminology
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 -b <name> ¶ Create a new local branch and make it the current branch.
git checkout <file> ¶ Undo changes to a tracked, unstaged file.
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 rev-list ¶ List commit objects in reverse chronological order.
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.
Remote ¶ Git repository on another server.
Repository ¶ A place where large amounts of source code are kept, either publicly or privately.
Working Directory ¶ The directory in which one is currently doing work.
Facts, Thoughts and Opinions
Commiting files to git, best practice
- git status # Confirm that the stage doesn't contain files that you don't want to commit.
- git add <file> # Add the files to the stage.
- 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.
- 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.
Images
- Subtopics
- git branch
- git checkout
- git commit
- git diff
- git grep
- git log
- git merge
- git push
- git reset
- git stash
- git tag
- Practical Git
- Writings
Sources & Bookmarks