git github 使用


首先进入刚创建的应用程序的根目录,然后初始化一个新仓库:
$ git init

git 默认会跟踪所有文件的变化,但是有些文件我们并不想跟踪,git 有忽略文件的机制:在应用程序的根目录创建一个名为 .gitignore 的文件,然后写入一些规则告诉 git 要忽略哪些文件即可。rails 命令默认会在应用程序的根目录创建 .gitignore 文件

把项目中的文件添加到 git 中,(除了 .gitignore 中忽略的文件)
$ git add .

用 status 命令查看暂存区域有哪些文件
$ git status

用 commit 命令告诉 git 你想保存这些改动:
$ git commit -m "Initial commit"

用 log 命令查看提交的历史信息:
$ git log

git 为我们带来了什么好处,当一个文件被删除了,但是这个改动只发生在工作区,还没有提交。这样我们就可以使用 checkout 命令切换到前一个提交记录来撤销这次改动(其中旗标 -f 意思是覆盖当前的改动):
$ git checkout -f


分支,编辑,提交,合并
$ git checkout -b modify-README
Switched to a new branch 'modify-README'
$ git branch
master
* modify-README

合并
$ git checkout master
Switched to branch 'master'
$ git merge modify-README

用 git branch -d 删除这个从分支:
$ git branch -d modify-README

用 git branch -D 放弃对从分支所做的修改:
$ git checkout -b topic-branch
$ <really screw up the branch>
$ git add .
$ git commit -a -m "Major screw up"
$ git checkout master
$ git branch -D topic-branch
和旗标 -d 不同,即使还未合并 -D 也会删除分支

推送:
$ git push -u origin master
$ git push
因为之前我们已经推送过一次了,在大多数系统中我们都可以省略 origin master,只要运行 git push


http://railstutorial-china.org/chapter1.html#section-1-3-4

http://www.worldhello.net/gotgithub/


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值