![]() ![]() ![]() Let's look at a simple example and say you have just performed a "reset". With all of the most important actions nicely protocoled, the Reflog is the perfect safety net when you've done something horrible. Git takes note of this in this special journal. This means that every time you commit, merge, cherry-pick, rebase, reset. In a nutshell, the Reflog is Git's "diary" where it protocols all of the HEAD pointer movements that happened in your local repository. Using the Reflog to Save Your NeckĪlthough it can be tremendously helpful, the "Reflog" is a rather little-known feature in Git. In case you'd like to make any modifications to your alias at a later time, you'll find it in your global Git config (in ~/.gitconfig). Now, your status output will be much more concise when you enter your new "git st" command: $ git st The way to achieve this is by creating a custom alias like this: $ git config -global alias.st "status -short -branch" No changes added to commit (use "git add" and/or "git commit -a")ĭon't get me wrong: this is great for beginners! But once you're a bit more experienced with Git, a leaner output could be nice. ![]() " to discard changes in working directory) (use "git pull" to update your local branch) Your branch is behind 'origin/main' by 1 commit, and can be fast-forwarded. The default output of "git status" contains quite a bit of stuffing: $ git status # To undo all of the local changes in your working copy (be careful!). # To unstage a file, but leave its actual changes untouched. Here's an overview of the most important use cases with "git restore": # To undo your local changes in a certain file. If you wanted to undo local changes, you had to use some form of "git checkout" or "git reset" - until recently! Another relatively new command is "git restore" that was made for exactly this purpose (in contrast to "checkout" and "reset", which have plenty of other jobs). Very handy, as said, to go back and forth between two branches! Undoing Local Changes with "git restore" With the dash character as its only parameter, "git switch" will check out the branch that was previously active. If you often have to switch back and forth between two branches, the following shortcut might come in handy for you: $ git switch. Since it's quite a new member of the Git command family, you'll have to make sure your Git installation is up to date in order to use "git switch". But unlike the "checkout" command, "switch" doesn't have 1,000 other responsibilities. Its usage is, as you can see, very simple and similar to how you would use "git checkout". Noticing that "git checkout" has so many different jobs and meanings, the Git community recently published a new command to lighten its workload: the "git switch" command allows you to. In order to go beyond this "little bit", I'd like to show you seven short commands which you might not know - and which might help you become more productive and proficient with Git! Using "git switch" Instead of "git checkout" Almost every software developer today knows at least a little bit about Git. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |