Github, push new project instead of old

I have an iOS project setup on github, and over the past few days, I've started realizing that I need to refactor most of my code. I am building a project without following many MVC basics and now I want to go back and fix everything.

The main problem is that the project is large enough where refactoring will be a huge pain. Is there anyway that I can start a new project, build it where the current one is (obviously with some major design changes), and push that to github in one branch instead of the original project? If it is unclear, please let me know.

+3


source to share


5 answers


I would expand on these answers a bit, considering your desire to keep your old history. In this case, you don't want to start a new repo; you just want to "destroy" the old one by clearing the old data and adding new ones. You can accomplish this by following these steps:

  • cd to the root directory of your project.
  • Remove anything you don't want from the file system. Be careful to leave the .git / folder . This is the previous history of your store.
  • Add all the new things you want (new Xcode project, directory structure, etc.).
  • When you're ready to commit, it git status

    will show you quite a mess (the size of which will depend on how many files you have used) deletions and additions. That's good, this is where you get the wide brush for all of these writing with git add --all .

    . This will work everything in your repo, deletions, new additions, etc.
  • git commit -m "My new beginning"

    ...
  • git push origin myBranch --force



Voila! Your repository is completely complete, with the added bonus of saving your previous history.

+10


source


You can. Just create a new project and enter the following commands into the command line interface (cmd on Windows, terminal on Linux).

cd /path/to/project
git remote add origin git@github.com:username/repo.git
git push origin master --force

      



This should do it.

+2


source


You can create a new project on GitHub and in your .git / config, change the url to a new repo

[remote "origin"]
   fetch = +refs/heads/*:refs/remotes/origin/*
   url = git@github.com:[yourname]/[yournewrepo]

      

0


source


I found the easiest way to copy your .git files / folders to a new project.

0


source


Faced with a similar issue, I used Stan's suggestion (reply dated Aug 31, 14 at 5:26 am). Below is a detailed description of the action I took with a positive result.

Assumptions:

  • the "old project" is on the GitHub repo
  • "New project" is created locally on your machine

Expectations:

  • the new project should be pushed to the old repository on github
  • old commit history should remain and be visible on github

Decision:

1) go to the "old project" folder on your local computer

2) find the hidden folder ".git" there and copy it

3) go to the new project folder on your computer

4) check if there is a .git folder (it's hidden so you need to show hidden files) - if there is a .git folder, rename it, you can either delete it, but it's better to rename it now and delete it if everything goes according to plan - if the .git folder is missing, skip to step 5 below. 5) paste the previously copied .git folder (from the old project) and paste it into the "new project" folder

The new project now has a .git folder with all previous changes and history, and contains a link to the URL of your old repository on GitHub.

6) If you are using for example VS, you can check the changes in the code. There will be many of them, or check them in the terminal. You can check that old files have been removed and new ones have been added.

7) Click on the current new project. This new project will be pushed into your old GitHub repository. Check your git repo online to make sure everything went well.

8) Now you can delete the old project from your local machine and delete the renamed new hidden git folder (it was renamed in point 4).

Now you can develop your new project while keeping all the old history to yourself.

Hope this helps.

0


source







All Articles