Really the ideal way to do this is to not use pull
at all, but instead fetch
and reset
:
git fetch origin master git reset --hard FETCH_HEAD git clean -df
(Altering master
to whatever branch you want to be following.)
pull
is designed around merging changes together in some way, whereas reset
is designed around simply making your local copy match a specific commit.
You may want to consider slightly different options to clean
depending on your system’s needs.
Related Posts:
- How do I ignore an error on ‘git pull’ about my local changes would be overwritten by merge?
- Why does git say “Pull is not possible because you have unmerged files”?
- How do I ignore an error on ‘git pull’ about my local changes would be overwritten by merge?
- Why does git say “Pull is not possible because you have unmerged files”?
- There is no tracking information for the current branch
- How do I ignore an error on ‘git pull’ about my local changes would be overwritten by merge?
- Files not updating using ‘git pull’
- git checkout tag, git pull fails in branch
- Why does git say “Pull is not possible because you have unmerged files”?
- Is it possible to pull just one file in Git?
- fatal: could not read Username for ‘https://github.com’: No such file or directory
- Git pull – Please move or remove them before you can merge
- How to `git pull` while ignoring local changes?
- Git push requires username and password
- What is git tag, How to create tags & How to checkout git remote tag(s)
- What is the best (and safest) way to merge a Git branch into master?
- How can I switch to another branch in git?
- GitHub: Permission denied (publickey). fatal: Could not read from remote repository
- Updates were rejected because the tip of your current branch is behind its remote counterpart
- Git: How do I force “git pull” to overwrite local files?
- git stash apply version
- Git fetch remote branch
- Practical uses of git reset –soft?
- Updating a local repository with changes from a GitHub repository
- How do I remove a submodule?
- Git push results in “Authentication Failed”
- Git push results in “Authentication Failed”
- Download single files from GitHub
- Undoing a git rebase
- How to resolve merge conflicts in a Git repository
- Ignoring directories in Git repositories on Windows
- How can I merge multiple commits onto another branch as a single squashed commit?
- How to find my GitHub username so that I can be found via the URL?
- Create Git branch with current changes
- github website publish cannot publish unborn HEAD
- Why do I have to “git push –set-upstream origin
“? - How do you create a remote Git branch?
- Move the most recent commit(s) to a new branch with Git
- How do I resolve git saying “Commit your changes or stash them before you can merge”?
- rejected master -> master (non-fast-forward)
- How do you stash an untracked file?
- How to name and retrieve a stash by name in git?
- Create a tag in a GitHub repository
- Filename too long in Git for Windows
- What is the difference between git rm –cached and git reset
? - How can I delete a file from a Git repository?
- Git: Could not resolve host github.com error while cloning remote repository in git
- What does git rev-parse do?
- Make an existing Git branch track a remote branch?
- git – pulling from specific branch
- What is the difference between ‘git pull’ and ‘git fetch’?
- GitHub: invalid username or password
- Why do I have to “git push –set-upstream origin
“? - Stash just a single file
- How can I reset or revert a file to a specific revision?
- How do I provide a username and password when running “git clone [email protected]”?
- “*** Please tell me who you are.” when using SSH key
- master branch and ‘origin/master’ have diverged, how to ‘undiverge’ branches’?
- Pull request vs Merge request
- What is the difference between `git merge` and `git merge –no-ff`?
- git pull from master into the development branch
- Clone A Private Repository (Github)
- Is there a “theirs” version of “git merge -s ours”?
- Your configuration specifies to merge with the
from the remote, but no such ref was fetched.? - How to clone a specific Git tag
- ! [rejected] master -> master (fetch first)
- How to git add a whole folder
- Heroku: How to change a Git remote on Heroku
- Updates were rejected because the remote contains work that you do not have locally
- Undoing a ‘git push’
- How to replace local branch with remote branch entirely in Git?
- Git diff against a stash
- What’s the significance of the “No newline at end of file” log?
- How to revert a “git rm -r .”?
- Git update submodules recursively
- Do a “git export” (like “svn export”)?
- What does git push origin HEAD mean?
- How do I set up Eclipse/EGit with GitHub?
- Repository size limits for GitHub.com
- How to compare a local Git branch with its remote branch
- git push origin master does not work
- Git clone verbose output?
- Could not create work tree dir ‘example.com’.: Permission denied
- Is there a git-merge –dry-run option?
- How to answer the git prompt in npm init for a local repo
- Add all files to a commit except a single file?
- How to update Git clone
- Git says “Automatic merge failed”, what does it mean?
- Sourcetree adding files in global .gitignore, not in repository .gitignore
- git pull remote branch cannot find remote ref
- How to configure git bash command line completion?
- How do I change the default location for Git Bash on Windows?
- How to stop tracking and ignore changes to a file in Git?
- WordPress and Git – What folders should I track?
- Pull latest stable release via git [closed]
- Why do the Roots theme CSS files not load (404)?
- Version control with a team of non-developers
- Painless way to track remote Git repo for WordPress updates
- Questions about Git and WordPress [duplicate]
- WordPress on git – need help with configuration