I thought I know simple features of git
until I began work with other contributors:)
The situation is as follows:
- I pulled source code from repository (from commit:
2c49868
). - I changed some of the code and I noticed that the changed app doesn't worked. I didn't use
git commit
and I didn't usegit push
. - I would like to restore the source code before the change (from commit:
2c49868
).
What should I do to not spoil the repo?
I'm going to do:
git fetch --all
git reset --hard origin/master
Is it correct or maybe is better way to do this?
EDIT:
It turns out that:
- I pushed the source code with new commit: (
c6a7e5f
) on the service computer at work yesterday. - I change some of the code locally (I didn't use
git commit
and I didn't usegit push
. - I went home.
- I pulled the source code (from commit:
c6a7e5f
) on the another, personal computer. - I changed the source code and added/deleted some of files at home, used
git commit
(commit:2c49868
) andgit push
. - Today, I came back to work (to service computer). In my IDE I see the changes from the second point and I would like to have the source code from the fifth point (commit:
2c49868
).
In conclusion: I don't want to have local changes (from the second point) on the service computer because they are still here, but I want to have the newest source code from this repo on the service computer.
I am asking for your understanding.