Git Init for new project


I'm a bit confused on "Git Init." I'm using Cloud9 for my projects. I had a previous project I worked on before that I cloned as a starting point for my new project. I'm currently in the process of pushing this new project to Heroku/Git. I do NOT want to override my previous project.

Current Steps taken:

  • Cloned original project as a starting point for a new project
  • Created new project with new code etc.
  • Time to deploy. Created new Heroku link with heroku create
  • Used git remote set-url heroku to change to new Heroku link
  • Now I'm ready to push but don't want to override original project

Now I've done git add -A and checked git status

Here is my problem and concern for the new project's files it says "new files" but for my previous project's files it says "delete files"

new file:   views/listings/show.ejs
new file:   views/listings/sold.ejs
deleted:    views/profile.ejs
deleted:    views/rentals/edit.ejs
deleted:    views/rentals/editprofile.ejs

I do not want to delete any files from my previous project I only want to create a new repo. I'm confused and concerned that if I push my new project I will delete my old project.

Any clarification is greatly appreciated!

Thanks so much!

Show source
| git   | node.js   | github   | mongodb   | heroku   2017-10-30 17:10 2 Answers

Answers to Git Init for new project ( 2 )

  1. 2017-10-30 18:10

    Ah... I now see from your updates that you are using one project as a starting point for another project.

    If you change the remote, then you will not affect the original repo on the server. You will be affecting your local repo, but I think that's what you want.

    If this is a brand new project and you don't have anyone else working on it, then you should be able to push the current repo to the server using --force to essentially force the server to use your current repo's state. This flag can have dire consequences if not used properly, so I suggest reading up on it before using it.

    Another option, which may be easier, is to simply clone the new repo, delete files you don't want to keep, then copy-paste your files from the other repo. There are more complicated ways of achieving the same result, but this will give you a cleaner history and will probably be more intuitive for you.

    Old Answer:

    ...and switched the remote to use that app

    If you are going to work on a different project contained in a different repo, then you should not switch the remote of your current repo. You should clone the second repo into a different directory.

    When you switched the remote, you basically said... "Hey, you know all that work on the other server? Well just ignore that, because this is what the project should look like now."

    You should restore your original remote and run git clone to a new directory.

  2. 2017-10-30 19:10

    Possible Solution:

    • Within C9 I copied the project folder and pasted it into a new folder
    • Then I deleted the "Git" Folder within the copied project (Removing Master)
    • Then I followed Heroku's advice and did the following:

      $ cd my-project/
      $ git init $
      $ heroku git:remote -a starklight-meadow-random

    I doubled checked using git remote -v that I was going to push to the correct Heroku project.

    All looks good when checking git status. Only added files to an empty repo.

Leave a reply to - Git Init for new project

◀ Go back