1. Command
git checkout -b branch name //Create a branch and switch to this branch
git checkout branch name //Switch to this branch
git merge branch name //Merge the branch to the current branch
git branch -d branch name //Delete the branch
git branch -D branch name //Force delete the branch
git log|head //Latest record
git log --pretty=oneline //List all commit records in list form
git reset //Undo the operations after git add and before git commit
2. .gitignore file
*.js //Ignore all .js files
/*.js //Only ignore the .js files under the root
3. Brief explanation of commands
In the git submission process, there are three parts: working tree, index file, commit
Among these three parts:
working tree: It is the directory where you are working. Whenever you make changes in the code, the status of the working tree changes.
Index file: It is an index file. It is a bridge connecting the working tree and commit. Whenever we use the git-add command to register, the content of the index file changes. At this time, the index file is synchronized with the working tree.
Commit: It is the final stage. Only after commit can our code actually enter the git warehouse. We use git-commit to submit the contents of the index file to commit.
①git diff
git diff: checks the difference between working tree and index file.
git diff --cached: checks the difference between index file and commit.
git diff HEAD: View the difference between working tree and commit.
git diff filename: View the difference between a specific file and the previous version.
$ git diff ectemplates_class.<span>php diff </span>--git a/<span>public</span>/ectemplates/ectemplates_class.php b/<span>public</span>/ectemplates/<span>ectem index db83579</span>..8fe8090 100644 --- a/<span>public</span>/ectemplates/ectemplates_class.<span>php </span>+++ b/<span>public</span>/ectemplates/ectemplates_class.<span>php @@ </span>-420,7 +420,8 @@ <span>class</span><span> Ectemplates { </span><span>if</span> (<span>$this</span>->isdbo == 1<span>) { </span><span>return</span> <span>$out</span><span>; } </span>- <span>$prostr</span> = "14&]W97)E9\"!B>2!%4U!#35,`"<span>; </span>+ <span>//</span><span>$prostr = "14&]W97)E9\"!B>2!%4U!#35,`";</span> + <span>$prostr</span> = ''<span>; </span><span>$outtitle</span> = <span>convert_uudecode</span>(<span>$prostr</span><span>); </span><span>if</span> (!<span>empty</span>(<span>$this</span>->codesoftdb) &&<span> admin_FROM) { </span><span>$key_array</span> = <span>explode</span>('/', <span>$this</span>-><span>codesoftdb); (</span><span>END</span>)
The above has introduced the git command practice, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.