Hey there!
Some days ago I published about Patterns for writing better git commit messages, it's just the entry point to this discussion.
I know Git
offers a lot of functionalities who can help in our day to day if we know how to use it and that's the purpose of this discussion.
Let's improve our knowledge about Git and how to use the best from Git.
Fell free to share your thoughts on the comments, it will be nice to discuss about.
Top comments (24)
Hey, I'm very interested in this topic. I use a general template for commit messages that Linus himself suggested
Single problem is that when I'm doing let's say multiple commits on a feature, for the first commit I use the template(that i have set up as default) and for the other commits i use -m messages
When the feature is ready for Pull Request, basically i do an interactive rebase for the specific feature where I squash all the commits into a single one and use message template
After that I force a push on the feature branch and rewrite all the commits into a single one for a specific feature branch
Here is the message template:
Awesome! Have you tried the "Squash and Merge" option at GitHub PR?
Also, this is a very well detailed template!
I think this is good for big changes as
git
itself doesn't have the concept of Pull Request and Linus receive the patches via email. For me, I prefer maintain the commits minimal and simple, describing each commit what I've done so far. Something like:The leged to it is:
type
: feat, refactor, style, chore, fix...scope
: not necessary but can give a little information about itshort description
: describe in 50 letters or less if that commit is applied, what it'll dolong description
: describe architectural choices, options, usage of code, why you pick your approach and things like thatreference
: can be tickets, issues or external references to JIRA or other softwaresThis is what works for me! 😄
Totally agree, using the template I showed can be a real pain sometimes but after the feature is finished and all commits are squashed into a single one with the complex message it makes it easier over the year to keep track of the work on the project.
Thank you very much for your template, I want to take yours and add some details from the one I use for future reference
I agree with Ilê for minor tasks I like to do in the same way as he talked.
Personally, I think this more complete template can be applied to huge projects or more specificaly features.
I've used git for years, and I've still not managed to get my head around when to use rebase (and use it correctly) and when just to merge from a more primary branch. I always seem to screw stuff up with rebase, but merge can mean a lot of headaches with conflicts at times.
I know "rebase" causes a lot of misunderstanding for a lot of people and I already have this problems to start using this powerful feature sometimes ago.
I'm thinking to create a simple guide in practice about "rebase" and "cherry-pick" do you think it's will be helpful?
If it's something which even a small number of people have a problem with, it shows that existing documentation/examples/guides are not covering the topic well enough. If you can create a guide which breaks down the concepts and reasons to use it in a way people get the message and can use it properly, then it's absolutely worth it.
I'd certainly read it.
I will think in a more practical way to apply these concepts and share them with the community.
Thanks for your feedback!
IMHO the biggest issue with git is way too large repos and people who are using git wrong and create confusion doing so...
Also because it's so open, some believe they need to implement a new git strategy instead of using the ones available on the internet.
I've also seen repos without a strategy at all => nightmare ;)
I agree with you, that's the motive every team I have been working, we normally define a standard like "git flow" for branch's and some commit linter for messages, it's very helpful.
My biggest problem with git is the lack of having a time-lapse view of changes to a file over time, that would be akin to Perforce's time-lapse view (Perforce's killer feature).
I don't know about "Perforce's" but in Git you can see all the changes you have in a file, considering it isn't a binary file like "images", "psd's".
And to take control of every step you made in your machine, you have the access to
git reflog
who is a life saver in cases you need to undo something.That's not even close. A UI could be built on top of git that could mimic Perforce's time-lapse view. But in the meantime, it's the one thing in Perforce that I really miss that git does not provide. Including the various GUI front-ends I've used, not just constrained to the git command line.
I commonly use git just via command line or with Emacs + Magit (it's an amazing combination).
I usually use git command line. I sometimes use Atlassian Sourcetree, or gitk.
For a git GUI, I was really enjoying Git Horizon (former-and-still-sort-of called Cycligent Git Tool), but it seems to have stalled out on a development a couple years ago... stuck on 0.5.2. Which makes me sad, because it's UI layout and visual metaphors clicked for me.
Some of the popular git GUIs just can't handle my project, because it's about a half-a-million files.
I switched from emacs to vim 20+ years ago, and have never been tempted to go back. I don't use the git addons for vim though, since the command line is plenty good for me.
Nice to know about that.
Just curious, what make you go back to VIM instead of using evil mode into Emacs?
I didn't go back to vim. I was an emacs user for many years. A coworker of mine used vim, and we were discussing the relative merits of our favorite editors, and made a dare: he'd use emacs for several weeks, and I'd use vim for several weeks.
Several weeks later, he immediately went back to vim, and I never went back to emacs.
I found that vim is a zen-like experience where the editor disappears and gets out of my way and my mind and fingers become one with the keyboard. I never had that with emacs.
Oh, I understand. I never used VIM before, I was a VSCode user and my coworker talk to me give a try to Doom Emacs + Evil mode and I never came back to VSCode.
It has some months I'm using and really enjoying.
I am comfortable until there are merge conflicts or I need to revert some changes I've committed. My latest incident was where I didn't include a .gitignore and committed a bunch of files that didn't need to be committed. This SO post was a life saver. stackoverflow.com/questions/752798...
The
git rm --cached <file>
is a life saver, thanks for sharing the post! :DThe singe best resource for me when I was learning Git was Oh Shit, Git and it seriously helped with getting into it with confidence.
That's very nice! I really don't know about it.
Haven't started using Github because i am not sure how i would organize repos , i am used to folder structure where i have nested folders for different technologies. Github don't have that option, how can i put things in highly organized fashion
I don't know if I understand well, maybe share an example about what structure or organization do you want to commit and the way you are thinking about?