![]() So if I'm hopping between two branches, this saves a lot of typing. The - refers to the last branch I had checked out. You can get some really lovely output with the -pretty option, but this is almost always good enough for me since it provides a quick list of recent commits without too much extra info. I find that git log takes up too much space, so most of the time I use this when I want to see what's been going on recently. ![]() The "3" above can be replaced with any positive integer, depending on how many commits I want to work with. My local commit messages are often notes to myself, like "tests passing but need to refactor database queries" or "created model and migration, do routes next." To get my work ready for a pull request, I do an interactive rebase to combine commits, reorder commits, and rewrite my commit messages so they are in line with project standards and useful for other developers. I commit a lot while I'm working but like to leave a clean history before I open a pull request. It won't automatically catch untracked files, so if I've added anything brand new, I'll run git add -N. It helps me catch typos, errant debugging statements, or other mistakes. ![]() I use this almost exclusively when staging since I like to review my changes before I commit them. ![]() If you, like me, pretty much always want to see things this way, you can make this setting your default by opening your git config file with $ git config -global -edit and adding this: Īfter that, git branch will always show your most recently used branches at the top. zshrc.This lists branches in order of recent activity instead of alphabetically. zshrc, or save it in its own file and source that file in your. You can paste this code directly into your. (If I make any changes to the code in the future, the most up-to-date version will always be available in my. Here’s the code for the prompt, as of this writing. This solution works great for my needs, but if you’d prefer a zsh Git prompt that can keep repositories up to date on its own, check out sindresorhus/pure. I use this prompt in combination with the excellent sickill/git-dude Git commit notifier, which automatically keeps repositories of your choosing up to date, and which will periodically trigger appropriate “commits behind” counts in the prompt when working with those repositories. While creating this updated version of my Git prompt, I looked into implementing it using zsh’s built-in vcs-info mechanism, but attempting to use it only made the code more complicated and cumbersome, so I decided against it. Here’s a contrived example that demonstrates how the prompt works (click on it for a larger version):
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |