Here's an explanation of how each command works:
### Create a new repository on the command line
1. **`echo "# my_notes" >> README.md`**
- Appends the text `# my_notes` to a file named `README.md`. If the file doesn't
exist, it creates one.
2. **`git init`**
- Initializes a new Git repository in the current directory. Creates a hidden
`.git` folder to track changes.
3. **`git add .`**
- Stages all changes (new files, modifications, deletions) in the current
directory for the next commit.
4. **`git add README.md`**
- Stages only the `README.md` file for the next commit. This is redundant if you
already ran `git add .`.
5. **`git commit -m "first commit"`**
- Creates a commit with the staged changes, including a message (`"first
commit"`) describing what was changed.
6. **`git branch -M main`**
- Renames the current branch to `main`. This is often done to follow modern
naming conventions.
7. **`git remote add origin https://github.com/linkOfyourRepositery`**
- Links your local Git repository to a remote repository hosted on GitHub at the
given URL.
8. **`git push -u origin main`**
- Pushes the `main` branch to the remote repository (`origin`) and sets
`origin/main` as the default upstream branch for future pushes and pulls.
---
### Push an existing repository to a remote
1. **`git remote add origin https://github.com/kashershahzad/my_notes.git`**
- Links the local repository to the GitHub repository at the specified URL
(`https://github.com/kashershahzad/my_notes.git`).
2. **`git branch -M main`**
- Renames the current branch to `main`.
3. **`git push -u origin main`**
- Pushes the current branch (`main`) to the remote repository (`origin`) and
sets it as the default upstream branch for future operations.
### Pull an existing repository to a remote
git pull origin main
Fetches updates from the remote repository's main branch and merges them into the
local main branch.