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 […]
By default the output of ‘git log’ is not nearly as useful as it could be. By creating a new command ‘git lg’ that uses some of the options available to ‘git log’, we create a much more useful command.
While working with a client recently, I found that deploying to WP Engine with Git had stopped working. The Symptom The following appeared on the command line when I ran git push production remote: – warning: syntax Error Found in wp-content/vendor/composer/autoload_static.php … remote: – failed: we detected a PHP syntax failure. The Problem The file […]
One can rename a file with git mv however, if you try to use this technique to change the case of the filename it will fail and you’ll get fatal: destination exists. I prefer to keep all my filenames lowercase, so getting this to work is important to me. If I modified the filename case […]