0

I working with a fork and I made a temporary fix but I don't want to make a commit yet since the changes aren't finished.

I'm going to use "git stash" to save those changes temporarily and then continue working in another branch. What I'd like to know is if there is a way to save those changes in my repo on github like a backup and then getting them back to continue working on them without any commit until finishing them. Otherwise those changes are only in my computer with the risk to lose them. Thanks

David
  • 169
  • 5
  • 14
  • With git stage you mean git stash? – sandesh dahake Feb 16 '19 at 09:55
  • Oh yes, sorry I mean git stash – David Feb 16 '19 at 09:57
  • You can squash/overwrite/pick existing commits in your pushed working-branch by using e.g git rebase -i and git push -f (force-push) afterwards – nologin Feb 16 '19 at 09:58
  • @nologin based on my understanding of question David want to keep his temp changes on github to avoid risk of losing them on local machine. Stash copy will be always on the local machine and no backup will be maintained on the github. – sandesh dahake Feb 16 '19 at 10:05
  • Yes, that's right. I know that I could use a rebase but I'd like to know if there is a way to push them after a "git stash" without a commit – David Feb 16 '19 at 10:09
  • git stash stores your changes locally without committing them. You can just push committed changes. I suggest @sandeshdahake s way. Use separate branches for different fixes/changes/features and push them. – nologin Feb 16 '19 at 11:04

1 Answers1

2

I will prefer to create branch for your temporary fix and push it to github. Checkout new branch and work on that. Steps:

  1. Create a temporary branch
  2. Commit your fix and push to github
  3. Work on any other branch you wish
  4. Later Merge temp branch to your new / any other branch

No changes will be pushed to github unless you commit them.

sandesh dahake
  • 1,028
  • 7
  • 16
  • I understand now. My problem was to believed that I could push my temporary fix with git stash but I like your way to push my changes to github and then make a merge and probably a rebase to avoid having ugly code in my final commit. Thanks – David Feb 16 '19 at 15:26