HT
11/23/2025, 9:59 PMmain branch
hi all, we are using OSS version of lakefs.
We have the situation where we mistakenly merge a wrong branch to main.
We started with this:
A good branch, then branch out and had a bunch of bad commit on a "bad-branch"
And then merged bad-branch to main !
With git, we would just delete main, and create a new main out of the good branch.
But I cannot delete main branch, nor changing the default branch of the repo to something else ...
One solution is just delete data in main and then re-copy all files from the good branch. But is there a more efficient way ?Ion
11/24/2025, 7:14 AMAriel Shaqed (Scolnicov)
11/24/2025, 7:45 AMmain to whatever you like. It's an API-only call; exposing it on lakectl would be very unsafe. (One day we will have a reflog and it will be safer; until that day, you'll need to use the API.)HT
11/24/2025, 7:57 AMAriel Shaqed (Scolnicov)
11/24/2025, 7:57 AMAriel Shaqed (Scolnicov)
11/24/2025, 7:57 AMso basically using python sdk to move the main HEAD to previous commit ??Yup, it's the best I have right now.
HT
11/24/2025, 7:58 AMAriel Shaqed (Scolnicov)
11/24/2025, 7:58 AMIon
11/24/2025, 8:00 AMIon
11/24/2025, 8:00 AMAriel Shaqed (Scolnicov)
11/24/2025, 8:03 AMgit reflog and discover from where it came. But such an operation on CLI with no way to undo is incredibly dangerous in a data product.Ion
11/24/2025, 8:04 AMIon
11/24/2025, 8:04 AMAriel Shaqed (Scolnicov)
11/24/2025, 8:07 AMisnt it possible to maintain a reflog server side?I believe this is the way to do it. But it's a fair amount of product work, followed by a fair amount of dev work. One day we'll get there.
HT
11/27/2025, 4:06 AMCreatd branch hardreset-20251127170412
Current HEAD of 'hardreset-20251127170412': f7b8dee66468e7d1c9b82cf4e4b2a3599d75bdb0106bc1bf1147e79e53b3331e
Upload successful - changes will be committed atomically
Transaction committed to main
Current HEAD of 'hardreset-20251127170412': a84e61da290707df70f8f11f306c5108274fd5c1ff7fe4bdec1eb2857ea231de
Hardreseting to f7b8dee66468e7d1c9b82cf4e4b2a3599d75bdb0106bc1bf1147e79e53b3331e for branch hardreset-20251127170412
Current HEAD of 'hardreset-20251127170412': a84e61da290707df70f8f11f306c5108274fd5c1ff7fe4bdec1eb2857ea231de
Prior commit ID: a84e61da290707df70f8f11f306c5108274fd5c1ff7fe4bdec1eb2857ea231de
Post-reset commit ID: a84e61da290707df70f8f11f306c5108274fd5c1ff7fe4bdec1eb2857ea231de
Expected commit ID: f7b8dee66468e7d1c9b82cf4e4b2a3599d75bdb0106bc1bf1147e79e53b3331e
Hard reset failed.
Can anyone reproduce this ?
Using OSS 1.72 both on server and sdkAriel Shaqed (Scolnicov)
11/27/2025, 8:18 AMHT
11/27/2025, 8:22 AMHT
11/27/2025, 8:31 AMHT
11/27/2025, 8:31 AMAriel Shaqed (Scolnicov)
11/27/2025, 8:35 AMHT
11/27/2025, 8:38 AMAriel Shaqed (Scolnicov)
11/27/2025, 9:16 AMAriel Shaqed (Scolnicov)
11/27/2025, 9:17 AMHT
11/27/2025, 9:17 AMAriel Shaqed (Scolnicov)
11/27/2025, 9:19 AMAriel Shaqed (Scolnicov)
11/27/2025, 9:20 AMHT
11/27/2025, 9:25 AMtype of each of your branch objectsThere is suck function in the high level API ? when I do
print(lakefs.repository(repo_name,client=clt).branch(branch_name))
I get:
Branch(repository="test-repo", id="init")HT
11/27/2025, 9:25 AMAriel Shaqed (Scolnicov)
11/27/2025, 9:37 AMHT
11/27/2025, 10:00 AM# This docker-compose file provides an ephemeral lakeFS quickstart instance for local development.
services:
lakefs:
image: treeverse/lakefs:latest
ports:
- 8000:8000
environment:
LAKEFS_INSTALLATION_USER_NAME: "quickstart"
LAKEFS_INSTALLATION_ACCESS_KEY_ID: "AKIAIOSFOLQUICKSTART"
LAKEFS_INSTALLATION_SECRET_ACCESS_KEY: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
LAKEFS_DATABASE_TYPE: "local"
LAKEFS_AUTH_ENCRYPT_SECRET_KEY: "THIS_MUST_BE_CHANGED_IN_PRODUCTION"
LAKEFS_BLOCKSTORE_TYPE: "local"
Got lakefs server version 1.73
And same issue: hard reset did not move the branch head ...HT
11/27/2025, 10:06 AMHT
11/27/2025, 10:07 AMHT
11/27/2025, 10:17 AMAriel Shaqed (Scolnicov)
11/27/2025, 10:27 AMAriel Shaqed (Scolnicov)
11/27/2025, 10:28 AMlakefs_sdk.__version__ I guess.HT
11/27/2025, 10:28 AMlakefs==0.9.1
lakefs-client==1.44.0
lakefs-sdk==1.72.0
lakefs-spec==0.11.3HT
11/27/2025, 10:30 AMlakefs==0.14.0
lakefs-client==1.44.0
lakefs-sdk==1.73.0
lakefs-spec==0.11.3HT
11/27/2025, 10:31 AMAriel Shaqed (Scolnicov)
11/27/2025, 10:31 AMAriel Shaqed (Scolnicov)
11/27/2025, 10:33 AMAriel Shaqed (Scolnicov)
11/27/2025, 10:38 AM>>> import lakefs_sdk
>>> lakefs_sdk.__version__
'1.73.0'
>>> import lakefs
>>> c = lakefs.Client()
>>>
>>>
>>> c.sdk_client.experimental_api.hard_reset_branch('no-such-repo', 'reset-me', ref='123456789')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/pypypy/lib/python3.12/site-packages/pydantic/v1/decorator.py", line 40, in wrapper_function
return vd.call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pypypy/lib/python3.12/site-packages/pydantic/v1/decorator.py", line 134, in call
return self.execute(m)
^^^^^^^^^^^^^^^
File "/tmp/pypypy/lib/python3.12/site-packages/pydantic/v1/decorator.py", line 206, in execute
return self.raw_function(**d, **var_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pypypy/lib/python3.12/site-packages/lakefs_sdk/api/experimental_api.py", line 1953, in hard_reset_branch
return self.hard_reset_branch_with_http_info(repository, branch, ref, force, **kwargs) # noqa: E501
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pypypy/lib/python3.12/site-packages/pydantic/v1/decorator.py", line 40, in wrapper_function
return vd.call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pypypy/lib/python3.12/site-packages/pydantic/v1/decorator.py", line 134, in call
return self.execute(m)
^^^^^^^^^^^^^^^
File "/tmp/pypypy/lib/python3.12/site-packages/pydantic/v1/decorator.py", line 206, in execute
return self.raw_function(**d, **var_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pypypy/lib/python3.12/site-packages/lakefs_sdk/api/experimental_api.py", line 2064, in hard_reset_branch_with_http_info
return self.api_client.call_api(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pypypy/lib/python3.12/site-packages/lakefs_sdk/api_client.py", line 410, in call_api
return self.__call_api(resource_path, method,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pypypy/lib/python3.12/site-packages/lakefs_sdk/api_client.py", line 222, in __call_api
raise e
File "/tmp/pypypy/lib/python3.12/site-packages/lakefs_sdk/api_client.py", line 212, in __call_api
response_data = self.request(
^^^^^^^^^^^^^
File "/tmp/pypypy/lib/python3.12/site-packages/lakefs_sdk/api_client.py", line 462, in request
return self.rest_client.put_request(url,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pypypy/lib/python3.12/site-packages/lakefs_sdk/rest.py", line 288, in put_request
return self.request("PUT", url,
^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pypypy/lib/python3.12/site-packages/lakefs_sdk/rest.py", line 232, in request
raise NotFoundException(http_resp=r)
lakefs_sdk.exceptions.NotFoundException: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({'Date': 'Thu, 27 Nov 2025 10:37:16 GMT', 'Content-Type': 'application/json', 'Content-Length': '35', 'Connection': 'keep-alive', 'X-Content-Type-Options': 'nosniff', 'X-Request-Id': 'ce4f2065-b118-4503-9e32-cc0857554c0b'})
HTTP response body: {"message":"repository not found"}
Do I correctly understand that when you do this you do not get a 404??HT
11/27/2025, 10:39 AMHT
11/27/2025, 10:40 AMAriel Shaqed (Scolnicov)
11/27/2025, 10:40 AMc = lakefs.Client()
It reads .lakectl.yaml and environment variables and usually just does the right thing.HT
11/27/2025, 10:41 AMHT
11/27/2025, 10:41 AMAriel Shaqed (Scolnicov)
11/27/2025, 10:42 AMHT
11/27/2025, 10:43 AMHT
11/27/2025, 10:43 AMHT
11/27/2025, 10:44 AMwith lakefs_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = lakefs_sdk.ExperimentalApi(api_client)
repository = "FOO" # str |
branch = "Whatever" # str |
# ref = initcommit
ref= "whever"
force = True # bool | (optional) (default to False)
try:
# hard reset branch
api_instance.hard_reset_branch(repository, branch, ref, force=force)
except Exception as e:
print("Exception when calling ExperimentalApi->hard_reset_branch: %s\n" % e)
which I got from your doc pageHT
11/27/2025, 10:44 AMHT
11/27/2025, 10:45 AMAriel Shaqed (Scolnicov)
11/27/2025, 10:48 AM