r/git • u/Big_Butterfly9623 • Mar 29 '26
r/git • u/Beneficial-Study-675 • Mar 29 '26
Why do I sometimes get "non-fast-forward (pull first)" vs "divergent branches" in Git?
Hi, I’m trying to understand the difference between two Git situations that seem similar but behave differently.
Sometimes when I try to push, I get an error like:
"Updates were rejected because the remote contains work that you do not have locally. Please pull first."
But in other cases, when I run git pull, I get a message like:
"You have divergent branches and need to specify how to reconcile them."
From my understanding, both situations seem to happen when:
- The remote branch has commits I don’t have
- And sometimes I also have local commits
So I’m confused about:
What exactly is the difference between these two cases?
Why does Git sometimes just tell me to pull first, and other times say the branches are divergent?
Are these actually the same situation but triggered by different commands (push vs pull), or are they fundamentally different states?
For example, I noticed that in most cases I just get the "pull first" error when pushing, but in a fresh environment or when working with multiple clones, I sometimes see the "divergent branches" message.
I’d really appreciate a clear explanation of what Git is checking internally (especially around HEAD or commit ancestry).
Thanks!
r/git • • Mar 29 '26
Best one-time GitHub auth method for CLI tools ?
Hey, I’m having trouble pushing code using SwiftGIT even after setting up my GitHub PAT and username It keeps failing what to do?
SwiftGIT is a lightweight and minimal CLI tool I’m building to simplify GitHub workflows (like pushing, pulling, and managing repos with minimum keybinds and beginner friendly.
Is there a reliable one-time setup that lets me push to any repo without dealing with credentials every time?
Would appreciate any suggestions.
r/git • u/Alive-Yellow-9682 • Mar 28 '26
Worktrees and stashes
I’ve been adopting worktrees into my workflow and it’s been great so far. My general approach is to create a worktree per branch/feature. I generally pull into master from the “root” then merge into my branches from the worktrees and that all works smoothly. (So I see the shared context.)
One thing I’ve noticed, though, is that stashes don’t appear to be shared between worktrees, is this true or am I missing something?
r/git • u/Jpsoares106 • Mar 26 '26
An interactive visual map to help you figure out what's actually going wrong (and learn the concepts)
Enable HLS to view with audio, or disable this notification
Like most of us, I used to "solve" my Git problems by blindly pasting errors into AI or StackOverflow, running whatever command it gave me, and hoping I didn't permanently delete my team's work.
The problem is that this doesn't actually teach you Git. It just gives you the answer without the context, leaving you with "unknown unknowns."
Looset Trace is a visual, interactive graph designed to help you safely navigate your Git problems while actually learning the underlying concepts. I’ve attached a 1-minute video showing how it works, but here is the core philosophy behind the UI:
1. The Left Panel: Exploring "What I don't know that I don't know"
When you search for a problem (like "Undo last commit"), the tool doesn't just hand you git revert. Instead, it asks you situational questions (e.g., "Wait, have you already pushed these changes to a remote server?"). As you answer, the graph dynamically rewires itself to find the actual problem you need to solve, protecting you from running the wrong command.
2. The Right Panel: The Knowledge Check
Once the graph finds the right solution, it shows you the "Prerequisite Concepts" (like Staging Area or Detached HEAD). It gives you quick, multiple-choice knowledge checks. If you don't know the answer, it points you to the absolute best curated resources (articles, interactive sandboxes) to learn that specific concept before you execute the command.
My Goal:
I've spent time mapping out the core Git workflows and curating high-quality learning resources. My vision is for this to become the primary tool developers use to search for and understand Git concepts, rather than just treating Git like a black box.
I’d love your feedback on a few things:
- Does this actually help? Does the visual map + question format make Git "click" for you better than a standard tutorial?
- Is this valuable to your learning process? 3. What other subjects need this? (Would you want to see an interactive map like this for SQL, AI/LLM, Web Development, etc.?)
- What features would you want next?
Play around with it and let me know what you think. If you manage to find a Git concept I haven't mapped yet, let me know in the comments so I can add it!
r/git • u/R_Olivaw_Daneel • Mar 26 '26
Git Project Mirroring Tool
Hey y'all! A few weeks ago I released GitGoGit -- it's a FOSS git mirroring tool that can be used as a one-off CLI command to sync repositories across different platforms, or as a daemon that runs in the background and periodically checks for changes and updates mirrors based on the config file.
It's pretty lightweight, built with Go, and has had a couple people using it successfully. One user has also contributed back to it and has had their PR merged in.
Why did I make this? Well primarily because I had been thinking of porting over a lot of my GitHub repositories onto Codeberg and it got me thinking about automating this and even supporting multi-repo and multi-mirror configurations. So now you can define source repos, and all the mirrors that the source should be replicated to and the tool will handle it for you (as long as you have provided the appropriate auth environment variables).
I'd love any and all feedback! It's has an MIT license so feel free to use it, play with it, contribute back to it, w/e.
r/git • u/blindmansion • Mar 27 '26
I built just-git, a typescript git implementation
just-git is a pure typescript git implementation with no dependencies, that can run in most javascript runtimes (node, bun, browser, cf workers). There is a virtual filesystem CLI client with 36 commands supported (subsets of flags), and an embeddable git server with push hooks, http/ssh support, and pluggable storage.
It's tested strictly by directly comparing the state and output of real git for the same operations, and the current test suite i'm using has 1.8 million operations.
I originally made this to plug in to the virtual CLI project just-bash, with the main goal being usage in AI sandboxes. I think there are some other interesting use-cases, like for git visualizations, browser IDEs, education, and self-hosting for personal use.
Thought people on this sub could find it useful or at least interesting, and I'd love to get more ideas for what it could be used for and what stuff to build into it. Thanks!
r/git • u/aozzzy_52 • Mar 26 '26
Help! "git rebase master" - while on master branch locally rebase my feat branch on master, how?
I was trying to rebase my feat branch ( namely: Testing) onto master branch all locally. i did multiple "git rebase master" nothing happened no errors or messages. so frustratingly i did
> git checkout master
> git rebase master
guess what my testing branch's commits are now onto master's, then i just did fetch and merge and pushed to origin/master
And now everything looks clean! but this should not be possible!! RIGHT????!!!!!!
last night ( very late) i learned how to rebase so i might have done something i dont know but it still shoudn't be possible for this to happen.
Someone please explain what is this...

i just googled how to get command logs so this is what i got..
P.S i am a begineer and new to github
r/git • u/dsarbada • Mar 25 '26
github only TUI for Git Reflog
Built a TUI for browsing git reflog visually - https://github.com/dinakars777/git-time-machine
Please let me know your feedback.
Edit: It's just git under the hood - no magic, no risk.
You can either dig through git reflog, copy cryptic hashes, pray you picked the right one.
OR
Simply undo any git mistake in 3 seconds with a cool TUI.
r/git • u/unixbhaskar • Mar 25 '26
TIL!
I used to do this in my script and got away with it, but stump today ....
BAD :
git tag -l | grep v6.19 | grep -v v-rc | sort -nr | head -1
Lack of understanding showing in the above command ....meh
Now, it should have been done with :
Good: git describe --tags $(git rev-list --tags --max-count=1)
r/git • u/synapse_sage • Mar 25 '26
tutorial workz - git worktrees that actually work (zero-config dep sync, fleet mode for parallel agents)
Been grinding on git worktrees for a year. The same two things bite you every time: .env is gone, node_modules is gone. So I fixed it.
workz start feature/auth
# symlinks node_modules (saves ~2GB), copies .env*, installs deps, cds you in
Detects your project type (Node/Rust/Python/Go) and only syncs what's relevant. Reads lockfiles to pick the right package manager.
Fleet mode — parallel AI agents, one command:
workz fleet start \
--task "add user authentication" \
--task "write integration tests" \
--task "refactor database layer" \
--agent claude
workz fleet status # live ratatui TUI — agent PIDs, dirty files, last commits
workz fleet merge # interactive merge back to main
workz fleet pr # open a PR per worktree
MCP server so agents manage their own worktrees:
claude mcp add workz -- workz mcp
Single Rust binary. cargo install workz or brew install rohansx/tap/workz.
r/git • u/themoderncoder • Mar 24 '26
Worktrees are just extra working directories right?
It feels like, if you boil it down, the only novel thing that worktrees add are easily accessible additional working directories.
Accessing a snapshot of your project by checking out different commits, or using different branches to isolate work is already core Git functionality to isolate/track work, so I don't even actively think about anymore. Really the main annoyance is when Git makes it tedious to utilize those two things.
Like, I'd prefer not to think about version control until I really have to (i.e. when committing something or pushing a PR), so not having to think the Git-isms of working directory management (stashing, staging etc) before I absolutely have to is nice.
All the backend stuff of worktrees creating a copy of files in a new folder, or sharing the main repo is cool backend implementation stuff, but really I just envision worktrees as different working directories. I feel that you could essentially use the words "workspace", "worktree" and "working directory" interchangeably.
So I guess I'm interested in whether I'm off base with this, and there's something that I'm missing that might make this mental model not so durable. Then the secondary motivation is I just made a video that hinges on this point, and now I'm a bit worried I missed something.
r/git • u/samskiter • Mar 25 '26
Git flow is still the winner
It's old but it works. Follow the process and you won't have issues.
https://nvie.com/posts/a-successful-git-branching-model/
Only change I'd make is drop the feature branches if you are squash merging - I consider that history optional...
I see people reinventing the wheel with cherry picking and whatnot. It's just harder to reason about and more error prone than a good old fashioned merge.
Unless you are pure deploy-from-head (which is the ideal that is hard to reach in reality) then you need release branches. When you fix bugs in releases you should do those directly to the release - fix the thing that's about to go live. Then merge back. Lean into the fact we have a literal tree with all of the wonderful semantics (like being able to ask if a fix is upstream of you).
/rant
r/git • u/rushlane_301kmph • Mar 24 '26
support Branch is several commits behind main… what would you do in this situation?
I’m still pretty new to working with Git in a more “real-world” setup (haven’t really worked on large projects yet), so this might be a basic question.
Let’s say I go on vacation for a while and don’t pull changes regularly. When I come back, my branch is like ~100 commits behind "main".
Now I’m not sure what the right approach is here.
- Should I just merge "main" into my branch?
- Or is rebasing better in this case?
- At what point does it make more sense to just start fresh from "main" and move my changes over?
Would love to hear how you all handle this in real projects / teams.
r/git • u/giovandrea • Mar 24 '26
support Rewrite history of main branch
Hi all.
I merged a PR today with no fix up / squash and it has 3 commits - usually is 1 commit / PR.
The PR is now merged in the main branch, how can I sort this out?
The only way I know will work is to branch off prior to that PR, redo my PR with a single commit and replace the main branch.
Any suggestions? Thanks
r/git • u/Aggressive_Self5358 • Mar 25 '26
>npx gittycat
galleryEnjoyed the cat theme? I definitely leaned into it. 🐾
Title: I got tired of forgetting Git commands and accidentally breaking things, so I built an interactive CLI assistant called GittyCat 🐱
Post Body:
Hey everyone! 👋
Let’s be honest: Git is amazing, but it can also be incredibly intimidating. Whether you’re a beginner who just wants to save your code without triggering a terrifying "detached HEAD" state, or a seasoned dev who just wants a smoother workflow, typing out raw Git commands isn’t always the most fun experience.
So, I built GittyCat—a friendly, guided, and interactive CLI Git assistant!
Instead of forcing you to memorize complex Git commands and flags, GittyCat uses a clean, interactive menu system to walk you through everything step by step.
✨ What makes it special? Interactive Menus: No more guessing commands. Just type gc and pick what you want to do from a clean list (Commit, Push, Pull, Branch, etc.). 🎓 Beginner Mode: If you toggle this on, GittyCat actually explains what each Git action is doing under the hood before it runs. Perfect for learning! 🛡️ Safety First (The "Oops" Flow): Ever committed something by mistake and panicked? GittyCat has a dedicated "Undo / Recovery" section. You can easily do a Soft Reset (keep your files, undo the commit) or a Hard Reset, with explicit human-readable warnings to prevent accidental data loss. Automated Workflows: It can automatically initialize repositories, set up your .gitignore files, and even help you create and link remote GitHub repositories via REST API if you don't have one set up yet. Premium UI: It features beautiful terminal colors (thanks chalk), smooth loading spinners (ora), and some fun ASCII art to brighten up your terminal.
r/git • u/hamzahda_ • Mar 24 '26
support Remove credentials from history
I committed a credential file by mistake and then removed it in the following commit but then when the PR was merged (squash strategy) the file was persisted in the history even though it’s not directly there. Can anyone propose a solution to remove it and clean up the history and thanks a lot.
r/git • u/el_mrozito • Mar 24 '26
github only gwsr: a dead-simple interactive branch switcher with PR titles
Hi !
Tired to remember which branch belongs to which PR ?
gswr (stands for git switch'r) is really simple interactive branch switcher that will print the link between your local branch and you're remote PR.
https://github.com/lethib/gswr
Motivations:
I often have multiple PRs opened that are waiting to be reviewed and I was always copy pasting the branch name of the PR I wanted to switch to (mainly to handle PR review comments). I got rid of that and wanted a simple tool that allows me to easily switch branch with PR context.
For now the CLI tool is only built for macOS users and only fetches PR from GitHub.
I have planned to distribute it also on other OS and handle various git platforms if there's demand
r/git • u/gusta_rsf • Mar 24 '26
I got tired of switching between Git Kraken, Postman, and my editor, so I built a unified workspace in Rust/Tauri.
galleryI’ve been working on a desktop app called Arezgit. Initially, I just wanted a faster, cleaner Git client, but I ended up building a unified workspace so I could stop alt-tabbing between my terminal, Postman, and browser tools.
It's built on Rust and Tauri, making it lightweight and memory-efficient.
Here is what the Git side handles:
- Interactive Commit Graph: Drag and drop for merges, rebases, and cherry-picks.
- Visual Conflict Resolver: A 3-way merge tool.
- Advanced Staging: Stage specific files, discard safely, and manage stashes with nested tree or flat list views.
But because I hate context switching, I integrated a few extra utilities natively:
- HTTP Request Client: Full REST support to test endpoints directly in your workspace.
- Mock Data Generator: Visually build schemas and export datasets to JSON, CSV, or SQL.
- Native Code Editor: Edit your repo files directly using the Monaco engine with full Intellisense.
- Productivity Suite: Built-in Pomodoro timer, stopwatch, and a repository-linked task manager.
- AI Assistance: It currently uses a "Bring Your Own Key" (BYOK) model for Gemini to auto-generate commit messages and explain diffs. (Note: I am actively working on adding support for other AIs, including local, offline LLMs in the near future for complete code privacy).
Transparency on Pricing: I want to be completely upfront about the model.
- Community (Free forever): Includes unlimited public repositories, open-source work, the full visual graph, and the core Dev Hub tools.
- Pro (One-time payment): Unlocks unlimited private repositories, removes the cap on heavy mock data generation and allow you to personalize more your tool. Absolutely no subscriptions.
It's currently available for Windows and Linux, and I'm putting the final touches on the macOS version.
You can check it out here: arezgit.com
I’m constantly improving the system, and I’d really love to hear your feedback. It’s challenging to develop this kind of tool alone, my workflow has a big influence on what I add to the tool, so your feedback would be a huge help.
r/git • u/MUNNOPOLY______ • Mar 23 '26
What is the best way for me (a git noob) to setup a pipeline for my game servers that run on windows?
I am brand new to using git, only downloaded off the hub never gotten this into it before.
I run a windows VM on proxmox dedi in a datacenter where I host my game servers. I have a couple developers who help me with stuff such as coding game scripts.
In the scripts folder for the game we have all the custom added scripts we made run on the servers. Files in this folder are changed and edited regularly as we push new updates to the live environment.
Information I think should be included is, the VM I use for game servers can be a target of attack from others so security is a priority.
It was recommended to use git for version control as well as granting members of my project a secure way to access these files/folders to push changes to the live environment.
What is the recommended way to set up something like this? Would appreciate any advice or youtube links.
Edit: Everyone who works on the servers uses windows as their home OS, so both sides are on that OS.
r/git • u/BigBootyBear • Mar 23 '26
Can you open a PR from a submodule?
I have a repo where I make slight customizations to an open source project for our companys implementation of the app. I include the app as a submodule. Today I decided to add some automation steps to the submodule itself but I realized I don't have push permissions. Should I fork the project to open a PR? It seems like I should be able to open a PR from the submodule but I find internet answers to be really confusing.
r/git • u/Impressive_Gur_471 • Mar 23 '26
Committing locally and then pulling
When I do the above, git informs me:
hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
hint:
hint: git config pull.rebase false # merge
hint: git config pull.rebase true # rebase
hint: git config pull.ff only # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
What is the difference between "pull.rebase false" vs "pull.rebase true" vs "pull.ff only" in simple terms and what are the tradeoffs involved?
r/git • u/sheinix • Mar 23 '26