{"id":294,"date":"2019-05-28T10:41:37","date_gmt":"2019-05-28T01:41:37","guid":{"rendered":"https:\/\/blog.hgrs.me\/?p=294"},"modified":"2020-02-24T02:42:25","modified_gmt":"2020-02-23T17:42:25","slug":"git%e3%81%a8github%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9","status":"publish","type":"post","link":"https:\/\/blog.hgrs.me\/archives\/294.html","title":{"rendered":"Git\u3068GitHub\u306e\u4f7f\u3044\u65b9"},"content":{"rendered":"

\u306f\u3058\u3081\u306b<\/h2>\n

\u5927\u5b66\u306e\u7814\u7a76\u5ba4\u3067\u5f8c\u8f29\u306bGit\u3068GitHub\u306e\u4f7f\u3044\u65b9\u3092\u6559\u3048\u308b\u4f1a\u3092\u524d\u306b\u3084\u3063\u305f\u306e\u3067\u3001\u3064\u3044\u3067\u306b\u8a18\u4e8b\u3068\u3057\u3066\u6b8b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n

Git<\/h2>\n

\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\/\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n

\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u306a\u3051\u308c\u3070\u3053\u3061\u3089<\/a>\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u3057\u307e\u3059\u3002<\/p>\n

\u521d\u671f\u8a2d\u5b9a(GitHub\u767b\u9332\u3057\u3066\u304b\u3089\u306e\u65b9\u304c\u3044\u3044\u304b\u3082)<\/h3>\n

\u30bf\u30fc\u30df\u30ca\u30eb\u304b\u3089\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u6253\u3061\u307e\u3059\u3002<\/p>\n

$ git config --global user.name "GitHub\u306e\u30e6\u30fc\u30b6\u540d(\u3058\u3083\u7121\u304f\u3066\u3082\u3044\u3044\u3051\u3069\u63c3\u3048\u3068\u304f\u3068\u3044\u3044)"\n$ git config --global user.email "GitHub\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9(\u3058\u3083\u7121\u304f\u3066\u3082\u3044\u3044\u3051\u3069\u63c3\u3048\u3068\u304f\u3068\u3044\u3044)"<\/code><\/pre>\n

\u30ed\u30fc\u30ab\u30eb\u3067\u30ea\u30dd\u30b8\u30c8\u30ea\u3054\u3068\u306b\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n

GitHub<\/h2>\n

\u767b\u9332<\/h3>\n

Join GitHub<\/a>\u304b\u3089Username\/Email address\/Password\u3092\u5165\u529b\u3057\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u4f5c\u308a\u307e\u3059\u3002\u591a\u5206\u8e93\u304f\u3068\u3053\u308d\u306f\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n

\u3042\u3068\u3001GitHub\u306f\u5b66\u751f\u30d7\u30e9\u30f3\u3082\u3042\u308b\u306e\u3067\u30aa\u30b9\u30b9\u30e1\u3067\u3059\u3002<\/p>\n

\u30ea\u30dd\u30b8\u30c8\u30ea\u4f5c\u6210<\/h3>\n

\u753b\u50cf\u306b\u3042\u308b\u3088\u3046\u306b\u300cNew\u300d\u304b\u3089\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002<\/p>\n

\"\"<\/p>\n

\u4f5c\u6210\u304c\u3067\u304d\u305f\u3089\u3001\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u60c5\u5831\u3092\u5165\u529b\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n

\"\"<\/p>\n

\u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea<\/h2>\n

\u81ea\u5206\u306e\u624b\u5143\u3067\u6271\u3046\u30ea\u30dd\u30b8\u30c8\u30ea\u3067\u3059\u3002<\/p>\n

\u30ea\u30dd\u30b8\u30c8\u30ea\u5358\u4f4d\u3067\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u3092\u884c\u3046\u306e\u3067\u3059\u304c\u5927\u307e\u304b\u306a\u6d41\u308c\u306f<\/p>\n

    \n
  1. \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u8ffd\u52a0<\/li>\n
  2. \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u8ffd\u52a0\u3055\u308c\u305f\u3082\u306e\u3092\u30b3\u30df\u30c3\u30c8<\/li>\n<\/ol>\n

    \u3067\u3059\u3002\u3053\u3053\u3067\u884c\u3063\u305f\u30b3\u30df\u30c3\u30c8\u304c\u3069\u3093\u3069\u3093\u7a4d\u307f\u91cd\u306a\u3063\u3066\u3044\u304d\u3001\u7279\u5b9a\u306e\u5730\u70b9\u306e\u30b3\u30df\u30c3\u30c8\u306b\u623b\u308c\u305f\u308a\u3057\u307e\u3059\u3002<\/p>\n

    \u307e\u305f\u30d6\u30e9\u30f3\u30c1\u3092\u5207\u308b\u3053\u3068\u3067\u3001\u5225\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u958b\u767a\u304c\u3067\u304d\u305f\u308a\u3057\u307e\u3059\u3002<\/p>\n

    \u521d\u671f\u5316<\/h3>\n

    \u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u3001\u73fe\u5728\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092Git\u30ea\u30dd\u30b8\u30c8\u30ea\u3068\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n

    $ git init<\/code><\/pre>\n

    \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u8ffd\u52a0<\/h3>\n

    \u3084\u308a\u65b9\u306f\u4ee5\u4e0b\u306e\u3069\u308c\u304b\u3067\u3059\u3002<\/p>\n

    $ git add <\u8ffd\u52a0\u3057\u305f\u3044\u30d5\u30a1\u30a4\u30eb\/\u30c7\u30a3\u30ec\u30af\u30c8\u30ea>\n$ git add .   # \u5168\u3066\u8ffd\u52a0\n$ git add README.md   # README.md\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u3092\u8ffd\u52a0\n$ git add assets  # assets\u3068\u3044\u3046\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u8ffd\u52a0<\/code><\/pre>\n

    \u4e00\u756a\u3088\u304f\u4f7f\u3046\u306e\u306fgit add .<\/code>\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n

    \u305f\u3060\u3001\u3053\u308c\u3060\u3068\u5168\u3066\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u8ffd\u52a0\u3057\u3066\u3057\u307e\u3046\u305f\u3081\u3001Git\u3067\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u3057\u306a\u3044\u3082\u306e\u3084\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u3066\u306f\u56f0\u308b\u30d5\u30a1\u30a4\u30eb\/\u30c7\u30a3\u30ec\u30af\u30c8\u30ea(\u4f8b\u3048\u3070\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30ad\u30fc\u304c\u66f8\u304b\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u3084\u30d3\u30eb\u30c9\u3057\u305f\u30d0\u30a4\u30ca\u30ea\u3068\u304b)\u307e\u3067\u8ffd\u52a0\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n

    \u305d\u3053\u3067.gitignore<\/code>\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u3067Git\u3067\u306e\u7ba1\u7406\u306b\u542b\u3081\u306a\u3044\u30d5\u30a1\u30a4\u30eb\/\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002<\/p>\n

    \u30b3\u30df\u30c3\u30c8<\/h3>\n

    \u6b21\u306e\u3069\u3061\u3089\u304b\u3067\u3001\u30b3\u30df\u30c3\u30c8\u3092\u767b\u9332\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n

    $ git commit -m "\u30b3\u30df\u30c3\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8"\nor\n$ git commit  # \u30a8\u30c7\u30a3\u30bf\u304c\u958b\u3044\u3066\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u6253\u3066\u307e\u3059<\/code><\/pre>\n

    \u30b3\u30df\u30c3\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8\u306f\u81ea\u7531\u306b\u6253\u3066\u307e\u3059\u304c\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3054\u3068\u306b\u66f8\u5f0f\u304c\u6c7a\u307e\u3063\u3066\u305f\u308a\u3082\u3057\u307e\u3059\u3002\u7279\u306b\u306a\u3051\u308c\u3070\u3001\u5909\u66f4\u70b9\u3092\u308f\u304b\u308a\u3084\u3059\u304f\u66f8\u3051\u3070\u3044\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n

    \u307e\u305f\u30b3\u30df\u30c3\u30c8\u306e\u983b\u5ea6\u3082\u81ea\u7531\u3067\u3059\u304c\u3001\u7d30\u304b\u304f\u3084\u308b\u3053\u3068\u3092\u63a8\u5968\u3057\u307e\u3059\u30021\u3064\u306e\u6a5f\u80fd\u3084\u4f55\u304b\u30bf\u30b9\u30af\u304c\u7d42\u308f\u308b\u3054\u3068\u306b\u3084\u308b\u3068\u3044\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n

    \u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u3067\u306e\u66f4\u65b0\u306fadd<\/code>\u3068commit<\/code>\u304c\u3042\u308c\u3070\u3044\u3044\u306e\u3067\u3001\u3053\u306e2\u3064\u304c\u3082\u3063\u3068\u3082\u9ad8\u3044\u983b\u5ea6\u3067\u4f7f\u3046\u3053\u3068\u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n

    \u30d6\u30e9\u30f3\u30c1<\/h3>\n

    \u5225\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u958b\u767a\u3084\u3001\u6a5f\u80fd\u306e\u8ffd\u52a0\/\u4fee\u6b63\u3054\u3068\u306a\u3069\u306b\u4f7f\u3046\u3053\u3068\u304c\u3042\u308b\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u679d\u5206\u304b\u308c\u6a5f\u80fd\u3067\u3059\u3002\u7279\u306b\u4ed6\u4eba\u3068\u306e\u5171\u540c\u958b\u767a\u3067\u306f\u3088\u304f\u4f7f\u3046\u3053\u3068\u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n

    \u30b3\u30de\u30f3\u30c9\u4e00\u89a7\u3092\u793a\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n

    $ git branch <\u30d6\u30e9\u30f3\u30c1\u540d>  # \u30d6\u30e9\u30f3\u30c1\u306e\u767b\u9332\n$ git checkout <\u30d6\u30e9\u30f3\u30c1\u540d>    # \u30d6\u30e9\u30f3\u30c1\u306e\u5207\u66ff\nor\n$ git checkout -b <\u30d6\u30e9\u30f3\u30c1\u540d>   # \u4e0a\u306e\u4e8c\u3064\u3092\u307e\u3068\u3081\u3066\u3067\u304d\u308b\n\n$ git branch -d <\u30d6\u30e9\u30f3\u30c1\u540d>   # \u30d6\u30e9\u30f3\u30c1\u306e\u6d88\u53bb\n\n$ git merge <\u30d6\u30e9\u30f3\u30c1\u540d>   # \u4ed6\u306e\u30d6\u30e9\u30f3\u30c1\u3068\u7d50\u5408<\/code><\/pre>\n

    \u30ea\u30e2\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea(\u4eca\u56de\u306fGitHub)<\/h2>\n

    \u30ea\u30e2\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u8ffd\u52a0<\/h3>\n

    \u5148\u307b\u3069\u306egit add<\/code>\u3068\u4f3c\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u3061\u3089\u306fgit remote add<\/code>\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n

    $ git remote add <\u30ea\u30dd\u30b8\u30c8\u30ea\u540d> <URL>\n$ git remote add origin https:\/\/github.com\/hoge\/huga.git # \u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u540d\u524d\u304corigin\u3067\u3059<\/code><\/pre>\n

    \u30d7\u30c3\u30b7\u30e5<\/h3>\n

    \u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u5909\u66f4\u3092\u30ea\u30e2\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n

    $ git push -u <\u30ea\u30dd\u30b8\u30c8\u30ea\u540d> <\u30d6\u30e9\u30f3\u30c1\u540d>    # -u\u3092\u3064\u3051\u308b\u3068\u6b21\u56de\u304b\u3089git push\u306e\u307f\u3067\u826f\u304f\u306a\u308a\u307e\u3059\n$ git push -u origin master\n$ git push<\/code><\/pre>\n

    \u30d7\u30eb<\/h3>\n

    \u30ea\u30e2\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea\u304b\u3089\u6700\u65b0\u7248\u3092\u6301\u3063\u3066\u304d\u307e\u3059\u3002\u4f5c\u696d\u524d\u306b\u5fc5\u305a\u3084\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n

    $ git pull<\/code><\/pre>\n

    \u304a\u308f\u308a\u306b<\/h2>\n

    \u3053\u308c\u3067\u4e00\u901a\u308a\u306e\u4f5c\u696d\u304c\u3067\u304d\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n

    \u3053\u3053\u306b\u66f8\u3044\u3066\u3044\u306a\u3044\u3053\u3068\u3084\u3001\u56f0\u3063\u305f\u6642\u306f\u5148\u8f29\u304c\u6b8b\u3057\u3066\u304f\u308c\u305f\u4f5c\u696d\u5225Git\u30b3\u30de\u30f3\u30c9\u96c6<\/a>\u3092\u898b\u308c\u3070\u3001\u3060\u3044\u305f\u3044\u66f8\u3044\u3066\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

    \u306f\u3058\u3081\u306b \u5927\u5b66\u306e\u7814\u7a76\u5ba4\u3067\u5f8c\u8f29\u306bGit\u3068GitHub\u306e\u4f7f\u3044\u65b9\u3092\u6559\u3048\u308b\u4f1a\u3092\u524d\u306b\u3084\u3063\u305f\u306e\u3067\u3001\u3064\u3044\u3067\u306b\u8a18\u4e8b\u3068…<\/p>\n","protected":false},"author":1,"featured_media":296,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[39,27],"_links":{"self":[{"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/posts\/294"}],"collection":[{"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/comments?post=294"}],"version-history":[{"count":0,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/posts\/294\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/media\/296"}],"wp:attachment":[{"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/media?parent=294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/categories?post=294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/tags?post=294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}