What is the purpose of git merge's rebase option?

Learning git from here

git pull --rebase origin master

What is the difference with and without the –rebase option? I read that rebase option allows you to put your own commits over the master branch after the commits have synced up, but isn’t that what happens normally anyway?

  • Git checkout repository from N days ago
  • Are there different meanings to the concept of 'tracking' in git?
  • git: fatal: Cannot switch branch to a non-commit '12382'
  • Subdirectories in checked out directory of a previous revision not disappearing in Git?
  • Git: Is checking out a branch while visual studio open bad practice?
  • What does “fatal: You are on a branch yet to be born” mean in this context
  • I also don’t understand the purpose of designating a branch as an option during checkout.

    git checkout -b marys-feature master

    Why do you need to designate master? If you’re already on master on it, wouldn’t making a new branch automatically make it a copy of the master branch. If so, designating the branch you want to make a copy of is only useful if you’re on a branch (the currently checked out branch) that you don’t want to copy off of it right?

    Also, what’s the purpose of the -u option during a push?

    git push -u origin marys-feature

    Even if you don’t have the -u it would have made it a remote tracking branch right? I thought anything you push will make it remote tracking automatically?

  • managing permissions between windows and mac git commiters
  • GIT VCS not updating sources after Teamcity upgrade
  • How to browse Android source code at a particular version?
  • Made changes in wrong branch - How do I get those changes to a different branch for a commit
  • How to move Git repositories and minimize downtime
  • Can I specify multiple users for myself in .gitconfig?
  • 2 Solutions collect form web for “What is the purpose of git merge's rebase option?”

    From the git pull doc

    git pull runs git fetch with the given parameters and calls git merge
    to merge the retrieved branch heads into the current branch. With
    –rebase, it runs git rebase instead of git merge.

    From the git checkout doc

    Specifying -b causes a new branch to be created as if master was called and then checked out.

    In your case: git checkout -b marys-feature master
    It means that whatever branch you are on (with no change to commit), you will create a new branch named marys-feature with content from branch master.

    Rergarding your last question, you can refer to this link : What exactly does the "u" do? "git push -u origin master" vs "git push origin master"

    git push -u ... sets the specified upstream tracking branch.

    Meaning if it is not tracked already it would be set. If the branch is assigned an upstream tracking branch, change to the branch specified (overwrite). As such is normally only needed to be applied once when defining the upstream.

    Git push by default, does not automatically assign a remote tracking branch if the branch names are different, see the git-config documentation for details related to push.default.

    Defines the action git push should take if no refspec is explicitly
    given. Different values are well-suited for specific workflows; for
    instance, in a purely central workflow (i.e. the fetch source is equal
    to the push destination), upstream is probably what you want. Possible
    values are:

    nothing – do not push anything (error out) unless a refspec is
    explicitly given. This is primarily meant for people who want to avoid
    mistakes by always being explicit.

    current – push the current branch to update a branch with the same
    name on the receiving end. Works in both central and non-central

    upstream – push the current branch back to the branch whose changes
    are usually integrated into the current branch (which is called
    @{upstream}). This mode only makes sense if you are pushing to the
    same repository you would normally pull from (i.e. central workflow).

    simple – in centralized workflow, work like upstream with an added
    safety to refuse to push if the upstream branch’s name is different
    from the local one.

    When pushing to a remote that is different from the remote you
    normally pull from, work as current. This is the safest option and is
    suited for beginners.

    This mode has become the default in Git 2.0.

    matching – push all branches having the same name on both ends. This
    makes the repository you are pushing to remember the set of branches
    that will be pushed out (e.g. if you always push maint and master
    there and no other branches, the repository you push to will have
    these two branches, and your local maint and master will be pushed

    git checkout -b marys-feature master

    Is a shortcut for running

    git branch marys-feature master
    git checkout marys-feature

    Which will create a new branch of master named marys-feature and change your working copy to marys-feature.

    See the official git-branch documentation for more details on creating a branch and changing your working copy.

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