gitã§ããããæ»ããã
gitã§ä½ããæ»ãããæããã¤ãã©ã®ã³ãã³ãå©ããå¿ããã®ã§ã¡ã¢
ã¯ã¼ãã³ã°ããªã¼ãå ã«æ»ã
ãã¡ã¤ã«ç·¨éãããã©ã¾ã addãã¦ãªãæ
$ git checkout . $ git checkout -- . $ git checkout HEAD -- .
ã©ããHEADã®ç¶æ
ã«ã¯ã¼ãã³ã°ããªã¼ãæ»ãã¦ãããã(çµæãåããªã ãã§æåã¯éããã ãããã©ã»ã»ã»)
"--"ãè¬ãªãã ãã©ãhelpãè¦ã¿ãã¨ãããªä¾ããã£ãã
If you have an unfortunate branch that is named hello.c, this step would be confused as an
instruction to switch to that branch. You should instead write:$ git checkout -- hello.c
ãªãã»ã©ããã¡ã¤ã«ã¨ååã®ãã©ã³ããããã¨ãã©ã³ã移åãã¡ããããã--ã¤ããã°file_pathã¨ãã¦è§£éãã¦ãããã£ã¦ãã¨ãã
indexãå ã«æ»ã
addãã¡ãã£ããã¤ãæ»ãæ
- ã¯ã¼ãã³ã°ããªã¼ã®å¤æ´ã¯ãã®ã¾ã¾ã§addã ããæ»ããªã
$ git reset HEAD
- ã¯ã¼ãã³ã°ããªã¼ã®å¤æ´ãå«ãã¦ãªãã£ããã¨ã«ãããªã
$ git reset --hard HEAD
commitãå ã«æ»ã
commitãããã©ãã£ã±ããæ»ãããæ
- commitã ããæ»ãã¦addããç¶æ ã«ãããªã
$ git reset --soft HEAD~
- commitã¨indexãæ»ãã¦ã¯ã¼ãã³ã°ããªã¼ãç·¨éããç¶æ ã«ãããªã
$ git reset HEAD~ $ git reset --mixed HEAD~
- commitãindexãã¯ã¼ãã³ã°ããªã¼ãæ»ããªã
$ git reset --hard HEAD~
ãªã¢ã¼ãã«pushããã¦ãã³ããããå ã«æ»ã
pushãããã ãã©ããã£ã±ã¿ãã£ã¦ãããæ»ãããï¼ã£ã¦æ
- æ»ãããã³ãããã®SHA-1ã調ã¹ã¦
- ã¨ãã£ã¿ãç«ã¡ä¸ããã®ã§revert commitã®ã¡ãã»ã¼ã¸ãå ¥åãã
$ git revert [SHA-1] $ git push origin [branch]
ãªãã¸ããªãç·¨éããåã®ç¶æ ã¾ã§æ»ãããã£ã¦æ
è²ã ããããã¦ããããããªãï¼ã¨ãããããªã¢ã¼ãã®ææ°ã¾ã§æ»ããããªã
$ git reset --hard origin/[branchå]