Any Git shortcuts for the current branch and the branch it tracks?

I would like to do something like this:

$ git fetch origin
$ git rebase -i origin/a_very_very_very_long_branch_name

Where, my local branch name is as same as a_very_very_very_long_branch_name.

  • move branch so that it branches off from master in git
  • Git: Fetching latest commit on a branch
  • Switch node_modules folder when I change git branch
  • Subversion branch reintegration
  • How to move master to branch without merge
  • How to determine when a Git branch was created?
  • So when I execute this kind of command, I don’t want to copy and paste the long branch name again and again.

    Are there any shortcuts for the current branch name in Git?

  • how to get git working on git proxy
  • git add * (asterisk) vs git add . (period)
  • Concurrent operations on a Git repo
  • Why I lost my master branch after executing `git checkout -b 3_1 `?
  • GitHub: Setup SSH
  • git central repository and Team
  • 3 Solutions collect form web for “Any Git shortcuts for the current branch and the branch it tracks?”

    In your particular example, if your branch is tracking the remote branch, you can just do

    git fetch
    git rebase -i

    Without parameters.

    In case your branch is not tracking the remote branch, that can be set up by doing

    git branch -u origin/a_very_very_very_long_branch_name

    If your branch is set up to track the remote branch of the same name in origin, you can use @{u} as pointed out in the manpage gitrevisions:

    <branchname>@{upstream}, e.g. master@{upstream}, @{u}

    The suffix @{upstream} to a branchname (short form <branchname>@{u}) refers to the branch that the branch specified by branchname is set to build on top of. A missing branchname defaults to the current one.

    You could always create an alias to do the rebase to origin/current-branch;

    git fetch ; git rebase -i origin/$(git rev-parse --abbrev-ref HEAD)

    Or, if you don’t specifically need the interactive part of the rebase;

    git pull --rebase

    Git Baby is a git and github fan, let's start git clone.