LoginSignup
0
0

More than 3 years have passed since last update.

git 初心者書置き

Last updated at Posted at 2020-03-28

最初のリポジトリ連携

gitとは俗にいうバージョン管理ツール
よく使われているgithubを使用

branchを作成後ローカルで作業する場合
windowsユーザーはまずgit for windowsが必要な
為downloadする

終わったら コマンドで初期設定をやる

git config --global user.name 'yourname'
git config --global user.email 'yourname@example.com'

vscodeでソース管理で連携させたら
初回コミットは宛先が必要なため

git remote add origin https://github.com/yourname/gitpath.git

をしておくこと。
github上でclone or downloadってボタン押したらURLあるので
gitpath.gitの部分をそこに入れてね

次に初回push等をする際宛先聞かれるので

git push --set-upstream origin branch-name

とします。

これでpushして無事ローカルで作業できるはず。

コマンド

便宜上
リモートリポジトリ→remote
ローカルリポジトリ→local

cmd

コマンド 内容
clone remoteをマウント
remote -v remote確認
branch localブランチ作成
push local→remote
pull remote→local
stash local変更退避

よく使う流れ

branchにmaster情報反映

最新情報取得

git pull origin master

branch切り替えて

git rebase master

localのcommit取消

該当commitのIDを確認して

git log

ID指定して削除

git reset --hard <commitId>

local branch 削除

参照

困った時

failed to push some refs to

rebertして整合性がおかしくなってpushできない時

error: failed to push some refs to  'リポジトリパス'

こんなエラーが出たら

git push origin :<branch name>

で解決
ただしlocalが正のときに限る

rebase-apply

なんかrebase出来ない

It seems that there is already a rebase-apply directory, and
I wonder if you are in the middle of another rebase.  If that is the
case, please try
        git rebase (--continue | --abort | --skip)
If that is not the case, please
        rm -fr "hoge/fuga/rebase-apply"
and run me again.  I am stopping in case you still have something
valuable there.

要するに「rebase-apply」ってfolderあるから出来ねーよ
って言われているので該当フォルダを消して再度通すと出来ます。
たぶん処理中にハングアウトしたとかそーゆーので残ると起こり得る

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