A few important concepts
First, define several concepts:
WorkPlace: Work Area
Index: Staging Area
Repository: Local Warehouse/Repository
Remote: Repository
When cloning a project locally on a remote (such as GitHub) (assuming the project is named Gittest), you will see a directory named Gittest on the local directory with the Project code and a directory named . Git. What is a workspace, except for the . Git folder, we read, modify, and add delete code and other content mainly on the workspace, and this . Git directory is called a repository, and this repository has a lot of things to store, For example, there is a master branch that Git automatically creates for us a head pointer to that branch, where there is an area called Index, which is staging area, which steals a figure:
git commands in a detailed
Git init initializes the current directory to a repository that git can manage
git clone [url] downloads an item from the specified URL to the current directory, automatically turning it into a git repository
git config [--global] user.name "zhangsan" git config [--global] user.email "[Email protected]"
As the name implies, set a user name and mailbox, mainly used to display when the code is submitted, so that others can know that the code is submitted, but only in the current warehouse, if added----the global parameter will be displayed in all warehouses this user name and mailbox.
Git Add File: Add specified file to staging area
Git add-a: Add all the current workspace changes to staging area
Git commit-m "...": submits the contents of the staging area to the local repository, and the ellipsis content is best to make meaningful comments that are convenient for you and others to view later.
Git status View the status of the current warehouse, can clearly see which files have been modified, which files in the staging area and other information
git diff file name: If the file has been modified and has been added to staging area, we would like to see what the file has been modified, and you can use this command to see what has been changed.
Git log view the project's commit log, which contains a version number, the name and mailbox of the submitter, the date of submission, and comments added at the time of submission.
git reset--hard head^: Fallback to previous version, if using two ^ is fallback to the last version
git reset--hard 76786554: Fallback to the specified version according to the version number, the version number can be viewed through git log, the version number is very long, take the first few can
git checkout--a.txt: Undo changes to A.txt, there are two cases, 1 if the a.txt has been modified, but not committed to staging area, then A.txt will be revoked to the same state as the repository. 2 If A.txt has been added to staging area and has been modified, the a.txt will be revoked to the state you just added to the staging area.
git reset HEAD a.txt: If A.txt has been modified and added to staging area, but we want to recall it to the workspace, use this command
git rm a.txt: Removing a.txt from the repository
git push origin remote: Push the project of the local library to the remote library
Git branch: View Current Branch
Git branch-r: View Remote Branch
Git branch-a: View all Branches
GIT branch Develop: Create a branch named develop from the current section
git checkout Develop: Jump from the current branch to a branch named develop
Git checkout-b Develop: Creates a branch named develop from the current branch and jumps to that branch, which is equivalent to the simplification of the two commands above
Git merge Develop: Merge a branch named develop into the current branch
git branch-d Develop: Remove a branch named develop
Git commands have a lot of, more commonly used is these, after the encounter of any time to add it ~
A discussion of git--notes and Git commands