git delete branch and rollback

[git delete local branch]

git branch -D br

 

[git delete remote branch]

git push origin :br (with a space after origin)

 

Git code base rollback: refers to returning a branch of the code base to a previous commit id

[Local code base rollback]:

git log

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

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

 

[Remote code base rollback]:

This is the key point to say, the process is more complicated than local rollback

Application scenario: After the automatic deployment system is released, if problems are found, it needs to be rolled back to a certain commit and re-released

Principle: first return the local branch to a commit, delete the remote branch, and then re-push the local branch

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 locally

5. 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

 

【View branch】

git branch -a

 

[Create a local branch and push to remote]

git branch test

git push origin test

 

【tag】

git tag 2.5.5

git push origin 2.5.5

git push origin --tags all tags

git tag -d 2.5.5 delete local tag

git push origin --delete tag 2.5.5 delete remote tag

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327026410&siteId=291194637