Git的基本使用

一:准备工作:

1.建立库文件夹:repository,用户文件夹develop

2.$ cd c:   $ cd software/   清屏(ctrl + l clear$ cd repository/ 然后初始化仓库:

 git init --bare shared.git

在develop文件夹下建立两个用户:user1 user2

c盘下的库文件shared.git复制到user1

$ cd ..

$ cd develop/user1

$ git clone /c/software/repository/shared.git .

创建文件:$ echo "user1 create the file fuck" >index.jsp

vim index.jsp

 

 

3.改变为修改模式:按i键:

4.修改后按esc退出修改模式,按:保存,wq退出,强制退出:!q

5.查看修改的情况:

$ cat index.jsp

user1 create the file fuck

user1 update the fuck file

6.提交修改:

$ git config user.name "user1"

$ git config user.email "user1@163.com"

$ git add index.jsp

$ git commit

 

7.将本地代码上传到远端的服务器:

$ git push origin master

 

二:新开一个git bash窗口,为user2 clone 库文件:

$ cd c:

$ cd software/develop/user2

$ git clone /c/software/repository/shared.git .

可以看到user2文件夹下有与user1文件夹下相同的文件。

且内容相同:

$ cat index.jsp

user1 create the file fuck

user1 update the fuck file

1.User2修改:

vim index.jsp

 

2.查看修改的情况:

$ cat index.jsp

user1 create the file fuck

user1 update the fuck file

user2 update the file ~~~~

3.提交修改:

$ git config user.name "user2"

$ git config user.email "user2@163.com"

$ git add index.jsp

$ git commit

 

 

4.提交到远程服务器:

$ git push origin master

三:user1查看user2的更新情况:

$ git pull

 

1.User1修改:

$ echo "user1 update" >>index.jsp

$ cat index.jsp

user1 create the file fuck

user1 update the fuck file

user2 update the file ~~~~

user1 update

2.User1提交修改:

$ git add index.jsp

$ git commit -m "user1 update"

 

通过以上的方式,可以实现开发人员与开发人员2的交互过程。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值