How to list all commits that changed a specific file?
2022-04-15
Question Is there a way to list all commits that changed a specific file? Answer The --follow works for a particular file git log --follow -- filename Difference to other solutions given Note that other solutions include git log path (without the --follow). That approach is handy if you want to track e.g. changes in a directory, but stumbles when files were renamed (thus use --follow filename).
Show git diff on file in staging area [duplicate]
2022-04-15
Question This question already has answers here: </div> How do I show the changes which have been staged? (16 answers) Closed 3 years ago. Is there a way I can see the changes that were made to a file after I have done git add file? That is, when I do: git add file git diff file no diff is shown. I guess there's a way to see the differences since the last commit but I don't know what that is.…
Git symbolic links in Windows
2022-04-13
Question Our developers use a mix of Windows and Unix-based OSes. Therefore, symbolic links created on Unix machines become a problem for Windows developers. In Windows (MSysGit), the symbolic link is converted to a text file with a path to the file it points to. Instead, I'd like to convert the symbolic link into an actual Windows symbolic link. The (updated) solution I have to this is: Write a post-checkout script that will recursively look for "…
Display last git commit comment
2022-04-12
Question Often during a commit ($ git -commit -m ""), I wish to read my last comment to remember what progress I have made. Is there an easy way to directly access the last commit message through command-line? (I'm using Windows.) Answer git show is the fastest to type, but shows you the diff as well. git log -1 is fast and simple. git log -1 --pretty=%B if you need just the commit message and nothing else.…
How do I rename a repository on GitHub?
2022-04-12
Question I wanted to rename one of my repositories on GitHub, but I got scared when a big red warning said: We will not set up any redirects from the old location You will need to update your local repositories to point to the new location Renaming may take a few minutes to complete Does anyone have step-by-step instructions on how to accomplish #1 and #2 manually? Or what do I have to do locally?…
How do I create a remote Git branch?
2022-04-10
Question I created a local branch. How do I push it to the remote server? UPDATE: I have written a simpler answer for Git 2.0 here. Answer First, create a new local branch and check it out: git checkout -b <branch-name> The remote branch is automatically created when you push it to the remote server: git push <remote-name> <branch-name> <remote-name> is typically origin, which is the name which git gives to the remote you cloned from.…
Renaming column names in Pandas
2022-04-10
Question I want to change the column labels of a Pandas DataFrame from ['$a', '$b', '$c', '$d', '$e'] to ['a', 'b', 'c', 'd', 'e'] Answer Rename Specific Columns Use the df.rename() function and refer the columns to be renamed. Not all the columns have to be renamed: df = df.rename(columns={'oldName1': 'newName1', 'oldName2': 'newName2'}) Or rename the existing DataFrame (rather than creating a copy) df.rename(columns={‘oldName1’: ’newName1’, ‘oldName2’: ’newName2’}, inplace=True) Minimal Code Example…