| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

差分

ナビゲーションに移動 検索に移動
3,954 バイト追加 、 2023年1月29日 (日) 02:56
==GUI==
===gitk===
----
*[http://futurismo.biz/archives/824 Cygwinでgitkが使えないときの対策メモ]
*gitk はグラフィカルな履歴ビューア。 git log や git grep をパワフルなGUIシェルから使えるようにしたようなもの。 過去に何が起こったかを検索したり、プロジェクトの歴史を視覚化しようとしているときに使う。
[[File:0552_gitk.jpg]]
===git-gui===
----
*git-gui は主にコミットを作成するためのツール
*左側はインデックスです。ステージされていない変更が上に、ステージされた変更が下に表示
$ git gui
[[File:0551_git_gui.jpg]]
 
===GitKraken===
----
*[https://www.gitkraken.com/ GitKraken]
 
===Github Desktop===
----
*[https://desktop.github.com/ Github Desktop]
 
===Sourcetree===
----
*[https://www.atlassian.com/ja/software/sourcetree Sourcetree]
 
==プロジェクトの作成==
===プロジェクトコードが保存される3つの場所===
$git status
====差分の確認 (diff) ====
----
*https://qiita.com/shibukk/items/8c9362a5bd399b9c56be
=====作業ツリーの変更を表示=====
----
*パラメータなし
$git diff
=====ステージングとリポジトリとの差分表示=====
----
$git diff --cached
=====ステージング含め作業ツリーのすべてをリポジトリと比較=====
----
$git diff HEAD
<blockquote>HEADは現在作業しているブランチの直前のコミットを表すキーワード</blockquote>
 
====コミット同士====
----
<pre>
$ git diff 変更前SHA..変更後SHA
</pre>
===コミットログの確認 (log)===
*特定の時点
$ git reset --hard 昔のコミットのハッシュ値
<blockquote>
*リモートにpush済みの場合、再度pushするとエラーになる
<pre>
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
</pre>
*無理矢理pushするには、-f とする
<pre>
$ git push -f origin master
</pre>
</blockquote>
 
 
=====resetの後最新の状態に戻す=====
* master
</pre>
*リモートのブランチ一覧
<pre>
$ git branch -r
origin/HEAD -> origin/master
origin/fix_chart
origin/master
</pre>
 
===ブランチを作る (branch)===
----
*masterブランチを元にRB_1.0ブランチを作成する
*masterブランチは、Subversionにおけるtrunkにあたる
</blockquote>
===作業途中のブランチを切り替える(stash)===
[https://qiita.com/chihiro/items/f373873d5c2dfbd03250 【git stash】コミットはせずに変更を退避したいとき]
「とあるブランチで作業中だけど、いますぐやりたいことができた。作業がすごく中途半端だからコミットはしたくない。」
というときに、stashが使えます。
stashを使用すると、コミットしていない変更を退避することができます。
stashで現在の変更を退避して、今すぐやりたい作業をして、退避させていた変更を戻して作業を再開することができます。
 
*未コミットの状態だと、checkoutでブランチを切り替えられない
*git stash を利用することで、作業状態を保存し、ブランチを切り替えられる
Your branch is up to date with 'origin/master'.
$ git merge directlink
</pre>
 
===コンフリクトを解消===
----
*以下のようなコンフリクトが発生した場合
<pre>
Auto-merging lib/photo_list_screen.dart
CONFLICT (content): Merge conflict in lib/photo_list_screen.dart
Automatic merge failed; fix conflicts and then commit the result.
</pre>
*「自動マージに失敗しました。コンフリクトを修正してから結果をコミットしてください。」
*git status で対象を確認
<pre>
$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 1 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
 
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
:
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: lib/photo_list_screen.dart
both modified: pubspec.lock
</pre>
*==== より上の部分が、HEADが参照しているブランチの内容
*==== より下の部分が、変更内容
*どちらかを採用するなどした後、git add , git commit
<pre>
<<<<<<< HEAD
.collection('users/${user.uid}/photos')
.doc()
.set(data);
=======
.collection('users/${user.uid}/photos')
.doc()
.set(data);
 
HttpsCallable callable = FirebaseFunctions.instance.httpsCallable('ocr',
options: HttpsCallableOptions(timeout: const Duration(seconds:30)));
 
var res = await callable.call(
{'gsUrl':'gs://tenarai-online.appspot.com/users/${user.uid}/photos/$path'});
//gs://tenarai-online.appspot.com/users/m8dAoyu7s3UJUNQwI1F8E3NcMO72/photos/1628325188064403_IMG_20210807_173119.jpg
await showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('Response'),
content: Text(res.data.toString()),
);
},
);
>>>>>>> 090b91525ddb715a39803757bd7617eeb0e8029a
</pre>
$ git push origin master
===未 push コミットの確認===
*git log (リポジトリ名)/(リモートのブランチ名)..(ローカルのブランチ名)
*存在しなければ何も出力されない
<pre>
$ git log origin/master..master
</pre>
===rebase:ブランチから変更を取り出し別ブランチの先頭で再生 (rebase)===
$ git pull origin master
==[[Tips]]==
===日本語ファイル名日本語ファイル名を表示させる(文字化け対応)===
*日本語ファイル名は "\nnn" にエスケープされてしまって読めない。以下の設定を追加することで日本語ファイル名が表示されるようになる。
$ git config --global core.quotepath false
===[[Git]]でやらかしたときに使えるコマンド===
*https://qiita.com/muran001/items/dea2bbbaea1260098051
 
==Workflow==
*拾いもの
 
[[File:Git workflow.jpeg]]

案内メニュー