'How to save my progress from a public repo to my private repo?
I have been working on a series of exercises from a popular GitHub repository.
But unfortunately I have committed my answers to the main branch of their repository. I should have cloned their repository first and then committed my changes to the cloned repository. Both of these are on GitHub.
Do I have a way to do this?: I don't want to loose my progress and redo the exercises, but more importantly I want to preserve the timestamps associated with my commits. I want to commit the answers to my clone (which is to be created) and then push the already committed commits to it.
All of guides/solutions to similar problems started with the clone first and then
Here is what I have done:
$ git clone repo_of_exercises.git
< Solved many exercises and I have a commit message for each exercise >
$ git add <solution to an exercise>
$ git commit -m "<Appropriate commit message>"
< Note that I have not pushed these changes, it's all on my computer >
What are the next steps that I should take to copy all of commits to a clone that I will create soon?
Solution 1:[1]
Here is how I solved my problem:
I just had to add my repository as a remote.
git remote add main link_to_my_repo.git
< I could have removed the origin, which points to the original public repository
- read the documentation linked below >
git push main
< to push all the commits to my private repository >
With these commands I will preserve the timestamp of my commits.
With my first attempt I had rebased the local repository to correct some commit messages and because of this all the commit messages were updated with a new timestamp.
I could have removed the original remote of the public repository but I chose not to thinking that it if I kept it then it may be recognised as a fork of the public repository.
But I was wrong and it does not recognise it as a fork.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | dope_centipede |
