git的学习笔记
来源:互联网 发布:最燃的一句话 知乎 编辑:程序博客网 时间:2024/05/22 10:21
git 学习指南:
http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/001373962845513aefd77a99f4145f0a2c7a7ca057e7570000
git学习指南
http://backlogtool.com/git-guide/cn/
git的基本命令:
把一个文件放到Git仓库只需要两步:
1.git add file
2.git commit -m "explain"
查看当前仓库的状态:
git status
分三种情况
1.仓库文件没有改动,没有变化
$ git status
# On branch master
nothing to commit, working directory clean
2.仓库文件有变动,1.例如你修改了文件的内容,需要commit 2.你添加的新的文件需要commit
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working
#
# modified: s.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
很明显修改了s.txt的内容。
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# status.txt
nothing added to commit but untracked files present (use "git add" to track)
没有跟踪的文件,status.txt是先添加的文件
对比文件修改和修改之前的差异内容
git diff file
版本回退(注释很重要)
1.查看所有版本信息
git log
2.回退到上一个版本
上一个版本就是HEAD^,上上一个版本就是HEAD^^,当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100
git reset --hard HEAD^
git reset --hard 版本号
撤销修改
当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout -- file
当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD file,就回到了场景1,第二步按场景1操作。
删除一个文件
git rm file 用于删除一个文件
合并分支:
查看分支:git branch
创建分支:git branch <name>
切换分支:git checkout <name>
创建+切换分支:git checkout -b <name>
合并某分支到当前分支:git merge <name>
删除分支:git branch -d <name>
http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/001373962845513aefd77a99f4145f0a2c7a7ca057e7570000
git学习指南
http://backlogtool.com/git-guide/cn/
git的基本命令:
把一个文件放到Git仓库只需要两步:
1.git add file
2.git commit -m "explain"
查看当前仓库的状态:
git status
分三种情况
1.仓库文件没有改动,没有变化
$ git status
# On branch master
nothing to commit, working directory clean
2.仓库文件有变动,1.例如你修改了文件的内容,需要commit 2.你添加的新的文件需要commit
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working
#
# modified: s.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
很明显修改了s.txt的内容。
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# status.txt
nothing added to commit but untracked files present (use "git add" to track)
没有跟踪的文件,status.txt是先添加的文件
对比文件修改和修改之前的差异内容
git diff file
版本回退(注释很重要)
1.查看所有版本信息
git log
2.回退到上一个版本
上一个版本就是HEAD^,上上一个版本就是HEAD^^,当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100
git reset --hard HEAD^
git reset --hard 版本号
撤销修改
当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout -- file
当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD file,就回到了场景1,第二步按场景1操作。
删除一个文件
git rm file 用于删除一个文件
合并分支:
查看分支:git branch
创建分支:git branch <name>
切换分支:git checkout <name>
创建+切换分支:git checkout -b <name>
合并某分支到当前分支:git merge <name>
删除分支:git branch -d <name>
0 0
- git的学习笔记
- git的学习笔记
- Git学习笔记---git的初始化
- Git学习笔记二:Git的使用
- GIT初学的学习笔记
- 我的git学习笔记
- git的学习笔记整理
- 关于git的学习笔记
- 我的Git学习笔记
- 我的Git学习笔记
- Git hooks 的学习笔记
- git 学习的简单笔记
- Git的理解学习笔记。
- git的学习笔记1
- 【git】git学习笔记
- 学习git的相关疑问及笔记
- git学习笔记(文件的提交)
- git的学习笔记(分支管理)
- SVN版本管理工具介绍
- python3里使用selenium webdriver自动化测试
- 分数类的运算符重载
- leecode_309 Best Time to Buy and Sell Stock with Cooldown
- window7 已经分好区的硬盘如何再次分区?
- git的学习笔记
- Android studio开发环境搭建教程与软件安装教程(从零开始学android)
- Machine Learning-Recommender Systems(推荐系统)
- phpcms v9如何给父级单页栏目添加内容?
- 迁户风波
- Android APP架构心得
- Android中的“再按一次返回键退出程序”功能实现
- exec和source
- 工程师精神一定程度上就是精益求精的工匠精神