如果您舍弃线上的文件,则在推送时选择强制推送,强制推送需要执行下面的命令
git push origin master -f
Git global settings:
git config --global user.name "dub"
git config --global user.email "2950509548@qq.com"
Create git repository:
mkdir test
cd test
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitee.com/www.dub.get/test.git
git push -u origin master
Existing repository?
cd existing_git_repo
git remote add origin https://gitee.com/www.dub.get/test.git
git push -u origin master
本文介绍了如何在Git中进行文件操作,包括创建仓库、添加和提交文件、远程仓库连接与初次推送,以及如何在现有仓库中进行强制推送。重点讲解了git push -f命令及其使用场景。
997





