rails tutorial--git

$ git config --global user.name "Your Name"
$ git config --global user.email youremail@example.com

$ git config --global alias.co checkout

git init

git add .


git status

git commit -m "Initial commit"

git log

$ ls app/controllers/
application_controller.rb
$ rm -rf app/controllers/
$ ls app/controllers/
ls: app/controllers/: No such file or directory


$ git status
# On branch master
# Changed but not updated:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       deleted:    app/controllers/application_controller.rb
#
no changes added to commit (use "git add" and/or "git commit -a")


$ git checkout -f
$ git status
# On branch master
nothing to commit (working directory clean)
$ ls app/controllers/
application_controller.rb


The missing directory and file are back. That’s a relief!


$ git remote add origin git@github.com:<username>/first_app.git
$ git push origin master


branch

$ git checkout -b modify-README
Switched to a new branch 'modify-README'
$ git branch
master
* modify-README

edit
commit

$ git status
# On branch modify-README
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       renamed:    README -> README.markdown
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   README.markdown
#


$ git commit -a -m "Improved the README file"
2 files changed, 5 insertions(+), 243 deletions(-)
delete mode 100644 README
create mode 100644 README.markdown

Be careful about using the -a flag improperly; 
if you have added any new files to the project since the last commit, 
you still have tell Git about them using git add first.

merge

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


$ git branch -d modify-README
Deleted branch modify-README (was 2c92bef).


# For illustration only; don't do this unless you mess up a branch
$ git checkout -b topic-branch
$ <really screw up the branch>
$ git add .
$ git commit -a -m "Screwed up"
$ git checkout master
$ git branch -D topic-branch


push

$ git push

or git push orgin master



git diff跟踪wd和index的不同

git diff --staged跟踪index和last committed的不同


It’s important to note that the fetch command pulls the data to your
local repository — it doesn’t automatically merge it with any of your work or modify what you’re
currently working on. You have to merge it manually into your work when you’re ready.



To see which branches
are already merged into the branch you’re on, you can run git branch --merged:

To see all the branches that contain work you haven’t yet merged in, you can run git branch --no-
merged:


If you
didn’t want it to be called serverfix on the remote, you could instead run git push origin
serverfix:awesomebranch to push your local serverfix branch to the awesomebranch branch on
the remote project.



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值