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

Re: [PATCH] Allow "git cancel" to change branches

From
PRPavel Roskin <proski@gnu.org>
Date
Apr 21, 2005, 20:00 UTC
Message-ID
<1114113609.29603.24.camel@dv>
In-Reply-To
<E1DObsr-0006Au-MA@server.smurf.noris.de>
Hi, Matthias!
On Thu, 2005-04-21 at 23:31 +1000, Matthias Urlichs wrote:
> "git cancel" may not be named correctly for this job, but it does almost
> everything you'd need for switching between one branch and another
> within a repository, so...

This functionality is badly needed, but "git cancel" should probably remain what it is.

> +if [ "$1" ] ; then
> +	test -f .git/heads/$1 || cp .git/HEAD .git/heads/$1
> +	ln -sf "heads/$1" .git/HEAD
> +fi

Considering that the patch is essentially just this block of code, it could be (in the first approximation) a separate command, e.g. "git switch", that would call "git cancel" if needed.

But let's consider the fact that "git cancel" removes all local changes. That's quite a serious side effect. I don't always want to remove local changes when I switch between branches in CVS. Many users would prefer git to do a merge.

I think that "git track" needs to be redesigned. There are at least three properties of the working directory (related to branch tracking) that users may want to change:

1) Where new revisions are pulled from.  It could be more than one
branch (ideal implementation - with several copies of rsync run
simultaneously).
2) What branch is "checked out" to the working directory, i.e. what
branch would "git cancel" restore.
3) Whether new changes are merged automatically.
I suggest following syntax:

git track -b WORKING-BRANCH [--cancel] [--active|--passive] [TRACK-BRANCH...|--notrack]

--cancel would cancel changes rather than merge when the current branch changes.

--active enables automerge, --passive disables it

Empty list of branches to track should not disable tracking. Only --notrack should do it.

Then your "git cancel BRANCH" would become: git track -b BRANCH --cancel

-- 
Regards,
Pavel Roskin
Previous: Petr Baudis
Message 3 of 3 in “Allow "git cancel" to change branches”
  1. Allow "git cancel" to change branchesMatthias Urlichs, Apr 21, 2005
  2. Petr BaudisApr 21, 2005
  3. Pavel RoskinApr 21, 2005

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.