git服务器ubuntu下操作使用说明

来源:互联网 发布:淘宝店类目可以改吗 编辑:程序博客网 时间:2024/05/16 05:37

git服务器ubuntu下操作使用说明

假设我的服务器的ip为192.168.0.123

克隆:                                     gitclone git@192.168.0.123:/home/git_repo/test.git

查看远程分支:                     git branch-r

查看分支:                             gitbranch

建立新分支:                       git branch branch1

切换分支:                             gitcheckout branch1

添加文件(或文件夹):           git add readme.txt

提交:                                     gitcommit –m "说明操作的注释"

推送到远端branch1分支:    git push origin branch1  

切换到当前master分支:   gitcheckout master

拉取差异:                             gitpull

 

生成公钥的方法:ssh-keygen –t rsa

 

接下来举例说明。该例子目的是在原来的远程test.git仓库里的branch1_ubuntu分支里加上一个名为branch1_ubuntu_test_by_hansheng.txt的文件,并推送到远端服务器。

1.    克隆远端的test.git仓库到一个新建的文件夹里。

在桌面建立一个名字为git_repo的文件夹。

cd /home/robot/桌面/git_repo     注意要改变路径,我的电脑是robot,将这里的robot改做你自己ubuntu的名字。

git clone git@192.168.0.123:/home/git_repo/test.git

输入密码:******

cd test

2.    查看远程分支

git branch –r

切换到branch1_ubuntu分支

git checkout branch1_ubuntu

 

将branch1_ubuntu_test_by_hansheng.txt文件拷贝到当前目录/home/robot/桌面/git_repo/test 路径下

 

添加文件

git addbranch1_ubuntu_test_by_hansheng.txt

提交日志说明

git commit –m add the file namedbranch1_ubuntu_test_by_hansheng.txt

推送到远端branch1_ubuntu分支

git push origin branch1_ubuntu

输入密码:*******

切换回master主分支

git checkout master

 

0 0
原创粉丝点击