Reputation: 1337
Hi guys I am new to git .
mistakenly did
git checkout
instead of
git checkout "file"
Now when I type git status
i get a message
nothing to commit
What can I do?
Upvotes: 0
Views: 1949
Reputation: 7862
I think that you are missunderstanding commit
and push
.
A commit
is like a pictures you are shooting with a camera. (you specifie what elements you want to add to this pictures with add
).
When you have taken this pictures, it will stay in you album (where nobody execpt you can see it).
How to :
git add <path_to_file_1>
git add <path_to_file_2>
git commit -m "my commit message to describe what i had done"
A push
is use to send you album to a repository.
How to :
git push <repo_name> <branchName>
When code is into a distant repository, it can be pulled to be merged with your code.
How to :
git pull <repo_name> <repoBranch>
What have you done.
As far as i understand, you have done the following sequence.
git branch my_first_branch
git checkout my_first_branch
..... working on your branch, modifying files .....
git add < all my files>
git commit -m "Hey this is my first commit"
git branch my_second_branch
# At this point, since you created your second_branch from first_branch, second branch contains all modifications made to first_branch, there are both the same.
git pull origin first_branch
# This should have failed unless you have push ????
git checkout
# this should have done nothing
Upvotes: 0
Reputation: 2286
You can revert to previous commit, ignoring any changes: git reset --hard HEAD
.
Where HEAD is the last commit in your current branch.
If you want to get remote gh-pages branch: git reset --hard origin/gh-pages
.
Upvotes: 1