How to first commit on Git

How to first commit on Git

I used to GitLab before, and now I have set up Gitea on my Synology NAS server.

First of all, I want to manage to branch:

  • main: Operation
  • develop: Development

when creating a repository for the first time:

šŸ’” tip: This post is a simple guide on how to use Git.

Web

  1. Create to repository
  2. Copy to default branch(main) https address

Local repository

  1. Move to project directory
  2. Open terminal
  3. Set your Git information
$ git config --global user.name "YourName"
$ git config --global user.email "YourEmail"
  1. Initialise local repository Git
$ git init

Result:

Initialized empty Git repository in /Users/.../.git/
  1. Create to local branch
$ git branch -M main
  1. Add remote repository Git branch to local
$ git remote add origin YourGitURL
  1. Add all source files
$ git add .
  1. Commit and add message
$ git commit -m "YourMessage"

Result:

[main (root-commit) ddddddd] your message
34 files changed, 928 insertions(+)
create mode 100644 ...
...
  1. Push from local to remote repository
$ git push -u origin main

Result:

Enumerating objects: 44, done.
Counting objects: 100% (44/44), done.
Delta compression using up to 18 threads
Compressing objects: 100% (40/40), done.
Writing objects: 100% (44/44), 31.73 MiB | 9.41 MiB/s, done.
Total 44 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote: . Processing 1 references
remote: Processed 1 references in total
To https://YourGitURL.git
* [new branch]      main -> main
branch 'main' set up to track 'origin/main'.