天天看点

初次使用github

加单个文件,并提交

$ git add README

$ git commit -m 'second commit'

$ git remote add origin [email protected]:yourName/yourRepo.git

$ git push -u origin master #[-u | --set-upstream]

加所有文件

$ git add -A #-A是all的意思

$ git commit -m 'second commit' #-m是给出message,不是modify

$ git push -u origin master

修改文件后

git add -u #-u是 update的意思

git status

git commit -m 'third test'

git push -u origin master

利用.gitignore来忽略文件。

在.git文件夹里新建.gitignore文件。

可以写文件夹,也可以写文件名。

.gitignore

*.cache

*.suo

如果之前已经将一些文件用git add进行跟踪了,需要利用git rm –cached -r <path>先将其删除。

git rm --cache -r .httpd.conf

git rm --cache -r project.suo

之后再用git add -u.

这样就不会跟踪这些文件了。

你可以运行`git reset FILE`, 他可以将File从当前要提交的文件集合中移除。而且不会改变任何信息。

git 删除已删除文件

Update: If you only want to add deleted files, try:

git ls-files --deleted | xargs git rm | git commit

git ls-files --modified

git ls-files --others