Roll back the specified version

  • Git log — Pretty =oneline displays each commit on a single line, which is useful when browsing through a large number of commits

  • Git reset –hard commitId

  • Git reflog Check the operation records

  • Git log -p displays the submitted content

Merge branches into Release

  • Pull release locally
  • Release: Git pull Origin Branch to merge
  • Git push Origin release

Changing the branch name

  • git branch -m oldName newName

A merges local branch B

  • git merge B

Example Delete remote branch A

  • git push origin :A

Stash operation

  • Git Stash pop Restores the latest progress to the workspace. Git reverts all changes to the workspace and staging area by default.
  • Git Stash pop –index restores the latest progress to the workspace and staging area. (Try to restore the original staging changes to the staging area)

The difference lies in that the latter still restores the content originally stored in the temporary storage area to the temporary storage area

  • Git stash pop Stash @{1} Restores the specified progress to the workspace.
  • git stash save ‘message… ‘You can add some comments

Revocation of the commit

  • Git reset HEAD^ is the same as git reset –mixed HEAD^, do not delete the workspace change code, undo commit, and undo git add. operation

  • — Soft does not delete workspace change code, revoke commit, and do not undo Git add.

  • –hard Delete workspace change code, commit, and git add.

  • Git Stash part file

Git Stash -p is an interactive command that allows you to traverse file by file. Whenever we need a stash file, we’ll do Y. Whenever we don’t need a stash file and we need a commit file, we’ll do N. If we don’t need a Stash file next, we’ll just exit q.

Modify the commit

git commit –amend

Termination of merger

git merge –abort

Merge logs (merge multiple commits)

Git merges multiple commit requests with git commit requests. 1) Prepare to merge the following three items

Git rebase -i HEAD~n git rebase -i HEAD~n git rebase -i HEAD~n git rebase -i HEAD~n

Select commit, squash, squash, squash, squash, squash, squash Squash Select commit and :wq to save the configuration

B. Merge and exit

C. Git log

Remote and local branch deletion synchronization

  • Git branch -a is used to view all branches, including local and remote branches. Git remote show origin

The remote branch is removed, but the local branch remains, for example, after the bugfix/tag-style branch is removedgit remote show originTo view:

You can use Git Remote Prune Origin to remove the branch. (that is, you can refresh the local repository to keep these changes in sync with the remote repository.

Common misoperation

There are two branches, A and B, which are simultaneously developed and need to be tested in A test environment before development, so both of them need to be combined into release.

Now A was merged into release first, and then B should have merged into Release, but B misoperated, merged release into B branch, and then B branch found the code of A branch, so it deleted the code of A branch from B branch, and then merged B branch into Release again. After the test, branch B is online first, and the status of branch A changes to merged at =====.

This is my own handwriting duck, before reprinting the first point to give an encouragement ha ~~~