Have you ever been stucked while using git🤔? If your answer is yes, This article is for you. You dont need to memorize all of git command. Here is a cheat sheet that will simply your life.
What is Git?
Git is a free, open-source version control software. It was created by Linus Torvalds in 2005.
Therefore, Git is essentially a content tracker. Git can therefore be used to store content; however, due to its other features, it is primarily used to store code.
GIT CHEAT SHEET
Initialze a local repository:
git init <directory>
Set configuration value for your usernmae and email:
git config --global user.name <your name>
git config --global user.email <your email>
Clone a repository:
git clone <repository-url>
Add a file to the staging area:
git add <file>
Add all files changes to the staging area:
git add .
Check the unstaged changes:
git diff
Commit the staged changes:
git commit -m "Your Message"
Add changes made to track files and commit:
git commit -a -m "Your Message"
Reset staging area from last commit:
git reset <file>
Check the status of the working directory:
git status
Remove a file from the index and working directory
git rm <file>
List the commit history:
git log
To display branches:
git branch
To create a branch:
git branch <branch name>
To switch to a branch:
git checkout <branch name>
To delete a branch:
git branch -d <branch name>
To merge a branch:
git merge <branch name>
Pull changes from a remote repository:
git pull <remote name>
Push changes to a remote repository:
git push <remote name>
Conclusion
Git is used for source code management. It is a free and open-source version control system used to handle small to very large projects efficiently. Git is used to tracking changes in the source code, enabling multiple developers to work together on non-linear development.
I hope you found this article helpful in understanding Git command. Follow me here on Dev or Twitter for more updates 😊
Top comments (5)
Well done Adeola 🎉
Thank you
Thanks for the summary. It's good to have on hand. 👌
Well done Adeola, this was quite impactful
Thank you