Roll back git historical versions and delete historical commit records in AS

When you want to delete the code after a certain version, roll back to the specified version. You can use the following method.

1. Open the git history commit window in AS

2. Select the version option that needs to be rolled back, and right-click to pop up the menu. Select Reset Current Branch to Here...

3. Select the Hard option

soft: Applies the merged changes to the current branch, but does not commit the merged changes. This means you need to perform a manual commit operation to commit the merged changes.

mixed: This is the default merge strategy. It applies the merged changes to the current branch and adds the merged changes to the staging area. You need to perform a manual commit operation to commit the merged changes.

 hard: Applies the merged changes to the current branch and resets all changes in the working directory and staging area to the state of the merged branch. This means you will lose uncommitted changes on the current branch.

 merge: Applies the merged changes to the current branch and automatically creates a new merge commit. This is a non-fast-forward merge, which preserves the merge history. 

keep: If there is a conflict, the conflicting files will be kept and the conflict will not be automatically resolved. This allows you to manually resolve conflicts before committing the merged changes.

4. Confirm that the local code hard header has been rolled back to the version that needs to be rolled back.

 5. Submit using the command line Terminal window of the AS project

You can use any of the following:

1. Enter the command ( xxx branch to be rolled back

git push origin xxx --force

As shown below:

2.  Enter the command (  forced recommendation)

git push -f 

As shown below:

6. Log in to gitlab and find that the branch has been rolled back successfully.

Guess you like

Origin blog.csdn.net/hzqit520/article/details/132447009
Recommended