Git

作者: RoyTien | 来源:发表于2017-12-07 16:52 被阅读7次
command result
fetch 只会抓取从上次clone以来别人上次到此远程仓库中的所有更新;即只将远端数据拉到本地,不自动合并到当前工作分支
pull 自动抓取数据并合并
clone 自动创建本地master分支用于跟踪远程仓库中master分支
push 在remote仓库中有写权限,同一时间无其他人push数据;若有人push了更新,则需要先抓取他们的更新到本地,合并到自己的项目中,才可以再次push
merge 先回到master branch - git checkout master;再merge - git merge <branch name>; 将<branch name> branch合并入master
command result
git checkout <branch name> 切换分支 <branch name>
git branch <branch name> 创建分支 <branch name>
git remote -v View current remotes
git remote rm <remote name> Removing a remote
command result
git checkout . Discard all changes in working directory (modified files)
git clean -fd Remove untracked files from the working tree
git clean -fd -f focus; -d remove whole directories
git branch -d <branch> 删除分支
修改最后一次提交 (重新提交,覆盖最后一次提交)
$ git commit -m 'initial commit'
$ git add forgotten_file
$ git commit --amend
command result
git commit --amend 重新提交(并覆盖最后一次提交)
取消暂存文件 modified file
$ git add .
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   README.txt
        modified:   benchmarks.rb

// 取消暂存
$ git reset HEAD benchmarks.rb
Unstaged changes after reset:
M       benchmarks.rb
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   README.txt

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   benchmarks.rb
取消对文件的修改(删除对文件的修改)
$ git checkout -- benchmarks.rb
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   README.txt

相关文章

网友评论

      本文标题:Git

      本文链接:https://www.haomeiwen.com/subject/bpvtcxtx.html