【githubエラー集合】githubブランチ問題
4251 ワード
githubの一般的なエラーの要約
ブランチ競合の問題
ブランチ競合の問題
エラー:fatal: Not a valid object name: 'master'.
エラーの原因:倉庫を作成する時、masterのメインブランチはファイルREDMEが存在する.mdファイルgit pushローカルファイルが競合する
klaus@klausMINGW 64/d/CODE/Github/day 1/2回目の提出テスト(master)$ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
$ git push --set-upstream origin master
To https://github.com/klauscf/-git.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/klauscf/-git.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解決策:
1.ローカルファイルをローカルウェアハウスキャッシュにaddし、commintをローカルウェアハウスに追加します。
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add ..." to include in what will be committed)
ME
Main/
README.md
hh.c
nothing added to commit but untracked files present (use "git add" to track)
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
$ git add *
warning: LF will be replaced by CRLF in ME.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached ..." to unstage)
new file: ME
new file: Main/main.c
new file: README.md
new file: hh.c
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
$ git commit -m ' '
[master (root-commit) 7081a85]
4 files changed, 2 insertions(+)
create mode 100644 ME
create mode 100644 Main/main.c
create mode 100644 README.md
create mode 100644 hh.c
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
Pushファイル、フォルダが一致しない、gitエラーklaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
$ git push --set-upstream origin master
To https://github.com/klauscf/-git.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/klauscf/-git.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
2.他のブランチを新規作成し、他のブランチに切り替える
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
$ git checkout -b dev
Switched to a new branch 'dev'
klaus@klaus MINGW64 /d/CODE/Github/day1/ (dev)
$ git push
fatal: The current branch dev has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin dev
klaus@klaus MINGW64 /d/CODE/Github/day1/ (dev)
$ git push -u origin dev
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (5/5), 358 bytes | 119.00 KiB/s, done.
Total 5 (delta 0), reused 0 (delta 0)
remote:
remote: Create a pull request for 'dev' on GitHub by visiting:
remote: https://github.com/klauscf/-git/pull/new/dev
remote:
To https://github.com/klauscf/-git.git
* [new branch] dev -> dev
Branch 'dev' set up to track remote branch 'dev' from 'origin'.
ブランチの作成に成功し、ファイルはdevブランチにアップロードされました.
fatal: Not a valid object name: 'master'.
$ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
$ git push --set-upstream origin master
To https://github.com/klauscf/-git.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/klauscf/-git.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add ..." to include in what will be committed)
ME
Main/
README.md
hh.c
nothing added to commit but untracked files present (use "git add" to track)
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
$ git add *
warning: LF will be replaced by CRLF in ME.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached ..." to unstage)
new file: ME
new file: Main/main.c
new file: README.md
new file: hh.c
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
$ git commit -m ' '
[master (root-commit) 7081a85]
4 files changed, 2 insertions(+)
create mode 100644 ME
create mode 100644 Main/main.c
create mode 100644 README.md
create mode 100644 hh.c
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
$ git push --set-upstream origin master
To https://github.com/klauscf/-git.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/klauscf/-git.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
klaus@klaus MINGW64 /d/CODE/Github/day1/ (master)
$ git checkout -b dev
Switched to a new branch 'dev'
klaus@klaus MINGW64 /d/CODE/Github/day1/ (dev)
$ git push
fatal: The current branch dev has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin dev
klaus@klaus MINGW64 /d/CODE/Github/day1/ (dev)
$ git push -u origin dev
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (5/5), 358 bytes | 119.00 KiB/s, done.
Total 5 (delta 0), reused 0 (delta 0)
remote:
remote: Create a pull request for 'dev' on GitHub by visiting:
remote: https://github.com/klauscf/-git/pull/new/dev
remote:
To https://github.com/klauscf/-git.git
* [new branch] dev -> dev
Branch 'dev' set up to track remote branch 'dev' from 'origin'.