Skip to content

Instantly share code, notes, and snippets.

@menny
Last active February 12, 2019 20:45
Show Gist options
  • Save menny/d238af6b9a82a77f9e1d0b757ccd1888 to your computer and use it in GitHub Desktop.
Save menny/d238af6b9a82a77f9e1d0b757ccd1888 to your computer and use it in GitHub Desktop.
git cheatsheet

SpotiGit Cheat-Sheet

General

rebasing local branch from origin git pull --rebase if rebasing from a different remote branch git pull --rebase origin master

most of the time, after pull, you’ll need to update the submodules git submodule update --init —recursive

Fixing a commit

this will open up the interactive rebase, starting the the last commit from the tracking branch (origin/develop) git rebase -i then we get the interactive commits picker (order is reverse, compared to git log) pick/edit/whatever fix commit git add [affected files] git commit --amend when satisfied - continue git rebase --continue

Splitting a commit: git reset HEAD~

if it is further than the last commit, first edit it with rebase: git rebase -i HEAD~3 then do git reset HEAD~ split as you like, and then git rebase —continue

amend you commit, and then force push it. git push --force origin HEAD:[your local branch, e.g., master]

How to merge branches

we are merging upstream branch release-0.0.x, into master first, checkout the branch from GHE to your local repo, and branch that git checkout -b merging00x upstream/master now, merge the upstream branch into git merge upstream/release-0.0.x --log fix any conflicts (fix the conflict and do git add filename) when done: git commit then push to your git fork git push origin merging00x create a pull request from you merging00x fork to the upstream master

github PR branch pull

git fetch upstream pull/1234/head:pr-1234 git co pr-1234

Internal

Core push Go to native/src/core git fetch && git reset --hard origin/master Do your changes and commit git push origin HEAD:refs/publish/master

Gerrit

To push to Gerrit as draft: git push origin HEAD:refs/drafts/develop Or git push origin HEAD:refs/drafts/personal_branch

Or to push to Gerrit for the develop branch: git push origin HEAD:refs/for/develop

SpotiGit Cheat-Sheet
To push to Gerrit as draft:
git push origin HEAD:refs/drafts/develop
Or
git push origin HEAD:refs/drafts/personal_branch
Or to push to Gerrit for the develop branch:
git push origin HEAD:refs/for/develop
//rebasing local branch from origin
git pull --rebase
//if rebasing from a different remote branch
git pull --rebase origin develop
//most of the time, after pull, you’ll need to update the submodules
git submodule update --init —recursive
Fixing a commit
//this will open up the interactive rebase, starting the the last commit from the tracking branch (origin/develop)
git rebase -i
//then we get the interactive commits picker (order is reverse, compared to git log)
//pick/edit/whatever
//fix commit
git add [affect files]
git commit --amend
//when satisfied - continue
git rebase --continue
//then push to Gerrit
Splitting a commit:
git reset HEAD~
//if it is further than the last commit, first edit it with rebase:
git rebase -i HEAD~3
//then do
git reset HEAD~
//split as you like, and then
git rebase —continue
GHE: How to submit revised commit to pull request
//amend you commit, and then force push it.
git push --force origin HEAD:[your local branch, e.g., master]
GHE: How to merge branches in GHE
we are merging upstream branch release-0.0.x, into master
//first, checkout the branch from GHE to your local repo, and branch that
git checkout -b merging00x upstream/master
//now, merge the upstream branch into
git merge upstream/release-0.0.x --log
//fix any conflicts (fix the conflict and do git add filename)
//when done:
git commit
//then push to your GHE fork
git push origin merging00x
//create a pull request in GHE from you merging00x fork to the upstream master (probably android:paste?)
Gerrit merge
//first, checkout the branch from origin to your local repo, and branch that
git checkout -b temp_merge_branch_name origin/develop
//now, merge the upstream branch into
git merge --no-commit --no-ff --no-edit origin/testing-android-2.0.0
//reset core
git reset HEAD native/src/core
git submodule update --init
//fix any conflicts (fix the conflict and do git add filename)
//when done:
git commit
//then push
git push origin HEAD:refs/for/develop
Note: If the merge commit fails to be merged to develop due to missing dependency, it means the testing branch needs to be amend a bit. Push an empty commit to it:
git commit -m “pleasing the TeamCity gods with an empty commit to allow develop merge" --allow-empty
ghe PR branch pull
git fetch upstream pull/1234/head:pr-1234
git co pr-1234
Core push
Go to native/src/core
git fetch && git reset --hard origin/master
Do your changes and commit
git push origin HEAD:refs/publish/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment