git remote branch and local branch fallback version

Source: http://www.jianshu.com/p/0b50e4a43cdf
Comment:
git code base rollback: refers to returning a branch of the code base to a previous commit id

[local code base rollback]:

git reset - -hard commit-id : roll back to commit-id, remove commits submitted after commit-id

git reset --hard HEAD~3: roll back the last 3 commits

[remote code base rollback]:

this is The important thing to say is that the process is more complicated than the local rollback.

Application scenario: After the automatic deployment system finds problems after the release, it needs to be rolled back to a commit, and then republished.

Principle: First, return the local branch to a commit and delete the remote branch. , and then push the local branch again.

Operation steps:

1. git checkout the_branch

2. git pull

3. git branch the_branch_backup //back up the current situation of this branch

4. git reset --hard the_commit_id //roll the_branch back to the_commit_id

5 locally , git push origin: the_branch //Delete the remote the_branch

6. git push origin the_branch //Re-establish the remote branch with the rolled back local branch

7. git push origin: the_branch_backup //If the previous ones are successful, delete this backup branch.

If you use gerrit as the remote code center repository and code review platform, you need to ensure that the user who operates git has the push permission of the branch, and chooses Force Push Option (there is this option in the push permission setting)

In addition, the gerrit central library is a bare library, and the HEAD is pointed to the master by default, so the master branch cannot be deleted. It is best not to choose the strategy of deleting the master branch, and use other branch. If you must do this, consider modifying the HEAD pointer on the gerrit server. . . It is not recommended to do this

Reference : https://review.typo3.org/Documentation/access-control.html#category_push

Author: Flying General
Link : http://www.jianshu.com/p/0b50e4a43cdf
Source: Jianshu
Copyright Owned by the author. For commercial reprints, please contact the author for authorization, and for non-commercial reprints, please indicate the source.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326450172&siteId=291194637