Once you know the hash of the stash commit you dropped, you can apply it as a stash:
git stash apply $stash_hash
Or, you can create a separate branch for it with
git branch recovered $stash_hash
After that, you can do whatever you want with all the normal tools. When you’re done, just blow the branch away.
Finding the hash
If you have only just popped it and the terminal is still open, you will still have the hash value printed by git stash pop
on screen (thanks, Dolda).
Otherwise, you can find it using this for Linux, Unix or Git Bash for Windows:
git fsck --no-reflog | awk '/dangling commit/ {print $3}'
...or using Powershell for Windows:
git fsck --no-reflog | select-string 'dangling commit' | foreach { $_.ToString().Split(" ")[2] }
This will show you all the commits at the tips of your commit graph which are no longer referenced from any branch or tag – every lost commit, including every stash commit you’ve ever created, will be somewhere in that graph.
The easiest way to find the stash commit you want is probably to pass that list to gitk
:
gitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )
...or see the answer from emragins if using Powershell for Windows.
This will launch a repository browser showing you every single commit in the repository ever, regardless of whether it is reachable or not.
You can replace gitk
there with something like git log --graph --oneline --decorate
if you prefer a nice graph on the console over a separate GUI app.
To spot stash commits, look for commit messages of this form:
WIP on somebranch: commithash Some old commit message
Note: The commit message will only be in this form (starting with "WIP on") if you did not supply a message when you did git stash
.
In the simplest terms, git pull
does a git fetch
followed by a git merge
.
You can do a git fetch
at any time to update your remote-tracking branches under refs/remotes/<remote>/
. This operation never changes any of your own local branches under refs/heads
, and is safe to do without changing your working copy. I have even heard of people running git fetch
periodically in a cron job in the background (although I wouldn't recommend doing this).
A git pull
is what you would do to bring a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.
From the Git documentation for git pull
:
In its default mode, git pull
is shorthand for git fetch
followed by git merge FETCH_HEAD
.
Best Answer
Create a new empty symfony project
Generate a new bundle
(for example
src/Company/DemoBundle
)Init your github repository in
src/Company/DemoBundle
Add a composer.json file
src/Company/DemoBundle/composer.json
:Now you have the base structure of your bundle
Use it in another project
composer.json:
Do:
app/AppKernel:
Work on it
src/Company
folder, then manually install itConclusion
You can develop and test your bundle in your first project and use it with github and composer in your second project.