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:35] – tmccanna | newdevs:git:commands [2025/04/04 13:28] (current) – [Useful Git Commands] tmccanna | ||
---|---|---|---|
Line 52: | Line 52: | ||
* '' | * '' | ||
* '' | * '' | ||
+ | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
Line 59: | Line 60: | ||
* '' | * '' | ||
- | ==== 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 72: | Line 73: | ||
- 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 94: | Line 105: | ||
* '' | * '' | ||
+ | ===== Aliases ===== | ||
- | ==== Common Bash Commands ==== | + | 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.1711398939.txt.gz · Last modified: 2024/03/25 16:35 by tmccanna