Ubuntu下GitHub和Git的安装配置

Ubuntu下GitHub和Git的安装配置

配置用户信息

git config --global user.name "accountname"
git config --global user.email "[email protected]"
ssh-keygen -t rsa -C "[email protected]"
cat ~/.ssh/id_rsa.pub

SSH key format: ssh-rsa AAAAB3NzaC1yc2EAA....9FD [email protected]

复制SSH Key到GITHUB

在github网站中添加SSH key.
运行以下命令测试是否连接成功:

ssh -T [email protected]

建立本地仓库,如project1

建议在windows端下载github desktop来建立仓库。

cd ~/github/project1
git init

下载、克隆项目

cd ~/github/project1
git clone https://github.com/accountname/project1.git

修改上传

git add ~/github/project1
git commit -m "change reason"
git push

git push 记住帐号密码

git config --global user.email "[email protected]"
git config --global user.name "accountname"
git config --global credential.helper store   # git push的时候记住用户名和密码
git config --global push.default simple

相关命令

  1. git status 查看仓库当前的状态
  2. git diff 查看difference
  3. git log 查看记录
  4. git checkout 可以用来覆盖修改
  5. git merge 合并

猜你喜欢

转载自www.cnblogs.com/herryzz/p/10220772.html