This article is not about how the team uses GIT content for the time being, but how to use git from a personal point of view.
Conventions
The green 5-bit character represents the submitted ID, which is indicated by <commit>, pointing to the parent node, respectively. Branches are displayed in orange, pointing to specific commits. The identity on which the current branch is attached. This image shows the last 5 commits, which are the latest submissions. The branch points to this commit, and the other branch points to the grandfather commit node.
Git cat-file
Git cat-file-t <commit>, look at the types of Git objects, the main git objects include tree,commit,parent, and blobs, and so on.
git cat-file-p <commit> View the contents of a Git object
git log
Git log is used primarily to display records that commit changes in the branch. When a git commit is executed to store a snapshot, the file details, the submission message and the submitter's information, and the snapshot on which the submission is based are saved.
git log--oneline, you can display a shorter commit ID.
git log--graph, showing when information such as branching and merging has occurred.
git log--pretty=raw, which displays the parent property of the Commit object.
git config
Git config-e
Git config-e--global
Git config-e--system
Git's three profiles are the repository-level profile (/.git/config), the global profile (under the user's home directory), and the system-level configuration file (/etc directory). The purpose of this command is to open the appropriate configuration file and edit it. The configuration file at the repository level has the highest priority, followed by the global profile, and the lowest system-level profile. The git configuration file is in the INI file format.
git config <section>.<key> Read and change the contents of the INI configuration file.
git config <section>.<key> <value> modify the key value of a configuration in the INI configuration file
Add a new user to the global space
git config--global user.name "Harvey Liu"
git config--global user.email [email protected]
To set the alias for a git command
git config--global alias.ci commit
git config--global alias.co checkout
Delete a user name from a git global configuration file
git config--unset--global user.name
git config--unset--global user.email
git grep
git grep can be used to search the contents of a file in the workspace
To find content in a particular version of the Git repository, we can add the tag name (tag reference) to the end of the command line as follows, git grep ' text content ' v1.0
Git diff
Git diff, showing the differences between workspaces and staging area
Git diff head, showing the difference between the workspace and head
Git diff--cached, showing the difference between staging area and head
git diff id1 Id2, showing the difference between two commits
git status
Git status, view the status of your code in the cache with the current working directory
Git status-s, output the results in a short form
git add
Git add, you need to add them to the staging area before committing your modified files. If the file is newly created, you can do this by adding the file to the staging area
git Add. , Git will recursively add all the files in the directory where you executed the command, so if you use the current working directory as a parameter, it will track all the files there.
Git add-u, which uses the-u parameter to invoke the git add command, marks the tracked files that have changed locally (including deletions and modifications) to staging area.
Git add-a, using the-a parameter will add all changed tracked and non-tracked files.
Git add-i, add in an interactive way.
Git commit
git commit--amend, Patch commit.
Git commit--a commits all locally changed files, including locally modified and deleted files, but does not include files that are not tracked by the repository. But this command is best not to be used, which will throw away the greatest benefit of Git staging area to the user: the ability to control the content submitted
Git commit--allow-empty, allowing blank commits to be performed
git reset
Point the current branch to another location, and have the selected changes working directory and index
git reset--hard <commit>, where commit is optional, can use a reference or commit ID, if omitted is equivalent to using Head's point as the commit ID, the completed operation includes replacing the reference point, replacing the staging area, replacing the workspace
git reset--soft <commit>, where commit is optional, can use a reference or commit ID, and if omitted is equivalent to using Head's point as the commit ID. The main things to do are to change the point of reference, without changing the staging area and workspace
Git reset, which is the same as git reset head, resets the staging area with the directory tree that the head points to
git reset-filename, the file filename changes to withdraw staging area, staging area other files unchanged
git reset HEAD--filename equivalent to git reset--filename
Git branch
Git branch, showing the current branch
Git branch <branchname>, create a new branch Branchname
Git branch <branchname> <start-point>, based on submit <start-point> Create new branch, the branch name of the new branch is <branchname >
Git branch-d <branchname>, delete a branch named Branchname, delete will check if all the deleted branches have been merged into other branches, otherwise deny delete
Git branch-d <branchname>, Force delete branch <branchname>
git branch-m <oldbranch> <newbranch>, renaming branches
Git checkout
Git checkout branchname, will change head head pointer, mainly for switching branches
Git checkout-b branchname to create a new branch and switch to the new branch that you created
git checkout--filename, using the filename file in staging area to overwrite the filename file in the workspace
git checkout <commit>--filename, overwriting files in staging area and workspace with files in the specified submission
Git checkout--. or git checkout., overwriting local files directly with all files of staging area, canceling all local modifications, is a dangerous operation
Git clean
Delete Local redundant directories and files
Git clean-nd, which shows what to delete, but is pre-deleted
Git clean-fd, forcing the removal of redundant files and directories
git rm
The RM command deletes files that have been deleted locally and have not been added to staging area, that is, deleted directly from the workspace, with no effect on staging area and the repository.
The git RM command adds the delete action to the staging area, which is a commit action that performs a file delete in the real sense.
Git MV
Git mv, move files, git with git rm and git add two commands instead.
Git archive
Git archive, file the corresponding directory tree for any submission.
Git archive-o latest.zip HEAD, creating archive files based on the latest submissions Latest.zip
git archive-o partial.tar HEAD src doc, only the directory SRC and Doc are built into the archive file Partial.tar
Git Archive--format=tar--prefix=1.0/v1.0 | Gzip > foo-1.0.tar.gz, build an archive based on Milestone v1.0, and add directory prefixes to files in Archive 1.0
git clone
git clone <repository> <directory>, create a clone into the directory directory of the repository that repository points to. Directory directories are equivalent to the workspace of the cloned repository, the files are checked out, and the repository is in the. git directory under the workspace.
git clone--bare <repository> <directory.git>
git clone--mirror <repository> <directory.git>
Neither version of the above contains workspaces, which are directly the contents of the repository, which is known as the bare repository.
git push
git push <remote> [branch] will push your [branch] branch to the [branch] branch on the far end of [alias], and the URL address of the remote version number to be pushed by Remote.<remote> Pushurl is given, if not configured, uses the URL address of the Remote.<remote>.url configuration.
Git pull
Git pull, which downloads data from the remote server for simultaneous updates. The URL address of the remote repository to get is provided by Remote.<remote>.url.
git commands in a detailed