首页 > 技术文章 > git简单使用

leafchen 2020-09-18 11:11 原文

 

第一次使用Git? 学习基本的Git命令

1. 第一次配置Git
git config --global user.name "chen**"
git config --global user.email "chen**@**.com"
2. 使用您的存储库

  我只想克隆这个存储库 如果要简单地克隆此空存储库,请在终端中运行此命令。

git clone http://******.git
3. 我的代码已经准备好推送

  如果你代码已经准备好推送到仓库,请在终端中执行该命令

cd existing-project
git init
git add --all
git commit -m "Initial Commit"
git remote add origin http://******.git
git push -u origin master
4. 服务端生成分支后,客户端创建并切换分支
git branch  # 查看本地所有分支
git branch -a # 查看所有分支,包含克隆后所有远程分支
5. 第一次在本地创建分支
git checkout -b 分支名 origin/远程分支名    # 创建并切换分支
git checkout 分支名 # 在本地切换分支
6. 删除分支
git banch               # 查看本地分支
git branch -d 分支名 # 删除某个分支



推荐阅读