user18277059
user18277059

Reputation:

Can't push Angular project - Github

So I'm trying to push my angular project to Github. The project structure is:

In order to push the angular project, I positioned myself in the root folder and executed the following commands:

  1. git add .
  2. git commit -m "First commit"
  3. git remote add origin URL_OF_MY_REPO
  4. git push -u origin master

The backend is pushed without any apparent issues, but the frontend will only push an empty folder as shown:

enter image description here

The file .gitignore only includes node_modules to avoid pushing the node_modules folder (which works, as the node_modules is not being pushed).

However, the frontend is not being pushed at all.

Upvotes: 6

Views: 2952

Answers (1)

Manuel Tomás
Manuel Tomás

Reputation: 570

Notice that when you run the ng new command, it creates a git repository along with the angular project. When git finds a repository inside another repository it only commits the reference to that repository which is what you show in the image as the folder with an arrow. To solve this issue, you can

  1. Remove the .git folder (if it exists) in the frontend folder
  2. Then copy the folder to another location and delete the one at the repository.
  3. Make a commit with these changes
  4. Copy the frontend code back to the repository (make sure there is no .git folder in it)
  5. Commit the changes
  6. Push

From what I have experienced, it solved the problem when I had it.

Upvotes: 7

Related Questions