git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How to track history of personal changes in a repository?

From
Elijah Newren <newren@gmail.com>
Date
Aug 30, 2019, 15:21 UTC
Message-ID
<CABPp-BEWn1wHdxWM8cVqmvzYo8HDdUzuh4G-XTN51o8JdvkrCw@mail.gmail.com>
In-Reply-To
<CAEV-cEp19ehfBwHxh7OGsvTxTchNJLSRZGZXqAsDjyQg-W3rFA@mail.gmail.com>

On Thu, Aug 29, 2019 at 10:58 AM Matthew McClure <matt@continuousdelta.com> wrote:

Show 11 quoted lines
>
> On Thu, Aug 29, 2019 at 1:04 PM Elijah Newren <newren@gmail.com> wrote:
> >
> > Perhaps put all the changes in a specific branch and run:
> >   git config branch.${personalBranchName}.pushRemote
> > Do.Not.Push.Changes.From.This.Branch
> > ?  (And make sure that push.default is not set to 'matching'.)
>
> I imagine putting all the changes on a specific branch might be part
> of a solution. I'm looking for ways to keep the changes in the work
> tree as well, even as I switch among other branches I'm working on.
Well, here's some ideas...

If you want personal changes kept in the worktree and aren't worried about versioning them:

* If the changes are new files that are not tracked, just .gitignore them.
* If the changes are to files that are tracked, AND you aren't making
changes to those same files that do need to be committed and pushed,
use the assume-unchanged bit (see git-update-index(1)).
* If the changes are to files that are tracked and you need to make
other changes to those same files, the best you've probably got is "be
careful while using 'git add -p' to only select the bits that should
be staged".

If you want to keep the personal changes in the worktree AND are worried about version control:

* You could just make sure that any personal changes are made in
separate commits of their own and put a special string (e.g. "DO NOT
PUSH") in the commit message.  Add a pre-push hook (see githooks) that
checks for this string in any of the commits to be pushed and denies
the push if it is found.  At that point, you'd just rebase to move the
"DO NOT PUSH" to be the last commits in the series, and always make
sure when pushing that you specify a commit older than the current tip
of your branch to push (i.e. using refspecs; see the git-push manpage)
* If you don't like the githook route and if the personal changes are
all in different filenames than exist in other branches, and you're
willing to do a little low-level hackery...then you could put all
these changes in a different branch as mentioned previously, and use
some low-level commands to "checkout" the files from both branches
simultaneously.  The basic way it'd work is that the real branch would
have a .gitignore for all files in your personal changes (whereas the
personal changes branch would have no .gitignore because files have to
be independent; things will just be uglier when you're on that
branch).  You'd use 'git symbolic-ref HEAD $OTHER_BRANCH && git reset'
to swap branches on the fly so you can commit different types of
changes.

Hope that helps, Elijah

Previous: Matthew McClureNext: Philip Oakley
Message 4 of 6 in “How to track history of personal changes in a repository?”
  1. Matthew McClureAug 29, 2019
  2. Elijah NewrenAug 29, 2019
  3. Matthew McClureAug 29, 2019
  4. Elijah NewrenAug 30, 2019
  5. Philip OakleyAug 31, 2019
  6. Matthew McClureSep 3, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.