[golang] github.com의 private repo 접근하기

$ git config --global url.git@github.com:.insteadOf https://dasomoli@github.com/
$ go get github.com/dasomoli/private-repo

참고: https://stackoverflow.com/questions/27500861/whats-the-proper-way-to-go-get-a-private-repository

[Linux][bash] git branch를 prompt에 넣기

~/.bashrc 에 다음을 추가.

parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
#  PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\]$ "

[github] Public repo를 private으로 바꾸기

public project를 가져와서 혼자 몰래 뭘 해보고 싶을 때, Apache 2.0 License 등 derived works의 source code 공개 의무가 없는 프로젝트의 경우 private으로 바꿔서 작업을 해볼 수 있다.

다음과 같이 한다.

먼저 만들고 싶은 이름으로 github에서 project를 하나 private으로 만든다.

$ git clone --bare https://github.com/publicproject/project.git
$ cd project.git
$ git push --mirror https://github.com/myname/myproject.git

그리고 나서 실제로 clone해서 쓰면 된다.

$ git push https://github.com/myname/myproject.git

최신 코드로의 업데이트는 public repository를 여기다 remote로 추가해서 fetch & rebase하면 된다.

push는 public으로 fork해온 후 거기다 push 해서 pull request하면 될 듯.

참고: https://medium.com/@bilalbayasut/github-how-to-make-a-fork-of-public-repository-private-6ee8cacaf9d3

[Git][Windows] Git bash의 시작 디렉토리 바꾸기

Git Bash에서 속성을 누른다.

“바로 가기” 탭의 “시작 위치(S):”를 보면 “%HOMEDRIVE%%HOMEPATH%”로 되어 있을텐데, 이를 시작하고자 하는 위치로 바꾼다.

그 위의 “대상(T):” 을 보면 마지막에 git-bash.exe의 뒤에 “–cd-to-home” 이 붙어 있을텐데 이를 지운다.

[github] 웹 브라우저로 내 repository 업데이트하기

github에서 fork한 내 repository는 해당 시점의 코드에서 멈춰 있게 된다. 이걸 git으로 작업하지 않고 그냥 브라우저 내에서 업데이트할 수 있다. 나에게 pull request하는 방법을 쓰면 된다.

절차를 간단히 설명하면 다음과 같다.

  1. 내 repository에서 “Compare”를 누른 후, “switching the base”

  2. “Create pull request”를 눌러 원본 repository에서 나에게 pull request를 생성

  3. 아래 confirm하는 곳에서 “Merge pull request” 옆의 세모를 눌러 “Rebase and merge”

 

[git] git tips 한국어판

​https://github.com/mingrammer/git-tips/blob/master/README.md

git worktree

git worktree add <path> <branch>

하나의 git repository로 체크 아웃을 한군데 하는게 아니라 여러군데에 하고 싶을 때 쓴다. 브랜치를 아예 물리적으로 다른 경로로 나누어서 작업하고 싶을 때라던지 용도는 매우 다양하다.