Updated: Git: removing feature branch on merge
- Resolve @{-1} to actual branch name. (Happens when merging "-".)
Related cards:
Git: removing feature branches on merge
When working with feature branches, stale branches pile up over time. It's best to remove them right after merge, locally and on the remote, but it is a little t...
Git: How to rebase your feature branch from one branch to another
In a nutshell: Use git rebase --onto target-branch source-commit
-
target-branch
means "branch you want to be based on" -
source-commit
means "commit before your first feature commit"
Let's say my-feature-branch
...
Recommended Git workflow for feature branches
This is a guide on how to effectively use Git when working on a feature branch. It is designed to get out of your way as much as possible while you work, and ensure you end up with clean commits in the end.
**We assume you are the only person wor...
Git: rebase dependent feature branch after squash
This card will show you how to use git rebase --onto
without confusion.
Use case:
You've got two feature branches (one
and two
), where two
depends on one
. Now commits of branch one
have changed after you branched two
from...
Git: Remove information on branches that were deleted on origin
When branches get deleted on origin
, your local repository won't take notice of that.
You'll still have your locally cached versions of those branches (which is actually good) but git branch -a
will still list them as remote branches.
You ca...
GitLab: Git alias for creating a merge request on push
Git allows you to set push options when pushing a branch to the remote.
You can use this to build an alias that automatically pushes a branch and creates a merge request for it.
Put this in your ~/.gitconfig
in the [alias]
section:
mr = ...
Git: Merge a single commit from another branch
This is called "cherry-picking".
git cherry-pick commit-sha1
Note that since branches are nothing but commit pointers, cherry-picking the latest commit of a branch is as simple as
git cherry-pick my-feature-branch
**Be aware that c...
How to revert features for deployment, merge back, and how to stay sane
Removing features and merging those changes back can be painful. Here is how it worked for me.\
tl;dr: Before merging back: reinstate reverted features in a temporary branch, then me...
Git: How to check out branches that exist on multiple remotes
So you're using multiple remotes that offer the same branch?
$ git branch -a | grep my-branch
remotes/something/my-branch
remotes/origin/my-branch
And when trying to check out that remote branch, it fails for you with an error li...
Show the current Git branch on your Bash prompt
Append this to your ~/.bashrc
:
export PS1='\[\033[01;32m\]\h\[\033[01;34m\] \w\[\033[31m\]$(__git_ps1 "(%s)") \[\033[01;34m\]$\[\033[00m\] '
Reload the changes by saying
source ~/.bashrc
For some customized prompts that also ...