When using Git, sometimes (often) I find myself forgetting to delete local branches after merging them. This command deletes this branches (and I’ve included a Git alias to make it easy to use in the future).
I see lots of people get themselves into trouble when using git cherry-pick. By removing the commit from the source branch after cherry-picking, I’ve been able to avoid many of these problems.
At some point when pushing your code to a remote server (e.g. GitHub, Bitbucket, GitLab) you’re going to see an error that says, “failed to push some refs” and “Updates were rejected because the tip of your current branch is behind its remote counterpart”. This occurs when someone else pushes code to the remote server that you don’t have. Don’t panic, we can fix this.
There are lots of ways to target a git commit and one way that I often forget to use (but really like it when I remember) is targeting a specific git commit by the commit message.
This tweet blew my mind. $ git log | vim -R –Now press <K> on a commit hash. — Luke Diamand (@LukeDiamand) February 21, 2018 I spend a lot of my time in Vim and Git and this is an amazing combination of the two. While I love this command, I think we can do […]
When I’m working on a project using Git, I’m good about deleting local branches that I don’t need anymore. However, I often forget about my remote branches after they are merged. While it is convenient that most of the Git hosting I use makes it easy to show only unmerged branches, this also makes it […]
When I first started contributing to projects on GitHub, I had a difficult time with keeping my work and the original project in sync. Eventually, I found a way that works for me. Step 1: Fork the Repository I do this with the GitHub fork button. As an example, if I wanted to contribute to […]
Originally when I started using Git with my WordPress projects, I checked in all the files (WordPress core, plugins, themes, and even uploads). Over time I’ve found that to be less than ideal. My preferred .gitignore file appears below and it ignores everything by default. This allows me to whitelist only those plugins and themes […]
Historically, when trying to track down a bug in my code I spent a lot of time trying to determine exactly where the bug appears in the code. On all of my projects I use Git for version control. Knowing exactly which commit introduced the bug helps me track down the bug. Git bisect is […]
I use Git a lot and by default git log is not very helpful. Git log has a lot of optional parameters, which can make the output much more useful. Examples Default Git Log Improved Git Log Using a combination of command line parameters, the git log output becomes beautiful and infinitely more useful. git […]