Показаны сообщения с ярлыком manual. Показать все сообщения
Показаны сообщения с ярлыком manual. Показать все сообщения

воскресенье, 19 февраля 2012 г.

Полезные команды Git

Я начал использовать git совсем недавно и не могу назвать себя git экспертом. Но каждый день я сталкиваюсь с ситуациями и командами, описание которых, думаю, будет полезным для вас. Описание даю на английском, так как это будет понятнее.

Create and Checkout a New Branch
#branches from currently checked out directory
git checkout -b 

Checkout a Remote Branch
git checkout -b  origin/

Abort Changes of a File
git checkout -- 

Modify the Previous Commit’s Message
git commit --amend

Partial Change Checkin
git add --edit

Undo the Previous Commit
git revert HEAD^

Temporarily Stash Changes, Restore Later
# After changes have been made...
git stash

# Do some other stuff here, like switch branches, merge other changes, etc.

#Re-apply the changes
git stash pop

Delete a Remote Branch
git push origin :

Pull in the Latest from a Shared Repository
# Add a remote branch
git remote add  
 # For example:  git remote add lightfaceOfficial git://github.com/darkwing/LightFace.git

# Get changes from that branch
git fetch 

Tagging, Deleting, and Pushing Tags
# Create a Tag
git tag 

# Delete the tag
git tag -d 

# Push Tags
git push --tags

Who F’d it All Up?
git blame 

Читать далее

четверг, 19 января 2012 г.

Проверка наличия класса

Если вам нужно проверить наличие определенного класса, вы можете использовать функцию class_exists(). Ее важная особенность состоит в том, что class_exists() даже при отсутствии проверяемого класса автоматически вызывает автолоадер. Чтобы запретить такое поведение, необходимо передавать false в качестве второго параметра фунции class_exists().

Следующий код демонстрирует такое поведение:
    require_once('Zend/Loader.php');
 
    Zend_Loader::registerAutoload();
 
    if (!class_exists('MyTestClass')) {
       // class doesn't exist, but now the auto-loader will try and load it
    }
 
    if (!class_exists('MyOtherTestClass', false)) {
        // class doesn't exist, and the auto-loader will not be used
    }

Читать далее