A guess of the losing code issue
laihaotao opened this issue · 0 comments
There are two times we experienced the losing code issues, today I read an article about Git. Maybe be it will be the reason cause that problem.
As we know, when we create a file foo.java
we want to add it into the version control system and push to the remote repository, we need to use the following commands:
git add foo.java
git commit -m "add foo.java"
git push
After that, we keep programming in that foo.java
file, when we finished the second iteration, we may want to save our work locally. So we may say:
git add foo.java
git commit -m "finish the second iteration"
Keep doing the third iteration which is the final version of this feature, when we finished it we may want it to be pushed to the remote repository. But we may do it with some mistake which shown following:
git commit -m "finish the final version"
git push
Here we forget to execute the git add foo.java
command, so the foo.java
file pushed to the remote repository will be the second version (because you add it and commit it after the second iteration) instead of the final version. If you doing that, the remote repository will be the second version and your local machine will be the final version.