ラベル git の投稿を表示しています。 すべての投稿を表示
ラベル git の投稿を表示しています。 すべての投稿を表示

2020年8月16日日曜日

git特定のコミットのファイル一覧を表示するコマンド

 「git show コミット番号」で全ての差分を表示することができます。

ただ、差分ではなく、ファイル一覧のみを表示したい時があります。

以下のコマンドを使えば、コミット内の全てのファイルをリストアップすることができます。

git diff-tree --no-commit-id --name-only -r [コミット番号]
例:
git diff-tree --no-commit-id --name-only -r 1e3698d5fee9d3cdce68b6a708ba54efc47513d3

2019年11月13日水曜日

2019年9月19日木曜日

gitのエラー「fatal: refusing to merge unrelated histories」の解消方法

 git push -u origin masterでソースコードをリモートにpushしようとしたら、以下のエラーがおきました。

$ git push -u origin master
To https://git.xxxx.com/test/xxx.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://git.xxxx.com/test/xxx.git'
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.

どうや先にpullしないとだめみたいです。$ git pull origin masterでpullをしたら、今度またエラーがおきました。
fatal: refusing to merge unrelated histories
解決方法は、オプション--allow-unrelated-historiesを追加することです。

以下で無事に解決できました。
$ git pull origin master --allow-unrelated-histories
From https://git.xxxx.com/test/xxx.git
 * branch            master     -> FETCH_HEAD
Merge made by the 'recursive' strategy.
 README.md | 2 ++

 1 file changed, 2 insertions(+)

2018年8月30日木曜日

gitリモートブランチチェックアウトする方法

以下のコマンドを使えば、リモートにある「remote_branch_name」というブランチをローカル「local_branch_name」としてチェックアウトできます。
git checkout -b local_branch_name origin/remote_branch_name

2018年3月27日火曜日

git特定なフォルダにcloneする

特定なディレクターcloneするコマンドは以下の通りです。

git clone git@github.com:whatever folder-name

2017年8月24日木曜日

git hubにpush時にユーザー名を求められましたら

git hubにコミットしようとしてら、以下のようなユーザー入力を求められました。

$ git push -u origin master
Username for 'https://github.com':

git config でuser.nameを入れても、問題が解消されません。

最後、プロジェクトパス/.git/configファイルのurlを無理やり直したら、解消できました。
具体的に、
urlにユーザー名を入れる。例:
https://github.com/TEST/project-test.git


https://*yourname*@github.com/TEST/project-test.git

2017年5月23日火曜日

gitの.gitignore突然効かなくなりました。

今日突然gitの.gitignore効かなくなりました。
色々試しましたけどうまくスルーしてくれなかった。。。
解決方法をメモしておきます。


git rm -r --cached .
git add .
git commit -m "fixed untracked files"

2015年12月15日火曜日

git間違ったコミットをなかったことにするには?

gitでリモートに間違ったコミットをなかったことにする方法は?

例えば、branch名はmasterとします。

以下のコマンドを実行すれば、リモートのコミット履歴は綺麗に消えます。
※注意してほしいのは、その操作を実行する前に、念のため、masterブランチをバックアップしておくといいでしょうか。(簡単にgit branch master_bkを実行すれば、バックアップ用ブランチを作成できます)

 git reset --hard <commit-hash>
 git push -f origin master

2015年9月28日月曜日

git HTTPSリポジトリのユーザー名とパスワードを保存する方法

gitでHTTPSのリポジトリにアクセスする度に、ユーザー名とパスワードが毎回聞かれます
そこで、パスワードを保存すれば、次回から聞かれなくなります。

git config credential.helper store
bower update xxx-frontend

2015年5月4日月曜日

git 特定のユーザーのコミットログを表示

git how can view a git log of just one user's commits

git log --committer=[ユーザ名]
もしくは

git log --author=[ユーザ名]