What is Git? Why do you always face issues when trying your hand at Git commands? This blog tries to make it, make sense.
Not to be mistaken with GitHub, a host for software development and version control using Git.Git is the most popular modern version control system used by developers today.
Developed in 2005 by Linus Torvalds, Git is actually an actively maintained open source project. Why does that name ring a bell? Well, Torvalds is the creator of the well-known operating system kernel, Linux.
Hard to Git
Now, what would you say are the most common issues you face when using Git are?
- Clean local commits
- Undo local commits
- Remove a file from Git without removing from the file system
- Reverting pushed commits
- Avoid repeated merge conflicts
- Find a commit that broke something after a merge
I came across this helpful cheat sheet from a Slack channel which I've been meaning to print out and stick on the side of laptop until I memorize it. Also, if anybody knows the source of where it came from, please let me know:
A few commands not mentioned on the list are (not the greatest list in retrospect). Let's remake a personalized cheat sheet of what commands you would use often:
-
git status
: Displays the state of the working directory and the staging area -
git log
: Displays a record of the commits in a Git repository (add log # to list out specific log, press the "D" button to scroll down) -
git diff
: A multi-use Git command that when executed runs a diff function on Git data sources (add log # to access that specific log) - You can add
relative path just public
to the command for example, to locate a file or folder on a file system starting from the current directory - [
git stash
](https://www.atlassian.com/git/tutorials/saving-changes/git-stash#:~:text=git%20stash%20temporarily%20shelves%20(or,re%2Dapply%20them%20later%20on.): Temporarily shelves (or stashes) changes you've made to your working copy so you can work on something else
Check out other handy Git commands that we might not know of here.
Clearly, we all need a Git refresher course, and thanks to FreeCodeCamp this is comprehensive one.
Conclusion
As they say, the best way to get better at something is by practicing. Until then, I hope this can be a form of reference whenever you forget what Git command to use.
Latest comments (0)