git commands
Published:
merge main into your feature branch
useful git commands
git checkout main
git pull
git checkout feature-branch
git merge main
git clone multiple enterprise repos from organization
first login - stackoverflow.com/questions/19576742/how-to-clone-all-repos-at-once-from-github
https://stackoverflow.com/questions/41369365/how-can-i-export-github-issues-to-excel
export GH_HOST=http://github.molgen.mpg.de
cd ~/codes
TSV_FILE="repos.tsv" #contain name of repos
while IFS=$'\t' read -r repo _; do
gh repo clone http://github.molgen.mpg.de/<organization name>/"$repo" "$repo"
done < "$TSV_FILE"
# git pull
for repo in $(ls -d */) ; do
cd ${repo} ; git pull; cd ..
done
# issues
for repo in $(ls -d */) ;
do
cd ${repo}
gh issue list --limit 500 --state all --json title,number,createdAt,updatedAt,author,body | jq -r '(["title","number","createdAt","updatedAt","author","body"] | @csv), (.[] | [.title, .number, .createdAt, .updatedAt, .author.login, .body] | @csv)' > issues.csv
cd ..
done
# comments
for repo in $(ls -d */) ;
do
cd ${repo}
curl -H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ghp_xxxxxxxxxxxxxxxxxx" \
"https://github.molgen.mpg.de/api/v3/repos/<organization name>/${repo}issues?state=all&per_page=100" > issues.json
for issue_number in $(jq -r '.[].number' issues.json); do
curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ghp_xxxxxxxxxxxxxxxxxx" "https://github.molgen.mpg.de/api/v3/repos/<organization name>/${repo}issues/$issue_number/comments" | jq -r --arg issue_number "$issue_number" '.[] | [$issue_number, .user.login, .body, .created_at] | @csv' >> issues_with_comments.csv;
done
cd ..
done
remove tag
git tag -d <tag_name>
git push --delete origin <tag_name>
Undo Commits
git log
git revert --no-commit 9d7ade00757300bb24
git checkout
revert a single file to last commit
git checkout first_parsing.ipynb
git diff
compare same file between different versions
git difftool --tool=vimdiff 36b866 fdfd209dde -- kallisto_deseq2.sh
compare different files between different versions
git difftool --tool=vimdiff 0f10af3bc:ATAC_seqdev.sh 294f4b2d7:ATAC_seq.sh
git tag trigger
git fetch --tags
git describe --abbrev=0 --tags # get last tag
git tag -e -a <new tag> HEAD
git push
git push origin --tags
git config
Host gss
HostName raven01i.mpcdf.mpg.de
User wangy
ProxyCommand ssh -W %h:%p gate2.mpcdf.mpg.de 2>/dev/null
GSSAPIAuthentication yes
GSSAPIDelegateCredentials yes
Host gate2.mpcdf.mpg.de
User wangy