Version control is essential for programmers who want to collaborate effectively and track changes when working on code in a team. Git is a version...
For further actions, you may consider blocking this person and/or reporting abuse
Mastering these basic commands is a great start for anyone looking to get started with version control using Git. Thank you so much Thomas for collecting all these commands in one post!
You're welcome! I'm glad that the information was helpful.
One thing that might come in handy with
git checkout
is the ability to checkout or restore an individual file from another branch (usually main, but could be something else). For instance, if you make changes to a file that break the code and can't see an easy way to revise it, you can simply checkout the file frommain
and restore it to the original:This will overwrite the current branch's file with the, hopefully working, file from the
main
branch.Thanks for sharing.
git rebase
is another useful one to know for rewriting history.Definitely - interactive rebases (
-i
) are also great for squashing multiple commits and/or changing the commit messageIt's helpful. Thanks for sharing.
Goes along especially well with
git commit --fixup=<SHA>
, when you work on multiple changes at once but want to keep each commit small, representing a single consistent logical change. Keep in mind a risk of introducing a dependency on a future change, tho.git stash pop
Is a must, it take back the stashes changes, thank you good postThanks for sharing.
i use git stash apply instead because i dont want to lose the stash
Humnn, good approach
Thank you for sharing this valuable article. Version control is an essential tool for software development and working with source code, and understanding how to use the various Git commands is a great way to become a proficient version control user. We hope you found the article useful in your journey towards becoming an expert in version control!
Glad you liked it.
There are some hidden risks with 1. git config
I have made detailed article on it:
dev.to/codeofrelevancy/the-hidden-...
BTW, thanks for sharing the article on git commands in details.
Glad you liked it.
git stash save "message"
andgit stash apply stash{id}
are some good commands.Thank you Milan, for sharing these useful commands.
this is useful for all beginners or advanced users, however the title is not precise. It will not make you a 'PRO', but capable. I think the 'PRO' features are a lot more advanced and complex and they are not mentioned here (eg. atlassian.com/git/tutorials/advanc... )
I'm glad the information was beneficial to you. To be honest, the title was a bit misleading, my aim was to attract Git enthusiasts to read the article and either learn a new command or share their own knowledge with others.
Good collection for beginners thanks. I would add fetch and switch as recommendations for git beginners
You're welcome 😊.
To check the log of the commits, an other useful command is
git log --graph
- it will display the graph view of the branches and the merges.Try this
git lg
alias in the[alias]
section of~/.gitconfig
for a narrower, more informative graph (tweak colors to your liking).git la
is a variant that also adds initial 8 characters commit author's name.Good guide, all basic commands with simplest parameters, but imho this make developer beginner of git, not professional. So, subject is misleading.
Great article for absolute beginner as well for others.
Thanks.
The only new command I see here is fsck. Will check it out. Other than that, I think these are commands a regular dev uses on a daily basis. Thanks for putting them together.
Thank you for sharing such useful information...
Thanks for sharing,
rebase
is also a very helpful command.Just use lazygit
Thank you for the article. Is it not recommended to use git switch instead of git checkout?
The advantage of using
git switch
overgit checkout
when switching branches is that it provides more safety checks and clearer error messages, making it easier to use for some users. However, if you're already familiar withgit checkout
and feel comfortable using it, there's no compelling reason to switch to usinggit switch
.Pretty cool, thanks for sharing this cheatsheet 👍
Glad you liked it.
Great summary of the most important commands. Thanks!
You're welcome! I'm glad I could help.
Helpful
Thanks, El-Hussain
Didn't know the git fsck command, cool!!
Thanks, Alexis.
Helpful
Thank you, Lotfi.
Thanks for the post .it Helped me to understand some git commands .
Glad you liked it!
I am new with this, this post help me alot. thx!
I'm glad to hear that!
Thanks for making this effort for the community. I'll take note of it and use it right away. Keep up the good work.
Glad you liked it.
Great post !
I will add
git add -p
With that one you can check all your modifications one by one and review all your working directory modifications before adding them to the staging area of your futur commit
Thanks for sharing.
Thank you for the positive feedback! I'm glad to hear that the post was helpful in your learning journey with Git. If you have any further questions or need clarification on anything, feel free to ask!
Very useful
Thanks.
(please source your content)
If google hadn't suggested such a "valuable" article to me,
I wouldn't have known that I've been a pro since 2016.
I haven’t had the time (or at least I haven’t made any) to fully understand git. This is extremely helpful. Thanks!