You can set Git to preview all of the changes in your commit when you write your commit message. I find this to be a big help in writing my commits (and reminds me to keep the changes in my commits small).
Git
git switch
Git version 2.23.0 is introduced a new command ‘git switch’. This command does a subset of what ‘git checkout’ does (because ‘git checkout’ does so many different things).
git restore
Git version 2.23.0 is introduced a new command ‘git switch’. This command does a subset of what ‘git checkout’ does (because ‘git checkout’ does so many different things).
Git Diff Ignore Mode Changes
When the permissions on a file change in a commit, Git will include this in the diff. Git refers to this as a mode change. When I’m looking at a “git diff” (or specifically a “git diff –name-only” where I’m looking for a list of files that have been changed), I often want to ignore mode changes (a.k.a. permission changes). By adding “-G.” to the command, mode changes will be ignored.
git warning: path is unmerged
Sometimes after running git stash pop, I get a conflict warning and I want to discard any changes to a file. However, when I try to checkout the file I get an error message. Using reset and then checkout, lets me accomplish this goal.
View Current Commit Message during Git Rebase Conflict
When I do a git rebase and I get a conflict, I can use git log to see all the commits rebased thus far. However, I often get confused about what the current (incomplete) commit is that caused the conflict. It would be super helpful if I could see the commit message of the current commit. This command allows you to view the current (incomplete) commit during a rebase.
Git Previous Branch
When working with Git on the command line, I spend a lot of time switching back and forth between two branches. Even with Git tab completion, it is a lot of typing. However Git has a shortcut for the previous branch, a single dash (-).
Get a File from Another Git Branch
I was working on one Git branch and I wanted a file from another branch. Using git checkout, we can do this.
How is git push force-with-lease aware of a commit
I’ve written about using “git push –force-with-lease” instead of git push –force” because “force-with-lease” will only force push changes if your local copy is aware of all of the commits on the remote branch but how is git “aware” of the commits.
Never use git push force
Never use git push –force. Seriously, don’t use it. You should always use –force-with-lease instead. We’ll look at the problem with –force and how –force-with-lease addresses the issue.