git fetch

pull = fetch + merge origin/master

What is “git fetch”?
For git, there are two repositories: remote and local. Fetch is a command that brings the latest information from the remote repository to the local repository. Fetching does not mean that the file is updated like pull. Only the local repository is updated.

[vagrant@localhost test]$ git –version
git version 1.7.1
[vagrant@localhost test]$ git clone https://github.com/githubix/test.git
Initialized empty Git repository in /home/vagrant/local/app/test/test/test/.git/
remote: Enumerating objects: 45, done.
remote: Total 45 (delta 0), reused 0 (delta 0), pack-reused 45
Unpacking objects: 100% (45/45), done.
[vagrant@localhost test]$ ls
test

[vagrant@localhost test]$ git log origin/master
commit e4c42320159a32a377eb60249f9d5277f809c1bd
Author: githubix <@hotmail.com>
Date: Mon Jul 1 23:16:01 2019 +0900

Update test.php

commit 180cf3fcce48d905ede71a57ed0bd3973e1f90c8
Author: githubix <@hotmail.com>
Date: Mon Jan 28 08:45:42 2019 +0900

Update test.php

commit 812d49e3beb82bafe3699787ade3de5bf5d2f48f
Author: githubix <@hotmail.com>
Date: Fri Jan 25 09:09:15 2019 +0900

Update test.php

commit 5b3c59d4795b3a73e8723b35ffa58b2a6c262974

[vagrant@localhost test]$ git fetch –all
Fetching origin

なんか理解が足りんな。。

about waffle.io

What is waffle.io??
A tool that can visualize GitHub issues and pull requests as signs. By making the status of Issue and Pullrequest into a signboard, it becomes possible to grasp each progress on one screen.

https://waffle.io/${Github usename}/${Github repository name}

You can use Waffle simply by accessing in this way.

あれ、終わってね??

git diff

First of all, as a basic concept of git diff, the basic behavior of “git diff” is “display of changes made in the working tree”.

Then, if you do not specify the comparison source, you can specify “comparison source” as an argument, but by default, the difference when compared with “index” → ”working tree” with “index” as the comparison source and it will display.

[vagrant@localhost tests]$ git diff
diff –git a/sample.txt b/sample.txt
deleted file mode 100644
index 106287c..0000000
— a/sample.txt
+++ /dev/null
@@ -1 +0,0 @@
-Hello Git!
diff –git a/tests/test b/tests/test
— a/tests/test
+++ b/tests/test
@@ -1 +1 @@
-Subproject commit 180cf3fcce48d905ede71a57ed0bd3973e1f90c8
+Subproject commit 180cf3fcce48d905ede71a57ed0bd3973e1f90c8-dirty
[vagrant@localhost tests]$ git diff –name-only
sample.txt
tests/test

あれ?

[vagrant@localhost test]$ git diff –name-only
addfile.txt
[vagrant@localhost test]$

OK、理解した。

Roll back git remote repository

Those that pushed to the remote repository can not be rewound to the past state, or other members may start working. (It is possible to use supplementary git reset)
Roll back by executing the following command and pushing the processing opposite to the pushed contents.

git revert <commit id>
git revert bd912e1

When if it is merged, execute the command.

git revert-m 1 <commit_ID>
git revert-m 1 bd912e1

Create a folder with Github

Since GitHub had only file creation, I did not know how to create it.

But we will make folders from file creation.
follow circleci project step below.

Create a folder named .circleci and add a fileconfig.yml (so that the filepath be in .circleci/config.yml).

In this case, add “/” to the tail of text. Therefore, text should be “.circleci/” from “.crcileci”.

Then, automatically new folder has created.

Well done, let’s make sure not to create files trying to make folders.

.gitignoreとは

.gitignoreとは、リポジトリで、意図的に追跡対象から外したいファイルを設定するためのファイル。

例として、.gitignoreの中身を見てみましょう。
.envはもちろんの事、/node_modules、homestead.json|yml、/vendorなども含まれていますね。

/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
/.idea
/.vscode
/.vagrant
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.env
.phpunit.result.cache

git rm –cachedで追跡対象から外して、そのファイルを.gitignoreに加えればよいでしょう。

Git ソースツリー(source tree)とは

Git操作はコマンドラインではなかなか作業が見にくいのですが、Git ソースツリーでは、今誰が、どのファイルを、どのように編集しているかを視覚化して見えやすいようにすることができます。

細かい操作はコマンドの方が早い などのデメリットもあるようです。

Git tag(タグ)って何?

ねーねー、これGit Tagらしいよ。

あー知ってる、知ってる、Git tagね。(やべ、全く知らねー。。)

ということでGit tagを学びたいと思います。

まず、gitの公式を見ます。
Git タグ
公式ページの見出しを拾うと、色々な機能や種類があることがわかります。
タグの一覧表示、タグの作成、注釈付きのタグ、署名付きのタグ、軽量版のタグ、タグの検証、後からのタグ付け、タグの共有

まず、Githubのレポジトリにファイルを作成します。適当にtest.phpとしておきます。

vagrantにgit cloneします。

[vagrant@localhost test]$ git clone https://github.com/githubix/test.git
Initialized empty Git repository in /home/vagrant/local/test/test/.git/
remote: Enumerating objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 3
Unpacking objects: 100% (3/3), done.

1.git tagの一覧表示
コマンドラインでgit tagと打ちます。何も表示されません。タグはついていない状態です。

[vagrant@localhost test]$ git tag

git cloneしたファイルを適当に編集します。

echo "this is test<br>";
echo "addign git tag!";

2.git add .
[vagrant@localhost test]$ git add .

3.git commit -m “comment”
git commit します。
[vagrant@localhost test]$ git commit -m “tag commit”
[master a74bdba] tag commit
Committer: vagrant
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

git config –global user.name “Your Name”
git config –global user.email you@example.com

If the identity used for this commit is wrong, you can fix it with:

git commit –amend –author=’Your Name

1 files changed, 2 insertions(+), 1 deletions(-)

4.git tag -a でタグ作成
git tag -a tagname -m “comment”でタグを生成します。
[vagrant@localhost test]$ git tag -a gittag -m “first tag”

5.git tagでタグ一覧表示
タグが生成されていることがわかります。
[vagrant@localhost test]$ git tag
gittag

6.リポジトリへpush
git remote set-url origin hogehogeとしてから、git pushします。
[vagrant@localhost test]$ git remote set-url origin https://githubix@github.com/githubix/test.git
[vagrant@localhost test]$ git push -u origin master
Password:
Counting objects: 5, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 291 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://githubix@github.com/githubix/test.git
e44f89c..a74bdba master -> master
Branch master set up to track remote branch master from origin.

7.tag も git push
[vagrant@localhost test]$ git push origin gittag
Password:
Counting objects: 1, done.
Writing objects: 100% (1/1), 161 bytes, done.
Total 1 (delta 0), reused 0 (delta 0)
To https://githubix@github.com/githubix/test.git
* [new tag] gittag -> gittag

8.githubで確認
tagもpushされているのがわかります。

お疲れ様でしたー

git checkout

git initします。
[vagrant@localhost app]$ git init
Initialized empty Git repository in /home/vagrant/local/app/.git/

[vagrant@localhost app]$ vi sample.txt
[vagrant@localhost app]$ cat sample.txt
Hello Git!

[vagrant@localhost app]$ git add sample.txt
[vagrant@localhost app]$ git commit -m “git checkout”
[master (root-commit) c4b426e] git checkout
Committer: vagrant
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

git config –global user.name “Your Name”
git config –global user.email you@example.com

If the identity used for this commit is wrong, you can fix it with:

git commit –amend –author=’Your Name

1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 sample.txt

git branchを作成する。
[vagrant@localhost app]$ git branch branch1
[vagrant@localhost app]$ git branch branch2
[vagrant@localhost app]$ git branch
branch1
branch2
* master

[vagrant@localhost app]$ git checkout branch1
Switched to branch ‘branch1’
[vagrant@localhost app]$ git branch
* branch1
branch2
master
なるほど、checkoutはbranchの切り替えです。

[vagrant@localhost app]$ git checkout branch2
Switched to branch ‘branch2’
[vagrant@localhost app]$ cat sample.txt
Hello Git!

なるほど、なるほど。
最近なるほどが異常に増えた。