Skip to content
Haruko386Public

About

Gogit is a Go CLI tool that helps you type the correct Git commands, even if you're not familiar with most of Git's commands.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

54 Commits

Folders and files

Repository files navigation

Gogit

Gogit

Typing SVG

A little story:

You are an internal in a company, this is your first work since you are an adult.

First day, you boss told you to Clone the company's project from GitHub and get familiar with it. You know how to do it, just type: git clone ...

Next day, you need to submit some feat or fix PR to the upstream branch. Still ok: git checkout -b feat/something

Few days later, your boos walks over: A contributor's PR have conflict, you need to review his code and give him a suggestion to resolve the conflict.

Usually, on your local and your own branch, you just type: git checkout branch → git pull upstream main --rebase → resolve the conflict in local and git push --force-with-lease origin branch

But in this way, you found there are two conflict, but in GitHub, there should be only one conflict ???

Finally, you Boss told you how to do it right:

git remote add whhe git@github.com:whhe/ragflow
git fetch whhe
git checkout upstream/main
git merge whhe/feat-bedrock-api-key-auth

Like dude, what fk is this bro?

This was basically my experience while interning on infiniflow/ragflow. And that PR review is here

To be honest, I only know

git clone ...
git add .
git commit -m ""
git push # I like to use `--force`, although I know the consequence :)

before my internship in Infiniflow


What is Gogit?

Gogit is a Git CLI assistant written in Go.

Install and run from anywhere

Gogit requires Go 1.25 or later and Git. Clone this repository, enter its directory, and install the executable into your Go binary directory.

git clone https://github.com/Haruko386/Gogit.git
cd Gogit

Windows PowerShell

$installDir = go env GOBIN
if ([string]::IsNullOrWhiteSpace($installDir)) {
    $installDir = Join-Path (go env GOPATH) "bin"
}

New-Item -ItemType Directory -Force $installDir | Out-Null
go build -o (Join-Path $installDir "gogit.exe") .

$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if (($userPath -split ";") -notcontains $installDir) {
    $newPath = if ($userPath) { "$userPath;$installDir" } else { $installDir }
    [Environment]::SetEnvironmentVariable("Path", $newPath, "User")
}
$env:Path += ";$installDir"

macOS or Linux

install_dir="$(go env GOBIN)"
if [ -z "$install_dir" ]; then
    install_dir="$(go env GOPATH)/bin"
fi

mkdir -p "$install_dir"
go build -o "$install_dir/gogit" .

Add that directory to your shell's PATH if it is not already available:

# Bash
echo 'export PATH="$(go env GOPATH)/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

# Zsh (the default shell on modern macOS)
echo 'export PATH="$(go env GOPATH)/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

If you configured a custom GOBIN, add that directory instead of $(go env GOPATH)/bin.

Verify the installation from a new terminal or any directory:

gogit

This opens the Gogit-assisted shell. Type Git commands normally and press Ctrl+D on an empty input line when you want to leave Gogit.

For dangerous commands, Gogit should eventually be able to tell you that you're about to do something... interesting:

--force
    Force push to the remote repository.

    ⚠ This may overwrite remote history.

--force-with-lease
    Force push only when the remote branch has not unexpectedly changed.

    ✓ Usually safer than --force.

Because sometimes the most useful feature of a CLI assistant is not helping you type:

git reset --hard

It's stopping you for half a second before you do it.

Important

If you use agent to operate git, bro, this is not what you need.

Just use your agent and let your brain go to waste.

(I'm not mean AI is harmful or that I want to ban it, I just think we should not let AI do everything, so that we won't forget something basic skill)

About

Gogit is a Go CLI tool that helps you type the correct Git commands, even if you're not familiar with most of Git's commands.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages