### Modify Git Repository Source: https://github.com/git-up/gitup/blob/master/README.md Provides examples for taking a snapshot of the current repository state and creating a new local branch from a specified commit. Error handling is omitted for brevity. ```objc // Take a snapshot of the repo GCSnapshot* snapshot = [repo takeSnapshot:NULL]; // Create a new branch and check it out GCLocalBranch* newBranch = [repo createLocalBranchFromCommit:headCommit withName:@"temp" force:NO error:NULL]; NSLog(@"%@", newBranch); ``` -------------------------------- ### Configure skipRemoteBranchTips in GitUp Source: https://github.com/git-up/gitup/blob/master/GitUpKit/Interface/GIGraph-Tests/skip_remote_branches_1.txt Enable the skipRemoteBranchTips option to modify how GitUp processes commits starting before the local branch. ```json { "skipRemoteBranchTips": true } ``` -------------------------------- ### Initialize and Inspect GCRepository Source: https://context7.com/git-up/gitup/llms.txt Demonstrates opening an existing repository, checking its properties, and creating a new local repository using GCRepository. ```objective-c #import // Open an existing Git repository NSError* error; GCRepository* repo = [[GCRepository alloc] initWithExistingLocalRepository:@"/path/to/repo" error:&error]; if (repo == nil) { NSLog(@"Failed to open repository: %@", error.localizedDescription); return; } // Check repository properties NSLog(@"Repository path: %@", repo.repositoryPath); NSLog(@"Working directory: %@", repo.workingDirectoryPath); // nil for bare repos NSLog(@"Is bare: %@", repo.bare ? @"YES" : @"NO"); NSLog(@"Is empty: %@", repo.empty ? @"YES" : @"NO"); NSLog(@"Is shallow: %@", repo.shallow ? @"YES" : @"NO"); NSLog(@"State: %lu", (unsigned long)repo.state); // kGCRepositoryState_None, _Merge, _Rebase, etc. // Create a new repository GCRepository* newRepo = [[GCRepository alloc] initWithNewLocalRepository:@"/path/to/new/repo" bare:NO defaultBranchName:@"main" error:&error]; ``` -------------------------------- ### Open and Browse Git Repository Source: https://github.com/git-up/gitup/blob/master/README.md Demonstrates how to open an existing local repository, check its cleanliness, list branches, lookup HEAD, and load the entire repository history. Assumes necessary imports and error handling are managed separately. ```objc // Open repo GCRepository* repo = [[GCRepository alloc] initWithExistingLocalRepository: error:NULL]; // Make sure repo is clean assert([repo checkClean:kGCCleanCheckOption_IgnoreUntrackedFiles error:NULL]); // List all branches NSArray* branches = [repo listAllBranches:NULL]; NSLog(@"%@", branches); // Lookup HEAD GCLocalBranch* headBranch; GCCommit* headCommit; [repo lookupHEADCurrentCommit:&headCommit branch:&headBranch error:NULL]; NSLog(@"%@ = %@", headBranch, headCommit); // Load the *entire* repo history in memory for fast access, including all commits, branches and tags GCHistory* history = [repo loadHistoryUsingSorting:kGCHistorySorting_ReverseChronological error:NULL]; assert(history); NSLog(@"%lu commits total", history.allCommits.count); NSLog(@"%@\n%@", history.rootCommits, history.leafCommits); ``` -------------------------------- ### GCRepository - Opening and Initializing Source: https://context7.com/git-up/gitup/llms.txt Methods for initializing local Git repositories and accessing basic repository metadata. ```APIDOC ## GCRepository Initialization ### Description Initializes a GCRepository instance to interact with a local Git repository on disk. ### Method Objective-C Initializer ### Parameters #### Path Parameters - **path** (NSString) - Required - The file system path to the repository. ### Request Example // Open existing [[GCRepository alloc] initWithExistingLocalRepository:@"/path/to/repo" error:&error]; // Create new [[GCRepository alloc] initWithNewLocalRepository:@"/path/to/new/repo" bare:NO defaultBranchName:@"main" error:&error]; ### Response #### Success Response - **repo** (GCRepository) - An instance representing the Git repository. ``` -------------------------------- ### Initialize Repository and Load History Source: https://context7.com/git-up/gitup/llms.txt Initializes a GitUp repository object and loads its history. Ensure the provided path points to a valid local repository. ```objc #import NSError* error; GCRepository* repo = [[GCRepository alloc] initWithExistingLocalRepository:@"/path/to/repo" error:&error]; GCHistory* history = [repo loadHistoryUsingSorting:kGCHistorySorting_ReverseChronological error:&error]; ``` -------------------------------- ### Initialize Repository and Compute Diffs Source: https://context7.com/git-up/gitup/llms.txt Initializes a Git repository and demonstrates computing various types of diffs: working directory with HEAD, working directory with index, index with HEAD, and between two commits. Options for rename/copy detection and context lines can be specified. ```objc #import NSError* error; GCRepository* repo = [[GCRepository alloc] initWithExistingLocalRepository:@"/path/to/repo" error:&error]; // Diff working directory with HEAD (like 'git diff HEAD') GCDiff* headDiff = [repo diffWorkingDirectoryWithHEAD:nil // nil = all files options:kGCDiffOption_FindRenames maxInterHunkLines:0 maxContextLines:3 error:&error]; // Diff working directory with index (like 'git diff') GCDiff* workdirDiff = [repo diffWorkingDirectoryWithRepositoryIndex:nil options:kGCDiffOption_IncludeUntracked maxInterHunkLines:0 maxContextLines:3 error:&error]; // Diff index with HEAD (like 'git diff --cached') GCDiff* stagedDiff = [repo diffRepositoryIndexWithHEAD:nil options:0 maxInterHunkLines:0 maxContextLines:3 error:&error]; // Diff between two commits GCCommit* oldCommit = [repo findCommitWithSHA1:@"abc123..." error:&error]; GCCommit* newCommit = [repo findCommitWithSHA1:@"def456..." error:&error]; GCDiff* commitDiff = [repo diffCommit:newCommit withCommit:oldCommit filePattern:nil options:(kGCDiffOption_FindRenames | kGCDiffOption_FindCopies) maxInterHunkLines:0 maxContextLines:3 error:&error]; ``` -------------------------------- ### Initialize GIStashListViewController Source: https://context7.com/git-up/gitup/llms.txt Configures a stash list view controller with a live repository and attaches it to a window's content view. ```objective-c #import @interface StashDemoController : NSObject @property (nonatomic, strong) GCLiveRepository* repository; @property (nonatomic, strong) GIWindowController* windowController; @property (nonatomic, strong) GIStashListViewController* stashViewController; @end @implementation StashDemoController - (void)setupWithPath:(NSString*)path window:(GIWindow*)window { NSError* error; // Open repository with live updates self.repository = [[GCLiveRepository alloc] initWithExistingLocalRepository:path error:&error]; self.repository.undoManager = window.undoManager; self.repository.stashesEnabled = YES; // Enable stash tracking // Create window controller (required for GIViewControllers) self.windowController = [[GIWindowController alloc] initWithWindow:window]; // Create and configure stash list view controller self.stashViewController = [[GIStashListViewController alloc] initWithRepository:self.repository]; self.stashViewController.view.frame = window.contentView.bounds; [window.contentView addSubview:self.stashViewController.view]; // The view controller automatically displays stashes with: // - Live updating when stashes change // - Ability to apply, pop, and drop stashes // - Diff preview of stash contents // - Full undo/redo support } @end ``` -------------------------------- ### Initialize GIDiffContentsViewController Source: https://context7.com/git-up/gitup/llms.txt Sets up a diff view controller to display repository changes, including loading diff data and handling delegate events for selection and context menus. ```objective-c #import @interface DiffDemoController : NSObject @property (nonatomic, strong) GCLiveRepository* repository; @property (nonatomic, strong) GIDiffContentsViewController* diffViewController; @end @implementation DiffDemoController - (void)setupWithRepository:(GCLiveRepository*)repo inView:(NSView*)containerView { self.repository = repo; // Configure status mode for automatic diff computation self.repository.statusMode = kGCLiveRepositoryStatusMode_Unified; // Create diff view controller self.diffViewController = [[GIDiffContentsViewController alloc] initWithRepository:self.repository]; self.diffViewController.delegate = self; self.diffViewController.emptyLabel = @"No changes to display"; self.diffViewController.showsUntrackedAsAdded = YES; // Add to view hierarchy self.diffViewController.view.frame = containerView.bounds; [containerView addSubview:self.diffViewController.view]; // Load diff data [self reloadDiff]; } - (void)reloadDiff { // Display unified status (working directory + index vs HEAD) GCDiff* status = self.repository.unifiedStatus; NSDictionary* conflicts = self.repository.indexConflicts; [self.diffViewController setDeltas:status.deltas usingConflicts:conflicts]; } - (void)showDiffBetweenCommits:(GCCommit*)oldCommit and:(GCCommit*)newCommit { NSError* error; GCDiff* diff = [self.repository diffCommit:newCommit withCommit:oldCommit filePattern:nil options:kGCDiffOption_FindRenames maxInterHunkLines:0 maxContextLines:3 error:&error]; [self.diffViewController setDeltas:diff.deltas usingConflicts:nil]; } // Delegate methods - (void)diffContentsViewControllerDidChangeSelection:(GIDiffContentsViewController*)controller { // Handle selection changes for line-based staging GCDiffDelta* delta = controller.deltas.firstObject; NSIndexSet* oldLines; NSIndexSet* newLines; if ([controller getSelectedLinesForDelta:delta oldLines:&oldLines newLines:&newLines]) { NSLog(@"Selected old lines: %@ new lines: %@", oldLines, newLines); } } - (NSMenu*)diffContentsViewController:(GIDiffContentsViewController*)controller willShowContextualMenuForDelta:(GCDiffDelta*)delta conflict:(GCIndexConflict*)conflict { NSMenu* menu = [[NSMenu alloc] init]; [menu addItemWithTitle:@"Stage File" action:@selector(stageFile:) keyEquivalent:@""]; [menu addItemWithTitle:@"Discard Changes" action:@selector(discardChanges:) keyEquivalent:@""]; return menu; } @end ``` -------------------------------- ### Implement GIMapViewController Delegate Source: https://context7.com/git-up/gitup/llms.txt Demonstrates setting up a GIMapViewController within a controller and implementing required delegate methods for graph interaction and commit selection. ```objective-c #import @interface MapDemoController : NSObject @property (nonatomic, strong) GCLiveRepository* repository; @property (nonatomic, strong) GIMapViewController* mapViewController; @end @implementation MapDemoController - (void)setupWithRepository:(GCLiveRepository*)repo inView:(NSView*)containerView { self.repository = repo; // Create map view controller self.mapViewController = [[GIMapViewController alloc] initWithRepository:self.repository]; self.mapViewController.delegate = self; // Add to view hierarchy self.mapViewController.view.frame = containerView.bounds; [containerView addSubview:self.mapViewController.view]; } // Select a specific commit programmatically - (void)selectCommit:(GCCommit*)commit { if ([self.mapViewController selectCommit:commit]) { NSLog(@"Selected commit: %@", commit.summary); } } // Delegate methods - (void)mapViewControllerDidReloadGraph:(GIMapViewController*)controller { NSLog(@"Graph reloaded with %lu nodes", (unsigned long)controller.graph.allNodes.count); } - (void)mapViewControllerDidChangeSelection:(GIMapViewController*)controller { GCHistoryCommit* selected = controller.selectedCommit; if (selected) { NSLog(@"Selected: %@ - %@", selected.shortSHA1, selected.summary); NSLog(@" Author: %@", selected.authorName); NSLog(@" Branches: %@", [selected.localBranches valueForKey:@"name"]); NSLog(@" Tags: %@", [selected.tags valueForKey:@"name"]); } } - (void)mapViewController:(GIMapViewController*)controller quickViewCommit:(GCHistoryCommit*)commit { // Show quick preview of commit NSLog(@"Quick view requested for: %@", commit.summary); } - (void)mapViewController:(GIMapViewController*)controller diffCommit:(GCHistoryCommit*)commit withOtherCommit:(GCHistoryCommit*)otherCommit { // Show diff between commits NSLog(@"Diff requested: %@ vs %@", commit.shortSHA1, otherCommit.shortSHA1); } - (void)mapViewController:(GIMapViewController*)controller rewriteCommit:(GCHistoryCommit*)commit { // Open commit rewriter NSLog(@"Rewrite requested for: %@", commit.summary); } - (void)mapViewController:(GIMapViewController*)controller splitCommit:(GCHistoryCommit*)commit { // Open commit splitter NSLog(@"Split requested for: %@", commit.summary); } // Handle merge conflicts during operations - (BOOL)resolveMergeConflictsWithResolver:(id)resolver { NSLog(@"Merge conflicts need resolution"); return NO; // Return YES after resolving conflicts } @end ``` -------------------------------- ### Perform Git Repository Operations with GitUpKit Source: https://github.com/git-up/gitup/blob/master/README.md Demonstrates basic repository manipulation including branching, adding files, diffing, committing, and rolling back changes using snapshots. ```objective-c assert([repo checkoutLocalBranch:newBranch options:0 error:NULL]); // Add a file to the index [[NSData data] writeToFile:[repo.workingDirectoryPath stringByAppendingPathComponent:@"empty.data"] atomically:YES]; assert([repo addFileToIndex:@"empty.data" error:NULL]); // Check index status GCDiff* diff = [repo diffRepositoryIndexWithHEAD:nil options:0 maxInterHunkLines:0 maxContextLines:0 error:NULL]; assert(diff.deltas.count == 1); NSLog(@"%@", diff); // Create a commit GCCommit* newCommit = [repo createCommitFromHEADWithMessage:@"Added file" error:NULL]; assert(newCommit); NSLog(@"%@", newCommit); // Restore repo to saved snapshot before topic branch and commit were created BOOL success = [repo restoreSnapshot:snapshot withOptions:kGCSnapshotOption_IncludeAll reflogMessage:@"Rolled back" didUpdateReferences:NULL error:NULL]; assert(success); // Make sure topic branch is gone assert([repo findLocalBranchWithName:@"temp" error:NULL] == nil); // Update workdir and index to match HEAD assert([repo resetToHEAD:kGCResetMode_Hard error:NULL]); ``` -------------------------------- ### Accessing and Manipulating Commits with GCCommit Source: https://context7.com/git-up/gitup/llms.txt Demonstrates how to initialize a repository, retrieve commit metadata, navigate parent relationships, and perform commit operations such as creating, merging, and amending. ```objc #import NSError* error; GCRepository* repo = [[GCRepository alloc] initWithExistingLocalRepository:@"/path/to/repo" error:&error]; // Find a commit by SHA1 GCCommit* commit = [repo findCommitWithSHA1:@"abc123def456..." error:&error]; // Or by prefix GCCommit* commit2 = [repo findCommitWithSHA1Prefix:@"abc123" error:&error]; // Access commit properties NSLog(@"SHA1: %@", commit.SHA1); NSLog(@"Short SHA1: %@", [repo computeUniqueShortSHA1ForCommit:commit error:&error]); NSLog(@"Message: %@", commit.message); NSLog(@"Summary: %@", commit.summary); // First line, cleaned NSLog(@"Author: %@ <%@>", commit.authorName, commit.authorEmail); NSLog(@"Author date: %@", commit.authorDate); NSLog(@"Committer: %@ <%@>", commit.committerName, commit.committerEmail); NSLog(@"Committer date: %@", commit.committerDate); NSLog(@"Tree SHA1: %@", commit.treeSHA1); // Get parent commits NSArray* parents = [repo lookupParentsForCommit:commit error:&error]; for (GCCommit* parent in parents) { NSLog(@"Parent: %@", parent.SHA1); } // Check if a file exists in a commit's tree NSString* fileSHA1 = [repo checkTreeForCommit:commit containsFile:@"README.md" error:&error]; if (fileSHA1) { NSLog(@"README.md exists with SHA1: %@", fileSHA1); } // Create a new commit from the current index GCCommit* newCommit = [repo createCommitFromHEADWithMessage:@"Add new feature" error:&error]; NSLog(@"Created commit: %@", newCommit.SHA1); // Create a merge commit with two parents GCCommit* mergeCommit = [repo createCommitFromHEADAndOtherParent:otherBranchCommit withMessage:@"Merge feature branch" error:&error]; // Amend the HEAD commit GCCommit* amendedCommit = [repo createCommitByAmendingHEADWithMessage:@"Updated message" error:&error]; ``` -------------------------------- ### File and Object Handling Options Source: https://github.com/git-up/gitup/blob/master/GitUpKit/Views/en.lproj/GIConfigViewController-Help.txt Configuration options related to how Git interacts with files and objects on disk. ```APIDOC ## File and Object Handling Options ### Description Configuration options related to how Git interacts with files and objects on disk. ### Options - **`core.fsyncObjectFiles`**: Enables `fsync()` when writing object files. Useful for filesystems that do not use journaling or only journal metadata. - **`core.createObject`**: Controls how objects are created. Can be set to 'link' to use hardlinks followed by deletes, or 'rename' to avoid overwriting existing objects but potentially be unreliable on some systems. ``` -------------------------------- ### Monitor Repositories with GCLiveRepository Source: https://context7.com/git-up/gitup/llms.txt Shows how to implement GCLiveRepository to track history, status, and stashes with automatic updates and delegate callbacks. ```objective-c #import @interface MyController : NSObject @property (nonatomic, strong) GCLiveRepository* repository; @end @implementation MyController - (void)setupRepository:(NSString*)path { NSError* error; self.repository = [[GCLiveRepository alloc] initWithExistingLocalRepository:path error:&error]; self.repository.delegate = self; // Enable features self.repository.undoManager = [[NSUndoManager alloc] init]; self.repository.stashesEnabled = YES; self.repository.snapshotsEnabled = YES; self.repository.automaticSnapshotsEnabled = YES; // Enable status tracking (computes diff between HEAD and working directory) self.repository.statusMode = kGCLiveRepositoryStatusMode_Unified; // Configure diff options self.repository.diffWhitespaceMode = kGCLiveRepositoryDiffWhitespaceMode_Normal; self.repository.diffMaxContextLines = 3; // Access repository data GCHistory* history = self.repository.history; NSLog(@"Total commits: %lu", (unsigned long)history.allCommits.count); GCDiff* status = self.repository.unifiedStatus; NSLog(@"Modified files: %lu", (unsigned long)status.deltas.count); NSArray* stashes = self.repository.stashes; NSLog(@"Stashes: %lu", (unsigned long)stashes.count); } // Delegate methods for live updates - (void)repositoryDidUpdateHistory:(GCLiveRepository*)repository { NSLog(@"History updated - %lu commits", (unsigned long)repository.history.allCommits.count); } - (void)repositoryDidUpdateStatus:(GCLiveRepository*)repository { NSLog(@"Status updated - %lu changed files", (unsigned long)repository.unifiedStatus.deltas.count); } - (void)repositoryDidUpdateStashes:(GCLiveRepository*)repository { NSLog(@"Stashes updated - %lu stashes", (unsigned long)repository.stashes.count); } @end ``` -------------------------------- ### Abbreviation and Add Command Options Source: https://github.com/git-up/gitup/blob/master/GitUpKit/Views/en.lproj/GIConfigViewController-Help.txt Configuration options for object name abbreviation and behavior of the `git add` command. ```APIDOC ## Abbreviation and Add Command Options ### Description Configuration options for object name abbreviation and behavior of the `git add` command. ### Options - **`core.abbrev`**: Sets the length for abbreviating object names. Defaults to 7 hexdigits. - **`add.ignore-errors`**: Tells `git add` to continue adding files even if some cannot be added due to indexing errors. Equivalent to `--ignore-errors`. - **`add.ignoreErrors`**: An alternative name for `add.ignore-errors`. ``` -------------------------------- ### Load and Navigate Repository History Source: https://context7.com/git-up/gitup/llms.txt Use GCHistory to access commits, branches, and tags in a repository. Requires an initialized GCRepository instance. ```objc #import // Load the entire repository history NSError* error; GCRepository* repo = [[GCRepository alloc] initWithExistingLocalRepository:@"/path/to/repo" error:&error]; GCHistory* history = [repo loadHistoryUsingSorting:kGCHistorySorting_ReverseChronological error:&error]; // Access history properties NSLog(@"Total commits: %lu", (unsigned long)history.allCommits.count); NSLog(@"Root commits: %@", history.rootCommits); NSLog(@"Leaf commits: %@", history.leafCommits); NSLog(@"HEAD commit: %@", history.HEADCommit); NSLog(@"HEAD branch: %@", history.HEADBranch.name); NSLog(@"HEAD detached: %@", history.HEADDetached ? @"YES" : @"NO"); // List all branches and tags NSLog(@"Local branches: %@", [history.localBranches valueForKey:@"name"]); NSLog(@"Remote branches: %@", [history.remoteBranches valueForKey:@"name"]); NSLog(@"Tags: %@", [history.tags valueForKey:@"name"]); // Find a commit by SHA1 GCHistoryCommit* commit = [history historyCommitWithSHA1:@"abc123..."]; NSLog(@"Commit: %@ - %@", commit.shortSHA1, commit.summary); NSLog(@"Author: %@ <%@>", commit.authorName, commit.authorEmail); NSLog(@"Date: %@", commit.date); NSLog(@"Parents: %lu", (unsigned long)commit.parents.count); NSLog(@"Children: %lu", (unsigned long)commit.children.count); // Walk all ancestors from leaves (most recent first) [history walkAllCommitsFromLeavesUsingBlock:^(GCHistoryCommit* commit, BOOL* stop) { NSLog(@"%@ %@", commit.shortSHA1, commit.summary); if (commit.isRoot) { NSLog(@"Reached root commit"); } }]; // Count commits between two points NSUInteger count = [history countAncestorCommitsFromCommit:leafCommit toCommit:rootCommit]; NSLog(@"Commits between: %lu", (unsigned long)count); ``` -------------------------------- ### GCLiveRepository - Live Monitoring Source: https://context7.com/git-up/gitup/llms.txt Methods for monitoring repository changes, managing stashes, and tracking status diffs with undo/redo support. ```APIDOC ## GCLiveRepository Monitoring ### Description Extends GCRepository to provide automatic live updates, status tracking, and history management. ### Method Objective-C Initializer ### Parameters #### Path Parameters - **path** (NSString) - Required - The file system path to the repository. ### Request Example self.repository = [[GCLiveRepository alloc] initWithExistingLocalRepository:path error:&error]; ### Response #### Success Response - **repository** (GCLiveRepository) - An instance configured for live monitoring and status tracking. ``` -------------------------------- ### GCIndex - Staging and Unstaging Files Source: https://context7.com/git-up/gitup/llms.txt API for fine-grained control over the Git index, including staging/unstaging individual files or specific lines within files. ```APIDOC ## GCIndex - Staging and Unstaging Files ### Description The GCIndex API provides fine-grained control over the Git index (staging area), including staging/unstaging individual files or specific lines within files. ### Method Objective-C methods are used to interact with the Git index. ### Endpoint N/A (This is an Objective-C API, not a REST endpoint) ### Parameters N/A for the overall API, parameters are specific to individual methods. ### Request Example ```objc #import NSError* error; GCRepository* repo = [[GCRepository alloc] initWithExistingLocalRepository:@"/path/to/repo" error:&error]; // Read the current repository index GCIndex* index = [repo readRepositoryIndex:&error]; // Check index properties NSLog(@"Index is empty: %@", index.empty ? @"YES" : @"NO"); NSLog(@"Index has conflicts: %@", index.hasConflicts ? @"YES" : @"NO"); // Enumerate all files in the index [index enumerateFilesUsingBlock:^(NSString* path, GCFileMode mode, NSString* sha1, BOOL* stop) { NSLog(@"Indexed file: %@ (mode: %lu, sha1: %@)", path, (unsigned long)mode, sha1); }]; // Stage a file (git add) [repo addFileToIndex:@"README.md" error:&error]; // Stage multiple files [repo addFilesToIndex:@[@"file1.txt", @"file2.txt", @"src/main.m"] error:&error]; // Unstage a file (git reset HEAD) [repo resetFileInIndexToHEAD:@"README.md" error:&error]; // Discard changes in working directory (git checkout) [repo checkoutFileFromIndex:@"README.md" error:&error]; // Stage specific lines only (interactive staging like 'git add -p') [repo addLinesFromFileToIndex:@"main.m" error:&error usingFilter:^BOOL(GCLineDiffChange change, NSUInteger oldLineNumber, NSUInteger newLineNumber) { // Only stage additions in lines 10-20 return (change == kGCLineDiffChange_Added && newLineNumber >= 10 && newLineNumber <= 20); }]; // Unstage specific lines (like 'git reset -p') [repo resetLinesFromFileInIndexToHEAD:@"main.m" error:&error usingFilter:^BOOL(GCLineDiffChange change, NSUInteger oldLineNumber, NSUInteger newLineNumber) { return (newLineNumber >= 50 && newLineNumber <= 60); }]; // Reset entire index to HEAD [repo resetIndexToHEAD:&error]; // Sync entire working directory to index (git add -A) [repo syncIndexWithWorkingDirectory:&error]; // Handle conflicts if (index.hasConflicts) { [index enumerateConflictsUsingBlock:^(GCIndexConflict* conflict, BOOL* stop) { NSLog(@"Conflict at: %@ (status: %lu)", conflict.path, (unsigned long)conflict.status); // kGCIndexConflictStatus_BothModified, _BothAdded, _DeletedByUs, _DeletedByThem }]; // Resolve a conflict [repo resolveConflictAtPath:@"conflicted-file.txt" error:&error]; } ``` ### Response N/A (This is an Objective-C API, responses are handled via return values and error objects.) ``` -------------------------------- ### Git Core Configuration Settings Source: https://github.com/git-up/gitup/blob/master/GitUpKit/Views/en.lproj/GIConfigViewController-Help.txt Overview of core configuration variables used to manage repository behavior, performance, and file permissions. ```APIDOC ## Git Core Configuration ### Description Configuration settings for Git repositories, typically found in the .git/config file. ### Parameters - **core.bare** (boolean) - If true, the repository has no working directory. - **core.worktree** (string) - Path to the root of the working tree. - **core.logAllRefUpdates** (boolean) - Enables reflog for branch heads, remote refs, and notes. - **core.repositoryFormatVersion** (integer) - Internal version identifier for repository layout. - **core.sharedRepository** (string/octal) - Defines file permissions for shared access (e.g., 'group', 'all', 'umask', or '0xxx'). - **core.warnAmbiguousRefs** (boolean) - Warns if a ref name is ambiguous. - **core.compression** (integer) - Default compression level (-1 to 9). - **core.loosecompression** (integer) - Compression level for loose objects (-1 to 9). - **core.packedGitWindowSize** (string) - Memory mapping window size for pack files (e.g., '1m', '32m', '1g'). - **core.packedGitLimit** (string) - Limit for total memory mapping of pack files. ``` -------------------------------- ### Performance and Indexing Options Source: https://github.com/git-up/gitup/blob/master/GitUpKit/Views/en.lproj/GIConfigViewController-Help.txt Configuration options aimed at improving Git's performance, particularly with index operations. ```APIDOC ## Performance and Indexing Options ### Description Configuration options aimed at improving Git's performance, particularly with index operations. ### Options - **`core.preloadIndex`**: Enables parallel index preload for operations like `git diff` and `git status`, potentially speeding them up on high-latency filesystems. ``` -------------------------------- ### Manage Git tags with GCTag Source: https://context7.com/git-up/gitup/llms.txt Demonstrates listing, creating, renaming, deleting, and pushing tags using GCRepository and GCTag classes. ```objc #import NSError* error; GCRepository* repo = [[GCRepository alloc] initWithExistingLocalRepository:@"/path/to/repo" error:&error]; // List all tags NSArray* tags = [repo listTags:&error]; for (GCTag* tag in tags) { NSLog(@"Tag: %@", tag.name); // Get the commit and annotation (if any) for the tag GCTagAnnotation* annotation; GCCommit* commit = [repo lookupCommitForTag:tag annotation:&annotation error:&error]; NSLog(@" Points to: %@ - %@", commit.shortSHA1, commit.summary); if (annotation) { NSLog(@" Annotated: %@", annotation.message); NSLog(@" Tagger: %@", annotation.tagger); } } // Find a specific tag GCTag* v1 = [repo findTagWithName:@"v1.0.0" error:&error]; // Create a lightweight tag GCCommit* headCommit = [repo lookupHEAD:nil error:&error]; GCTag* lightTag = [repo createLightweightTagWithCommit:headCommit name:@"v2.0.0-beta" force:NO error:&error]; // Create an annotated tag GCTagAnnotation* newAnnotation; GCTag* annotatedTag = [repo createAnnotatedTagWithCommit:headCommit name:@"v2.0.0" message:@"Release version 2.0.0\n\nMajor features:\n- Feature A\n- Feature B" force:NO annotation:&newAnnotation error:&error]; NSLog(@"Created annotated tag: %@ (%@)", annotatedTag.name, newAnnotation.SHA1); // Rename a tag [repo setName:@"v2.0.1" forTag:annotatedTag force:NO error:&error]; // Delete a tag locally [repo deleteTag:lightTag error:&error]; // Push a tag to remote GCRemote* origin = [repo lookupRemoteWithName:@"origin" error:&error]; [repo pushTag:annotatedTag toRemote:origin force:NO error:&error]; // Push all tags [repo pushAllTagsToRemote:origin force:NO error:&error]; // Delete a tag from remote [repo deleteTag:annotatedTag fromRemote:origin error:&error]; ``` -------------------------------- ### Git Configuration Variables Source: https://github.com/git-up/gitup/blob/master/GitUpKit/Views/en.lproj/GIConfigViewController-Help.txt This section outlines various Git configuration variables and their functions. ```APIDOC ## Git Configuration Variables This section outlines various Git configuration variables and their functions. ### i18n.commitEncoding * **Description**: Character encoding for commit messages. Git itself does not enforce encoding, but this is necessary for importing commits from emails or in graphical history browsers. Defaults to 'utf-8'. * **Section**: i18n ### i18n.logOutputEncoding * **Description**: Character encoding for commit messages when running 'git log' and related commands. * **Section**: i18n ### init.templatedir * **Description**: Specifies the directory from which templates are copied during `git init`. See `git-init(1)` for details. * **Section**: init ### instaweb.browser * **Description**: Specifies the program used to browse your working repository in `gitweb`. See `git-instaweb(1)` for details. * **Section**: instaweb ### instaweb.httpd * **Description**: The HTTP daemon command-line to start `gitweb` on your working repository. See `git-instaweb(1)` for details. * **Section**: instaweb ### instaweb.local * **Description**: If true, the web server started by `git-instaweb` will be bound to the local IP (127.0.0.1). * **Section**: instaweb ### instaweb.modulepath * **Description**: The default module path for `git-instaweb` to use instead of `/usr/lib/apache2/modules`. Only used if `httpd` is Apache. See `git-instaweb(1)` for details. * **Section**: instaweb ### instaweb.port * **Description**: The port number to bind the `gitweb` HTTP daemon to. See `git-instaweb(1)` for details. * **Section**: instaweb ### interactive.singlekey * **Description**: In interactive commands, allows single-key input (without pressing Enter). Used by `--patch` modes of `git-add`, `git-checkout`, `git-commit`, `git-reset`, and `git-stash`. Ignored if portable keystroke input is not available. * **Section**: interactive ### log.abbrevCommit * **Description**: If true, makes `git-log`, `git-show`, and `git-whatchanged` assume `--abbrev-commit`. Can be overridden with `--no-abbrev-commit`. * **Section**: log ### log.date * **Description**: Sets the default date-time mode for the `git log` command, similar to the `--date` option. Possible values: 'relative', 'local', 'default', 'iso', 'rfc', 'short'. See `git-log(1)` for details. * **Section**: log ### log.decorate * **Description**: Controls the display of ref names (tags, branches) for commits shown by `git log`. Can be 'short' (no prefixes), 'full' (full ref name), or unset. Equivalent to `git log --decorate`. * **Section**: log ### log.showroot * **Description**: If true, the initial commit is shown as a creation event (diff against an empty tree). Tools like `git-log` will show the root commit. True by default. * **Section**: log ### log.mailmap * **Description**: If true, makes `git-log`, `git-show`, and `git-whatchanged` assume `--use-mailmap`. * **Section**: log ### mailmap.file * **Description**: Specifies the location of an augmenting mailmap file. The default mailmap in the repository root is loaded first, then the file specified here. See `git-shortlog(1)` and `git-blame(1)` for details. * **Section**: mailmap ### mailmap.blob * **Description**: Similar to `mailmap.file`, but the value is treated as a reference to a blob in the repository. If both `mailmap.file` and `mailmap.blob` are given, `mailmap.file` entries take precedence. Defaults to `HEAD:.mailmap` in bare repositories, empty otherwise. * **Section**: mailmap ### man.viewer * **Description**: Specifies the program used to display help in `man` format. See `git-help(1)` for details. * **Section**: man ### man..cmd * **Description**: Specifies the command to invoke a specific `man` viewer. The command is evaluated in the shell with the man page passed as an argument. See `git-help(1)` for details. * **Section**: man ### man..path * **Description**: Overrides the path for a specific `man` viewer tool. Useful if the tool is not in the system's PATH. See `git-help(1)` for details. * **Section**: man ### mergetool..path * **Description**: Overrides the path for a specific merge tool. Useful if the tool is not in the system's PATH. * **Section**: mergetool ### mergetool..cmd * **Description**: Specifies the command to invoke a specific merge tool. The command is evaluated in the shell with variables like `BASE`, `LOCAL`, `REMOTE`, and `MERGED` available. See `git-merge-tools(1)` for details. * **Section**: mergetool ### mergetool..trustExitCode * **Description**: For custom merge commands, specifies whether the exit code determines merge success. If not true, the target file's timestamp is checked, or the user is prompted. See `git-merge-tools(1)` for details. * **Section**: mergetool ``` -------------------------------- ### Manage Git Index with GCIndex Source: https://context7.com/git-up/gitup/llms.txt Use GCIndex to stage, unstage, and resolve conflicts in the Git index. Requires an initialized GCRepository instance. ```objective-c #import NSError* error; GCRepository* repo = [[GCRepository alloc] initWithExistingLocalRepository:@"/path/to/repo" error:&error]; // Read the current repository index GCIndex* index = [repo readRepositoryIndex:&error]; // Check index properties NSLog(@"Index is empty: %@", index.empty ? @"YES" : @"NO"); NSLog(@"Index has conflicts: %@", index.hasConflicts ? @"YES" : @"NO"); // Enumerate all files in the index [index enumerateFilesUsingBlock:^(NSString* path, GCFileMode mode, NSString* sha1, BOOL* stop) { NSLog(@"Indexed file: %@ (mode: %lu, sha1: %@)", path, (unsigned long)mode, sha1); }]; // Stage a file (git add) [repo addFileToIndex:@"README.md" error:&error]; // Stage multiple files [repo addFilesToIndex:@[@"file1.txt", @"file2.txt", @"src/main.m"] error:&error]; // Unstage a file (git reset HEAD) [repo resetFileInIndexToHEAD:@"README.md" error:&error]; // Discard changes in working directory (git checkout) [repo checkoutFileFromIndex:@"README.md" error:&error]; // Stage specific lines only (interactive staging like 'git add -p') [repo addLinesFromFileToIndex:@"main.m" error:&error usingFilter:^BOOL(GCLineDiffChange change, NSUInteger oldLineNumber, NSUInteger newLineNumber) { // Only stage additions in lines 10-20 return (change == kGCLineDiffChange_Added && newLineNumber >= 10 && newLineNumber <= 20); }]; // Unstage specific lines (like 'git reset -p') [repo resetLinesFromFileInIndexToHEAD:@"main.m" error:&error usingFilter:^BOOL(GCLineDiffChange change, NSUInteger oldLineNumber, NSUInteger newLineNumber) { return (newLineNumber >= 50 && newLineNumber <= 60); }]; // Reset entire index to HEAD [repo resetIndexToHEAD:&error]; // Sync entire working directory to index (git add -A) [repo syncIndexWithWorkingDirectory:&error]; // Handle conflicts if (index.hasConflicts) { [index enumerateConflictsUsingBlock:^(GCIndexConflict* conflict, BOOL* stop) { NSLog(@"Conflict at: %@ (status: %lu)", conflict.path, (unsigned long)conflict.status); // kGCIndexConflictStatus_BothModified, _BothAdded, _DeletedByUs, _DeletedByThem }]; // Resolve a conflict [repo resolveConflictAtPath:@"conflicted-file.txt" error:&error]; } ``` -------------------------------- ### Whitespace and Formatting Options Source: https://github.com/git-up/gitup/blob/master/GitUpKit/Views/en.lproj/GIConfigViewController-Help.txt Configuration options that control how Git handles whitespace and line endings. ```APIDOC ## Whitespace and Formatting Options ### Description Configuration options that control how Git handles whitespace and line endings. ### Options - **`space-before-tab`**: Treats a space character immediately before a tab character in the initial indent as an error (enabled by default). - **`indent-with-non-tab`**: Treats a line indented with spaces instead of tabs as an error (not enabled by default). - **`tab-in-indent`**: Treats a tab character in the initial indent as an error (not enabled by default). - **`blank-at-eof`**: Treats blank lines added at the end of the file as an error (enabled by default). - **`trailing-space`**: A shorthand for `blank-at-eol` and `blank-at-eof`. - **`cr-at-eol`**: Treats a carriage-return at the end of a line as part of the line terminator (not enabled by default). - **`tabwidth=`**: Specifies the number of character positions a tab occupies. Allowed values are 1 to 63. The default is 8. ```