Use the git
Git user global naming
git config --global user.name "XXXXX"
git config --global user.email "[email protected]"
Copy the code
Push knows who submitted the information
Create a repository locally
git bash here
mkdir filename
cd filename
pwd
Copy the code
Initialize a Git Repository
Git init ls -ah #Copy the code
Create a file
touch readme.txt
vi readme.txt
Copy the code
Git add File commits the file to the staging area
Git add can be used multiple times to add multiple files
Git commit -m “prompt” commits the file to the repository
Git status Displays the status of the repository
Git diff Displays file modification information
Git log Displays historical commit logs
git log –pretty=oneline
The first string is the commit ID (version number)
Git back
In Git, HEAD means the previous version of the current version, HEAD^ the previous version, HEAD^^ the 100 version EHAD~100
Roll back Git to the previous version
git reset --hard HEAD^
Copy the code
Git reset –hard (commit ID) Git reset –hard (commit ID
Git reflog records each command
Git diff HEAD — readme.txt Check the differences between workspace and latest version of repository
git checkout –readme.txt
Undo all readme. TXT changes in the workspace in two cases:
-
The readme.txt file has not been placed in the staging area and is back to the same state as the version library
-
Readme.txt has been placed in the staging area and modified. Now undo it and return to the state after it was added to the staging area
Rm Deleting a file
Git staus to view the deleted files
-
Git commit -m “commit”
-
Git checkout — test.txt
Remote warehouse
ssh-keygen -t rsa -C "[email protected]" Copy the code
SSH folder id_rsa.pub file in the user directory on drive C.
On Github, click “Settings” on the top right
Add SSH
Create a warehouse
Click on Github
git remote add origin [email protected]: user name/repository name git
Push all contents of the local repository to the remote repository git push
git push -u origin master Copy the code
Commit by using git push origin master
Git remote -v
Then delete git remote rm Origin based on the name
The deletion removes the local and remote binding
Clone from a remote repository
Click on Github
Git clone [email protected]: username/repository name.gitCopy the code
Branch management