创建new repository
1.profile右上角点击new repository,根据自己要求选择public或者private。
2.使用ssh协议进行下载, 处置ssh link, 打开terminal
3.terminal中需要设置公钥和私钥,让GitHub确认用户
公钥&私钥的创建
1.ssh -keygen -t rsa -b 4096 -C "Email"
should be ssh-keygen or Bad escape character 'ygen'.
2.~./ssh 下生成了本机和GitHub邮箱账号对应的公私钥
利用cat ~/.ssh/id_rsa.pub 获取公钥
3.github的setting里复制ssh公钥到ssh and gpg keys
!打开新的terminal进行git clone
upload to the repository from pc
git add . // add . comma and add have space
git commit -am "add"
git push
设置用户名和邮箱
git config --global user.name “ ” / email
Git的简单使用
1,添加文件
touch a.md
echo "hello" > a.md
git status
git add . //add
git commit -am "add" //upload
git push origin master //push
2.更新仓库
git pull
3.修改删除文件
rm -rf file_name
Git的高级使用
1.本地创建项目推送到GitHub仓库
create a new repository on the command line
echo "# blogtest" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:vsl1/blogtest.git
git push -u origin master
- git push -f origin master /force to overwrite
git remote add abc git@..... / add git labs
git remote set-url origin "git addresee"
分支操作
1.git branch dev /create a local repository dev
2.git checkout dev
- create files on dev and push origin dev
- git checkout master and merge dev and push to master
网友评论