![]() ![]() ![]() Now you have a clean working folder, allowing you to work on a different task and make a commit. Note that shelving only shelves things currently staged for commit, so if you’ve added new files, then do a hg add to make sure they are included in the shelveset. Or you can name your shelveset: hg shelve -name "some name" Or if you are using TortoiseHg, you can easily enable the extension in the settings dialog. To turn it on, you need the following lines in your mercurial.ini file (or to enable it in just a single repository, add them to. Mercurial doesn’t come with a stash command, but it does have an extension called shelve which does the same thing. ![]() It allows you to put some work in progress to the side and get back to a clean working directory, without needing to make an actual commit of half-finished code. The command git reflog is my Lord and savior, but git rebase -i is my fave because I like to rewrite history.One of the really nice features of git is the stash command. I also find it a helpful command as it allows me to reset my branch and go back in my repository history. Should it find a conflict, it forces Git to preserve the local value and ignore any incoming changes.Īs I find myself constantly having to abandon changes or needing to make sure my local branch is synced with the remote, I use git reset a lot. Git stash commands code#If you know you never want to override local values when doing a merge, the -Xours flag is a big-time saver, especially when used to sync code between mirrored repos. The theirs option within the recursive merge strategy incorporates changes from their side, as long as the changes don't conflict with what they are getting merged into. Specifically, I love merging development branches into the master branch with the following: $ git merge -strategy recursive -X theirs 3.17.x My real answer: git push because it reminds me of the song "Kick, Push" by Lupe Fiasco and also means, "I did the thing and all that remains is opening a PR." Also, I can quickly add just the relevant changes and then do away with any pseudocode or debugging nonsense that's leftover. My practical answer: git add -p because it allows me to have that extra review step before I commit my code. The first reason is I love git push is that it simply allows you to share your work-your code-with others! The second reason is that push -force is considered harmful and destructive, but I like to see it as a great power that comes with great responsibility. It is a great way to be able to noodle around with an idea. I love using git stash and having the ability to stash changes that I'm not sure about and being able to recall them later. Either way, I can always pop back from it and return to my work in progress. Maybe it's just a clean slate, a hiatus that might lead to nothing or something great. Sometimes, stash serves a higher purpose: The need to chase a divergent solution to something already solved. But it's not only about being distracted into more urgent matters. The git stash command allows me to get back to the initial state very quickly after I've applied changes to the projects I want to revert.Įasily git stash! I get derailed a lot into urgent matters (bug fixes) while coding a longer piece. Simple to use but incredibly effective.Īlso, if I create a script that tells me whether the current source is good or bad, then git bisect run figures everything out on its own!Īt work, I have to deal with customer projects in order to reproduce specific kinds of behavior. It helps identify the commit that introduced a bug by doing a binary search on commits. If it wasn't me, then it gives me a pointer to go and ask someone why they did it and why it had to be that way. It's usually something I did long ago, and I've forgotten why it had to be that way. I use git blame because invariably when I stare at code and ask, "who did this?!" the answer ends up being me. It's useful when there are merge conflicts, but there is an important change(s) you need for some reason. I can pull out the changes from a single commit and apply them to the branch I'm working on now. I use git cherry-pick if I have been working on a branch and want to only keep one or two commits. It's also nice if I want to quickly see which PHP, SCSS, or JavaScript files are being committed before I do one last PHPCS run-through. ![]() gitignore, and I'm unsure if I got the syntax correct. This one is great if I've recently adjusted my. I can't live without the git status command. It can also diff arbitrary files: $ git diff -word-diff file1 file2 One of the hidden gems of Git is its ability to do word-level diffs. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |