I have done "git reset --soft HEAD^"
to get rid of some files from commit, but I have some problems.
Command "git status"
shows list of files (modified -- green). But if I want to shows changes with command "git diff"
git shows nothing.
Also when I trying revert changes by "git checkout <FILE>"
it gives no result.
If I open any of these files I see my changes.
Your file is already staged to be committed. You can show it's diff using the --cached option of git. To unstage it, just do what git status suggests in it's output ;) You can check The Git Index For more info.
These changes mean that metadata about your file changed, however the content of your file did not. If you're working in a group, this may start to intefere with pushes or just add noise to your commits.
The main difference between the commands is that git diff is specially aimed at comparisons, and it's very powerful at that: It can compare commits, branches, a single file across revisions or branches, etc. On the other hand, git status is specifically for the status of the working tree.
The git diff command returns a list of all the changes in all the files between our last commit and our current repository. If you want to retrieve the changes made to a specific file in a repository, you can specify that file as a third parameter.
I have done "git reset --soft HEAD^" to get rid of some files from commit, but I have some problems. Command "git status" shows list of files (modified -- green).
This expected behavior according to documentation:
--soft
Does not touch the index file or the working tree at all (but resets the head to , just like all modes do). This leaves all your changed files "Changes to be committed", as git status would put it.
In future use --mixed
flag to move files to not-staged area
git reset --mixed HEAD^
OR just:
git reset HEAD^
because --mixed
is used by default
The current situation may be fixed by:
git reset HEAD -- <file>
This will make a file unstaged. Or without -- <file
to apply to all files.
Or use git diff --cached
to show diff of staged files.
Also when I trying revert changes by "git checkout " it gives no result.
git checkout <FILE>
works if file is unstaged.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With