The GitHub Copilot for CLI is more powerful than you think...
At some point in mid-2023, I was able to play with the GitHub Copilot for CLI and haven't looked back.
I first saw a sneak peak in April when Martin Woodward (VP for DevRel at GitHub) was at MVP Summit and was kind enough to sit down and show me all the cool things it can do. Since then I have installed it and slowly but surely began to discover how powerful it is. Of course, like all things AI/GenAI, it is not fool proof and it can't always understand you. But it can do so much more than just git or GitHub commands used by developers. Let's take a look.
You can ask it a question for a CLI command by using gh copilot suggest "<your question here>"
and it will go away and think about a response.
In fact, it even asks you if you want a shell, git or GitHub CLI command and will tailor the response accordingly! I asked it a simple question to find any files in my current directory that were created before 1st January 2025. Once I selected that I wanted a generic shell command it took mere milliseconds to think about it and pop back with a command! `find . -type f -not -newermt 2025-01-01`
You can try this yourself but it is super helpful for finding out how to do things. It has certainly saved me from git nightmares on many occasions! They say great power comes with great responsibility and to me git is a great power and it is far too easy sometimes to mess things up! So the existence of Copilot in the CLI really helps me!
But what about if you already have a command that perhaps a colleague has shared and you have no idea what it does. This is where explain comes in! You can use ```gh copilot explain "<your command>"```and it will actually explain to you, often in a good level of detail, what the command does. I ran it against ```git rebase -i --autosquash origin/main``` and it let me know what it was doing:
Explanation: • git rebase is used to reapply commits on top of another base tip. • -i initiates an interactive rebase, allowing you to modify commits. • --autosquash automatically squashes commits that are marked to be squashed. • origin/main specifies the branch onto which you want to rebase your current branch, typically the main branch on the remote repository.
I really do love the GitHub Copilot CLI and I probably don't even use it for even half the power it has! I imagine if you are an enterprise developer who potentially has a large and complex repo to update and maintain, this could save you a lot of time and headaches! Why not get started today, you can even find the repo on GitHub.