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

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?

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.
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.

I know I am a bit late on this thread. But I was facing an issue where the selected code block was not getting added when I click on the line I wanted to include in the commit. Just make sure you've disabled the Hide whitespace changes checkbox in the settings menu.

Related

'.pbxproj' file is missing in commits list

currently building a project clone and push all the changes to my github account step by step.
And i always used to see 'Twitter.xcodeproj/project.pbxproj' checked together with modified .swift files.
However, i don't see it now. I've reopened and did some additional changes to the code, but still nothing.
Is that ok, if it's not pushed?
And how do i get it back to normal if it's not?
The list you are looking at is generated by git status. Well, git status does not include any files that didn't change. So you should not expect to see project.pbxproj in the list unless you did something that would change it (like making a new code file and adding it to your project). Merely editing your existing code wouldn't change it, so it doesn't appear.
(In a way, this is a case of the classic confusion as to what git status means. Beginners often think that it's a list of your files, or a list of the files that will go into this commit. It isn't. A commit always contains all your files. But git doesn't bother to list them in the git status, because that could be an unnecessarily huge list. There are ways to find out what's in the commit, but the screen you are displaying is not how to do it.)
TL;DR Don't worry, be happy.

Changes list all files as added instead of only last commit modification

Using Jenkins 2.108, the Changes summary is now wrong.
It list only the last commit (even if there were several since last build) and it list all files of the project as added.
Any idea?
As reported in JENKINS-45586 this issue can occur if you are using GIT shallow clone option.
As a workaround, you can set the depth to 2 if you run a Jenkins build for every commit as explained in JENKINS-45586#comment-331463. To be safe you can set it to a number like 5.

Commit option in source control does not work properly in Xcode

I have created an application, and I want to commit it to GitHub as as soon as I implement a new option. What I have noticed is that when I use the commit option under source control in Xcode,
some commits appear in the GitHub website, while others don't, following is a clarification
The following figure shows the commits that appear in Xcode and the next one shows the commits appearing in the GitHub website. As you can notice "Added the Login with Facebook button" commit is missing, and any commit that I try to do after this one does not appear. What is the problem?
EDIT: What I have noticed is that I have two working copies of the same project. I doubt that I have created both, where the first copy has the remote GitHub link specified to it, while the other does not. I have tried to add the GitHub link to the second, but it creates more confusion than ever.

What Discard all changes in Xcode source control actually does?

As in question, I wonder if there is some documentation about what this Xcode command does (Source Control -> Discard all changes) ?
I guess it reverts to last commit but on local branch ? Can somebody confirm that it doesn't affect the same remote branch automatically ?
I didn't use git in XCode, but I can be so sure that Discard all changes will NOT affect history in the remote.
It will most probably discard all unstaged changes you made to the tracked files in the working directory, simply like executing git checkout -- . from the terminal.
With unstaged, it means changes you once executed git add -u for will not be discarded.
By the way, to find out what it actually does, a test by yourself is needed.
I ran into a similar problem in which I wanted to roll back to my most recent local commit, and being unfamiliar with command line git, I took a chance with selecting 'Discard Changes in /filename/' and it did exactly the same thing all the websites said git checkout would do.
Once again, this is just my "test" but the feature works as advertised.

Remove git history for distributing project for bug report?

My iOS app is having a strange core data bug, and I contacted Apple's developer technical support for help. They are asking me to submit a copy of the offending code, so they can see what is going on exactly and help me identify the problem, but as one would expect I don't want to give them all my code, not only because it is proprietary but also because I want them to be able to identify the arts of the code that are having issues.
So I have removed 95% pf my code so that the app still builds and loads, and the problem can be demonstrated. I would like to provide them with a git repository, so that the developer who looks at my code can see how the changes I am making creates the bug.
However, I don't want to send them the whole git repository as it stands because the history would allow them to just go back in time, and undo all of the deleting work that I did. What is the proper way to go about "pruning" a copy of my git repository, so that a particular commit will become the root of the new commit tree?
You can delete a given file/files using git filter-branch.
See here:
https://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html
Specifically, you may use the following example to delete a file named as filename:
git filter-branch --index-filter 'git rm --cached --ignore-unmatch filename' HEAD

Resources