免费学校网站模板html,深圳网站制作开发,彩页设计软件,网站建设单位排名1. git入门操作
1、基本名词解释
图片
名词含义index索引区#xff0c;暂存区master分支名#xff0c;每个仓库都有个master#xff0c;它作为主分支。branch其他分支#xff0c;我们可以把master分支上的代码拷贝一份#xff0c;重新命名为其他分支名work space就是我…1. git入门操作
1、基本名词解释
图片
名词含义index索引区暂存区master分支名每个仓库都有个master它作为主分支。branch其他分支我们可以把master分支上的代码拷贝一份重新命名为其他分支名work space就是我们的工作区使用git status就可以看到工作区的内容有无变动responsitory仓库我们将代码写好之后先add在commit就提交到我们的本地仓库中remote就是远程仓库git push就提交到远程服务器上。
2、与github关联
配置ssh-key
$ ssh-keygen –t rsa –C “comment message” **1.在使用https clone下来的仓库在提交的时候每次都需要输入用户名和密码**
1、是因为github使用ssh协议所以我们需要修改将https协议修改ssh2、先执行$ git remote rm origin 移除远程服务器3、再添加远程服务器 $ git remote add server_name 4、在提交的时候建立远程跟踪关系git push --set-upstream
2、基本命令
命令参数含义git clone支持多种协议除了HTTP(S)以外还支持SSH、Git、本地文件协议等git clone 版本库的网址 本地目录名-o指定远程服务器名称-b指定clone分支$ git clone http[s]://example.com/path/to/repo.git/ $ git clone ssh://example.com/path/to/repo.git/ $ git clone git://example.com/path/to/repo.git/ $ git clone /opt/git/project.git git commit -m后面跟提交的message –a 相当于先操作add -amen修改最后一次提交的messagegit status -s显示简短信息 –show-stash 显示stash内容 -v –v 相当于git diff --ignoredtranditional 查看gitignore中被忽略的文件 --ignoredmatching查看正在被忽略的文件git add .将当前目录所有文件添加到index中–a 将所有的修改文件都添加到index中 –u更新已经修改过的文件git push 远程主机名远程分支名-f强制推到服务器$ git push origin --delete master 删除远程分支 $ git push origin --tags 推送tag信息 git pull 远程主机名 远程分支名-p同步服务器的信息$ git branch --set-upstream master origin/next 手动建立追踪关系 $ git pull –rebase server_name server_branch:local_branch 使用rebase模式merge代码 git log显示日志git mvfile_name文件重命名git rmfile_name文件重命名--cached将文件移除追踪但本地不删除git checkout.将当前已经提交到缓存区的内容撤销-b branch_name创建分支并且切换到这个分支
3、.gitignore文件
这个文件的作用就是让git可以忽略某些不需要管理的文件和文件夹
$ touch .gitignore #创建.gitignore文件 可以在文件写入不想被管理的文件可以用正则符号 Debug* *.obj $ git status –ignored #查看gitignored中忽略的文件
4、配置文件的操作
1、基本配置项
命令参数含义git config--list列出所有的参数--global全局参数--local本地仓库参数--unset取消参数设置 常用的配置项 user.name user.email https.proxy http.proxy core.editor diff.tool $ git config --global core.editor \C:\\Program Files\\Notepad\\notepad.exe\
2、配置文件
difftool配置 在~/.gitconfig文件中写入如下配置信息
[diff] prompt false prompt false [difftool tortoisediff] cmd \C:/Program Files/TortoiseGit/bin/TortoiseGitMerge.exe\ -mine $REMOTE -base $LOCAL mergetool配置
[merge] tool tortoisemerge prompt false [mergetool tortoisemerge] cmd \C:/Program Files/TortoiseGit/bin/TortoiseGitMerge.exe\ -mine $LOCAL -theirs $REMOTE -base $BASE -merged $MERGED
3、配置git bash编码配置
命令含义$ git config --global core.quotepath false显示 status 编$ git config --global gui.encoding utf-8图形界面编码$ git config --global i18n.commit.encoding utf-8提交信息编码$ git config --global i18n.logoutput.encoding utf-8输出 log 编码