I'm looking at the `branch revert` <docs> and tryi...
# help
r
I'm looking at the
branch revert
docs and trying to do a revert, but hitting an unclear error. I want to rollback the last commit (ideally without having to look up its specific ID). Is that possible?
Copy code
$ lakectl branch revert <lakefs://quickstart/main> HEAD~1

Branch: <lakefs://quickstart/main>
Are you sure you want to revert the effect of commits HEAD~1: y
get commit from ref HEAD~1: not found
404 Not Found
also can reverts be done through the web UI? I couldn't see how
b
The HEAD is just place holder in this case - try
main~1
r
Copy code
$ lakectl branch revert <lakefs://quickstart/main> main~1

Branch: <lakefs://quickstart/main>
Are you sure you want to revert the effect of commits main~1: y
update branch: conflict found
409 Conflict
b
you branch hold uncommitted changes?
r
no
b
Can you share your commit log? The above revert command will try to revert the change in the one commit above the latest.
if you are trying to revert the last commit on main - use main as the last argument.
r
Copy code
$ lakectl log <lakefs://quickstart/main>


ID:            3c6d7270bbcec2d5c0f477b06cb143953d4aad0a24bb79981fa714d3257b8e0d
Author:        admin
Date:          2023-03-15 08:25:34 +0000 UTC
Merge:         55f9b17656e4c2e5a1f783d14d4567d391cb4f47cf3f1cdb1e65bc51a53b8611, f6436033e20a5f0769c090f59765abf8bac3075b03541e3614f0a681acc09fa3

        Merge 'denmark-lakes' into 'main'

Metadata:

        .lakefs.merge.strategy = default

ID:            f6436033e20a5f0769c090f59765abf8bac3075b03541e3614f0a681acc09fa3
Author:        admin
Date:          2023-03-15 08:25:23 +0000 UTC

        Create a dataset of just the lakes in Denmark

ID:            55f9b17656e4c2e5a1f783d14d4567d391cb4f47cf3f1cdb1e65bc51a53b8611
Author:        admin
Date:          2023-03-15 08:22:19 +0000 UTC

        Load sample data

ID:            84f5331e226955df56ce810bded5ff702c4b0fae8cd2bc17d4f82736e3cfd9da
Date:          2023-03-15 08:22:19 +0000 UTC

        Repository created
Copy code
$ lakectl branch revert <lakefs://quickstart/main> main

Branch: <lakefs://quickstart/main>
Are you sure you want to revert the effect of commits main: y
must specify 1-based parent number for reverting merge commit
409 Conflict
(using
main
as the last argument)
b
your main got two parents - current revert will not revert a merge operation
r
I don't follow, sorry. What's two parents mean (and how can I see that from the
log
output)? And is it any merge that can't be reverted, or just this case here with two parents?
b
Sorry I need to test my previous comment
Give me a min
r
thanks 🙂
b
When you revet a merge commit you need to pass which parent you like to follow -
-m 1
for first parent
using
main~1
should work in your case - but I think you already run it and found a conflict
so running revert
main -m 1
will probably give the same result, can you verify?
r
Copy code
$ lakectl branch revert <lakefs://quickstart/main> main -m 1

Branch: <lakefs://quickstart/main>
Are you sure you want to revert the effect of commits main: y
commit main successfully reverted
no error! let me just check what it's done
b
it should revert the changes from the merge of the first parent
r
🎉 that's worked. Thanks @Barak Amar!
lakefs 1
I'm puzzled by this though
Copy code
ID:            f6436033e20a5f0769c090f59765abf8bac3075b03541e3614f0a681acc09fa3
Author:        admin
Date:          2023-03-15 08:25:23 +0000 UTC

        Create a dataset of just the lakes in Denmark
this was a commit that I made in another branch - so why would it show up in the log for
main
?
b
log will show all the commits based on time until the root of the repository
did you merge this commit to main?
r
yes I did
b
so you need to see it
r
aha,got it
b
try commit on top of a new branch from main
it will not be part of log from main branch
👍 1