1.创建Github账号,Linux创建SSH密钥:
2.将公钥加入到Github账户信息Account Settings,测试验证是否成功。
1 2 | ssh -T git@github.com
Hi haiyun.me! You've successfully authenticated, but GitHub does not provide shell access.
|
3.GitHub创建项目。
4.本地配置,新建Git项目并提交到Github。
1 2 3 4 5 6 7 8 9 10 | touch README.md
git init
git add README.md
git status
git commit -m "first commit"
git remote add origin git@github.com:user /test .git
git remote - v
git remote rm origin
git pull origin master --allow-unrelated-histories
git push origin master
|
5.复制项目到本地:
1 | git clone git: //github .com /user/xxx .git
|
6.删除GitHub文件:
1 2 3 | git rm README.md
git commit -m "rm README.md"
git push -u origin master
|
7.和远程项目连接,注意不要使用https clone:
1 2 3 4 5 | git clone git@github.com:user /test .git
git add .
git status
git commit -m "commit"
git push -u origin main
|
8.删除回滚到最近的commit:
1 2 3 | git reflog
git reset --hard commit_id
git push origin master --force
|