LoginSignup
0
0

More than 1 year has passed since last update.

【ノート】git

Last updated at Posted at 2022-04-06

ファイルの出入り

$ git init
$ git add .
$ git commit -m "first commit"
$ git status

git remote add origin 【リモリポURL】

$ git remote origin
$ git push origin 【ブランチ名】
// check remote repository URL
$ git config --get remote.origin.url

チェック

$ ssh -T git@github.com
$ git remote -v
// 変更有無の確認
$ git status -sb

修正

直前のコミットを取り消す

$ git reset --soft HEAD^

リモートリポジトリURL書換

$ git remote set-url origin [新しいリモートリポジトリURL]
git branch -m <古いブランチ名> <新しいブランチ名>

ブランチ名の変更

git branch -m <古いブランチ名> <新しいブランチ名>

ブランチ

// check all branches
$ git branch
// make sample1 branch
$ git branch sample1
// enter sample1 branch
$ git checkout sample1
// branch
https://kakakakakku.hatenablog.com/entry/2020/04/08/151627

問題解決

error : failed to pushsome refs to 'リモリポURL'

→ リモートの最新情報と異なる
→ $ git merge origin main
→ error : refusing to merge unrelated history
→ 同じ元(根、祖先)を持っていないブランチ同士はマージ付加
→ git merge --allow-unrelated-histories origin/main

プッシュした後、コードいじってやっぱその段階に戻したい

$ git status -sb
#dev
M app.rb
$ git restore .
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0