# onlineGit **Repository Path**: wulala/onlineGit ## Basic Information - **Project Name**: onlineGit - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2014-03-19 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #onlineGit 当你为某个项目发布补丁,然后某个核心成员将你的补丁并入项目时,你就是作者,而那个核心成员就是提交者。 git目录是一个新的项目 1.我们要纳入版本控制: git init //初始化新仓库 2.查看状态: git status // //未跟踪:Untracked files:不在版本控制中 //放入暂存区: 3.跟踪新文件并处于暂存状态:git add //Changes to be committed[已暂存] //git add 把目标文件快照放入暂存区域,同时未曾跟踪过的文件标记为需要跟踪。 4.修改已暂存文件会出现Changes not staged for commit[跟踪文件已修改但未放入暂存区]:git add //暂存最新版本已修改的文件 5.查看当前文件跟暂存区域之间的差异:git diff git diff --staged //查看暂存区与上次提交文件的不同 6.提交更新:git commit -m [Description] 7.已跟踪的文件一并提交[不管是否在暂存区域]:git commit -a -m [Description] 8.从git移除某个文件:git rm [file_name] 删除之前修改过并且已经放到暂存区域的话:git rm -f [file_name] 9.从git仓库或暂存区删除文件.文件还在工作目录:git rm --cached [file_name] 10.重命名:git mv old_file_name new_file_name 11.查看提交历史:git log git log -2 //最近两次提交 git log -p //查看每次提及的差异 git log -stat //查看增改行数 //... //撤销操作:有些撤销操作是不可逆的 1.修改最后一次提交:git commit -amend 执行了 git commit -m 后发现忘记暂存某些修改可以这样: git add [] git commit -amend 2.取消已暂存的文件:git reset head [file] 3.__撤销上一条操作:git checkout -- [file]__ //破坏性操作 onlineGit是一个远程仓库 1.查看当前的远程库: git remote -v 2.查看远程仓库信息: git remote show remote-name/origin 3.添加一个远程仓库:git remote add [shortname短名] url //短名可以直接饮用,而不用书写一大坨url 4.从远程仓库抓取数据: git fetch shortname/url //如果是克隆了一个仓库,此命令会自动将远程仓库归于 origin 名下。所以,git fetch origin 会抓取从你上次克隆以来别人上传到此远程仓库中的所有更新(或是上次 fetch 以来别人提交的更新)。 5.推送数据到远程仓库: git push origin master //克隆操作会自动使用默认的 master 和 origin 名字 6.修改远程仓库在本地的命名: git remote rename shortname 7.远程仓库的删除: git remote rm shortname 打标签 查看现有标签:git tag 新建标签:git tag -a v0.1 -m "0.1版本" //艹,无效是为什么。 轻量级标签:git tag v1.4 //艹,可以 查看标签:git show ...