20191124のGitに関する記事は4件です。

よく使うMarkdown記法

Markdownとは

markdownはqiitaの記事作成やgithubのREADMEファイルなどの文章の書き方です。
手軽に文章構造を明示できるので様々なオンラインプラットフォームで採用されています。
よく使われるMarkdownの記法を紹介します。

見出し

書き方

# 見出しh1
## 見出し h2
### 見出し h3
#### 見出し h4
##### 見出し h5
###### 見出し h6

実装後

見出しh1

見出し h2

見出し h3

見出し h4

見出し h5
見出し h6

強調

書き方

** テキスト **

実装後

テキスト

番号付きリスト

書き方

1. テキスト
2. テキスト
3. テキスト
  1. テキスト
  2. テキスト
  3. テキスト

リスト

書き方

* テキスト
* テキスト
* テキスト

実装後

  • テキスト
  • テキスト
  • テキスト

インライン表示

書き方

`ソースコード`
`var text = "hello"`

実装後

ソースコード
var text = "hello"

コードの追加

書き方
rubyとしている箇所は言語なので、phpで表記したい場合はphpにしてください

```ruby:title

puts "hello"
```

実装後

title
puts "hello"

リンクの書き方

書き方

[タイトル](URL)

[youtube](https://www.youtube.com/)

実装後
youtube

画像の追加

書き方

![desktop-1985856_1280.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/528825/c4e55ebc-2345-0de3-5e81-a6c785911dc5.jpeg)

実装後
desktop-1985856_1280.jpg

  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

gitのローカルで行ったファイル削除をリモートに反映させる

ローカルで不要なファイルを削除したが,すでにリモートへpushしてしまっていて,削除したことがうまく反映されないときの解決方法.

やること

git add -u # update option
git commit -m "deleted some files"
git push

コマンドの意味

git-addの公式ドキュメントを見ると,

-u
--update
Update the index just where it already has an entry matching . This removes as well as modifies index entries to match the working tree, but adds no new files.
If no <pathspec> is given when -u option is used, all tracked files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).__

とあり,太字にした箇所のように「インデックスのエントリをワーキングツリーに削除/同期する」とあるので,この機能を使ったことになるのだと思われ...
git rm [filename]でもできるそうだが,これは指定したファイルをgit管理下から外すという操作なので,複数ファイルを扱いたい場合には少し面倒.

参考

ほぼこのページの丸パクリです.
http://core.hatenablog.jp/entry/2013/08/09/134511

  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

ssh: connect to host github.com port 22: Operation timed out

SSH接続エラー?

普段からGitHubにアクセスしているMacでコードをアップしようとすると、22番ポートでSSH接続できないとのエラーがでたので対処していく。

$ git push -u origin HEAD
ssh: connect to host github.com port 22: Operation timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

結論

443番ポートでアクセスする設定で接続することで、接続に成功した。22番ポートで接続できなくなった理由は不明のまま。

$ vi ~/.ssh/config
Host github.com
    User git
    Hostname ssh.github.com
    Port 443
    IdentityFile ~/.ssh/id_rsa
$ git push -u origin HEAD
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 1.45 KiB | 1.45 MiB/s, done.
Total 5 (delta 0), reused 0 (delta 0)
To github.com:toppy-luna/TodoList-Vuejs.git
 * [new branch]      HEAD -> issue#1_regist_code
Branch issue#1_regist_code set up to track remote branch issue#1_regist_code from origin.

参考

Githubにport:22 で push できなかった場合の対処法
https://qiita.com/SOJO/items/74b16221580a17296226

  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

一括Tagを消す

git tag -l '1.0.*' | xargs -I % echo "git tag -d %; git push --delete origin %" | sh

下記のようなTagを削除します。

1.0.4
1.0.5
1.0.6
1.0.7
1.0.8
1.0.9
git tag -l '1.0.2*' | xargs -I % echo "git tag -d %; git push --delete origin %" | sh

下記のようなTagを削除します。

1.0.20
1.0.21
1.0.22
1.0.23
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む