# GitHub Enterprise ## Clone all GHE repos This is limited to cloning 100 repos at a time, the second command gets page 2 ``` TOKEN=foo ORG_NAME=developer-journey COMPANY=IBM $ curl -s "https://github.ibm.com/api/v3/orgs/developer-journeys/repos?access_token=TOKEN&per_page=100" | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}' $ curl -s "https://github.ibm.com/api/v3/orgs/developer-journeys/repos?access_token=TOKEN&per_page=100&page=2" | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}' ``` ## Move a repo from GHE to GH > This will keep the commit history! ``` ## get the repo to be cloned $ git clone git@github.ibm.com:IBMDigital/Procurement-System.git ## rename the origin branch to something else to avoid conflicts $ git remote rename origin destination ## go to github and create an empty repo, add the new repo location $ git remote add origin https://github.com/IBM/procurement-system.git ## optionally check remotes using -v $ git remote -v destination git@github.ibm.com:IBMDigital/Procurement-System.git (fetch) destination git@github.ibm.com:IBMDigital/Procurement-System.git (push) origin https://github.com/IBM/procurement-system.git (fetch) origin https://github.com/IBM/procurement-system.git (push) ## push code up to new remote branch $ git push -u origin master ## note that if using the below command with 2FA, you will need to ## use a personal access token as a password along with your username! ``` --- # Gerrit ## Remote Rebasing 1. Click "Rebase" button in the Gerrit UI under your patch set. ## Local rebasing 1. git review -d $PARENT_CHANGE_NUMBER 1. git review -x $BROKEN_CHANGE_NUMBER 1. fix the issues 1. git add 1. git cherry-pick --continue 1. git review ## backporting a patch 1. git checkout -b some_branch_name origin/stable/liberty 1. git review -x 1. fix errors 1. git add keystone/ 1. git cherry-pick --continue 1. modify the commit message 1. git review stable/liberty --- # General Git ## Undo a git commit amend 1. git reflog (to find the number) 1. git reset --soft HEAD@{number} 1. git commit -C HEAD@{number}