UFSの備忘録 % Home / Categories

git备忘录

Created 2022-12-03 / Updated 2022-12-13
$ git config --global user.email "<email address>"
$ git config --global user.name "<name>"
$ git config --global init.defaultBranch main

查看用户名和邮箱:

$ git config user.name
$ git config user.email

首次push:

$ git init
$ git add README.md
$ git commit -m "first commit"
$ git remote add origin git@github.com:xxx/xxx.git
$ git push -u origin main

第一次push要加-u,此后不需要。

$ git push -h
-u, --set-upstream    set upstream for git pull/status

一、将现有的master分支更名为main

$ git branch -m master main
$ git push -u origin main
$ git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main

然后到github项目所在的Repositories里,点Settings -> Branches,将默认分支切换为main

命令行最后一步:

$ git push origin --delete master

二、查看所有分支:

$ git branch

三、重命名当前分支:

$ git branch -m <新分支名>
Categories: [devel]