Arnold
Arnold

Reputation: 903

How can I commit and push to someone else's repository on 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".

Upvotes: 15

Views: 32938

Answers (3)

Arnold
Arnold

Reputation: 903

RESOLVED. I deleted and recloned the directory now that I have collaborator permissions. This was definitely the way to go because it removed the failed ssh keys and all of the different configurations I'd been experimenting with. Once everything was recloned, I re-made my directory, put a blank file in it, git added the directory and then the file, committed my change from the astr596 repository, and pushed to origin. Success!

Upvotes: 3

asmacdo
asmacdo

Reputation: 653

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>
    

Upvotes: 5

Fernando
Fernando

Reputation: 83

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.

Upvotes: 1

Related Questions