github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/docs/quickstart/commit-and-merge.md (about)

     1  ---
     2  title: 4️⃣ Commit and Merge
     3  description: lakeFS quickstart / Commit the change and merge it back into the main branhch
     4  parent: ⭐ Quickstart
     5  nav_order: 20
     6  next: ["Rollback the changes", "./rollback.html"]
     7  previous: ["Create a branch of the data", "./branch.html"]
     8  ---
     9  
    10  _In the previous step we branched our data from `main` into a new `denmark-lakes` branch, and overwrote the `lakes.parquet` to hold solely information about lakes in Denmark. Now we're going to commit that change (just like Git) and merge it back to main (just like git)._
    11  
    12  # Committing Changes in lakeFS
    13  
    14  Having make the change to the datafile in the `denmark-lakes` branch, we now want to commit it. There are various options for interacting with the lakeFS API, including the web interface, [a Python client](https://pydocs.lakefs.io/), and `lakectl` which is what we'll use here. Run the following from a terminal window:
    15  
    16  ```bash
    17  docker exec lakefs \
    18      lakectl commit lakefs://quickstart/denmark-lakes \
    19  	    -m "Create a dataset of just the lakes in Denmark"
    20  ```
    21  
    22  You will get confirmation of the commit including its hash.
    23  ```
    24  Branch: lakefs://quickstart/denmark-lakes
    25  Commit for branch "denmark-lakes" completed.
    26  
    27  ID: ba6d71d0965fa5d97f309a17ce08ad006c0dde15f99c5ea0904d3ad3e765bd74
    28  Message: Create a dataset of just the lakes in Denmark
    29  Timestamp: 2023-03-15 08:09:36 +0000 UTC
    30  Parents: 3384cd7cdc4a2cd5eb6249b52f0a709b49081668bb1574ce8f1ef2d956646816
    31  ```
    32  
    33  With our change committed, it's now time to merge it to back to the `main` branch. 
    34  
    35  # Merging Branches in lakeFS 🔀
    36  
    37  As above, we'll use `lakectl` to do this too. The syntax just requires us to specify the source and target of the merge. Run this from a terminal window.
    38  
    39  ```bash
    40  docker exec lakefs \
    41  	lakectl merge \
    42  		lakefs://quickstart/denmark-lakes \
    43  		lakefs://quickstart/main
    44  ```
    45  
    46  We can confirm that this has worked by returning to the same object view of `lakes.parquet` as before and clicking on **Execute** to rerun the same query. You'll see that the country row counts have changed, and only Denmark is left in the data: 
    47  
    48  <img src="{{ site.baseurl }}/assets/img/quickstart/duckdb-main-03.png" alt="The lakeFS object browser with a DuckDB query on lakes.parquet showing that there is only data for Denmark." class="quickstart"/>
    49  
    50  **But…oh no!** A slow chill creeps down your spine, and the bottom drops out of your stomach. What have you done! 😱 *You were supposed to create **a separate file** of Denmark's lakes - not replace the original one*
    51  
    52  Is all lost? Will our hero overcome the obstacles? No, and yes respectively!
    53  
    54  Have no fear; lakeFS can revert changes. Tune in for the final part of the quickstart to see how.