I want to pull a branch(master branch) to current repository, and replace the file that is existing, not just merge the file, the command git pull
is not appropriate to my needs, how to do that?
git checkout origin/master -- path/to/file // git checkout / -- path/to/file will checkout the particular file from the downloaded changes (origin/master). That's it!
So you've made a local commit affecting this file, and wish to discard your commit and just take the remote state without merging, is that right?
Assuming no-one else has seen your local commit (ie, you didn't push
and nobody pull
ed from your repo), you can just wind your local HEAD back to before the commit, and then do the pull.
NB. if you're not sure, run git fetch
first, and then git status
will tell you whether pull would be a fast-forward or a merge operation. Fast-forward means your local change is out of the picture.
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