git-branchless icon indicating copy to clipboard operation
git-branchless copied to clipboard

Clean up old branchless aliases during `git branchless init`

Open banool opened this issue 2 years ago • 5 comments

Wiki page

https://github.com/arxanas/git-branchless

Subcommand

git co

Description

Hi, the README refers to git co, but I believe it is now git sw.

Before just fixing the docs however, I came here in the first place because I updated git branchless only to find that git co no longer works. Could we please keep this as an alias for git co, or at least provide some way to alias it?

banool avatar Dec 07 '22 15:12 banool

Currently it just does this:

$ git co
error: The subcommand 'checkout' wasn't recognized

Usage: git-branchless [OPTIONS] <COMMAND>

For more information try '--help'

I don't think I have any alias (e.g. in ~/.gitconfig) that aliases git co to git checkout. I'd like to be able to set an alias myself but it doesn't work.

banool avatar Dec 07 '22 15:12 banool

Hi @banool, thanks for reporting. This command has changed to git branchless switch, and installs an alias called git sw by default, for a few reasons:

  • Many people already have git co aliases, which the original alias could conflict with.
  • For consistency with Git upstream, we've changed to calling this operation "switching".

You should be able to install an alias with something like git config alias.co 'branchless switch'. Let me know if this doesn't work for you.

arxanas avatar Dec 07 '22 19:12 arxanas

@arxanas I ran this command:

git config --global alias.co 'branchless switch'

Which left me with a ~/gitconfig that looks like this: https://gist.github.com/banool/65d9c277659a8059705c1cbea6392a61.

However, when I run git co main for example, I get this:

$ git co main
error: The subcommand 'checkout' wasn't recognized

Usage: git-branchless [OPTIONS] <COMMAND>

For more information try '--help'

Do you have any idea why this might fail?

banool avatar Dec 07 '22 22:12 banool

@banool hmm, this might be https://github.com/arxanas/git-branchless/issues/338. Can you check .git/branchless/config in your repository? There's no include directive in the gitconfig you've shown, but presumably there is one in the repository itself. If so, you would want to delete the conflicting entries from .git/branchless/config.

arxanas avatar Dec 07 '22 23:12 arxanas

Ah bingo there it is, I see this line:

[alias]
    co = branchless checkout

Whereas in a new repo it's not there.

Perhaps git branchless init should clean up this old alias?

banool avatar Dec 07 '22 23:12 banool