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
- Create to repository
- Copy to default branch(main) https address
Local repository
- Move to project directory
- Open terminal
- Set your Git information
$ git config --global user.name "YourName"
$ git config --global user.email "YourEmail"
- Initialise local repository Git
$ git init
Result:
Initialized empty Git repository in /Users/.../.git/
- Create to local branch
$ git branch -M main
- Add remote repository Git branch to local
$ git remote add origin YourGitURL
- Add all source files
$ git add .
- Commit and add message
$ git commit -m "YourMessage"
Result:
[main (root-commit) ddddddd] your message 34 files changed, 928 insertions(+) create mode 100644 ... ...
- 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'.