News for hackers. Stuff that matters.
Re:High-Level Problems with Git and How to Fix Them by xenomachina on Tuesday December 12, 2017 @02:43AM (#15903718)
How do you test the thing you're actually committing without everything else in your working tree contaminating your test?

There are ways to do this using stash but if you stash before you commit, you get merge conflicts when you pop the stash. The workaround I've seen is to commit before you stash, but that means you're also committing before you've actually tested that change, which seems pretty broken, IMHO.

Re:High-Level Problems with Git and How to Fix Them by sunny256 on Tuesday December 12, 2017 @10:35AM (#15906280)
I've created a script for this, it applies the staged changes to a fresh clone and executes the command you specify. To quote from --help:

If you have lots of unrelated uncommitted changes in the current repository and want to split up the commit, how can you easily check if the changes passes the test suite? With all the other unrelated changes it can be hard to make sure that only relevant changes becomes part of the commit, and that they don't result in regressions. This script clones the repository to the directory ".testadd.tmp" in the current directory and applies the staged changes there (unless -u/--unmodified or -p/--pristine is specified), chdirs to the same relative directory in the clone and executes the command specified on the command line there.

It's available from

https://github.com/sunny256/utils/blob/master/git-testadd

and the test suite (place it in a subdirectory below the script) is at

https://github.com/sunny256/utils/blob/master/tests/git-test...

It's stable, and I've been using it almost every day for 1.5 years. It also works with binary files.

Re:High-Level Problems with Git and How to Fix Them by kazagistar on Tuesday December 12, 2017 @03:29AM (#15903908)
Commits are just a bit of local data. Until you push it out somewhere public, it's all just a big mushy pallette to do with as you will.
Re:High-Level Problems with Git and How to Fix Them by imtringued on Tuesday December 12, 2017 @10:20AM (#15906139)
Create a new branch for each issue where you create broken untested garbage commits with meaningless messages like "Fix".

When you're done:

git checkout master

git merge --squash <branch_name>

git commit -m "<Real commit message here>"