简体   繁体   English

为什么git commits存在于我的本地克隆目录中,而不存在于GitHub上?

[英]Why do git commits exist on my local clone/directory but not on GitHub?

I have committed and pushed several changes for a project using git on the command line, but when I log in to GitHub, the branches and commits I made are not shown on my account. 我已经在命令行上使用git提交并推送了对项目的一些更改,但是当我登录GitHub时,我所做的分支和提交未显示在我的帐户中。 Why? 为什么?

I can review all commit history I have made using git on the command line. 我可以在命令行上使用git查看所有提交历史。

Results of git remote -v command git remote -v命令的结果

origin  https://github.com/felixtan/guessing-game.git (fetch)
origin  https://github.com/felixtan/guessing-game.git (push)

Once committed locally, you still need to push those commits to github: 一旦在本地提交,您仍然需要将这些提交推送到github:

git push

(since your remote is named origin, you don't need to specify its name: it pushes by default to 'origin') (由于您的遥控器被命名为Origin,因此您无需指定其名称:默认情况下它会推送到“ origin”)

This assumes you are the owner or one of the collaborators of the repo felixtan/guessing-game . 这假设您是repo felixtan / guessing-game的所有者或合作者之一。

If it is the first time you push your current branch: 如果这是您第一次推送当前分支,请执行以下操作:

git push -u origin yourCurrentBranch

That establish a tracking relationship between your branch and ' origin/yourBranch ', as detailed in " Why do I need to explicitly push a new branch? ". 这将在您的分支与“ origin/yourBranch ”之间建立跟踪关系,如“ 为什么需要显式推送新分支? ”中所述。

Once that first push is done, the subsequent pushes are simple ' git push '. 一旦完成第一次推送,随后的推送就是简单的“ git push ”。


If you are not the owner/collaborator, you won't have the right to push to that repo. 如果您不是所有者/合作者,则无权推送到该存储库。

You need to make a fork (See GitHub forking ), and in your local cloned repo you are already working on: 您需要制作一个分叉 (请参阅GitHub forking ),并且在本地克隆的仓库中您已经在工作:

git remote rename origin upstream
git remote add origin https://YourLogin@github.com/YourLogin/guessing-game.git

That way, you will push to your fork (that you own), and will make pull requests from there (See GitHub pull requests ). 这样,您将推入(您拥有的)分叉,并从那里发出拉取请求 (请参阅GitHub的拉取请求 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM