Add to and break up branching
parent
fbf5dfe5bb
commit
91521d5d2b
|
@ -9,7 +9,6 @@ pages:
|
|||
before_script:
|
||||
- export PATH="$PATH:$CARGO_HOME/bin"
|
||||
- mdbook --version || cargo install --debug mdbook
|
||||
- cargo install mdbook-toc
|
||||
script:
|
||||
- mdbook build -d public
|
||||
only:
|
||||
|
|
|
@ -15,8 +15,10 @@
|
|||
* [Fixing commits](commits/fixing.md)
|
||||
* [Stashing](stashing.md)
|
||||
* [Collaboration](collaboration.md)
|
||||
* [Branches](branching.md)
|
||||
* [Rebasing](rebasing.md)
|
||||
* [Branching](branching.md)
|
||||
* [Rebasing](branching/rebasing.md)
|
||||
* [Reporting](branching/reporting.md)
|
||||
* [Worktree](branching/worktree.md)
|
||||
* [Tags](tags.md)
|
||||
* [Logging](logging.md)
|
||||
* [Output examples](logging/outputs.md)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Branching
|
||||
```bash
|
||||
# Create a new branch.
|
||||
# Create a new branch. Stay in the current branch.
|
||||
git branch <branchName>
|
||||
|
||||
# Create a new branch at a specific commit, and switch to it.
|
||||
|
@ -42,12 +42,6 @@ git merge master
|
|||
# Abort a merge (such as if there's conflicts that need to be resolved differently).
|
||||
git merge --abort
|
||||
|
||||
# Delete a branch.
|
||||
git branch -d my_new_branch
|
||||
|
||||
# Delete a branch on the remote.
|
||||
git push origin :my_new_branch
|
||||
|
||||
# Merge two local branches, without fast-forwarding, with default editor opening to modify the message.
|
||||
git merge <branchName> --no-ff --edit
|
||||
|
||||
|
@ -74,6 +68,15 @@ git cherry-pick -n <commitId>
|
|||
# Rename the current branch
|
||||
git branch -m <newBranchName>
|
||||
|
||||
# Show all local branches with last commit message.
|
||||
git branch -v
|
||||
|
||||
# Above, plus corresponding remote branch name. Also includes worktree path, if applicable.
|
||||
git branch -vv
|
||||
```
|
||||
|
||||
## Navigating
|
||||
```bash
|
||||
# Get the name of the previous branch.
|
||||
git rev-parse --symbolic-full-name @{-1}
|
||||
# For PowerShell.
|
||||
|
@ -82,32 +85,12 @@ git rev-parse --symbolic-full-name '@{-1}'
|
|||
|
||||
## Management
|
||||
```bash
|
||||
# Show all current branches, including remotes.
|
||||
git show-branch -a --list
|
||||
# Delete a branch.
|
||||
git branch -d my_new_branch
|
||||
|
||||
# Show all local branches that have been merged into master.
|
||||
git branch --merged
|
||||
|
||||
# Show all local branches that have not been merged into master.
|
||||
git branch --no-merged
|
||||
|
||||
# Show all local branches, sorted by and showing last commit
|
||||
# https://stackoverflow.com/a/5188364/11912
|
||||
git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
|
||||
# Delete a branch on the remote.
|
||||
git push origin :my_new_branch
|
||||
|
||||
# Do a dry run of pruning local branches that no longer exist on a remote.
|
||||
git remote prune origin --dry-run
|
||||
```
|
||||
|
||||
## Worktree
|
||||
|
||||
```bash
|
||||
# List all worktrees for the current repo.
|
||||
git worktree list
|
||||
|
||||
# Create a new worktree for a specific branch. Path can't be a current working directory.
|
||||
git worktree add ../path/for/branchName
|
||||
|
||||
# Delete a worktree.
|
||||
git worktree remove path/to/worktree
|
||||
```
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
# Reporting
|
||||
```bash
|
||||
# Show all current branches, including remotes.
|
||||
git show-branch -a --list
|
||||
|
||||
# Show all local branches that have been merged into master.
|
||||
git branch --merged
|
||||
|
||||
# Show all local branches that have not been merged into master.
|
||||
git branch --no-merged
|
||||
|
||||
# Show all local branches, sorted by and showing last commit
|
||||
# https://stackoverflow.com/a/5188364/11912
|
||||
git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
|
||||
```
|
|
@ -0,0 +1,12 @@
|
|||
# Worktree
|
||||
|
||||
```bash
|
||||
# List all worktrees for the current repo.
|
||||
git worktree list
|
||||
|
||||
# Create a new worktree for a specific branch. Path can't be a current working directory.
|
||||
git worktree add ../path/for/branchName
|
||||
|
||||
# Delete a worktree.
|
||||
git worktree remove path/to/worktree
|
||||
```
|
Loading…
Reference in New Issue