messages listlengths 3 3 |
|---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-cherry-pick - Apply the changes introduced by some existing commits --allow-empty-message"
},
{
"role": "assistant",
"content": "By default, cherry-picking a commit with an empty message will fail.\nThis option overrides that behavior, allowing commits with empty\nmessages to be cherry picked."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker --git-dir=<path>"
},
{
"role": "assistant",
"content": "Set the path to the repository (\".git\" directory). This can also be\ncontrolled by setting the GIT_DIR environment variable. It can be\nan absolute path or relative path to current working directory. Specifying the location of the \".git\" directory using this\noption (or GIT_DIR environment variable) turns off the\nrepository discovery that tries to find a directory with\n\".git\" subdirectory (which is how the repository and the\ntop-level of the working tree are discovered), and tells Git\nthat you are at the top level of the working tree. If you\nare not at the top-level directory of the working tree, you\nshould tell Git where the top-level of the working tree is,\nwith the --work-tree=<path> option (or GIT_WORK_TREE environment variable) If you just want to run git as if it was started in <path> then use git -C <path> ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order"
},
{
"role": "assistant",
"content": "SYNOPSIS git rev-list [<options>] <commit>… [--] [<path>…]"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc blocks"
},
{
"role": "assistant",
"content": "Blocks of moved text of at least 20 alphanumeric characters\nare detected greedily. The detected blocks are\npainted using either the color.diff.{old,new}Moved color.\nAdjacent blocks cannot be told apart."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options color.status"
},
{
"role": "assistant",
"content": "A boolean to enable/disable color in the output of git-status . May be set to always , false (or never ) or auto (or true ), in which case colors are used\nonly when the output is to a terminal. If unset, then the\nvalue of color.ui is used ( auto by default)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fast-import - Backend for fast Git data importers External data format"
},
{
"role": "assistant",
"content": "The data content for the file was already supplied by a prior blob command. The frontend just needs to connect it. 'M' SP <mode> SP <dataref> SP <path> LF Here usually <dataref> must be either a mark reference ( :<idnum> )\nset by a prior blob command, or a full 40-byte SHA-1 of an\nexisting Git blob object. If <mode> is 040000` then <dataref> must be the full 40-byte SHA-1 of an existing\nGit tree object or a mark reference set with --import-marks ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --histogram"
},
{
"role": "assistant",
"content": "Generate a diff using the \"histogram diff\" algorithm."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git undo merge attempt\nI have working directory (#1) which has vendor directory(#2) in it. There is one dependency which I wanted to pull manually without composer (php version of npm/gem). I was working in #1, haven't saved/commited changes, when I decided I want to update library in #2. I navigated to vendor/myname, and did git pull repository.\nUnfortunately it started to pull and merge to #1, instead of creating new directory in vendor folder.\nNow I have:\n\n#1 folder with my changes\n#1 folder with files I don't want from wrong repository\n#1 merge conflicts such as composer.json, Readme.md... (general files)\n\nI want to \"undo\" this last git pull without loosing any changes I did to folder #1. How can I do this?"
},
{
"role": "assistant",
"content": "git merge --abort might be what you're looking for."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I create a folder in a GitHub repository?\n\nI want to create a folder in a GitHub repository and then add files to that folder. \nHow do I achieve this?"
},
{
"role": "assistant",
"content": "TL;DR Use / in the file name field to create folder(s), e.g. typing folder1/file1 in the file name field will create a folder folder1 and a file file1.\nOriginal answer\nYou cannot create an empty folder and then add files to that folder, but rather creation of a folder must happen together with adding of at least a single file. This is because git doesn't track empty folders.\nOn GitHub you can do it this way:\n\nGo to the folder inside which you want to create another folder\nClick on New file\nOn the text field for the file name, first write the folder name you want to create\nThen type /. This creates a folder\nYou can add more folders similarly\nFinally, give the new file a name (for example, .gitkeep which is conventionally used to make Git track otherwise empty folders; it is not a Git feature though)\nFinally, click Commit new file."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Override configured user for a single git commit\n\nI am trying to commit to a project on github.com from my work laptop, which is already configured for the company git server. Is there a way to commit specifying different author credentials, possible using a different configuration file or orther command line switches?\nI've tried using\n--author=\"My Name <[email protected]>\" \n\nand I received the message: \n Committer: unknown <[email protected]>\nYour name and email address were configured automatically based\non your username and hostname. Please check that they are accurate.\nYou can suppress this message by setting them explicitly:\n\n git config --global user.name \"Your Name\"\n git config --global user.email [email protected]\n\nAfter doing this, you may fix the identity used for this commit with:\n\n git commit --amend --reset-author\n\nbut it still didn't update my username for committing to the github.com project. Is there anything else I can try and is it even possible?"
},
{
"role": "assistant",
"content": "First, the author is not necessarily the same as the committer. Git tracks both.\nTo set what name to use for just this repository, you could do:\ngit config user.name \"Your Name\"\ngit config user.email \"Your email\"\n\nNotice the absence of the --global option. This will set the configuration in this repository only.\nAlternatively, you can do this for only a single command, using the -c option:\ngit -c \"user.name=Your Name\" -c \"user.email=Your email\" commit ...\n\nBut I think it's better to just use the config options above."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-add - Add file contents to the index --chmod=(+|-)x"
},
{
"role": "assistant",
"content": "Override the executable bit of the added files. The executable\nbit is only changed in the index, the files on disk are left\nunchanged."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I use Git's `difftool` to merge conflicts?\nAfter a merge failed with some conflicts, I can list those with git diff, but git difftool won't display them with the difftool set in the config (in my case Kaleidoscope). Instead it will just use normal diff.\nA git difftool comparing with a previous commit will work.\nIs there a way to use git difftool on merge conflicts?"
},
{
"role": "assistant",
"content": "Try git mergetool."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options row"
},
{
"role": "assistant",
"content": "fill rows before columns"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to apply a patch generated with git format-patch?\nI have two local git repositories, both pointing to the same remote repository.\nIn one git repository, if I do git format-patch 1, how can I apply that patch to the other repository?"
},
{
"role": "assistant",
"content": "Note: You can first preview what your patch will do:\nFirst the stats:\ngit apply --stat a_file.patch\n\nThen a dry run to detect errors:\ngit apply --check a_file.patch\n\nFinally, you can use git am to apply your patch as a commit. This also allows you to sign off an applied patch.\nThis can be useful for later reference.\ngit am --keep-cr --signoff < a_file.patch \n\nAs noted by riverofwind in the comments:\n\nDon't forget if you have autocrlf=false for Windows only development you'll need to pass --keep-cr to am to keep those CRLFs\n\nSee an example in this article:\n\nIn your git log, you’ll find that the commit messages contain a “Signed-off-by” tag. This tag will be read by Github and others to provide useful info about how the commit ended up in the code."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git submodule sync command - what is it for?\nI don't understand from the documentation what does git submodule sync do. Please explain."
},
{
"role": "assistant",
"content": "Git stores information about submodules in two places. The first is in a file called .gitmodules, which is checked in to the git repository. Changes to this file are what get propagated to other repositories.\nThe other location is in .git/config, and it's where git actually looks when performing most commands.\nSo imagine you've worked on a project for a while, and there's a submodule called foo. Files for this submodule are checked out from some url, it doesn't really matter where. At some point, however, this url changes. Perhaps it changes so that the submodule is checked out from a different server, or a different path or whatever. When you update your repository your copy of the .gitmodules file will be updated, but not your .git/config file; you would still be checking out from the old url. When you want to start checking out from the new url, you would run git submodule sync to copy the new configuration from .gitmodules to .git/config. Git doesn't do this automatically because you might have made your own changes to your configuration, and it wouldn't want to overwrite them."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Commit message linking to issue AND issue link to commit\n\nHow is it possible to linkg a commit message to issue AND the issue to the commits? \nIf I add in the commit message #123 it is a link to the issue, but on the issue there is no link to the commit.\nIs this in any way possible to show the commit in the issue?"
},
{
"role": "assistant",
"content": "Seems GitLab has now added this feature.\nIf you add to your commit message the issue id the commit number will be mentioned in the issue like this:\n\nLinks to docs:\nhttps://docs.gitlab.com/ee/user/markdown.html#gitlab-specific-references\nhttps://docs.gitlab.com/ee/user/project/issues/managing_issues.html#default-closing-pattern"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Importing a Maven project into Eclipse from Git\nHow can I get the effect of choosing to import from both Maven and Git and have Eclipse properly generate my project? \nTo get my project into Eclipse I can choose File->import->maven and then I get all the Maven projects imported and can build fine, or I can choose File->import->git and make a new project that ignores the pom.xml and does not generate the project properly. \nIt seems I can do one or the other but not combine both so I get a correctly generated project."
},
{
"role": "assistant",
"content": "Eclipse Indigo + M2Eclipse 1.0 makes it very easy. \nIf you don't already have the Git connector for M2Eclipse install it. M2Eclipse will help you along by prompting you on the Import menu. \n\nSelect the \"Import...\" context menu from the Package Explorer view\nSelect \"Check out Maven projects from SCM\" option under the Maven category\nOn the window that is presented choose the link \"Find more SCM connectors in the m2e Marketplace\nFind connector for Git...install...restart\n\nNote that in the search box you may have to enter \"EGit\" instead of \"Git\" to find the right connector.\nWith that done, simply go to the EGit repository, bring up the context menu for the Working directory and select \"Import Maven projects...\". \nDone!"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to change git shell's start directory in windows 7\n\nI downloaded and installed the programs offered by GitHub including Git Shell.\nThe problem is that I want to set up the home directory of the Git Shell program to a custom one, but I don't know how to do that.\nI tried changing the \"start in\" field from the properties menu of the Git Shell shortcut but it didn't work.\nCan anybody please give me some information on how to change the home directory of the Git Shell to a custom one?"
},
{
"role": "assistant",
"content": "Right click on Git Shell\nChoose Properties\nMove to the end of the Target field\nChange --open-shell to --open-shell=c:\\your_dir"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order --ignore-missing"
},
{
"role": "assistant",
"content": "Upon seeing an invalid object name in the input, pretend as if\nthe bad input was not given."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Pull is not possible because you have unmerged files, git stash doesn't work. Don't want to commit\nI just want to pull. I have changes to disregard, my Gemfile and Gemlock files and I'd be happy to just overwrite them and just pull. I tried stashing my changes away, this didn't work out for me. What do I do?\ngit pull\nM Gemfile\nU Gemfile.lock\nPull is not possible because you have unmerged files.\nPlease, fix them up in the work tree, and then use 'git add/rm <file>'\nas appropriate to mark resolution, or use 'git commit -a'.\n~/projects/sms/apps2/apps2_admin(apps2)$ git stash save \"saved\"\nGemfile.lock: needs merge\nGemfile.lock: needs merge\nGemfile.lock: unmerged (4ea16799dba7bfe1db28adecf36dee1af5195c1a)\nGemfile.lock: unmerged (e77439c9f86d1d0eda7ae0787e3e158f90959e68)\nGemfile.lock: unmerged (d690d3860db1aa8e46c1bb2f4de3e52a297b5c26)\nfatal: git-write-tree: error building trees\nCannot save the current index state\n~/projects/sms/apps2/apps2_admin(apps2)$ git pull\nM Gemfile\nU Gemfile.lock\nPull is not possible because you have unmerged files.\nPlease, fix them up in the work tree, and then use 'git add/rm <file>'\nas appropriate to mark resolution, or use 'git commit -a'."
},
{
"role": "assistant",
"content": "git fetch origin\ngit reset --hard origin/master\ngit pull\n\nExplanation:\n\nFetch will download everything from another repository, in this case, the one marked as \"origin\". \nReset will discard changes and revert to the mentioned branch, \"master\" in repository \"origin\". \nPull will just get everything from a remote repository and integrate. \n\nSee documentation at http://git-scm.com/docs."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options color.interactive.<slot>"
},
{
"role": "assistant",
"content": "Use customized color for git add --interactive and git clean\n--interactive output. <slot> may be prompt , header , help or error , for four distinct types of normal output from\ninteractive commands."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git / Bower Errors: Exit Code # 128 & Failed connect\nI am using Bower to install several libraries. For demonstration purposes here, I am installing bootstrap. Regardless of the package, I receive the following errors:\nC:\\Scott>bower install bootstrap\nbower not-cached git://github.com/twbs/bootstrap.git#*\nbower resolve git://github.com/twbs/bootstrap.git#*\nbower ECMDERR Failed to execute \"git ls-remote --tags --heads git://github\n.com/twbs/bootstrap.git\", exit code of #128\n\nAdditional error details:\nfatal: unable to access 'https://github.com/twbs/bootstrap.git/': Failed connect\nto github.com:443; No error \n\nI have tried using the following solution to remove the first error - which I found from this search:\ngit config --global url.\"https://\".insteadOf git://\n\nHowever, this does not work nor do any of the other solutions found on that page. Searching for a solution for the 2nd error, it seems that setting a username/pwd for a proxy server will resolve the issue if you are on a corporate network/behind a firewall. However, I am not using a proxy server as I am on my home pc/network (windows 7 x64).\nThanks!\nEDIT: Command window with errors:"
},
{
"role": "assistant",
"content": "I know this is not \"fixing\" the problem, but you can use\ngit config --global url.\"https://\".insteadOf git://\nto tell git to use HTTPS instead of GIT which worked out for me to install npm dependencies."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --no-ext-diff"
},
{
"role": "assistant",
"content": "Disallow external diff drivers."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_TRACE_SHALLOW"
},
{
"role": "assistant",
"content": "Enables trace messages that can help debugging fetching /\ncloning of shallow repositories.\nSee GIT_TRACE for available trace output options."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc none"
},
{
"role": "assistant",
"content": "Disable word diff again."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Remote rejected (shallow update not allowed) after changing Git remote URL\nI have a project under Git version control that I worked on both a server and my local computer. I originally had the remote origin set as my local computer but I would now like to change that to BitBucket.\nOn the server I used the command\ngit remote set-url origin bitbucket_address\n\nBut now when I try to push my project I get the error\n ! [remote rejected] master -> master (shallow update not allowed)\n\nWhat is causing this and how do I fix it?"
},
{
"role": "assistant",
"content": "As it seems you have used git clone --depth <number> to clone your local version. This results in a shallow clone. One limitation of such a clone is that you can't push from it into a new repository.\nYou now have two options:\n\nif you don't care about your missing history, take a look at this question\nif you want to keep your full history, then continue reading:\n\nSo, you want to keep your history, eh? This means that you have to unshallow your repository. If you already removed or replaced your old remote then you'll need to add it again:\ngit remote add old <path-to-old-remote>\n\nAfter that we use git fetch to fetch the remaining history from the old remote (as suggested in this answer).\ngit fetch --unshallow old\n\nAnd now you should be able to push into your new remote repository.\n\nNote: After unshallowing your clone you can remove the old remote."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Automate code deploy from Git lab to AWS EC2 instance\n\nWe're building an application for which we are using GitLab repository. Manual deployment of code to the test server which is Amazon AWS EC2 instance is tedious, I'm planning to automate deployment process, such that when we commit code, it should reflect in the test instance.\nfrom my knowledge we can use AWS code-deploy service to fetch the code from GitHub. But code deploy service does not support GitLab repository . Is there a way to automate the code deployment process to AWS Ec2 instance through GitLab. or Is there a shell scripting possibility to achieve this? Kindly educate me."
},
{
"role": "assistant",
"content": "One way you could achieve this with AWS CodeDeploy is by using the S3 option in conjunction with Gitlab-CI: http://docs.aws.amazon.com/codepipeline/latest/userguide/getting-started-w.html\nDepending on how your project is setup, you may have the possibility to generate a distribution Zip (Gradle offers this through the application plugin). You may need to generate your \"distribution\" file manually if your project does not offer such a capability.\nGitlab does not offer a direct S3 integration, however through the gitlab-ci.yml you would be able to download it into the container and run the necessary upload commands to put the generated zip file on the S3 container as per the AWS instructions to trigger the deployment. \nHere is an example of what your brefore-script could look like in the gitlab-ci.yml file:\nbefore_script:\n - apt-get update --quiet --yes\n - apt-get --quiet install --yes python\n - pip install -U pip\n - pip install awscli\n\nThe AWS tutorial on how to use CodeDeploy with S3 is very detailed, so I will skip attempting to reproduce the contents here.\nIn regards to the actual deployment commands and actions that you are currently performing manually, AWS CodeDeploy provides the capability to run certain actions through scripts defined in the app-spec file depending on event hooks for the application: \n\nhttp://docs.aws.amazon.com/codedeploy/latest/userguide/writing-app-spec.html\nhttp://docs.aws.amazon.com/codedeploy/latest/userguide/app-spec-ref.html\nhttp://docs.aws.amazon.com/codedeploy/latest/userguide/app-spec-ref-hooks.html\n\nI hope this helps."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to see which commits in one branch aren't in the other?\nI have two branches devel and next. In devel I have a more or less huge amount of commits. Some of the commits are cherry picked in next. Also I added some commits to next which are merged to devel.\nNow I would like to see what is missing in next, so I can test the changes in detail before bringing them to next. My question is now, how can I see which commits are in devel but not in next?"
},
{
"role": "assistant",
"content": "The little-used command git cherry (docs) shows you the commits which haven't yet been cherry-picked.\nIn short:\ngit cherry <feature-branch> [base-branch]\n\n# Checkout the base branch\ngit checkout main\n\n# Diff against the target branch\ngit cherry -v next\n\n# Diff against the target branch, without switching\ngit cherry -v next main\n\nExample output:\n+ 492508acab7b454eee8b805f8ba906056eede0ff feat: make bazzable\n- 5ceb5a9077ddb9e78b1e8f24bfc70e674c627949 hotfix: off-by-one\n+ b4459544c000f4d51d1ec23f279d9cdb19c1d32b feat: add bar\n+ b6ce3b78e938644a293b2dd2a15b2fecb1b54cd9 feat: add foo\n\n+ means the commit is only in next, but not in main \n- means the commit has an equivalent in both branches\nRemove the -v if you want the commits without the subject line:\n+ 492508acab7b454eee8b805f8ba906056eede0ff\n- 5ceb5a9077ddb9e78b1e8f24bfc70e674c627949\n+ b4459544c000f4d51d1ec23f279d9cdb19c1d32b\n+ b6ce3b78e938644a293b2dd2a15b2fecb1b54cd9"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-gc - Cleanup unnecessary files and optimize the local repository gc.aggressiveWindow"
},
{
"role": "assistant",
"content": "The window size parameter used in the delta compression\nalgorithm used by git gc --aggressive . This defaults\nto 250, which is a much more aggressive window size than\nthe default --window of 10. See the documentation for the --window option in git-repack for more details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab cannot open git-upload-pack error\n\nI have been using Gitlab without problems for a couple of months now.\nBut, since yesterday, I can not \"reach\" (fetch, push,...) Gitlab from my Eclipse IDE anymore.\nNo matter whether I'm working in my firm (could have been a proxy problem) or at home.\nI get the following error message :\nhttps://gitlab.com/XXX/XXX.git: \n cannot open git-upload-pack\n cannot open git-upload-pack\n\nLooking at my Eclipse .log, the cause is :\nCaused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure\n at sun.security.ssl.Alerts.getSSLException(Unknown Source)\n at sun.security.ssl.Alerts.getSSLException(Unknown Source)\n at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)\n at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)\n at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)\n at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)\n at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)\n at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)\n at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)\n at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)\n at java.net.HttpURLConnection.getResponseCode(Unknown Source)\n at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)\n at org.eclipse.jgit.transport.http.JDKHttpConnection.getResponseCode(JDKHttpConnection.java:98)\n at org.eclipse.jgit.util.HttpSupport.response(HttpSupport.java:168)\n at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:460)\n ... 10 more\n\nAdding http.sslVerify=false in my Eclipse/Git configuration did not help...\nAny idea why this is (suddenly) happening?"
},
{
"role": "assistant",
"content": "I've encountered a similar error with another Gitlab server. I dug into it and discovered that all of the available ciphers on the server were at least 256 bits. Standard Oracle Java ships with crypto that's restricted to 128 bits for some algorithms. After installing the unlimited strength crypto package from Oracle the issue went away.\nAlmost forgot, the unlimited strength package is only legally available in the US. If you're outside of the US then I think that OpenJDK will work instead."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Link to the issue number on GitHub within a commit message\nIs it somehow possible to automatically have a link to GitHub issue number in the git commit message?"
},
{
"role": "assistant",
"content": "Just include #xxx in your commit message to reference an issue without closing it.\nWith new GitHub issues 2.0 you can use these synonyms to reference an issue and close it (in your commit message):\n\nfix #xxx\nfixes #xxx\nfixed #xxx\nclose #xxx\ncloses #xxx\nclosed #xxx\nresolve #xxx\nresolves #xxx\nresolved #xxx\n\nYou can also substitute #xxx with gh-xxx.\nReferencing and closing issues across repos also works:\nfixes user/repo#xxx\n\nCheck out the documentation available in their Help section."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to search on GitHub to get exact string matches, including special characters\n\nI can search exact matches from Google by using quotes like \"system <<-\".\nHow can I do the same thing for GitHub?"
},
{
"role": "assistant",
"content": "You couldn't (before 2022). The official GitHub searching rules:\n\nDue to the complexity of searching code, there are a few restrictions\non how searches are performed:\n\nOnly the default branch is considered. In most cases, this will be the master branch.\nOnly files smaller than 384 KB are searchable.\nOnly repositories with fewer than 500,000 files are searchable.\nYou must always include at least one search term when searching source code. For example, searching for language:go is not valid, while amazing language:go is.\nAt most, search results can show two fragments from the same file, but there may be more results within the file.\nYou can't use the following wildcard characters as part of your search query:\n. , : ; / \\ ` ' \" = * ! ? # $ & + ^ | ~ < > ( ) { } [ ]\nThe search will simply ignore these symbols.\n\n\nUpdate: GitHub supports literal strings now, but you can also try some more powerful ways below.\n\nTry Sourcegraph\nFor complex search with regex support try Sourcegraph.\n\n\nClone and use git-grep:\ngit support searching in sources with git-grep command. Just clone a repository and use the command in the folder:\ngit grep \"text-to-search\"\n\nAlternatives:\nI recommend you to try ripgrep tool, it's fast and simple. Works like git-grep but looks nicer:\nrg \"text-to-search\"\n\nAnd you can use the standard grep to search any text in files:\ngrep -r \"text-to-search\" /repository"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-submodule - Initialize, update or inspect submodules -N --no-fetch"
},
{
"role": "assistant",
"content": "This option is only valid for the update command.\nDon’t fetch new objects from the remote site."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout - Switch branches or restore working tree files <start-point>"
},
{
"role": "assistant",
"content": "The name of a commit at which to start the new branch; see git-branch for details. Defaults to HEAD . As a special case, you may use \"A...B\" as a shortcut for the\nmerge base of A and B if there is exactly one merge base. You can\nleave out at most one of A and B , in which case it defaults to HEAD ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can a Git hook automatically add files to the commit?\nI'd like to add an automatically generated file to the same commit using a pre- or post-commit hook in Git, dependent on the files that were modified in that commit. How would I go about this?\nI've tried this as a pre-commit hook, but no luck:\n#!/bin/sh\nfiles=`git diff --cached --name-status`\nre=\"<files of importance>\"\nif [[ $files =~ $re ]]\nthen\n echo \"Creating files\"\n exec bundle exec create_my_files\n exec git add my_files\n exec git commit --amend -C HEAD\nfi\n\nThis successfully adds them to the repository, but does not add them to the commit. I've also tried using the last two exec lines in a post-commit hook along with the pre-commit inspection, but no good either."
},
{
"role": "assistant",
"content": "Since git add was also not working for me in a pre commit, I followed mark's idea of using a .commit file and splitting the process into pre- and post-commit.\nHere is some code that should be easy to understand\nIn the pre-commit:\n\n\nTouch a file .commit or something. (be sure to add this to .gitignore)\n\n\n#!/bin/sh \necho \ntouch .commit \nexit\n\nIn the post-commit:\n\nif .commit exists you know a commit has just taken place but a\n post-commit hasn't run yet. So, you can do your code generation here.\n Additionally, test for .commit and if it exists:\n\nadd the files\ncommit --amend -C HEAD --no-verify (avoid looping)\ndelete .commit file\n\n\n#!/bin/sh\necho\nif [ -e .commit ]\n then\n rm .commit\n git add yourfile\n git commit --amend -C HEAD --no-verify\nfi\nexit\n\nHope this makes it easier for people with few bash knowledge to follow mark's idea."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do you get git to always pull from a specific branch?\nI'm not a git master, but I have been working with it for some time now, with several different projects. In each project, I always git clone [repository] and from that point, can always git pull, so long as I don't have outstanding changes, of course.\nRecently, I had to revert to a previous branch, and did so with git checkout 4f82a29. When I was again ready to pull, I found that I had to set my branch back to master. Now, I can not pull using a straight git pull but instead, have to specify git pull origin master, which is annoying, and indicates to me that I don't fully understand what is going on.\nWhat has changed which does not allow me to do a straight git pull without specifying origin master, and how to I change it back?\nUPDATE:\n-bash-3.1$ cat config\n[core]\n repositoryformatversion = 0\n filemode = true\n bare = false\n logallrefupdates = true\n[branch \"master\"]\n[remote \"origin\"]\n url = [email protected]:user/project.git\n fetch = refs/heads/*:refs/remotes/origin/*\n\nUPDATE 2: To be clear, I understand that my original method may have been incorrect, but I need to fix this repo so that I can simply use git pull again. Currently, git pull results in:\n-bash-3.1$ git pull\nYou asked me to pull without telling me which branch you\nwant to merge with, and 'branch.master.merge' in\nyour configuration file does not tell me either. Please\nname which branch you want to merge on the command line and\ntry again (e.g. 'git pull ').\nSee git-pull(1) for details on the refspec.\n\nIf you often merge with the same branch, you may want to\nconfigure the following variables in your configuration\nfile:\n\n branch.master.remote = \n branch.master.merge = \n remote..url = \n remote..fetch = \n\nSee git-config(1) for details.\n\nI can tell git pull which branch to merge, and it works correctly, but git pull does not work as it did originally before my git checkout."
},
{
"role": "assistant",
"content": "Under [branch \"master\"], try adding the following to the repo's Git config file (.git/config):\n[branch \"master\"]\n remote = origin\n merge = refs/heads/master\n\nThis tells Git 2 things:\n\nWhen you're on the master branch, the default remote is origin.\nWhen using git pull on the master branch, with no remote and branch specified, use the default remote (origin) and merge in the changes from the remote master branch.\n\nI'm not sure why this setup would've been removed from your configuration, though. You may have to follow the suggestions that other people have posted, too, but this may work (or help at least).\nIf you don't want to edit the config file by hand, you can use the command-line tool instead:\n$ git config branch.master.remote origin\n$ git config branch.master.merge refs/heads/master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to create a new (and empty!) \"root\" branch?\nI would like to define a new \"root\" branch in this git repository. By \"root\" branch I mean a branch that is entirely independent of all the other branches in the repository1.\nUnfortunately, even the commit (let's call it A) at the very base of the repo's commit tree contains a lot of files (this was a repository that was initialized on an already fairly mature project).\nThis means that even if I gave A as the new branch's <start-point>, this new branch would not start from a \"clean slate\", but rather it would contain all the files that were committed in A.\nIs there some way I can create a completely bare branch in this repository, with <start-point> as close to A as possible?\n\n1BTW, this is not equivalent to creating a new repo. Separate repos would be less convenient for a lot of reasons.\n\nEDIT: OK, this is what I did, based on vcsjones' answer:\n# save rev of the current earliest commit\nOLDBASE=$(git rev-list --max-parents=0 HEAD)\n\n# create a new orphan branch and switch to it\ngit checkout --orphan newbranch\n# make sure it's empty\ngit rm -rf .\n\n# create a new empty commit in the new branch, and\n# save its rev in NEWBASE\ngit commit --allow-empty -m 'base commit (empty)'\nNEWBASE=$(git rev-list HEAD)\n\n# specify $NEWBASE as the new parent for $OLDBASE, and\n# run filter-branch on the original branch\necho \"$OLDBASE $NEWBASE\" > .git/info/grafts\ngit checkout master\ngit filter-branch\n\n# NOTE: this assumes that the original repo had only one\n# branch; if not, a git-filter-branch -f <branch> command\n# need to be run for each additional branch.\n\nrm .git/info/grafts\n\nAlthough this procedure is a bit involved, the end result is an empty base commit that can serve as the <start-point> for any new \"clean-slate branch\"; all I'd need to do then is\ngit checkout -b cleanslate $(git rev-list --max-parents=0 HEAD)\n\nIn the future I will always create new repositories like this:\ngit init\ngit commit --allow-empty -m 'base commit (empty)'\n\n...so that the first commit is empty, and always available for starting a new independent branch. (This would be, I know, a very rarely needed facility, but it is quite effortless to make it readily available.)"
},
{
"role": "assistant",
"content": "Use the --orphan when creating the branch:\ngit checkout --orphan YourBranchName\n\nThis will create a new branch with zero commits on it, however all of your files will be staged. At that point you could just remove them.\n(\"remove them\": A git reset --hard will empty the index, leaving you with an empty working tree)\nTake a look at the man page for checkout for more information on --orphan."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout - Switch branches or restore working tree files --"
},
{
"role": "assistant",
"content": "Do not interpret any more arguments as options."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Adding a collaborator to my free GitHub account?\n\nI created a GitHub account, and I want to give someone write access so he can push just like me, there is a way to add a collaborator with a free plan? If not, what can I do? (besides buying a paid account, which I'll do in the future)"
},
{
"role": "assistant",
"content": "Go to Manage Access page under settings (https://github.com/user/repo/settings/access) and add the collaborators as needed.\nScreenshot:"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary hook"
},
{
"role": "assistant",
"content": "During the normal execution of several Git commands, call-outs are made\nto optional scripts that allow a developer to add functionality or\nchecking. Typically, the hooks allow for a command to be pre-verified\nand potentially aborted, and allow for a post-notification after the\noperation is done. The hook scripts are found in the $GIT_DIR/hooks/ directory, and are enabled by simply\nremoving the .sample suffix from the filename. In earlier versions\nof Git you had to make them executable."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs -X[<param1,param2,…>] --dirstat[=<param1,param2,…>]"
},
{
"role": "assistant",
"content": "Output the distribution of relative amount of changes for each\nsub-directory. The behavior of --dirstat can be customized by\npassing it a comma separated list of parameters.\nThe defaults are controlled by the diff.dirstat configuration\nvariable (see git-config ).\nThe following parameters are available: changes Compute the dirstat numbers by counting the lines that have been\nremoved from the source, or added to the destination. This ignores\nthe amount of pure code movements within a file. In other words,\nrearranging lines in a file is not counted as much as other changes.\nThis is the default behavior when no parameter is given. lines Compute the dirstat numbers by doing the regular line-based diff\nanalysis, and summing the removed/added line counts. (For binary\nfiles, count 64-byte chunks instead, since binary files have no\nnatural concept of lines). This is a more expensive --dirstat behavior than the changes behavior, but it does count rearranged\nlines within a file as much as other changes. The resulting output\nis consistent with what you get from the other --*stat options. files Compute the dirstat numbers by counting the number of files changed.\nEach changed file counts equally in the dirstat analysis. This is\nthe computationally cheapest --dirstat behavior, since it does\nnot have to look at the file contents at all. cumulative Count changes in a child directory for the parent directory as well.\nNote that when using cumulative , the sum of the percentages\nreported may exceed 100%. The default (non-cumulative) behavior can\nbe specified with the noncumulative parameter. <limit> An integer parameter specifies a cut-off percent (3% by default).\nDirectories contributing less than this percentage of the changes\nare not shown in the output. Example: The following will count changed files, while ignoring\ndirectories with less than 10% of the total amount of changed files,\nand accumulating child directory counts in the parent directories: --dirstat=files,10,cumulative ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can the owner of a repo see clones?\n\nI know that the owner of a repo is able to see a fork request when one is performed. But what about a clone? Can the owner of the repo see when someone clones it?"
},
{
"role": "assistant",
"content": "The question is too general, but let me answer the question as it stands now.\n\nCan the owner of the repo see when someone clones it?\n\nNo, they cannot. If I go to one of your repositories and clone it to my local hard drive, the owner will not be able to view that activity. And why would you want to? Likely there are many clones of your repository.\nKnow that clones can live on other systems than GitHub.\nNow, will the owner know that someone forked their repository on GitHub itself?\nYes, they will, assuming they pay attention.\nI did the following:\n\nLogged in as my main account\nCreated a repository\nSet up a new dummy-account on an alternate email address\nForked the repository I created earlier\nLogged back into my main account\n\nThis is what I see on my first page after logging in:\n\nIf I do the following:\n\nClick on my repository\n\nClick on the small 1 to the right of the \"Fork\" button:\n\n\nClick on the \"Members\" tab:\n\n\nThen I see this:\n\n\n\nConclusion:\nYes, the owner of a repository will see when someone makes a fork on GitHub, but no, they will not see it when someone makes a clone somewhere else."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What are the differences between double-dot \"..\" and triple-dot \"...\" in Git diff commit ranges?\nWhat are the differences between the following commands?:\ngit diff foo master # a \ngit diff foo..master # b\ngit diff foo...master # c\n\nThe diff manual talks about it:\n\nComparing branches\n$ git diff topic master <1>\n$ git diff topic..master <2>\n$ git diff topic...master <3>\n\n\nChanges between the tips of the topic and the master branches.\nSame as above.\nChanges that occurred on the master branch since when the topic branch was started off it.\n\n\nbut isn't totally clear to me."
},
{
"role": "assistant",
"content": "Since I'd already created these images, I thought it might be worth using them in another answer, although the description of the difference between .. (dot-dot) and ... (dot-dot-dot) is essentially the same as in manojlds's answer.\nThe command git diff typically¹ only shows you the difference between the states of the tree between exactly two points in the commit graph. The .. and ... notations in git diff have the following meanings:\n# Left side in the illustration below:\ngit diff foo..bar\ngit diff foo bar # same thing as above\n\n# Right side in the illustration below:\ngit diff foo...bar\ngit diff $(git merge-base foo bar) bar # same thing as above\n\n\nIn other words, git diff foo..bar is exactly the same as git diff foo bar; both will show you the difference between the tips of the two branches foo and bar. On the other hand, git diff foo...bar will show you the difference between the \"merge base\" of the two branches and the tip of bar. The \"merge base\" is usually the last commit in common between those two branches, so this command will show you the changes that your work on bar has introduced, while ignoring everything that has been done on foo in the mean time.\nThat's all you need to know about the .. and ... notations in git diff. However...\n\n... a common source of confusion here is that .. and ... mean subtly different things when used in a command such as git log that expects a set of commits as one or more arguments. (These commands all end up using git rev-list to parse a list of commits from their arguments.)\nThe meaning of .. and ... for git log can be shown graphically as below:\n\nSo, git rev-list foo..bar shows you everything on branch bar that isn't also on branch foo. On the other hand, git rev-list foo...bar shows you all the commits that are in either foo or bar, but not both. The third diagram just shows that if you list the two branches, you get the commits that are in either one or both of them.\nWell, I find that all a bit confusing, anyway, and I think the commit graph diagrams help :)\n¹ I only say \"typically\" since when resolving merge conflicts, for example, git diff will show you a three-way merge."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "vscode search for a text only in git changes\nBefore to publish branch sometimes I want to search for a specific keyword to ensure I have fixed it correctly everywhere. The problem is, I want to search it only in changes not for a whole project.\nIs it possible?"
},
{
"role": "assistant",
"content": "As AsGoodAsItGets pointed out in one of the comments there is a feature request pending on VS Code github which will allow us to do that.\nIn the meantime I have a workaround:\n\nClose all open files\nOpen Source Control\n\n\n\nRight click on Changes and choose Open changed files. Note that it will open also deleted files.\n\n\n\nGo to Search and select Search only in Open Editors\n\n\nNot ideal, but that's how I search for my console.log leftovers ;)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-update-server-info"
},
{
"role": "assistant",
"content": "Update auxiliary info file to help dumb servers"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git status shows fatal: bad object HEAD\nI have a problem with git on Windows Azure. Git status shows - \"fatal: bad object HEAD\" and I tried running:\n git fsck --full\n git gc\n\nBut git fsck shows:\nbroken link from commit 739df633f185ce5d1ab7eb97d619b28e7d81185a\n to tree 2a6d4876d135c1fa7cbe1348c62570006e895fc5\nbroken link from commit 9c7eae5ffed34dbfac977e515dee675626b59f93\n to tree 400132d215ab9aced883a9971e648b82624b2032\nbroken link from commit 9c7eae5ffed34dbfac977e515dee675626b59f93\n to commit 4a49af0a0cb64a0a0415734b11772d6df18561fb\nbroken link from commit bc3072f30e71c616a8196089e19a67a2c9c0a5ad\n to tree 0aa813c183487d0a1b1f7ae81501ca7a1168283f\nbroken link from commit d3bb4f8545e91ec8ace15ad31a3147d92a1d4242\n to tree 4682108accd8e72fe68858232386dffe60f9f02d\nbroken link from commit 6b34795c4b54286301bcdc0ed254a04c132cb2ad\n to tree 5c57dd3222d11924dba841d3cae517bdc9220601\nbroken link from commit d70172d855391b93bc1c5eeb9b4226df525dfc6e\n to commit 390c8cbd527c8e707c51e25142e54421f4dd3948\nbroken link from commit cc05e8d2e3733693ebb67d697ae4b65e51fea79a\n to commit 32f081f8b901425fd1e8898478f0551970bee0f5\nbroken link from tree 6a75ed6d0311d800078e77f43d427d128372d5bc\n to blob 4a064d610c0e7207967d59934c8bc5f491f26dae\nbroken link from tree 6a75ed6d0311d800078e77f43d427d128372d5bc\n to tree 5c06ec964dcbade49287d0f36efe1f7b60f446e3\nbroken link from tree b4855fa6734b5652a93a9b799eafe47fad0d13a0\n to blob 3e1fb421613dc9066cbf9c95eddc61619a9f8eed\nbroken link from tree b4855fa6734b5652a93a9b799eafe47fad0d13a0\n to tree 556a50048d42346c283c94b78ea278ba1d57d251\nbroken link from tree 289c03409370c4ca7c12266ce2822a2976bd032b\n to blob 3abf3c48ada45f63404dcf4d675ddfdadcfa83c6\nbroken link from tree 289c03409370c4ca7c12266ce2822a2976bd032b\n to blob 3fa569892003b468ed1301426dd6d96d9644be3c\nbroken link from tree 289c03409370c4ca7c12266ce2822a2976bd032b\n to blob 0a9a54a51e84f3bc34122dbce1146d895fcbe22c\nbroken link from tree 289c03409370c4ca7c12266ce2822a2976bd032b\n to blob 3fa48873564361b4d95830803ae77f79eeafaf5b\n\ngit branch shows - *master"
},
{
"role": "assistant",
"content": "try this; it worked for me (Warning: this destroys work that exists only in your local repo):\n rm -rf .git \nYou can use mv instead of rm if you don't want to lose your stashed commits\nthen copy .git from other clone\n cp <pathofotherrepository>/.git . -r\nthen do\n git init \nthis should solve your problem , ALL THE BEST"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Find which commit is currently checked out in Git\nI'm in the middle of a git bisect session. \nWhat's the command to find out which commit (SHA1 hash) I am currently on? git status does not provide this. \nEdit: I guess calling git log and looking at first entry works?"
},
{
"role": "assistant",
"content": "You have at least 5 different ways to view the commit you currently have checked out into your working copy during a git bisect session (note that options 1-4 will also work when you're not doing a bisect):\n\ngit show.\ngit log -1.\nBash prompt.\ngit status.\ngit bisect visualize.\n\nI'll explain each option in detail below. \nOption 1: git show\nAs explained in this answer to the general question of how to determine which commit you currently have checked-out (not just during git bisect), you can use git show with the -s option to suppress patch output:\n$ git show --oneline -s\na9874fd Merge branch 'epic-feature'\n\nOption 2: git log -1\nYou can also simply do git log -1 to find out which commit you're currently on.\n$ git log -1 --oneline\nc1abcde Add feature-003\n\nOption 3: Bash prompt\nIn Git version 1.8.3+ (or was it an earlier version?), if you have your Bash prompt configured to show the current branch you have checked out into your working copy, then it will also show you the current commit you have checked out during a bisect session or when you're in a \"detached HEAD\" state. In the example below, I currently have c1abcde checked out:\n# Prompt during a bisect\nuser ~ (c1abcde...)|BISECTING $\n\n# Prompt at detached HEAD state \nuser ~ (c1abcde...) $\n\nOption 4: git status\nAlso as of Git version 1.8.3+ (and possibly earlier, again not sure), running git status will also show you what commit you have checked out during a bisect and when you're in detached HEAD state:\n$ git status\n# HEAD detached at c1abcde <== RIGHT HERE\n\nOption 5: git bisect visualize\nFinally, while you're doing a git bisect, you can also simply use git bisect visualize or its built-in alias git bisect view to launch gitk, so that you can graphically view which commit you are on, as well as which commits you have marked as bad and good so far. I'm pretty sure this existed well before version 1.8.3, I'm just not sure in which version it was introduced:\ngit bisect visualize \ngit bisect view # shorter, means same thing"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs log.initialDecorationSet"
},
{
"role": "assistant",
"content": "By default, git log only shows decorations for certain known ref\nnamespaces. If all is specified, then show all refs as\ndecorations."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-clean - Remove untracked files from the working tree filter by pattern"
},
{
"role": "assistant",
"content": "This shows the files and directories to be deleted and issues an\n\"Input ignore patterns>>\" prompt. You can input space-separated\npatterns to exclude files and directories from deletion.\nE.g. \"*.c *.h\" will exclude files ending with \".c\" and \".h\" from\ndeletion. When you are satisfied with the filtered result, press\nENTER (empty) back to the main menu."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Where to host an Open Source Project: CodePlex, Google Code, SourceForge? [closed]\n\nAs it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.\n \n \n\n\n\nClosed 11 years ago.\n\n\n\nI have been reading through the backlog of answered questions on SO regarding \"How to promote an open source project\". Not surprisingly, many of the answers pointed people to SoureForge/FreshMeat and other sites etc as well as blogging and whatnot. This started me thinking where is the best place to host a project and why?\nAs my first project is currently hosted on CodePlex, I started to wade through the Google search results to collect information on the pros/cons of each; however the comparisons that I found are rather dated (2+ years old). \nhttp://www.stum.de/2008/12/13/sourceforge-vs-codeplex/\nhttp://www.developmentnow.com/blog/2006/11/codeplex-vs-sourceforge/\nhttp://www.spacesocket.com/forum/thread-6654.html\netc...\nSo the next question becomes \"Should I host my project on multiple sites\" to which the following post provides the expected answer (thankfully! as that would be a pain to maintain).\nHosting an open source project at several sites\nBased on the current state of various Open Source hosting sites such as CodePlex, GitHub, Google Code, SourceForge, etc, etc is there any notable pros/cons of one site over the other? i.e., should I stick with CodePlex or am I missing out by not using one of the alternatives? Will one bring about more traffic to a new and unknown project?\nI plan on exploring each site in more detail to see what they all offer, but given the vast knowledge of the good folks on SO, figured I would start with this question first.\nUPDATED\nAs per erjiang answer below... I am currently using Mercurial for version control, and I am open to anything other than TFS. Also, my current project is only me developing, but future projects may be collaborative so worth considering..."
},
{
"role": "assistant",
"content": "Edit 2015-08-01: This answer is still getting views and votes. It's more than ancient and I'd like to delete it, but since it's the accepted answer, I can't do that. Then again, it's community wiki and the community has kept it up-to-date - thank you for that!\nSourceForge has crossed over to the dark side, taking over project and bundling them with Adware (Google GIMP Sourceforge Adware). Avoid at all costs. GitHub is as of now still the most popular one, although there are alternatives (e.g., BitBucket offers unlimited private repos for free for up to 5 users.)\nIt's crazy how much the landscape changed in the past few years, and if you're reading this in the future, maybe GitHub is no longer the cool product. Bottom line is: There are a plethora of awesome options for whatever source control system you want to use.\nOld 2010 information below for the sake of history\nEdit: This answer is now ancient. In the past 2 years, GitHub has emerged as the prime Code Hosting place, and whenever I have to create a new OSS project, I don't have the trace of a shadow of a doubt where to go to. Leaving this below for reference.\nIndeed, my posting is almost 2 years old (2008) now and not entirely accurate anymore.\nWhy?\nBecause I think that SourceForge is insignificant now for open source projects. Okay, this will get me into a lot of trouble, so let me clarify:\nI am absolutely convinced that Open Source projects should be run on a DVCS, preferably git or mercurial as they are the most widespread - nothing against Bazaar, but I think it's a bit too obscure. (Edit: SourceForge now offers Mercurial and Bazaar, so that argument doesn't stand anymore. However, following two redesigns I think that SF's image isn't too great. To compare them to the images of companies: While GitHub is Apple, SF is IBM. Rock solid, but a bit dusty)\nSo if I were to write this posting again, it would be CodePlex vs. GitHub vs. BitBucket, with GitHub being the Winner. But that is a blanket statement, so let me add details. +/- isn't strictly Pro/Con, it's more to highlight different philosophies.\nCodePlex\n+ Real Mercurial/Git Hosting - no buggy bridge on top of TFS, you have real Mercurial/Git\n+ Integrated Wiki that allows to add rich documentation and nice looking pages\n+ Bug Tracker and Discussion Forums included\n- Source Code browser isn't that great - Diffs appear in a popup and just 'feel' complicated\n- Forks and Pull Requests 'not as easy' - the UI could use some work\nOverall, CodePlex is still great but I feel it's more suited for single developers or very small teams because the focus of the website is on the Wiki rather than on the source code. It's more a publishing than a collaboration platform. Theoretically you don't need a project homepage, your CodePlex project can be your one stop shop.\nGitHub\n+ Git Hosting, supports SSL/SSH\n+ Network graph allows to see forks and what merged into what when\n+ Ability to 'watch' projects - your account page is like a Facebook wall with new checkins\n+ Super good diff viewer with the ability to comment on single line changes - see here\n+ Forking is a 2-click process, and so is sending pull requests\n+ GitHub now has the the GUI tool GitHub for Windows\n- Main page is not very 'pretty' for Non-Developers. If you have a Readme in your project (supports some markup languages like Markdown or HTML) it is displayed, but the initial page is the source code\n- Wiki isn't that great - it's Markdown, but sometimes formatting feels a bit too complex.\nGitHub has a different philosophy than CodePlex: it's all about the source code and about collaboration among devs. The main project page is the most up to date source code. There is a separate Wiki, but that's more intended for Documentation rather than presentation of your project. The network graph is fantastic, although it can get confusing once there are more than about 20 forks (frequently when a high profile project is announced everyone and their dog is forking it, but most forks die quickly). GitHub scales very well to any size.\nIn fact, GitHub makes it super easy for me to fork a project, apply a fix/patch, commit it to my fork and send a pull request to the author. Together with the Network graph it's really easy to see the commit.\nBut you most likely need a separate home page to present your project to end users and to provide downloads, as GitHubs download facilities aren't that great.\nBitBucket\n+ Git/Mercurial\n+ Allows private repositories for free, up to 5 users\nI haven't used BitBucket enough to make a real comment. The one feature that sets it apart is that private hosting is free, while GitHub charges and Codeplex does not offer it at all.\nGoogle Code\nGoogle Code is not an option anymore.\n- Project creation is disabled since March 2015, and the Google service will be permanently closing down in January 25, 2016, as the competing services are simply better.\n- It's ugly and it's too complicated to browse the source code (the link is somewhat buried)\nI haven't used it so I don't want to say it's bad - it's not. A lot of projects use it and it's very stable and robust, haven't heard much bad from any developer. However, as a matter of personal, subjective opinion the 'design' puts me off.\nSVN vs. Git/Mercurial\nTo reiterate my comment above about SourceForge being obsolete: That is of course a bit harsh. I do however believe that SVN is detrimental for open source projects. First of all, weird metadata requirements to ignore files. On Git or mercurial, you have a file called .gitignore or .hgignore in the root of your source tree which includes a list of files/directories/patterns to ignore. No magic svn:ignore metadata in the .svn folder. This alone blows SVN out of the water for me. If I start a new Visual Studio project I need to then apply that magic metadata, while with Git/mercurial I just copy over one file and be done with it.\nThen, the ability to fork, patch and send a pull request is fantastic, especially for small/one-off patches.\nLast but not least, SourceForge is still WAY too complex for my taste. It's not a bad host, but it really shows it's age IMHO. That being said, it's still robust and has many mirrors world wide. Also the Bug Tracker is much more sophisticated than the others.\nAlso, if your project for some reason requires strict contribution rules (which may make sense, e.g. legal protection to make sure the committed code is indeed legally contributed) then a traditional system like SVN hosted on SourceForge may work.\nEdit: Wasn't aware that SF finally has distributed hosting. As said above, it's robust but just not the 'cool kid' anymore, and I find it much too complex.\nTL;DR\nFor any small to medium project I whole hearty recommend GitHub, for small projects where you want a nice Web Site as well I'd go with CodePlex and for private projects I'd go with BitBucket. For big projects that require a very sophisticated bug tracker, tons of extra features and a 'real' website, consider Source Forge."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-push - Update remote refs along with associated objects --[no-]signed --signed=(true|false|if-asked)"
},
{
"role": "assistant",
"content": "GPG-sign the push request to update refs on the receiving\nside, to allow it to be checked by the hooks and/or be\nlogged. If false or --no-signed , no signing will be\nattempted. If true or --signed , the push will fail if the\nserver does not support signed pushes. If set to if-asked ,\nsign if and only if the server supports signed pushes. The push\nwill also fail if the actual call to gpg --sign fails. See git-receive-pack for the details on the receiving end."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to change line-ending settings\nIs there a file or menu that will let me change the settings on how to deal with line endings?\nI read there are 3 options:\n\nCheckout Windows-style, commit Unix-style\nGit will convert LF to CRLF when checking out text files. When\ncommitting text files, CRLF will be converted to LF. For\ncross-platform projects, this is the recommended setting on Windows\n(\"core.autocrlf\" is set to \"true\")\nCheckout as-is, commit Unix-style\nGit will not perform any conversion when checking out text files.\nWhen committing text files, CRLF will be converted to LF. For\ncross-platform projects this is the recommended setting on Unix\n(\"core.autocrlf\" is set to \"input\").\nCheckout as-is, commit as-is\nGit will not perform any conversions when checking out or committing\ntext files. Choosing this option is not recommended for cross-platform\nprojects (\"core.autocrlf\" is set to \"false\")"
},
{
"role": "assistant",
"content": "The normal way to control this is with git config\nFor example\ngit config --global core.autocrlf true\n\nFor details, scroll down in this link to Pro Git to the section named \"core.autocrlf\"\n\nIf you want to know what file this is saved in, you can run the command:\ngit config --global --edit\n\nand the git global config file should open in a text editor, and you can see where that file was loaded from."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %gd"
},
{
"role": "assistant",
"content": "shortened reflog selector; same as %gD , but the refname\nportion is shortened for human readability (so refs/heads/master becomes just master )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-push - Update remote refs along with associated objects *"
},
{
"role": "assistant",
"content": "for a successfully pushed new ref;"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options stash.showPatch"
},
{
"role": "assistant",
"content": "If this is set to true, the git stash show command without an\noption will show the stash entry in patch form. Defaults to false.\nSee the description of the show command in git-stash ."
}
] |
[
{
"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-lines"
},
{
"role": "assistant",
"content": "Color line annotations in the default format differently if they come from\nthe same commit as the preceding line. This makes it easier to distinguish\ncode blocks introduced by different commits. The color defaults to cyan and\ncan be adjusted using the color.blame.repeatedLines config option."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to run \"git status\" and just get the filenames\nHow can I run \"git status\" and just get the filenames as opposed to the long relative path?"
},
{
"role": "assistant",
"content": "The output of git status --porcelain, designed to be easy to parse in a script, outputs the full paths rather than relative paths regardless of where your current directory is within the tree.\nEach line output by git status --porcelain has two leading characters indicating the status of the file (e.g. whether it's untracked, modified, new, deleted, etc.) followed by a space, so if you just want the full paths of everything that would be mentioned in the output of git status you can do:\ngit status --porcelain | sed s/^...//"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects %H"
},
{
"role": "assistant",
"content": "commit hash"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to create new local branch in Git\nI am working on a project which I cloned from a remote repository hosted on GitLab. I made some changes to the project, but I didn’t create any branch and want to now start work on some other new features, but without first pushing my existing work to the remote repository.\nI might discard the changes in the new feature or might need to push both the new feature as well as the earlier changes to the remote repository, at a later stage.\nFrom what I know about Git, I think I need to create a new local branch, which I can do using git checkout -b NEW_BRANCH_NAME. Is this the correct way to accomplish what I am trying to do? When I use this command, it creates a new branch. How do I switch back and forth between working on this new branch and the earlier one?"
},
{
"role": "assistant",
"content": "You switch back and forth between branches using git checkout <branch name>.\nAnd yes, git checkout -b NEW_BRANCH_NAME is the correct way to create a new branch and switching to it. At the same time, the command you used is a shorthand to git branch <branch name> and git checkout <branch name>."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database missingNameBeforeEmail"
},
{
"role": "assistant",
"content": "(ERROR) Missing name before an email in an author/committer line."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Logout and login as another user git bash\nI want to logout from Git bash and login it again as another user .\nI have googled but can't find any solution."
},
{
"role": "assistant",
"content": "You don't have to \"logout\" or \"login\": regarding git, who you are is determined by:\ngit config user.name\ngit config user.email\n\nChange those two settings while being in a repo, if you are someone else, when it comes to creating commits.\nIf you want to change it in your local machine for all repos, add --global like\ngit config --global user.name [your username]\n\n\nAs suggested by the Deepak swain's answer, you can also change credentials in Windows using the Credentials Manager by typing in the console:\nrundll32.exe keymgr.dll, KRShowKeyMgr\n\nAs Kartik Ranpise answer's and Stuart Axon's contribution\nBut Credentials are about git remote -v, that is with the user account you will use to push to the upstream repo.\n\nfor an HTTPS url, you can simply specify a new user\nfor ssh, you would need a ~/.ssh/config file referring to multiple private ssh keys (also described here). In which case, the Credential Manager would not be involved."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary core Git"
},
{
"role": "assistant",
"content": "Fundamental data structures and utilities of Git. Exposes only limited\nsource code management tools."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fast-import - Backend for fast Git data importers get-mark"
},
{
"role": "assistant",
"content": "Causes fast-import to print the SHA-1 corresponding to a mark\nto the file descriptor set with --cat-blob-fd , or stdout if\nunspecified."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Guide to understanding gitk? [closed]\nClosed. This question is seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. It 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 We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.\n\n\nClosed 9 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI am introducing git to a team of developers and i find gitk to be an amazing tool. It's also quite hard to understand, since understanding gitk requires an understanding of both git history and the viewer tool itself. \nDoes anyone have any good references to something like a \"beginner's guide to git history with gitk\" ?"
},
{
"role": "assistant",
"content": "I've never seen anything specifically for gitk. Here's a stab at it, from a \"how does it work\" point of view. Knowing the commands that are behind everything (or at least generally equivalent) helps learn to use command-line tools more easily, and also shows you where to look in documentation to understand gitk better!\nFile menu\nThis has changed somewhat over the last few major versions - I'm describing the current state.\n\nupdate and reload: This is probably the most confusing thing. Reload refreshes everything as if you started the program over with the same configuration. This means if a branch has been removed/rebased, if some commits are now dangling, you don't see them anymore. Update, on the other hand, refreshes all the information, but still shows all commits that were previously shown. This is an excellent thing to use if you're rebasing and want to make sure you didn't mess up - you can see both the original and rebased versions.\nreferences: pretty obvious. References include tags and branches (which may be remote). You can reread them, and list to click a particular one to show it in the history.\n\nViews\nAs the man page says, gitk takes git-rev-list options to help specify what history should be shown. These can also be set interactively in the \"view\" menu. The man page is an excellent place to find more information about the ways you can control views (it's mostly in the commit limiting section). If you've looked at git-log before, you'll have seen a lot of this.\nHelp\nThere's a list of keybindings here! Sweet.\nContext menu\nThis presents several common git porcelain commands, generally in a common/default mode of operation. Listing them will at least help you find the right documentation to understand what they do, if you don't already!\n\ngit-diff (Diff this <-> selected\ngit-format-patch (make patch)\ngit-tag (create tag)\ngit-diff-tree (write commit to file, rarely used)\ngit-branch\ngit-cherry-pick\ngit-reset (reset branch to here) This prompts you for soft, mixed, or hard, with a brief reminder of what each does. Longer description on the man page, but of course you have to understand the concept of the index to really get it.\n\nThe \"mark a commit\" and related commands should be self-explanatory at this point.\nIn the context menu for a branch, we have git-checkout and the -d (delete) mode of git-branch.\nMiddle section\n\nSHA1 ID: the hash of the current commit. Very useful for copy/paste into a terminal to perform an action on a given commit you used gitk to find. You can also paste hashes into here.\nForward/back buttons, row number... obvious!\nFind! The options here are again pretty self-explanatory, but for everyone's education, they're analogous to git-log parameters: \"containing\" is --grep, \"touching paths\" is the arguments, and adding/removing string is -S (pickaxe).\n\nMessage/diff pane\nHere we have the commit message along with git-diff's output - this is something like using git-log -p, with a little extra:\n\n\"Branches\" is equivalent to git branch -a --contains=<commit>\n\"Precedes\"/\"Follows\" is equivalent to git describe [--contains] <commit> (git-describe)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fast-import - Backend for fast Git data importers --import-marks=<file>"
},
{
"role": "assistant",
"content": "Before processing any input, load the marks specified in\n<file>. The input file must exist, must be readable, and\nmust use the same format as produced by --export-marks.\nMultiple options may be supplied to import more than one\nset of marks. If a mark is defined to different values,\nthe last file wins."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Trying to git pull with error: cannot open .git/FETCH_HEAD: Permission denied\n\nHelp me please, I am trying to run this in my terminal:\nasgard@asgard-A7N8X2-0:~/CollegePortal$ git pull\nerror: cannot open .git/FETCH_HEAD: Permission denied\n\nThen I try this one\nasgard@asgard-A7N8X2-0:~/CollegePortal$ sudo git pull\nPermission denied (publickey).\nfatal: The remote end hung up unexpectedly\n\nHelp me, I don't understand this problem."
},
{
"role": "assistant",
"content": "It seems like the first one isn't working because your user doesn't have the permissions for changing that directory, and the second because your root user doesn't have the right SSH keys for accessing that git repository.\nDepending on what you're trying to do, it might be better to clone the repository to a different directory, or maybe chown the current directory to have full access for your user"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What does a grey icon in remote GitHub mean\nCan anyone please tell me why i have the grey icon when i push my files to github ? In side the app directory, there should be models, views , and controllers but in the remote GitHub I can't click in."
},
{
"role": "assistant",
"content": "git rm --cached <folder_name>\n\nThen go to the parent directory and do:\ngit add .\ngit commit -m \"<your_message>\"\ngit push --all"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --histogram"
},
{
"role": "assistant",
"content": "Generate a diff using the \"histogram diff\" algorithm."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to link to a specific line number on GitHub\nI know I can link to a specific line number on a file on a GitHub repository (I'm sure I've seen this before)...\nHow can I do this?"
},
{
"role": "assistant",
"content": "Don't just link to the line numbers! Be sure to use the canonical URL too. Otherwise when that file is updated, you'll have a URL that points to the wrong lines!\nHow to make a permanent link to the right lines:\nClick on the line number you want (like line 18), and the URL in your browser will get a #L18 tacked onto the end. You literally click on the 18 at the left side, not the line of code. Looks like this:\n\nAnd now your browser's URL looks like this:\nhttps://github.com/git/git/blob/master/README.md?plain=1#L18\n\nIf you want multiple lines selected, simply hold down the Shift key and click a second line number, like line 20. Looks like this:\n\nAnd now your browser's URL looks like this:\nhttps://github.com/git/git/blob/master/README.md?plain=1#L18-L20\n\nHere's the important part:\nNow get the canonical URL for that particular commit by pressing the Y key. The URL in your browser will change to become something like this:\nhttps://github.com/git/git/blob/5bdb7a78adf2a2656a1915e6fa656aecb45c1fc3/README#L18-L20\n\nThat link contains the actual SHA-1 hash for that particular commit, rather than the current version of the file on master. That means that this link will work forever and not point to lines 18-20 of whatever future version of that file might contain.\nNow bask in the glow of your new permanent link. ;-)\nAfter this answer was originally written, watashiSHUN pointed out that GitHub has now made it easier to get the permanent link. A ... menu is provided on the left after you select one or more lines, like this:\n\nPlease see watashiSHUN's answer too.\nNote that GitHub does not show line numbers for some \"renderable\" files, like Markdown files. Adding ?plain=1 to the url will show the source file with line numbers, e.g. https://github.com/git/git/blob/master/README.md?plain=1."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database gitattributesLarge"
},
{
"role": "assistant",
"content": "(ERROR) The .gitattributes blob is too large."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git and working on multiple branches\nI have a couple of Git branches: 'experimental', 'something' and 'master'.\nI switched to the 'experimental' branch. I noticed a bug which is unrelated to 'experimental' and belongs to changes which have been made in 'something'. How should I fix it?\nI'm thinking I should switch to 'something', fix the bug, commit and then move back to 'experimental'. How should I take the minor change from 'something' and apply it to both 'master' and 'experimental' so that I don't have to re-fix the bug again when I switch into these branches?"
},
{
"role": "assistant",
"content": "There are two solutions not mentioned already that you can use: use a topic branch or use cherry-picking.\n\nTopic branch solution\nIn the topic branch solution, you switch to branch 'something', create a branch to fix a bug e.g. 'something-bugfix', merge this branch into 'something' (fixing the bug), then merge this branch into 'experimental'.\n$ git checkout -b something-fix something\n[edit, commit]\n$ git checkout something\n$ git merge something-fix\n$ git checkout experimental\n$ git merge something-fix\n[fix conflicts if necessary and commit]\n\nSee also Resolving conflicts/dependencies between topic branches early and Never merging back, and perhaps also Committing to a different branch blog posts by Junio C Hamano (git maintainer).\n\nCherry-picking a bugfix\nThe cherry-picking solution is useful if you noticed later that the bugfix you created (e.g. on development branch) would be useful also on other branch (e.g. stable branch). In your case you would comit a fix on 'something' branch:\n$ git checkout something\n[edit, edit, edit]\n$ git commit\n$ git checkout experimental\n\nThen you noticed that fix you comitted in 'something' branch should be also on 'experimenta' branch. Lets say that this bugfix was commit 'A' (e.g. 'something' if you didn't commit anything on top of 'something', but it might be e.g. 'something~2' or 'c84fb911'):\n$ git checkout experimental\n$ git cherry-pick A\n\n(you can use --edit option to git cherry-pick if you want to edit commit message before comitting cherry-picked bugfix)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Move tag one commit ahead\nI have a repository with only one branch (master). I'm the only contributor to my repo.\nI've recently added a tag, both locally and pushed to GitHub. After making what I though was the last necessary commit, but now I realize I should have made one more change/commit.\nSo what I have is:\ncommit 124\ncommit 125\ncommit 126 <-- tag v1.0\ncommit 127\n\nand I want to move the v1.0 tag to the next commit, ie: 127, both locally and in GitHub.\nHow can I do that?"
},
{
"role": "assistant",
"content": "Have you ever been to a book club where members do not all use the same edition of the \"book of the week\"? It's a nightmare, right? Moving a tag would essentially put you in the same situation.\nIf you think of your repository as a book that chronicles progress in your project, you can think of a tag as a chapter heading.\n\nMoving a tag to a different commit after sharing it is like telling all your book-club buddies\n\nYou know what, guys? The edition of the book we've all been using so far is now obsolete, because I have solely decreed that chapter 8 shall now start, not on page 126, but on page 128.\n\nNot good. Moving a tag is a form of history rewriting, and you shouldn't rewrite history that has been shared. It's the surest way to piss your collaborators off. Besides, you write\n\nI'm the only contributor to my repo [...]\n\nThat may be true for now, but if other people than you have access to your GitHub repository (e.g. if it's public), some of them may already have forked or cloned it (although there is a way to find out), and you run the risk of pissing them off if you rewrite history.\n\nIf you're 100% sure that you want to move that tag anyway, Git does allow you to do it. Here, you could use\ngit tag --force v1.0 <ID-of-commit-127>\n\nand then you would have to force push that tag, using\ngit push --force --tags\n\nBut again, think twice before going ahead...\nAddendum (2018/09/26)\nI feel the need to revisit my answer...\nOver the years, some people have objected in the comments to my injunction not to move an already published tag. Of course, this piece of advice is contextual rather than universal; I don't doubt that good cases for moving a published tag exist. However, I stand firm in the belief that, as a general rule, the decision to move a published tag should be made deliberately and with extreme care.\nOne recent example comes to mind. Go 1.11 added experimental support for a module system that relies heavily on Git tags for versioning. Moving a tag in a Go module that has been published (on GitHub, say) would have disastrous consequences.\nBy doing so, you would break the contract established between you (the module author) and your users (those who depend on your module), because you would negate the guarantees that Go's module system intends to provide:\n\nModules record precise dependency requirements and create reproducible builds.\n\nThat's one sure way to piss people off.\nThis example may be enough to convince you that, at least in some cases, you shouldn't mindlessly move published tags. I rest my case."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do you move multiple files in git?\nI try:\ngit mv a.py b.py src/\nand get\nfatal: multiple sources for the same target, source=b.py, destination=src/b.py\nUsing the -n flag, like so git mv -n a.py b.py src/\ngives me:\nChecking rename of 'a.py' to 'src/b.py'\nChecking rename of 'b.py' to 'src/b.py'\nfatal: multiple sources for the same target, source=b.py, destination=src/b.py\n\nAm I doing something really stupid? I'm using git version 1.6.6.1"
},
{
"role": "assistant",
"content": "I use bash loop:\nfor FILE in src/*.h; do git mv $FILE include/; done"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "got 'fatal: branch 'master' does not exist' in git\nusing git for a while, it's very powerful and beautiful.. \nbut also got some confused about it: \nit should under branch master after I init a git repo, isn't it? \nbut git branch -a, i got nothing man.\nand I got fatal: branch 'master' does not exist when I try to set upstream for my branch. \nusers@debian MINGW64 ~/Desktop/taste\n$ git init\nInitialized empty Git repository in C:/Users/users/Desktop/taste/.git/\n\nusers@debian MINGW64 ~/Desktop/taste (master)\n$ git remote add origin [email protected]:greedev/Test.git\n\nusers@debian MINGW64 ~/Desktop/taste (master)\n$ git branch -u origin/master\nfatal: branch 'master' does not exist\n\nusers@debian MINGW64 ~/Desktop/taste (master)\n$ git branch -a\n\nusers@debian MINGW64 ~/Desktop/taste (master)\n$ git fetch\nThe authenticity of host 'gitee.com (120.55.226.24)' can't be established.\nECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.\nAre you sure you want to continue connecting (yes/no)? yes\nWarning: Permanently added 'gitee.com,120.55.226.24' (ECDSA) to the list of know n hosts.\nremote: Counting objects: 7, done.\nremote: Compressing objects: 100% (6/6), done.\nremote: Total 7 (delta 0), reused 0 (delta 0)\nUnpacking objects: 100% (7/7), done.\nFrom gitee.com:greedev/Test\n* [new branch] master -> origin/master\n\nusers@debian MINGW64 ~/Desktop/taste (master)\n$ git branch -a\n remotes/origin/master\n\nusers@debian MINGW64 ~/Desktop/taste (master)\n$ git branch -u origin/master\nfatal: branch 'master' does not exist"
},
{
"role": "assistant",
"content": "TL;DR\nYou can git checkout master at this point.\nLonger description (but still not that long)\nYou are doing this the hard way.\nIn the future, instead of:\nmkdir repo\ncd repo\ngit init\ngit remote add origin <url>\ngit fetch origin\ngit checkout master\n\nyou can simply run:\ngit clone <url> repo\n\nsince the six commands above are pretty much what git clone does.\nAfter the first three steps—creating a new, totally-empty repository—you have a repository that is in a peculiar state: it has no commits, so it has no branches. At the same time, it does have a current branch, which is master.\nIn other words, the current branch is a branch that does not exist.\nThis state is unusual, but normal. If you run git checkout --orphan newbranch, you put your Git repository into that same state:1 on a branch that does not exist. The branch gets created once there is a commit hash to store under the branch name.\nWhenever you run git checkout <name> and there is no branch named <name>, Git checks to see if there is exactly one remote-tracking branch such as origin/<name>. If so, Git creates a new branch named <name> that points to the same commit as origin/<name> and that has origin/<name> as its upstream.\nSince this last step—git checkout master when master does not actually exist yet—is the final step of git clone, git clone will also create a new branch master that tracks the remote-tracking branch origin/master.\n\n1Note that you retain the current index / staging-area content. This is true for the new empty repository as well, but since it's a new empty repository, the index / staging-area is also empty, and \"retaining the empty set\" does not feel much like retainment."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-stash - Stash the changes in a dirty working directory away create"
},
{
"role": "assistant",
"content": "Create a stash entry (which is a regular commit object) and\nreturn its object name, without storing it anywhere in the ref\nnamespace.\nThis is intended to be useful for scripts. It is probably not\nthe command you want to use; see \"push\" above."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I add Git tags in Bitbucket?\nI'm hosting my code on Bitbucket using Git. My local client is EGit (eclipse plugin). I created a tag locally (Team -> Advanced -> Tag) and then pushed it to remote repository. But when I open my repository page, I can't find tags there. I'm pretty sure the tag can be seen locally.\nI'm not a Git expert. But it seems to me there are several types of tags in Git. Does Bitbucket only show certain types of tags?"
},
{
"role": "assistant",
"content": "Did you click the button \"Add All Tags Spec\" in Push Wizard in Eclipse? If not, try it.\nOr if you have access to console version of git just perform:\ngit push --tags"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I clear my local working directory in Git? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do I remove local (untracked) files from the current Git working tree?\n\n (42 answers)\n \n\nClosed 10 years ago.\n\n\n\nHow can I clear my working directory in Git?"
},
{
"role": "assistant",
"content": "To reset a specific file to the last-committed state (to discard uncommitted changes in a specific file):\ngit checkout thefiletoreset.txt\n\nThis is mentioned in the git status output:\n(use \"git checkout -- <file>...\" to discard changes in working directory)\n\nTo reset the entire repository to the last committed state:\ngit reset --hard\n\nTo remove untracked files, I usually just delete all files in the working copy (but not the .git/ folder!), then do git reset --hard which leaves it with only committed files.\nA better way is to use git clean (warning: using the -x flag as below will cause Git to delete ignored files): \ngit clean -d -x -f\n\nwill remove untracked files, including directories (-d) and files ignored by git (-x). Replace the -f argument with -n to perform a dry-run or -i for interactive mode, and it will tell you what will be removed.\nRelevant links:\n\ngit-reset man page\ngit-clean man page\ngit ready \"cleaning up untracked files\" (as Marko posted)\nStack Overflow question \"How to remove local (untracked) files from the current Git working tree\")"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitLab CI: Get source branch after merge-request has been accepted\n\nI have a master branch which is supposed to only get commits by merging either a \"release/xxxxx\" branch into it or by merging a \"hotfix/xxxxx\" branch into it.\nThe pipeline for a release branch builds a docker image and publishes it using the tag \"beta\".\nThe pipeline for a release branch builds a docker image and publishes it using the tag \"hotfix\".\nThe pipeline for the master simply re-tags either \"beta\" to \"stable\" (when a release branch has been merged into the master) or \"hotfix\" to \"stable\" (when a hotfix branch has been merged into the master). Then it also creates a new git tag for that version and a release in gitlab. Finally the docker image gets deployed.\nCurrently the following happens:\n\nA merge request is created to merge \"release/xxxxx\" into \"master\".\nThe pipeline starts automatically (before the merge request has been accepted and merged).\nThe docker job parses the CI_MERGE_REQUEST_SOURCE_BRANCH_NAME variable to determine the source branch of the merge request was a release branch.\nThe docker job then re-tags \"beta\" to \"latest\".\nThe git tag job adds a version tag and gitlab release to the project.\nThe deploy job deploys the docker image.\n\nWhen the merge request is finally accepted the following happens:\n\nThe pipeline starts again.\nThe docker job parses CI_MERGE_REQUEST_SOURCE_BRANCH_NAME which is now empty and thus fails to determine the source branch for this merge.\nThe docker job fails.\n\nI think it's pretty obvious that I don't want to run all these jobs (especially the deploy job) before the merge request has been accepted. \nBut I can't think of a good way to only run the pipeline on the master after a merge-request has been accepted and then still be able to determine the source branch."
},
{
"role": "assistant",
"content": "Using only information stored in git :\nwhen running after a merge request has been accepted, the HEAD commit should be the result of the merge, so HEAD^2 should be the head commit of the branch that was merged.\nYou can have information on :\n\nthe tags that point directly at this commit :\n git tag --points-at HEAD^2\n\n\nthe branches that point directly at this commit :\n git branch --points-at HEAD^2 # for local branches\n git branch -r --points-at HEAD^2 # for remote branches\n\n\nthe branches that contain this commit :\n git branch --contains HEAD^2 # for local branches\n git branch -r --contains HEAD^2 # for remote branches\n\n\n\nUsing environment variables set by gitlab :\nafter reading the predefined variables doc page, I was surprised not to find variables that would indicate that the job was triggered after a merge request was accepted.\nYou may look into gitlab's webhooks : Merge requests events ; these should provide enough information to identify what branches were involved in the merge request after it has been accepted.\n[update] you can also use gitlab's API, see @BastienSander's answer"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Should bower_components be gitignored?\nWould it be good practice to keep only the bower.json file and gitignore the whole bower_components directory?"
},
{
"role": "assistant",
"content": "The official Bower page stated:\n\nN.B. If you aren't authoring a package that is intended to be consumed by others (e.g., you're building a web app), you should always check installed packages into source control.\n\nMake sure to check out the link in the quote, it discusses some pro and cons. The main pro it mentions is that checking them in ensures that your dependencies are always available, as long as your repository is available. No matter what happens to Bower, GitHub or whatever else would be needed otherwise."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to see which files were changed in last commit\nIn this commit message, it says that 2 files have been changed. \n$ git commit -m \"fixed .gitignore\"\n[master c30afbe] fixed .gitignore\n Committer: Sahand Zarrinkoub <[email protected]>\nYour name and email address were configured automatically based\non your username and hostname. Please check that they are accurate.\nYou can suppress this message by setting them explicitly. Run the\nfollowing command and follow the instructions in your editor to edit\nyour configuration file:\n\n git config --global --edit\n\nAfter doing this, you may fix the identity used for this commit with:\n\n git commit --amend --reset-author\n\n 2 files changed, 5 insertions(+), 4 deletions(-)\n\nThis is a little surprising for me. I thought I'd only staged one file to be changed. Now, I'd like to see which files have been changed and how. What is the way to do this?"
},
{
"role": "assistant",
"content": "Get all changed files in the last commit\ngit diff --name-only HEAD HEAD~1"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: How to make outer repository and embedded repository work as common/standalone repository?\nI have a big project(let's say A repo), and it there one child folder which is come from B repo. I would meet warning like below when I commit from A repo\nwarning: adding embedded git repository: extractor/annotator-server\nhint: You've added another git repository inside your current repository.\nhint: Clones of the outer repository will not contain the contents of\nhint: the embedded repository and will not know how to obtain it.\nhint: If you meant to add a submodule, use:\nhint:\nhint: git submodule add <url> extractor/annotator-server\nhint:\nhint: If you added this path by mistake, you can remove it from the\nhint: index with:\nhint:\nhint: git rm --cached extractor/annotator-server\nhint:\nhint: See \"git help submodule\" for more information.\n\nI have seen git-submodule and git-subtree:\nMaintaining Git repo inside another git repo\nhttps://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree\nBut I don't like them , because they need extra config.\n\nWhat I want is , for example:\nstructure like:\nA/\n--- a.py\n\n--- B/\n--- B/b.py\n\nWhen I change B/b.py .\n\nIf I am on path A/ , git add can detect B/b.py changed, git push only commit that to A repo. \ngit add . (would add changes under A/ )\ngit push (would push changes under A/ )\ngit pull (would pull changes under A/ )\ngit clone XXX:A (would clone all files under A/ , A/B/ is just looks like plain folder with all files, not a repo )\n\nIf I am on path A/B/ , git add only add B/b.py changes to B repo, and git push only commit that to B repo. \ngit add . (would add changes under B/ , but not add changes to A repo)\ngit push (would push changes under B/ , but not push changes to A repo)\ngit pull (would clone changes under B/ , )\ngit clone XXX:B (would clone all files under B/ )\n\nOnce I want to snyc A and B in another machine, just do\ngit clone A\nrm -rf A/B/\ngit clone B ./B\ngit add . && git commit 'sync with B'\n\n\nIn another word, A and B act as a standalone repo.\nBut the truth is , A repo treat B repo as submodule: \nA repo\nhttps://github.com/eromoe/test\nB repo\nhttps://github.com/eromoe/test2\n\nHow do I force A repo track all files under A/ , and B repo track all files under A/B/ ? I want A and B act as a self-contain repo , without any other config."
},
{
"role": "assistant",
"content": "You can use below commands to add files from test2 repo to test repo as below:\n# In local test repo\nrm -rf test2\ngit clone https://github.com/eromoe/test2\ngit add test2/\ngit commit -am 'add files from test2 repo to test repo'\ngit push\n\nNote: \nYou should use git add test2/ (with slash, not git add test2).\ngit add test2/ will treat test2 folder and it's files as ordinary folder and file for test repo (create mode 100644). \ngit add test2 will treat test2 folder as a submodule for test repo (create mode 160000)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git with development, staging and production branches\nThis article sounds interesting, but I'm pretty sure the diagrams are wrong.\nhttp://guides.beanstalkapp.com/version-control/branching-best-practices.html\nShouldn't it be DEVELOPMENT > STAGING > PRODUCTION?\n\nMerges should only flow in one direction: from feature and bug-fixes\n done in their own branch or in development into staging for testing.\n Once tested, you can merge those changes from development into\n production.\n\nHere I get a bit confused. So I merge Staging to Master or Master to Staging?\nI'm using a client called SmartGit and I get confused about this point. Normally I make a branch for a feature, commit to it, then switch to master and merge it to the branch (forward). So in this new workflow with Staging and Production, I create these two extra branches, then create a branch from master (aka dev) for my feature. Commit to it, then switch to Staging and merge (forward) to my feature branch? Does that sound correct?\n\nActually what made this so confusing is that the Beanstalk people stand behind their very non-standard use of Staging (it comes before development in their diagram, and it's not a mistake! \nhttps://twitter.com/Beanstalkapp/status/306129447885631488\nHave decided to forget about Beanstalk and just go with Github.\n\nSince I posted this, the Beanstalk people took my hint and renamed their stages, now calling Development \"Stable\"."
},
{
"role": "assistant",
"content": "The thought process here is that you spend most of your time in development. When in development, you create a feature branch (off of development), complete the feature, and then merge back into development. This can then be added to the final production version by merging into production.\nSee A Successful Git Branching Model for more detail on this approach."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitLab: How to find the owner of an SSH key\n\nGiven an SSH public key or fingerprint that has been registered with GitLab, how do I find out which account is associated with that key?\nNote that the key may have been registered as a \"deploy key,\" in which case I'd like to know account that registered it.\nI'd prefer to know ways to do this using both the standard web UI (if possible), and programatically via the REST API. If neither of these are possible, I'll take answers that involve digging into the internals of GitLab (e.g., via a query on GitLab's database) if necessary."
},
{
"role": "assistant",
"content": "If you can access the postgres console:\nroot@gitlab:/# gitlab-psql\n psql (9.6.8)\n Type \"help\" for help.\n\n gitlabhq_production=#\n gitlabhq_production=# select a.name,a.username,b.fingerprint \nfrom users a, keys b where a.id=b.user_id;\n\n name | username | fingerprint \n ---------------+----------+-------------------------------------------------\n Administrator | root | f4:cc:ec:76:d0:1c:86:1d:45:6d:a7:6e:b3:df:32:7c\n (1 row)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git diff: Write output and exit instead of interactive mode\nWhen I run git diff on my OSX command line, the output is displayed inside a less or vim interface. The interface lets me to scroll up and down, and quit using the q key.\nThis is very annoying, especially when there is no diff and git opens a blank screen.\nCan I just write the diff (color) output the the screen without entering the interactive mode?"
},
{
"role": "assistant",
"content": "Disable the interactive pager with the --no-pager option.\nUsage: git --no-pager diff (note how it's not specific to git-diff, so it's usable with any git command!)\nDocumentation: https://git-scm.com/docs/git\nCopied from https://stackoverflow.com/a/2183920/2221472"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge - Join two or more development histories together --commit --no-commit"
},
{
"role": "assistant",
"content": "Perform the merge and commit the result. This option can\nbe used to override --no-commit. With --no-commit perform the merge and stop just before creating\na merge commit, to give the user a chance to inspect and further\ntweak the merge result before committing. Note that fast-forward updates do not create a merge commit and\ntherefore there is no way to stop those merges with --no-commit.\nThus, if you want to ensure your branch is not changed or updated\nby the merge command, use --no-ff with --no-commit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Using .gitignore to ignore everything but specific directories\nMy issue is that I have a bunch of WordPress websites in my git repo, of which I want to selectively commit only the content of my themes folders, while ignoring the rest of the redundant files found in WordPress. \nI've used .gitignore files to ignore file types before, but can it be used the other way around- that is to ignore everything BUT a certain folder path?\n\nroot (git repo)\n - / wordpress \n - - / (WordPress Site 1)/wp-content/themes \n - - / (WordPress Site 2)/wp-content/themes \n - - / (WordPress Site 3)/wp-content/themes\n\nThanks-\nUPDATE: \nBased on the answers I did the following, but it's not working. Any ideas?\n# Ignore everything:\n*\n# Except for wordpress themes:\n!*/wp-content/themes/*\n\nI've also tried the following variations:\n!*/wp-content/themes*\n!*wp-content/themes/*\n!wp-content/themes/*\n!/wordpress/*/wp-content/themes*\n!wordpress/*/wp-content/themes*\n\nNone of these read my themes folders."
},
{
"role": "assistant",
"content": "Here's how I did it - you essentially have to walk up the paths, you can't wildcard more than one level in any direction:\n# Ignore everything:\n*\n\n# Except for the themes directories:\n\n!wordpress/\n!wordpress/*/\n!wordpress/*/wp-content/\n!wordpress/*/wp-content/themes/\n!wordpress/*/wp-content/themes/*\n!wordpress/*/wp-content/themes/*/*\n!wordpress/*/wp-content/themes/*/*/*\n!wordpress/*/wp-content/themes/*/*/*/*\n!wordpress/*/wp-content/themes/*/*/*/*/*\n\nNotice how you have to explicitly allow content for each level you want to include. So if I have subdirectories 5 deep under themes, I still need to spell that out.\nThis is only how it worked for me. If someone cares to offer a more informed explanation by all means.\nAlso, these answers helpful: \nhow-do-negated-patterns-work-in-gitignore \nhow-do-gitignore-exclusion-rules-actually-work \n\nNOTE: I tried using double-wildcard 'globs' but according to this that functionality is system dependent and it didn't work on my mac:\nDid NOT work:\n!**/wp-content/themes/\n!**/wp-content/themes/**"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-daemon - A really simple server for Git repositories --init-timeout=<n>"
},
{
"role": "assistant",
"content": "Timeout (in seconds) between the moment the connection is established\nand the client request is received (typically a rather low value, since\nthat should be basically immediate)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to reset Heroku app and re-commit everything?\nI'm building an application which I'm also testing in Heroku. I ran into some problem today and had to rollback one commit in my local git repo, but Heroku now won't recognize my changes saying that \"everything is up to date\".\nSo, running\ngit push heroku master\n\nheroku responds with \nEverything up-to-date\n\nwhich isn't true.\nUPDATE: Things I've tried\ngit push -f heroku master\ngit push --force heroku master\ngit push heroku +master\ngit push --force heroku +master\n\nDid some changes in the source code and then\ngit add.\ngit commit -a -m \"Message\" #(Then this commit shows in my git explorer)\ngit push heroku master #Everything up-to-date"
},
{
"role": "assistant",
"content": "Sounds weird. Maybe try pushing a different branch would do?\ngit branch production\ngit checkout production\n#do some code changes\ngit commit -am \"some desperate code changes to try fix heroku\"\ngit push heroku production:master\n\nCreating a new production branch is what I want you to test. Besides, it's nice to have a production branch that you can use to deploy.\nIf it doesn't work, then I think the problem runs deeper and you need help from heroku.\nEDIT: \nAdd the heroku releases addon too. Rolling back is as easy as heroku rollback"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to install Github for Windows offline?\n\nAs the question says how to install Github for Windows without an internet connection? \nIf it is not possible then is there some alternative client with the following features:\n\nSupport for proxy\nOffline installer\n\nI found smartgit which has an offline installer but it seems it doesn't have proxy support.\nIf there is no such client then what can be done to extend the functionality of github for windows or some other client? I mean is there a way to use some API to extend it? Any links for that would be helpful."
},
{
"role": "assistant",
"content": "This is the answer I received from the support today (2015-06-30):\n\nUnfortunately we do not have a standalone installer at this time.\n GitHub for Windows makes use of Microsoft's ClickOnce technology for\n installation and updates.\nWe are currently working on an open source replacement for ClickOnce\n here: \nhttps://github.com/squirrel/squirrel.windows\nOnce that technology is complete and ready for use, we hope to switch\n GitHub for Windows to use that. It would allow for a standalone\n installer.\nIn the meantime, you can find a list of alternate GUIs available\n here:\nhttp://git-scm.com/downloads/guis"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitrevisions - Specifying revisions and ranges for Git <rev>^[<n>] , e.g. HEAD^, v1.5.1^0"
},
{
"role": "assistant",
"content": "A suffix ^ to a revision parameter means the first parent of\nthat commit object. ^<n> means the <n>th parent (i.e. <rev>^ is equivalent to <rev>^1 ). As a special rule, <rev>^0 means the commit itself and is used when <rev> is the\nobject name of a tag object that refers to a commit object."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to find commit when line was deleted/removed?\nI have a deleted line in a file in my Git repository. I knew some of the missing text, and the file that it was in, so I used git log -S'missingtext' /path/to/file.\nHowever, the only thing that came back was the commit in which I added the line containing the missing text. The text wasn't present in HEAD, and the commit that added it was present in my branch, so I knew that one of the commits in my branch's history must have removed it, but it wasn't showing up.\nAfter some manual searching, it turned out that the line was removed accidentally while resolving a conflict for a merge. So I'm wondering:\n\nIs this the reason why pickaxe couldn't find the commit that deleted the line?\nHow could I have found where \"missingtext\" was deleted without digging through the history manually?\n\nAny insight on #1 would be great (I assumed that git log -S would give me my answer), but my real question is #2 since I'd like to be able to avoid this in the future."
},
{
"role": "assistant",
"content": "git log -c -S'missingtext' /path/to/file\ngit log doesn't show a diff for merge commits by default. Try the -c or --cc flags.\nMore discussion/explanation:\nhttps://git-scm.com/docs/git-log\nnabble.com\nFrom the git-log docs:\n\n-c With this option, diff output for a merge commit shows the differences from each of the parents to the merge result\nsimultaneously instead of showing pairwise diff between a parent and\nthe result one at a time. Furthermore, it lists only files which were\nmodified from all parents.\n--cc This flag implies the -c option and further compresses the patch output by omitting uninteresting hunks whose contents in the\nparents have only two variants and the merge result picks one of them\nwithout modification."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-archive - Create an archive of files from a named tree --worktree-attributes"
},
{
"role": "assistant",
"content": "Look for attributes in .gitattributes files in the working tree\nas well (see ATTRIBUTES )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - Server host key not cached\nI try to push changes from my local repo to a remote repo. When I type:\ngit push origin\n\nI get the following error:\nThe server's host key is not cached in the registry. You\nhave no guarantee that the server is the computer you\nthink it is.\nThe server's rsa2 key fingerprint is:\nssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx\nConnection abandoned.\nfatal: The remote end hung up unexpectedly\n\nHow can I solve this? I'm using git from the command line in Windows 7.\nEdit\nWhen I try to do a simple ssh\nssh user@hostname\n\nI get the following error:\nCould not create directory '/c//%HOMEDRIVE%%HOMEPATH%/.ssh'.\npercent_expand: unknown key %H\n\nSomehow it will not create the directory, because the path is invalid. How to fix this?\n@eckes: Edit2\nMy Home is set to %HOMEDRIVE%%HOMEPATH% is this correct?"
},
{
"role": "assistant",
"content": "For those of you who are setting up MSYS Git on Windows using PuTTY via the standard command prompt, the way to add a host to PuTTY's cache is to run\n> plink.exe <host>\n\nFor example:\n> plink.exe codebasehq.com\n\nThe server's host key is not cached in the registry. You\nhave no guarantee that the server is the computer you\nthink it is.\nThe server's rsa2 key fingerprint is:\nssh-rsa 2048 2e:db:b6:22:f7:bd:48:f6:da:72:bf:59:d7:75:d7:4e\nIf you trust this host, enter \"y\" to add the key to\nPuTTY's cache and carry on connecting.\nIf you want to carry on connecting just once, without\nadding the key to the cache, enter \"n\".\nIf you do not trust this host, press Return to abandon the\nconnection.\nStore key in cache? (y/n)\n\nJust answer y, and then Ctrl+C the rest.\nDo check the fingerprint though. This warning is there for a good reason. Fingerprints for some git services (please edit to add more):\n\nGitHub: 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48\nBitbucket: 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40\nGitorious: 7e:af:8d:ec:f0:39:5e:ba:52:16:ce:19:fa:d4:b8:7d"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git:nothing added to commit but untracked files present\nI'm new to Git and is using for the very first time. I would appreciate if someone could help me out. I tried finding the answer at forums,but there are tons of commands that are coming out and not sure which one to use.\nOn the prod server, if I do the git pull, it is giving me the following error:\n\nUntracked files:\n (use \"git add ...\" to include in what will be committed)\n\nOptimization/language/languageUpdate.php\nemail_test.php\nnothing added to commit but untracked files present (use \"git add\" to track)\nPlease move or remove them before you can merge.\n\nI'm not too sure how to make it work. If I remove them, from where would it be removed. Appreciate your reply."
},
{
"role": "assistant",
"content": "You have two options here. You can either add the untracked files to your Git repository (as the warning message suggested), or you can add the files to your .gitignore file, if you want Git to ignore them.\nTo add the files use git add:\ngit add Optimization/language/languageUpdate.php\ngit add email_test.php\n\nTo ignore the files, add the following lines to your .gitignore:\n/Optimization/language/languageUpdate.php\n/email_test.php\n\nEither option should allow the git pull to succeed afterwards."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git stash apply version\nI have 2 branches: master | design\nWorking in design I did a stash and switched to master, made some adjustments. Switched back to design and did a stash apply only to lose all my changes in the design branch.\nI am hoping all my work is within a stash as I have not cleared or removed these.\nIf I do a stash list I get 4 results:\nstash@{0}: WIP on design: f2c0c72... Adjust Password Recover Email\nstash@{1}: WIP on design: f2c0c72... Adjust Password Recover Email\nstash@{2}: WIP on design: eb65635... Email Adjust\nstash@{3}: WIP on design: eb65635... Email Adjust\n\nIf I try git stash apply f2c0c72 I am getting an error:\nfatal: Needed a single revision\nf2c0c72: no valid stashed state found\n\nHow can I apply a specific stash?"
},
{
"role": "assistant",
"content": "The keys into the stash are actually the stash@{n} items on the left. So try: \ngit stash apply stash@{0}\n\n(note that in some shells you need to quote \"stash@{0}\", like zsh, fish and powershell).\nSince version 2.11, it's pretty easy, you can use the N stack number instead of using stash@{n}. So now instead of using:\ngit stash apply \"stash@{n}\"\n\nYou can type:\ngit stash apply n\n\nTo get list of stashes:\ngit stash list\n\nIn fact stash@{0} is a revision in git that you can switch to... but git stash apply ... should figure out how to DTRT to apply it to your current location."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge - Join two or more development histories together ours"
},
{
"role": "assistant",
"content": "This resolves any number of heads, but the resulting tree of the\nmerge is always that of the current branch head, effectively\nignoring all changes from all other branches. It is meant to\nbe used to supersede old development history of side\nbranches. Note that this is different from the -Xours option to\nthe recursive merge strategy."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc files"
},
{
"role": "assistant",
"content": "Compute the dirstat numbers by counting the number of files changed.\nEach changed file counts equally in the dirstat analysis. This is\nthe computationally cheapest --dirstat behavior, since it does\nnot have to look at the file contents at all."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can I merge table rows in markdown\n\nIs there a way to create merged rows in a column of table in markdown files like ReadMe.md files? \nSomething like this:"
},
{
"role": "assistant",
"content": "No, this is not possible with GitHub-Flavored Markdown. As the spec explains (emphasis added):\n\nThe remainder of the table’s rows may vary in the number of cells. If there are a number of cells fewer than the number of cells in the header row, empty cells are inserted. If there are greater, the excess is ignored:\n\nOf course, you can always fall back to raw HTML.\n<table>\n <thead>\n <tr>\n <th>Layer 1</th>\n <th>Layer 2</th>\n <th>Layer 3</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td rowspan=4>L1 Name</td>\n <td rowspan=2>L2 Name A</td>\n <td>L3 Name A</td>\n </tr>\n <tr>\n <td>L3 Name B</td>\n </tr>\n <tr>\n <td rowspan=2>L2 Name B</td>\n <td>L3 Name C</td>\n </tr>\n <tr>\n <td>L3 Name D</td>\n </tr>\n </tbody>\n</table>\n\nTry it yourself at https://jsfiddle.net/7h89y55r/"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I rollback a git repository to a specific commit?\n\nMy repo has 100 commits in it right now. I need to rollback the repository to commit 80, and remove all the subsequent ones.\nWhy?\nThis repo is supposed to be for merging from miscellaneous users. A bunch of merges went in as commits from me, due to excessive editing. That was due to a mislabeling of my remote branches, where 3 developers were labeled as each other. I need to reset to that point, and then pull forwards.\nI wanted to rebase, as in this example: How can I remove a commit on GitHub?\nHowever, git wants me to do a lot of conflict management. Is there a simpler way?"
},
{
"role": "assistant",
"content": "git reset --hard <old-commit-id>\ngit push -f <remote-name> <branch-name>\n\nNote: As written in comments below, Using this is dangerous in a collaborative environment: you're rewriting history"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git merging within a line\nPreamble\nI'm using git as a version control system for a paper that my lab is writing, in LaTeX. There are several people collaborating.\nI'm running into git being stubborn about how it merges. Let's say two people have made single-word changes to a line, and then attempt to merge them. Though git diff --word-diff seems capable of SHOWING the difference between the branches word-by-word, git merge seems unable to perform the merge word-by-word, and instead requires a manual merge.\nWith a LaTeX document this is particularly annoying, as the common habit when writing LaTeX is to write a full paragraph per line and just let your text editor handle word wrapping when displaying for you. We are working around for now by adding a newline for each sentence, so that git can at least merge changes on different sentences within a paragraph. But it will still get confused about multiple changes within a sentence, and this makes the text no longer wrap nicely of course.\nThe Question\nIs there a way to git merge two files \"word by word\" rather than \"line by line\"?"
},
{
"role": "assistant",
"content": "Here's a solution in the same vein as sehe's, with a few changes which hopefully will address your comments:\n\nThis solution considers merging by sentence rather than by word, as you had been doing by hand, only now, the user will see a single line per paragraph, but git will see paragraphs broken into sentences. This seems to be more logical because adding/removing a sentence from a paragraph may be compatible with other changes in the paragraph, but it is probably more desirable to have a manual merge when the same sentence is edited by two commits. This also has the benefit of the \"clean\" snapshots to still be somewhat human readable (and latex compilable!).\nThe filters are one-line commands, which should make it easier to port this to collaborators.\n\nAs in saha's solution make a (or append to) .gittatributes.\n *.tex filter=sentencebreak\n\nNow to implement the clean and smudge filters:\n git config filter.sentencebreak.clean \"perl -pe \\\"s/[.]*?(\\\\?|\\\\!|\\\\.|'') /$&%NL%\\\\n/g unless m/%/||m/^[\\\\ *\\\\\\\\\\\\]/\\\"\"\n git config filter.sentencebreak.smudge \"perl -pe \\\"s/%NL%\\n//gm\\\"\"\n\nI've created a test file with the following contents, notice the one-line paragraph.\n \\chapter{Tumbling Tumbleweeds. Intro}\n A way out west there was a fella, fella I want to tell you about, fella by the name of Jeff Lebowski. At least, that was the handle his lovin' parents gave him, but he never had much use for it himself. This Lebowski, he called himself the Dude. Now, Dude, that's a name no one would self-apply where I come from. But then, there was a lot about the Dude that didn't make a whole lot of sense to me. And a lot about where he lived, like- wise. But then again, maybe that's why I found the place s'durned innarestin'.\n\n This line has two sentences. But it also ends with a comment. % here\n\nAfter we commit it to the local repo, we can see the raw contents.\n $ git show HEAD:test.tex\n\n \\chapter{Tumbling Tumbleweeds. Intro}\n A way out west there was a fella, fella I want to tell you about, fella by the name of Jeff Lebowski. %NL%\n At least, that was the handle his lovin' parents gave him, but he never had much use for it himself. %NL%\n This Lebowski, he called himself the Dude. %NL%\n Now, Dude, that's a name no one would self-apply where I come from. %NL%\n But then, there was a lot about the Dude that didn't make a whole lot of sense to me. %NL%\n And a lot about where he lived, like- wise. %NL%\n But then again, maybe that's why I found the place s'durned innarestin'.\n\n This line has two sentences. But it also ends with a comment. % here\n\nSo the rules of the clean filter are whenever it finds a string of text that ends with . or ? or ! or '' (that's the latex way to do double quotes) then a space, it will add %NL% and a newline character. But it ignores lines that start with \\ (latex commands) or contain a comment anywhere (so that comments cannot become part of the main text).\nThe smudge filter removes %NL% and the newline.\nDiffing and merging is done on the 'clean' files so changes to paragraphs are merged sentence by sentence. This is the desired behavior.\nThe nice thing is that the latex file should compile in either the clean or smudged state, so there is some hope for collaborators to not need to do anything. Finally, you could put the git config commands in a shell script that is part of the repo so a collaborator would just have to run it in the root of the repo to get configured.\n #!/bin/bash\n\n git config filter.sentencebreak.clean \"perl -pe \\\"s/[.]*?(\\\\?|\\\\!|\\\\.|'') /$&%NL%\\\\n/g unless m/%/||m/^[\\\\ *\\\\\\\\\\\\]/\\\"\"\n git config filter.sentencebreak.smudge \"perl -pe \\\"s/%NL%\\n//gm\\\"\"\n\n fileArray=($(find . -iname \"*.tex\"))\n\n for (( i=0; i<${#fileArray[@]}; i++ ));\n do\n perl -pe \"s/%NL%\\n//gm\" < ${fileArray[$i]} > temp\n mv temp ${fileArray[$i]}\n done\n\nThat last little bit is a hack because when this script is first run, the branch is already checked out (in the clean form) and it doesn't get smudged automatically.\nYou can add this script and the .gitattributes file to the repo, then new users just need to clone, then run the script in the root of the repo.\nI think this script even runs on windows git if done in git bash.\nDrawbacks:\n\nThis doesn't handle lines with comments smartly, it just ignores them.\n%NL% is kind of ugly\nThe filters may screw up some equations (not sure about this)."
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.