Rockbox Technical Forums

Rockbox Development => Starting Development and Compiling => Topic started by: Bilgus on June 22, 2020, 10:51:32 AM

Title: Git commands cheat sheet
Post by: Bilgus on June 22, 2020, 10:51:32 AM
I figured it'd be nice to have an online document of helpful git commands

Rebase master branch
Code: [Select]
git checkout master
git pull --rebase

Rebase child branch
Code: [Select]
git checkout <childbranch>
git rebase master

Merge a patchset
Code: [Select]
patch -p1 < /path/to/diff.diff
Create a new branch
Code: [Select]
git checkout -b <new_branch>
Display branches
Code: [Select]
git branch
Rename branch
(in desired branch)
Code: [Select]
git branch -m <new_name>
Delete branch
Code: [Select]
git branch -d <localbranch>
Reset to master
Code: [Select]
git reset --hard origin/master

Pull Patch from gerrit back to local by reference/#gerrit id:
Code: [Select]
git ls-remote | grep 1234
From git://
bc9e5af34c61639ce815df9b8e4b2af860b20a2b   refs/changes/34/1234/1
c75309a65f0c49f9b1042f578141f97506e3d2bc   refs/changes/34/1234/2
2d95c8b9f2eab115dc421234b9c058b249f47e09   refs/changes/73/1073/12
5d106748ec32654ccf53718a9dac2088d12341d8   refs/changes/73/73/1
27217bfe1052401386be677212347024a1009c37   refs/tags/rbutil_1.2.11

Code: [Select]
git pull origin refs/changes/34/1234/2
Code: [Select]
git-review -d c75309a65f0c49f9b1042f578141f97506e3d2bc
Code: [Select]
you may need to install sudo apt-get git-review && git config --global --add gitreview.remote origin

Code: [Select]
git status
Revert file
Code: [Select]
git checkout <filename>
Revert all modified files
Code: [Select]
git checkout `git status | grep modified | sed 's/\(.*modified:\s*\)//'`
Add a file to commit
Code: [Select]
git add <filename>
Add all modified files to a commit
Code: [Select]
git add `git status | grep modified | sed 's/\(.*modified:\s*\)//'`
Remove File added but not yet committed
Code: [Select]
git reset <filename>
Remove all modified files added to a commit
Code: [Select]
git reset `git status | grep modified | sed 's/\(.*modified:\s*\)//'`