您的位置:首页 > 其它

Drupal--Day7:git学习笔记

2017-07-12 08:21 375 查看

Git的使用

 详细的使用介绍:http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

Git:备份代码。

1、创建版本库(window10)
版本库又名仓库,英文名repository,你可以简单理解成一个目录,这个目录里面的所有文件都可以被Git管理起来,每个文件的修改、删除,Git都能跟踪,以便任何时刻都可以追踪历史,或者在将来某个时刻可以“还原”。

在需要备份项目的根目录下,右击,点击git bash here,进入类似控制台的界面,
命令端,进入项目根目录,输入:git init 初始化一个仓库
ls -a(可以看到文件夹内所有文件名,如果只输入ls,则看不到.git文件, 因为这个目录默认是隐藏的。所以,-a的作用是看到隐藏的文件)



git status  看到需要备份的文件的状态,用git add "文件名"。再次用git status 查看文件。如果文件名为红色,则备份失败,需要在次操作。



以上显示表示操作成功。

(产生的问题:
 warning: LF will be replaced by CRLF in sites/ZX.dd/files/.htaccess.

The file will have its original line endings in your working directory.

warning: CRLF will be replaced by LF in sites/ZX.dd/files/2017-07/web.txt.

以上是warning,因为换行符的转换,导致的,所有可以不关注。但是如果这个warining一直出现,也不能按“”CTRL+C“”强制停止,需要等到输出结束。

不然会产生以下错误:
 fatal: Unable to create 'D:/ZX/.git/index.lock': File exists.

If no other git process is currently running, this probably means a

git process crashed in this repository earlier. Make sure no other git

process is running and remove the file manually to continue.

解决办法,参考网址:http://blog.csdn.net/lysc_forever/article/details/42835203

)

git diff  

git add file1 file2 ...依次添加文件

git commit



2、上传远程服务器

请自行注册GitHub账号

第1步:创建SSH Key。在用户主目录下,看看有没有.ssh目录,如果有,再看看这个目录下有没有id_rsa和id_rsa.pub这两个文件,如果已经有了,可直接跳到下一步。如果没有,打开Shell(Windows下打开Git Bash),创建SSH Key:

ssh-keygen -t rsa -C "472013816@qq.com"





首先,登陆GitHub,然后,在右上角找到“Create a new repo”按钮,创建一个新的仓库

 git remote add origin git@github.com:dev-comm/learngit.git

 git push -u origin master

3、从远程服务器克隆

 git clone git@github.com:michaelliao/gitskills.git
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: