5 ms·
Ask HN: How do you stop forgetting to commit or push?
This happens to me frequently. I hack on a project at my laptop or home computer. The next day I travel to my office only to realize that I didn't commit or push any of yesterday's work. Thus to continue working on whatever I was working on I need to go home, push my changes, and then return to office. Very frustrating.
Does this happen to anyone else? How do you prevent it?
- blumomo 5y agoAre you making many small commits every some minutes? Or are you usually waiting til the end of the day to create one big commit? If you make it a habit to commit often and in small steps, `git commit` will become an automatic response like pressing Ctrl+S in the 90s and early 2000s.
- selbyk 5y agoDoesn't matter how often you commit if you forget to push
- outsomnia 5y agoIt's not a good idea to mix work done on employer devices with work done on your home devices, for the employer there's a security problem and for the employee a bad employer may lay claim to everything you do on your home computer. So you should solve this by only working on work stuff using work devices, or, eg, ssh into your work box to do stuff from home.
- Faaak 5y agoCustomise your shell (bash, zsh, etc.) in order to show on each prompt the status of your git repo (untracked changes, commits not on a remote, etc..). When I see some red, I now something is amiss and it really helps. Also, `tig` is a great tool to explore the git history
- noir_lord 5y agoI just install zsh/oh-my-zsh and it has all that nicely setup out the box. I love oh-my-zsh and it's plugins.
- tummybug 5y agoI have a portforward on my home router and simply ssh in to my always on desktop. This is also useful for not having to keep sensitive documents on a device I may lose while out and about.
- mritzmann 5y agoUse the same device. With a powerful notebook and a docking station (usb c to power, hdmi, mous, keyboard) this is very comfortable. At least for me.
- willcipriano 5y agoI use squashing on my PRs so I dont annoy others and then do it at each logical step. First commit - Function to do task Completed Second commit - Added unit test Third commit - Linter fixes Forth commit - Fix bug And so on.
- waste_monk 5y agoIf a problem bites you on the ass enough times, you'll either correct it yourself or run out of ass. That is, it sounds like you've only suffered mild inconvenience so far, not any real consequence (failure to meet deadline, being reprimanded by boss for not making progress, etc.). Once that happens, it is a powerful motivator not to make the same mistake again.
- aneil 5y agoPut a sign on your inner front door: "Did you commit your changes?"
- captainbland 5y agoCommit small, commit often. The smaller the commits, the less you'll lose when you do forget.
- iex_xei 5y agoThese days I'm using a script[0]. It checks all directories under ˋ$HOME/github.com/ˋ for changes and opens lazygit if there are changes. You can replace that line with a ˋgit commit -am "wip" ; git push origin/my-current-branchˋ for an ultimate lazy solution, to rebase later. :) [0]: https://gist.github.com/iesahin/398af2556f5ae809c4b368ffc2ef7130 https://gist.github.com/iesahin/398af2556f5ae809c4b368ffc2ef...
- bronzecarnage 5y agoIt's about creating a habit, like many people mentioned here. For me, the git commandline process was a bit too much hassle and typing to do if I wanted to do it atomically. In the end, I wound up using lazygit[0] and the nvim plugin[1] to make life easier. It makes committing only selected chunks a lot easier, not to mention easier cherry picking and other stuff. [0]: https://github.com/jesseduffield/lazygit https://github.com/jesseduffield/lazygit [1]: https://github.com/kdheepak/lazygit.nvim https://github.com/kdheepak/lazygit.nvim
- dustymcp 5y agoi work only on one machine, my laptops are basically just terminals at this point ssh into my workmachine.
- heavenlyblue 5y agoThe solution is simple: commit and push code all the time.
- Nales 5y agoI wrote a bunch of scripts, on Linux, to show me repositories with uncommitted changes when I open a terminal. Here is my blog post about them: https://www.nales.xyz/en/blog/follow-changes-repos.html https://www.nales.xyz/en/blog/follow-changes-repos.html
- Jtsummers 5y agoSame way I learned to use C-s (or whatever your editor's equivalent is) as a habit gesture. I got burned. "Save early, save often" was extended, for me, with "commit early, commit often", also after getting burned with an over-large (and broken in a few ways) commit that had merge conflicts with other people's work. Pushing is the same, except it's an extension of my "make a backup of the hard drive because it can fail at any time" learning experience. I push because that's how the backup works for a git repo (also collaboration), I backup because I got burned when a HDD failed catastrophically and I had no consistent backups. Something fails, learn from the experience and make new habits or processes (automated or manual) to avoid those failures in the future.
- deleted 5y ago[deleted]
- epirogov 5y agoI cured it with vitamin B6 B12 :D