Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use terminal commands with Github?

Tags:

git

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?

like image 567
iOS_Passion Avatar asked Jun 13 '12 17:06

iOS_Passion


People also ask

How do I use terminal on GitHub?

Open Terminal. To launch GitHub Desktop to the last opened repository, type github . To launch GitHub Desktop for a particular repository, type github followed by the path to the repository. You can also change to your repository path and then type github . to open that repository.

Can you run Git commands from terminal?

To execute Git commands on your computer, you must open a terminal (also known as command prompt, command shell, and command line).

Is there a terminal in GitHub?

GitHub CLI brings GitHub to your terminal. Free and open source.


2 Answers

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:

  • https://help.github.com/articles/create-a-repo for commit and push
  • https://help.github.com/articles/fork-a-repo for fetch and merge
like image 111
Shahbaz Avatar answered Sep 30 '22 17:09

Shahbaz


git add myfile.h git commit -m "your commit message" git push -u origin master 

if you don't remember all the files you need to update, use

git status 
like image 24
Morgan Avatar answered Sep 30 '22 18:09

Morgan