git 基本操作


workspace:工作区
staging area:暂存区/缓存区
local repository:版本库或本地仓库
remote repository:远程仓库

  • git init [指定目录] 创建仓库

  • git add *.c 对.c文件进行跟踪

  • git clone [git仓库] | [本地目录] 拷贝项目

  • git config 配置

  • git config --global user.name "myName"

  • git config --global user.email ...com
    设置提交代码用户信息

  • cat README.md 查看文件内容

  • git branch (branchname) 创建分支

  • git branch 列出分支

  • git checkout (branchname) 切换分支

  • git merge 将任何分支合并到当前分支中

  • git commit -m '版本提交' 提交

  • git checkout -b (branchname) 创建新分支并切换到该分支下

  • git branch -d (branchname) 删除分支

  • git log 查看历史提交记录

  • git blame [file] 查看指定文件修改记录

  • git tag [-a] v1.0 创建带注解(-a)的标签

  • git fetch 从远程仓库下载新分支与数据,接着要

  • git merge 从远端仓库提取数据并合并到当前分支

  • git push [alias] [branch] 将 [branch] 分支推送成为 [alias] 远程仓库上的 [branch] 分支

  • git remote -v 添加删除远程仓库
    origin git@github.com:tianqixin/runoob-git-test.git (fetch)
    origin git@github.com:tianqixin/runoob-git-test.git (push)

  • git remote add origin2 git@github.com:tianqixin/runoob-git-test.git

  • git remote -v
    origin git@github.com:tianqixin/runoob-git-test.git (fetch)
    origin git@github.com:tianqixin/runoob-git-test.git (push)
    origin2 git@github.com:tianqixin/runoob-git-test.git (fetch)
    origin2 git@github.com:tianqixin/runoob-git-test.git (push)

  • git remote rm origin2

  • git remote -v
    origin git@github.com:tianqixin/runoob-git-test.git (fetch)
    origin git@github.com:tianqixin/runoob-git-test.git (push)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值