Dr.JoeBeer Dr.JoeBeer - 12 days ago 8
Linux Question

sync local folder to github repo with ubuntu

Im an noob on github.
I have an repo in github.com
No i have downloaded it and write some new files and edit some files.
Now i want to sync this folder to my Guthub repo.
But how i can do that? Can anyone help me please step by step?

i have read something here but i cant undersand how it works.
i tryed some codes but it dosent work :/

How i can use this:

git remote add origin 'url to github repo'


git pull origin master
git checkout master
git cherry-pick
git commit -m 'Made a change to the master branch'
git push origin master

Answer

If you haven't cloned a github repo, you have to connect it to your remote repo with:

git remote add origin <url_of_your_github_repo>

To 'sync' your local changes, add the files you want to send to your changes list with:

git add <filename>

Then, when you have added all your files, commit them:

git commit -m "Commit message : new project begun"

It will add your files into the HEAD, but not to your remote repo yet. In order to do this, you will have to do:

git push origin <origin> 

where origin is generally master.

After doing this, you can check on your github account that a new commit has been made.

To make things easier, when you begin a new project, you can create a new repo on github, then clone it on your computer with:

git clone <url_of_your_github_repo>

So that you won't need to connect your local repo to the remote one.

Comments