How long does 'Git push -u' remember the parameters for?

I just got started with a tutorial on Git.

There, they mentioned a command

  • Get list of changes in branch since certain datetime
  • How to enable multiple usernames for git? ie. Specfic project can have specfic username
  • GitHub to Heroku Commit Error
  • got a git merge issue after git pull
  • Any reason against switching from svn to Git Version Control?
  • How to revert a folder to a particular commit by creating a patch
  • git push -u origin master

    where the changes made on local branch master are pushed to origin repository(on Github).
    And the -u tells git to remember the parameters so that next time we can just write git push

    Can someone tell me whether git remembers the parameters only for the very next time we use git push, or every time henceforth till a command to tell git to forget the parameters is written? Also, is any there such command?

    Thanks in advance!

  • Is there negation syntax for git add's filepattern?
  • Run git bash script in Windows 7/64bit
  • move one commit to the top of all commits
  • Git rebase complication
  • How to combine two unrelated git repositories, preserving history
  • Git delete branch and all corresponding changes
  • 2 Solutions collect form web for “How long does 'Git push -u' remember the parameters for?”

    In the command

    git push -u origin master

    The -u flag means that your local branch will become a tracking branch. That is, a branch that tracks a remote branch, so that future git pull will know which branch to merge from and git push will be directed to the correct remote branch.

    Technically, the tracking adds the following information about the master branch to your .git/config file:

    [branch "master"]
        remote = origin
        merge = refs/heads/master

    and it creates a file here .git/refs/remotes/origin/master, representing the remote branch.

    These settings are local to the current repository, so they will not apply to other repositories.

    The changes in .git/config are permanent (until you explicitly change them), so the effects of git push -u are permanent.

    git push -u tells git to track the remote branch locally (an ‘upstream tracking reference’), so git push whilst on the local branch will then always push to the remote branch specified in the initial git push -u. This will persist on the branch (or master in your case) until the next push -u you do (which will cause it to track another remote branch).

    It’s also used so that other git commands know where to retrieve data from e.g. git pull uses it to pull changes made to the remote being tracked to the local repo.

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