git的简单使用

背景
假设你在github上有一个私有仓库,需要将它克隆到自己的云服务器上,并在上面进行修改提交。本文基于Ubuntu16.04。

安装git

切换到root用户:sudo su
输入密码,密码输入的时候光标是不会变化的,不用理会它
安装git:apt-get install git

克隆文件

git clone https://github.com/xxx/xxx.git
因为是自己的私有仓库,这里会让你输入你的用户名和密码

添加未跟踪文件

git add xxx这里的xxx包含文件的路径名,这里还有些其他参数,例如git add .或者git add --all

文件提交

Git commit -m "xxxxx"
第一次操作时git会提示你输入自己的用户信息

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

再次运行commit代码,输入你的私有仓库的用户名和密码

提交

git push origin master这里假设提交的是主分支,最后就可以在github网页上看到刚刚替提交的内容啦

拉取最新代码

git pull origin master

posted @ 2020-03-03 16:18  wuzu  阅读(123)  评论(0编辑  收藏  举报