[GUIDE] How to upload repo with commit history

Search This thread

Mazda

Retired Recognized Developer
Oct 19, 2008
5,273
12,519
In the time I’ve spend dealing with open source projects and just being around fellow developers, I’ve found that there are a few things that should not happen but continue on happening.

Why does this happen?

Maybe a case of laziness, maybe they are trying to hide something….who knows but one thing that is sure is that it should not happen.

What I’m speaking of is people uploading repos without commit history. It bugs the living hell out of me. It does because sometimes I’m trying to learn how to do something and without commit history, is kind of difficult to do so. I mean, some brag that they’re 100 percent open source but I don’t think you can claim that without commit history in place.

Also, you can’t complain if you’re not willing to provide a solution to the problem….right?

Ok, well I will go ahead and provide a simple step by step way of uploading a repo with commit history as well as provide screenshots for those that learn by seeing.

So let’s say you want to upload a repo to your github but you don’t want to fork it for one reason or another.

I personally like to upload repos instead of forking them ONLY because I had a case back during Android 4.1.2 where I forked AOKP’s frameworks_base repo and some how it got corrupted and github claim that there was nothing they could do because it was a fork.

This made me mad and ever since I upload repos with commit history instead of just fork them on github.

Anyways, let’s start……

Find that repo and copy the HTTPS clone URL


Open up a terminal then type in "git clone + the https URL"


Press Enter and let it do it's thing


Now head over to github and create a repo, this is important


Now type in the name of the repo (whatever you want) and hit "Create repository"


You will be prompted with a screen like below, the bottom part is what we'll be using


Open up a terminal and navigate to the repo you git cloned above


Ok so when you fork a repo, you usually have a .git folder and with that it has a origin. Where it came from and what is used to know where to push to if you typed in something like git push origin or whatever. With that said, you have now git clone this repo and are wanting to upload it but yet keep commit history. So you need to type in the following command to remove the origin and have it pointing to your newly created repo

Keep in line with the step above, type in "git remote rm origin"


With all repos, you have branches. Branches are generally used to create snapshots of your work but sometimes used to work on other things while keeping the main goal in place and not having to create another repo. For example, if I had a repo that is used for KitKat 4.4.2 but Google decides to push 4.5 or 5.0 or whatever and I want to keep the work I did on 4.4.2, I would simply create another branch and use it for 4.5 or 5.0 or whatever.

With that said, you need to create a branch to start things off since this will a new repo....at least for you it is.

Type in "git branch master" and you'll find sometimes it exists, sometimes it doesn't. If it does then that's good......don't freak out! Just means you don't need to do this step :)


Ok after this you will need to go back to your github repo you created not so long ago and find the two lines I highlighted/had arrows pointing to and copy/paste them into terminal



Make sure you type in your Github username/password when prompted and the end result should look like this




ENJOY and hopefully this will help someone that doesn't exactly want to hide their kanging tracks but just doesn't know how to upload a repo with commit history!
 
Last edited:

bsined

Senior Member
Mar 22, 2013
229
134
Washington, DC
Although most coders do prefer working with the command prompt, managing Git branches and working with a remote repository can become tedious. GitHub has great GUI clients for Windows and Mac. The clients make it incredibly easy to clone repos, make commits (and see past ones), manage branches, and sync back to GH.
 
  • Like
Reactions: Mazda

spoidar

Senior Member
Aug 13, 2010
153
59
I personally like to upload repos instead of forking them ONLY because I had a case back during Android 4.1.2 where I forked AOKP’s frameworks_base repo and some how it got corrupted and github claim that there was nothing they could do because it was a fork.

This made me mad and ever since I upload repos with commit history instead of just fork them on github.

This is a really terrible idea, and you definitely should not be recommending that anyone else do this, simply because you had one issue one time (and where was your local copy of this code if it was so important?).

Choosing to upload a new repository instead of forking has a number of bad side-effects:
  • You lose the trail of ownership
  • You lose the commit graph
  • You lose the ability to send pull requests

The first item is useful, because then people can see the provenance of the code, and understand where they should submit issues that are not related directly to just your commits.

The second item is useful for people wanting to merge multiple forks into their local fork, or looking for fixes/features that other people have implemented outside the upstream project.

And the last item is the most important: by uploading a brand new repository, you've completely broken what makes Github great - the ability to collaborate easily with other teams.

I'd also suggest you paste textual code fragments rather than uploading massive images that are mostly just the blank space in your terminal - the images make for very painful reading, and also ensures copy/paste doesn't work.
 

Mazda

Retired Recognized Developer
Oct 19, 2008
5,273
12,519
Thanks guys for the kind words, glad it has made it to the portal and hopefully it can help someone in need of this info :)
 

Mazda

Retired Recognized Developer
Oct 19, 2008
5,273
12,519
Although most coders do prefer working with the command prompt, managing Git branches and working with a remote repository can become tedious. GitHub has great GUI clients for Windows and Mac. The clients make it incredibly easy to clone repos, make commits (and see past ones), manage branches, and sync back to GH.
This is true, Github has made it easy here recently and for that I give them a thumbs up :)
 

GottZ

Senior Member
Sep 20, 2008
170
124
35
Cologne
gottz.de
This is awesome but the screenshots are kinda unreadable on tapatalk. Good enough you added textual descriptions so following this guide is not impossible

Gesendet von meinem ThinkPad Tablet mit Tapatalk
 

iRiKi

Senior Member
Jul 27, 2007
618
19
Lisbon
This is awesome but the screenshots are kinda unreadable on tapatalk. Good enough you added textual descriptions so following this guide is not impossible

Gesendet von meinem ThinkPad Tablet mit Tapatalk

Yeah the screenshot are giant ;) Maybe you could crop them, especially the ones with the terminal, so only the necessarity text is shown.

And btw, bookmarked, thank you !!
 

Top Liked Posts

  • There are no posts matching your filters.
  • 31
    In the time I’ve spend dealing with open source projects and just being around fellow developers, I’ve found that there are a few things that should not happen but continue on happening.

    Why does this happen?

    Maybe a case of laziness, maybe they are trying to hide something….who knows but one thing that is sure is that it should not happen.

    What I’m speaking of is people uploading repos without commit history. It bugs the living hell out of me. It does because sometimes I’m trying to learn how to do something and without commit history, is kind of difficult to do so. I mean, some brag that they’re 100 percent open source but I don’t think you can claim that without commit history in place.

    Also, you can’t complain if you’re not willing to provide a solution to the problem….right?

    Ok, well I will go ahead and provide a simple step by step way of uploading a repo with commit history as well as provide screenshots for those that learn by seeing.

    So let’s say you want to upload a repo to your github but you don’t want to fork it for one reason or another.

    I personally like to upload repos instead of forking them ONLY because I had a case back during Android 4.1.2 where I forked AOKP’s frameworks_base repo and some how it got corrupted and github claim that there was nothing they could do because it was a fork.

    This made me mad and ever since I upload repos with commit history instead of just fork them on github.

    Anyways, let’s start……

    Find that repo and copy the HTTPS clone URL


    Open up a terminal then type in "git clone + the https URL"


    Press Enter and let it do it's thing


    Now head over to github and create a repo, this is important


    Now type in the name of the repo (whatever you want) and hit "Create repository"


    You will be prompted with a screen like below, the bottom part is what we'll be using


    Open up a terminal and navigate to the repo you git cloned above


    Ok so when you fork a repo, you usually have a .git folder and with that it has a origin. Where it came from and what is used to know where to push to if you typed in something like git push origin or whatever. With that said, you have now git clone this repo and are wanting to upload it but yet keep commit history. So you need to type in the following command to remove the origin and have it pointing to your newly created repo

    Keep in line with the step above, type in "git remote rm origin"


    With all repos, you have branches. Branches are generally used to create snapshots of your work but sometimes used to work on other things while keeping the main goal in place and not having to create another repo. For example, if I had a repo that is used for KitKat 4.4.2 but Google decides to push 4.5 or 5.0 or whatever and I want to keep the work I did on 4.4.2, I would simply create another branch and use it for 4.5 or 5.0 or whatever.

    With that said, you need to create a branch to start things off since this will a new repo....at least for you it is.

    Type in "git branch master" and you'll find sometimes it exists, sometimes it doesn't. If it does then that's good......don't freak out! Just means you don't need to do this step :)


    Ok after this you will need to go back to your github repo you created not so long ago and find the two lines I highlighted/had arrows pointing to and copy/paste them into terminal



    Make sure you type in your Github username/password when prompted and the end result should look like this




    ENJOY and hopefully this will help someone that doesn't exactly want to hide their kanging tracks but just doesn't know how to upload a repo with commit history!
    4
    I personally like to upload repos instead of forking them ONLY because I had a case back during Android 4.1.2 where I forked AOKP’s frameworks_base repo and some how it got corrupted and github claim that there was nothing they could do because it was a fork.

    This made me mad and ever since I upload repos with commit history instead of just fork them on github.

    This is a really terrible idea, and you definitely should not be recommending that anyone else do this, simply because you had one issue one time (and where was your local copy of this code if it was so important?).

    Choosing to upload a new repository instead of forking has a number of bad side-effects:
    • You lose the trail of ownership
    • You lose the commit graph
    • You lose the ability to send pull requests

    The first item is useful, because then people can see the provenance of the code, and understand where they should submit issues that are not related directly to just your commits.

    The second item is useful for people wanting to merge multiple forks into their local fork, or looking for fixes/features that other people have implemented outside the upstream project.

    And the last item is the most important: by uploading a brand new repository, you've completely broken what makes Github great - the ability to collaborate easily with other teams.

    I'd also suggest you paste textual code fragments rather than uploading massive images that are mostly just the blank space in your terminal - the images make for very painful reading, and also ensures copy/paste doesn't work.
    1
    Great guide. Hopefully many will put this to use.
    1
    Nice guide. :good:
    1
    Fine tutorial, bookmarked. :good: