How long does 'Git push -u' remember options for?

I just started with a tutorial on Git.

There they mentioned a team

git push -u origin master

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

Can someone tell me if git will remember the parameters only the very time we use git push , or every time now, until the command tells git to forget the parameters are written? Also, is there such a team?

Thanks in advance!

+4
source share
2 answers

In a team

 git push -u origin master 

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

Technically, tracking adds the following main branch information 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 be applied to other repositories.

Changes to .git/config are permanent (unless you explicitly change them), so the effects of git push -u are permanent.

+7
source

git push -u tells git to track the local remote branch (the "upstream tracking link"), so git push , while on the local branch, the remote branch specified in the initial git push -u will always be git push -u . This will remain on the branch (or leading in your case) until the next push -u (which will cause it to be tracked by another remote branch).

It is also used to let other git commands know where to retrieve data, for example. git pull uses it to pull changes made to a remote object tracked by a local repo.

+2
source

Source: https://habr.com/ru/post/1487033/


All Articles