ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] # 常用 ## 提交 ``` git add . git commit -am '备注' git push git config --add core.filemode false ``` ## 忽略文件模式 ``` git config --add core.filemode false ``` ## linux 免密码 linxu使用功能ssh https://www.jianshu.com/p/b5ec092fc1d1 ``` $ cd ~/.ssh $ ls authorized_keys2 id_rsa known_hosts config id_rsa.pub ``` 如果没有密匙 , 使用命令创建 我们需要寻找一对 `id_rsa` 或 id_dsa 命名的文件,其中一个带` .pub `扩展名。 '.pub'文件是你的公钥,另一个则是私钥。如果没有找不到这样的文件(或者根本就没有`.ssh`目录),我们可以通过 `ssh-keygen` 程序来创建它们。 ``` ssh-keygen -t rsa -C "xx@xx.com" ``` 首先 ssh-keygen 会确认密钥的存储位置和文件名(默认是 .ssh/id_rsa),然后他会要求你输入两次密钥口令,留空即可。所以一般选用默认,全部回车即可。 接下来我们登陆到GitHub上,右上角小头像->Setting->SSH and GPG keys中,点击new SSH key。 Title:可以随便填写,但最好起的名字能让自己知道这个公钥是哪个设备的。 Key:将上面生成的.pub文件中的所有内容复制到这里。 点击下面的Add SSH key即可。 然后你就会发现可以免密码访问了 # 克隆 ``` git clone https://git.dev.tencent.com/mulo/huopinadmin.git ``` # 提交文件   ``` (添加文件) git add .     (提交所有修改到本地)  git commit -am '备注内容' (推送到服务器) git push ``` # 拉取  ``` git pull ``` # 配置  ``` git config --global user.email "you@example.com" git config --global user.name "Your Name" ``` ***** # 更多 ## linux上记住密码 ``` git config --global credential.helper store ``` ## 暂存和取消 ``` git add test1.php git reset test1.php git status -s ``` ## 推送到分支 ``` git remote add origin https://git.coding.net/xxx/xxx.git git push -u origin master ``` 分支 ``` 查看: git branch 创建: git branch dev ``` ## 把新建的项目初始化到git ``` 1. git init 2. git add -A 3. git commit -am "init && dev package" 4. git remote add origin git@github.com:hbh112233abc/php-cas-client.git 5. git push -u origin master ``` ## 忽略文件模式 ``` git config --add core.filemode false ``` ## 冲突解决 - 放弃当前所有更改 ``` git checkout . git checkout master . ``` - 放弃某个文件更改 ``` git checkout filepath ``` ### 放弃所有更改 ``` git checkout . #本地所有修改的。没有的提交的,都返回到原来的状态 git stash #把所有没有提交的修改暂存到stash里面。可用git stash pop回复。 git reset --hard HASH #返回到某个节点,不保留修改。 git reset --soft HASH #返回到某个节点。保留修改 git clean -df #返回到某个节点 git clean 参数 -n 显示 将要 删除的 文件 和 目录 -f 删除 文件 -df 删除 文件 和 目录 git checkout . && git clean -xdf ``` # 安装 ## linux下安装 ``` yum install git ```