git基础

git基础

github上创建新的项目后,在本地拉取项目或者将本地的项目关联到建立的仓库。

1
# git clone git@github.com:xxxxxxxxx.git

命令行新建一个新的仓库

1
2
3
4
5
6
7
8
# mkdir myProject
# cd myProject
# echo '# my new project' >> README.md
# git init
# git add .
# git commit -m "first commit"
# git remote add origin git@github.com:xxxxxxxxx.git
# git push origin master

本地项目关联远程git仓库

1
2
3
# cd myProject
# git remote add origin git@github.com:xxxxx/xxxx/git
# git push origin master

本地分支关联远程分支

1
2
# git checkout test
# git remote add origin git@github.com:xxxx/test.git

fatal

首次拉取代码失败

git pull错误信息 :

1
2
* branch       master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

解决:

1
# git pull origin master --allow-unrelated-histories

首次安装git设置

1
2
# git config -global user.nme "xxxxxx"
# git config -global user.email "xxxxxx@jd.com"

公钥密钥配置

1
# ssh-keygen -t rsa

会生成两个文件:id_rsa(密钥)和id_rsa.pub(公钥)
在github中设置公钥。

# git, github

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×