git基本操作总结
git更新操作(最经常使用 )
1 2 3 4 5 6 7
| git status git diff server.py git add . git commit -m “change threshold for higher precision” git branch git push origin master git push --set-upstream origin vulgar
|
git新建任务并上传已有文件夹项目
首先在git网页上手动创建对应名字的项目
然后按照下面代码进行上传
1 2 3 4 5 6 7
| cd existing_folder git init git remote add origin ssh://git@g.hz.netease.com:22222/wanglichun/liquid.git git add . git commit -m "Initial commit" git push -u origin master Push an existing Git repository
|
git新建分支并上传文件的方法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Git init
git add *
git commit -m "test"
git branch test
git checkout test
git remote add origin https://github.com/yangxiaoyan20/BowlingScore.git
git push origin test
|
git其他命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| git add<file> ,可以向git添加文件,当然可以添加多个文件如:git add a.txt b.txt
git commit -m <message> 提交代码 message为修改备注,方便回溯
git log 可以查看提交日志
git status 可以查看那个当前状态
git diff xxx 查看不同
git checkout -- readme.txt 可以让文件回退到最近一次git commit或者git add的状态
git rm 删除文件
添加github流程: 首先本地git建好,github同样建好repository,
git remote add origin git@github.com:lichun-wang/[name].git
git push -u origin master
|
其他
1 .dockerignore容易被.gitignore给忽略掉,所以需要使用如下代码上传才行。
1
| git add -f .dockerignore
|
2 配置github ssh-key
ssh-keygen,一路回车就好了,生成ssh key
在github网站中->setting->SSH->add new ssh,title就可以填 id_rsa.pub
ssh -T git@github.com 验证是否成功