Overview
Concepts
- Changes & Status:
- a file can be tracked or untracked which indicates whether the file is recognized by git as part of the repository.
- a change includes added, deleted, modified at the minimum unit of lines.
- staging meaning that you're selectively picking untracked files or changes into bucket, and waiting for committing them.
- Commit: With staged changes, you're ready to generate a new snapshot, which is called commit.
- commits constructs a acyclic graph representing all revisions of your repository.
- you can rollback to one snapshot by
reset.
- Branching: a special form of commit that can represent a divergence of the commit graph.
- each branch is essentially a dynamic head commit of that divergence, it can traverse back to its start point to delineated the branch.
- branching is all about how to attach/detach a commit
- History & Reset
- inspect local history
reflogand commit historylog- each history is just a commit, tracked or wild, attached or detached
- use
bisectto binary search the commit introduced bad things. - revert changes of a commit by
git revert(with revert commit) - reset to commit with altered history
- inspect local history
- Synchronization: working with remotes and locals
- download remote branches by
fetch mergeorrebaseremote branches- use
pullas shortcut offetchplusmerge/rebase
- download remote branches by
Getting Help
git help <subcommand> is the builtin command to show man page of the specified subcommand on UNIX or opening documentation html page on Windows
For example, open documentation for git clone subcommand:
sh
git help clone1