

This is where the reset command comes in. This usually isn't a big deal if you haven't committed yet, but if you have made multiple commits it can be hard to exactly remove all changes. Sometimes you make changes and realize that you need to scrap everything you have done so far.
#GIT RESET ALL LOCAL CHANGES CODE#
This is amazing at narrowing down your bug search since some bugs can be really hard to track down without knowing what code was changed to cause it. You keep repeating this process of typing either good or bad until eventually you are able to narrow it down to the exact commit that caused the bug. If the bug is not present then you can type git bisect good and Git will select the commit that is halfway between this good commit and the last bad commit. If the bug is present you just type git bisect bad and it will select the commit that is halfway between this bad commit and the last good commit. Git reset allows you to move the HEAD to a previous commit, undoing the changes between your starting state and specified commit. You can then test to see if the bug is in this commit or not. Now after you run these three commands Git will choose the commit in the middle of these two commits and grab all the code from that commit. In our example we know that in commit 48c86d6 there is no bug.

Reverting files via TortoiseGit Commit dialog. The final command tells Git which commit is known to not have this bug. Select File > Source Control > Reset from the TestComplete main menu. If you leave this blank, as we have, Git will just use the latest commit. The second command tells Git which commit is the bad commit with the bug. To start a bisect you need to run three commands. To explain this further here is an example of creating an alias for git commit -a -m "Message" The following command resets the Git repositorys branch one commit backward. By prefixing our command with an exclamation point Git will not assume we are running one simple command. Option 1: Discard All of the Recent Commits Changes. The reason for this is that a Git alias by default assumes that you will be calling one single git command, but we want to run a command that is more complex than a single Git command. This is just our normal Git command, but we have prefixed the command with an exclamation point.
#GIT RESET ALL LOCAL CHANGES FULL#
This says we want to create an alias called ac.įinally, the last part is the full command !git add - A & git commit -m. This just says we are modifying our global Git config since we want this alias to be available in any Git repository. The first part of the command is git config -global. The code looks a bit confusing, but the result is that I can now run git ac "Message" and it will do the full add and commit for me. With this simple line we are modifying our global Git config and adding an alias called ac which will run the command git add -A & git commit -m. Git config -global alias.ac '!git add -A & git commit -m'
