How do I use 'git reset --hard HEAD' to revert to a previous commit?
2022-12-09
Question This question already has answers here: </div> How do I revert a Git repository to a previous commit? (41 answers) </span> Closed 9 years ago. I know that Git tracks changes I make to my application, and holds on to them until I commit the changes. To revert to a previous commit, I used: $ git reset --hard HEAD HEAD is now at 820f417 micro How do I then revert the files on my hard drive back to that previous commit?…
How do I remove a submodule?
2022-12-08
Question How do I remove a Git submodule? Why can't I do git submodule rm module_name? Answer In modern git (I'm writing this in 2022, with an updated git installation), this has become quite a bit simpler: Run git rm <path-to-submodule>, and commit. This removes the filetree at <path-to-submodule>, and the submodule's entry in the .gitmodules file. I.e. all traces of the submodule in your repository proper are removed. As the docs note however, the .…
How do I remove a single file from the staging area (undo git add)?
2022-12-06
Question Situation: I have a Git repository with files already in the index. I make changes to several files, open Git and add these files to my staging area with "git add ." Question: How do I remove one of those files from the staging area but not remove it from the index or undo the changes to the file itself? Answer If I understand the question correctly, you simply want to "…
How can I list all the deleted files in a Git repository?
2022-12-04
Question I know Git stores information of when files get deleted and I am able to check individual commits to see which files have been removed, but is there a command that would generate a list of every deleted file across a repository's lifespan? Answer git log --diff-filter=D --summary See Find and restore a deleted file in a Git repository If you don't want all the information about which commit they were removed in, you can just add a grep delete in there.…
LF will be replaced by CRLF in git - What is that and is it important? [duplicate]
2022-12-04
Question This question already has answers here: </div> Git replacing LF with CRLF (25 answers) Closed 3 years ago. git init git add . Gives the following warnings for many files: The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in <filename>. What's the difference between LF and CRLF? What should I do about the warnings? Answer In Unix systems the end of a line is represented with a line feed (LF).…
Using Git, how could I search for a string across all branches?
2022-12-04
Question Using Git, how could I search within all files in all local branches for a given string? GitHub specific: is it possible to perform the above search across all GitHub branches? (There are several remote branches on my remote GitHub repository that ideally I wouldn't have to bring down for this search...) Answer You can do this on a Git repository: git grep "string/regexp" $(git rev-list --all) GitHub advanced search has code search capability:…
How to drop rows of Pandas DataFrame whose value in a certain column is NaN
2022-12-02
Question I have this DataFrame and want only the records whose EPS column is not NaN: >>> df STK_ID EPS cash STK_ID RPT_Date 601166 20111231 601166 NaN NaN 600036 20111231 600036 NaN 12 600016 20111231 600016 4.3 NaN 601009 20111231 601009 NaN NaN 601939 20111231 601939 2.5 NaN 000001 20111231 000001 NaN NaN ...i.e. something like df.drop(....) to get this resulting dataframe: STK_ID EPS cash STK_ID RPT_Date 600016 20111231 600016 4.…