【开发工具】Git版本控制及报错处理

学习的时候接触到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
发布了28 篇原创文章 · 获赞 12 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/Carson_Chu/article/details/77861814