pythn面试总结-git

1.新建仓库

1.git init
2.git clone [url]

2.配置

1.显示git配置

git config --list

2.编辑Git配置文件

git config -e [--global]

3.设置提交代码时的用户信息

git config [--global] user.name "[name]"
git config [--global] user.email "[email address]"

3.增加/删除文件

1.增加/删除文件暂存区

git add/rm [file1] [file2]

2.添加目录暂存区

git add [dir]

3.添加当前目录所有文件

git add ..

4. 提交代码

1.提交暂存区到仓库区

git commit -m message

2.提交暂存区的指定文件到仓库区

git commit [file1] [file2] ... -m [message]

3.提交工作区自上次commit之后的变化,直接到仓库区

gir commit -a

4.提交时显示所有diff信息

git commit -v

5. 使用一次新的commit,替代上一次提交 如果代码没有任何新变化,则用来改写上一次commit的提交信息。

git commit --amend -m [message]

6.重做上一次commit,并包括指定文件的新变化

git commit --amend [file1] [file2] ...

5 分支

1.列出所有本地分支

git branch

2.列出所有远程分支

git branch -r

3.列出所有本地分支和远程分支

git branch -a

4.新建一个分支,但依然停留在当前分支

git branch [branch-name]

5.新建一个分支,并切换到该分支

git checkout -b [branch-name]

6.新建一个分支,指向指定commit

git branch [branch] [commit]

7.切换到指定分支,并更新工作区

git checkout [branch-name]

8.合并指定分支到当前分支

git merge [branch-name]

9.删除本地分支

git branch -d [branch-name]

10. 删除远程分支

git push origin --delete [branch-name]
git branch -dr [remote/branch]

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容