1.安装以及配置
- 1.1 intall:
sudo apt-get install git #ubuntu
sudo pacman -S git #manjaro
- 1.2 config
git config —global user.name “github_name”
git config —global user.email “github_emil” #自己的GitHub名字和email
如果和github端不同会出错
- 1.3关联ssh
* 1.3.1 #生成密钥对
ssh-keygen -C “标识符,想写啥写啥“ #生成一个密钥对
1.3.2
在github上找到
setting->ssh and GPG keys-> new key
然后点击添加ssh,复制公钥到内容里面去,titl内容自己填,便于区分
公钥文件在 ~/.ssh/id_rsa.pub
1.3.3
测试是否连通
ssh -T git@github.com
2.本地同步至github
- 2.1github中新建一个repository
- 2.2 同步内容(新建一个文件夹或者clone一个仓库)
git init #初始化仓库
git clone https://github.com/user_name/repository#或者克隆那个仓库
touch README.md #建立readme文件
echo ”test for sync“ >README.md
git add README.md #添加一个文件到项目里面
git commit README.md -m “first commit”#第一次提交 m选项是添加提交评论,以便区分
git remote add first git@github:[user_name]/[repository].git#添加推送(远程连接源)
git push first -u master #推送,u选项是选择分支,默认是master,可省略。
- 2.3 以后
git pull #同步github端的修改,拉取
git add [new_file] #添加新的文件进去,如果是本来有的可以不用添加
git commit [new_file] [change_file] -m “继续写本次提交的内容批注” #commit后面跟新文件和原来存在但修改了的文件
git push first#推送修改