1. Git workspace
The three major areas of Git are the workspace , the cache and the remote warehouse
. For example, when we execute the [vscode] terminal, it is in the workspace. When the commit command is executed, it is submitted to the cache, and finally git push is the Submitted to the remote repository.
2. Important orders
3. In addition, there is a way to select the file to submit without using a command.
Take vscode as an example:
① For example, if I modify a code, there will be a blue circle 1 on the right, and the appearance of this blue circle 1 means that you have changed a place.
② Click the + sign to tell the browser to select this file, as shown below
③ Then use the git [commit] -m ‘submitted content’ command, it will be submitted to the cache area
④ Then run the git push command and it will be submitted to the remote warehouse
, which is equivalent to less execution of the git add command.
4. Other commands
Add the specified file to the staging area:
git add [file1] [file2] ...
Add the specified directory to the staging area, including subdirectories:
git add [dir]
Add all files in the current directory to the staging area:
git add .
When we need to delete the file in the staging area or branch, and the work area does not need this file, we can use
git rm file_path
When we need to delete the file in the staging area or branch, but it needs to be used locally, at this time, the file on the push side will not be there. If it is re-added before push, it will still exist.
git rm --cached file_path
Add the file name directly to restore the file from the temporary storage area to the workspace. If the file already exists in the workspace, it will be overwritten
Adding [branch name] + file name means that the branch name is written from the branch name Pull the file and overwrite the file in the workspace