# Fwd: git and github query about maintaining project

2 messages from 2012-01-03 to 2012-01-03. Participants: manoj soni, Seth Robertson.
Thread: https://gitlist.dev/t/29286

## manoj soni, 2012-01-03 19:42

Subject: Fwd: git and github query about maintaining project
Message-ID: <CA+KSefW+K1hMiFkrFCP1LAVjfV9hECwFWAHz940fwGJawHuoFQ@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BKSefW%2BK1hMiFkrFCP1LAVjfV9hECwFWAHz940fwGJawHuoFQ%40mail.gmail.com
In-Reply-To: <CA+KSefVajgEBCH+31a0DLXPGUgb2yshxPeXV+SdmGvPFVBOBtg@mail.gmail.com>

```
Dear Admin,
Forwarding you below email, which I have sent to wrong email address by mistake.

Thanks,
Manoj


---------- Forwarded message ----------
From: manoj soni <manoj6891@gmail.com>
Date: Tue, Jan 3, 2012 at 2:20 PM
Subject: git and github query about maintaining project
To: git@vger.kernel.orgm, support@github.com


Dear Admin,
I am using git along with github since august 2011. I am new to it but
now I know it significantly. It is interesting and helpful.
I have started with a already existing project (say P). We were two
persons working on this project, so we forked P (on github). I got
project forked copy C1 and my friend got C2. We each have committed to
C1 and C2 independently. Now my friend merged his commits from C2 to P
and moved out of this project. I have created a branch OLD in my
repository C1 along with a already existing master branch. What I want
to do that in my project C1, OLD branch should have all of my commits
and master branch should be same as P. Please tell how should I do
this? I am trying since a week to get it done, I have attempted some
unsuccessful tries, which I can tell you if you want. If you need more
information, please tell me.

Hope to get response.
I shall be thankful.
Manoj Soni

```

## Seth Robertson, 2012-01-03 20:21

Subject: Re: git and github query about maintaining project
Message-ID: <201201032021.q03KLblT024296@no.baka.org>
URL: https://gitlist.dev/e/201201032021.q03KLblT024296%40no.baka.org
In-Reply-To: <CA+KSefW+K1hMiFkrFCP1LAVjfV9hECwFWAHz940fwGJawHuoFQ@mail.gmail.com>

```

In message <CA+KSefW+K1hMiFkrFCP1LAVjfV9hECwFWAHz940fwGJawHuoFQ@mail.gmail.com>, manoj soni writes:

    Forwarding you below email, which I have sent to wrong email address by mistake.

You might want to ask on the IRC #git channel for tactical support
questions, like this. irc://irc.freenode.net/git

    we forked P (on github),  I got project forked copy C1

    What I want to do that in my project C1, OLD branch should have
    all of my commits and master branch should be same as P.

Tactically, the answer to your question is as follows:
----------------------------------------------------------------------
# Create a new branch OLD from where master is (presumably containing your commits)
git checkout -b OLD master

# Share OLD with your forked C1 (if you want to)
git push origin OLD
git branch --set-upstream OLD origin/OLD

# Get access to the repository you forked from
git remote add P URL-TO-P
git fetch P

# Reset the master branch to the contents of P/master
#  Please note that any uncommitted changes WILL BE LOST
git checkout master
git reset --hard P/master

# Share your rewritten history with origin (C1)
#  Please note, rewriting publicly visible history is a BAD IDEA.
#  Anyone else who might have pulled the old history will have to do
#  special things and may hate you forever.
git push -f origin
----------------------------------------------------------------------

However, interpreting what you are really trying to do (get your
changes and C2's changes put together and uploaded to P), this is what
*I* would do:
----------------------------------------------------------------------
# Get access to the repository you forked from git remote add P
URL-TO-P git fetch P

# Merge your development with the other development that has been happening
git merge origin/P

# Share your rewritten history with origin (C1)
git push

# When you have finished testing (unless you are using the github pull request method)
git push P master
----------------------------------------------------------------------

					-Seth Robertson

```
