Git common process commands

git clone 'http://www.url' // Download the repository code locally
git branch -a // View all branchesGit checkout -b Local branch Remote branch// The remote branch downloads code to the local branch
git pull
git add . || git add -A
git commit -m 'commitMsg'
git push
Copy the code

Scenario 1: Restoring git Deletion by mistake

If you have executed git add or git statch
git log  // Find the record where you submitted the codeGit reset Specifies the version// Roll back to the deleted version ID
git status // Find the deleted record that contains the deleted file and other related informationGit Checkout removes files or folders// Restore the deleted file
Copy the code

Scenario 2: A pull conflict

git add . // Add the locally modified content
git statch save 'Temporary mark' // Store local changes
git pull // Update remote code to local
git stash pop stash@{0} // Restore the cached code
// Then resolve the conflict and commit the code.
Copy the code

Scenario 3: Merge branches

To merge the dev branch into the master branch, do the following

1First switch to git checkout master branch2Git pull Origin master (git pull Origin master3Git merge dev (git merge dev4, and then check the status and execute the commit command git status5Git push Origin masterCopy the code

Other Common Commands

git config -e // Check the git configuration file that contains the source address of the current project
git --amend -m 'msg' // Modify the last commit MSG
git stash list // You can view git's staging code
Copy the code