Skip to content

Git First Commit

  1. Create a project on Github and get the repository address. For example, git address is git@github.com:silentQQQ/cookiecutter.git

  2. Run the following commands in the directory where you want to commit code:

git init # Create master branch locally by default
git branch -m master main # Rename master to main
git remote add origin git@github.com:silentQQQ/cookiecutter.git

# Force Git to merge the remote main branch history into your local branch
git pull origin main --allow-unrelated-histories

git add .
git commit -m "first commit"
git push -u origin main

Other Common Git Commands

# View all branches
git branch -a

# Create and switch to main branch
git checkout -b main

Released under the [BY-NC-ND License](https://creativecommons.org/licenses/by-nc-nd/4.0/deed.en).