messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge - Join two or more development histories together"
},
{
"role": "assistant",
"content": "PRE-MERGE CHECKS Before applying outside changes, you should get your own work in\ngood shape and committed locally, so it will not be clobbered if\nthere are conflicts. See also git-stash . git pull and git merge will stop without doing anything when\nlocal uncommitted changes overlap with files that git pull / git\nmerge may need to update. To avoid recording unrelated changes in the merge commit, git pull and git merge will also abort if there are any changes\nregistered in the index relative to the HEAD commit. (Special\nnarrow exceptions to this rule may exist depending on which merge\nstrategy is in use, but generally, the index must match HEAD.) If all named commits are already ancestors of HEAD , git merge will exit early with the message \"Already up to date.\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options mergetool.meld.hasOutput"
},
{
"role": "assistant",
"content": "Older versions of meld do not support the --output option.\nGit will attempt to detect whether meld supports --output by inspecting the output of meld --help . Configuring mergetool.meld.hasOutput will make Git skip these checks and\nuse the configured value instead. Setting mergetool.meld.hasOutput to true tells Git to unconditionally use the --output option,\nand false avoids using --output ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_NOGLOB_PATHSPECS"
},
{
"role": "assistant",
"content": "Setting this Boolean environment variable to true will cause Git to treat all\npathspecs as literal (aka \"literal\" magic)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git says a file is unmerged and I can't commit, but the file seems to be merged\nI had about 12 file conflicts when I merged branches. I manually fixed all the conflicts and staged the files. But now when I try to commit, it says one of the files is unmerged.\nU app/models/disclosure_event.rb\nfatal: 'commit' is not possible because you have unmerged files.\nPlease, fix them up in the work tree, and then use 'git add/rm <file>' as\nappropriate to mark resolution and make a commit, or use 'git commit -a'.\n\nWhen I type git status, it shows all the changed files, including \"disclosure_event.rb\", under Changes to be committed. It shows no files as unstaged. I've repeatedly tried to add the file, but it seems to do nothing. If I open the file, everything looks great.\nAny ideas? I'm completely stuck."
},
{
"role": "assistant",
"content": "I can't tell you what's wrong, but you might try\ngit reset app/models/disclosure_even.rb\ngit add app/models/disclosure_even.rb\n\nand then commit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-update-ref"
},
{
"role": "assistant",
"content": "Update the object name stored in a ref safely"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order %Cred"
},
{
"role": "assistant",
"content": "switch color to red"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git: check if commit xyz in remote repo?\nI have a commit xyz in my local branch that I want to check if it is included in a remote release repository; can I do that in some easy way? I could clone the remote repo, but I'm hoping for a nicer+faster way. git ls-remote seemed promising, but found nothing of value to me there. Thanks!"
},
{
"role": "assistant",
"content": "Let's suppose that the remote that refers to the remote repository is called origin. In that case, first update all your remote-tracking branches with:\ngit fetch origin\n\nNow you can use the useful --contains option to git branch to find out which of the remote branches contains that commit:\ngit branch -r --contains xyz\n\n(The -r means to only show remote-tracking branches.) If the commit xyz is contained in one or more of your remote-tracking branches, you'll see output like:\n origin/test-suite\n origin/HEAD -> origin/master\n origin/master\n\nIf it's contained in your local repository, but not one of the remote-tracking branches, the output will be empty. However, if that commit isn't known in your repository at all, you'll get the error malformed object name and a usage message - perhaps a bit confusing if you're not expecting it..."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Set Visual Studio Code to be global Git editor on OSX\nI want to set VS Code to be my default git editor for commands such as rebase. This doesn't seem to be documented on the VS Code website. I've found a SO question about doing it for Windows, which sounds like it has mixed success: How to use Visual Studio Code as Default Editor for Git\nHas anyone managed this on OSX?"
},
{
"role": "assistant",
"content": "This work for me.\n\nInstall \"code\" from VSCode commander (Shift + Command + P)\n\nSearch for:\n\nShell Command: Install 'code' command in 'PATH'\n\nInstall it.\nafter that… run commands on terminal for config git with new editor:\n$ git config --global core.editor \"code --wait\"\n$ git config --global -e"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git copy file preserving history [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nRecord file copy operation with Git\n\n (3 answers)\n \n\nClosed 4 years ago.\n\n\n\nI have a somewhat confusing question in Git.\nLets say, I have a file dir1/A.txt committed and git preserves a history of commits\nNow I need to copy the file into dir2/A.txt (not move, but copy).\nI know that there is a git mv command but I need dir2/A.txt to have the same history of commits as dir1/A.txt, and dir1/A.txt to still remain there.\nI'm not planning to update A.txt once the copy is created and all the future work will be done on dir2/A.txt\nI know it sounds confusing, I'll add that this situation is on java based module (mavenized project) and we need to create a new version of code so that our customers will have the ability to have 2 different versions in runtime, the first version will be removed eventually when the alignment will be done.\nWe can use maven versioning of course, I'm just newbie to Git and curious about what Git can provide here."
},
{
"role": "assistant",
"content": "All you have to do is:\n\nmove the file to two different locations,\nmerge the two commits that do the above, and\nmove one copy back to the original location.\n\nYou will be able to see historical attributions (using git blame) and full history of changes (using git log) for both files.\nSuppose you want to create a copy of file foo called bar. In that case the workflow you'd use would look like this:\ngit mv foo bar\ngit commit\n\nSAVED=`git rev-parse HEAD`\ngit reset --hard HEAD^\ngit mv foo copy\ngit commit\n\ngit merge $SAVED # This will generate conflicts\ngit commit -a # Trivially resolved like this\n\ngit mv copy foo\ngit commit\n\nWhy this works\nAfter you execute the above commands, you end up with a revision history that looks like this:\n( revision history ) ( files )\n\n ORIG_HEAD foo\n / \\ / \\\nSAVED ALTERNATE bar copy\n \\ / \\ /\n MERGED bar,copy\n | |\n RESTORED bar,foo\n\nWhen you ask Git about the history of foo, it will:\n\ndetect the rename from copy between MERGED and RESTORED,\ndetect that copy came from the ALTERNATE parent of MERGED, and\ndetect the rename from foo between ORIG_HEAD and ALTERNATE.\n\nFrom there it will dig into the history of foo.\nWhen you ask Git about the history of bar, it will:\n\nnotice no change between MERGED and RESTORED,\ndetect that bar came from the SAVED parent of MERGED, and\ndetect the rename from foo between ORIG_HEAD and SAVED.\n\nFrom there it will dig into the history of foo.\nIt's that simple. :)\nYou just need to force Git into a merge situation where you can accept two traceable copies of the file(s), and we do this with a parallel move of the original (which we soon revert)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show-ref - List references in a local repository"
},
{
"role": "assistant",
"content": "SYNOPSIS git show-ref [--head] [-d | --dereference]\n\t [-s | --hash[=<n>]] [--abbrev[=<n>]] [--tags]\n\t [--heads] [--] [<pattern>…] git show-ref --verify [-q | --quiet] [-d | --dereference]\n\t [-s | --hash[=<n>]] [--abbrev[=<n>]]\n\t [--] [<ref>…] git show-ref --exclude-existing[=<pattern>] git show-ref --exists <ref>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitLab Checking pipeline status - running forever\n\nI've enabled the option - Settings/General/Merge Requests/Merge Checks - Pipelines must succeed.\nSince then every merge requests automatically starts execution of the pipeline which is actually what i want. The problem is that this is running forever , i'm receiving message : Checking pipeline status\nIf i run the pipeline manually from CI/CD Pipelines - Run pipeline finish immediately. I don't understand what is wrong and why it stuck , can i check logs somewhere or something ?\nFor testing , the pipeline is really simple , just exit 1 .. but still not working ..\nAt this stage , \"running pipeline\" is not listed in pipeline list even if the status in merge request is\n\nChecking pipeline status"
},
{
"role": "assistant",
"content": "We ran into a case where a merge request does not contain the .gitlab-ci.yml file. The fix is simply to do a rebase\nFor troubleshooting purposes, pipelines can be run manually on particular branches at CI/CD -> Pipelines -> Run Pipeline"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index --no-color"
},
{
"role": "assistant",
"content": "Turn off colored diff.\nIt is the same as --color=never ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: renamed file manually, Git confused\nI am using Git and manually renamed a file that I had added to the repository. Now, I have added the \"new\" file which I renamed to the repository but Git complains that the \"old\" file has been deleted. So how can I make Git forget about the old file? Better yet, how do I tell Git that the \"new\" file really is the \"new\" file so that I can keep the change history intact?"
},
{
"role": "assistant",
"content": "There is no problem. Simply git rm old or even git add -A and it will realize that it is a rename. Git will see the delete plus the add with same content as a rename.\nYou don't need to undo, unstage, use git mv etc. git mv old new is only a short hand for mv old new; git rm old; git add new."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Converting a repository from git to subversion\nReasons for doing this aside, is there a reasonable way to convert an entire git repository to subversion?\nI can find only tons on information on migrating from subversion to git, and exchanging changesets between the two, but not for doing a simple conversion of the entire git repository to svn."
},
{
"role": "assistant",
"content": "The general problem with doing conversions this direction is that Git repositories can contain more than just a linear history of revisions, as Subversion would expect. Multiple ancestries with divergent histories and frequent merge commits are all possible, which can't be easily represented in a Subversion repository.\nFor simple cases where you do have a linear history in your Git repository, you can use git-svn dcommit to push the lot up to an otherwise empty Subversion repository."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why git says \"both modified\" when outputting git status after conflict?\nWhen having a conflict on a file while trying to merge in git, git says both modified on the file that has a conflict like this:\n$ git status\nOn branch master\nYou have unmerged paths.\n (fix conflicts and run \"git commit\")\n\nUnmerged paths:\n (use \"git add <file>...\" to mark resolution)\n\n both modified: file1\n\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nNot sure why exactly \"both modified\". Does anybody of you know?"
},
{
"role": "assistant",
"content": "This gets back to Git 1.6.5 (Oct. 2009) and commit 4d4d572, which introduced this more detailed message :\nstatus: show worktree status of conflicted paths separately\n\nWhen a path is unmerged in the index, we used to always say \"unmerged\" in the \"Changed but not updated\" section, even when the path was deleted in the work tree.\nRemove unmerged entries from the \"Updated\" section, and create a new section \"Unmerged paths\". Describe how the different stages conflict in more detail in this new section.\n\nAs you can see in this patch, \"both modified\" (in both parents) is not the only conflict case.\ncase 1: how = \"both deleted:\"; break;\ncase 2: how = \"added by us:\"; break;\ncase 3: how = \"deleted by them:\"; break;\ncase 4: how = \"added by them:\"; break;\ncase 5: how = \"deleted by us:\"; break;\ncase 6: how = \"both added:\"; break;\ncase 7: how = \"both modified:\"; break;\n\n\nYou see more cases in commit 173e6c8, with git status -s:\n\nFor unmerged entries, \n\nX shows the status of stage #2 (i.e. ours) and \nY shows the status of stage #3 (i.e. theirs).\n\n\nX Y Meaning\n-------------------------------------------------\nD D unmerged, both deleted\nA U unmerged, added by us\nU D unmerged, deleted by them\nU A unmerged, added by them\nD U unmerged, deleted by us\nA A unmerged, both added\nU U unmerged, both modified\n\nThat illustrates the fact an index in git has 3 stages (see \"How do I force git to think a file is unmerged?\")\n\nIn Git file that has a merge conflicts has (usually) three versions in index, and a version in working area with diff3 -E / rcsmerge conflict markers. \n\nThe versions in the index are stage 1 from common ancestor, \nstage 2 for \"our\" version, and\nstage 3 for \"theirs\" version. \n\nFor unmerged file there is no version in stage 0 \n\nHere, \"both modified\" is \"modified in 'ours' and 'theirs'."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to override a rule set in .gitignore\nIn .gitignore I have a rule that excludes a path settings.php\nHowever, that rule has to be disregarded (the file has to be included in git), but for special reasons (the .gitignore file gets frequently reset to default from outside) I prefer not to change the .gitignore itself, but rather to override it by setting a counter-rule in the core.excludesfile file.\nSo in the relevant core.excludesfile file I put: !settings.php to override the above rule.\nBut it does NOT work. I suspect that rules in .gitignore have priority over the ones in the global file with exclusions (this is how I understand https://www.kernel.org/pub/software/scm/git/docs/gitignore.html).\nIs there any way to override a rule set in .gitignore by a rule in core.excludesfile or elsewhere?"
},
{
"role": "assistant",
"content": "Yes! It turns out that when adding a file to a repository you can force it to override .gitignore:\ngit add -f <filename>\n\nor\n\ngit add --force <filename>\n\nSource: https://www.kernel.org/pub/software/scm/git/docs/git-add.html"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Pushing an existing Git repository to SVN\nI've been doing all my work in Git and pushing to GitHub. I've been very happy with both the software and the site, and I have no wish to change my working practices at this point.\nMy PhD adviser is asking all students to keep their work in an SVN repository that's hosted at the university. I've found tons of documentation and tutorials about to pull down an existing SVN repository into Git, but nothing about pushing a Git repository to a fresh SVN repository. I expect there must be some way to do this with a combination of git-svn and a fresh branch and rebasing and all those wonderful terms, but I'm a Git newbie and don't feel confident with any of them.\nI then want to just run a couple of commands to push commits to that SVN repository when I choose. I wish to keep using Git and just have the SVN repository mirror what's in Git.\nI'll be the only person ever committing to SVN, if this makes any difference."
},
{
"role": "assistant",
"content": "I needed this as well, and with the help of Bombe's answer + some fiddling around, I got it working. Here's the recipe:\nImport Git -> Subversion\n1. cd /path/to/git/localrepo\n2. svn mkdir --parents protocol:///path/to/repo/PROJECT/trunk -m \"Importing git repo\"\n3. git svn init protocol:///path/to/repo/PROJECT -s\n4. git svn fetch\n5. git rebase origin/trunk\n5.1. git status\n5.2. git add (conflicted-files)\n5.3. git rebase --continue\n5.4. (repeat 5.1.)\n6. git svn dcommit\n\nAfter #3 you'll get a cryptic message like this:\n\nUsing higher level of URL: protocol:///path/to/repo/PROJECT => protocol:///path/to/repo\n\nJust ignore that.\nWhen you run #5, you might get conflicts. Resolve these by adding files with state \"unmerged\" and resuming rebase. Eventually, you'll be done; then sync back to the SVN repository, using dcommit. That's all.\nKeeping repositories in sync\nYou can now synchronise from SVN to Git, using the following commands:\ngit svn fetch\ngit rebase trunk\n\nAnd to synchronise from Git to SVN, use:\ngit svn dcommit\n\nFinal note\nYou might want to try this out on a local copy, before applying to a live repository. You can make a copy of your Git repository to a temporary place; simply use cp -r, as all data is in the repository itself. You can then set up a file-based testing repository, using:\nsvnadmin create /home/name/tmp/test-repo\n\nAnd check a working copy out, using:\nsvn co file:///home/name/tmp/test-repo svn-working-copy\n\nThat'll allow you to play around with things before making any lasting changes.\nAddendum: If you mess up git svn init\nIf you accidentally run git svn init with the wrong URL, and you weren't smart enough to take a backup of your work (don't ask ...), you can't just run the same command again. You can however undo the changes by issuing:\nrm -rf .git/svn\nedit .git/config\n\nAnd remove the section [svn-remote \"svn\"] section.\nYou can then run git svn init anew."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to specify the private SSH-key to use when executing shell command on Git?\nA rather unusual situation perhaps, but I want to specify a private SSH-key to use when executing a shell (git) command from the local computer.\nBasically like this:\ngit clone [email protected]:TheUser/TheProject.git -key \"/home/christoffer/ssh_keys/theuser\"\n\nOr even better (in Ruby):\nwith_key(\"/home/christoffer/ssh_keys/theuser\") do\n sh(\"git clone [email protected]:TheUser/TheProject.git\")\nend\n\nI have seen examples of connecting to a remote server with Net::SSH that uses a specified private key, but this is a local command. Is it possible?"
},
{
"role": "assistant",
"content": "None of these solutions worked for me.\nInstead, I elaborate on @Martin v. Löwis 's mention of setting a config file for SSH.\nSSH will look for the user's ~/.ssh/config file. I have mine setup as:\nHost gitserv\n Hostname remote.server.com\n IdentityFile ~/.ssh/id_rsa.github\n IdentitiesOnly yes # see NOTES below\n AddKeysToAgent yes\n\nAnd I add a remote git repository:\ngit remote add origin git@gitserv:myrepo.git\n\n(or clone a fresh copy of the repo with git@gitserv:myrepo.git as address)\nAnd then git commands work normally for me.\ngit push -v origin master\n\nIf you have submodules, you can also execute the following in the repo directory, to force the submodules to use the same key:\ngit config url.git@gitserv:.insteadOf https://remote.server.com\n\nNOTES\n\nThe IdentitiesOnly yes is required to prevent the SSH default behavior of sending the identity file matching the default filename for each protocol. If you have a file named ~/.ssh/id_rsa that will get tried BEFORE your ~/.ssh/id_rsa.github without this option.\n\nAddKeysToAgent yes lets you avoid reentering the key passphrase every time.\n\nYou can also add User git to avoid writing git@ every time.\n\n\nReferences\n\nBest way to use multiple SSH private keys on one client\nHow could I stop ssh offering a wrong key"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to revert a folder to a particular commit\nHere's my history for the folder 'somefolder'\n$ git log somefolder\n\ncommit 89cd\nMore changes to somefolder\n\ncommit ef47a\nUpdating somefolder and other stuff\n\ncommit e095\nBugs fixed in somefolder\n\nI want to revert somefolder back to the 'Bugs fixed in some folder\" commit.\nSince the second commit involved changes outside of somefolder, I don't want to revert this commit. \nI guess the safest way would be to create a diff/patch between commit e095 and 89cd that applies just to some folder, and then apply that patch. How can I do that?"
},
{
"role": "assistant",
"content": "You can use git checkout to update your repository to a specific state.\ngit checkout e095 -- somefolder\n\nAs for your question about generating the diff, that would work too. Just generate the diff to go from your current state back to e095:\ngit diff 89cd..e095 -- somefolder"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Untrack and stop tracking files in git\nI have a deep subfolder called objects with files called *.object which I don't want tracked by git (Windows).\nIn .gitignore I have tried various combinations (e.g. **/objects/* or **/objects/* etc.) to no avail: each time, when I do git status I see:\n# Untracked files:\n# (use \"git add <file>...\" to include in what will be committed)\n#\n# foo/src/objects/a.object\n# foo/src/objects/b.object\n\nIt is only when I add *.object to .gitignore that the files disappear from the untracked files list. What's wrong with my wild cards?\nAlso, when is git update-index required and when should I do git rm --cached myfile?\nIs there a wildcard feature for rm like git rm --cached **/foo/*.zip?\nUPDATE: Similarly, adding the line .gitignore to .gitignore (not always desirable but still) has no effect. Is this weirdness because the files may have been tracked in the past?"
},
{
"role": "assistant",
"content": "OK, though wildcards don't work (in Windows apparently) it seems one can remove a whole folder with:\ngit rm -r --cached \"path/to/foo/\"\n\nI understand that --cached only unstages - you have to git commit to remove them from the repo."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gittutorial - A tutorial introduction to Git"
},
{
"role": "assistant",
"content": "DESCRIPTION This tutorial explains how to import a new project into Git, make\nchanges to it, and share changes with other developers. If you are instead primarily interested in using Git to fetch a project,\nfor example, to test the latest version, you may prefer to start with\nthe first two chapters of The Git User’s Manual . First, note that you can get documentation for a command such as git log --graph with: $ man git-log or: $ git help log With the latter, you can use the manual viewer of your choice; see git-help for more information. It is a good idea to introduce yourself to Git with your name and\npublic email address before doing any operation. The easiest\nway to do so is: $ git config --global user.name \"Your Name Comes Here\"\n$ git config --global user.email [email protected]"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-shortlog - Summarize git log output --branches[=<pattern>]"
},
{
"role": "assistant",
"content": "Pretend as if all the refs in refs/heads are listed\non the command line as <commit> . If <pattern> is given, limit\nbranches to ones matching given shell glob. If pattern lacks ? , * , or [ , /* at the end is implied."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitrevisions - Specifying revisions and ranges for Git [<branchname>]@{upstream} , e.g. master@{upstream} , @{u}"
},
{
"role": "assistant",
"content": "A branch B may be set up to build on top of a branch X (configured with branch.<name>.merge ) at a remote R (configured with branch.<name>.remote ). B@{u} refers to the remote-tracking branch for\nthe branch X taken from remote R, typically found at refs/remotes/R/X ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-branch - List, create, or delete branches --merged [<commit>]"
},
{
"role": "assistant",
"content": "Only list branches whose tips are reachable from the\nspecified commit (HEAD if not specified). Implies --list ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-for-each-ref - Output information on each ref signature:trustlevel"
},
{
"role": "assistant",
"content": "The trust level of the GPG signature of a commit. Possible\noutputs are ultimate , fully , marginal , never and undefined ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --color-words[=<regex>]"
},
{
"role": "assistant",
"content": "Equivalent to --word-diff=color plus (if a regex was\nspecified) --word-diff-regex=<regex> ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What does it mean to squash commits in git?\n\nWhat does Squashing commits in git mean. How do I squash commits in Github?"
},
{
"role": "assistant",
"content": "You can think of Git as an advanced database of snapshots of your working directory(ies).\nOne very nice feature of Git is the ability to rewrite the history of commits.\nThe principal reason for doing this is that a lot of such history is relevant only for the developer who generated it, so it must be simplified, or made more nice, before submitting it to a shared repository.\nSquashing a commit means, from an idiomatic point of view, to move the changes introduced in said commit into its parent so that you end up with one commit instead of two (or more).\nIf you repeat this process multiple times, you can reduce n commit to a single one.\nVisually, if you started your work at the commit tagged Start, you want this\n\nYou may notice that the new commit has a slightly darker shade of blue. This is intentional.\nIn Git squashing is achieved with a Rebase, of a special form called Interactive Rebase.\nSimplifying: when you rebase a set of commits into a branch B, you apply all the changes introduced by those commits as they were done, starting from B instead of their original ancestor.\nA visual clue\n\nNote again the different shades of blue.\nAn interactive rebase let you choose how commits should be rebased.\nIf you run this command:\n git rebase -i branch\n\nYou would end up with a file that lists the commits that will be rebased\n pick ae3...\n pick ef6...\n pick 1e0...\n pick 341...\n\nI didn't name the commits, but these four ones are intended to be the commits from Start to Head\nThe nice thing about this list is that it is editable.\nYou can omit commits, or you can squash them.\nAll you have to do is to change the first word to squash.\n pick ae3...\n squash ef6...\n squash 1e0...\n squash 341...\n\nIf you close the editor and no merge conflicts are found, you end up with this history:\n\nIn your case, you don't want to rebase into another branch, but rather into a previous commit.\nIn order to transform the history as shown in the very first example, you have to run something like\ngit rebase -i HEAD~4\n\nchange the \"commands\" to squash for all the commits apart from the first one, and then close your editor.\n\nNote about altering history\nIn Git, commits are never edited. They can be pruned, made not reachable, cloned but not changed.\nWhen you rebase, you are actually creating new commits.\nThe old ones are not longer reachable by any refs, so are not shown in the history but they are still there!\nThis is what you actually get for a rebase:\n\nIf you have already pushed them somewhere, rewriting the history will actually make a branch!"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-filter-branch - Rewrite branches --env-filter <command>"
},
{
"role": "assistant",
"content": "This filter may be used if you only need to modify the environment\nin which the commit will be performed. Specifically, you might\nwant to rewrite the author/committer name/email/time environment\nvariables (see git-commit-tree for details)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to set up your avatar in SourceTree.app?\nI saw other people's image appears to the right of the commit message. How to set up that?\nedit:\nThe GUI tools I am using is the SourceTree mac version."
},
{
"role": "assistant",
"content": "Go to http://en.gravatar.com/ create your account and upload the avatar image files that map to your emails.\nClose Source Tree\nDelete the cache file (or delete all files) inside path \n\n\n%USERPROFILE%\\AppData\\Local\\Atlassian\\SourceTree\\cache\\img\n\ne.g. C:\\Users\\MYUSERNAME\\AppData\\Local\\Atlassian\\SourceTree\\cache\\img\n\nOpen Source Tree. Now you got what you want!"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I remove a commit on GitHub? [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\n\nUndoing a 'git push'\n\n (17 answers)\n \n\nClosed 4 years ago.\nThe community reviewed whether to reopen this question 8 months ago and left it closed:\n\nOriginal close reason(s) were not resolved\n\n\n\n\nI \"accidentally\" pushed a commit to GitHub.\nIs it possible to remove this commit?\nI want to revert my GitHub repository as it was before this commit."
},
{
"role": "assistant",
"content": "Note: please see an alternative to git rebase -i in the comments below—\ngit reset --soft HEAD^\n\nFirst, remove the commit on your local repository. You can do this using git rebase -i. For example, if it's your last commit, you can do git rebase -i HEAD~2 and delete the second line within the editor window that pops up.\nThen, force push to GitHub by using git push origin +branchName --force\nSee Git Magic Chapter 5: Lessons of History - And Then Some for more information (i.e. if you want to remove older commits).\nOh, and if your working tree is dirty, you have to do a git stash first, and then a git stash apply after."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options gui.newBranchTemplate"
},
{
"role": "assistant",
"content": "Is used as a suggested name when creating new branches using the git-gui ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index --ignore-submodules[=<when>]"
},
{
"role": "assistant",
"content": "Ignore changes to submodules in the diff generation. <when> can be\neither \"none\", \"untracked\", \"dirty\" or \"all\", which is the default.\nUsing \"none\" will consider the submodule modified when it either contains\nuntracked or modified files or its HEAD differs from the commit recorded\nin the superproject and can be used to override any settings of the ignore option in git-config or gitmodules . When\n\"untracked\" is used submodules are not considered dirty when they only\ncontain untracked content (but they are still scanned for modified\ncontent). Using \"dirty\" ignores all changes to the work tree of submodules,\nonly changes to the commits stored in the superproject are shown (this was\nthe behavior until 1.7.0). Using \"all\" hides all changes to submodules."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why can't I create an empty Pull Request for discussion prior to developing changes?\nI want to branch from master and immediately create an empty Pull Request to discuss implementation details of a specific feature.\nAfter selecting my branch and clicking \"Pull Request\", Github claims \"Nothing to Compare\" and doesn't offer any \"Create Pull Request\" button.\nGithub's own documentation on Flow states (click the right-arrow twice):\n\nYou can open a Pull Request at any point during the development process: when you have little or no code but want to share some screenshots or general ideas, when you're stuck and need help or advice, or when you're ready for someone to review your work.\n\nBut their own documentation on Pull Requests here states:\n\nPull requests can only be opened if there are differences between your branch and the upstream branch\n\nI would like to utilise Github collaboration features with my team prior to committing changes to code. As we understand it, Pull Requests are for code changes and discussion of implementation details (ie: the \"solution\"), while Issues are higher level, for discussing features/bugs (ie: the \"problem\").\nAm I misunderstanding these things?\nEdit:\nApparently I can circumvent the process by changing the branch with an empty commit:\n\ngit commit --allow-empty -m \"make pull request\"\n\nbut I am trying to better understand why my (default) decision to create an empty PR was wrong in the first place, and why their documentation appears contradictory. Is there a strict \"discuss code explicitly in PRs\" policy or similar? Is this a contentious issue?\nUpdate\nGithub have released Draft Pull Requests, but (alas) they can't be created if the 2 branches are identical."
},
{
"role": "assistant",
"content": "The documentation talking about \"no code\" dates from... December 2013:\n\nIt is possible they changed their policy in the official documentation, which is up-to-date and apply to github.com as well as GitHub Enterprise.\nSo you might want to contact GitHub support to mention this inaccuracy."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "[email protected]: Permission denied (publickey)\n\nI created a new remote repository and tried to use git push -u origin master command to push my local files into the new repository the first time after I add it and commit it. However, it pops up this [email protected]: Permission denied (publickey). fatal: Could not read from remote repository.. How can I fix this fatal error?\nI've tried this\nHow to solve Permission denied (publickey) error when using Git?\nIt seems that the question in this link happens in the first time using git. I've used my git for a while, do I still need to follow this solution? Can anyone gives me a more specific solution? \nThis the fatal error that I got\nC:\\Users\\ASUS\\Desktop\\React-Practice App\\my-app>git status\nOn branch master\nnothing to commit, working tree clean\n\nC:\\Users\\ASUS\\Desktop\\React-Practice App\\my-app>git push -u origin master\n[email protected]: Permission denied (publickey).\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists."
},
{
"role": "assistant",
"content": "You’re accessing GitHub through SSH. First generate an SSH key pair; then add the public key to GitHub.\nGenerate key pair, github prefers the \"Ed25519 algorithm\"\nssh-keygen -t ed25519 -C \"[email protected]\"\n\nIt still allows using rsa for systems that don't support Ed25519\nssh-keygen -t rsa -b 4096 -C “[email protected]”\n\nSee more at https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent and https://help.github.com/en/articles/adding-a-new-ssh-key-to-your-github-account"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitHub - Pull changes from a template repository\n\nI have created a Template Repository in GitHub and then created some repositories based on the template. Since they were created, there have been updates to the template that I want to pull into those repositories.\nIs this possible?"
},
{
"role": "assistant",
"content": "On the other repositories you have to add this template repository as a remote.\ngit remote add template [URL of the template repo]\n\nThen run git fetch to update the changes\ngit fetch --all\n\nThen is possible to merge another branch from the new remote to your current one.\ngit merge template/[branch to merge] --allow-unrelated-histories\n\nhttps://help.github.com/en/articles/adding-a-remote"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Steps to Troubleshoot \"django.db.utils.ProgrammingError: permission denied for relation django_migrations\"\n\nWhat are some basic steps for troubleshooting and narrowing down the cause of the Django error:\ndjango.db.utils.ProgrammingError: permission denied for relation django_migrations\n\nI'm getting this message after what was initially a stable production server but has since had some changes to several aspects of Django, Postgres, Apache, and a pull from Github. In addition, it has been some time since those changes were made. I don't recall or can't track every change that may be causing the problem.\nI get the message when I run python manage.py runserver or any other python manage.py ... command except python manage.py check, which states the system is good."
},
{
"role": "assistant",
"content": "I was able to solve my issue based on instructions from this question. Basically, postgres privileges needed to be re-granted to the db user. In my case, that was the user I had setup in the virtual environment settings file. Run the following from the commandline (or within postgres) where mydatabase and dbuser should be your own database and user names: \npsql mydatabase -c \"GRANT ALL ON ALL TABLES IN SCHEMA public to dbuser;\"\npsql mydatabase -c \"GRANT ALL ON ALL SEQUENCES IN SCHEMA public to dbuser;\"\npsql mydatabase -c \"GRANT ALL ON ALL FUNCTIONS IN SCHEMA public to dbuser;\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-replace"
},
{
"role": "assistant",
"content": "Create, list, delete refs to replace objects"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I delete all of my Git stashes at once?\nHow can I delete all of my Git stashes at once?\nSpecifically I mean, with typing in one command."
},
{
"role": "assistant",
"content": "The following command deletes all your stashes:\ngit stash clear\n\nFrom the git documentation:\n\nclear\nRemove all the stashed states.\nIMPORTANT WARNING: Those states will then be subject to pruning, and may be impossible to recover (...)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "firebase deploy error, Error: Failed to list functions for (project name)\n\nI am hosting my web application in Firebase and I have been deploying it with Gitlab CI/CD and it has been working just fine! But today for some reason I am getting this error when the pipeline is working\n56Error: Failed to list functions for project-name\nThis is the command that I run in the pipeline\n firebase deploy --only hosting --non-interactive --token $FIREBASE_TOKEN\nThis is the error I am getting\ndeploying hosting\n50i hosting[project-name]: beginning deploy...\n51i hosting[project-name]: found 39 files in dist/dev\n52i hosting: hashing files [34/39] (87%)\n53i hosting: upload complete\n54✔ hosting[project-name]: file upload complete\n55i hosting[project-name]: finalizing version...\n56Error: Failed to list functions for project-name\n\nKindly note that the command is working up to the point where it says \"finalizing version...\" then it stops.\nWhat could be causing this error?"
},
{
"role": "assistant",
"content": "My firebase tools version was 11.14.0. I changed that to 11.13.0. Installed this specific version through npm install -g [email protected]. After that, I could successfully deploy."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to see what type of line endings are already in git repository?\nFirst of all, I'm not asking what does it mean or how to change it. The thing what interest me most is: how can I see what's already in repo? What type of line endings.\nI have my repositories on github and bitbucket.\nThanks for help"
},
{
"role": "assistant",
"content": "You can use this command:\ngit ls-files --eol\n\nIt will output one line per file with the following information:\ni/lf w/crlf attr/text=auto eol=lf file.txt\n\nIn that example, i/lf means that the file uses lf in the index, and w/crlf means it uses crlf in the working directory."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --color-moved-ws=<modes>"
},
{
"role": "assistant",
"content": "This configures how whitespace is ignored when performing the\nmove detection for --color-moved .\nIt can be set by the diff.colorMovedWS configuration setting.\nThese modes can be given as a comma separated list: no Do not ignore whitespace when performing move detection. ignore-space-at-eol Ignore changes in whitespace at EOL. ignore-space-change Ignore changes in amount of whitespace. This ignores whitespace\nat line end, and considers all other sequences of one or\nmore whitespace characters to be equivalent. ignore-all-space Ignore whitespace when comparing lines. This ignores differences\neven if one line has whitespace where the other line has none. allow-indentation-change Initially ignore any whitespace in the move detection, then\ngroup the moved code blocks only into a block if the change in\nwhitespace is the same per line. This is incompatible with the\nother modes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc git diff [<options>] <commit> <commit>… <commit> [--] [<path>…]"
},
{
"role": "assistant",
"content": "This form is to view the results of a merge commit. The first\nlisted <commit> must be the merge itself; the remaining two or\nmore commits should be its parents. Convenient ways to produce\nthe desired set of revisions are to use the suffixes ^@ and ^! . If A is a merge commit, then git diff A A^@ , git diff A^! and git show A all give the same combined diff."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to know the git username and email saved during configuration?\nWhile configuring git I ran these two commands:\ngit config --global user.name \"My Name\"\n\ngit config --global user.email \"[email protected]\"\n\nHowever, I doubt whether I made a typo or not. So, is there any command to know the name and email which git saved during configuration? Obviously, I can know that using the git log command by looking at the commit history. But for that I have to make commits, right? Can I know that with the help of command line?"
},
{
"role": "assistant",
"content": "The command git config --list will list the settings. There you should also find user.name and user.email."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order --max-age=<timestamp> --min-age=<timestamp>"
},
{
"role": "assistant",
"content": "Limit the commits output to specified time range."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git: dangling blobs\nI recently ran git fsck --lost-found on my repository. \nI expected to see a couple dangling commits, where I had reset HEAD.\nHowever, I was surprised to see likely over several thousand dangling blob messages.\nI don't believe anything is wrong with my repository, but I'm curious as to what causes these dangling blobs? There's only two people working on the repository, and we haven't done anything out of the ordinary.\nI wouldn't think they were created by an older version of a file being replaced by a new one, since git would need to hold onto both blobs so it can display history.\nCome to think of it, at one point we did add a VERY large directory (thousands of files) to the project by mistake and then remove it. Might this be the source of all the dangling blobs?\nJust looking for insight into this mystery."
},
{
"role": "assistant",
"content": "Last time I looked at this I stumbled across this thread, specifically this part:\n\nYou can also end up with dangling objects in packs. When that pack is\n repacked, those objects will be loosened, and then eventually expired\n under the rule mentioned above. However, I believe gc will not always\n repack old packs; it will make new packs until you have a lot of packs,\n and then combine them all (at least that is what \"gc --auto\" will do; I\n don't recall whether just \"git gc\" follows the same rule).\n\nSo it's normal behavior, and does get collected eventually, I believe.\nedit: Per Daniel, you can immediately collect it by running\ngit gc --prune=\"0 days\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.<driver>.cachetextconv"
},
{
"role": "assistant",
"content": "Set this option to true to make the diff driver cache the text\nconversion outputs. See gitattributes for details. araxis bc codecompare deltawalker diffmerge diffuse ecmerge emerge examdiff guiffy gvimdiff kdiff3 kompare meld nvimdiff opendiff p4merge smerge tkdiff vimdiff winmerge xxdiff"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is GitHub's public GPG key?\n\nIf you make an edit through GitHub's website, or merge a pull request, then the resulting commits are automatically signed with GitHub's GPG key. It looks like this:\n\nI would like to have the full public key so that I can add it as a trusted key on my system. What is GitHub's public GPG key?"
},
{
"role": "assistant",
"content": "GitHub sets the committer for all commits made using their web interface to the user web-flow.\nFor any given GitHub account, you can add .gpg to its URL to get its public key—so for web-flow, you can find it at https://github.com/web-flow.gpg:\n-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nxsBNBFmUaEEBCACzXTDt6ZnyaVtueZASBzgnAmK13q9Urgch+sKYeIhdymjuMQta\nx15OklctmrZtqre5kwPUosG3/B2/ikuPYElcHgGPL4uL5Em6S5C/oozfkYzhwRrT\nSQzvYjsE4I34To4UdE9KA97wrQjGoz2Bx72WDLyWwctD3DKQtYeHXswXXtXwKfjQ\n7Fy4+Bf5IPh76dA8NJ6UtjjLIDlKqdxLW4atHe6xWFaJ+XdLUtsAroZcXBeWDCPa\nbuXCDscJcLJRKZVc62gOZXXtPfoHqvUPp3nuLA4YjH9bphbrMWMf810Wxz9JTd3v\nyWgGqNY0zbBqeZoGv+TuExlRHT8ASGFS9SVDABEBAAHNNUdpdEh1YiAod2ViLWZs\nb3cgY29tbWl0IHNpZ25pbmcpIDxub3JlcGx5QGdpdGh1Yi5jb20+wsBiBBMBCAAW\nBQJZlGhBCRBK7hj4Ov3rIwIbAwIZAQAAmQEIACATWFmi2oxlBh3wAsySNCNV4IPf\nDDMeh6j80WT7cgoX7V7xqJOxrfrqPEthQ3hgHIm7b5MPQlUr2q+UPL22t/I+ESF6\n9b0QWLFSMJbMSk+BXkvSjH9q8jAO0986/pShPV5DU2sMxnx4LfLfHNhTzjXKokws\n+8ptJ8uhMNIDXfXuzkZHIxoXk3rNcjDN5c5X+sK8UBRH092BIJWCOfaQt7v7wig5\n4Ra28pM9GbHKXVNxmdLpCFyzvyMuCmINYYADsC848QQFFwnd4EQnupo6QvhEVx1O\nj7wDwvuH5dCrLuLwtwXaQh0onG4583p0LGms2Mf5F+Ick6o/4peOlBoZz48=\n=HXDP\n-----END PGP PUBLIC KEY BLOCK-----\n\nYou can then import and trust that public key.\nAs shown in this thread:\n$ curl https://github.com/web-flow.gpg | gpg --import\n$ gpg --edit-key [email protected]\ngpg> trust\ngpg> save\n$ gpg --lsign-key [email protected]"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --single-worktree"
},
{
"role": "assistant",
"content": "By default, all working trees will be examined by the\nfollowing options when there are more than one (see git-worktree ): --all , --reflog and --indexed-objects .\nThis option forces them to examine the current working tree\nonly."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to sync with a remote Git repository?\nI forked a project on github, made some changes, so far so good.\nIn the meantime, the repository I forked from changed and I would like to get those changes into my repository. How do I do that ?"
},
{
"role": "assistant",
"content": "Generally git pull is enough, but I'm not sure what layout you have chosen (or has github chosen for you)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %s"
},
{
"role": "assistant",
"content": "subject"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-pull - Fetch from and integrate with another repository or a local branch --porcelain"
},
{
"role": "assistant",
"content": "Print the output to standard output in an easy-to-parse format for\nscripts. See section OUTPUT in git-fetch for details. This is incompatible with --recurse-submodules=[yes|on-demand] and takes\nprecedence over the fetch.output config option."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-add - Add file contents to the index --no-warn-embedded-repo"
},
{
"role": "assistant",
"content": "By default, git add will warn when adding an embedded\nrepository to the index without using git submodule add to\ncreate an entry in .gitmodules . This option will suppress the\nwarning (e.g., if you are manually performing operations on\nsubmodules)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git credential helper - update password\nI'm currently using GitHub over HTTPS and have the latest version of Git installed (1.9.0) along with the Git credential helper on Windows 7.\nOn setting up my environment, I told git-credentials to permanently remember my username and password.\nI've recently updated my GitHub password via the website and I'm now no longer able to push/pull/fetch, etc. \nHow I would go about updating my password on git-credentials helper on Windows 7?"
},
{
"role": "assistant",
"content": "None of these answers ended up working for my Git credential issue. Here is what did work if anyone needs it (I'm using Git 1.9 on Windows 8.1).\nTo update your credentials, go to Control Panel → Credential Manager → Generic Credentials. Find the credentials related to your Git account and edit them to use the updated password.\nReference: How to update your Git credentials on Windows\nNote that to use the Windows Credential Manager for Git you need to configure the credential helper like so:\ngit config --global credential.helper wincred\n\nIf you have multiple GitHub accounts that you use for different repositories, then you should configure credentials to use the full repository path (rather than just the domain, which is the default):\ngit config --global credential.useHttpPath true"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge-base - Find as good common ancestors as possible for a merge"
},
{
"role": "assistant",
"content": "NAME git-merge-base - Find as good common ancestors as possible for a merge"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-check-ref-format"
},
{
"role": "assistant",
"content": "Ensures that a reference name is well formed"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to rebase all the commits from the beginning\n\nSo I'm migrating from svn (code.google.com) to git(github).\nI've imported my project from the svn repo, and it imported all the commit history along way.\nI'm not really proud of those comments as it was one of my first project, not really serious.\nI'd like to rebase everything into a single 'initial import' commit.\nI've pulled everything on my computer and I'm trying to do that. But all I found was: \ngit rebase -i master but it only rebases new modifications and commits.\nHow can I clean my github repository from all history with a rebase?"
},
{
"role": "assistant",
"content": "git rebase -i --root will start an interactive rebase of all commits from the beginning.\nFrom there, you can squash all commits into one and/or perform other edits."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why does git merge sometimes create a commit, sometimes does not?\nWhen I do git merge from another branch to current workspace, git sometimes makes a new commit:\nMerge remote-tracking branch xxx into xxx\n\nSometimes, it does not:\nFast-forward\n... src files ...\n\nSo what determines whether a commit should be created or not?"
},
{
"role": "assistant",
"content": "So-called \"Fast-forward\" merges don't produce a commit, whereas other merges (often refered to as \"octopus merge\" (now you see why github's mascott is an octocat)) produce commits.\nBasically, a Fast-forward happens when your branches did not diverge.\nSay you want to merge a branch foo in the master branch. If these branches did not diverge, you would have an history like this (each * represents a commit):\n*---* (master)\n \\\n *---*---* (foo)\n\nIn this situation, the merge is fast-forward because (according to the graph theory, which is the underlying foundation of a git graph), master is reachable from foo. In other words, you just have to move the master reference to foo, and you're done:\n*---*\n \\\n *---*---* (master, foo)\n\nWhen your branches diverge:\n*---*---* (master)\n \\\n *---*---* (foo)\n\nYou have to create a commit to \"join\" the two branches:\n ↓\n*---*---*-------* (master)\n \\ / \n *---*---* (foo)\n\nThe commit pointed by the arrow is the merge commit and has two parent commits (the former master branch tip, and the current foo branch tip).\nNote that you can force Git to create a merge commit for a fast-forward merge with the --no-ff option.\nI highly recommend reading http://think-like-a-git.net/ for a good understanding of how the graph theory applies to git (you don't need to know the graph theory, everything you need to know is on the website), which will make working with Git incredibly easier :)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is there a way to display all sub wikis in an index page in gitlab?\n\nSo in gitlab you can use [[_TOC_]] to display a table of contents for the current page - which works on headings.\nBut I want to have a heirachy in my wiki like:\n<home-url>/Project1\n<home-url>/Project1/Tools\n<home-url>/Project1/Debugging\n<home-url>/Project1/Debugging/GDB\n<home-url>/Project1/Debugging/MSVS\n\nSuch that in the Project1 page I get an index (links) to each section similar to the table of contents layyout - e.g.:\n - Tools\n - Debugging\n - GDB\n - MSVS\n\nI can do this manually, but that's a pain to maintain. Is there some automatic tool to do this for me like TOC?"
},
{
"role": "assistant",
"content": "Thanks to VonC for the actual answer - i.e. there is not such a feature at the moment (well, not quite as I want it) - but there is the side bar in gitlab wiki which shows you the pages within your wiki.\nIf you structure you wiki into folders and subfolders then you can navigate with this side bar \"tree\". Its not collapseable - so its just a bog-roll off text, but it is indented to aid navigation.\nIt works well enough for simple wikis with a few dozen pages - but probably if there are hundreds of pages it might start to breakdown - at that point you might want to break your wiki up into several wikis with a top-level links page or some such.\nHere is (a crap) picture - it was the best I could see on google without looking too hard see here\n\nYou get this for free (without doing anything) so its decent for most cases."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc git-diff-index <tree-ish>"
},
{
"role": "assistant",
"content": "compares the <tree-ish> and the files on the filesystem."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Differences between Commit, Commit and Push, Commit and Sync\n\nI'm using visual studio 2013, and I'm faced with 3 options for when I commit my C# code. I need an explanation of the differences between each of the options with regards to what happens to my local repo vs. the GitHub repo. \n\nOption 1 says Commit\nOption 2 says Commit and Push\nOption 3 says Commit and Sync\n\nI don't quite understand the difference between the last 2 options. When should I use Commit and Sync as opposed to Commit and Push?"
},
{
"role": "assistant",
"content": "Commit will simply make record of your changes that you have made on your local machine. It will not mark the change in the remote repository.\nCommit and Push will do the above and push it to the remote repository. This means that any changes you have made will be saved to the remote repository as well.\nCommit and Sync does three things. First, it will commit. Second, it will perform a pull (grabs the updated information from the remote repo). Finally, it will push.\n\nSee more from Microsoft here"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - apply a commit on another branch to the working copy / Share content between branches and repositories\nSo I have a commit that has a helpful code change but it's on another branch.\nI would like to apply this commit in the other branch to my working copy on my current branch (not as another commit).\nIs this possible? How would I do this?\nThought I'd share this is related to my previous question but specific to working copy:\ngit cherry picking one commit to another branch"
},
{
"role": "assistant",
"content": "How to add the desired commit(s) into different branches.\ngit cherry-pick <SHA-1>...<SHA-1> --no-commit\n\nApply the change introduced by the commit(s) at the tip of the master branch and create a new commit(s) with this change.\n\nThe syntax of the ... is a commit range. grab all commits from start (exclude) to the last one. If you want a single commit to use a single SHA-1\n\n\ncherry-pick without commiting\nBy default git cherry-pick commit your changes, so if you wish to cherry-pick without committing all the changes simply add the -n flag\nThis will allow you to review the changes and commit them manually if you wish or abort it if you run into too many conflicts.\ngit cherry-pick -n <hash>\n\n\ncherry-pick a merge commit\nIn case you needed to cherry-pick a merge instead of a commit, use the -m flag\n#\n# In this case, we select the [1] first parent in the commit\n# Use git show <hash> to see a list of available parents\n# \ngit cherry-pick -m 1 <hash> \n\n\nRead out the full git cherry-pick documentation for all the options you can use"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Remove an Existing File from a Git Repo\nI want git to stop tracking my local development log (log/development.log) in our repositories. Is this possible and how can I do it?"
},
{
"role": "assistant",
"content": "Just to give the full answer all at once:\n\nfrom klemens: You need to add the file to your .gitignore file somewhere above the undesired file in the repo. i.e.\n$ cd \n$ cat >> .gitignore\ndevelopment.log\nC-d\nfrom m. narebski: You then need to remove the file from the repo by executing \"git rm --cached <file> and then committing this removal\"\n\nIf you were also hoping to make the repo look as if it had never tracked that file, that is much more complicated and highly discouraged as it not only creates brand new commits for every single commit in your history, thus destroying interoperability in a nasty way between other people who have cloned your repo, but it also leaves every one of those commits untested (assuming you test your commits before making them).\nWith that caveat in mind, the tool you're looking for if that's your goal is filter-branch. The first example does exactly what I'm describing."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options trace2.normalTarget"
},
{
"role": "assistant",
"content": "This variable controls the normal target destination.\nIt may be overridden by the GIT_TRACE2 environment variable.\nThe following table shows possible values."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Display JavaDocs on GitHub\n\nI'm looking for a way to convert the javadocs from my open source project (generated in Eclipse) to GitHub MarkDown, or come up with some other simple solution to display my documentation on GitHub (shy of simply adding a docs directory). Is there a simple solution for this? Can I simply point the GitHub README.md to my docs directory? Is there something more elegant? I have been striking out on Google."
},
{
"role": "assistant",
"content": "I don't think it's possible to make a usable Javadoc with MarkDown. The best solution is probably to commit the Javadoc you generated on the gh-pages branch (or in the docs/ directory depending on the settings of your GitHub project). It will be available at :\nhttp://username.github.io/projectname\nHere is an example from one of my projects:\nhttp://ebourg.github.io/jsign/apidocs/\nI used to do this but nowadays I just rely on javadoc.io to host the Javadoc:\nhttps://javadoc.io/doc/net.jsign/jsign/\nThe documentation is picked automatically from Maven Central, this saves the extra step of commiting the files into the Git repository when preparing a new release."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "npm install private github repositories by dependency in package.json\n\nI'm trying to install github private repository by npm that includes other private github repositories as dependency.\nHave tried a lot of ways and posts but none is working. Here is what i'm doing :\nnpm install git+https://github.com/myusername/mygitrepository.git\n\nin package.json is like : \n\"dependencies\": {\n \"repository1name\": \"git+https://github.com/myusername/repository1.git\",\n \"repository2name\": \"git+https://github.com/myusername/repository2.git\"\n}\n\nWhat is the the right way to do it?"
},
{
"role": "assistant",
"content": "Try this:\n\"dependencies\" : {\n \"name1\" : \"git://github.com/user/project.git#commit-ish\",\n \"name2\" : \"git://github.com/user/project.git#commit-ish\"\n}\n\nYou could also try this, where visionmedia/express is name/repo:\n\"dependencies\" : {\n \"express\" : \"visionmedia/express\"\n}\n\nOr (if the npm package module exists):\n\"dependencies\" : {\n \"name\": \"*\"\n}\n\nTaken from NPM docs"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Making 'git log' ignore changes for certain paths\nHow can I make git log only show commits that changed files other than the ones I specify?\nWith git log, I can filter the commits I see to those that touch a given set of paths. What I want is to invert that filter so that only commits that touch paths other than the specified ones will be listed.\nI can get what I want with\ngit log --format=\"%n/%n%H\" --name-only | ~/filter-log.pl | git log --stdin --no-walk\n\nwhere filter-log.pl is:\n#!/usr/bin/perl\nuse strict;\nuse warnings;\n\n$/ = \"\\n/\\n\";\n<>;\n\nwhile (<>) {\n my ($commit, @files) = split /\\n/, $_;\n\n if (grep { $_ && $_ !~ m[^(/$|.etckeeper$|lvm/(archive|backup)/)] } @files) {\n print \"$commit\\n\";\n }\n}\n\nexcept I want something somewhat more elegant than that.\nNote that I am not asking how to make git ignore the files. These files should be tracked and committed. It's just that, most of the time, I'm not interested in seeing them.\nRelated question: How to invert git log --grep=<pattern> or How to show Git logs that don't match a pattern. It's the same question except for commit messages rather than paths.\nForum discussion on this subject from 2008: Re: Excluding files from git-diff. This looked promising but the thread seems to have dried up."
},
{
"role": "assistant",
"content": "It is implemented now (git 1.9/2.0, Q1 2014) with the introduction pathspec magic :(exclude) and its short form :! in commit ef79b1f and commit 1649612, by\nNguyễn Thái Ngọc Duy (pclouds), documentation can be found here.\nYou now can log everything except a sub-folder content:\ngit log -- . ':(exclude)sub'\ngit log -- . ':!sub'\n\nOr you can exclude specific elements within that sub-folder\n\na specific file:\n git log -- . ':(exclude)sub/sub/file'\n git log -- . ':!sub/sub/file'\n\n\nany given file within sub:\n git log -- . ':(exclude)sub/*file'\n git log -- . ':!sub/*file'\n git log -- . ':(exclude,glob)sub/*/file'\n\n\n\nYou can make that exclusion case insensitive!\ngit log -- . ':(exclude,icase)SUB'\n\nAs Kenny Evitt noted\n\nDon't forget to use single quotes or proper escaping in double quotes if you're running git in a bash shell, e.g. ':!sub' or \":\\!sub\". Otherwise you will run into bash: ... event not found errors\n\n\nNote: Git 2.13 (Q2 2017) adds a synonym ^ to !\nSee commit 859b7f1, commit 42ebeb9 (08 Feb 2017) by Linus Torvalds (torvalds).\n(Merged by Junio C Hamano -- gitster -- in commit 015fba3, 27 Feb 2017)\n\npathspec magic: add '^' as alias for '!'\nThe choice of '!' for a negative pathspec ends up not only not matching what we do for revisions, it's also a horrible character for shell expansion since it needs quoting.\nSo add '^' as an alternative alias for an excluding pathspec entry.\n\n\nNote that, before Git 2.28 (Q3 2020), the use of negative pathspec, while collecting paths including untracked ones in the working tree, was broken.\nSee commit f1f061e (05 Jun 2020) by Elijah Newren (newren).\n(Merged by Junio C Hamano -- gitster -- in commit 64efa11, 18 Jun 2020)\n\ndir: fix treatment of negated pathspecs\nReported-by: John Millikin\nSigned-off-by: Elijah Newren\ndo_match_pathspec() started life as match_pathspec_depth_1() and for correctness was only supposed to be called from match_pathspec_depth(). match_pathspec_depth() was later renamed to match_pathspec(), so the invariant we expect today is that do_match_pathspec() has no direct callers outside of match_pathspec().\nUnfortunately, this intention was lost with the renames of the two functions, and additional calls to do_match_pathspec() were added in commits\n\n75a6315f74 (\"ls-files: add pathspec matching for submodules\", 2016-10-07, Git v2.11.0-rc0 -- merge listed in batch #11)\n89a1f4aaf7 (\"dir: if our pathspec might match files under a dir, recurse into it\", 2019-09-17, Git v2.24.0-rc0).\n\nOf course, do_match_pathspec() had an important advantge over match_pathspec() -- match_pathspec() would hardcode flags to one of two values, and these new callers needed to pass some other value for flags.\nAlso, although calling do_match_pathspec() directly was incorrect, there likely wasn't any difference in the observable end output, because the bug just meant that fill_diretory() would recurse into unneeded directories.\nSince subsequent does-this-path-match checks on individual paths under the directory would cause those extra paths to be filtered out, the only difference from using the wrong function was unnecessary computation.\nThe second of those bad calls to do_match_pathspec() was involved -- via either direct movement or via copying+editing -- into a number of later refactors.\nSee commits\n\n777b420347 (\"dir: synchronize treat_leading_path() and read_directory_recursive()\", 2019-12-19, Git v2.25.0-rc0 -- merge)\n8d92fb2927 (\"dir: replace exponential algorithm with a linear one\", 2020-04-01, Git v2.27.0-rc0 -- merge listed in batch #5)\n95c11ecc73 (\"Fix error-prone fill_directory() API; make it only return matches\", 2020-04-01, Git v2.27.0-rc0 -- merge listed in batch #5)\n\nThe last of those introduced the usage of do_match_pathspec() on an individual file, and thus resulted in individual paths being returned that shouldn't be.\nThe problem with calling do_match_pathspec() instead of match_pathspec() is that any negated patterns such as :!unwanted_path will be ignored.\nAdd a new match_pathspec_with_flags() function to fulfill the needs of specifying special flags while still correctly checking negated patterns, add a big comment above do_match_pathspec() to prevent others from misusing it, and correct current callers of do_match_pathspec() to instead use either match_pathspec() or match_pathspec_with_flags().\nOne final note is that DO_MATCH_LEADING_PATHSPEC needs special consideration when working with DO_MATCH_EXCLUDE.\nThe point of DO_MATCH_LEADING_PATHSPEC is that if we have a pathspec like\n*/Makefile\n\nand we are checking a directory path like\nsrc/module/component\n\nthat we want to consider it a match so that we recurse into the directory because it might have a file named Makefile somewhere below.\nHowever, when we are using an exclusion pattern, i.e. we have a pathspec like\n:(exclude)*/Makefile\n\nwe do NOT want to say that a directory path like\nsrc/module/component\n\nis a (negative) match.\nWhile there might be a file named Makefile somewhere below that directory, there could also be other files and we cannot pre-emptively rule all the files under that directory out; we need to recurse and then check individual files.\nAdjust the DO_MATCH_LEADING_PATHSPEC logic to only get activated for positive pathspecs.\n\n\nPeter Mortensen adds in the comments:\n\nBut it is not sophisticated enough for more specific matching than matching any character(?).\nFor example, matching numbers in the path (example: \"keyboards/keychron/c1_pro\", \"keyboards/keychron/c2_pro\", \"keyboards/keychron/c42_pro\", \"keyboards/keychron/c821_pro\", etc.).\nThat it is far from something resembling regular expressions (if that is the case). Or is there an escape?\n\nTrue: Git pathspecs do not support regular expressions directly, which means you cannot use them to match specific patterns like numbers or complex strings within paths in a manner similar to regular expressions.\nFor cases like Peter's examples (keyboards/keychron/c1_pro, keyboards/keychron/c2_pro, keyboards/keychron/c42_pro, keyboards/keychron/c821_pro, etc.), the pathspec magic :(exclude) or :! allows for basic wildcard matching but does not offer the granularity of regular expressions.\nYou can exclude paths based on simple patterns like wildcards (* for any sequence of characters, ? for any single character) but not with the specificity that regular expressions provide (e.g., matching any path ending with a sequence of numbers followed by _pro).\nIf you need to filter Git logs based on more complex patterns that require regular expression-like matching, you would typically need to combine git log with other command-line tools that support regular expressions, such as grep or awk.\nFor example, to list commits affecting paths that match a specific pattern, you might first list all affected paths with git log --name-only, then filter those paths using grep with a regular expression.\nHowever, for Peter's specific use case of excluding paths, you could use a workaround by leveraging the shell's capabilities or scripting. You would list all commits, then filter out commits that only affect the specified patterns. There is no direct escape within Git's pathspec syntax that introduces regular expression capabilities.\nSomething like:\n#!/bin/bash\n\n# Define the pattern to exclude. That uses extended regex for matching any 'keychron' directory followed by 'c', numbers, and '_pro'\nexclude_pattern='keyboards/keychron/c[0-9]+_pro'\n\n# Get a list of all commits, showing affected paths, then filter out commits that only modify paths matching the exclude pattern\ngit log --all --name-only --format=\"%H\" | \\\nawk '/^[0-9a-f]{40}$/{commit=$0; next} {print commit \" \" $0}' | \\\ngrep -vE \"$exclude_pattern\" | \\\ncut -d' ' -f1 | \\\nuniq | \\\nwhile read commit; do\n git log -1 --format=\"%h %ad %s\" --date=short $commit\ndone"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Are Git forks actually Git clones?\n\nI keep hearing people say they're forking code in Git. Git \"fork\" sounds suspiciously like Git \"clone\" plus some (meaningless) psychological willingness to forgo future merges. There is no fork command in Git, right?\nGitHub makes forks a little more real by stapling correspondence onto it. That is, you press the fork button and later, when you press the pull request button, the system is smart enough to email the owner. Hence, it's a little bit of a dance around repository ownership and permissions.\nYes/No? Any angst over GitHub extending Git in this direction? Or any rumors of Git absorbing the functionality?"
},
{
"role": "assistant",
"content": "Fork, in the GitHub context, doesn't extend Git. \nIt only allows clone on the server side.\nWhen you clone a GitHub repository on your local workstation, you cannot contribute back to the upstream repository unless you are explicitly declared as \"contributor\". That's because your clone is a separate instance of that project. If you want to contribute to the project, you can use forking to do it, in the following way:\n\nclone that GitHub repository on your GitHub account (that is the \"fork\" part, a clone on the server side)\ncontribute commits to that GitHub repository (it is in your own GitHub account, so you have every right to push to it)\nsignal any interesting contribution back to the original GitHub repository (that is the \"pull request\" part by way of the changes you made on your own GitHub repository)\n\nCheck also \"Collaborative GitHub Workflow\".\nIf you want to keep a link with the original repository (also called upstream), you need to add a remote referring that original repository. \nSee \"What is the difference between origin and upstream on GitHub?\"\n\nAnd with Git 2.20 (Q4 2018) and more, fetching from fork is more efficient, with delta islands."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Maintain git repo inside another git repo\n\nHere's what I'd like:\nREPO-A\n /.git\n /otherFiles\n /REPO-B\n /.git\n /moreFiles\n\nI want to be able to push all of REPO-A's contents to REMOTE-A and only REPO-B to REMOTE-B.\nPossible?"
},
{
"role": "assistant",
"content": "It sounds like you want to use Git submodules.\n\nGit addresses this issue using submodules. Submodules allow you to keep a Git repository as a subdirectory of another Git repository. This lets you clone another repository into your project and keep your commits separate."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission --skip-to=<file> --rotate-to=<file>"
},
{
"role": "assistant",
"content": "Discard the files before the named <file> from the output\n(i.e. skip to ), or move them to the end of the output\n(i.e. rotate to ). These options were invented primarily for the use\nof the git difftool command, and may not be very useful\notherwise."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "\"git rm --cached x\" vs \"git reset head -- x\"?\nGitRef.org - Basic:\n\ngit rm will remove entries from the\n staging area. This is a bit different\n from git reset HEAD which \"unstages\"\n files. By \"unstage\" I mean it reverts\n the staging area to what was there\n before we started modifying things.\n git rm on the other hand just kicks\n the file off the stage entirely, so\n that it's not included in the next\n commit snapshot, thereby effectively\n deleting it.\nBy default, a git rm file will remove the file from the staging area entirely and also off your disk > (the working directory). To leave the file in the working directory, you can use git rm --cached.\n\nBut what exactly is the difference between git rm --cached asd and git reset head -- asd?"
},
{
"role": "assistant",
"content": "There are three places where a file, say, can be - the (committed) tree, the index and the working copy. When you just add a file to a folder, you are adding it to the working copy.\nWhen you do something like git add file you add it to the index. And when you commit it, you add it to the tree as well.\nIt will probably help you to know the three more common flags in git reset:\n\ngit reset [--<mode>] [<commit>]\nThis form resets the current branch head to <commit> and possibly\nupdates the index (resetting it to the tree of <commit>) and the\nworking tree depending on <mode>, which must be one of the\nfollowing:\n--soft\nDoes not touch the index file nor the working tree at all (but resets\nthe head to <commit>, just like all modes do). This leaves all your\nchanged files \"Changes to be committed\", as git status would put it.\n--mixed\nResets the index but not the working tree (i.e., the changed files\nare preserved but not marked for commit) and reports what has not been\nupdated. This is the default action.\n--hard\nResets the index and working tree. Any changes to tracked files in\nthe working tree since <commit> are discarded.\n\nNow, when you do something like git reset HEAD, what you are actually doing is git reset HEAD --mixed and it will \"reset\" the index to the state it was before you started adding files / adding modifications to the index (via git add). In this case, no matter what the state of the working copy was, you didn't change it a single bit, but you changed the index in such a way that is now in sync with the HEAD of the tree. Whether git add was used to stage a previously committed but changed file, or to add a new (previously untracked) file, git reset HEAD is the exact opposite of git add.\ngit rm, on the other hand, removes a file from the working directory and the index, and when you commit, the file is removed from the tree as well. git rm --cached, however, removes the file from the index alone and keeps it in your working copy. In this case, if the file was previously committed, then you made the index to be different from the HEAD of the tree and the working copy, so that the HEAD now has the previously committed version of the file, the index has no file at all, and the working copy has the last modification of it. A commit now will sync the index and the tree, and the file will be removed from the tree (leaving it untracked in the working copy). When git add was used to add a new (previously untracked) file, then git rm --cached is the exact opposite of git add (and is pretty much identical to git reset HEAD).\nGit 2.25 introduced a new command for these cases, git restore, but as of Git 2.28 it is described as “experimental” in the man page, in the sense that the behavior may change."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order -P --perl-regexp"
},
{
"role": "assistant",
"content": "Consider the limiting patterns to be Perl-compatible regular\nexpressions. Support for these types of regular expressions is an optional\ncompile-time dependency. If Git wasn’t compiled with support for them\nproviding this option will cause it to die."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary alternate object database"
},
{
"role": "assistant",
"content": "Via the alternates mechanism, a repository can inherit part of its object database from another object database, which is called an \"alternate\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-cherry-pick - Apply the changes introduced by some existing commits -n --no-commit"
},
{
"role": "assistant",
"content": "Usually the command automatically creates a sequence of commits.\nThis flag applies the changes necessary to cherry-pick\neach named commit to your working tree and the index,\nwithout making any commit. In addition, when this\noption is used, your index does not have to match the\nHEAD commit. The cherry-pick is done against the\nbeginning state of your index. This is useful when cherry-picking more than one commits'\neffect to your index in a row."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database nulInCommit"
},
{
"role": "assistant",
"content": "(WARN) Found a NUL byte in the commit object body."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary directory"
},
{
"role": "assistant",
"content": "The list you get with \"ls\" :-)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Determining a page is outdated on github pages\n\nGithub pages sets very aggressive cache headers (Cache-Control: max-age=86400 1 day, Expires 1 month ahead) on all served content.\nIf you update your pages and push to github, people revisiting the pages who have already got cached copies will not get the new pages without actually cleaning their browser cache.\nHow can a script running in a page determine that it is stale and force an update?\nThe steps might be:\n\ndetermine you are running on github pages: easy, parse window.location for github.com/\ndetermine current version of page: hard, git doesn't let you embed the sha1 in a commited page; no RCS $id$. So how do you know what version you are?\nget the current version in github; hard, github got rid of non-authenticated v2 API. And there's a time disconnect between pushing to github and github getting around to publishing too. So how do you know what version you could get?\nhaving determined you're stale, how do invalidate a page and force reload? hard, window.location.reload(true) doesn't work in Safari/Chrome, for example...\n\nSo its solve-these-steps; of course there may be another way?"
},
{
"role": "assistant",
"content": "To have a better control of the caching of your website you can use the HTML5 cache manifest. See:\n\nA Beginner's Guide to Using the Application Cache on HTML5 Rocks\nUsing the application cache on Mozilla Developer Network\nCache manifest in HTML5 on Wikipedia\nOffline Web Applications W3C Working Group Note\nOffline Web applications at WHATWG\n\nYou can use the window.applicationCache.swapCache() to update the cached version of your website without the need for manually reloading the page.\nThis is a code example from HTML5 Rocks explaining how to update users to the newest version of your site:\n// Check if a new cache is available on page load.\nwindow.addEventListener('load', function(e) {\n\n window.applicationCache.addEventListener('updateready', function(e) {\n if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {\n // Browser downloaded a new app cache.\n // Swap it in and reload the page to get the new hotness.\n window.applicationCache.swapCache();\n if (confirm('A new version of this site is available. Load it?')) {\n window.location.reload();\n }\n } else {\n // Manifest didn't changed. Nothing new to server.\n }\n }, false);\n\n}, false);\n\nTo avoid some confusion I'll add that GitHub sets the correct HTTP headers for cache.manifest files:\nContent-Type: text/cache-manifest\nCache-Control: max-age=0\nExpires: [CURRENT TIME]\n\nso your browser knows that it's a cache manifest and that it should always be checked for new versions."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Server Like GitHub? [closed]\nClosed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\nClosed 10 years ago.\n\n\n\nThis question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.\nQuestions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI am a long time Subversion user that is going to try Git. I have read some about it and understand the distributed nature - I can see a lot of the benefits. \nHowever, I do like the idea of a central server that can take on the role of backups, system of record, etc, while still using Git for my local branching and sharing. I am not doing an open source project, so I can't use Github (without paying), so my question really is: what is a best practice way to run a local git server?\nI realize this may be against the standard Git usage pattern, but it will be useful for my project. Any concerns that I may have overlooked are always welcome, however.\nThanks!"
},
{
"role": "assistant",
"content": "You can just set up an ssh server and run a central repository there. All developers then simply agree (as a matter of policy) to push to the server when they are done making commits. This is the usage pattern at my workplace. Very CVS and SVN-like.\n\nFind somewhere to put the repository (/var/gitroot for example).\nCreate a new repo (mkdir project.git && cd project.git && git init --bare --shared=group).\nThen on your client, clone the remote repo (git clone ssh://yourserver.com/var/gitroot/project.git && cd project)\nadd some files (git add README)\ncommit (git commit -m \"Initial import\"), \npush (git push origin master)\n\nThis should set things up for you."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git author Unknown\n\nmy author name in all my commits is coming up as unknown https://github.com/freeenergy/Teacher-Login-Validation-Module\ndid this\n$ git config --global user.name \"Firstname Lastname\"Sets the name of the user for all git instances on the system\n$ git config --global user.email \"[email protected]\"\n\nbut still the author/committer name shows [unknown]\nnot knowing what I was doing I experimented with setting $ GIT_AUTHOR_NAME=\"my name\" and it changed my name to my username [freeenergy] (I.E. my issue was fixed.) But when I switched back to my other computer the issue was the same.\nmy config file now looks like this but is still committing as [unknown]\n[core]\n repositoryformatversion = 0\n filemode = false\n bare = false\n logallrefupdates = true\n symlinks = false\n ignorecase = true\n hideDotFiles = dotGitOnly\n[remote \"origin\"]\n url = [email protected]:freeenergy/my-project.git\n fetch = +refs/heads/*:refs/remotes/origin/*\n[user]\n name = my name\n email = myEmail.com"
},
{
"role": "assistant",
"content": "Even better than running git config, you can edit your ~/.gitconfig file directly. Look and see if there's a section for [user] with the relevant information. For example, my ~/.gitconfig has this...\n[user]\n name = Bob Gilmore\n email = [email protected]\n\n(There's no space in front of the [user], and single tabs in front of the name and email labels)\nIf it doesn't have those set properly, just go ahead and edit the .gitconfig file by hand."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge - Join two or more development histories together --verify-signatures --no-verify-signatures"
},
{
"role": "assistant",
"content": "Verify that the tip commit of the side branch being merged is\nsigned with a valid key, i.e. a key that has a valid uid: in the\ndefault trust model, this means the signing key has been signed by\na trusted key. If the tip commit of the side branch is not signed\nwith a valid key, the merge is aborted."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Unable to Connect to GitHub.com For Cloning\n\nI am trying to clone the angular-phonecat git repository, but I am getting the following message when I enter the command in my Git Bash:\n$ git clone git://github.com/angular/angular-phonecat.git \nCloning into 'angular-phonecat'... \nfatal: unable to connect to github.com: \ngithub.com[0: 204.232.175.90]: errno=No error"
},
{
"role": "assistant",
"content": "You are probably behind a firewall. Try cloning via https – that has a higher chance of not being blocked:\ngit clone https://github.com/angular/angular-phonecat.git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to transfer a project from user to a group in Gitlab?\n\nI want to move a project under my username/ownership to a group whose owner is a different user. Something like https://gitlab/user/project to https://gitlab/group/project\nHow can I achieve this?"
},
{
"role": "assistant",
"content": "You can do this in the left-hand sidebar, under Settings -> General -> Transfer project. You will need manage rights to that group that you are transferring to though.\n\n\nBe careful. Changing the project's namespace can have unintended side effects. \nYou can only transfer the project to namespaces you manage.\nYou will need to update your local repositories to point to the new location.\nProject visibility level will be changed to match namespace rules when transferring to a group."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options git diff --no-index a b"
},
{
"role": "assistant",
"content": "compares two non-git things (1) and (2)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "how to delete all commit history in github? [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\n\nMake the current commit the only (initial) commit in a Git repository?\n\n (19 answers)\n \n\nClosed 8 years ago.\n\n\n\nI want to delete all commit history but keep the code in its current state because, in my commit history, there are too many unused commits.\nHow can I do it?\nIs there any git command can do this?\ngit filter-branch ?\ngit rebase ?\n... \n\nMy code is hosted on github.com."
},
{
"role": "assistant",
"content": "Deleting the .git folder may cause problems in your git repository. If you want to delete all your commit history but keep the code in its current state, it is very safe to do it as in the following:\n\nCheckout/create orphan branch (this branch won't show in git branch command):\ngit checkout --orphan latest_branch\n\n\nAdd all the files to the newly created branch:\ngit add -A\n\n\nCommit the changes:\ngit commit -am \"commit message\"\n\n\nDelete main (default) branch (this step is permanent):\ngit branch -D main\n\n\nRename the current branch to main:\ngit branch -m main\n\n\nFinally, all changes are completed on your local repository, and force update your remote repository:\ngit push -f origin main\n\n\n\nPS: This will not keep your old commit history around. Now you should only see your new commit in the history of your git repository."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Linking to other Wiki pages on GitHub?\n\nGitHub wikis allow you to link to other pages in the wiki like so:\n[[Wiki Page Name]]\n\nHowever, I want to display different text than the wiki page name when making the link. Is there a way to do this? Am I linking to wiki pages all wrong?"
},
{
"role": "assistant",
"content": "Using the Markdown link syntax\n[Link Text](WikiPage)\n\nseems to work in the edit preview but not on the actual wiki page. At least for me the generated link is WikiPage instead of wiki/WikiPage and I get the famous GitHub 404.\nHowever the MediaWiki syntax\n[[Link Text|WikiPage]]\n\nworks for me, even for Markdown wiki pages."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options diff.context"
},
{
"role": "assistant",
"content": "Generate diffs with <n> lines of context instead of the default\nof 3. This value is overridden by the -U option."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the HEAD in git?\nThere seems to be a difference between the last commit, the HEAD and the state of the file I can see in my directory.\nWhat is HEAD, what can I do with it and what mistake should I avoid?"
},
{
"role": "assistant",
"content": "HEAD is a reference to the last commit in the currently checked-out branch.\n\nThere is a small exception to this, which is the detached HEAD. A detached HEAD is the situation you end up in whenever you check out a commit (or tag) instead of a branch. In this case, you have to imagine this as a temporary branch without a name; so instead of having a named branch reference, we only have HEAD. It will still allow you to make commits (which will update HEAD), so the above short definition is still true if you think of a detached HEAD as a temporary branch without a name."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Artifacts for failed builds in Gitlab\n\nI would like to know how to generate artifacts for failed builds in gitlab continuous integration, to view the html report generated by the build.\nI tried like this:\n artifacts:\n when: on_failure\n paths:\n - SmokeTestResults/\n - package.json\n\nbut it does not work unfortunately. I am using Gitlab 8.11.4 community edition."
},
{
"role": "assistant",
"content": "Using when: on_failure will upload the artifact only when there is a failure.\nTo always upload the artifact despite a failure, use when: always.\nhttps://docs.gitlab.com/ce/ci/yaml/index.html#artifactswhen"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Where are git-lfs files stored?\nI am trying to figure out how to use git-lfs. I use a gitlab EE server.\nMaybe I missed something, but I failed to find any documentation on git-lfs beyond very short tutorial introducing the \"track\" command and cute 1 minute videos.\nFor example, I add and track a 3.7GB tar file in a repo, and push it:\ngit lfs track \"*.tar\"\ncp <a folder>/a.tar .\ngit add a.tar \ngit commit -m \"add a.tar\"\ngit push origin master\n\nQuestion 1: at the end of this process, has a.tar been uploaded on the gitlab server ? It is unclear as the \"add\" and the \"commit\" commands took some time (maybe not long enough to let me wonder if the 3.7GB were uploaded during that time) but the push did not take any time at all (a fraction of second).\nQuestion 2: if the file was uploaded on the server, where ? Obviously not in the same place as the repo (that is the point). I asked because my server is being backed-up, and I need to know if the use of git-lfs requires me to update this in any way.\nQuestion 3: if the file was not uploaded, does this mean other users of the repo will get the link to the file on the original machine on which the file was added ? Is there a way to change this to a location on the server ? (back to question 2)\nQuestion 4: after cloning the repo, indeed the full 3.4G file is not there, \"just\" a text file with the content:\nversion https://git-lfs.github.com/spec/v1\noid sha256:4bd049d85f06029d28bd94eae6da2b6eb69c0b2d25bac8c30ac1b156672c4082\nsize 3771098624\n\nThis is of course awesome and the whole point. But what if access to the full file is required ? how to download it ?\nI would be happy with either direct answer to this question or a link toward a proper documentation."
},
{
"role": "assistant",
"content": "Answer 1\nAs explained in this video (at 1:27), when you push a file tracked by git lfs it is intercepted and placed on a different server, leaving a pointer in your git repository. As you see in the reference you provide in Question 4, this worked for you.\nAnswer 2\nThis is a bit more tricky. Reading the documentation for git lfs smudge, we have:\n\nRead a Git LFS pointer file from standard input and write the contents\n of the corresponding large file to standard output. If needed,\n download the file's contents from the Git LFS endpoint. The \n argument, if provided, is only used for a progress bar.\n\nThe git lfs endpoint can be found from the output of git lfs env. My \"endpoint\" is a folder under (but not in) my repository, which makes me think that GitLab creates a git repository on the server in our account space to store binary files.\nThat said, I don't know how you'd go about backing this up. GitHub provides a git lfs server that's \"not in a production ready state,\" so it'd require some work on your part to set it up such that your binary files are uploaded to a server you administer. If backing up these files is a priority and you don't want to use one of the implementations (Amazon S3, etc), you might try another binary file storage system that works with git, such as git-media, git-annex, git-fat, git-bigstore.... I haven't looked into these options in depth, so couldn't make a recommendation.\nAnswer 3\nIf the file was not uploaded using git lfs it would have been pushed using git and you'd have a binary file in your git repository. But, yours was uploaded using git lfs as you say in Question 4.\nAnswer 4\nOther users of your repository, after having installed git lfs on their local machines, can simply type git lfs pull to bring in the binary file(s) that you pushed using git lfs."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.context"
},
{
"role": "assistant",
"content": "Generate diffs with <n> lines of context instead of the default\nof 3. This value is overridden by the -U option."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Difference between git pull and git pull origin master [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nDifferences between \"git pull\" commands when pulling from origin?\n\n (2 answers)\n \n\nClosed 10 years ago.\n\n\n\nWhat is the difference between these two commands?\ngit pull\n\nand \ngit pull origin master"
},
{
"role": "assistant",
"content": "[Edit, May 2018: git pull is no longer a shell script and a few details are different in modern Git. Pull also now has recursion options that make it more useful with submodules. This answer ignores the submodules.]\nThe git pull script is meant as a convenience method for invoking git fetch followed by git merge (or, with git pull --rebase, invoking git fetch followed by git rebase).\nThe first extra argument to git pull tells it which remote to give to the fetch operation:\ngit pull origin\n\nfor example, means to fetch from origin. If you leave this out, Git uses the current branch's remote:\n$ git branch\n* master\n$ git config --get branch.master.remote\norigin\n\nThe second (and any additional) arguments to git pull tell it which branch or branches to merge in. These are the names of the branches as found on the remote. For instance, suppose you create a new branch feature2 that tracks origin/feature:\n$ git checkout -b feature2 origin/feature\n\nIf you now want to fetch from origin to pick up new commits added to their feature branch, but merge them in to your local feature2 branch:\n$ git pull origin feature\n\nIf you leave out the branch name(s), git uses the current branch's merge:\n$ git config --get branch.feature2.merge\nfeature\n\nNote that if you list multiple branch names, Git will do an \"octopus merge\". In my experience, this usually surprises people the first time: they think git pull remote br1 br2 will run git fetch followed by a series of separate git merge-s on each branch, but that's not what happens."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to get a list of all files that changed between two Git commits?\nDue to bureaucracy, I need to get a list of all changed files in my repository for a report (I started with existing source code).\nWhat should I run to get this list?"
},
{
"role": "assistant",
"content": "For files changed between a given SHA and your current commit:\ngit diff --name-only <starting SHA> HEAD\n\nor if you want to include changed-but-not-yet-committed files:\ngit diff --name-only <starting SHA>\n\nMore generally, the following syntax will always tell you which files changed between two commits (specified by their SHAs or other names):\ngit diff --name-only <commit1> <commit2>\n\nUsing --name-status instead of --name-only will show what happened to the files as well as the names."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I merge another developer's branch into mine?\n\nI am relatively new to git. Our organization uses a Fork & Pull Model for managing changes to the master branch. Each developer forks the master and branches from their fork when adding new features. I keep an eye on commits that other developers are making in their own branches, and would sometimes like to merge these changes into my own branch. What steps do I take to accomplish this?"
},
{
"role": "assistant",
"content": "You first need to add the other developer repository as a remote.\ngit remote add otherrep uriToOtherRep\n\nThen you fetch changes from there\ngit fetch otherrep\n\nAnd then you merge the branch from the remote repository into yours\ngit merge otherrep/branchname\n\nHappy merging!"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options core.commitGraph"
},
{
"role": "assistant",
"content": "If true, then git will read the commit-graph file (if it exists)\nto parse the graph structure of commits. Defaults to true. See git-commit-graph for more information."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-blame - Show what revision and author last modified each line of a file --color-by-age"
},
{
"role": "assistant",
"content": "Color line annotations depending on the age of the line in the default format.\nThe color.blame.highlightRecent config option controls what color is used for\neach range of age."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Retrieve the commit log for a specific line in a file?\nIs there any way to get git to give you a commit log for just commits that touched a particular line in a file?\nLike git blame, but git blame will show you the LAST commit that touched a particular line. \nI'd really like to get a similar log of, not the list of commits to anywhere in the file, but just the commits that touched a particular line."
},
{
"role": "assistant",
"content": "See also Git: discover which commits ever touched a range of lines.\n\nSince Git 1.8.4, git log has -L to view the evolution of a range of lines.\nFor example, suppose you look at git blame's output. Here -L 150,+11 means \"only look at the lines 150 to 150+11\":\n$ git blame -L 150,+11 -- git-web--browse.sh\na180055a git-web--browse.sh (Giuseppe Bilotta 2010-12-03 17:47:36 +0100 150) die \"The browser $browser is not\na180055a git-web--browse.sh (Giuseppe Bilotta 2010-12-03 17:47:36 +0100 151) fi\n5d6491c7 git-browse-help.sh (Christian Couder 2007-12-02 06:07:55 +0100 152) fi\n5d6491c7 git-browse-help.sh (Christian Couder 2007-12-02 06:07:55 +0100 153) \n5d6491c7 git-browse-help.sh (Christian Couder 2007-12-02 06:07:55 +0100 154) case \"$browser\" in\n81f42f11 git-web--browse.sh (Giuseppe Bilotta 2010-12-03 17:47:38 +0100 155) firefox|iceweasel|seamonkey|iceape)\n5d6491c7 git-browse-help.sh (Christian Couder 2007-12-02 06:07:55 +0100 156) # Check version because firefox < 2.0 do\n5d6491c7 git-browse-help.sh (Christian Couder 2007-12-02 06:07:55 +0100 157) vers=$(expr \"$($browser_path -version)\" \n5d6491c7 git-browse-help.sh (Christian Couder 2007-12-02 06:07:55 +0100 158) NEWTAB='-new-tab'\n5d6491c7 git-browse-help.sh (Christian Couder 2007-12-02 06:07:55 +0100 159) test \"$vers\" -lt 2 && NEWTAB=''\na0685a4f git-web--browse.sh (Dmitry Potapov 2008-02-09 23:22:22 -0800 160) \"$browser_path\" $NEWTAB \"$@\" &\n\nAnd you want to know the history of what is now line 155.\nThen, use git log. Here, -L 155,155:git-web--browse.sh means \"trace the evolution of lines 155 to 155 in the file named git-web--browse.sh\".\n$ git log --pretty=short -u -L 155,155:git-web--browse.sh\ncommit 81f42f11496b9117273939c98d270af273c8a463\nAuthor: Giuseppe Bilotta <[email protected]>\n\n web--browse: support opera, seamonkey and elinks\n\ndiff --git a/git-web--browse.sh b/git-web--browse.sh\n--- a/git-web--browse.sh\n+++ b/git-web--browse.sh\n@@ -143,1 +143,1 @@\n-firefox|iceweasel)\n+firefox|iceweasel|seamonkey|iceape)\n\ncommit a180055a47c6793eaaba6289f623cff32644215b\nAuthor: Giuseppe Bilotta <[email protected]>\n\n web--browse: coding style\n\ndiff --git a/git-web--browse.sh b/git-web--browse.sh\n--- a/git-web--browse.sh\n+++ b/git-web--browse.sh\n@@ -142,1 +142,1 @@\n- firefox|iceweasel)\n+firefox|iceweasel)\n\ncommit 5884f1fe96b33d9666a78e660042b1e3e5f9f4d9\nAuthor: Christian Couder <[email protected]>\n\n Rename 'git-help--browse.sh' to 'git-web--browse.sh'.\n\ndiff --git a/git-web--browse.sh b/git-web--browse.sh\n--- /dev/null\n+++ b/git-web--browse.sh\n@@ -0,0 +127,1 @@\n+ firefox|iceweasel)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options man.<tool>.cmd"
},
{
"role": "assistant",
"content": "Specify the command to invoke the specified man viewer. The\nspecified command is evaluated in shell with the man page\npassed as an argument. (See git-help .)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitHub: Why should I fork?\n\nI understand that forking is cloning the repository on the server side. But I don't understand why I would do that.\nWhy not clone the original repository to my machine, add my code, than push the new branch to GitHub and make a pull request?"
},
{
"role": "assistant",
"content": "I understand that forking is cloning the repository on the server side [...]\n\nThat's about right. On GitHub, a fork is a copy of some other GitHub repo, with a reference to the repo it was copied from.\n\nRemark: the concept of a fork originated with GitHub; it is not a Git concept.\n\n[...] but I don't understand why I would do that. Why not clone the original repository to my machine, add my code, then push the new branch to GitHub and make a pull request?\n\nUnless you have write access to the repository in question, you cannot simply push anything to it; your push will be denied by the server with an error message of the form\nremote: Permission to bos/text.git denied to Jubobs.\nfatal: unable to access 'https://github.com/bos/text/': The requested URL returned error: 403\n\nThat's where a fork comes into play. By forking someone else's repo, you get a copy to which you have write access, i.e. to which you can push your contributions. The entire workflow goes something like this:\n\nIdentify an area in Alice's repo that can be improved.\nFork that repo.\nMake a clone of your fork on your local machine.\nIn that clone, make changes, run tests, create commits (possibly on a new branch), etc.\nOptionally, once you're happy with your amendments to Alice's code, make your work more presentable: tidy/squash your commits, write good commit messages that respect the style of Alice's repo. You may also want to rebase your branch to that of Alice's branch, if Alice has pushed changes to her repo since you forked her repo.\nPush to your fork.\nIssue a pull request to Alice (essentially notifying Alice to take a look at the changes you made in your fork of her repo) and wait for her to review it.\nPush more commits to (and possibly rebase) your branch until Alice is satisfied with your work.\nIf all goes well, Alice merges your pull request; your work gets integrated into her GitHub repo. Champagne! Your work was not in vain.\nIf you don't intend to contribute to Alice's repo any time soon, you can safely delete your fork, to save space on GitHub's servers. If, on the other hand, you frequently contribute to Alice's repo, keep your fork and frequently sync it with Alice's repo."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-grep - Print lines matching a pattern --full-name"
},
{
"role": "assistant",
"content": "When run from a subdirectory, the command usually\noutputs paths relative to the current directory. This\noption forces paths to be output relative to the project\ntop directory."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "See diff between current state and last commit\nSometimes when I'm about to make a commit, I can't recall exactly what has changed since the last commit. How can I see a diff of the current state of the code and the last commit?"
},
{
"role": "assistant",
"content": "If you haven't added any files to the index yet (with git add), simply do\ngit diff\n\nThis will show the diff between your working tree and index.\nIf you have added files to the index, you need to do this to show the differences between index and the last commit (HEAD).\ngit diff --cached\n\nFinally, if you want to see the changes made in the working tree compared to the latest commit (HEAD) you can (as Carlos points out) do\ngit diff HEAD\n\nThose changes are the combination of git diff and git diff --cached."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is it safe to ignore /xcuserdata/ with Git if using Launch Arguments?\nI have an argument being passed on launch: -D DEBUG which allows me to use the following in my release app:\n#ifndef DEBUG\n /* Some code I only want to be run when using the release app */\n#endif\n\nWhen I run git status, it shows me that the file changed when adding -D DEBUG is MyExampleProject.xcodeproj/xcuserdata/myusername.xcuserdatad/xcschemes/MyExampleProject.xcscheme\nWhich should be excluded using the commonly used Xcode .gitignore file. Is there any other way to include this argument that complies with .gitignore and doesn't rely on my user accounts xcuserdata?"
},
{
"role": "assistant",
"content": "Generally the xcuserdata is safe to ignore for individual projects. Each user gets their own file that saves userstate, folders opened, last file opened, that sort of stuff. It does contain your schemes. If it is the first time opening and the file doesn't exist, Xcode will create it for you.\nHowever... we have run into this issue at the office when you have a continuous build server, like Hudson or Jenkins, that copies the source from Git or SVN without ever opening it and tries to build it. If you ignore this file, there will be no schemes to build against or it will force someone to open the project to auto create it the first time.\nWe solved this by checking the shared box under manage schemes. This moves the schemes out from under your individual xcuserdata into a shared folder that can be committed via source control and used by the continuous build servers."
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.