Git provides flexibility, allowing you to create workflows that suit your needs and preferences. However, there are best practices and caveats to be aware of.
Push to only bare repositories
Keep either file in merge conflicts
Sometimes when resolving a merge conflict, you may want to keep one file instead of the other. You don’t need to open up the files and fix potentially hundreds of conflicts
Squashing commits with rebase
The git rebase command offers powerful options in its –interactive mode, commonly abbreviated as -i. One of the most popular features is the ability to squash commits
ZSH git status
While it’s great to have Git status shown in your bash prompt, it’s not your only option. Z Shell (zsh) is another popular command-line interface used by many programmers
Bend logs to your will
The git log command is incredibly powerful, offering a multitude of options to help you understand what work has been done in your repositories and who has done it.
Piecemeal staging
This article is a follow-up to the comments from yesterday’s discussion about interactive adding. Many readers were eager to learn more about the powerful git add -p command, which is a shortcut to the patch mode
Restoring lost commits
So, you just executed git reset –hard HEAD^ and discarded your last commit. But now you realize you really needed those changes.
Fixing broken commit messages
You just committed that awesome feature, test, or bug fix, but something isn’t quite right. Maybe some information is missing, the commit message is incorrect, or something else is off.
Ignoring doesn’t remove a file
One common source of confusion among Git beginners is the misconception that adding a file to the .gitignore file will erase it from the repository’s history.
Push and delete remote branches
Pushing and deleting remote branches are common actions that many Git users need to perform regularly. However, some users may forget how to do so or simply not know the process.