我有一个包含文件的目录:test.js
。我初始化git存储库并进行第一次提交:
myusername@laptop:~/test$ git init
Initialized empty Git repository in /home/myusername/test/.git/
myusername@laptop:~/test$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# test.js
nothing added to commit but untracked files present (use "git add" to track)
myusername@laptop:~/test$ git add .
myusername@laptop:~/test$ git commit -m "Test commit"
[master (root-commit) a1ba24e] Test commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test.js
然后我输入:git status
:
myusername@laptop:~/test$ git status
# On branch master
nothing to commit, working directory clean
这就像我已经推动了我的改变一样。但他们没有被推!
我希望看到这一个:
# Your branch is ahead of 'origin/master' by 1 commit.
# (use "git push" to publish your local commits)
我想这是因为git
的新版本。
这是新功能还是错误?我希望看到当我输入git status
时没有推送多少次提交 - 但如果这是一个新功能,我怎么能看到它?
答案 0 :(得分:4)
根据您的工作流程,您在创建存储库时未设置远程。因此,没有origin/master
领先。试试这个,看看会发生什么:
git remote add origin <remote_uri>
git branch --set-upstream master origin/master
git pull
git status