# Re: Like commit -a, but...

4 messages from 2012-11-05 to 2012-11-05. Participants: Andreas Krey, Tomas Carnecky, Andreas Schwab.
Thread: https://gitlist.dev/t/32023

## Andreas Krey, 2012-11-05 20:29

Subject: Like commit -a, but...
Message-ID: <20121105202948.GA17505@inner.h.apk.li>
URL: https://gitlist.dev/e/20121105202948.GA17505%40inner.h.apk.li

```
Hi all,

I have a workflow for which I can't quite find the git tooling.

Essentially what I want is like 'git commit -a', except that I
want the resulting commit on a branch I name instead of the current
one, and I want my current index not being modified. At the moment
I emulate that via

  git commit -a -m TEMP": `date` $*" && \
  git push -f nsd master:temp && \
  git reset HEAD^ && \

but that a) changes the index (ok, not that bad), and it
will change my current commit in the case that there are
no unmodified files (no commit -> head doesn't point
where I want). Ok, that can be prevented by --allow-empty.

But still I'd like to know if there is a cleaner solution,
esp. with respect to the index.

(Ah, the point of all this is to take the exact current worktree and
push it to a compile&deploy server; I don't want to chop my work into
commits before I even could compile it.)

Andreas



-- 
"Totally trivial. Famous last words."
From: Linus Torvalds <torvalds@*.org>
Date: Fri, 22 Jan 2010 07:29:21 -0800

```

## Andreas Krey, 2012-11-05 20:56

Subject: Re: Like commit -a, but...
Message-ID: <20121105205628.GG21244@inner.h.apk.li>
URL: https://gitlist.dev/e/20121105205628.GG21244%40inner.h.apk.li
In-Reply-To: <20121105202948.GA17505@inner.h.apk.li>

```
On Mon, 05 Nov 2012 21:29:48 +0000, Andreas Krey wrote:
...
> But still I'd like to know if there is a cleaner solution,
> esp. with respect to the index.

Actually, it seems

 commit -m 'index'
 commit -a -m 'worktree'
 ...push
 git reset HEAD^
 git reset --soft HEAD^

might do the index trick.

But is there a direct way to convert the current working tree into a
tree object?

Andreas

-- 
"Totally trivial. Famous last words."
From: Linus Torvalds <torvalds@*.org>
Date: Fri, 22 Jan 2010 07:29:21 -0800

```

## Tomas Carnecky, 2012-11-05 21:36

Subject: Re: Like commit -a, but...
Message-ID: <1352151388-ner-1077@calvin>
URL: https://gitlist.dev/e/1352151388-ner-1077%40calvin
In-Reply-To: <20121105205628.GG21244@inner.h.apk.li>

```
On Mon, 05 Nov 2012 21:56:28 +0100, Andreas Krey <a.krey@gmx.de> wrote:
> On Mon, 05 Nov 2012 21:29:48 +0000, Andreas Krey wrote:
> ...
> > But still I'd like to know if there is a cleaner solution,
> > esp. with respect to the index.
> 
> Actually, it seems
> 
>  commit -m 'index'
>  commit -a -m 'worktree'
>  ...push
>  git reset HEAD^
>  git reset --soft HEAD^
> 
> might do the index trick.
> 
> But is there a direct way to convert the current working tree into a
> tree object?

PARENT=$(git rev-parse HEAD)
TREE=$(git write-tree)
COMMIT=$(git commit-tree -p $PARENT -m "message' $TREE)
git push origin $COMMIT:refs/heads/teh-branch

write-tree+commit-tree is what git-commit does internally.

```

## Andreas Schwab, 2012-11-05 22:36

Subject: Re: Like commit -a, but...
Message-ID: <m2fw4nd6e0.fsf@igel.home>
URL: https://gitlist.dev/e/m2fw4nd6e0.fsf%40igel.home
In-Reply-To: <20121105205628.GG21244@inner.h.apk.li>

```
Andreas Krey <a.krey@gmx.de> writes:

> But is there a direct way to convert the current working tree into a
> tree object?

You can create a temporary index by setting the GIT_INDEX_FILE env var.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

```
