git pull -f (git force pull)
| 03-Dec-2012 | Posted by Sonia Hamilton under Git |
Git has a “force push” option (git push -f remote branch), but it doesn’t have a “force pull” option (like git pull -f remote branch).
This works:
% git fetch remote branch % git reset --hard FETCH_HEAD % git clean -df
Or, as a function for your bash/zsh config file:
gpuf () {
# git pull -f $1
remote=${1:?"need remote to force pull from"}
current_branch=$(git symbolic-ref -q HEAD)
current_branch=${current_branch##refs/heads/}
current_branch=${current_branch:-HEAD}
if [ $current_branch = 'HEAD' ] ; then
echo
echo "On a detached head. Exiting..."
exit 1
fi
git fetch $remote $current_branch
git reset --hard FETCH_HEAD
git clean -df
}
Share This
[...] 2012 Tagged: Blog: Desenvolvimento Interessante esta dica que eu achei neste blog aqui. O git, de acordo com a dica, possui uma função de forçar o push ( git push -f remote branch ), [...]