cogito - how to drop a commit

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

cogito - how to drop a commit

From: Sam Ravnborg <hidden>
Date: 2016-06-15 22:42:03

I accidently commited too many files to my tree today, and now I want to
drop the commit so I have logically separate commits.

What is the right way to do this - in cogito hopefully.

I do not mind to execute a few git commands, but for my daily usage I
expect cogito to hanle everything and dropping a commit has proved
useful for me from time to time, so I expect it be be implemented in the
porcelain somehow.

I have read the help for cg-seek - but it di not convince me to be what
I seeked.

	Sam

Re: cogito - how to drop a commit

From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:03


On Sun, 7 Aug 2005, Sam Ravnborg wrote:
I accidently commited too many files to my tree today, and now I want to
drop the commit so I have logically separate commits.

What is the right way to do this - in cogito hopefully.
Not cogito, and this needs to be scripted, but if what you _want_ to do is
undo the commit (in order to re-do it as several commits), here are the
raw git commands necessary (you could make this "git-fix-script", and then
"git fix"  basically does the git equivalent of what "bk fix -C" did)

	# Set up
	#
	. git-sh-setup-script || die "Not a git archive"

	# Figure out the parent.
	#
	parent=$(git-rev-parse --verify HEAD^) || exit

	#
	# Update the index to be at that point in time and make HEAD 
	# point to it, but don't update the working tree contents (ie
	# the changes remain in the working tree, to be re-committed).
	#
	git-read-tree -f -m $parent && echo $parent > .git/HEAD

NOTE! The commit still _exists_, but the HEAD reference to it is now lost.  
If you want to save that as a broken branch, you can precede this with

	git branch broken-branch

which means that the broken point got saved off as "broken-branch".

And if you didn't do that (or if you _did_ do that, and later end up 
deciding to throw that branch away with a

	rm .git/refs/heads/broken-branch

or similar) then you can get rid of the stale and unreachable objects with
a simple "git prune".

Be careful! "git prune" _will_ throw away all the objects that it can't 
find references to. You might want to run "git-fsck-cache --full 
--unreachable" first to get an idea of what it's going to throw away.

			Linus

Re: cogito - how to drop a commit

From: Petr Baudis <hidden>
Date: 2016-06-15 22:42:03

Dear diary, on Sun, Aug 07, 2005 at 12:34:36AM CEST, I got a letter
where Sam Ravnborg [off-list ref] told me that...
I accidently commited too many files to my tree today, and now I want to
drop the commit so I have logically separate commits.

What is the right way to do this - in cogito hopefully.

I do not mind to execute a few git commands, but for my daily usage I
expect cogito to hanle everything and dropping a commit has proved
useful for me from time to time, so I expect it be be implemented in the
porcelain somehow.

I have read the help for cg-seek - but it di not convince me to be what
I seeked.
cg-admin-uncommit, be sure to read --help first. Linus' pruning notes
apply as well, cg-admin-uncommit won't delete it from the database
(I personally don't care about that and never pruned so far).

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
If you want the holes in your knowledge showing up try teaching
someone.  -- Alan Cox
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help