首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 其他相关 >

Git的根本使用

2013-10-31 
Git的基本使用一:准备工作:1.建立库文件夹:repository,用户文件夹develop2.$ cd c:$ cd software/清屏(ctr

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

 

 

Git的根本使用

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

Git的根本使用

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

Git的根本使用

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

 Git的根本使用

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

 Git的根本使用

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

 Git的根本使用

 Git的根本使用

Git的根本使用

4.提交到远程服务器:

$ git push origin master

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

$ git pull

 Git的根本使用

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"

 Git的根本使用

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

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

热点排行