User Tools

Site Tools


git_cheat_sheet

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
git_cheat_sheet [2024/04/18 00:00] – [Import from SVN] stephengit_cheat_sheet [2025/12/04 00:38] (current) – [Who needs to clean up] stephen
Line 59: Line 59:
  ci = commit -m  ci = commit -m
  ca = commit --amend --no-edit  ca = commit --amend --no-edit
 + cu = reset HEAD~
 + cuh = reset --hard HEAD~
  br = branch  br = branch
  ba = branch -a  ba = branch -a
Line 66: Line 68:
  fa = fetch -a  fa = fetch -a
  tf = !git reset && git checkout -- . && git clean -df  tf = !git reset && git checkout -- . && git clean -df
 + as = !git add . && git stash
 + pr = !git stash pop && git reset
  brdr = push --delete origin  brdr = push --delete origin
  fp = push --force  fp = push --force
Line 145: Line 149:
 | ''<nowiki>git log --no-merges --oneline develop..</nowiki>'' | Show all commits on the current branch. | | ''<nowiki>git log --no-merges --oneline develop..</nowiki>'' | Show all commits on the current branch. |
 | ''<nowiki>git cherry-pick ebe6942^..905e279</nowiki>'' | Cherry-pick an //inclusive// commit range. | | ''<nowiki>git cherry-pick ebe6942^..905e279</nowiki>'' | Cherry-pick an //inclusive// commit range. |
 +| ''<nowiki>git --git-dir=../<other repo>/.git format-patch -k -1 --stdout <commit hash> | git am -3 -k</nowiki>'' | 'Cherry pick' a commit from another repo. |
 | ''<nowiki>git remote -v</nowiki>'' | View remote / origin URL. | | ''<nowiki>git remote -v</nowiki>'' | View remote / origin URL. |
  
Line 271: Line 276:
 ===== Who needs to clean up ===== ===== Who needs to clean up =====
  
-Lists the author and date of the last commit on each remote branch. Need to run it on bash.+Lists the author and date of the last commit on each remote branch.
  
-<code>+Bash: 
 +<code bash>
 for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ai %ar by %an" $branch | head -n 1` \\t$branch; done | sort -r for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ai %ar by %an" $branch | head -n 1` \\t$branch; done | sort -r
 </code> </code>
  
 +Powershell:
 +<code powershell>
 +git branch -r | Where-Object { $_ -notmatch 'HEAD' } | ForEach-Object {
 +    $branch = $_.Trim()
 +    $info = git show --format="%ai %ar by %an" $branch | Select-Object -First 1
 +    [PSCustomObject]@{
 +        Info = $info
 +        Branch = $branch
 +    }
 +} | Sort-Object Info -Descending | Format-Table -AutoSize
 +</code>
 ===== How PRs work ===== ===== How PRs work =====
  
git_cheat_sheet.1713398414.txt.gz · Last modified: 2024/04/18 12:00 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki