ns-rse / git-collaboration

Intermediate level course on using Git for collaboration
https://ns-rse.github.io/git-collaboration/
Other
1 stars 0 forks source link

Git Hygiene #69

Open ns-rse opened 1 month ago

Robadob commented 1 month ago

Git configuration, "The global configuration file lives in your home director and on GNU/Linux and OSX systems is" (Typo) "Configuration defined locally over-rides global configurations." (should be plural, or preceded by "a")

ns-rse commented 1 month ago

Tpyo in commiterdate

ns-rse commented 1 month ago

Not regexs for .gitignore patterns/globs instead.

Robadob commented 1 month ago

GH gitignores collection: https://github.com/github/gitignore

ns-rse commented 1 month ago

In Challenge for .gitignore make sure to add into the solution creating a branch.

ns-rse commented 1 month ago

sdiff as a possible alteranative to difftastic

EDIT : Considered adding reference to sdiff but have opted not to as there is no clear way of how to install it on Windows (for example its not listed here) and the package its part of on Linux systems may differ. In contrast difftastic has clear instructions for all platforms.

Robadob commented 1 month ago

difftastic, "like the following where the old lines are started with - signs and may well be in red and the newer lines are started with + and may well be in green." Rather than old/newer, - refers to lines deleted, and + lines added? (changes within a line are reflected as a delete and addition)

Robadob commented 1 month ago

Atomic commits, (title) git commit --ammend (typo amend)

Same typo again in the body of "Squashing commits"

fredsonnenwald commented 1 month ago

git commit --ammend - would be nice for an explanation of what you were about to do before launching straight into commands?

section after this is Making Amends, which demos git commit --fixup? naming might be inconsistent

or is Making Amends a sub-section of git commit --ammend? fond size is larger so it looks like a new section

ns-rse commented 1 month ago

Make example for git commit --ammend in python-maths

fredsonnenwald commented 1 month ago

What are the caveats of fixup/ammend/rebase?

ns-rse commented 1 month ago

Perhaps include aspects of force pushing when squashing/fixup as its important to know about what force pushes are and why you do them.

Warn about force pushing things that have been merged into main.

ns-rse commented 1 month ago

More explanation/motivation of why you would be doing ammend / fixup / squash at each stage.

Perhaps exclude fixup and git absorb and focus just on git rebase -i which is what these are doing in the background.

fredsonnenwald commented 1 month ago

If garbage collection is automatic how necessary is it to know about it?

fredsonnenwald commented 1 month ago

Could have a exercise after conventional commits to go back and fix your commit message, using that as an excuse for some of the git amend/rebase type stuff

Robadob commented 1 month ago

arithmatic (typo of arithmetic) in various places.

fredsonnenwald commented 1 month ago

"perf:ormance" in the conventional commits list?

ns-rse commented 1 month ago

How do hooks work on Windows?

ns-rse commented 1 month ago

pre-push hook recommend git fetch if on collaborative work.

ns-rse commented 1 month ago

Again emphasise the importance and value of these to researchers.

fredsonnenwald commented 1 month ago

git commit --fixup for me did not work at all using git rebase -i --autosquash [commit of the target of the fixup] as I think the documentation is suggesting.

git commit --fixup 4fda15f
git rebase -i --autosquash 4fda15f

I needed to go one commit further back. Related, the text that says just change pick to fixup should also note that you need to move the line the fixup is on as well. Also a warning that this clobbers commit IDs and that you probably shouldn't do this if you've pushed and something else is referencing those commit IDs you're about to clobber.

Having now struggled a git hygiene thing again (previously with git amend) without really understanding exactly what was going to happen and all the implications, I'm a bit more concerned about handing researchers these tools to alter history. It's so easy to mess up, and without the tools for someone to undo their mistake, could cause a lot of stress.

I think if the course contains so many ways to clobber things it really needs to include a section on how to undo mistakes - git reflog has saved my bacon multiple times now.

ns-rse commented 1 month ago

Thanks for the on-going testing and feedback @fredsonnenwald

Duly noted about having to go one commit hash back, I rarely use the command line approach when I do fixups as I use Magit which has the ability to apply a fixup to the selected commit and squash it all there and then.

I've added #79 to remind me to add warnings about force pushing if others have touched the branch although in practice I personally find its quite rare for more than one person to work on a branch simultaneously (its still worth calling out though).

I'm finding its a tricky balance between introducing new ideas ("keep commits atomic and avoid commits that correct tpyos or linting, instead ammend or fixup") and not overwhelming/confusing people with complex topics such as full git rebase usage which is why I introduce rebase only after introducing --amend and --fixup in the hope of easing people into it. Further with the scope for messing things up that git rebase introduces I didn't want to cover it in detail (although obviously I need to get what I do cover correct).

Messing with reflog feels like an Advanced topic and would take up considerable time, the material is already in need of trimming back as it is so as useful as it might be I might have to just reference it and suggest some articles for people to go and read if they want to know more.

ns-rse commented 3 weeks ago

Mention the ability to include hunks of files that have changed via git add --patch as it aids reviewing what is being added and the ability to exclude e.g. debugging statements.

Thanks @Robadob for the suggestion.