git command learning
1), CD: Change the directory
2), CD .. Roll back to a directory of the previous level, direct CD into the default directory
3), PWD: Display the current directory path
4), LS: List all the files in the current directory
5), touch: New a file such as Touch Index.js will create a new index.js file in the current directory.
6), RM: Delete a file, RM Index.js will delete the index.js file
7), mkdir: New a directory is to create a new folder
8), RM -R: Delete a folder, RM -R SRC Delete SRC Directory
9), MV: Mobile file
10), REST Reinitializing Terminal / Cleanup
11), CLEAR clearing
12), History View Command History
13), Help Help
14), exit exits
15), # 标示 注释
Set user name and mailbox
The first thing you need to do after you install git is to set your user name and email address. This is very important because this information will be used each time GIT submission. It is always embedded in your submission:
$ git config --global user.name "zhuyu" # Name
$ git config --global user.email "email@example.com" # 邮箱
Git Basic Theory (Core)
Git local work area: Working Directory, Stage / INDEX, Repository or Git Directory. If you add a remote repository, you can be divided into four work areas.
Workspace: Workspace, place where you usually store code
index / Stage: Temporary area, used to temporarily store your changes, in fact it is just a file, saving will be submitted to the file list information.
Repository: Warehouse area (or local warehouse) is safely stored in the location of the data, which is submitted to all versions of data. Head points to the latest version of the warehouse.
Remote: Remote warehouse, managed server, can simply think that a computer in your project group is used for remote data exchange.
git project construction
Mainly remember the following commands:
Local warehouse construction
There are two ways to create a local warehouse: one is to create a new warehouse and the other is a cloning remote warehouse.
1 To create a new warehouse, you need the root directory of the GIT management project:
# Create a new GIT code base with the current with the directory
$ git init
Initialized empty Git repository in F:/Git/GitCode/.git/
Cloning Remote Warehouse
1, another way is to clon the remote directory, which is a complete image of the warehouse on the remote server to the local!
# Clone a project and its entire code history (version information)
$ git clone [url]
git file operation
File 4 states
Version control is to control the version of the file, to modify, submit, etc., first to know what the file is currently in, or may submit the file that is still not intended to be submitted, or to submit the documents to submit.
1) Untracked: Not tracked, this file is in the folder, but does not join the Git library, do not participate in the version control, passgit addThe state changesstaged
2) Unmodify: File has been invested, not modified, the file snapshot content in the release library is exactly the same, this file has two places, if it is modified,ModifiedIf usedgit rmMove the version of the library,UntrackedDocument.
3)Modified: File has been modified, just modifications, there is no other operation, this file has two goals, throughgit addCan enter a temporary storagestagedState, usegit checkedIf you discard the modified, return tounmodifyState, thisgit checkoutTake the file from the library, override the current modification.
4)Staged: Temporary status, executiongit commitThe modification synchronizes to the library, and the files in the library and the local files become consistent, the file isUnmodifyState, executiongit reset HEAD filenameCancellation, file status isModified.
View file status
The above statement has 4 states, and the status of the file can be viewed by the following command:
# View the specified file status
git status [filename]
# View all file status
# git add. Add all files to the temporary area
# git commit -m "Message Content" Submit the contents of the temporary area to the local warehouse -M submission information
Ignore the file
Sometimes we don’t want to include some files into version control, such as database files, temporary files, design files, etc.
# 注 注
*.txt # ignore all .txt files ending files, so that upload will not be selected!
!lib.txt # l.. T t 外
/temp # Only ignore the TODO file under the root directory, do not include other directories TEMP
bulid/ # ignore all files in the bulid / directory
doc/*.txt # ignore doc / notes.txt but does not include Doc / Server / Arch.txt
Take the code cloud
github is a wall, slower, in China, we generally use Gitee, sometimes it will build your own Gitlab server