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.

  • Linking SVN repository trunk as branch for Git repository subfolder
  • How do I fix the fact that I'm working on the wrong branch
  • Source code management strategies - branching, tagging, forking, etc. - for web apps
  • Visualize branches on GitHub
  • Make git master HEAD point to current HEAD of branch
  • How can I find out which files have been modified in a branch?
  • 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 restore the aborted or interrupted “git clone”?
  • Git - How to see if a branch has EVER been merged into another branch?
  • Git force revert to HEAD~7
  • rebase reverted merged branch
  • New Git repository has no “master” branch
  • Git - get all commits and blobs they created
  • 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.