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 [2023/07/20 09:14] – tmccanna | newdevs:git:commands [2025/07/24 01:12] (current) – git commit --amend --date=now --no-edit sleary | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| **New Developers Working Group** | **New Developers Working Group** | ||
| - | ====== Git for Windows ====== | + | ====== |
| - | + | ||
| - | ===== Useful | + | |
| - | + | ||
| - | ==== Git Commands | + | |
| * '' | * '' | ||
| Line 22: | Line 18: | ||
| * '' | * '' | ||
| * '' | * '' | ||
| + | * '' | ||
| * '' | * '' | ||
| * '' | * '' | ||
| * '' | * '' | ||
| * '' | * '' | ||
| + | * '' | ||
| * '' | * '' | ||
| * '' | * '' | ||
| + | * '' | ||
| * '' | * '' | ||
| * '' | * '' | ||
| * '' | * '' | ||
| + | * '' | ||
| + | * '' | ||
| * '' | * '' | ||
| * '' | * '' | ||
| * '' | * '' | ||
| * '' | * '' | ||
| - | * '' | + | |
| + | * '' | ||
| + | | ||
| * '' | * '' | ||
| * '' | * '' | ||
| Line 43: | Line 46: | ||
| * '' | * '' | ||
| * '' | * '' | ||
| - | * '' | + | * '' |
| * '' | * '' | ||
| * '' | * '' | ||
| * '' | * '' | ||
| * | * | ||
| - | * '' | + | * '' |
| + | * '' | ||
| + | * '' | ||
| * '' | * '' | ||
| * '' | * '' | ||
| Line 56: | 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 69: | 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 | ||
| - | ==== Squash Commits ==== | + | If you need to start over, just rebase again and paste in your original pick list. |
| - | If you are in your local working branch and you've pushed up two commits to the remote git repository, you can combine them: | + | ===== Squash Commits ===== |
| - | - Verify that you are in your local branch. | + | If you have multiple commits |
| - | - Type: '' | + | |
| - | * Alternatively if your branch is already built on current main, you can use: '' | + | - Use ' |
| + | - Type '' | ||
| - Your text editor will open and should show both of the commits, for example: | - Your text editor will open and should show both of the commits, for example: | ||
| * pick 014e59c579 LP#1839359 Select element on login not accessible | * pick 014e59c579 LP#1839359 Select element on login not accessible | ||
| * pick 9de92lsi9a LP#1839359 Select element on login not accessible | * pick 9de92lsi9a LP#1839359 Select element on login not accessible | ||
| - | - Change the word " | + | - Change the word " |
| * squash --> merges commits, then allows amendment of commit message | * squash --> merges commits, then allows amendment of commit message | ||
| * fixup --> merges commits like squash does, but discards previous commit message | * fixup --> merges commits like squash does, but discards previous commit message | ||
| - | - Push the commit | + | - Use " |
| - | * '' | + | - 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: | ||
| + | - 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.1689858842.txt.gz · Last modified: 2023/07/20 09:14 by tmccanna