Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fork an existing read-only Git repository

I want to make additions to a Git, so that the original author is able to pull the changes. Normally I'd fork that on something like GitHub and the workflow is simple. However for external repos I did find nothing in the documentation.

Does anybody know how this would work for an external repository? Here's what I tried:

% more .git/config 
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "upstream"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git://wiesel.ece.utah.edu/gr-ieee802-15-4.git
[branch "master"]
    remote = origin
    merge = refs/heads/master
[remote "origin"]
    url = [email protected]:wishi/gr_802.15.4.git
    fetch = +refs/heads/*:refs/remotes/origin/*

upstream is supposed to be the remote repo, and master the GitHub thingy. So after a trivial first change:

% git commit -a -m "check"
[master 796f97a] check
 1 files changed, 1 insertions(+), 1 deletions(-)

% git push origin master
To [email protected]:wishi/gr_802.15.4.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:wishi/gr_802.15.4.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again.  See the 'Note about
fast-forwards' section of 'git push --help' for details.

So that makes sense: merge the two branches:

% git merge upstream/master
fatal: 'upstream/master' does not point to a commit

And here I am...

like image 548
wishi Avatar asked Jan 28 '26 12:01

wishi


1 Answers

I don't think it's this complicated.

  1. Clone the original repository git clone git://wiesel.ece.utah.edu/gr-ieee802-15-4.git
  2. Create a new repository on github (say gr-ieee802-15-4 under the username wishi).
  3. Add the r/w URL as a remote into your local clone - git remote add github [email protected]:wishi/gr-ieee802-15-4.git.
  4. Push to your newly added remote git push github master

Assuming that your ssh keys and stuff are set up correctly, this should work fine.

The original author can add a read only URL for your github repository as a remote in his local clone, update that and pull in any changes which you've made. The "pull request" will have to be done via. email or an external issue tracker.

like image 104
Noufal Ibrahim Avatar answered Jan 30 '26 03:01

Noufal Ibrahim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!