git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC/GSOC] Git Beginner | Warnings for potentially destructive commands

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 25, 2016, 17:38 UTC
Message-ID
<xmqqd1qi4fvi.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<56F51089.2050703@gmail.com>
Sidhant Sharma <tigerkid001@gmail.com> writes:
Show 20 quoted lines
> $ ggit rebase
>
> [WARNING] You are about to rebase your commits in <topic-branch> onto the
> $BASE_BRANCH, which will essentially replay the work done in $TOPIC_BRANCH
> since last merge onto $BASE_BRANCH.
> For instance,
> Current state:
>
>     o---o---A---B  $BASE_BRANCH
>          \
>           X---Y  $TOPIC_BRANCH
>
> State after rebasing:
>
>     o---o---A---B---X'---Y'  $BASE_BRANCH
>          \
>           X---Y  $TOPIC_BRANCH
>
> where X' and Y' are the commits making changes identical to those made by X and
> Y respectively.

The topology may be correct, but the branch labels are both wrong, no? The tip of the base branch will stay at B, and the tip of the topic will point at Y'.

> Rebasing is not usually problematic except in cases when you are rebasing
> commits that do not exist in your repository.

This cannot be correct, as you fundamentally cannot work on (not limited to rebasing) commits that do not exist in your repository.

> $ ggit reset --hard
>
> Resetting to <destination-commit-hash>
> [WARNING] You are about to hard reset the current HEAD (master) by <n> commit(s).
If I were on B and did "git reset --hard Y", i.e.
     o---o---A---B  $CURRENT_BRANCH
          \
           X---Y  $CURRENT_BRANCH_AFTER_RESETTING
does the phrasing "about to reset by <n> commit(s):" make any sense?
Show 9 quoted lines
> This will take you back to commit <destination-commit-hash>, and discard all
> changes make thereafter. For instance,
> Current state:
>
>     o---o---A---B---C---D---E  $CURRENT_BRANCH
>
> After resetting 3 commits:
>
>     o---o---A---B  $CURRENT_BRANCH

The above two examples make me wonder if these should be static text. "ggit rebase" and "ggit reset" have full information of the concrete branch names, commit object names and the actual topology of the history, so it should be able to give a description more tailored to the user's situation. Instead of giving a fictional drawing with "For instance, Current state:", it should be able to draw the actual before-and-after picture based on where the end-user actually is. I see _some_ attempts (e.g. with "<n>", mention of "(master)" and $BASE_BRANCH, you may have meant that they will be replaced with actual values), but I suspect that telling some truth (i.e. use of the real branch names) while showing pictures that do not match the reality (i.e. if the topology and the description are done as fixed text) would only confuse the users.

Previous: Sidhant SharmaNext: Jacob Keller
Message 2 of 8 in “[RFC/GSOC] Git Beginner | Warnings for potentially destructive commands”
  1. Sidhant SharmaMar 25, 2016
  2. Junio C HamanoMar 25, 2016
  3. Jacob KellerMar 25, 2016
  4. Matthieu MoyMar 26, 2016
  5. Jacob KellerMar 27, 2016
  6. Sidhant SharmaMar 29, 2016
  7. [RFC/GSOC] Git Beginner | Warnings for potentially destructive commands (v2)Sidhant Sharma, Mar 30, 2016
  8. Remi Galan AlfonsoMar 31, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.