We'll take a look at how to use "git revert" in the next video. This is great, but what if you make a change and then make multiple commits before you realize that that change broke something? "git reset" isn't helpful, because you want to keep all of the changes since the bad commit. Now, "git status" shows a clean working directory, and "git log -oneline" confirms that we are back to the "Installed Views 3.8" commit. Now, you'll see that "HEAD is now at 269bec4 Installed Views 3.8", so our repo is back to the way it was before we updated Views. If, at this point, you realize that the 3.10 version of Views caused an issue and you'd like to reset those commits and associated files so that it'll be as though you never installed the update, you can do that by specifying the commit you would like to reset to. Now, "git status" shows a clean working directory, and "git log -oneline" shows the two commits. Also, just as a quick reminder, git reset -hard will move the HEAD pointer back to the commit hash that was given, the Stage Index and the Working Directory will be reset back to the way they were at that commit, and all commits after the commit that was given will be dropped from the commit history.git commit -m "Added missing Views 3.10 file".Now a "git status" show us that we missed the unstaged file. The most significant difference between git revert and git reset is that the git revert command targets a specific commit not removing all the coming commits. I'll start out by updating Views to 3.10 and committing it. Now, we'll take a look at using the "git reset -hard" command, and passing a hash to reset multiple commits including associated files. Resetting Multiple Commits and Associated Files Now "git status" shows that we have a clean working directory and "git log -oneline" shows that we are at the "Installed Views 3.8" commit. rm -rf sites/all/modules/contrib/views/modules/field/views_handler_filter_field_list_boolean.inc.So, now, just like I did then, I'll delete the untracked file with the rm command. git-checkout hash sets the working tree to the given hash and unless hash is a branch name, youll end up with a detached head. Now, you'll see that "HEAD is now at 269bec4 Installed Views 3.8", so we're still at the same commit, and "git status" will show us that the only files not committed are the untracked files, just like when we ran "git checkout sites/all/modules/contrib/views" to checkout the entire views directory in the earlier video. git-reset hash sets the branch reference to the given hash, and optionally checks it out, with-hard. If you'd like to reset your uncommitted changes back to the last commit, you can use "git reset -hard" to do so. The files you have from the latest checkout remain in your working-tree. Reseting Staged Files to the Latest Committed State Using git reset means youre using git reset -mixed (-mixed is the default), so Git is copying the files from the specified commit into its staging area.The first way I'll show you to use the "git reset -hard" command imitates the way we used "git checkout" in the video Reverting to the Committed Versions of Files where we checked out the entire views directory.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |