crospin.blogg.se

Git discard local changes
Git discard local changes







git discard local changes

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.

git discard local changes

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. Time Travel in Your Project: Undo Changes with Git









Git discard local changes