git基本教程,每天更新

初次运行git需要先行配置基本信息,git的配置信息文件位置有三.其一,/etc/gitconfig 全局配置 命令行git config --system user.name "test"。其二,~/.gitconfig或~/.config/git/config 针对当前用户配置 命令行 git config --global user.name "test" 第三,当前项目下的.git/config 针对当前项目 第一二三层层深入,第三覆盖第二,以此类推。因此.git/config会覆盖所有。

用户基本配置:git config --global user.name "test" 使用了--global的话 仅仅针对当前用户 如果仅仅针对项目的话 在项目下执行 git config user.name "test" 。

查看所有配置信息:git config --list 查看某一项配置: git config user.name 获取帮助:git help 命令,git 命令 --help, man git 命令 本人喜欢git help config格式 

.gitignore忽略要提交的文件 例如:*.[oa] *.~ *.log (git有一个详细的针对数十种项目及语言的.gitignore文件列表,地址 https://github.com/github/gitignore )

命令开始:

git status [-s|--short] 查看文件状态

git add file 跟踪文件或已跟踪的文件放到暂存区或合并有冲突的文件标记为已解决状态

git checkout -b 本地分支名x origin/远程分支名x

git fetch origin 远程分支名x:本地分支名x 需要手动checkout分支

git push origin <local_branch_name>:<remote_branch_name>

git pull origin 远程:本地分支

git push origin :develop 删除远程分支

疯子在左,天才在右
原文地址:https://www.cnblogs.com/zilixiang/p/8397945.html