Leandro
Leandro

Reputation: 377

How to push local git repository to existing project on remote Github project and after that add another branch to other developer work with?

I have been trying to find a solution for a couple days now and I couldn't find the best way to work yet because it is very specific - I guess.

I am working on a project that is both on a private server and on GitHub. The most up-to-date files are always in the server. I use NetBeans to edit the files and it creates a local copy for all of them. When I hit "save" it updates both the local files and files in the server. Simultaneously, I was committing the relevant changes on Git and pushing them to the remote folder on GitHub.

It turns that is has been 2 months since I made the last commit and I lost track of my changes on Git. I made a lot of changed in the project but I was not using Git. N

Now, I want to track my files again. For that, I want to commit everything and push to the GitHub so it will be accordingly to the files on my server and I will be able to continue committing and pushing from now on.

The steps I followed so far:

1- Git Init my local copy of the files (that thanks to NetBeans are always synced with the server). 2- Git add remote (project uri) 3- Git push: that's when I get an error: "The following untracked working tree files would be overwritten by merge" and it lists two files that are in a cache folder. I decided to add those two files to be tracked but then a message came saying that those files are in gitignore. 4- So I made a copy of those two files and deleted them from the project. 5- Ran git pull again, this time it listed a lot of conflicts and all my files in the netbeans folder started to change - I believe they got overwritten by the old version that was on github or something like that. I'm completely lost at this point.

Besides that, another programmer will work on the front end of this project. I am not sure how I should set GitHub in order to have him set up in a such a way that merging it later will be smooth. The challenge is to keep the files in the server up-to-date and the files on github as well. Not sure if that is possible though.

I really appreciate any help.

Thanks

Upvotes: 0

Views: 933

Answers (1)

David Deutsch
David Deutsch

Reputation: 19035

What you want to do is create a brand new directory, cd into it, and type:

git clone (project uri) .

This will make it so you are up to date with the repository. Then copy your new files into that directory, git add them, and commit as normal.

Upvotes: 1

Related Questions