-
-
Notifications
You must be signed in to change notification settings - Fork 89
Add git tips #669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add git tips #669
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -55,3 +55,37 @@ | |||||
| git branch -D my-branch | ||||||
| git push -d origin my-branch | ||||||
| ``` | ||||||
| # Tips and Tricks | ||||||
|
|
||||||
| ## Use worktrees to make switching between branches easier | ||||||
|
|
||||||
| It's possible to create a worktree to make working with things like stack updates easier. | ||||||
| If you need to switch focus, you can switch to a different folder with a different worktree (like main). | ||||||
| When you're ready to return to previous work, like the stack update, change to its folder. | ||||||
|
|
||||||
| The [official docs from git](https://git-scm.com/docs/git-worktree) have details on how to do this. | ||||||
|
|
||||||
| ## Splitting a commit during `rebase -i` | ||||||
|
|
||||||
| There may be times when you're in the middle of an interactive rebase where you want to split a commit. To do this, start by running | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ```bash | ||||||
| git rebase -i origin/HEAD --autostash | ||||||
| ``` | ||||||
|
|
||||||
| Then, find the needed commit and change pick to e (short for edit), save and exit. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I'm not entirely sure if those should be quoted, or code text (like |
||||||
| Then run | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ```bash | ||||||
| git reset HEAD~ | ||||||
| ``` | ||||||
|
|
||||||
| If you run `git status` you can see the changes are unstaged. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| Then `gotopkg your-package` and run `git add` and `git commit` as normal. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| Do the same for the second split. | ||||||
| Then run | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think both this line and the previous one should also either be on the same line, or have a blank line added between them. |
||||||
|
|
||||||
| ```bash | ||||||
| git rebase --continue | ||||||
| git push --force-with-lease | ||||||
| ``` | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.