How can I create a branch alias in such a way that it can be pushed and pulled without being treated as a separate branch. Some background:
We have a branch named Production
. For various reasons, I can't just rename the branch.
$ git branch --all
* master
remotes/origin/HEAD -> origin/master
remotes/origin/Production
remotes/origin/master
Sometimes I will git checkout production
by mistake and not notice it's a new branch. There is no remote branch production
. There is also no ref origin/production
.
$ git checkout production
Branch production set up to track remote branch production from origin.
Switched to a new branch 'production'
$ git status
On branch production
Your branch is up-to-date with 'origin/production'.
nothing to commit, working directory clean
$ git branch --all
master
* production
remotes/origin/HEAD -> origin/master
remotes/origin/Production
remotes/origin/master
Git created a local branch production
and claimed it is tracking the remote branch production
. Now if I commit and push or just push git will push a new branch. Not what I want.
$ git push
Total 0 (delta 0), reused 0 (delta 0)
To git@github.com:path/repo.git
* [new branch] production -> production
Then I have to step back and reverse things
$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
$ git branch -d production
warning: deleting branch 'production' that has been merged to
'refs/remotes/origin/production', but not yet merged to HEAD.
Deleted branch production (was bc6d7a2).
$ git push origin :production
To git@github.com:path/repo.git
- [deleted] production
$ git checkout Production
error: pathspec 'Production' did not match any file(s) known to git.
And somehow now I've lost Production
until I pull it again. Is git case sensitive or not?
$ git branch --all
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
$ git pull
From github.com:path/repo
* [new branch] Production -> origin/Production
Already up-to-date.
$ git checkout Production
Branch Production set up to track remote branch Production from origin.
Switched to a new branch 'Production'
Your branch is up-to-date with 'origin/Production'.
And pushing doesn't push a new branch now. Actually what I want.
$ git push
Everything up-to-date
My first thought is to create an alias of the Production
branch that is called production
but I want it to be able to be pushed and pulled as though the two were actually the same thing. This is the thing I don't know how to do. All the alias methods in other questions appear to be local aliases only.
If you have a different solution to my problem, I'd like to hear it as well.
As a side note, bonus points if you can tell me why git is sometimes case sensitive and sometimes not.