GIT

git 基础

git 分为三个区域:

1,工作代码区  work 
2,暂存区  stage 
3,最终仓库  repository 

git常用配置:

git config --global user.name 'zxxxxx' # 设置用户名
git config --global user.email '10xxxxxx35@qq.com' #设置用户名邮箱
git config --global core.editor vim # 设置 git 编辑器为vim ,不然默认的是Nano
git config --list # 查看设置

git提交流程:

1,工作代码区创建git 仓库
cd 工作目录
git init

2,添加到暂存区
git add 文件


3,提交到最终的仓库
git commit -m "注释"

# 其他操作
在工作代码区 增删改查 了代码
重新走 2,3 步骤

# 清空工作区
还没有 add 和 commit 的文件,可以使用 git checkout .
还没有 add 和 commit 的目录,可以使用 git clean -df

# 清空暂存区
如果只 add 了,可以使用 git reset . 【这时是退回到了工作区】

以上内容 和 github.com 还没关系,所有的操作都是本地在操作!!!

git 将本地仓库提交到远程仓库:

将本地仓库push 到github仓库
git remote add <shortname> https://github.com/zzzzz/xxx.git #shortname 代表后面整个URL
git push -u <shortname> <branch> # 将本地的branch 推送到 shortname代表的服务器上

# 其他
分支操作
git branch -M <new_branch> # 将当前分支名字改为 new_branch


git branch <new_branch>
git checkout <new_branch> 切换到 new_branch => git checkout -b <new_branch>

git 高级

git status,git add,git commit, git mv,git rm,git diff, and short status and ignoring files,

https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository

git diff 仅仅是比较stage 中的文件的变化

git undoing things 

https://git-scm.com/book/en/v2/Git-Basics-Undoing-Things

git working with remotes

https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes

原文地址:https://www.cnblogs.com/zach0812/p/14589143.html