0%

Git操作总结

git基本操作总结

git更新操作(最经常使用 )

1
2
3
4
5
6
7
git status           #查看git当前状态
git diff server.py #查看server.py 在git当中
git add . #将当前修改提交到 git
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
# 1、Git init (在本地工程目录下),生成.git 文件夹
Git init

# 2、上传修改的文件
git add * #(*可替换成具体要上传的文件名,*表示提交所有有变化的文件)

# 3、添加上传文件的描述
git commit -m "test" #(”test“为描述)

# 4、创建分支
git branch test

# 5(切换分支
git checkout test

# 6、与远程分支相关联
git remote add origin https://github.com/yangxiaoyan20/BowlingScore.git

# 7、上传到对应分支
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 验证是否成功