Connect local Git repository to Github 048

1) Create a new Github repository

Login to your github account and create a new repository. You can choose every name you would like.

DO NOT CREATE A README FILE NOW
-> if you create a readme file than GitHub will automatically create a „main“ branch. Your local Git branch will be named „master“ and if you commit to GitHub you create a second branch. First push your local repository to GitHub and create a readme file afterwards.

2) Git init your local repository

Go to your local repository or normal folder and open the GitBash terminal. Now you can „git init“ your folder or do your first commit.

3) Connect your local repository with Github

At the top of your GitHub repository’s page, click to copy the remote repository URL:

In GitBash, add the URL for the remote repository where your local repository will be pushed.

git remote add origin <remote repository URL> 
git remote -v

Now you can push your local files:

git push origin master

To pull your GitHub repository to your local folder, you have to set the right upstream:

git branch --set-upstream-to=origin/master

Links

unsere-schule.org

×

Connect local Git repository to Github

Code: 048