1.Three main sections of Git: the git directory, the working directory, and the staging area.
Git directory: where git stores the metadata and object database (most important).
Working directory: a single checkout of one version of the project. Pulled out of the Git database and plcaed on disk for use or modify.
Staging area:A simple file contained in the Git directory which stores information about what will ao into your next commit.
2.State of files: untracked -> unmodified -> modified -> staged -> commited
3.Three git config files: /etc/git config(git config --system); ~/.gitconfig(git config --global); .git/config.
4.Check git settings: git config --list.
5.Initializing a Repository: git init; git clone git://....(url).
6.Check the state of git: git status.
7.Tracking files: Git will not track new files automatically until you asked to do so. To begin tracking files, run this: git add file.
8.Staging files: run git add. If you modify a file after run git add, you have to run git add again to stage the latest version of the file.
9.Ignore files: Setting up a .gitignore file if you don't want some filed commited in Git repository.
Rule of patterns for .gitignore:
- Blank lines or lines starting whith # are ignored.
- Standard glob patterns work.
- End patterns with a forward slash (/) to specif a directory.
- Negate a pattern by starting it with an exclamation point (!).
10.To see what you've changed but not staged, type git diff. To see what you've staged that will go into your next commit,type git diff --staged.
11.Commit files:git coomit -m "message". Skipping the staging Area to commit: git -a -m "message".
12.Rmoving files: git rm command remove file from staging area and working directory, then commit. If simply remove the file from working directory, it shows up under the "Changed but not updated" and then you should commit again.
13.Moving files: git mv file_from file_to is equivalent to mv file_from file_to, git rm file_from, git add file_to.
14:Viewing the Commit History: git log. gitk.
15.Undo Things:
- Change Last Commit: git commit --amend which overwrites previous commit.
- Unstaging a Staged file:git reset HEAD file.
- Unmodifying a Modified File:git checkout -- file.
16.Working whith Remotes:see remotes:git remote -v.
17.Adding Remote Repositories: git remote add [short name] [url].
18.Fetching and Pulling from Remotes: git fetch/pull [remote-name], git push [remote-name] [branch name].
19.Removing and Renaming Remotes: git remote rename [original] [new]. git remote rm [remote-name].
20.Git Aliases: git config --global alias.[alias] 'original comment'. eg.git config --global alias.unstage 'reset HEAD --'