Skip to content

Git使用个人笔记 #62

@bojue

Description

@bojue

根据个人使用情况,不定时更新

撤销 git add

  1. 被git add 的文件退出暂存区, 但是修改保留
git reset --mixed
  1. git reset 默认 --mixed,所以可以使用git reset HEAD
git reset HEAD

代码找回

  1. 本地代码commit 但是未提交(reset --hard等操作造成代码丢失)时,代码找回
git reflog 
  1. 撤下到之前状态
git reset --hard HEAD^ //上一个commit 
git reset --hard id

更新master到gh-pages分支

git checkout gh-pages // go to the gh-pages branch
git rebase master // bring gh-pages up to date with master
git push origin gh-pages // commit the changes

git放弃本地,强制覆盖本地代码

$ git fetch --all
$ git reset --hard origin/master 
$ git pull

删除远程分支文件夹,保留本地文件夹

git rm --cached -r xxx
git commit -m "remove file from remote"
git push -u origin master

发布项目到git-pages

git branch gh-pages  
git checkout gh-pages  
git rm -rf .  
git add .  
git commit -m "git pages"  

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions