How to clone a repository into another repository from a specific point
While working on our project I had to create a repository clone up until a specific commit. So, I began researching and after trial and error, I finally made it. Therefore, I thought I will share what I’ve done with the community, as copying a git repository is not the easiest task.
Below you will find git commands I used to do so, and below the code, quick explanation of the steps
First you have to initialize new git repository, then add both remote repositories:
- the one you want copy into as origin
- the one you want to copy from as to-clone
Then you have to fetch and checkout to-clone master (or whichever branch you want to clone). By now you should be in a “detached HEAD” state. At this point you can do to the repository whatever you want, including discarding commits, reverting, commiting new changes, etc. You can also use external tools like tig.
So, before we do that, let’s reset to the commit we want to copy the repository to. In my case, I wanted to do git reset --hard 83d81abc... The parameter --hard was necessary to remove commits made after this commit, so I could copy the repository without experimental commits made afterwards.
After you’re done, use git checkout -b master to save the changes you’ve done under new branch master and now you’re ready to push the changes to the new remote repository you want to copy to.
git push origin master makes it’s first appearance here, and now you’re set. The repository to-clone has been copied at specific point to origin. Hope that little tutorial will help somebody in the future!
Dä Kölsch Zähler launched!
Ladies and Gentleman – Railslove and Payango proudly introduce you to “Dä Kölsch Zähler”. What is it about? In the next few days, Cologne (Germany) is going to get crazy. Carnival is coming and on Thursday almost every citizen in the city will be celebrating the “fifth season” here. Almost everything is closed: shops, offices, etc. And instead people will be drinking “Kölsch”. How much Kölsch will be drunk? Nobody knows. So, we decided to count it, and so the idea of “Dä Kölsch Zähler” was born. Tech-Specs: Kölsch Zähler is based on JQueryMobile, Ruby on Rails and Pusherapp. The amount of beer per Table is directly pushed to the other Mobilephones connected.
To be honest: we really have better and more important stuff to do! But this is a kind of “app in a day” project where hacking brings people together. We love building web applications!
Follow @koelschzaehler on twitter, become a fan on Facebook and visit “Dä Kölsch Zähler” while drinking Kölsch on Carnival in Cologne!
Prost!
