Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub for Windows: How to commit only a part of the file?

I am new in GitHub for Windows. I learn how to commit a single change. But i don't understand how can i commit only a part of file. On GitHub for Mac you can just select the line.

How can i do it on GitHub for Windows?

like image 380
FrancescoMussi Avatar asked Aug 29 '13 16:08

FrancescoMussi


People also ask

What is partial commit?

Commit partially using the staging area Commit everything directly with git commit -a. This way, only the relevant changes will end up in the commit. It is also possible to stage only parts of a file, to leave leave unrelated changes out of the commit.

How do I commit a single file in git?

To add and commit files to a Git repository Enter git status to see the changes to be committed. Enter git commit -m '<commit_message>' at the command line to commit new files/changes to the local repository. For the <commit_message>, you can enter anything that describes the changes you are committing.


1 Answers

Update: January 2015, 14th: Partial commits in GitHub for Windows:

The newest release of GitHub for Windows supports selecting lines or blocks of changes when creating a commit. Simply click the desired lines in the gutter, create the commit, and leave the other changes for you to continue working on.

https://cloud.githubusercontent.com/assets/359239/5745722/ab3d336e-9bdf-11e4-8001-fc7316e8155b.gif

The GitHub post adds what I mentioned in my original answer below:

For people familiar with the command line, this change is similar to interactive staging using git add -i or git add -p.


(Original answer: Aug. 2013)

From GitHub for Windows, you can open the console, and type:

git add -p -- path/to/your/File

You will then be able to stage exactly what you want from that file.

git add --patch:

Interactively choose hunks of patch between the index and the work tree and add them to the index.
This gives the user a chance to review the difference before adding modified contents to the index.

like image 79
VonC Avatar answered Oct 24 '22 01:10

VonC