【Python】indexメソッド indexメソッドは、リストやタプルの中で、指定した要素が最初に現れる位置(インデックス)を返すメソッド。 サンプルコード python/index.py at main · ki-hi-ro/python some_list = [1, 2, 3, 4, 5] index = some_list.index(3) print(f"The index of 3 in the list is: {index}") some_tuple = (10, 20, 30, 40, 50) index = some_tuple.index(40) print(f"The index of 40 in the tuple is: {index}") 以下のコ… Python プログラミング学習
【git】プルリクエスト リモートリポジトリにmasterとmainブランチがある。 master branch is 1 commit ahead of, 2 commits behind main masterブランチがmainよりも1コミット進んでいて、2コミット遅れている。 Contribute > Open pull request これをクリックする。 プルリクエストを記入 mainよりも進んでいる1コミットがmainに統合される。 Create pull requestを押す コンフリクトは起こらなかった。 Mearge pull requestをクリック Confirm mergeをクリック。 マージ完了 Delete branchをクリック mainブランチだ… Git
【git】git remote show originをした時のRemote branchesにnew(next fetch will store in remotes/origin)があった git remote show originは、リモートリポジトリ(この場合は、origin)の詳細情報を確認するコマンド。 今回のgit remote show originの結果 hiroki@shibatahiroshitakanoMacBook-Air python % git remote show origin * remote origin Fetch URL: https://github.com/ki-hi-ro/python.git Push URL: https://github.com/ki-hi-ro/python.git HEAD branch: main Remote branches: main tracked mast… Git
【Git】リモートとローカルの履歴が分岐している場合の対処法3つ git pullできない場合に提示される以下の選択肢3つについて、ここに掲載していこう。 hiroki@shibatahiroshitakanoMacBook-Air ki-hi-ro.com % git pull origin main remote: Enumerating objects: 11, done. remote: Counting objects: 100% (11/11), done. remote: Compressing objects: 100% (3/3), done. remote: Total 7 (delta 5), reused 6 (delta 4), pack-reused 0 (from 0) Unpackin… Git
【Git】git stash git stashは、作業途中の変更を一時的に保存して、ワークツリーを綺麗な状態に戻すためのコマンド。 git stashの使用例 hiroki@shibatahiroshitakanoMacBook-Air ki-hi-ro.com % git stash Saved working directory and index state WIP on main: d9f2e53 タグ名 git stashの使用前後 使用前は、git pullができなかった。 hiroki@shibatahiroshitakanoMacBook-Air ki-hi-ro.com % git pull origin main error: cannot pull with… Git
【Git】git pushができない原因 この記事では、ローカルからリモートにgit pushができない原因を掲載していく。 non-fast-forward ローカルとリモートの状態。vue-js-1というコミットで分岐している。 ローカル リモート この状態でローカルからリモートにpushしようとすると、以下のメッセージが表示される。 hiroki@shibatahiroshitakanoiMac my-vue-js % git push origin main To https://github.com/ki-hi-ro/my-vue-js.git ! [rejected] main -> main (non-fast-forward) error: failed to p… Git
【Python】現在の座標をzipで更新する 二次元配列の座標空間で、現在地からある量だけ移動するというプログラムを作成した。 from pprint import pprint two_d_list = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] pprint(two_d_list, width=20) my_position = (2, 2) # (row, column) print(two_d_list[my_position[0]][my_position[1]]) move_direction = (0, -1) # (row_change, column_change) my_moved_po… Python
【Git】リモートのブランチをローカルから削除する方法 現状、リモートに不要なmasterブランチがある。 git branch -aで、ローカルとリモートのブランチが確認できる。 hiroki@shibatahiroshitakanoMacBook-Air python % git branch -a * main remotes/origin/main remotes/origin/master リモートのブランチをローカルから削除する方法 git push origin --delete masterで、リモートにある不要なmasterブランチを削除することができる。 リモート側でdefaultブランチとして設定されている場合 以下のエラーが起こる。 hiroki@shibatahiroshitaka… Git
【Git】ローカルブランチとリモートブランチの対応関係を正しく整えるためのコマンド git branch --set-upstream-to=origin/main main について解説していこう。 git branch --set-upstream-to=origin/main mainとは ローカルのmainブランチが、リモートのorigin/mainブランチを追跡するように設定するという意味。 git branch --set-upstream-to=<リモート名>/<リモートブランチ> <ローカルブランチ> 現状 現状、以下のようになっている。 hiroki@shibatahiroshitakanoiMac ki-hi-ro.com-2022 % git remote show origi… Git
【Git】ローカルの不要ブランチを削除する方法 現状、iMacのこのブログのWordPressテーマのディレクトリのフォルダには、mainとshowのブランチがある。 showブランチは不要なので、削除したい。 git branch -d <ブランチ名> git branch -d <ブランチ名>で、ブランチを削除することができる。 git branch -d showで、showブランチを削除することができた。 Git