クローンからブランチ作成まで勉強させてもらった。
参考URL
クローン
- git clone (URL.git)
nari@nariUbun18:~/Desktop$ git clone http://nawhlinux.intra.gavann-it.com:10080/naritomi/memos.git
Cloning into 'memos'...
remote: Enumerating objects: 1258, done.
remote: Counting objects: 100% (1258/1258), done.
remote: Compressing objects: 100% (939/939), done.
remote: Total 1258 (delta 269), reused 1256 (delta 268)
Receiving objects: 100% (1258/1258), 814.57 MiB | 20.89 MiB/s, done.
Resolving deltas: 100% (269/269), done.
Checking out files: 100% (1092/1092), done.
nari@nariUbun18:~/Desktop$ ls
memos
nari@nariUbun18:~/Desktop$ cd memos/
nari@nariUbun18:~/Desktop/memos$ ls
01_URL_ショートカット集 09_linuxノウハウ 16_KVMノウハウ 23_git
02_windowsノウハウ 10_VBAノウハウ 17_xamppノウハウ 24_AWS
03_dotnetノウハウ 11_電話ノウハウ 18_oracleノウハウ 25_GoogleCloud
05_vmwareノウハウ 12_LANノウハウ 19_c 26_docker
06_奉行ノウハウ 13_全銀手順 20_routerノウハウ README.md
07_hyperV-VirtualPCノウハウ 14_メール 21_teratadaノウハウ
08_terastationノウハウ 15_MySQLノウハウ 22_SQLノウハウ
nari@nariUbun18:~/Desktop/memos$
ブランチ一覧確認とブランチ切り替え
- git branch -a
- git checkout -b (branch name))
nari@nariUbun18:~/Desktop/memos$ git branch -a
* master
remotes/origin/20190923
remotes/origin/2nd
remotes/origin/HEAD -> origin/master
remotes/origin/master
nari@nariUbun18:~/Desktop/memos$ git checkout -b 20190926
Switched to a new branch '20190926'
nari@nariUbun18:~/Desktop/memos$ git branch -a
* 20190926
master
remotes/origin/20190923
remotes/origin/2nd
remotes/origin/HEAD -> origin/master
remotes/origin/master
nari@nariUbun18:~/Desktop/memos$
gitログの確認
- git log –oneline
nari@nariUbun18:~/Desktop/memos/23_git/gitCommand$ git log --oneline
316450c (origin/master, origin/HEAD, master) Merge branch '20190923' into 'master'
c401f18 (origin/20190923) 1)ノウハウを追加
a4c6680 (origin/2nd) 追記してコミット
35ff8ff Ubuntu setup1
c553dc1 Add README.md
nari@nariUbun18:~/Desktop/memos/23_git/gitCommand$
ファイル/フォルダを追加
- git add (folder or filename))
nari@nariUbun18:~/Desktop/memos$ cd 23_git/
nari@nariUbun18:~/Desktop/memos/23_git$ ls -l
合計 6556
drwxr-xr-x 3 nari nari 4096 9月 26 04:35 git
-rw-r--r-- 1 nari nari 6704532 9月 26 04:35 git.zip
drwxrwxr-x 2 nari nari 4096 9月 26 04:50 gitCommand
nari@nariUbun18:~/Desktop/memos/23_git$
nari@nariUbun18:~/Desktop/memos/23_git$ git add gitCommand
nari@nariUbun18:~/Desktop/memos/23_git$
ファイル/フォルダを削除
- git rm (folder or filename)
ブランチをコミット
- git commit -a -m “任意のコメント”
nari@nariUbun18:~/Desktop/memos/23_git/gitCommand$ git commit -a -m "gitコマンドの追記"
[20190926 afd002e] gitコマンドの追記
1 file changed, 73 insertions(+)
create mode 100644 23_git/gitCommand/gitCommand.txt
nari@nariUbun18:~/Desktop/memos/23_git/gitCommand$
コミットのコメントを修正
- git commit –amend -m “任意のコメント”
nari@nariUbun18:~/Desktop/memos/23_git/gitCommand$ git commit --amend -m "GITコマンドの追記"
[20190926 505c6b3] GITコマンドの追記
Date: Thu Sep 26 05:06:13 2019 +0900
1 file changed, 73 insertions(+)
create mode 100644 23_git/gitCommand/gitCommand.txt
nari@nariUbun18:~/Desktop/memos/23_git/gitCommand$ git log --oneline
505c6b3 (HEAD -> 20190926) GITコマンドの追記
316450c (origin/master, origin/HEAD, master) Merge branch '20190923' into 'master'
c401f18 (origin/20190923) 1)ノウハウを追加
a4c6680 (origin/2nd) 追記してコミット
35ff8ff Ubuntu setup1
c553dc1 Add README.md
nari@nariUbun18:~/Desktop/memos/23_git/gitCommand$
コミットのコメント複数行を修正
- git commit –amend
※専用エディタが起動する
変更内容を確認
- git diff commit1 commit2
ブランチをサーバに登録
- git push origin (branch name)
nari@nariUbun18:~/Desktop/memos$ git log --oneline
505c6b3 (HEAD -> 20190926) GITコマンドの追記
316450c (origin/master, origin/HEAD, master) Merge branch '20190923' into 'master'
c401f18 (origin/20190923) 1)ノウハウを追加
a4c6680 (origin/2nd) 追記してコミット
35ff8ff Ubuntu setup1
c553dc1 Add README.md
nari@nariUbun18:~/Desktop/memos$ git push origin 20190926
Username for 'http://nawhlinux.intra.gavann-it.com:10080': naritomi
Password for 'http://naritomi@nawhlinux.intra.gavann-it.com:10080':
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 1.48 KiB | 1.48 MiB/s, done.
Total 5 (delta 1), reused 0 (delta 0)
remote:
remote: To create a merge request for 20190926, visit:
remote: http://svgitlab/naritomi/memos/merge_requests/new?merge_request%5Bsource_branch%5D=20190926
remote:
To http://nawhlinux.intra.gavann-it.com:10080/naritomi/memos.git
* [new branch] 20190926 -> 20190926
nari@nariUbun18:~/Desktop/memos$
サーバに登録したブランチを削除した後、再度コミットしてからサーバに登録
git reset --soft HEAD^
git add .
git commit --amend -m "任意のコメント"
git push origin (branch name)
nari@nariUbun18:~/Desktop/memos$ git reset --soft HEAD^
nari@nariUbun18:~/Desktop/memos$ git log --oneline
316450c (HEAD -> 20190926, origin/master, origin/HEAD, master) Merge branch '20190923' into 'master'
c401f18 (origin/20190923) 1)ノウハウを追加
a4c6680 (origin/2nd) 追記してコミット
35ff8ff Ubuntu setup1
c553dc1 Add README.md
nari@nariUbun18:~/Desktop/memos$ git add .
nari@nariUbun18:~/Desktop/memos$ git commit --amend -m "■ GITコマンドの追記"
[20190926 bac97c1] ■ GITコマンドの追記
Author: naritomi <naritomi@gavann-it.com>
Date: Sun Sep 22 22:03:34 2019 +0000
nari@nariUbun18:~/Desktop/memos$ git push origin 20190926
Username for 'http://nawhlinux.intra.gavann-it.com:10080': naritomi
Password for 'http://naritomi@nawhlinux.intra.gavann-it.com:10080':
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 2.17 KiB | 2.17 MiB/s, done.
Total 5 (delta 1), reused 0 (delta 0)
remote:
remote: To create a merge request for 20190926, visit:
remote: http://svgitlab/naritomi/memos/merge_requests/new?merge_request%5Bsource_branch%5D=20190926
remote:
To http://nawhlinux.intra.gavann-it.com:10080/naritomi/memos.git
* [new branch] 20190926 -> 20190926
nari@nariUbun18:~/Desktop/memos$ git log --oneline
bac97c1 (HEAD -> 20190926, origin/20190926) ■ GITコマンドの追記
c401f18 (origin/20190923) 1)ノウハウを追加
a4c6680 (origin/2nd) 追記してコミット
35ff8ff Ubuntu setup1
c553dc1 Add README.md
nari@nariUbun18:~/Desktop/memos$
全ブランチを取得
git fetch
for branch_name in `git branch -r | grep -v mster` ; do
git checkout -t $branch_name
done
最新タグの取得
git ls-remote --tags http://xxx/yyy.git | cut -d / -f3 | sort -r --version-sort | head -1
リモートのタグを削除して反映
- git tag -d TAGNAME
- git push –delete origin TAGNAME
ローカルのタグをリモートへ反映
- git push origin –tags
コンテナ稼働のgitlabを作り直したときのurl確認と変更
- git remote -v
- git remote set-url origin (url.git)
nari@clubu24:/gvis/download/gvis$ git remote -v
origin http://51aaa35cfbc7/naritomitsukasa/gvis-doc2024.git (fetch)
origin http://51aaa35cfbc7/naritomitsukasa/gvis-doc2024.git (push)
nari@clubu24:/gvis/download/gvis$ git remote set-url origin http://1dbd050f9740/naritomitsukasa/gvis-doc2024.git
nari@clubu24:/gvis/download/gvis$ git remote -v
origin http://1dbd050f9740/naritomitsukasa/gvis-doc2024.git (fetch)
origin http://1dbd050f9740/naritomitsukasa/gvis-doc2024.git (push)
nari@clubu24:/gvis/download/gvis$