1
coookie
8y

!rant

Often times while working/debugging I get to a state where the app/whatever works but then I realize that it didn't, so some more changes and I get to a new state.

Question is, does there exist something which lets me switch between these states without messing up my git? I do have a solution in mind but want to know if it already exists.

Comments
  • 0
    A local git or something?
  • 0
    You can `git checkout commit` to spend time with a previous push. Is that not what you're looking for?
  • 0
    @kevbost I am kinda reluctant to commit
  • 0
    but for usual cases that works
  • 0
    git stage may be sufficient
  • 0
    @rookiemaverick I actually want to switch between versions of my code. Let's say a function, I can't ctrl+z all the way till it's back. Soo, staging and resetting don't seem to be helping much, or maybe I am failing to see.
  • 1
    @coookie If you're worried about messing up the git history, git branch and push to the new branch. Then you can switch to whatever version you want without fear of mucking anything up
  • 0
    @kevbost True, and that's a perfect solution which I followed initially. And for the weirdest reason I can't do that, there's a slackbot which posts these messages on the company public channel, and I really wouldn't want my test commits ending up there
  • 2
    @coookie That makes so much sense now. I definitely understand being weirded out by that.
  • 0
    Create git branch for development. Commit as often as needed - you switch between commits. One you are done, squash (rebase) all your commits and merge to master.
  • 0
    So I am thinking of using rsync and a bit of sauce to have what I want. Thoughts?
  • 0
    You can create a branch that only stays on your computer, then just merge that whenever you're ready.

    There's also git stash, although that may not be appropriate here.
  • 0
    @CombustLemons Now I feel really stupid
  • 1
    For the branch thing, just create a new branch normally (git checkout - b new_branch_name) which creates a new branch based off of the current branch, and then switches to that branch. When you're done, you just switch back to the main branch (git checkout main_branch_name) and then merge it (git merge new_branch_name). Although that will include all the commits you've made in the other branch, and I don't have much experience with squashing commits in git
  • 0
    @CombustLemons Thanks, I think I saw too much in a simple problem
  • 0
    No problem!
Add Comment