Git使用main分支
Xplorist Lv6

Git使用main分支

reference-site-list

steps

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 先将keep项目下原来的.git目录剪切到其他文件夹如keep-git-bak中
git init
git remote add origin https://gitlab.xplorist.tech/xplorist/keep.git

# 获取远程分支,并合并远程分支 ps:可以使用 git pull origin main 一步取代
git fetch origin main
git merge origin/main

# 查看本地分支
git branch

# 本地分支是master,直切创建并切换到main分支
git checkout -b main

# 查看本地文件状态
git status

git add .
git commit -m "init commit"

git push -u origin main:main
  • GitHub 示例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
…or create a new repository on the command line

echo "# FinalSudoku" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/Xplorist/FinalSudoku.git
git push -u origin main

…or push an existing repository from the command line

git remote add origin https://github.com/Xplorist/FinalSudoku.git
git branch -M main
git push -u origin main

…or import code from another repository
You can initialize this repository with code from a Subversion, Mercurial, or TFS project.
 评论