如何在Github上使用终端命令? [英] How to use terminal commands with Github?

查看:178
本文介绍了如何在Github上使用终端命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个私有仓库(一个iPhone项目),如下所示:

  cd nameofdirectory 
git init
git clone forkedURL

现在我想将我所做的更改推送到我的分叉存储库主管理员可以检查我的书面代码并将其与主存储库合并。



如何使用MacOS上的终端将我所做的更改推送到我的分叉库中?

解决方案

您无法推入其他人的存储库。这是因为推送永久性地将代码存入他们的存储库,这不是很酷。



你应该做的是要求他们从您的存储库。这在GitHub中通过转到其他存储库并发送pull请求来完成。



有关GitHub帮助本身的非常丰富的文章: https://help.github.com/articles/using-pull-requests






要与您自己的存储库进行交互,请使用以下命令。



将新文件添加到存储库或将更改后的文件添加到暂存区域:

  $ git add< files> 

提交它们:

  $ git commit 

提交非分页但已更改的文件:

  $ git commit -a 

推送到存储库(例如 origin ):

  $ git push origin 

只推送一个分支(比如 master ):

  $ git push origin master 

要获取另一个存储库的内容(例如 origin ):

  $ git fetch origin 

只抓取其中一个分支(例如 master ):

  $ git获取原始大师

要将分支与当前分支合并(比如 other_branch ):

  $ git merge other_branch 

注意 origin / m aster 是您在前一步从 origin 中获取的分支的名称。因此,更新你的主分支从原产地完成:

  $ git fetch origin master 
$ git merge origin / master

你可以在他们的手册页面阅读所有这些命令(无论是在你的linux还是在线) ,或者按照GitHub的帮助:


I have forked a private repository (an iPhone project) as follows:

cd nameofdirectory
git init
git clone forkedURL

Now I want to push the changes done by me to my forked repository so that the main admin can review my written code and merge it with the main repository.

How can I push the changes done by me to my forked repository using terminal on MacOS?

解决方案

You can't push into other people's repositories. This is because push permanently gets code into their repository, which is not cool.

What you should do, is to ask them to pull from your repository. This is done in GitHub by going to the other repository and sending a "pull request".

There is a very informative article on the GitHub's help itself: https://help.github.com/articles/using-pull-requests


To interact with your own repository, you have the following commands. I suggest you start reading on Git a bit more for these instructions (lots of materials online).

To add new files to the repository or add changed files to staged area:

$ git add <files>

To commit them:

$ git commit

To commit unstaged but changed files:

$ git commit -a

To push to a repository (say origin):

$ git push origin

To push only one of your branches (say master):

$ git push origin master

To fetch the contents of another repository (say origin):

$ git fetch origin

To fetch only one of the branches (say master):

$ git fetch origin master

To merge a branch with the current branch (say other_branch):

$ git merge other_branch

Note that origin/master is the name of the branch you fetched in the previous step from origin. Therefore, updating your master branch from origin is done by:

$ git fetch origin master
$ git merge origin/master

You can read about all of these commands in their manual pages (either on your linux or online), or follow the GitHub helps:

这篇关于如何在Github上使用终端命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆