Search This Blog

2017/06/21

Git command line memo

gitコマンドメモ

init a repo/新規

cd [ローカルリポジトリのパス]
git init
git add * // 全部追加
git commit -m "initial commit" // コメント

clone/クローン

cd [ローカルリポジトリのパス]
git clone [リモートリポジトリパス]
git clone [リモートリポジトリパス] -b [ブランチ名]

add file/ファイルの追加

git add [ファイル名] //追加
git add . //すべてのファイル・ディレクトリ
git add *.css //すべてのCSSファイル
git add -n //追加されるファイルを調べる
git add -u //変更されたファイルを追加する
git rm --cached //addしてしまったファイルを除外

commit/コミット

git commit -a -m "任意のコメント"  //コミット (-aオプションは変更を自動検出してくれる)
git commit -a //変更のあったファイルすべて
git commit -v //変更点を表示してコミット

pull

git pull is shorthand for git fetch followed by git merge FETCH_HEAD. pull = fetch + merge

git pull [options] [<repository> [<refspec>…]]
git pull -f [リモートリポジトリパス] // force強制的

push

git push [] []
git push origin master //masterを更新

switch to another branch/ブランチを変更

git checkout [branchName]
git checkout -b [branchName] // switch to new branch/新しいブランチを作って、変更

Remove ignored files/無視したファイルを削除

git rm -r --cached . 
git add .

commit cancel/コミットを取り消す

git commit --amend // 直前のコミットを取り消す
git reset --soft HEAD~2 // 最新のコミットから2件分をワークディレクトリの内容を保持し取り消す
git reset --hard HEAD~2 // 最新のコミットから2件分のワークディレクトリの内容とコミットを取り消す

mergeコミットを取り消し

git revert -m 1 [mergeコミットのSHA1]

commit comments modify/コミットのコメントを修正する

git rebase -i HEAD~2 // HEADから2件のコミットメッセージ
git commit --amend // 修正が完了したら--amendオプションを付けてコミットする。
git rebase --continue // 実行し完了

reset

git reset
git reset -h

show branch

ls
git branch
git branch -r // all
git branch -a // all

change git dir

git mv [-f] [-n] [-k] (source) ... (destination directory)
git mv [元パス] [新パス]

sync git to git

git remote add sync git@your_git_path.git
git fetch sync

git-svn

cd [ローカルリポジトリのパス]
git svn clone --trunk= --branches=branches --prefix=svn/ [リモートリポジトリパス]
git checkout -b trunk svn/trunk // マージする
git svn fetch
git svn rebase // pull
git svn dcommit // push

クローンが成功したが、ファイルがない

クローンしたbranchがNULLので、その他のbranchをチェックアウトする

git branch -a // 全部のブランチを取得
git checkout [branch name]
git checkout -f [branch name] // 強制的

crlf自動変換

git config --global core.autocrlf input

my blog

https://randinblogger.blogspot.com/

VirtualBox: Can't support 64bits OS

Try using VirtualBox to setup a 64bits Linux server, but there's an error said it can't support 64bits OS but 32bits. In VirtualBox system settings, only 32bits OSs are availabled.

Solution: Enable the virtualization technology in motherboard BIOS.

Example: hp notebook
Before boot OS > Key[Esc] > BIOS setup > Advanced > check virtualization.

VirtualBox quick key

Default [host key] is Right Ctrl.

Display
Full screen on/off: [host key] + F
Scale screen on/off: [host key] + C

Menu
Call menu: [host key] + home

2017/06/16

IE: js only working in debug mode

I happened to an issue that js function is working in Chrome, Firefox and IE's debug mode. ONLY IN DEBUG MODE.

In stackoverflow, most answer are "Don't use 'console.log'". Because console object exists in scope only in debug mode after IE9.
Or use codes likes below to avoid console's problem.
if(!('console' in window)){
    window.console ={};
    window.console.log=function(string){
        return string;
    };
}

But it's not working on my issue, and try to catch the error is non-help at all.
window.onerror = function(msg, url, line) {
    alert('Error message: '+msg+'\nURL: '+url+'\nLine Number: '+line);
    return true;
}

Maybe it is cached that set to true somewhere, so I tried to set it to false.
$.ajax({
    type: "GET",
    url: "/" + filename,
    dataType: "xml",
    cache: false,
    success: function(xml){ /* code */ }
});

Success. Issue closed.

2017/06/13

Setting NLS_LANG Oracle in Non-English Environment

Develop in No-English Environment, setting the NLS_LANG environment variable for Oracle databases.

1. Determine the NLS_LANG
SELECT * FROM V$NLS_PARAMETERS
The NLS_LANG will be in format [NLS_LANGUAGE]_[NLS_TERRITORY].[NLS_CHARACTERSET]

2. For Windows
Control Panel > System: Advanced tab: Environment Variables
New in System variable section. Variable Name: NLS_LANG.

3. For UNIX
SETENV NLS_LANG [NLS_LANG]
If data is 7-bit or 8-bit ASCII it will be NLS_LANG: [NLS_LANGUAGE]_[NLS_TERRITORY].WE8ISO8859P1

4. Reboot machine.

[NLS_LANGUAGE]_[NLS_TERRITORY].[NLS_CHARACTERSET]:
American_America.UTF8
Japanese_Japan.JA16SJISTILDE

2017/06/12

Create and download file by JavaScript

Code:
<script>
function download(fileName, content){
    var file = document.createElement('a');
    file.download = fileName;
    file.href = 'data:application/octet-stream,'+encodeURIComponent(content);
    file.click();
}
</script>
Html:
<button onclick="download('test.txt','test text.');"/>

2017/06/02

VBA: Unhide all sheets in Excel

Code:
Sub UnhideAllSheets()
    Dim ws as Worksheet
    For Each ws In ActiveWorkbook.Worksheets
        ws.Visible = xlSheetVisible
    Next ws
End Sub