2017-10-22 7 views
1

私はコードに新しく、GitHubのレポにテキストファイルをプッシュしようとしていましたが、同じエラーが発生しています。git pushの使用に問題があります

私はGitのプッシュを使用すると、私は次のエラーを取得する:

$ 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 

それから私はGitのプッシュ--set-上流の原点マスターをして、この応答を取得:

$ git push --set-upstream origin master 
    To https://github.com/KMagrane/test-repo.git 
    ! [rejected]  master -> master (non-fast-forward) 
    error: failed to push some refs to 'https://github.com/KMagrane/test- 
    repo.git' 
    hint: Updates were rejected because the tip of your current branch is 
    behind 
    hint: its remote counterpart. Integrate the remote changes (e.g. 
    hint: 'git pull ...') before pushing again. 
    hint: See the 'Note about fast-forwards' in 'git push --help' for 
    details. 

だから私はgitのを試してみましたこの応答を得る:

$ git pull origin master 
    From https://github.com/KMagrane/test-repo 
    * branch   master  -> FETCH_HEAD 
    fatal: refusing to merge unrelated histories 

私はそれ以外のファイルをプッシュしようとするのか分からないo私のレポ。どんな助けでも大歓迎です!

+0

あなたの現在の 'master'ブランチはどうでしたか?リモートリポジトリをクローンしましたか? –

+0

私はリモートリポジトリをクローンしました – KMagrane

+0

あなたのエラーは、Gitがリモートリポジトリをあなたのローカルリポジトリと関係があると認識しないことを意味します。これを保存する方法があるかもしれませんが、私はもう一度クローンを作成するかもしれません。 –

答えて

1

あなたは、リモートのmasterブランチまたはそのリポジトリとは関係のないローカルリポジトリに取り組んでいると思います。 、そして、

git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY 

master枝チェックアウト:むしろ、あなたの現在の設定を救済しようとするよりも、私はどこかに新しいフォルダにあなたのリモートリポジトリをクローン推薦

git checkout master 

最後に、あなたのテキストファイルをコピーしますあなたがそれをしたい、git commit続いgit addを行い、その後、押し:

git push origin master 
-1

のgit bashのyの中で、このコマンドを使用してください私たちのgit repoが複製されます。その後

git status 

、あなたは非マージされたファイルがある場合

git add . 

を使用してそれらを追加してください、あなたがあるならば、

git push origin <branch-name> 

を使用

git commit -m "<comment to push>" 

を使用して、それをコミットそれでも何かエラーが発生した場合は、再度投稿してください。

関連する問題