How to undo everything in Git, how to undo after git commit

Updated on technology 2024-03-26
7 answers
  1. Anonymous users2024-02-07

    1. Open the git terminal window, switch the directory, and then git init performs an initialization action.

    2. git status, you can check how many files can be added to the hold area.

    3. git add -a, at this time change the state to changes to be committed.

    4、git commit -m ""This is the time to add comments and clean up the workspace.

    5. git log: Check the commit record. There are two submissions here. Make a note of the log number.

    6. git reset --soft, so that you can undo the commit just now, check the status to verify.

  2. Anonymous users2024-02-06

    How do I cancel git if it has already committed? Fallback!

    There are three ways to fall back, as follows:

    The git reset --soft fallback version will overwrite the source of the commit, keeping the source of the index file and working tree. This is available for modifying the upload information.

    git reset --mixed git reset without any arguments, which is used by default. The rollback version will overwrite the source of the commit and index file, leaving only the source of the working tree.

    The git reset --hard fallback version will overwrite the source of the commit, index file, and working tree. (Hazardous Operations).

    Depending on what you want, you should do a soft fallback by running git reset --soft.

  3. Anonymous users2024-02-05

    git checkout head^

    Before switching to multiple versions:

    git checkout head n * n is the number of fallback versions *

  4. Anonymous users2024-02-04

    For example, suppose that the current gas branch has the following 4 commits

    Let's say you want to delete the note is 222 and the commit is bb0d81806a0c1b05c for this commit.

    1. View the commit record.

    2. Find this submissionA previous commit commit

    3. Run the following command:

    4. Pop-up box. vim precedes the line bb0d81806a0c1b05cpickInsteaddropand follow the prompts to save your exit.

    5. At this point, the specified commit has been deleted, and you can use the git log to view it.

    6 If you want to push a branch after rebase to a remote repository, git will prevent you from doing so because the two branches contain conflicts. But you can pass in a force tag to force a push.

  5. Anonymous users2024-02-03

    In Git, there are several scenarios for discarding file changes (i.e., undoing file changes):

    The detailed principles and usage of each scheme are as follows:

    The restore command is primarily used to restore file changes in the Workspace and Staging Area; So, it's a command designed to drop file changes;

    Here's how to use it:

    Syntax:

    Example:

    The checkout command is mainly used to check out a specified branch; However, it can also be used to check out a specified file, and we can use this feature to discard file changes;

    Check out the specified file to the version of the specified commit;

    Syntax:

    Example:

    The reset command resets a commit with head, and its target is the commit history; However, this command has the ability to place the reset changes (i.e., the changes discarded after the reset) in the Staging Area or Workspace, or to discard and reset the Temporary Area or Workspace at the end of the operation. With this feature, we can achieve the effect of discarding file changes;

    Reset the current head to the current head, that is, do not change the position of the head, and choose to reset the Staging Area or Workspace to the state of the head as needed;

    Example:

  6. Anonymous users2024-02-02

    Original file:

    First, let's take a look at the repository status:

    We make this modification:

    Only amd 。Check the status again:

    At this point, we modify the file again and check the status:

    After committing, in the query status, it is found that there are changes on the branch, indicating that the second change is not committed:

    That is to say: modify->add->modify->commit can only commit changes that have already been added.

    To save the second change, you need to add and then commit again.

    (use "git checkout --to discard changes in working directory)

    Namely:git checkout -- changes to the workspace can be discarded

    The git checkout command is to undo all the changes in the workspace, and there are two ways to do this

    In short,Return the file to the state it was in the last git commit or git add to the file

    The -- in the git checkout --command is very important, and without it, it becomes a command to "switch branches".

    At this point, we looked at the content of the file, and sure enough, we went back to the content before the modification.

    What if you want to undo the changes after git add after the changes are made?

    Okay, let's try it: first modify the file, then execute the command.

    Happily, we see the phrase:

    (use "git reset head ..to unstage)

    So let's do it:

    Let's check the status:

    The workspace has been modified and the staging area has been cleaned. So how do you undo a job and get a change?

    git checkout

    In git,Deletion is also modification。Here's how we can do it:

    You have two options:

    Remember:The git checkout command replaces the workspace version with the version in the repository, regardless of whether the workspace is modified or deleted.

  7. Anonymous users2024-02-01

    For git-managed files, we have made changes to the files, because there are many modifications, how can we undo the changes to the files more quickly? The following is divided into different situations, and the modification of the disguise sales documents is removed. The following figure shows how to undo the modification

    history: the file that has been submitted;

    stage(index): files in the staging area;

    working directory: files in the workspace;

    The case1 file has been modified, but I regret it, I don't want this change, and I want to go back to the original neutralization form, you can run git checkout to undo the change, but try not to use this command. Because the execution of this command means that the modified content has been completely deleted, to prevent regret of revoking the previous modification to the file, we can execute git stash enter, put the file in the trash, when you want to retrieve it, you can also retrieve it directly, the retrieval instruction is: git stash apply enter.

    case2: To undo the modification of the staging area file, you need to perform two steps:

    1.For example, move files out of the staging area git reset head2 git checkout –

    case3 undo the change from the committed state before it is sold, and run git reset hard + commit number, for example: git reset hard 589924weq.

Related questions
16 answers2024-03-26

If you cultivate well, will you still think about those filthy things? If your heart is pure, and you understand the truth, will you still be deceived by false appearances? >>>More

12 answers2024-03-26

It's a bit difficult to organize your computer and install all the software. The easy way to do this is to set up a user and password. Setting a password can be completely eliminated. >>>More

9 answers2024-03-26

Enter n! directly in the place of the formulaYes.

Enter with shift+1, I don't know if that's what you mean. >>>More

6 answers2024-03-26

Click at the end of the portrait to set the insertion point at that location, and then"files"--"Page Setup"to set the paper type to landscape and apply it to the selection"After the insertion point", the document has just been automatically sectioned, and the new page is landscape. After a few pages, change to vertical version and operate as above. >>>More

19 answers2024-03-26

Start by formatting the cell or range where you need to enter a fraction. >>>More