1

I have a project in VS Code. I want to have it automatically synced with my Github. How can I accomplish this with a series of git commands from the command line?

I think the first one is

git init

but that does not fully accomplish the job. What are the other commands I need to do?

Let Me Tink About It
  • 15,156
  • 21
  • 98
  • 207
  • How *would* it fully accomplish the job? At the very least you need to create and target an appropriate remote; see e.g. https://stackoverflow.com/q/4658606/3001761, https://help.github.com/articles/creating-a-new-repository/. It's unclear what you mean by *"automatically synced"*, too; you'll still have to make and push commits. – jonrsharpe Nov 15 '18 at 17:17

1 Answers1

3

git init will initialize a new local git repository in your project folder. If you have a remote repository (at GitHub) and want to work with its content in your computer, you have to use the command git clone <url_of_the_github_repository_extension_dot_git>.

ie: git clone https://github.com/username/repo_name.git

After clone the remote repository into your computer, you will have a local repository connected with the remote cloned repository and then you can start to change the local repository and push your changes to the remote repository.

To save your changes in you local repository you can use the script below:

git add .
git commit -m "a message to describe your commit"

To send the changes saved locally to your remote repository you need to execute the command below:

git push origin master

This is the simplest flow to work with a remote GitHub repo in your computer.

Saulo
  • 499
  • 1
  • 4
  • 16