git 添加忽略文件 ,记住账号密码,忽略文件权限的变化

首先被忽略的文件一定不能是被天价斤索引的文件,所以如果已经被添加进索引,请使用命令

git rm --cached filename

删除这个文件,然后在 

git add .

git commit -m "info"

git push origin branchname

然后

nano .gitignore

在 .gitignore文件里面添加需要忽略的文件。

假设你当前在项目的根目录,使用以下命令,设定忽略文件

git config --global core.excludesfile ./.gitignore

到此就完成了

二 、git 忽略文件权限的变化

我们打开shell, cd到git根目录,执行命令: git config core.filemode false

然后我们再来执行git status就会发现少了很多需要变更的文件

建议设置到全局, 命令改为: git config --global core.filemode false








1.1 创建文件存储GIT用户名和密码

在%HOME%目录中,一般为C:\users\Administrator,也可以是你自己创建的系统用户名目录,反正都在C:\users\中。文件名为.git-credentials,由于在Window中不允许直接创建以"."开头的文件,所以需要借助git bash进行,打开git bash客户端,进行%HOME%目录,然后用touch创建文件 .git-credentials, 用vim编辑此文件,输入内容格式:

 

touch .git-credentials

vim .git-credentials

https://duanchangjiang:duan123456@github.com

 

 

1 创建文件存储GIT用户名和密码

在%HOME%目录中,一般为C:\users\Administrator,也可以是你自己创建的系统用户名目录,反正都在C:\users\中。文件名为.git-credentials,由于在Window中不允许直接创建以"."开头的文件,所以需要借助git bash进行,打开git bash客户端,进行%HOME%目录,然后用touch创建文件 .git-credentials, 用vim编辑此文件,输入内容格式:

touch .git-credentials

vim .git-credentials

https://{username}:{password}@github.com

(说明:此处应为https://username:password@github.com

2 添加Git Config 内容

进入git bash终端, 输入如下命令:

git config --global credential.helper store

执行完后查看%HOME%目录下的.gitconfig文件,会多了一项:

[credential]

    helper = store

重新开启git bash会发现git push时不用再输入用户名和密码

posted @ 2016-01-06 13:52  dcj890828  阅读(277)  评论(0编辑  收藏  举报