newdevs:git:commands
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| newdevs:git:commands [2024/03/25 16:31] – [Squash Commits] tmccanna | newdevs:git:commands [2025/07/24 01:12] (current) – git commit --amend --date=now --no-edit sleary | ||
|---|---|---|---|
| Line 26: | Line 26: | ||
| * '' | * '' | ||
| * '' | * '' | ||
| + | * '' | ||
| * '' | * '' | ||
| * '' | * '' | ||
| Line 35: | Line 36: | ||
| * '' | * '' | ||
| * '' | * '' | ||
| - | * '' | + | |
| + | * '' | ||
| + | | ||
| * '' | * '' | ||
| * '' | * '' | ||
| Line 50: | Line 53: | ||
| * '' | * '' | ||
| * '' | * '' | ||
| + | * '' | ||
| * '' | * '' | ||
| * '' | * '' | ||
| Line 57: | Line 61: | ||
| * '' | * '' | ||
| - | ==== Rebase ==== | + | ===== Rebase |
| If your patch is behind current main, you'll need to rebase it. | If your patch is behind current main, you'll need to rebase it. | ||
| Line 70: | Line 74: | ||
| - Type: git rebase < | - Type: git rebase < | ||
| + | You can also use the interactive rebase mode to look at a series of commits: | ||
| + | |||
| + | - Open the git branch | ||
| + | - Type: '' | ||
| + | - (Optional but recommended) Save this pick list to a separate file, for recovery later if things go wrong | ||
| + | - Choose what to do with each line using the commands listed in the comment block (pick, edit, drop, fixup, squash) | ||
| + | - Save and close the "to do" file | ||
| + | - Follow the prompts to complete each step you specified | ||
| + | |||
| + | If you need to start over, just rebase again and paste in your original pick list. | ||
| - | ==== Squash Commits ==== | + | ===== Squash Commits |
| If you have multiple commits in your local branch that you'd like to combine: | If you have multiple commits in your local branch that you'd like to combine: | ||
| Line 85: | Line 99: | ||
| - Use "git commit --amend" | - Use "git commit --amend" | ||
| - Push the changes up to your remote working directory as normal | - Push the changes up to your remote working directory as normal | ||
| + | * '' | ||
| If you've already pushed multiple commits up to your remote working git repository, you can still combine them: | If you've already pushed multiple commits up to your remote working git repository, you can still combine them: | ||
| - Follow the steps above, but when pushing, use " | - Follow the steps above, but when pushing, use " | ||
| - | * '' | + | * '' |
| - | ==== Common Bash Commands | + | ===== Aliases ===== |
| - | * '' | + | Shortens normal commands so you type less. You can add them one at a time from the command |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | ==== Vim Text Editor ==== | + | < |
| + | $ git config alias.co checkout | ||
| + | $ git config alias.cp cherry-pick | ||
| + | $ git config alias.br branch | ||
| + | $ git config alias.ci commit | ||
| + | $ git config alias.st status | ||
| + | </ | ||
| - | The vim text editor is built into the bash console (similar | + | You can also edit '' |
| - | * '' | + | With the above aliases, you would check out main using: |
| - | * '' | + | |
| - | Vim opens in command mode, which allows a variety of functions, but does not allow direct editing. | + | <code>git co origin main</ |
| - | * '' | + | |
| - | * '' | + | |
| - | * '': | + | |
| - | * '': | + | |
| - | * '': | + | |
| - | * '': | + | |
| - | * ''? | + | |
| + | ==== Bash Aliases ==== | ||
| + | Mike Rylander suggests using bash aliases so you can skip typing '' | ||
| + | < | ||
| + | # git-related contents of miker' | ||
| + | alias branch=' | ||
| + | alias ci=' | ||
| + | alias co=' | ||
| + | alias dif=' | ||
| + | alias fetch=' | ||
| + | alias lg=' | ||
| + | alias pick=' | ||
| + | alias pull=' | ||
| + | alias push=' | ||
| + | alias stash=' | ||
| + | alias status=' | ||
| + | alias wt=' | ||
| + | </ | ||
| + | With these bash aliases in place, you would check out main using: | ||
| + | < | ||
newdevs/git/commands.1711398684.txt.gz · Last modified: 2024/03/25 16:31 by tmccanna