Git ID:36hBr7hV

2名無しさん@Next2ch:2015/03/14(土) 23:26:15.73 ID:36hBr7hV

また支援が足りないな
bashrcか~/.profileに登録しておくと便利なショートカットいくつか
function git_ls(){
git branch
}
function git_cd(){
awk -v node="$1" '
function cmd(E,A,this,v){A[0]=0;while((E |getline v)>0)A[A[0]+=1]=v;A["RETURN_CODE"]=close(E);}
BEGIN{if(node=="")exit;cmd("git branch",A);for(i=1;i<=A[0];i++)sub("^[* ]*","",A[i]);
for(i=1;i<=A[0];i++){if(A[i]~node){E="/bin/bash -c \x27 git checkout \""node"\" \x27 & ";
E|getline v;close(E);break}}exit}'
}

3名無しさん@Next2ch:2015/03/14(土) 23:28:12.14 ID:36hBr7hV

#一時的に他の作業を行う場合
function git_keep_uncommitted_work_and_revert_to_known_state(){
[ "$1" == "" ] && echo "give a hash that points to desired restore state" && return;
git stash
git reset --hard "$1"
git stash pop
}
#即知の安全圏へ退避
function git_revert_to_known_state(){
[ "$1" == "" ] && echo "give a hash that points to desired restore state" && return;
git reset --hard "$1"
}

4名無しさん@Next2ch:2015/03/14(土) 23:31:14.04 ID:36hBr7hV

#即座に保存
function git_save_quick(){
git commit -am "Saved at $(date +"%Y %m %d %A %R:%S %p %s")$1"
}
#ファイルの一部だけ保存
function git_save_partial_choose_what_to_commit(){
[ "$1" == "" ] && echo "give a file name to save bits but not all of" && ret
urn;
[ ! -f "$1" ] && echo "give a file name that exsists" && return;
echo " Usage : will ask what you want to stage. You can:"
echo " hit [s] to split whatever change into smaller chunks."
echo " unchanged line in the _middle_ of the hunk is where hunk will
be split."
echo " Will not work if there is not any such line."
echo " hit [y] to partial save (stage) that chunk"
echo " [n] to ignore (not stage) that chunk"
echo " [e] to manually edit"
echo " [d] to exit or go to the next file."
echo " [?] to get the whole list of available options."
git add -p "$1"
git diff --cached
}
#もっとも最新の保存地点へさらに内容を追加する
function git_save_append_more_changes_to_most_recent_commit(){
git commit --amend
}

5名無しさん@Next2ch:2015/03/14(土) 23:33:32.46 ID:36hBr7hV

#特定のファイルの変更経歴を表示
function git_show_history_of_file(){
[ "$1" == "" ] && echo "give a file name" && return;
[ ! -f "$1" ] && echo "give a file name that exsists" && return;
git log --follow -p "$1"
}
#特定のハッシュの時点で行われた変更点を表示
function git_show_change_made_by_hash(){
[ "$1" == "" ] && echo "give a sha hash, usually 40 bytes, made from 0-9 and a
-f " && return;
git rev-list "HEAD..$1" 2>/dev/null
[ $? -ne 0 ] && {
echo "Hash [$1] does not exsist. Specify a valid commit.";
echo "Possible canidates are..."
git log |grep "${1:0:8}";
[ $? -ne 0 ] && {
{ git log |grep "${1:0:5}"; } || { [ ${#B} -gt 5 ] && git log |grep "${1:0-5:5}"; }
[ $? -ne 0 ] && {
echo "Unable to find any match. Is that really a sha hash of a commit?"
}
}
return 1;
}
git show "$1";
}

6名無しさん@Next2ch:2015/03/14(土) 23:35:35.38 ID:36hBr7hV

あとGitHubのリンクとかcgitの導入方法とかあったほうがいいかも>>1


このIDをNGリストに追加する

今後このIDの書き込みやスレッドを表示したくない場合、以下のボタンをクリックしてください。
NGリストに追加

レスを書き込む