cis-ds / Discussion

Public discussion
10 stars 15 forks source link

hw02: unable to commit changes or push to git #174

Closed ajth2021 closed 2 years ago

ajth2021 commented 3 years ago

I just finished hw02. At some point while I was completing it in RMarkdown, I wanted to start from scratch, so I deleted the file manually from my computer by going to Files > Documents > R > CFSS HW > hw02, right clicking, and deleting. I then re-did the process of forking the repo, cloning the file, opening a new Version Control file in RStudio, and pasting the hw02 link (for my own repository).

I finished the HW, and attempted to commit my changes. I got an error message when I did so (I don't remember what it said), looked online, and concluded I needed to "pull" my changes first, and then save them. I tried recommitting and pushing my file several times, but I did not see my changes on GitHub in mass-shootings.Rmd where I saved them. Instead, I saw my commit message on GitHub in the "demo" folder under the mass-shootings-solution.md; I thought this was weird, since I did not edit the mass-shootings-solutions.md file, and did not see my changes updated there on GitHub.

I copied my code to another file, and repeated the process of deleting the file manually, and starting over. I copied my code back into my new mass-shootings.Rmd file, and now when I try to commit changes, I get the following error:

C:/Program Files/Git/bin/git.exe commit -F C:/Users/ALLEGR~1.HAT/AppData/Local/Temp/Rtmp0wE1dQ/git-commit-message-10bc82c07353c.txt On branch master Your branch is up to date with 'origin/master'.

Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: mass-shootings.Rmd

no changes added to commit (use "git add" and/or "git commit -a")

When I try to push the file to GitHub, R says says

Everything up-to-date

But the changes are not there. I also see the following message in GitHub:

This branch is 4 commits ahead of cfss-win21:master.

What do I do? I didn't have any of these problems when submitting hw01.

Session Info: R version 4.0.2 (2020-06-22) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages: [1] stats graphics grDevices utils
[5] datasets methods base

other attached packages: [1] rcfss_0.2.1 knitr_1.30
[3] forcats_0.5.0 stringr_1.4.0
[5] dplyr_1.0.2 purrr_0.3.4
[7] readr_1.4.0 tidyr_1.1.2
[9] tibble_3.0.3 ggplot2_3.3.2
[11] tidyverse_1.3.0

loaded via a namespace (and not attached): [1] Rcpp_1.0.5 lubridate_1.7.9
[3] prettyunits_1.1.1 ps_1.4.0
[5] assertthat_0.2.1 rprojroot_1.3-2
[7] digest_0.6.25 R6_2.4.1
[9] cellranger_1.1.0 backports_1.1.10 [11] reprex_0.3.0 evaluate_0.14
[13] highr_0.8 httr_1.4.2
[15] pillar_1.4.6 rlang_0.4.10
[17] readxl_1.3.1 rstudioapi_0.11
[19] callr_3.5.0 blob_1.2.1
[21] rmarkdown_2.4 labeling_0.3
[23] desc_1.2.0 devtools_2.3.2
[25] munsell_0.5.0 broom_0.7.1
[27] compiler_4.0.2 modelr_0.1.8
[29] xfun_0.18 pkgconfig_2.0.3
[31] pkgbuild_1.1.0 htmltools_0.5.0
[33] tidyselect_1.1.0 fansi_0.4.1
[35] crayon_1.3.4 dbplyr_1.4.4
[37] withr_2.3.0 grid_4.0.2
[39] jsonlite_1.7.1 gtable_0.3.0
[41] lifecycle_0.2.0 DBI_1.1.0
[43] magrittr_1.5 scales_1.1.1
[45] stringi_1.5.3 cli_2.0.2
[47] farver_2.0.3 fs_1.5.0
[49] remotes_2.2.0 testthat_2.3.2
[51] xml2_1.3.2 ellipsis_0.3.1
[53] generics_0.0.2 vctrs_0.3.4
[55] tools_4.0.2 glue_1.4.2
[57] hms_0.5.3 processx_3.4.4
[59] pkgload_1.1.0 yaml_2.2.1
[61] colorspace_1.4-1 sessioninfo_1.1.1 [63] rvest_0.3.6 memoise_1.1.0
[65] haven_2.3.1 usethis_2.0.0

deblnia commented 3 years ago

First thing to check: did you fork the HW repo, or is this a clone on the master? If you run git remote -v in Terminal and it's a fork, you should see your username. If you don't, follow these instructions.

If you're definitely working on the fork (and at some point at least, it seems like you were -- I can see 4 commits, but no file changes), trying running git add in the Terminal, then git commit -m"TEST" and then git push.

If you're still getting an error we can debug this after class today 😄

ajth2021 commented 3 years ago

Hi Dublina,

Thanks for your comment! I tried running the codes you mentioned (outcome below) but still can't commit the changes or push to git. I reread the instructions for hw02, and saw the instruction about staging and committing mass-shootings.md and mass-shootings_files/ , but I don't see either of those in my hw02 folder. Could that be part of the problem?

I would definitely appreciate going over this after class if you are available!

Here is what the terminal said when I ran the code:

Allegra J. T. Hatem@DESKTOP-NEBBHDD MINGW64 ~/DocuFSS HW/hw02 (master) $ git remote -v origin https://github.com/ajth2021/hw02.git (fetc origin https://github.com/ajth2021/hw02.git (push

Allegra J. T. Hatem@DESKTOP-NEBBHDD MINGW64 ~/DocuFSS HW/hw02 (master) $ git add Nothing specified, nothing added. hint: Maybe you wanted to say 'git add .'? hint: Turn this message off by running hint: "git config advice.addEmptyPathspec false"

Allegra J. T. Hatem@DESKTOP-NEBBHDD MINGW64 ~/DocuFSS HW/hw02 (master) $ git commit -m"TEST" On branch master Your branch is up to date with 'origin/master'.

Changes not staged for commit: (use "git add ..." to update what will be ) (use "git restore ..." to discard changes g directory) modified: mass-shootings.Rmd

no changes added to commit (use "git add" and/oror "git commit -a")

Allegra J. T. Hatem@DESKTOP-NEBBHDD MINGW64 ~/Documents/uments/R/CFSS HW/hw02 (master) $ git push Everything up-to-date

bensoltoff commented 3 years ago

I would encourage you to avoid the terminal for this process. You have changes already committed on GitHub and you need to pull them down into the current repo you have on your local computer. To do that, clone your fork like normal using RStudio > New Project. Then in the Git tab click the pull button (instead of push). You will get an error message about merge conflicts if you made any changes locally that are not reflected in the version on GitHub. You need to open all the specific file and find the lines of code which need to be resolved (i.e. which version to use). Once you do that, save and knit the Rmd file. You should then be able to stage/commit/push as normal.