How to keep uncommitted work in a git clone

Jeremy Lavergne jeremy at lavergne.me
Thu Nov 3 19:25:25 PDT 2016


Religiously use `git status`, and perhaps update your shell prompt to
reflect it as well: branch name, unstaged changes, staged changes, etc.
Consider looking on Google for prompts that incorporate functions like
__git_ps1:
    GIT_PS1_SHOWDIRTYSTATE="1"
    GIT_PS1_SHOWUNTRACKEDFILES="1"
    PS1="\h:\W \u$BLUE\$(__git_ps1 \" [%s]\")$DEFAULT\$ "


The current working tree is by default unstaged. You must select what to
stage, or explicitly indicate files during actions. For example, these
are equivalent commands for commits changes to foo.txt (a file already
in the repo):

 1    echo "asdf" >> foo.txt
      git add foo.txt
      git commit -m "adding foo"

 2    echo "asdf" >> foo.txt
      git commit foo.txt -m "adding foo"


That first form is how you commit only explicit files while leaving more
for a subsequent commit. Same idea for `git add -p` for parts of files.
Once things are staged, leaving off filenames means the actions apply to
the staged changes.



Regarding the stash situation:  The nice thing about git is won't do
anything destructive without you forcing it.

Checkout the stashes and see if you perhaps made a second one?
   git stash list  # (or otherwise `git help stash`)
   git show stash@{0}


So your changes are very likely still there: either as a second stash,
or perhaps conflicting with the new working tree.

git status :-)


On 11/03/2016 09:56 PM, Ryan Schmidt wrote:
> With Subversion, I was accustomed to keeping changes in my working copy that I was not ready to commit yet.
> 
> Git doesn't let me do that. It complains and tells me to git stash and later git stash pop.
> 
> Well, I tried that. I git stashed, then made changes to curl and committed them, and later when I tried to git stash pop, my other changes that I had in my git clone were not restored. I have no idea where they are now.
> 
> I can get these particular changes back from my old Subversion working copy, but I don't understand how I'm meant to work with git when I have changes that I'm not ready to commit yet, yet there are other changes I need to make and commit elsewhere within that same clone.



More information about the macports-dev mailing list