Basic command operation of git

The download address of git: https://git-scm.com/download

After installing git

Right-click on the desktop to see two git shortcuts.

You need to configure git first, that is, you need to configure the user name and user mailbox

 

1. Open Git Bash
2. Set user information
git confifig --global user.name “zqy”
git confifig --global user.email “zqy @zqy.cn
View configuration information
git confifig --global user.name
git confifig --global user.email

 Then introduce the basic instructions of git, first create an empty folder, I created the test2 folder here

Enter the folder, right click to open the Git bash window

 1. Execute the command git init

The hidden folder .git appears, indicating that the downloaded git tool is fine. This step is to initialize the git warehouse.

 The status of the file existence is shown in the figure below

If it is a newly created file, it is in an untracked state, and if it is a modified file, it is called an unstaged state.

If the file is placed in the temporary storage area, it is called the temporary status.

 Let's first create a file

The command to create a file is consistent with the touch file name under the linux system

git status: View the status of commits.

git add: Modify one or more files to the temporary storage area, generally use git add to submit all files to the temporary storage area.

git commit: Submit the content in the temporary storage area to the local warehouse

Command form: git commit -m 'comment content'

git log: View commit log information

Command form: git log [option]
options
--all show all branches
--pretty=oneline display commit message as one line
--abbrev-commit makes the output commitId shorter
--graph is displayed in the form of a graph
Here you can view the submission information in detail, but the command is long, so you can write a configuration file for aliasing
1. Open the user directory and create a .bashrc file
Some windows systems do not allow users to create files starting with dots. You can open gitBash and execute touch ~/.bashrc
2. Enter the following content in the .bashrc file :
#Used to output git commit log
alias git-log='git log --pretty=oneline --all --graph --abbrev-commit'
#Used to output all files and basic information of the current directory
alias ll='ls -al'
3. Open gitBash and execute source ~/.bashrc
Then you can use the git-log command to view detailed information

You can then modify the contents of the file by executing

1.git add .

2.git commit -m "file01change"

View submission status

Role: version switching
Command form: git reset --hard commitID
The commitID can be viewed using the git - log or git log command

 

 

Guess you like

Origin blog.csdn.net/qq_45526401/article/details/127524128