git使用例子
1.克隆远程仓库
git clone URL
2.切换到某个分支
git checkout branch_name
3.提交某个文件修改
git add file /*对修改的文件先add到本地缓存区,然后通过commit加入到本地仓库,在push到远程仓库*/
git commit filename
4.显示文件的修改记录
git diff --name-only ./
5.清除commit的记录,回退到某个版本
git reset version_no(如:7dcc4ac0073fedd42ab8592726ad56cc7b180fb0)
6.将本地的提交更新到远程仓库
git push URL branch_name
7.查看某个文件的修改,只显示一行
git log --pretty=oneline filename
8.将远程仓库的更新同步到本地
git fetch branch_name /*将本地仓库和远程仓库进行同步,若出现错误:同步到远程仓库时出现non-fast-forward updates were rejected错误,可以使用-f强制同步*/
git pull /*将更新的文件内容拉到本地仓库*/
9.查看分支情况
git branch -a
10.创建分支
git branch branch.name
11.切换到某个分支
git checkout branch.name
12.将本地分支上传到远程仓库
git push --set-upstream origin branch.name