Ruby on Rails Tutorial 第一章 之 Git项目管理

1、安装和设置

(1)git的安装(略)

(2)初始化设置

  $ git config --global user.name "LihuaSun"

  $ git config --global user.email "12***50@**.com"

  $ git config --global push.default matching #向后兼容新的git版本

(3)第一次使用仓库要做的设置

  $ git init

  $ git add -A

  $ git status

  $ git commit -m "Initialize repository"

  $ git log

(4)公钥管理

  $ ssh-keygen -t rsa -C "1254575850@qq.com" #生成公钥

  $ cat ~/.ssh/id_rsa.pub #复制公钥

(5)在GitHub上添加hello_app仓库(略)

(6)添加远程仓库并推送

  $ git remote add origin git@github.com:LihuaSun/hello_app.git

  $ git push -u origin --all  #第一次推送仓库

2、分支、编辑、提交、合并、推送

(1)分支

  $ git checkout -b modify-README  #创建分支

  $ git branch  #查看分支

(2)编辑

  $ git mv README.rdoc README.md

  $ git checkout -f #强制撤销改动

(3)提交

  $ git status  #查看分支状态

  $ git add -A  #如果上次提交之后添加了新文件,则要执行这个命令

  $ git commit -a -m "Improve the README file"

(4)合并

  $ git checkout master  #切换到主分支

  $ git merge modify-README  #合并分支

  $ git brandh -d modify-README #删除分支,当用-D时,放弃该分支中的改动

(5)推送

  $ git push origin master  #其中origin master经常省略

原文地址:https://www.cnblogs.com/sunflower627/p/4605242.html