## Git ###############################
* add submodule
+------------------------------------------+
| $ git submodule add <src_url> <dst_path> |
+------------------------------------------+
* rm submodule
edit <git_dir>/.gitmodules
edit <git_dir>/.git/config
+------------------------------------------+
| $ rm <git_dir>/.git/modules/<dst_module> |
+------------------------------------------+
* update submodule
+-------------------------------------+
| $ git submodule update ^-i (--init)^|
+-------------------------------------+
* replace submodule
+------------------------------------+
| $ rm -rf <dst_module> |
| $ rm -rf .git/modules/<dst_module> |
| $ git rm --cached <dst_module> |
+------------------------------------+
edit .git/config
* change submodule position
edit these files
.gitmodules
.git/config
.git/modules/<dst module>/config
<dst module>/.git
* add new repository on GitHub
create new repository in WEB
+--------------------------------------------------------------+
| $ git remote add origin git@github.com:ekawa/<repo_name>.git |
| $ git push -u origin master |
+--------------------------------------------------------------+
* clone new repository from GitHub
+-------------------------------------------------------------+
| $ git clone git@github.com:ekawa/<repo_name>.git <dst_path> |
+-------------------------------------------------------------+
* conflict error
when conflict:merge error
then
+-------------------------------------+
| $ git reset --hard master; git pull |
+-------------------------------------+
at /usr/local
* do not open editor at merge
set environment variable
export GIT_MERGE_AUTOEDIT=no
* install git under home
+-------------------------------------------------------------+
| $ ./configure --prefix=/home/ekawa/local |
| $ PYTHON_PATH=/home/ekawa/local/bin/python3.0@ make |
| $ PYTHON_PATH=/home/ekawa/local/bin/python3.0@ make install |
+-------------------------------------------------------------+
NOTE : in git 1.8.4 case python3 is necessary
* check tracked files
+----------------+
| $ git ls-files |
+----------------+
* recover removed file
+----------------------------------------+
| $ git checkout <hash> -- <file> |
| e.g. HEAD\^, ce36818a3a |
+----------------------------------------+
* rebase brew Formula
+-----------------------------------+
| $ cd /usr/local |
| $ git pull --rebase origin master |
+-----------------------------------+
* add new repository to private git server
make repository dir on git server
+------------------------------------------+
| $ mkdir ~/git_repository/<repo name>.git |
| $ cd ~/git_repository/<repo name>.git |
| $ git --bare init |
+------------------------------------------+
remote add on local machine
+-----------------------------------------------------------------+
| $ cd <dst repo> |
| $ git remote add origin ssh://ekawa@yang.scphys.kyoto-u.ac.jp:\ |
| <port>/home/ekawa/git_repository/<repo name>.git |
| $ git push -u origin master |
+-----------------------------------------------------------------+
if you want to use this repository on anotner machine, use git clone
+--------------------------------------------------------+
| $ git clone ssh://ekawa@yang.scphys.kyoto-u.ac.jp:\ |
| <ip>/home/ekawa/git_repository/<repo name>.git <dst> |
+--------------------------------------------------------+
* remove file from all history
+-------------------------------------------------------------------------------------+
| $ git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch <dst>' HEAD |
| $ git push -u origin master --force |
+-------------------------------------------------------------------------------------+
* download tag from remote repository
+-------------------+
| $ git pull --tags |
+-------------------+
* change remote repository URL
+-------------------------------------+
| $ git remote set-url <branch> <URL> |
+-------------------------------------+
% example
git remote set-url origin ssh://<usr>@example.jp:22/home/<***.git>