git 常用命令(以与github交互为例)

修改github上的代码:


(1)git clone已存在GitHub上的Repository。(在新建的~/MyTestFolder目录中)

<span style="font-size:18px;">git clone https://github.com/zhchnchn/ZhchnchnTest.git</span>
(2)修改一个文件,然后提交
<span style="font-size:18px;">vim README.md
git status
git add README.md      或直接     git add .
git status
git commit -m "Edit by WorkUbuntu 1204"
git status
git remote add origin https://github.com/zhchnchn/ZhchnchnTest.git</span>
这时可能会报错误:
fatal: remote origin already exists.
解决办法【3】:
<span style="font-size:18px;">$ git remote rm origin
$ git remote add origin https://github.com/zhchnchn/ZhchnchnTest.git</span>
(3)之后,需要将修改push到GitHub上
<span style="font-size:18px;">git push -u origin master</span>
(4)提交完成后,查看GitHub上的Repository,会发现内容修改成功。


git 配置基本信息 

配置用户名
<span style="font-size:18px;">git config --global user.name T-bagwell</span>
配置用户email
<span style="font-size:18px;">git config --global user.email [email protected]</span>
配置默认的编辑器为vim
<span style="font-size:18px;">git config --global core.editor vim</span>
查看git配置
<span style="font-size:18px;">git config -l</span>



你可能感兴趣的:(git 常用命令(以与github交互为例))