Git 推送

工作协同,需要从远程仓库克隆一个副本到本机,再放里面添加文件/修改文件的,再提交,最后推到远程仓库。

这里我们完整演示这个过程。

1、克隆一个github上有读写权限的仓库。

这里切换到有github上项目读写权限的账号进行克隆

1
2
3
4
5
正克隆到  'gitDemo' ...
remote: Counting objects: 3,  done .
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3 /3 ),  done .

2、进入网刚克隆到本机的目录

cd gitDemo

下面几步就是添加文件的步骤

3、在里面建立一个文件 hello.txt,内容随意写

# vi hello.txt

4、添加文件到staging area

使用命令git add 文件名,文件名可以采用通配符*

# git add hello.txt

5、提交,使用git commit 命令

使用形式如下:git commit -m "提交说明"

1
2
3
4
# git commit -m "添加 hello.txt"
[master 7c1b9ee] 添加 hello.txt
  file changed, 1 insertion(+)
  create mode 100644 hello.txt

6、推本机更换到远程仓库

使用git push命令

1
2
3
4
5
6
7
8
9
10
# git push
Username  for 'https://github.com' :        # 这里要输入github账号
Password  for 'https://[email protected]' :      # 这里要输入github账号密码
Counting objects: 4,  done .
Compressing objects: 100% (2 /2 ),  done .
Writing objects: 100% (3 /3 ), 294 bytes | 0 bytes /s done .
Total 3 (delta 0), reused 0 (delta 0)
To https: //github .com /xxx/gitDemo .git
    1d54d92..7c1b9ee  master -> master
[root@localhost gitDemo] #

猜你喜欢

转载自www.cnblogs.com/max-hou/p/12040289.html
今日推荐