1

我从 git 开始。

我想知道该选项的-u作用。

那么 之间有什么区别:

  1. git add 对比 git add -u

  2. git push对比git push -u

4

2 回答 2

4

For Add, -u will make it only add updated files - eg. ones that you have already tracked/committed previously.

Manual entry for Add

For Push, -u will make it track the remote branch, so when you do git status it will let you know how many commits ahead/behind the remote branch you are at.

Manual entry for Push

于 2013-09-03T09:43:12.853 回答
1

Did you try reading the help?

git help add
git help push

to access it.

As for the specifics:

git add -u does the same as git add . except that it doesn't add untracked files, which the latter does.

git push -u sets the local branch as tracking the remote branch. Generally you only use it when you first push a new branch, and git will even tell you to use it then if you just type git push by mistake (it uses the long name --set-upstream).

于 2013-09-03T09:43:24.207 回答