2022/04/04

WSLインストール

WSLインストール

# WSL設定
## 場所
C:\Users\ユーザー名\.wslconfig
## 内容
[wsl2]
memory=10GB
processors=5
swap=5GB


# コマンドプロンプト
## インストール可能OS一覧
wsl --list --online
## インストール
wsl --install OS名
## アップグレード
wsl --update
## 再起動
wsl --shutdown
## バージョン確認
wsl --list --verbose
## アンインストール
wsl --unregister OS名


# WSL内
## 日本語化
sudo apt-get install -y language-pack-ja-base
sudo apt-get install -y language-pack-ja
sudo apt-get install -y ibus-kkc
sudo update-locale LANG=ja_JP.UTF8
exit


# 注意点
serviceは使えるが、systemctlは使えない

git操作

git操作

# git初期設定
sudo apt-get install -y git
ssh-keygen -t rsa -b 4096
>パスワード
ssh -T git@github.com

git config --global user.email "メールアドレス"
git config --global user.name "名前"


# GoogleSourceRepositories運用
## 初回
gcloud init
gcloud source repos clone レポジトリ名 --project=プロジェクトID
cd レポジトリ名


# GitHub運用
## 初回
git clone git@github.com:レポジトリ名.git
cd レポジトリ名
## 毎回
git switch master
git pull
git switch dev/開発ブランチ名
## 開発ブランチ作成
git switch --create dev/開発ブランチ名
git switch -c dev/開発ブランチ名
## 開発ブランチ参加
git switch --create dev/開発ブランチ名 origin/dev/開発ブランチ名
git switch -c dev/開発ブランチ名 origin/dev/開発ブランチ名
## add,update,fix
git add ファイル名
git commit --message "[コミット種別] バックログ番号 変更内容"
git push origin dev/開発ブランチ名

git add -A
git commit -m "[コミット種別] バックログ番号 変更内容"
git push origin dev/開発ブランチ名
## remove
git rm ファイル名
git commit --message "[remove] バックログ番号 変更内容"
git push origin dev/開発ブランチ名


# TIPS
## 状態確認
git status

## レポジトリ内の全ての変更を一括追加する
git add --all
git add -A
## レポジトリ内の全ての変更を一括追加する(新規追加ファイルは対象外)
git add --update
git add -u
## ディレクトリ内の全ての変更を一括追加する
git add .

## git add前のファイルの変更を戻す
git restore ファイル名
## git add後のファイルの変更を戻す
git restore --staged ファイル名
git restore -S ファイル名

## コミット番号を確認する
git log --oneline
git log --graph

## ファイルをコミット番号の状態にする
git restore --source コミット番号 ファイル名
git restore -s コミット番号 ファイル名
## ディレクトリ内をコミット番号の状態にする
git restore --source コミット番号 .
git restore -s コミット番号 .

## masterブランチにコミットしてしまった
git rebase 1個前のコミット番号
git switch --create dev/開発ブランチ名
git cherry-pick 該当コミット番号
git push origin dev/開発ブランチ名

## ローカルブランチ一覧
git branch
## リモートブランチ一覧
git branch --remotes
git branch -r
## ブランチ一覧
git branch --all
git branch -a

## マージ済みブランチの削除
git branch --delete dev/開発ブランチ名
git branch -d dev/開発ブランチ名
## マージされていないブランチの削除
git branch --delete --force dev/開発ブランチ名
git branch -D dev/開発ブランチ名

ワイルドカード

 ワイルドカード

*
任意の0文字以上の文字列

?
任意の1文字

[a-z]
英字の1文字

[0-9]
数字の1文字

[a,b,c]
「a,b,c」のどれか1文字

[^a-z]
英字以外の1文字

[^0-9]
数字以外の1文字

[^a,b,c]
「a,b,c」以外のどれか1文字

{abc,def,ghi}
「abc,def,ghi」のうちのどれか

.
カレントディレクトリ

./hoge
カレントディレクトリのhoge

find操作

find操作

# ディレクトリ内をワイルドカードを利用したファイル名で検索
find ディレクトリ名 -name ファイル名

# ディレクトリ内の日数にアクセスされたファイルを検索
find ディレクトリ名 -atime 日数

# ディレクトリ内の日数以内にアクセスされたファイルを検索
find ディレクトリ名 -atime -日数

# ディレクトリ内の日数以降にアクセスされたファイルを検索
find ディレクトリ名 -atime +日数

# ディレクトリ内の日数に更新されたファイルを検索
find ディレクトリ名 -mtime 日数

# ディレクトリ内の日数以内に更新されたファイルを検索
find ディレクトリ名 -mtime -日数

# ディレクトリ内の日数以降に更新されたファイルを検索
find ディレクトリ名 -mtime +日数