git本地删除文件后如何从服务器拉下来,git免密码和删除本地文件后 Git从远程仓库重新获取...

linux服务器git pull/push时提示输入账号密码之免除设置

1、先cd到根目录,执行git config --global credential.helper store命令

# git config --global credential.helper store

2、执行之后会在.gitconfig文件中多加红色字体项

[user]

name = 天明

email = xxxx@xxxx.com

[credential]

helper = store

3、之后cd到项目目录,执行git pull命令,会提示输入账号密码。输完这一次以后就不再需要,并且会在根目录生成一个.git-credentials文件

[root@iZ25mi9h7ayZ test]# git pull

Username for 'https://git.oschina.net': xxxx@xxxx.com

Password for 'https://xxxx@xxxx.com@git.oschina.net':

[root@iZ25mi9h7ayZ ~]# cat .git-credentials

https://Username:Password@git.oschina.net

4、之后pull/push代码都不再需要输入账号密码了~

删除本地文件后,想从远程仓库中从新Pull最新版文件。

Git提示:up-to-date,但未得到删除的文件

原因:当前本地库处于另一个分支中,需将本分支发Head重置至master.

git checkout master

git reset --hard

git 强行pull并覆盖本地文件

git fetch --all

git reset --hard origin/master

git pull