It's a good idea to create a new repository for each individual project you're working on. If you're writing a software project, grouping all the related files in a new repository makes it easier to maintain and manage the codebase over time.
- In the upper-right corner of any page, select , then click New repository.
- In the "Repository name" box, type a name for your project. For example, type "my-first-project."
- In the "Description" box, type a short description. For example, type "This is my first project on GitHub."
- Select whether your repository will be Public or Private. Select "Public" if you want others to be able to see your project.
- Select Add a README file. You will edit this file in a later step.
- Click Create repository.
- Git is installed:
git --version
- You have a GitHub account
- You have created the repo in the first step
- You have a local project folder (say it's called
myproject
)
-
Open terminal and navigate to your project
cd /path/to/myproject
-
Initialize git (if not already)
git init
-
Add remote GitHub repo
git remote add origin https://github.com/%your github username%/%your repo name from step 1%.git
-
Add files to staging
git add .
-
Commit the files
git commit -m "Initial commit"
-
Push to GitHub (main branch)
If you're pushing to the main branch:
git branch -M main git push -u origin main
If you're using master instead:
git push -u origin master
Visit your repo from step 1 β your project should now be visible there.
If you later want to update changes:
git add .
git commit -m "Some update message"
git push