1)删除提交记录
git reset --hard "commit ID"
e.g git reset --hard "0604b21f7f6e0c7abb8d73d56bfdb6e2d11836cd"
git push origin HEAD --force
前提是对操作的repo目录,有force push权限。
这样会彻底从commit history删除,而且对文件所做的修改也删除。
revert
只是回滚对文件所做的修改,但是git operation都会在commit history里删除。


2)git stash用法
git stash save "work in progress for too feature" #
保存当前工作进程,并命名加以区分
git diff HEAD #
查看当前工作区和本地repo的区别,并无区别才是对的,因为工作区已经被暂存
git stash list #
查看当前所有stash
git stash apply --index "stash@{1}"
git diff HEAD #
查看当前工作区和本地repo的区别,有区别才是对的,应用了工作区的修改

  

3)按照下列步骤创建repo失败00

步骤:

pc_user_name@CN00207328 MINGW64 /c/repo/test_repo (master)

echo "#This is test_repo" >> README.md

git init

git add README.md

git commit -m "first commit"

git remote add origin https://github.com/GITHUBSIGNUM/test_repo.git

git push -u origin master

pc_user_name@CN00207328 MINGW64 /c/repo/test_repo (master)

错误信息:

hunjng@CN00207328 MINGW64 /c/repo/test_repo (master)

$ git remote add origin https://github.com/GITHUBSIGNUM/test_repo.git

pc_user_name@CN00207328 MINGW64 /c/repo/test_repo (master)

$ git push -u origin master

remote: Repository not found.

fatal: repository 'https://github.com/GITHUBSIGNUM/test_repo.git/' not found

原因: need to create the repository on GitHub first.It can't find the repository because it doesn't exist yet!

http://stackoverflow.com/questions/10922028/github-error-repository-not-found-fatal-the-remote-end-hung-up-unexpectedly


4)提交已经修改的注释
git commit -amend
#
修改前次提交的注释 --amend amend previous commit
https://help.github.com/articles/changing-a-commit-message/


5)如何只更新一个文件
git fetch
git checkout origin/master -- training-basic/src/main/somefile.java


6)修改git用户

编辑repo下的.gitconfig文件或者

git config --global user.name "GraceJiang"
git config --global user.email jianghuanjunok@163.com


7)others

Maven

http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

posted on 2017-03-22 19:37  维也纳下午茶  阅读(267)  评论(0编辑  收藏  举报