In my work it is very common to switch between feature branches and stage / develop branches several times during the day. And many of these times I need to write or use a tab to complete the name of the branch even though it is inside it. I wanted something that acted similarly to a this
in programming: a reference to the current branch name.
Problem:
$ git checkout -b feature/nova-feature
// aqui eu trabalho na nova feature ate ficar ok
$ git push origin feature/nova-feature (*)
$ git checkout stage && git merge feature/nova-feature (*)
$ git push origin stage (*)
$ git checkout feature/outra-feature
// trabalho em mais alguma coisa
$ git push origin feature/outra-feature (*)
$ git checkout stage && git merge feature/outra-feature (*)
$ git push origin stage (*)
etc
In 8 interactions with git
I had to write 6 times the name of the branch I'm in (on 3 different branches).
What I already have today in my .gitconfig
[alias]
mg = merge --no-ff --no-edit
mc = commit -a --no-edit
df = "!git diff --color | diff-so-fancy"
ck = "!git checkout $1 && git pull origin $1"
gr = "!git branch | !grep $1"
msp = "!git ck $1 && git mg $2 && git push origin $1"
ck
, gr
, and msp
are aliases that allow me to write the branch name only once when I am concatenating.
What I wanted:
$ git checkout -b feature/nova-feature
// aqui eu trabalho na nova feature ate ficar ok
$ git push origin this
$ git checkout stage && git merge this
$ git push origin this
$ git checkout feature/outra-feature
// trabalho em mais alguma coisa
$ git push origin this
$ git checkout stage && git merge this
$ git push origin this
So that I could create alias
for these most common actions that work in any branch, without typing the name. Do you have a way?