5 ms·
Correct me if I’m wrong but these all seem to fix problems that exist in a local clone only. And that’s where none of my “oh shit” moments happen. All of my oh
by Waterluvian 6y ago
Correct me if I’m wrong but these all seem to fix problems that exist in a local clone only. And that’s where none of my “oh shit” moments happen.
All of my oh shit moments are two flavours: I have pushed to remote, or I have pushed to remote and force pushes are disallowed.
I want a list of as graceful solutions as possible for those scenarios. And certainly they can be real-world solutions like “this cannot be undone in a desirable way so here’s an approach to handle the commit(s) necessary to fix the problem.
This also brings up a question I didn’t realize I had: are people using git without frequently pushing to remote? I feel like having a remote backup of my work in progress is the killer feature. I can’t imagine doing any amount of work and not backing it up.
- bkanber 6y agoThere's a reason commit and push are two separate actions. That said, most people commit+push in the same keystroke. git revert is my best friend.
- Waterluvian 6y agoWhat is the reason? Like are people just not pushing changes to remote branches? Or is there some value in stuff to do in the small time between commit and push? Like are you checking your work before pushing?
- pirocks 6y agoIn the past I've done stuff like not pushing until the end of the day/coding session. Usually though I just end up committing and pushing immediately and then realizing I need to amend something and make a note to rebase later(I totally always do that rebase /s).
- dec0dedab0de 6y agoI try to keep my commits small, and I don't push each time because I have a Jenkins pipeline thats going to update a server for my branch and run unit tests and all that
- triceratops 6y agoIntermediate commits. For example, while building a UI - HTML is done, but you haven't begun styling. You want to be able to revert to a good point in case you screw up, but there isn't much reason to push it to a remote because it's not a shippable state. As long as your computer is being backed up (you are using backups, right?) you won't lose any data by not pushing to a remote.
- the_pwner224 6y ago> are people using git without frequently pushing to remote? I feel like having a remote backup of my work in progress is the killer feature. I use git without a remote pretty often. When doing personal projects or exploratory work, the problem is either so trivial that I don't care about backup, or already backed up using something like Nextcloud/Syncthing. But having the commit history allows me to easily look at old code, revert changes, and make big structural changes without having to back up the entire project folder in case I end up disliking the new structure. I guess you're just not working on many things at a scale where version control is useful but setting up an online repo doesn't seem worth the time.
- Waterluvian 6y agoWhen I do exploratory research, having a history of commits, days, months, years after the end of the research project is invaluable for many possible future needs. I’m still not sure I see a strong case for not bothering with a remote. But I appreciate we all do things at different fidelities.
- perryizgr8 6y ago> I guess you're just not working on many things at a scale where version control is useful but setting up an online repo doesn't seem worth the time. It is literally a couple of clicks to set up a private repo on github. For me, either the problem is too small to set up git, or it is big enough to spend half a minute to create a github repo.
- panpanna 6y agoPro tip: you can set up a remote repo on any Unix machine with SSH access: ssh machine "mkdir x; git init x" git clone machine:x If you have something sensetive or just want to avoid github/gitlab for some other reason, an empty remote container with SSH access works just as well.
- samus 6y agoYou could just set up a private Github monorepo for all your utility projects and experiments. One branch per project, and you check out exactly the branch you want. Since 2012, `git clone` supports `--single-branch`, which makes it download only the commit history of that specific branch.
- sigjuice 6y agoA git remote is not a backup. I could make a mistake, force push the wrong thing to the wrong place and lose a bunch of stuff.
- Waterluvian 6y agoThat’s why we disable force push. Then it’s a nice historical backup.
- dahfizz 6y agoThat's not really true. It is pretty difficult to delete any data from git, especially by accident. You may screw up your history but you can always fix that if you know what you are doing.
- sigjuice 6y agoIf I force push to the wrong branch on github, is it possible to access the remote reflog to try and recover from my mistake?
- rhn_mk1 6y agoYes. Git push does not remove the previous commit, but changes the HEAD of the branch to be another commit. The old commit becomes unconnected, but you can still get to it if you know its hash. There's also a way to list all unconnected commits, which is a bit involved. Unconnected commits will exist and take up space until garbage collection is done.
- juped 6y agoNot having a remote is the killer feature of DVCS.
- spanhandler 6y agoThat and multiple remotes. Not even necessarily all having the same branches.
- dreamcompiler 6y agoI used to use local-only git often. But now that private repos on github are free and take two seconds to create, I keep online backups of everything.