git入门

创建版本库

mkdir -p /demo/helloworld-git

cd /demo/helloworld-git

git init

ls -al

将文件提交到本地版本库

cd /demo/helloworld-git

echo "hello world" > helloworld.txt

git add helloworld.txt

git commit -m ‘helloworld-master’

git log

rm helloworld.tx

git checkout helloworld.txt


创建本地分支

git branch

git branch new-branch

git branch -D new-branch


切换本地分支

git branch new-branch

echo “世界你好”  > helloworld.txt

git commit -m helloworld-new-branch

git checkout master  cat helloworld.txt  //显示helloworld

git checkout new-branch cat helloworld.txt //显示 世界你好


在GitHub上创建开源项目

前面介绍的都是操作本地版本库和本地分支,git管理源代码都会使用远程的Git托管服务器(eg:GitHub)

git config --global user.name xuwuhao

git config --global user.email 1060xxxxx7@qq.com

然后输入用户名和密码

git remote add origin https://github.com/xuwuhao/xuwuhao.git

git push -u origin master //master是远程版本库origin中的主分支

git branch -a //查看所有本地和远程分支


git clone https://github.com/xuwuhao/xuwuhao.git //使用如下命令可以下载整个工程

git pull origin master //获得某一分支的最新内容

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值