Is there a way to do a git pull
that ignores any local file changes without blowing the directory away and having to perform a git clone
?
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
- Cannot commit changes with gitextensions
- git: retry if http request failed
This will fetch the current branch and attempt to do a fast forward to master:
For me the following worked:
(1) First fetch all changes:
(2) Then reset the master:
(3) Pull/update:
The command bellow wont work always. If you do just:
and so on...
To really start over, downloading thebranch and overwriting all your local changes, just do:
This will work just fine.
You just want a command which gives exactly the same result as
rm -rf local_repo && git clone remote_url
, right? I also want this function. I wonder why git does not provide such a command (such asgit reclone
orgit sync
), neither does svn provide such a command (such assvn recheckout
orsvn sync
).Try the following command:
If you are on Linux:
The for loop will delete all tracked files which are changed in the local repo, so
git pull
will work without any problems.The nicest thing about this is that only the tracked files will be overwritten by the files in the repo, all other files will be left untouched.
If you mean you want the pull to overwrite local changes, doing the merge as if the working tree were clean, well, clean the working tree:
If there are untracked local files you could use
git clean
to remove them. Usegit clean -f
to remove untracked files,-df
to remove untracked files and directories, and-xdf
to remove untracked or ignored files or directories.If on the other hand you want to keep the local modifications somehow, you'd use stash to hide them away before pulling, then reapply them afterwards:
I don't think it makes any sense to literally ignore the changes, though - half of pull is merge, and it needs to merge the committed versions of content with the versions it fetched.