设为首页 收藏本站
查看: 1327|回复: 0

[经验分享] git config配置,工作区和版本库联系。

[复制链接]

尚未签到

发表于 2018-1-13 20:37:14 | 显示全部楼层 |阅读模式
  关于git和github的介绍,我这边不多说。
  使用在windows下使用git,需要配置环境变量,也可以使用git自带的终端工具。,打开git bash
  

laoni@DESKTOP-TPPLHIB MINGW64 ~ (master)  
$ cd c:
/laoni  

  
laoni@DESKTOP
-TPPLHIB MINGW64 /c/laoni  
$
dir  
AutomatedMonitor  bak  Mr.blue  PycharmProjects
  

  
laoni@DESKTOP
-TPPLHIB MINGW64 /c/laoni  
$ cd PycharmProjects
/  

  界面和linux的终端相识,首先需要进行初始化,也就是配置个人信息:
  使用git help可以查看git相关命令,也可以通过git help command指定命令查询。

  

$ git help  
usage: git [
--version] [--help] [-C <path>] [-c name=value]
[

--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[

-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[

--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]<command> [<args>]  

  
These are common Git commands used
in various situations:  

  
start a working area (see also: git help tutorial)
  clone      Clone a repository into a new directory
  init       Create an empty Git repository or reinitialize an existing one
  

  
work on the current change (see also: git help everyday)
  add        Add
file contents to the indexmv         Move or rename a file, a directory, or a symlink  reset      Reset current HEAD to the specified state
rm         Remove files from the working tree and from the index  

  
examine the history and state (see also: git help revisions)
  bisect     Use binary search to
find the commit that introduced a buggrep       Print lines matching a pattern  log        Show commit logs
  show       Show various types of objects
  status     Show the working tree status
  

  
grow, mark and tweak your common history
  branch     List, create, or delete branches
  checkout   Switch branches or restore working tree files
  commit     Record changes to the repository
diff       Show changes between commits, commit and working tree, etc  merge      Join two or
more development histories together  rebase     Reapply commits on top of another base tip
  tag        Create, list, delete or verify a tag
object signed with GPG  

  
collaborate (see also: git help workflows)
  fetch      Download objects and refs from another repository
  pull       Fetch from and integrate with another repository or a local branch
  push       Update remote refs along with associated objects
  

  

'git help -a' and 'git help -g' list available subcommands and some  
concept guides. See
'git help <command>' or 'git help <concept>'  
to read about a specific subcommand or concept.
  


git help  使用git config --global user.name "XXX" 和git config --global user.email "XXX@XX.com"可以添加用户名和邮箱,
  使用 git config --unset --global user.name 可以取消用户名配置,
  使用 git config --list 查看所有可用的配置信息。

  

laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test  
$ git config
--global user.name 'LaoNiNi'  

  
laoni@DESKTOP
-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test  
$ git config
--global user.email "laonivv@163.com"  

  
laoni@DESKTOP
-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test  
$ git config
--unset --global user.name  

  
laoni@DESKTOP
-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test  
$ git config
--list  
core.symlinks
=false  
core.autocrlf
=true  
core.fscache
=true  
color.
diff=auto  
color.status
=auto  
color.branch
=auto  
color.interactive
=true  
help.format
=html  
rebase.autosquash
=true  
http.sslcainfo
=F:/pythonfile/Git/mingw64/ssl/certs/ca-bundle.crt  

diff.astextplain.textconv=astextplain  
filter.lfs.clean
=git-lfs clean -- %f  
filter.lfs.smudge
=git-lfs smudge -- %f  
filter.lfs.required
=true  
filter.lfs.process
=git-lfs filter-process  
credential.helper
=manager  
user.email
=laonivv@163.com  
filter.lfs.clean
=git-lfs clean %f  
filter.lfs.smudge
=git-lfs smudge %f  
filter.lfs.required
=true  


git config  git区分工作区和版本库

  对于项目根目录github_test目录来说,这就是工作区。
  使用 git init 命令进行初始化,之前的config配置,需要初始化才能生效,config配置信息存在.git/config文件
  laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test
  $ git init
  Initialized empty Git repository in C:/laoni/PycharmProjects/github_test/.git/
  PS:如果对git不熟悉的话,建议不要对。git目录下的文件进行修改。
  使用git status查看当前git状态,Untracked files(未监视的文件,未被跟踪文件)也就是没有存到暂存区(上面截图的版本库下的index部分)的文件,使用git add index.html 把文件添加到暂存区。
  

laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test (master)  
$ git status
  
On branch master
  

  
Initial commit
  

  
Untracked files:
  (use
"git add <file>..." to include in what will be committed)  

  index.html
  

  
nothing added to commit but untracked files present (use
"git add" to track)  

  
laoni@DESKTOP
-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test (master)  

  laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test (master)
  $ git add index.html
  laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test (master)
  $ git status
  On branch master
  Initial commit
  Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
  new file:   index.html
  把index.html文件添加到暂存区后,需要把文件从暂存区添加到branch master分支上,一般一个项目会有个主分支(一般叫master),使用git commit提交,会提示说明下这次的提交注释,再用git status查看,提示在当前主分支,没有需要commit的文件,工作区很干净。
  

laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test (master)  

$ git commit  
[master (root
-commit) 04c94a8] 添加一个文件index.html1 file changed, 0 insertions(+), 0 deletions(-)  create mode
100644 index.html  

  
laoni
@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test (master)  

$ git status  
On branch master
  
nothing to commit, working tree clean
  

  实际上不管是暂存区还是分支上的文件,都存储在objects里面,暂存区和分支上的文件只是一个指向,目录树,有点像windows里的快捷方式了,这个需要理清。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-434835-1-1.html 上篇帖子: Git新建本地分支与远程分支关联问题:git branch --set-upstream【转】 下篇帖子: 解决git did not exit cleanly (exit code 128)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表