git 学习笔记
来源:互联网 发布:淘宝清关信息在哪设置 编辑:程序博客网 时间:2024/05/16 18:48
开发中经常使用的git命令
git init 创建git repository,在当前文件夹中会看到.git文件夹
git status 在该目录下新创建的文件状态是untracked files.
git add filename 将新文件放在staging里面 然后使用git status 可以看到该文件状态变成 changes to be committed.
git checkout --file把文件在工作区的修改全部撤销。
git commit -m "comment" 然后就是可以使用git commit -m "comment"将处于staging状态的文件提交。commit只是提交到本地。
git add '*.txt' 使用通配符可以将多个文件一起提交到staging状态。
git log 会看到commit 文件的提交状态。
git remote add branch <link>. 把local repository放到 git server上,需要使用git remote add branch <link>. Github的功能就是一个git server,我们不在需要自己配置一个git server了。将本地仓库关联到一个远程仓库。此种方法适用于本地库已经准备好,将本地库关联到远程库。
另一种适用git clone 从已知的远程库克隆一个本地库。
git push -u origin master push命令是用于告诉我们以后的本地操作要push到哪里。 -u是要它记住当前的设置。
返回状态:Branch master set up to track remote branch master from origin.即推送的时候,要指定本地分支,这样,Git就会把该分支推送到远程库对应的远程分支上。
多人协作时,git push可能会存在冲突。当出现冲突的时候,可以先把远程代码pull到本地,merge,然后在push.
怎样区别远程库和本地库的分支和版本库呢??它们之间是什么样的关联关系呢?
git pull origin master 使用pull命令把远程库中提交的更该,更新到本地。
git diff HEAD --read.me
git stash 把当前工作现场储藏起来,等以后回复现场后继续工作。这样我们就可以创建一个新分支,在这个分支上解决另一个问题。
git stash list 查看刚才保存的现场
恢复现场的操作:
git stash apply 之后使用 git stash drop,先恢复现场然后删除现场
git stash pop,恢复现场的同时把stash内容也删除了
git branch 列出所有分支,当前分支前面会加“*”。分支指向不同版本,HEAD指向分支。
git merge dev 合并dev分支到master分支。执行“快速合并” git push发生冲突的时候,同样需要git merge的冲突解决方法来解决。
git status 会显示有冲突的文件,我们需要手动修改这些有冲突的文件。
git branch -d dev删除brach 分支。
工作中常用的命令:查看工作区和版本库里面最新版本的区别。
git checkout branchname 切换到branchname这个分支上。
Git checkout -b myTest 或者是 git checkout -b origin/master <my-topic>
创建一个新的topic branch,并切换。相当于下面两条命令:
git branch myTest
git checkout myTest.(如果myTest分支已经存在,则是切换到这个分支)
Git add XXX
Git commit -s
git push originHEAD:refs/for/stable_kbrs1pv_0715/myTest
将本地的更改更新到git server上,也就是gerrit,也可以说是review server.
gerrit的比较好的介绍文档:http://www.cnblogs.com/snow-backup/p/4990577.html
git commit -s --amend
git remote 查看远程库信息
- 【git】git学习笔记
- Git学习笔记-Git Branching
- Git学习笔记:Git命令
- git常用命令-Git学习笔记
- Git学习笔记--Git入门
- Git 学习笔记 --- 自定义Git
- git/github学习笔记
- git 学习笔记
- Git 学习笔记
- git学习笔记
- git 学习笔记
- Git学习笔记 - 1
- Git学习笔记
- Git学习笔记 - 1
- git/github学习笔记
- git学习笔记
- Git 学习笔记
- GIT之学习笔记
- HTTP
- C#WinForm 使用StreamWriter导出数据成Excel文件。
- 为虚拟化扩展“服务器新衣裳”
- GitHub从入门到精通常用命令
- 详解BluetoothAdapter
- git 学习笔记
- linux下nutch的安装配置
- 2-sat入门(例题hdu1814,poj3648)持续更新
- android 多尺寸生产xml
- 工具及其对商业社会的影响思考
- 仿今日头条/商城商品详情指示器
- C++拷贝构造函数详解
- ios打包ipa的四种实用方法(.app转.ipa)
- android lk解读 (2)