2025-08-18 20:01:21

This commit is contained in:
swangnice
2025-08-18 20:01:21 +08:00
parent 8a920994bf
commit 7c31f72eea
254 changed files with 29201 additions and 3566 deletions

View File

@@ -0,0 +1,62 @@
+++
title = 'Git'
date = 2024-09-20T04:17:50Z
draft = false
+++
## Submodule
## Commit
1. Add date and time in commit messages:
``` bash
git commit -m "$(date '+%Y-%m-%d %H:%M:%S')"
```
## Remote
Check the remote url:
``` bash
git remote -v
```
If the remote url existing, set a new one:
``` bash
git remote set-url origin <new_remote_address>
```
A Trick: you can connect your local repo to 2 remote repos:
``` bash
git remote add public https://<git_domain>/<username>/project-public.git
git remote add private https://<git_domain>/<username>/project-private.git
```
## Branch
List all branches, the branch where you are currently working is marked with an asterisk (*):
``` bash
git branch -a
```
Move to a specific branch:
``` bash
git checkout <branch_name>
```
Create a new branch and switch to it:
``` bash
git checkout -b <new_branch_name>
```
## Push
Let us break down the push command:
``` bash
git push origin main
```
, where `origin` is the remote name and `main` is the branch name. If you want to push to a different remote or branch, just replace them accordingly.
More advanced usage:
``` bash
git push <remote_name> <local_branch_name>:<remote_branch_name>
```