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 [2020/10/07 17:32] – [Squash Commits] tmccanna | newdevs:git:commands [2024/08/29 13:34] (current) – sleary | ||
---|---|---|---|
Line 1: | Line 1: | ||
**New Developers Working Group** | **New Developers Working Group** | ||
- | ====== Git for Windows ====== | + | ====== |
- | + | ||
- | ===== Useful | + | |
- | + | ||
- | ==== Git Commands | + | |
* '' | * '' | ||
Line 14: | Line 10: | ||
* '' | * '' | ||
* '' | * '' | ||
- | * '' | + | * '' |
- | * '' | + | * '' |
+ | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
+ | * '' | ||
+ | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
+ | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
Line 29: | Line 29: | ||
* '' | * '' | ||
* '' | * '' | ||
- | * '' | + | |
- | * '' | + | * '' |
- | * '' | + | |
- | * '' | + | * '' |
- | * '' | + | * '' |
- | * '' | + | * '' |
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
+ | * '' | ||
* '' | * '' | ||
+ | * '' | ||
+ | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
* | * | ||
- | * '' | + | * '' |
+ | * '' | ||
* '' | * '' | ||
+ | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
+ | * '' | ||
- | ==== Rebase ==== | + | ===== Rebase |
- | If your patch is behind current | + | If your patch is behind current |
- Open the git branch | - Open the git branch | ||
- | - Type: git rebase origin/master | + | - Type: git rebase origin/main --> rebases the current branch to main (you can do this when you have your branch checked out and changes committed, but have not yet pushed it) |
- If there are merge conflict errors, type: git status | - If there are merge conflict errors, type: git status | ||
- Open the file with the problem in your preferred text editor (notepad++, vim, nano, etc.) | - Open the file with the problem in your preferred text editor (notepad++, vim, nano, etc.) | ||
Line 60: | Line 72: | ||
- 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: git rebase -i origin/ | + | |
+ | - Use 'git log' to verify that the commits you want to combine are the most recent | ||
+ | - 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 " |
- | * git push --force working lp1839359_login_select: | + | - Push the changes up to your remote working directory |
- | + | * '' | |
- | + | ||
- | ==== Common Bash Commands ==== | + | |
- | + | ||
- | * '' | + | |
- | | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | + | ||
- | ==== Vim Text Editor ==== | + | |
- | + | ||
- | The vim text editor is built into the bash console (similar to notepad in Windows). | + | |
- | * '' | + | If you've already pushed multiple commits up to your remote working git repository, you can still combine them: |
- | * '' | + | |
- | Vim opens in command mode, which allows a variety of functions, but does not allow direct editing. | + | - Follow the steps above, but when pushing, use "--force" |
- | * '' | + | * '' |
- | * '' | + | |
- | * '': | + | |
- | * '' | + | |
- | * '': | + | |
+ | ===== Aliases ===== | ||
+ | Shortens normal commands so you type less: | ||
+ | < | ||
+ | $ 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 | ||
+ | </ | ||
newdevs/git/commands.1602106350.txt.gz · Last modified: 2022/02/10 13:34 (external edit)