Git命令行使用总结

Git使用简介

Git是分布式版本管理工具,版本管理工具常见的还有hg/svn,但是Git功能最强大,普及程度最广。这里记录一下常见的命令

1,基本概念

clone

git clone <code_repository_url> <set_folder_name>
从代码仓复制代码到本地。第一个参数是git的url,支持https/ssh,第二个是本地项目文件夹名。
用https的url可以保存账户密码,用ssh的url可以直接保存一对密钥。

fetch

抓取远端仓库的所有分支
git fetch

branch

git branch
查看当前工作路径的所有分支

git branch <branch_name>
创建目标分支

checkout

git checkout <branch_name>
切换到对应工作分支。代码改动量

diff

git diff
查看当前改动

add

将当前改动记录到暂存区。
git add .

commit

提交暂存区的代码改动
git commit -m “<commit_messges>”

push

推送代码
git push origin/<branch_name> <branch_name>

pull

拉最新的代码到本地
git pull <branch_name> <origin_branch_name>


clean

将未提交的所有改动全部清除,回退到最后一次提交的节点
git clean -dxf

2,使用案例:创建新分支并合入修改的代码

git clone xxx.git git_repo_clone
下载代码

git branch Feature/personal_add_function1
创建分支

git checkout Feature/personal_add_function1
切换分支

git push origin Featrue/personal_add_function1
推送分支到远端

<coding… … >

git diff
查看代码变化

git add .
将代码改动记录入暂存区。

git commit -m “modify 1st: add some functions.”
提交代码。

git push origin Feature/personal_add_function1
推送代码到远端

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值