Introduction: Git allows you to version your code so you can go back to a version at any time
First go to the directory you want to operate on: the CD path
Git init with git init, you will find that a.git directory is generated.
Git add git add git add git add git add git add Submit files for all changes
3,. Gitignore. Gitignore is used to describe which files do not need to change the usage method: create a. Gitignore file, write to the file you do not want to commit, it is ok
Git commit -m this operation can commit all the changed files
Jumping around from version to version
Use the following command:git reset --hard xxxxxx
(The six characters can be viewed using git log or git reflog.)
Scenario: Suppose I commit twice. I am currently in the second commit version and want to return to the first commit version. What should I do?
Let’s put it into practice:
I wrote the code in commit.html and submitted it to passgit log
You can look at the submitted information
Now modify the file contents again and commit:
Now we want to go back to the first version and use the first 6 bits of character 29fd33 of the first version of git log.
Command as follows:git reset --hard 29fd33
Through this command back to the first version, is there a kind of royal sword flying feeling
Git log and Git reflogGit reflog can view all commits
git branch
Git branch creates a branch based on the current commit.Git branch Specifies the branch name
Create branch A commandgit branch a
, and through thegit barnch
The current branch is in master git checkoutUsage:Git checkout Branch to switch to
Switch the branch to a:git checkout a
Git checkout -b
This command creates a new branch and switches to a new branch, switch to branch D and switch to branch D:git checkout -b d
Git branch -d Specifies the branch name
This command is used to delete branch d:git branch -d d