According to the git documentation, git pull
will fetch the current branch and then run git merge
to merge the changes. After a colleague made and pushed his changes to the server, I went to look for them.
Firstly, I made the changes that I had:
git add src git add war
Running git status
confirmed that my changes were set to be perfect. Then I ran:
git commit -m "Another commit to work on scrolling"
Subsequently, I removed the changes:
git pull
This showed me some warnings:
remote: Counting objects: 31, done. remote: Compressing objects: 100% (16/16), done. remote: Total 16 (delta 13), reused 3 (delta 0) Unpacking objects: 100% (16/16), done. From github.com:FullCreative/Loop + 3f00b3f...2e09a49 master -> master (forced update) Warning: fetch updated the current branch head. Warning: fast-forwarding your working tree from Warning: commit 3f00b3f6cb6ed6beddb16baa92f1beaa82b6944c. Already up-to-date.
Finally, I pushed my changes - or rather tried to push them - to the server:
git push
Question:
Now, why did it delete all my changes? Even files that my colleague did not modify were deleted from my working directory.
Console exit:
For thoroughness, the console log from my terminal is presented below. This shows the commands that I ran and the output of these commands:
jem@jem-VPCF136FM :~$ cd git jem@jem-VPCF136FM :~/git$ l Loop/ Loop-1-18.tar.gz jem@jem-VPCF136FM :~/git$ cd Loop jem@jem-VPCF136FM :~/git/Loop$ l Loop/ README readme.textile jem@jem-VPCF136FM :~/git/Loop$ l Loop/ README readme.textile jem@jem-VPCF136FM :~/git/Loop$ cd Loop jem@jem-VPCF136FM :~/git/Loop/Loop$ l src/ war/ jem@jem-VPCF136FM :~/git/Loop/Loop$ git add src jem@jem-VPCF136FM :~/git/Loop/Loop$ git status
UPDATE:
I can access my commits by checking the hash:
git checkout 3f00b3f6cb6ed6beddb16baa92f1beaa82b6944c
So why are they not included in my push to server?
UPDATE # 2
git reflog
:
3f00b3f HEAD@ {0}: checkout: moving from master to 3f00b3f6cb6ed6beddb16baa92f1beaa82b6944c 2e09a49 HEAD@ {1}: checkout: moving from 3f00b3f6cb6ed6beddb16baa92f1beaa82b6944c to master 3f00b3f HEAD@ {2}: checkout: moving from master to 3f00b3f6cb6ed6beddb16baa92f1beaa82b6944c 2e09a49 HEAD@ {3}: pull : forced-update 3f00b3f HEAD@ {4}: commit: Another commit to work on scolling 2927f85 HEAD@ {5}: commit: Removed Alert. 07deceb HEAD@ {6}: commit: Added url pattern to the servlet to get rid of the error. f2d48bb HEAD@ {7}: commit: iJames took over again! 88fb39c HEAD@ {8}: pull : fast-forward a22893e HEAD@ {9}: commit: Committing a very important change to intro.css. Not! ac19755 HEAD@ {10}: pull : fast-forward d2a401d HEAD@ {11}: commit: This is a test 85a6328 HEAD@ {12}: commit: Modified gitignore yet again. 251f557 HEAD@ {13}: commit: Committing the classpath. Hope it works. 4e7a428 HEAD@ {14}: checkout: moving from local_master to master 97aa2d7 HEAD@ {15}: checkout: moving from master to local_master 4e7a428 HEAD@ {16}: commit: Added Admin panel for making system changes. Modified the title and description so they go into edit 38dc2fa HEAD@ {17}: commit: Added notifications and real time comet. bc2f950 HEAD@ {18}: commit: Real time updates and chrome notifications. bc2f950 HEAD@ {19}: commit: Adding TagSubscription class. 5e696f4 HEAD@ {20}: commit: Bulk delete, fixed delete bug, tagging features and subscriptions. Added more server-side caching. Ad 7b41cc2 HEAD@ {21}: commit: adding dropdown plugin files d9e3716 HEAD@ {22}: commit: Added filter list to top, made dynamic, and deployed to 2-20. e256d21 HEAD@ {23}: commit: Cleaned up the HTML code. d9e3716 HEAD@ {24}: commit: Third time is a charm. 3e0863f HEAD@ {25}: commit: Here is the 2nd commit for tag-it. 13e70c8 HEAD@ {26}: commit: Added the tag-it tags to the application and connected to the database. 0893615 HEAD@ {27}: commit: Deployed 2-7 and made default version. 0073e04 HEAD@ {28}: commit: Deployed to 2-7 and made the default version. Finalized mobile form, although the error class shadow 0073e04 HEAD@ {29}: commit: test 4351a93 HEAD@ {30}: commit: Added notifications for comments and cleaned up mobile form. 5674cfb HEAD@ {31}: commit: Added Developer API call to switch users for @loopround.com users. a22808f HEAD@ {32}: commit: updating 8fa1a39 HEAD@ {33}: commit: updating the repository 8fa1a39 HEAD@ {34}: commit: Deployed to http:
.git / configuration file
[core] repositoryformatversion = 0 filemode = true logallrefupdates = true autocrlf = false [remote "origin"] url = git@github.com :FullCreative/Loop.git fetch = +refs/heads/*:refs/heads/* push = refs/heads/*:refs/heads/* [branch "master"] remote = origin merge = refs/heads/master