Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I commit and push to someone else's repository on GitHub?

Tags:

git

github

I have cloned a repository created by a professor on my virtual machine (I'm running Ubuntu 13.10) and we're supposed to create personal folders. I created mine, but I cannot for the life of me commit and push it to make it show up on GitHub. I swear I have tried every answer on here, and things have improved somewhat. For instance, I originally had a version of Git that was too old and wouldn't permit https. I also created a blank file in my personal directory because I know GitHub doesn't store empty folders.

I originally cloned the repository using:

$ git clone git://github.com/astrofoley/astr596.git 

And then used

git config --global user.name "myusername"

and

git config --global user.email "myemail"

I checked with my professor and he made sure I have adequate permissions.

At this point, depending upon which commit and push methods I use (I always try to push to https://github.com/astrofoley/astr596.git), I get several different errors ranging from "nothing added to commit but untracked files present" to simply "403". I have no idea what I am doing wrong, but I suspect it is something related to the fact that the repository belongs to another account. Either way, this is getting incredibly frustrating. Please help!

EDIT: Here's an example of my current problem. I tried adding and committing the file in my directory again using

git add blank.txt

(this step seems to have worked fine) and then

git commit blank.txt

At this point I get the message "On branch master, nothing to commit, working directory clean".

like image 504
Arnold Avatar asked Jan 26 '14 22:01

Arnold


2 Answers

Just to make it comprehensive,

  1. Make a change.

    touch somefile.txt
    
  2. tell git to track this change

    git add somefile.txt
    
  3. commit the change

    git commit -m "what you did"
    
  4. set up your remote.

  5. push

    git push <remote> <branch>
    
like image 168
asmacdo Avatar answered Oct 19 '22 23:10

asmacdo


Are you added as a collaborator in your professor's repo? If you are working from a linux terminal you must give your professor a id_rsa.pub file to add you as collaborator (since the terminal is not synced with your github account, which actually happens if you use the GUI versions of github for win or mac).

Other option is to fork his repo into your account, clone it from there to your PC and then send "pull request" to the original repo.

like image 34
Fernando Avatar answered Oct 20 '22 01:10

Fernando