makersacademy / problem-solving

For problem-solving during the PreCourse
6 stars 2 forks source link

Problems with pushing code to my pre-existing codewars repo. #116

Closed ghost closed 7 years ago

ghost commented 7 years ago

Before I understood how to work Github I had created an online codewars repo and uploaded ruby files manually by going into Github and uploading using the upload tab. Now I am trying to push anything using terminal. But it wont let me. I have searched the internet for help and tried a few things but keep getting stuck. I don't want to mess anything up permanently. for example by --f forcing the commit or push which some people do and don't recommend. I don't want to clone my repo either because then my github commits wont count!! Please advise.

This was my first error sign/warning sign:

/Desktop/Ruby/Codewars (master ✘)✹✭ ᐅ git push To git@github.com:RMCollins175/codewars.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'git@github.com:RMCollins175/codewars.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.

.....so I tried git pull and then continued to try git add, git commit....:

~/Desktop/Ruby/Codewars (master ✘)✹✭ ᐅ git add a_function_withint_a_function.rb ~/Desktop/Ruby/Codewars (master ✘)✹✭ ᐅ git commit -m "solution to kata" On branch master Changes not staged for commit: modified: number_of_the_people_in_bus.rb

Untracked files: $_and_cents.rb .DS_Store Add_More_Items_To_List.rb Basic_Mathematicl_Operations.rb Days_in_the_year.rb Square(n)Sum.rb add_length.rb are_you_playing_banjo.rb array_second.rb beginner_series_3_sum_of_numbers.rb bool_to_word.rb complementary_dna.rb convert_boolean_to_string.rb convert_num_to_string.rb count_by_x.rb count_of_pos_sum_of_negs.rb counting_sheep.rb descending_order.rb disemvowel_trolls.rb do_i_get_a_bonus.rb double_char.rb enumerable_magic_1_true_for_all.rb enumerable_magic_2_true_for_any.rb exhs_and_ohs.rb fake-binary.rb find_multiples_of_a_number.rb fizzbuzz_codewars.rb get_the_middle_char.rb grasshopper_summation.rb grasshopper_terminal_game.rb hello_johnny.rb hello_world.rb highest_lowest.rb inverting_numbers.rb inverting_numbers_1.rb jaden_smith.rb keep_hydrated.rb list_filtering.rb map_and_each.rb merging_sorted_integar_arrays_withoutduplicates.rb min_max.rb mr_freeze.rb multiply_the_number.rb multiplying_two_numbers.rb mumbling.rb needle_in_Haystack.rb number_to_reverse_array.rb odd_or_even.rb opposite numbers_inverting_numbers.rb push_hash_into_array.rb regular_ball_super_ball.rb removing_elements.rb removing_string_spaces.rb return_negative.rb rps.rb sentence_smash.rb short_long-short.rb split_that_array.rb square_every_digit.rb sum_arrays.rb sum_mixed_array.rb sum_of_positive.rb sum_without_highest_lowest.rb switch_it_up.rb unfinished_loop_bug_fixes.rb volume_of_cuboid.rb vowel_count.rb vowel_remover.rb welcome.rb yield_to_the_block.rb youre_a_square.rb

no changes added to commit ~/Desktop/Ruby/Codewars (master ✘)✹✭ ᐅ git add a_function_withint_a_function.rb ~/Desktop/Ruby/Codewars (master ✘)✹✭ ᐅ git commit -m "solution" On branch master Changes not staged for commit: modified: number_of_the_people_in_bus.rb

Untracked files: $_and_cents.rb .DS_Store Add_More_Items_To_List.rb Basic_Mathematicl_Operations.rb Days_in_the_year.rb Square(n)Sum.rb add_length.rb are_you_playing_banjo.rb array_second.rb beginner_series_3_sum_of_numbers.rb bool_to_word.rb complementary_dna.rb convert_boolean_to_string.rb convert_num_to_string.rb count_by_x.rb count_of_pos_sum_of_negs.rb counting_sheep.rb descending_order.rb disemvowel_trolls.rb do_i_get_a_bonus.rb double_char.rb enumerable_magic_1_true_for_all.rb enumerable_magic_2_true_for_any.rb exhs_and_ohs.rb fake-binary.rb find_multiples_of_a_number.rb fizzbuzz_codewars.rb get_the_middle_char.rb grasshopper_summation.rb grasshopper_terminal_game.rb hello_johnny.rb hello_world.rb highest_lowest.rb inverting_numbers.rb inverting_numbers_1.rb jaden_smith.rb keep_hydrated.rb list_filtering.rb map_and_each.rb merging_sorted_integar_arrays_withoutduplicates.rb min_max.rb mr_freeze.rb multiply_the_number.rb multiplying_two_numbers.rb mumbling.rb needle_in_Haystack.rb number_to_reverse_array.rb odd_or_even.rb opposite numbers_inverting_numbers.rb push_hash_into_array.rb regular_ball_super_ball.rb removing_elements.rb removing_string_spaces.rb return_negative.rb rps.rb sentence_smash.rb short_long-short.rb split_that_array.rb square_every_digit.rb sum_arrays.rb sum_mixed_array.rb sum_of_positive.rb sum_without_highest_lowest.rb switch_it_up.rb unfinished_loop_bug_fixes.rb volume_of_cuboid.rb vowel_count.rb vowel_remover.rb welcome.rb yield_to_the_block.rb youre_a_square.rb

no changes added to commit ~/Desktop/Ruby/Codewars (master ✘)✹✭ ᐅ git pull There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details

git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=<remote>/<branch> master

~/Desktop/Ruby/Codewars (master ✘)✹✭ ᐅ git checkout master M number_of_the_people_in_bus.rb Already on 'master' ~/Desktop/Ruby/Codewars (master ✘)✹✭ ᐅ git pull There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details

git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=<remote>/<branch> master

~/Desktop/Ruby/Codewars (master ✘)✹✭ ᐅ git push To git@github.com:RMCollins175/codewars.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'git@github.com:RMCollins175/codewars.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. ~/Desktop/Ruby/Codewars (master ✘)✹✭ ᐅ

andyrow123 commented 7 years ago

It's clear that your repo on your computer and your repo on Github are out of sync. Would it not be better to start again by:

  1. Backing up your existing local repo with the new files
  2. Cloning your repo off of GitHub(You said you already had files added manually)
  3. Add your new files from the backup to the newly cloned repo
  4. Then doing a add/commit/push on this?

I could be wrong but maybe look into this.

ghost commented 7 years ago

Andy, Thanks! for some reason I did not think cloning was an option. All sorted.

ghost commented 7 years ago

Thanks Austin*