Four work areas
A Workspace is the Repository for the information you need to submit to a list of files in your Index/Stage. This is a temporary Repository for the information you need to submit to a list of files. The warehouse area (or version repository) is the safe place to store all the data that you have committed to all the versions. Remote: A server that hosts code. You can think of it simply as a computer in your project group that is used for Remote data exchange
Git workflow
1. Modify the file in the working directory. 2. To temporarily save the file, put the snapshot of the file into the temporary storage area. 3. Commit the update, locate the file in the staging area, and permanently store the snapshot in the Git repository directory
The file has four states
Untracked: Not tracked, the file is in a folder but not added to the Git library, not involved in version control. Unmodify: The file is stored unmodified, meaning that the contents of the snapshot of the file in the repository are exactly the same as in the folder. There are two places to go for this type of file, if it has been Modified. If you move the library using Git RM, it is an Untracked file Modified: The file was Modified, just Modified, and nothing else was done. This file also has two places to go: Git Add to get to the staged: staged state, or Git Checkout to get rid of the modified staged: staged state and return to the unmodify state. This Git Checkout will take the file out of the library and override the currently modified staged: staged state. When you do a Git Commit, you synchronize the changes to the repository, and then the files in the repository and the local files become the same again, and the files are in the Unmodify state. Git reset HEAD filename to cancel the temporary save and the file state is Modified
New File ->Untracked Add newly created file to staging area using add command ->Staged Submission zone file to local repository using commit command ->Unmodified if you modify the Unmodified file -> Modified If remove an Unmodified state file ->Untracked
Common commands
-
Initialize the
Git config --global user.email "[email protected] --global user.name "name" // Configure the user name
-
operation
Git add <file> // A → B git add <file> // A → B git add <file> B → C git commit --amend, *B → C git push origin master, C → D git pull D → A git fetch; D → C git log; D → A git fetch; D → C git log; # git diff: 'workspace' = 'workspace' = 'index' = 'index' = 'workspace' = 'workspace'; # git diff --cached: To see the difference between Index (Repositorty) and Local Repositorty (Repositorty). # git diff HEAD: You can see the difference between a workspace and a local repository. Git show git show git show git show git show git show git show
-
undo
Git reset <file>// C → B git reset <file>// C → B git reset <file>// C → B git reset --hard // "// To copy git checkout from an index to A workspace, it is not recommended that you use the" checkout "command (or" checkout ") to undo "git checkout". B → A git checkout -- files // from the index to the workspace Git revert = git revert = git revert = git revert = git revert
-
Branch operation
Git checkout -b branch_name Git branch -d (-d) branch branch_name = branch git branch -a Branch -vv // View, Git merge branch branch_name git merge branch branch_name git merge branch branch_name git branch branch branch Rebase // derivation, automatic linearization, D → A
Git rm -- r -- cache. // Remove files from version control, no effect on local files, then edit
Some dynamic figure