Both HEAD^ and HEAD~ can be used in Git to refer to previous commits but in different ways.
By default Vim is the editor used when writing a Git commit message. While I love Vim, it does work very differently than most other editors. A good option for those who are not comfortable with Vim, is to use a different editor. This is how to setup Git to use a different editor.
The interactive rebase feature of Git is one of my favorites. I love being able to squash multiple commits into one commit or re-order my commits for clarity. My one complaint is the Git interactive rebase commit order is wrong (at least for the way my brain works).
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 […]