2014年1月3日 星期五

Git 指令速查

● git clone
● git push
● git pull
● git add
○ git add -i ,互動模式
○ git add 檔名 -p    互動式詢問, 切 commit 專用
○ git add 檔名  把指定的檔案放進 staging area
○ git add . 有異動的檔案全部放入 staging area. 偷懶作法 慎用
● git commit
○ git commit -v 寫摘要時 VIM 底下會有 diff
○ git commit -a 包含自動git add有異動的檔案
○ git commit -m “MESSAGE HERE”   不進 VIM 直接寫摘要
● git branch
○ git branch -d 分支名稱 刪除指定的分支
○ git branch -a # 看遠端 repo 所有分支
● git checkout
○ git checkout -f  清除全部未 commit 的異動, 慎用(不能復原)
● git revert
● git diff
○ git diff --cached 跟 staging area 比對差異 (commit 後使用)
● git merge 合併分支
○ git merge –no-ff ,commit log 會紀錄您是開分支出去的,清楚紀錄您的分支操作步驟
● git stash
○ git stash 把未 commit 的異動”暫存”, 讓 repo 變回乾淨狀態
○ git statsh -u 包含未新增的異動”暫存”, 讓 repo 變回乾淨狀態
○ git stash pop 把上述的異動從”暫存區” 抓回來
● git blame
○ git blame -w  忽略空白的 commit
● git log
○ git log -p 也顯示程式碼異動細節
● tig

Composer 筆記

1.安裝
http://getcomposer.org/doc/00-intro.md
$ curl -sS https://getcomposer.org/installer | php
2.使用
http://getcomposer.org/doc/03-cli.md

Command-line interface


init

In the Libraries chapter we looked at how to create a composer.json by hand. There is also an initcommand available that makes it a bit easier to do this.
When you run the command it will interactively ask you to fill in the fields, while using some smart defaults.
$ php composer.phar init

install

The install command reads the composer.json file from the current directory, resolves the dependencies, and installs them into vendor.
$ php composer.phar install
If there is a composer.lock file in the current directory, it will use the exact versions from there instead of resolving them. This ensures that everyone using the library will get the same versions of the dependencies.
If there is no composer.lock file, composer will create one after dependency resolution.

update

In order to get the latest versions of the dependencies and to update the composer.lock file, you should use theupdate command.
$ php composer.phar update
This will resolve all dependencies of the project and write the exact versions into composer.lock.
If you just want to update a few packages and not all, you can list them as such:
$ php composer.phar update vendor/package vendor/package2
You can also use wildcards to update a bunch of packages at once:
$ php composer.phar update vendor/*

require

The require command adds new packages to the composer.json file from the current directory.
$ php composer.phar require
After adding/changing the requirements, the modified requirements will be installed or updated.
If you do not want to choose requirements interactively, you can just pass them to the command.
$ php composer.phar require vendor/package:2.* vendor/package2:dev-master

global

The global command allows you to run other commands like installrequire or update as if you were running them from the COMPOSER_HOME directory.
This can be used to install CLI utilities globally and if you add $COMPOSER_HOME/vendor/bin to your $PATH environment variable. Here is an example:
$ php composer.phar global require fabpot/php-cs-fixer:dev-master
Now the php-cs-fixer binary is available globally (assuming you adjusted your PATH). If you wish to update the binary later on you can just run a global update:
$ php composer.phar global update
The search command allows you to search through the current project's package repositories. Usually this will be just packagist. You simply pass it the terms you want to search for.
$ php composer.phar search monolog
You can also search for more than one term by passing multiple arguments.

show

To list all of the available packages, you can use the show command.
$ php composer.phar show
If you want to see the details of a certain package, you can pass the package name.
$ php composer.phar show monolog/monolog

name : monolog/monolog
versions : master-dev, 1.0.2, 1.0.1, 1.0.0, 1.0.0-RC1
type : library
names : monolog/monolog
source : [git] http://github.com/Seldaek/monolog.git 3d4e60d0cbc4b888fe5ad223d77964428b1978da
dist : [zip] http://github.com/Seldaek/monolog/zipball/3d4e60d0cbc4b888fe5ad223d77964428b1978da 3d4e60d0cbc4b888fe5ad223d77964428b1978da
license : MIT

autoload
psr-0
Monolog : src/

requires
php >=5.3.0
You can even pass the package version, which will tell you the details of that specific version.
$ php composer.phar show monolog/monolog 1.0.2

depends

The depends command tells you which other packages depend on a certain package. You can specify which link types (requirerequire-dev) should be included in the listing. By default both are used.
$ php composer.phar depends --link-type=require monolog/monolog

nrk/monolog-fluent
poc/poc
propel/propel
symfony/monolog-bridge
symfony/symfony

validate

You should always run the validate command before you commit your composer.json file, and before you tag a release. It will check if your composer.json is valid.
$ php composer.phar validate

status

If you often need to modify the code of your dependencies and they are installed from source, the statuscommand allows you to check if you have local changes in any of them.
$ php composer.phar status
With the --verbose option you get some more information about what was changed:
$ php composer.phar status -v
You have changes in the following dependencies:
vendor/seld/jsonlint:
M README.mdown

self-update

To update composer itself to the latest version, just run the self-update command. It will replace your composer.phar with the latest version.
$ php composer.phar self-update
If you would like to instead update to a specific release simply specify it:
$ composer self-update 1.0.0-alpha7
If you have installed composer for your entire system (see global installation), you may have to run the command with root privileges
$ sudo composer self-update