![]() To be able to travel back and forth in time, we need a way to know where we are. Touch page3.txt & echo "Content for page3" > page3.txt git add page3.txt git commit -m "create page3" Checking Git History Touch page2.txt & echo "Content for page2" > page2.txt git add page2.txt git commit -m "create page2" Let's add a few more files with separate commits so we can have more commits to work with. ![]() ![]() Now, we have a repo set up with one file added and one commit in the git history. Mkdir git-undo & cd git-undo git init touch page1.txt & echo "Let us put something here" > page1.txt git add page.txt git commit -m "create page1" Setting Things Upįrom my terminal, I'll run the following commands to create the repo folder, add some files and create some commits to work with: We'll be doing everything from the terminal, so get ready to do some typing. I advise you do the same so you can easily follow along. To make this post practical and relatable, I'll be creating a new git folder to use as a demo. We'll be taking advantage of this timeline to move back and forth as we please. As you know, Git stores snapshots of a repo at different points and then creates a timeline history. So, next time you think you've made a commit in error, you'll have no reason at all to panic. In this post, we'll explore ways to undo changes in Git. For example, maybe you're working on a new feature that isn't ready yet, and then you need to rollback to a previous commit. There are many other valid reasons you'd want to travel in time between different versions of a project. Lucky us! Undoing things in Git isn't just for mistakes. While life might not always present us with a chance to undo our mistakes, Git provides us ample opportunities to do just that. In life, undoing our mistakes is something we've always wished was possible. The SimpleChord class, based on TclOO (Tcl/Tk 8.6), is added in this commit.Time Travel in Your Project: Undo Changes with Git Since the checkout_index and delete_files calls are both asynchronous and could potentially complete in any order, a "chord" is used to coordinate unlocking the index and returning the UI to a usable state only after both operations are complete. Update Tcl/Tk dependency from 8.4 to 8.6 in git gui.sh.Ī new proc delete_files takes care of actually deleting the files in batches, using the Tcler's Wiki recommended approach for keeping the UI responsive. ![]() Migrate unlocking of the index out of _close_updateindex to a responsibility of the caller, to permit paths that don't directly unlock the index, and refactor the error handling added in d4e890e5 so that callers can make flow control decisions in the event of errors. If after deleting untracked files, the directory containing them becomes empty, then remove the directory as well. Prompt the user independently for untracked files, since the underlying action is fundamentally different ( rm -f). Update the revert_helper proc to check for untracked files as well as changes, and then handle changes to be reverted and untracked files with independent blocks of code. (Merged by Junio C Hamano - gitster - in commit fe47c9c, ) git-gui: revert untracked files by deleting them See commit fa38ab6, commit d9c6469, commit 29a9366 () by Jonathan Gilbert ( jpg0). See commit 39acfa3 () by Kazuhiro Kato ( kkato233). See commit 786f4d2 () by Zoli Szabó ( zoliszabo). Revert Change will work with untracked files too, with Git 2.25 and git-gui.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |