$ git init
$ git add -A
$ git commit -m "提示语"
注意请把下面的 <username>
替换为你的用户名。
$ git remote add origin git@github.com:<username>/projectname.git
$ git push -u origin master
克隆远程版本仓库到本地:
$ git clone https://github.com/username/projectname.git
查看远程仓库的信息:
$ git remote -v
将远程版本库中的最新代码同步到本地:
$ git pull origin master
git remote show origin
还原修改文件到原始状态:
$ git checkout .
清理项目(先还原再清理):
$ git clean -f -d
命令 git clean 作用是清理项目,-f 是强制清理文件的设置,-d 选项命令连文件夹一并清除。
删除git:
$ rm -rf .git
禁用自动转换:
$ git config --global core.autocrlf false
windows中的换行符为 CRLF, 而在linux下的换行符为LF,所以在执行add . 时出现提示warning: LF will be replaced by CRLF。
.gitignore
我们在上传图片的时候,程序自动创建了 public/uploads/images/avatars/ 目录,此文件夹下的文件皆为用户上传的头像文件,我们需要防止这些文件被纳入 Git 版本控制器中,可以利用 Git 的 .gitignore 机制来实现.
新建一个.gitignore文件写入
*
!.gitignore
上面的两行代码意为:当前文件夹下,忽略所有文件,除了 .gitignore文件。