views:

113

answers:

3

For example Id like to modify the login page, so it auto-logs me.

I want those changes to ONLY work on my development station and dont be visible in push. if I make it on a branch than i would have to somehow un-merge that change before every push.

is that supported by git?

+2  A: 

Why don't use setup a gitattributes filter driver?

alt text

Every time to checkout your directory, it will check through a script in the smudge step) for that file (and that file only) if certain condition are met (as in "this is or is not your development station") and will modify the content accordingly.
The clean step would restore its content or at least ignore that particular modification.

VonC
i will try that, thx
01
A: 

I'm not sure I understand the question: why can't you just branch off? Have master your main, public branch and keep rebasing your private branch on master (or merging master with your private branch). Never bring your chances to master, only bring changes from master to your private branch.

If you happen to make changes on your private branch that you'd like to share with master there's no problem to cherry-pick the changes onto master.

wilhelmtell
but this way i will ALWAYS have to remember to NOT include that change(and i will forget about it sooner or later). is there some way to write script to ignore that change in merging?
01
If you really want to block yourself from exposing these changes then you can clone your repository elsewhere, but not add any remote in that clone that points to a public repository. Then, any change you make in that repository stays there: there's no remote you can push to. Of course, you can still get these changes exposed if you pull from that private clone, but that would require a different kind of explicit act than what you usually do. You usually _push_ your local repositories onto public ones, not _pull_ from your local clones onto other local repositories.
wilhelmtell
+1  A: 

If you have at least Git 1.7.0, you might like this bit of ‘plumbing’:

git update-index --skip-worktree -- path

From the git update-index manpage under “Skip-worktree bit”:

Skip-worktree bit can be defined in one (long) sentence: When reading an entry, if it is marked as skip-worktree, then Git pretends its working directory version is up to date and read the index version instead.

To elaborate, "reading" means checking for file existence, reading file attributes or file content. The working directory version may be present or absent.

The “skip-worktree bit” is the basis for the sparse checkout mechanism documented in the git read-tree manpage`.


There is a related ‘bit’ in older versions of Git (git update-index --assume-unchanged), but it should not be used for the OP's purpose. It seems like it might be useful for the OP's situation, but Git's maintainer has said that its contract (the “promise”) makes it unsuitable for such purposes.

Chris Johnsen
I guess the second line is supposed to be: `git update-index --skip-worktree -- path`?
wilhelmtell
@WilhelmTell: Yes, thanks. Fixed.
Chris Johnsen