XCode source control: view changes for one file
Asked Answered
H

6

47

Is it possible to view a "timeline" (history) for a selected file for like 50 commits? I mean changes made to this particular file and and view commits when they were made and users who changed them? I know Xcode got some powerful version control features, I just can not find this one.

Hae answered 3/3, 2014 at 11:50 Comment(0)
T
54

What it sounds like you want is the "Blame View", if we were on the terminal you could write git blame <file-name> to see the commit/time/and user for every single line of a particular file. In Xcode you can accomplish the same thing by activating the blame view. I've posted a picture to show you where the Blame View button resides. From there you should be all set.

Open Xcode Blame View

Tad answered 3/3, 2014 at 12:45 Comment(2)
This shows the history of each line of code. Is there a way to view the history of a file by date instead? For example, for a single file view all the dates it was changed on. And then for one of those dates, view the changes made via a compare.Garrity
That's the Log view in the image above. You don't get to see the diff between the current version and any version, but rather the diffs from one version to the next.Messina
M
37

For xcode 11.0, If you select a file, changes for that file is available on right panel.

enter image description here

Movie answered 13/1, 2020 at 10:3 Comment(1)
default hot key: option+cmd+2Souza
H
21

The commit history is in the Version Editor.

Select the file for which you want to see the commit history. Then go to View > Version Editor > Show Version Editor (or just select the Comparison view from the top-right toolbar icon - same place as the Blame view).

Clicking on the commit label below the editor will reveal the history including dates.

Hangchow answered 21/4, 2015 at 17:14 Comment(1)
For shortcut shift+command+alt+Enter. command+enter to go back to standard editor.Groundhog
L
9

Yes. Xcode's Comparison view is exactly for that. When you select a source file, and choose comparison view, you have a time-machine like user-interface that besides letting you compare any two versions of the file, will also present (when you hover) all the commits of the file with their descriptions. This UI opens when you click the clock button in the bottom between the two versions of the comparison view.

Pay attention, that Xcode will list all the commits, but will fail to show the content of versions of the file if the file-name or path changed. I think Xcode makers thought that because sources are considered "different" if they are named differently or located differently, there's no point in showing them. It may be, though that they just overlooked the --follow parameter to git.

Logistic answered 17/3, 2016 at 6:23 Comment(5)
Xcode 8+. Comparison "time machine" gone for me. Do you have the same?Small
@zulkis Missing for me too :(Volding
That was the best part. You could scroll through time and see when someone touches that spot.Quagmire
@AlekseiMinaev I can't remember now about Xcode 8 - but in Xcode 9.x and 10.x. the "Time-Machine" like UI was replaced by another view - instead of "Comparison" view, choose the "Log View" which presents the source, with a side-bar on the right, presenting all the commits to the file with their comment, date, author and hash. The "Authors View" will present the author (and his commit's details) for every line in the source. So you can clearly see who wrote what, and when. I find these three views very useful, But my hears still longs for the time-machine style UI. It was beautifulLogistic
@MottiShneor Yes, I saw that. It is cool, but it is not really helpful to check diff for one specific file.Small
R
8

Xcode 13

  1. Enable Code Review (default: cmd+shift+opt+Enter to toggle)
  2. On the right of the bottom bar (or if you have the debug area opened: the bar that sits on top of it) there are a couple of buttons used for comparing commits: clicking them allows you to pick which commits to use for the comparison on the current file.

Enable Code Review button

enable code review

Comparison buttons on Debug Area

code review comparison buttons

Rehearsal answered 18/7, 2022 at 17:44 Comment(2)
Note, you don't have to show the debug area; that's what's below the bottom bar.Inbred
You're right! I'm just so used to having it open I didn't realize it would still show :)Rehearsal
P
0

To show a side by side view of the current file and its changes over time press Shift Command Return.

When you're done, press Command Enter to return to the normal text editor.

Works in Xcode 14.

Parted answered 1/9, 2023 at 1:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.