Git基本操作

基本操作练习 https://try.github.io

git init 初始化仓库

git status 查看状态

git add '*.txt' 将文件加入管理

git commit -m "说明" 提交变动

git log 查看提交的历史记录

git remote add origin https://github.com/try-git/try_git.git 指定远程的仓库

git push -u origin master 将本地master分支推送到在线仓库,-u表示记住参数,下次可直接使用git push

git pull origin master 从在线仓库读取最新版本到master分支

git diff HEAD 查看最新版本的变动

git diff --staged 查看本地文件与最新版本的差异

git reset xxx.txt add的反操作

git checkout -- <target> 文件回退到最新版本

git branch branch_name 创建新分支branch_name

git checkout branch_name 切换到分支branch_name

git rm '*.txt' 删除文件

git merge branch_name 将分支branch_name合并到主分支

git branch -d branch_name 删除分支

 

进阶阅读http://git-scm.com/book

原文地址:https://www.cnblogs.com/ooobj/p/4262183.html