Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

push to git remote repo using a local copy

Given an existing private remote repository, to which I have access to, which contains only a README.md and a .gitingore file. Lets call this repo "myRepo".

Locally on my machine, I created a folder "myRepo", added some files to it and want to push everything to the remote "myRepo".

I am aware of the git init command. I would probably have to do git remote add "url_to_myRepo" then. Is this the right way to go?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

And, my local folder contains a whole bunch of files which I do not want to be tracked by git. Do I have to create a .gitignore file before I do git init, or can I do it also afterwards?

>Solution :

Running git init just creates a local repository directory. You then need to git add files. You can add individual files explicitly with that command, but if you are going to add directories, you should probably have the .gitignore file created first. Then of course you need to git commit to actually have the files actually saved into the repository. Finally as mentioned by @bronislav, you need to run the git remote add origin <url> command to allow you to git push the repository to the remote.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading