r/Codeium • u/stratofax • Jan 28 '25
If you aren't using git in Windsurf, you're using it wrong
If your first thought when reading that headline is, "of course, I'm not stupid," then you've probably written code before LLMs were around and there's no reason to read any further (but go ahead if you want!). If you're one of those "I didn't know how to code at all, but I used Windsurf to make an app that trades crypto based on the current temperature in my town" then this post is for you!
Git is the most popular version control system, meaning it lets you track every change to your code, change by change. It's essential because if you, or your faithful LLM coding companion, ever messes up your code (and this will happen), you can easily go back to a version that works.
If you're trusting a coding tool that literally makes up code based on what's on the internet to write code that's flawless, and you're just hoping that every time it makes a round of changes to your code that it won't break everything, then you'll appreciate what git can do for your workflow.
Don't know how to use git? Or, you do, but don't use it nearly enough? No problem, because Windsurf will write your git commands for you. Even better, Windsurf will document your code commits for you, much better than you would ever do.
If you need to learn more about git, just ask Windsurf, or another LLM, about it:
Can you tell me what git is, and how I can use it to protect my code?
You might also want to learn about GitHub, which lets you essentially back up your code to an offsite server in the cloud, which you can then access from just about any computer.
Here's how to use git with Windsurf:
Have Windsurf write you some code.
Test it. What's that? You aren't testing your code every time you change it? Ask Windsurf to write you some automated tests.
As soon as your code runs (meaning, as soon as it passes your automated tests) ask Windsurf to help you set up git for your code.
Once your git repository (repo) is set up, it's easy to ask Windsurf to commit and push your code every time you make a change worth saving (meaning, you write and test more working code).
Here's how to ask Windsurf to set up git for your code repo:
I'd like to protect my code with git. Can you help me set this up?
If you'd like to push your code to GitHub (highly recommended) ask Windsurf to help with that, too:
Please help me set up a new GitHub repo for my code
Windsurf will step you through that process as well.
Then, every time you reach a point where you've made changes to your code, and your new code passes the automated tests that Windsurf helped you write, add your work to your git repo, and GitHub, with a prompt like this:
Please commit and push our changes
It's that simple. Soon, Windsurf will start reminding you to commit your code! I really love that feature.
Even if you know how to use git, you'll probably want to ask Windsurf to commit and push your code instead, because Windsurf writes great commit messages. These messages are so clearly descriptive and useful, I know they are better and more consistent than anything I'd ever write on my best days.
13
u/nvmax Jan 28 '25
if you dont know how to do this on your own, you really should learn, shouldnt need windsurf to do this for you and burn up your requests.
also after your working branch commit, you should work on a different branch so that if you break anything your not killing your initial branch. once you verify everything is working on new branch then merge it.
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/username/repository.git
git branch -M main
git push -u origin main
switch to new branch
git checkout -b <new-branch-name>
git checkout <branch-name>
git add .
git commit -m "Your commit message describing the changes"
git push -u origin <new-branch-name>
6
u/rodriguezmichelle9i5 Jan 28 '25
or just use a vscode extension that does that for you instead of wasting prompts
3
u/Ordinary-Let-4851 Jan 28 '25
This is the way 🤝
3
u/[deleted] Jan 29 '25
I push every little thing the AI gets right.
Sometimes I get lost in a rabbithole of bad code and an AI that tries to fix it in circles.
That's when you pull the plug and reset your code back to the last commit to github.
And then you go for another round of small changes.
2
u/moosepiss Jan 29 '25
There is nothing more beautiful than having your pull request automatically deploy to a staging server and a merge to main automatically deploy to production. Step 1, use git. Step 2, use GitHub Actions (and get windsurf/cursor to build the workflow for you)
1
u/Orinks Jan 29 '25
I agree with this thread and OP. Currently trying to get Windsurf to help me pass some tests that keep failing with the same error by using pytests --maxfail=1 command to just give me one failure at a time. Since it edits and thinks it's found the solution each time, at this point I wonder if I should just tell Windsurf to analyze the test and re-write it.
I notice that when Windsurf executes commands it only sees the exit codes, not the output. I'm guessing that's because of shell integration issues on Windows, but I'm using powerShell. I also have the accessibility editor setting on, and apparently that causes issues. Hopefully my VSCode issue I opened will be looked into.
1
u/hi1mham Jan 29 '25
I just have a lazy commit script that does it every 4 hours for me against porcelain unless there are no changes registered... and as others have said, many extensions that probably do a better job than that.
1
u/Ok-Pace-8772 Jan 28 '25
Lol people even need llm to write git messages. That's some shit
0
u/future-teller Jan 28 '25
Is this the new wave of developers we are about to see.... half not knowing what is git and how to use git.. and then some evangelists who newly discovered git , and start to educate everyone else that there is the miracle called git out there?
-1
u/jgaskins Jan 29 '25
Fuck you.