1. Initialize git user information

git config --global user.name "xxx"
git config --global user.email "[email protected]"Git config --list git config user.nameCopy the code

2. Example

git cloneGit init // initialize git remote add Origin http://127.0.0.1/demo-fed/awesome-frontend.git Git fetch origin master: git fetch origin master: Git branch dev // create the local branch git checkout dev // switch the local branch git push origin dev Git branch --set-upstream -- to=origin/dev dev Git branch -d dev // Delete the local dev branch git branch -d dev // Forcibly delete the local dev branch git push origin --delete dev // delete the remote branch git branch -m oldName newName // rename the local branch git stash // Git stash drop drop git stash list check the stash stack git stash pop check git stash Apply stash@{1} // Take out the specific stashCopy the code

3. Submit logs

Feat Add Fix Fix Perf Optimize Refactor Reconstruct chore Style Docs document build deployCopy the code

4. Submit documents

Git add. // Add all files to the cache"."Git commit -m"Feat: submit"Git add missed-file // missed-file git commit --amend --no-edit --no-edit Only one git commit on Git -- amend-m"Fix: Modify the commit log"Git reset --soft HEAD^ undo the commit operation but keep the add operation git push to the associated remote branchCopy the code

5. Delete files

Git rm -r SRC /pages git commit -mRefactor: "delete"// Commit the code to the local repository. Note that the commit log is pushed in double quotes to the associated remote branchCopy the code

6. Merge branches

Git checkout master SRC /pages/ / merge the master branch to the current branchCopy the code

7. View branches

Git branch -r git branch -r git branch -v git diff master git remote -v // View the current remote versionCopy the code

8. View logs

git log --help// Run the git command to query logslog// check the branch's commit log gitlog-- pretty=oneline // Check the version number of the commit record gitlog--oneline --graph --decorate git //log--oneline --before={3. Weeks.ago} --after={2010-04-18} --no-merges// Specify a time period to hide merge commitCopy the code

9. Roll back the version

Git reset --hard HEAD^ git reset --hard HEAD^ git reset --hard HEAD^ Git reset --hard version number git reset --soft version number git reset --soft version numberCopy the code

10. Undo the operation

// Undo the before and after commit andhistoryGit revert HEAD commit Git revert HEAD commit Git reflog Git revert HEAD Revert COMMIT // Undo is also saved as a commit.Copy the code

11. Automate deployment

git checkout master
git pull
npm run build
git add deploy
git commit -m "Build: @deploy Automatic deployment"
git push
Copy the code

12. Release

Git flow release start 0.1.0npm run build:dev git pull origin develop --rebase Git flow release finish 0.1.0 fromCopy the code