Git精简教程,快速上手
来源:互联网 发布:云计算 自贸区 编辑:程序博客网 时间:2024/05/04 18:32
由于以前工作一直使用SVN,这次做RN,客户端使用的git来管理源码,所以今天花了点时间来研究git。
目的:以最短的时间上手git,不说原理性的东西,让从未使用过git的人能快速上手。so,让我们开始吧。
1、安装 (略) 百度一大把
2、配置账号
git cofig --global user.name "xiaodao"git config --global user.email "xiaodao@gmail.com"
3、克隆一个git仓库,并查看日志(git log)
git clone http://xxxx/test.gitcd testgit log
4、使用git管理代码流程(这个是重点)
git还是主要使用命令行来操作,感觉在Mac上用还是不错的,下面详细的说下命令,看官请看:
1) 与远程仓库同步 :git pull
F:\gitworkspace\Test>git pullAlready up-to-date.
如果是远程仓库项目没有变化,也就是说其他的开发者没有对项目进行变更,会显示这样的信息:
Already up-to-date.
2) 修改文件
这个就不用说了吧,自己随便改点什么文件吧。
3) 查看变更: git status
有2种情况吧
Untracked files 未载入stage unstaged
F:\gitworkspace\Test>git statusOn branch masterYour branch is up-to-date with 'origin/master'.Untracked files: (use "git add <file>..." to include in what will be committed) test.txtnothing added to commit but untracked files present (use "git add" to track)
changes to be committed 已经载入(stage)了
F:\gitworkspace\Test>git statusOn branch masterYour branch is up-to-date with 'origin/master'.Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: test.txt
4) 载入变更 : git add <file>
实际上上面已经看到了,就是将unstaged 状态变更为 changes to be committed
F:\gitworkspace\Test>git add test.txt
5) 提交载入的变更 git commit -a
F:\gitworkspace\Test>git commit -a[master 6610af9] test 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test.txt
再次查看 状态 nothing to commit 实际上这也是一种状态,上面忘记说了。本机已经提交,但是还没有push到服务器。
F:\gitworkspace\Test>git statusOn branch masterYour branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits)nothing to commit, working directory clean显示我们的工作目录clean了(同时提示我们现在的分枝上有1个提交还没有上传)
6)上传到服务器 git push
F:\gitworkspace\Test>git pushwarning: push.default is unset; its implicit value has changed inGit 2.0 from 'matching' to 'simple'. To squelch this messageand maintain the traditional behavior, use: git config --global push.default matchingTo squelch this message and adopt the new behavior now, use: git config --global push.default simpleWhen push.default is set to 'matching', git will push local branchesto the remote branches that already exist with the same name.Since Git 2.0, Git defaults to the more conservative 'simple'behavior, which only pushes the current branch to the correspondingremote branch that 'git pull' uses to update the current branch.See 'git help config' and search for 'push.default' for further information.(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode'current' instead of 'simple' if you sometimes use older versions of Git)Username for 'https://github.com': xiaodaoPassword for 'https://xiaodao@github.com':Counting objects: 3, done.Delta compression using up to 4 threads.Compressing objects: 100% (2/2), done.Writing objects: 100% (3/3), 301 bytes | 0 bytes/s, done.Total 3 (delta 0), reused 0 (delta 0)To https://github.com/xiaodao/Test.git e3479a5..6610af9 master -> master
查看状态,对比 Your branch is ahead of 'origin/master' by 1 commit. 可以看到没有需要commit的文件了。
F:\gitworkspace\Test>git statusOn branch masterYour branch is up-to-date with 'origin/master'.nothing to commit, working directory clean
到目前为止,我们看到了新数据都已经上传完毕,服务器上的主分支也已经更新了. 搞定!
还有些其他命令可以参考:
想和详细的了解git,可以参考:http://fsjoy.blog.51cto.com/318484/244397 ,分为几篇文章讲解,非常不错。
2 0
- Git精简教程,快速上手
- Git精简教程,快速上手
- Git教程 快速上手
- git快速上手教程
- Git 快速上手精华教程
- Git 快速上手 1
- git使用快速上手
- Git 快速上手
- Git 快速上手指南
- git 快速上手备忘录
- Git快速上手
- Git快速上手
- Git快速上手小结
- git上手教程
- 最快上手 Git教程
- PGP快速上手教程
- 信息技术快速上手教程
- webpack快速上手教程
- Java Se----语言基础(1)
- 使用Jquery解析Json基础知识
- CSS中几种颜色的表示方法
- Number_纪中1781_bfs+hash
- QStyledItemDelegate类的使用
- Git精简教程,快速上手
- 广点通api 时间段转换
- Activity启动模式
- Oracle RMAN异机恢复归档RMAN-07518(供日志挖掘使用)及修改dbid步骤
- 浅谈树链剖分(每日不间断更新中)
- j2ee是什么?(2)
- hihoCoder 1014 Trie树
- 心态的重要性
- 关于Hibernate Spring structs的学习