跳到主要内容

git command line

#初始化一个git仓库

git init

#将当前目录及其子目录中的所有文件提交到暂存区

git add .

#将暂存区中的更改提交到本地仓库

git commit -m “init”

#创建新分支并切换到该分支(如果需要)

git checkout -b main

#将指定目录的内容拆分为一个新分支(如果需要)

git subtree split --prefix=Asset/ZTest --branch main

  • 新仓库必须提交一次才能subtree split
  • 如果直接拆分到main报错,可用一个临时分支去拆分
#将一个远程仓库添加到本地仓库中

git remote add origin git@github.com:86K/web.git

将本地仓库的main分支推送到远程仓库的main分支

git push -u origin main

  • git push origin temp:main

#拉取远端最新更新

git pull origin main

#提交最新更新到本地

git add . git commit -m "commit"


#强制重命名当前分支为main

git branch -M main

#创建新分支

git branch your-branch-name

#切换到分支

git checkout your-branch-name


#查看远程仓库列表

git remote -v

#删除远程仓库分支

git push remote-name --delete branch-name

  • 主分支不可删除,除非在一个非主分支的分支上去删除主分支