When creating a Git alias that points to a function, sometimes Git provides the wrong tab completion by default (e.g. filename completion instead of branch name completion). This is how we can tell Git, which type of completion to use.
Git
git reset vs revert
Conceptually, “git reset” is erasing your last change while “git revert” is adding a new change that undoes your previous change.
Remove newline at end of text file
Sometimes when I’m working with files in Git, I find myself with a change in a file that says “No newline at end of file”. This occurs when my editor adds the missing newline at the end of the file. While you should have a newline at the end of the file, you may have a reason for not wanting to add this change. In that case, you can remove the newline from the end of the file.
Git Alias Open Pull Request on GitHub
I want to be able to type “git open-github-pr” and have my browser open to the GitHub URL to create a Pull Request (PR) for my current branch on the current project I’m working on. Here is how I built this.
Your edited hunk does not apply
When using git add -p and faced with a hunk that can not be split sufficiently for your purposes, you can use the e option (manually edit the current hunk). Unfortunately, after manually editing the current hunk it is common to get the message “Your edited hunk does not apply.” I’ve found there are some things I can do to avoid this failure.
Git Merge Commit with Blocks
We can’t do a fast-forward merge when the most recent commit on the receiving branch does not appear in the branch we are merging in. One of our options in this situation is to create a merge commit when we merge in our branch.
Should I add .env to .gitignore?
The short answer is, “yes”. You should use your .gitignore file to ignore the .env file.
.gitignore Hidden Files with Exceptions
In most operating systems by default, files that start with a period (.) are hidden. When setting up my .gitignore file, I like to ignore all these hidden files (with a few exceptions).
Starter .gitignore file
This is my general starter .gitignore file for projects. I have a separate .gitignore for WordPress websites.
git add -p
By using “git add -p”, I can include some of my current changes in my commit (without including all of my changes).