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

четверг, 5 апреля 2018 г.

AQA: tools: git - the simple guide. just a simple guide for getting started with git. no deep shit ;)


create a new repository

create a new directory, open it and perform a
git init
to create a new git repository.

checkout a repository

create a working copy of a local repository by running the command
git clone /path/to/repository
when using a remote server, your command will be
git clone username@host:/path/to/repository

workflow

your local repository consists of three "trees" maintained by git. the first one is your Working Directory which holds the actual files. the second one is the Index which acts as a staging area and finally the HEAD which points to the last commit you've made.


add & commit

You can propose changes (add it to the Index) using
git add <filename>
git add *
This is the first step in the basic git workflow. To actually commit these changes use
git commit -m "Commit message"
Now the file is committed to the HEAD, but not in your remote repository yet.

pushing changes

Your changes are now in the HEAD of your local working copy. To send those changes to your remote repository, execute
git push origin master
Change master to whatever branch you want to push your changes to.

If you have not cloned an existing repository and want to connect your repository to a remote server, you need to add it with
git remote add origin <server>
Now you are able to push your changes to the selected remote server


branching

Branches are used to develop features isolated from each other. The master branch is the "default" branch when you create a repository. Use other branches for development and merge them back to the master branch upon completion.



create a new branch named "feature_x" and switch to it using
git checkout -b feature_x
switch back to master
git checkout master
and delete the branch again
git branch -d feature_x
a branch is not available to others unless you push the branch to your remote repository
git push origin <branch>

update & merge

to update your local repository to the newest commit, execute
git pull
in your working directory to fetch and merge remote changes.
to merge another branch into your active branch (e.g. master), use
git merge <branch>
in both cases git tries to auto-merge changes. Unfortunately, this is not always possible and results in conflicts. You are responsible to merge those conflicts manually by editing the files shown by git. After changing, you need to mark them as merged with
git add <filename>
before merging changes, you can also preview them by using
git diff <source_branch> <target_branch>

tagging

it's recommended to create tags for software releases. this is a known concept, which also exists in SVN. You can create a new tag named 1.0.0 by executing
git tag 1.0.0 1b2e1d63ff
the 1b2e1d63ff stands for the first 10 characters of the commit id you want to reference with your tag. You can get the commit id by looking at the...


log

in its simplest form, you can study repository history using.. git log
You can add a lot of parameters to make the log look like what you want. To see only the commits of a certain author:
git log --author=bob
To see a very compressed log where each commit is one line:
git log --pretty=oneline
Or maybe you want to see an ASCII art tree of all the branches, decorated with the names of tags and branches:
git log --graph --oneline --decorate --all
See only which files have changed:
git log --name-status
These are just a few of the possible parameters you can use. For more, see git log --help


replace local changes

In case you did something wrong, which for sure never happens ;), you can replace local changes using the command
git checkout -- <filename>
this replaces the changes in your working tree with the last content in HEAD. Changes already added to the index, as well as new files, will be kept.
If you instead want to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it like this
git fetch origin
git reset --hard origin/master

useful hints

built-in git GUI
gitk
use colorful git output
git config color.ui true
show log on just one line per commit
git config format.pretty oneline
use interactive adding
git add -i

links & resources

graphical clients


guides


get help

воскресенье, 20 марта 2016 г.

AQA: tools: bash: Переносим функциональность bash в cmd.exe

Переносим функциональность bash в cmd.exe

Мне, как и многим из вас, работать с bash и стандартными утилитами Linux гораздо удобнее и приятнее, чем с cmd.exe. Однако, к сожалению, порой обстоятельства складываются так, что операционную систему выбирать не приходится. Например, в моём случае корпоративным стандартом является Windows 7. К счастью есть способ сделать жизнь линуксоида в командной строке Windows комфортнее, о нём и пойдет речь ниже.


Прежде всего, при переходе из bash в cmd.exe доставляет неудобства ограниченность самой командной оболочки. Чтоб вставить текст из буфера обмена нужно тянуться к мышке, не хватает возможностей автодополнения, история хранится только в пределах одной сессии, к тому же не работает Ctrl+R и другие возможности работы с историей команд в bash.

Исправить ситуацию нам поможет clink. Это Open Source утилита расширяющая возможности cmd.exe. Вот некоторые ее фичи:

  • Автодополнение по нажатию Tab. Возможности автодополнения могут быть расширены за счет пользовательских скриптов на Lua
  • Вставка текста из буфера по нажатию Ctrl-V (к сожалению Shift+Insert не работает)
  • Продвинутая работа с историей команд. Поиск по истории (Ctrl-R and Ctrl-S). Поддержка таких выражений как !!, !<string> и !$
  • Сохранение предыдущих сессий


Авторы говорят, что clink протестирован только на Windows XP SP3, но я пользуюсь им уже год на Windows 7 и всё работает нормально.

Скачали. Установили. Стало лучше, теперь cmd себя ведет почти как bash. Но кое-чего по прежнему не хватает. А именно привычных unix-утилит. Таких как cat, ls, tail, diff, grep, less, sort, wget и т.д. Некоторые утилиты имеют свои Windows-аналоги, например, вместо grep можно использовать findstr, но к ним придется привыкать заново, другие же аналогов вообще не имеют.

Эту проблему нам поможет решить готовый набор программ UnxUtils. Набор включает в себя множество популярных в Unix и Linux инструментов командной строки (полный список можно посмотреть по этой ссылке) а так же несколько дополнительных программ.

В частности, к дополнительным программам относятся pclip.exe и gclip.exe предназначенные для работы с буфером обмена Windows. Например вот так: pclip | sed "s/string1/string2/g" | gclip можно заменить все вхождения string1 на string2 в тексте хранящемся в буфере обмена.

Для того чтоб получить всё это на свою Windows-машину нужно скачать архив UnxUtils.zip, распаковать его содержимое в какой-то каталог и добавить в переменную среды PATH путь к usr\local\wbin\, т.к. именно там хранятся исполняемые файлы.

Для самых ленивых есть способ еще проще: скопируйте содержимое каталога usr\local\wbin\ из архива в каталог %WINDIR%\system32\ на вашей машине.
Внимание! Если вы решили поступить именно так, то я не рекомендую заменять системные файлы на одноименные файлы из архива без четкого понимания того, что вы делаете.

Всё! Осталось только запустить cmd и эффективно работать используя свой linux-опыт. Конечно есть и другие способы добиться того же самого результата, я описал тот, который нахожу максимально простым и удовлетворяющим все мои потребности.
 Альтернативный терминал для Windows
Обновление с Bash интерпретатором 
 см. практические подходы

Bash скрипт перезагрузки оборудования через telnet 
Bash-скрипт для проверки, запущены ли apache, nginx, mysql и ssh на сервере 
SSH — передача файлов и выполнение команд

   Копирование файлов через SSH
   SSH аутентификация по открытому ключу
   Подключения по SSH без ввода пароля
   Запуск команд на удаленном Linux-сервере через SSH
   Отключение проверки ключа хоста в SSH

SEO: Эксперимент: как Яндекс и Google учитывают ключевые слова в URL

Эксперимент: как Яндекс и Google учитывают ключевые слова в URL Эксперимент: как Яндекс и Google учитывают ключевые слова в URL Дата пу...