频道栏目
首页 > 资讯 > Linux > 正文

Git常用的几个命令

17-09-06        来源:[db:作者]  
收藏   我要投稿

实习的时候接触到Git版本控制系统,本篇博客旨在记录常用的几个操作以供交流学习。

一、创建版本库:

首先创建空目录:mkdir <目录名>

cd <目录名>

pwd //显示当前目录

把空目录变成Git可以管理的仓库:git init

二、把文件添加到版本库:

首先在上次创建的目录或其子目录下新建一个demo.txt文档

然后把该文档添加到Git库:

git add demo.txt(git add -A 上传所有修改 git add . 上传所有)

再把文件提交到Git库:

git commit -m "wrote a demo file" //-m "xxx"是提交说明,引号内可输入任意参数

三、版本回退

git reset --hard HEAD^ //HEAD表示当前版本,HEAD^表示当前版本的前一个版本

git reset --hard commit_id 回退到指定id的版本

四、查看历史

git log:查看提交历史

git reflog:查看命令历史

五、查看状态:

git status

六、克隆项目到本地:

git clone "项目地址"

七、上传项目:

git pull--->git add .--->git commit -m"说明"--->git push

八、如果报错:

fatal: Unable to create '/xxx/xx/.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.

进入git命令行执行:rm -f ./.git/index.lock

相关TAG标签
上一篇:面向对象的三大特性
下一篇:python中类的方法介绍
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站