Re: [git-users] rolling back to the first commit in a repository

2014-12-15 Thread Dale R. Worley
Konstantin Khomoutov  writes:
>   git log --reverse
>
> should help.

OK, that means that 

git reset --hard $( git log --reverse --pretty=tformat:%H | head -1 )

will reset the HEAD branch, the index, and the working directory to the
"first" commit on the HEAD branch.

But you should first think through that that is what you really want to
do, i.e., to go back to that particular state of things and throw away
all changes after that.

Dale

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] rolling back to the first commit in a repository

2014-12-15 Thread Konstantin Khomoutov
On Mon, 15 Dec 2014 09:50:31 -0500
wor...@alum.mit.edu (Dale R. Worley) wrote:

[...]
> As far as I know, there is no syntax to identify the oldest commit on
> the current branch.  But 
> 
> git log --pretty=tformat:"%h %ai %s"
> 
> will list all the commits that are part of the current branch, and
> from those you can select the hash of the oldest one.

  git log --reverse

should help.

Unfortunately,

  git log -r -1

lists the last (HEAD) commit contrary to what I would naturally expect.
I do understand the reason why it works as it does but oh well... ;-)

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] rolling back to the first commit in a repository

2014-12-15 Thread Dale R. Worley
Kevin Wilson  writes:
> Is there a command to roll back to the first commit in a repository?

Assuming that you want to reset the HEAD branch and the working
directory to be in the state of the first commit, the command would be:

git reset --hard {first-commit-hash}

As far as I know, there is no syntax to identify the oldest commit on
the current branch.  But 

git log --pretty=tformat:"%h %ai %s"

will list all the commits that are part of the current branch, and from
those you can select the hash of the oldest one.

Dale

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] rolling back to the first commit in a repository

2014-12-15 Thread Konstantin Khomoutov
On Mon, 15 Dec 2014 08:46:46 +0200
Kevin Wilson  wrote:

> Is there a command to roll back to the first commit in a repository?

I think you need to think about what you want to achieve a bit harder:
to roll back what exactly?

All the commits in any Git repository form one or more (directed,
acyclic) graphs, and a commit is said to exist in a repository only if
it is referenced, directly or indirectly, by one of entry points to
those graphs.  Entry points are branches and tags, so to have a
repository with the single existing commit you have to make sure all
the branches and tags existing in that repository point to that single
commit.

If, instead, you wanted to reset just a single branch to contain just
that commit, you just do use `git reset` to make that branch point to
that commit.

Consider reading [1] to learn about how the `git reset` command works.

1. http://git-scm.com/book/en/v2/Git-Tools-Reset-Demystified

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.