亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 2162 | 回復(fù): 1
打印 上一主題 下一主題

git應(yīng)用入門(mén) [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2012-02-23 21:31 |只看該作者 |倒序?yàn)g覽
git應(yīng)用入門(mén)






gitconfigrailsruby
安裝配置

Bash代碼  
$ git config --global user.name "Your Name"  
$ git config --global user.email your.email@example.com  

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

使用co作為checkout的alias

Java代碼  
$ git config --global alias.co checkout  

$ git config --global alias.co checkout

設(shè)置git的默認(rèn)編輯器

Java代碼  
$ git config --global core.editor "subl -w"  

$ git config --global core.editor "subl -w"

Replace "subl -w" with "mate -w" for TextMate, "gvim -f" for gVim, or "mvim -f" for MacVim.

初始化git空文件夾

Java代碼  
$ git init  

$ git init
Initialized empty Git repository in /Users/mhartl/rails_projects/first_app/.git/

配置rails命令生成的.gitignore文件




Java代碼  
# Ignore bundler config   
/.bundle   
  
# Ignore the default SQLite database.   
/db/*.sqlite3   
  
# Ignore all logfiles and tempfiles.   
/log/*.log   
/tmp  

# Ignore bundler config
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp


Mac OS 如此配置

Java代碼  
# Ignore bundler config   
/.bundle   
  
# Ignore the default SQLite database.   
/db/*.sqlite3   
  
# Ignore all logfiles and tempfiles.   
/log/*.log   
/tmp   
  
# Ignore other unneeded files.   
doc/   
*.swp   
*~   
.project   
.DS_Store  

# Ignore bundler config
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp

# Ignore other unneeded files.
doc/
*.swp
*~
.project
.DS_Store

add和commit

Java代碼  
$ git add .  

$ git add .

查看狀態(tài)

Java代碼  
$ git status   
# On branch master   
#   
# Initial commit   
#   
# Changes to be committed:   
#   (use "git rm --cached <file>..." to unstage)   
#   
#       new file:   README.rdoc   
#       new file:   Rakefile   
...  

$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#       new file:   README.rdoc
#       new file:   Rakefile
...


提交命令

Java代碼  
$ git commit -m "Initial commit"  
[master (root-commit) df0a62f] Initial commit   
42 files changed, 8461 insertions(+), 0 deletions(-)   
create mode 100644 README.rdoc   
create mode 100644 Rakefile  

$ git commit -m "Initial commit"
[master (root-commit) df0a62f] Initial commit
42 files changed, 8461 insertions(+), 0 deletions(-)
create mode 100644 README.rdoc
create mode 100644 Rakefile
(-m讓你添加一條提交信息)

查看git日志


Java代碼  
$ git log   
commit df0a62f3f091e53ffa799309b3e32c27b0b38eb4   
Author: Michael Hartl <michael@michaelhartl.com>   
Date:   Thu Oct 15 11:36:21 2009 -0700  
  
  Initial commit   
...  

$ git log
commit df0a62f3f091e53ffa799309b3e32c27b0b38eb4
Author: Michael Hartl <michael@michaelhartl.com>
Date:   Thu Oct 15 11:36:21 2009 -0700

  Initial commit
...


關(guān)于回滾
Java代碼  
$ git checkout -f   
$ git status   
# On branch master   
nothing to commit (working directory clean)   
$ ls app/controllers/   
application_controller.rb  

$ git checkout -f
$ git status
# On branch master
nothing to commit (working directory clean)
$ ls app/controllers/
application_controller.rb
(-f強(qiáng)制重寫(xiě)當(dāng)前改變)

關(guān)于同步到遠(yuǎn)程github
Java代碼  
$ git remote add origin git@github.com:<username>/first_app.git   
$ git push origin master  

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

關(guān)于git的分支
Java代碼  
$ git checkout -b modify-README   
Switched to a new branch 'modify-README'  
$ git branch   
master   
* modify-README  

$ git checkout -b modify-README
Switched to a new branch 'modify-README'
$ git branch
master
* modify-README
(使用checkout的-b創(chuàng)建分支,git branch查看當(dāng)前所有的分支,*說(shuō)明當(dāng)前的分支
git checkout -b modify-README創(chuàng)建分支并轉(zhuǎn)換到當(dāng)前分支

關(guān)于git的編輯功能
Java代碼  
$ git mv README.rdoc README.md   
$ subl README.md  

$ git mv README.rdoc README.md
$ subl README.md
mv類似unix的mv

新的README.md
Java代碼  
# Ruby on Rails Tutorial: first application   
  
This is the first application for  
[*Ruby on Rails Tutorial: Learn Rails by Example*](http://railstutorial.org/)   
by [Michael Hartl](http://michaelhartl.com/).   
  
$ git status   
# On branch modify-README   
# Changes to be committed:   
#   (use "git reset HEAD <file>..." to unstage)   
#   
#       renamed:    README.rdoc -> README.md   
#   
# 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.md   
#  

# Ruby on Rails Tutorial: first application

This is the first application for
[*Ruby on Rails Tutorial: Learn Rails by Example*](http://railstutorial.org/)
by [Michael Hartl](http://michaelhartl.com/).

$ git status
# On branch modify-README
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       renamed:    README.rdoc -> README.md
#
# 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.md
#

提交
Java代碼  
$ git commit -a -m "Improve the README file"  
2 files changed, 5 insertions(+), 243 deletions(-)   
delete mode 100644 README.rdoc   
create mode 100644 README.md  

$ git commit -a -m "Improve the README file"
2 files changed, 5 insertions(+), 243 deletions(-)
delete mode 100644 README.rdoc
create mode 100644 README.md
(-a提交所有改變)

關(guān)于合并Merge
Java代碼  
$ git checkout master   
Switched to branch 'master'  
$ git merge modify-README   
Updating 34f06b7..2c92bef   
Fast forward   
README.rdoc     |  243 --------------------------------------------------   
README.md       |    5 +   
2 files changed, 5 insertions(+), 243 deletions(-)   
delete mode 100644 README.rdoc   
create mode 100644 README.md  

$ git checkout master
Switched to branch 'master'
$ git merge modify-README
Updating 34f06b7..2c92bef
Fast forward
README.rdoc     |  243 --------------------------------------------------
README.md       |    5 +
2 files changed, 5 insertions(+), 243 deletions(-)
delete mode 100644 README.rdoc
create mode 100644 README.md

合并了所有changes后可以執(zhí)行以下命令
Java代碼  
$ git branch -d modify-README   
Deleted branch modify-README (was 2c92bef).  

$ git branch -d modify-README
Deleted branch modify-README (was 2c92bef).
用以刪除合并了的分支,這步可選

Java代碼  
# 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 "Major screw up"  
$ git checkout master   
$ git branch -D topic-branch  

# 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 "Major screw up"
$ git checkout master
$ git branch -D topic-branch
使用git branch -D 遺棄分支
(與-d不同,-D可以刪除沒(méi)有合并過(guò)的分支)

關(guān)于push
Java代碼  
$ git push  

$ git push
在大多數(shù)系統(tǒng)上可以省略origin master直接使用git push
在某些系統(tǒng)上會(huì)出現(xiàn)問(wèn)題
Java代碼  
$ git push   
fatal: The current branch master is not tracking anything.  

$ git push
fatal: The current branch master is not tracking anything.




論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2012-02-25 11:35 |只看該作者
謝謝分享
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP