Git Troubleshoooting Wiki
Let's all share our favorite git troubleshooting tips and resources. As it says, be bold and edit it.
Approaches to explore the repository without messing with your current work area
- Save your work into a branch and then explore
git add .
git checkout -b my_project_9993994_01
git commit -m "State of my work area before exploring"
Now checkout and explore the repository any way you want. You can come back to just where you were with
git checkout my_project_9993994_01 - Clone into a different place and experiment there! You can have all the clones you want.
cd /tmp
git clone git://git.drupal.org/project/drupal playarea
cd playarea
... dostuff ... - Use
git stash saveto store your current changes
git status
git add .
git stash save "my stuff I'm working on"
[.... do whatever you want ...]
[come back to the branch you were working on]
git stash list
git stash apply
and you're ready to get going again, right where you left off.
The first is probably the most robust workflow, but the other two are useful techniques.
You want to recover files that have been deleted in the current branch or revision
- Just explore using "Approaches to explore the repository" above.
- Most of the time you really want to know what's changed, so just use git diff:
git diff <revision_or_branch_or_tag> -- path/I/want/to/know/aboutor, to see the difference in a particular directory between two revisions:
git diff HEAD^^ HEAD^^^ -- path/I/want/to/know/about
Your whole local repository has been ruined somehow but you have files you're working on
Start over. Clone a repo and apply your files to it.
git clone git://git.drupal.org/project/<yourproject> new_yourproject_checkout
cd your_project_checkout
cp -r /old/directory/* . #won't copy .git/don't copy the .git
git checkout -b bring_in_hurt_repo
git add .
git status
git commit -m "my working files from when everything went to hell"Note: If the git.drupal.org hashes ever do change overnight for some reason before real deployment, an approach like this will allow a return to sanity.