What you describe is similar to git stash
, except since with git you have your own repository (not just a single one on a server), only you can get that change set back.
The general idea is:
# do some stuff
vim foo/bar.c
# stash away your changes
git stash
# do some other things...
# retrieve your changes
git stash pop
If you wanted someone else to have access to this changeset, you’d want to instead commit it to a working branch:
# make yourself a branch
git checkout -b temp-featureA
# commit to it
git add foo/bar.c; git commit
# now you push this branch (or they could just fetch straight from you)
git push origin temp-featureA
# Now, in someone else's repo:
# Fetch updates
git fetch origin
# Make a branch tracking the remote branch
git branch temp-featureA origin/temp-featureA
# Either check it out:
git checkout temp-featureA
# or cherry-pick it, to apply the changes somewhere else:
git cherry-pick temp-featureA
# or, if it's multiple commits, rebase it!
git rebase --onto my-branch start-of-featureA temp-featureA