Git 全局设置:
git config --global user.name "孙磊"
git config --global user.email "86907921@qq.com"
加入.gitignore文件
git config --global core.excludesfile '~/.gitignogtire'
创建 git 仓库:
mkdir software
cd software
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitee.com/sunlei1990/software.git
git push -u origin master
克隆仓库
git clone https://gitee.com/sunlei1990/software.git
查看git的配置信息
git config --list
从远程仓库同步最新版本到本地
git pull origin master
命令说明
git init 初始化仓库
git clone 拷贝一份远程仓库,也就是下载一个项目。
git add 添加文件到仓库
git status 查看仓库当前的状态,显示有变更的文件。
git diff 比较文件的不同,即暂存区和工作区的差异。
git commit 提交暂存区到本地仓库。
git reset 回退版本。
git rm 删除工作区文件。
git mv 移动或重命名工作区文件。
git log 查看历史提交记录
git blame <file> 以列表形式查看指定文件的历史修改记录
git remote 远程仓库操作
git fetch 从远程获取代码库
git pull 下载远程代码并合并
git push 上传远程代码并合并
git branch (branchname) 创建分支
git checkout (branchname) 切换分支
git merge 合并分支
git branch 列出分支
git branch -d (branchname) 删除分支
git log 查看历史提交记录
git blame <file> 以列表形式查看指定文件的历史修改记录
git tag -a v1.0 git标签创建
git tag 查看标签
git remote add [shortname] [url] 添加远程仓库
ssh-keygen -t rsa -C "youremail@example.com" 命令生成 SSH Key
git fetch 从远程仓库下载新分支与数据
git merge 从远端仓库提取数据并尝试合并到当前分支
git push [alias] [branch] 推送远程仓库
git remote rm [别名] 删除远程仓库