Summary - First push
- Git course
- Beginner
- Lesson 68/80
- 5 min
Combine remote and push to do the first upload.
The First Push Workflow
To share your local Git repository on GitHub, first create a remote connection with git remote add. Then send your commits and configure the upstream relationship using git push -u origin main.
git remote add origin https://github.com/ayse/ilk-projem.git
git push -u origin mainAfter these operations, your local main branch tracks the remote origin/main branch. You can use git push for subsequent commits.
Practice Make Your First GitHub Upload
First, add https://github.com/ayse/ilk-projem.git as a remote repository named origin. Then push the local main branch and establish its upstream connection using the -u option.
Starter code
# 1. GitHub deposunu uzak depo olarak ekle
# 2. Main dalını upstream bağlantısıyla gönderSample solution
git remote add origin https://github.com/ayse/ilk-projem.git
git push -u origin mainExpected output
branch 'main' set up to track 'origin/main'.
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which is the correct command sequence for the first push?
- git push origin main, then git remote add origin URL
- git remote add origin URL, then git push -u origin main Correct answer
- git commit origin, then git remote add main URL
- git add origin URL, then git merge main
Explanation: The remote repository must first be added with the name <code>origin</code>. Then <code>git push -u origin main</code> sends the commits and establishes the upstream connection.
2 Specify the Remote Repository Name
git remote add ____ https://github.com/ayse/ilk-projem.git
git remote add origin https://github.com/ayse/ilk-projem.git
Explanation: <code>origin</code> is the conventional name given when adding a remote repository. This name identifies the target repository in subsequent push commands.
3 First Push Stages
| Term | Meaning |
|---|---|
git remote add |
Creates a remote connection |
origin |
Short name of the remote |
git push |
Sends commits to the remote |
upstream |
Branch tracked by the local branch |