messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to prevent eslint from blocking git commit?\nI'm new to eslint and am using it to enforce coding style. However, when I write a TODO item into my code I get an eslint warning, alright that's fine. But, now when I try to git commit, it comes back with:\n**** ESLint errors found : \nline 145, col 9, Warning - Unexpected 'todo' comment. (no-warning-comments)\n\nHow can I prevent eslint from blocking me from committing? I want it to still warn me about TODOs etc, but I would like to be able to commit my code as well." }, { "role": "assistant", "content": "You have a pre-commit hook.\ngit commit --no-verify\n\nallows to avoid it once. Or you can remove it completely from .git/hooks." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to see remote tags?\nIn Atlassian SourceTree, how to know which tags are only local and which are also in remote?\nWhen creating a tag you get the option \"Push tag to: ...\", but how to know if a tag has been pushed or not after it is created? I can see all my tags locally, but I need to be sure that they are present in remote so that other developers can pull them." }, { "role": "assistant", "content": "You can list the tags on remote repository with ls-remote, and then check if it's there. Supposing the remote reference name is origin in the following.\ngit ls-remote --tags origin\n\nAnd you can list tags local with tag.\ngit tag\n\nYou can compare the results manually or in script." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Jenkins pipeline git command submodule update\nI want to update submodule on git clone.\nIs there a way to do this with Jenkins pipeline Git command?\nCurrently I'm doing this...\ngit branch: 'master',\n credentialsId: 'bitbucket',\n url: 'ssh://bitbucket.org/hello.git'\n\nIt doesn't however update submodule once cloned" }, { "role": "assistant", "content": "The git command as a pipeline step is rather limited as it provides a default implementation of the more complex checkout command. For more advanced configuration, you should use checkout command, for which you can pass a whole lot of parameters, including the desired submodules configuration.\nWhat you want to use is probably something like this :\ncheckout([$class: 'GitSCM',\n branches: [[name: '*/master']],\n doGenerateSubmoduleConfigurations: false,\n extensions: [[$class: 'SubmoduleOption',\n disableSubmodules: false,\n parentCredentials: false,\n recursiveSubmodules: true,\n reference: '',\n trackingSubmodules: false]], \n submoduleCfg: [], \n userRemoteConfigs: [[url: 'your-git-server/your-git-repository']]])\n\nFrom the documentation it is often cumbersome to write these kind of lines, I recommand you use instead Jenkins very good Snippet Generator (YourJenkins > yourProject > PipelineSyntax) to automatically generate the checkout line !" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to 'git commit' a single file/directory\nI tried the following command:\ngit commit path/to/my/file.ext -m 'my notes'\n\nAnd received an error in Git version 1.5.2.1:\nerror: pathspec '-m' did not match any file(s) known to git.\nerror: pathspec 'MY MESSAGE' did not match any file(s) known to git.\n\nIs that incorrect syntax for a single file or directory commits?" }, { "role": "assistant", "content": "Your arguments are in the wrong order. Try git commit -m 'my notes' path/to/my/file.ext, or if you want to be more explicit, git commit -m 'my notes' -- path/to/my/file.ext.\nIncidentally, Git v1.5.2.1 is 4.5 years old. You may want to update to a newer version (1.7.8.3 is the current release)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Difference between collaborator and contributor\n\nIn github, I often see these terms and in many cases they are used interchangeably. Can someone please explain the difference between a contributor and a collaborator?" }, { "role": "assistant", "content": "From the GitHub Open Source Guide and GitHub Help.\n\nAuthor: The person/s or organization that created the project\nOwner: The person/s who has administrative ownership over the organization or repository (not always the same as the original author)\nMaintainers: Contributors who are responsible for driving the vision and managing the organizational aspects of the project. (They may also be authors or owners of the project.)\nContributors: Everyone who has contributed something back to the project.\nCommunity Members: People who use the project. They might be active in conversations or express their opinion on the project’s direction.\nAn outside collaborator is a person who isn't explicitly a member of your organization, but who has Read, Write, or Admin permissions to one or more repositories in your organization." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I add an empty directory to a Git repository?\nHow do I add an empty directory (that contains no files) to a Git repository?" }, { "role": "assistant", "content": "Another way to make a directory stay (almost) empty (in the repository) is to create a .gitignore file inside that directory that contains these four lines:\n# Ignore everything in this directory\n*\n# Except this file\n!.gitignore\n\nThen you don't have to get the order right the way that you have to do in m104's solution.\nThis also gives the benefit that files in that directory won't show up as \"untracked\" when you do a git status.\nMaking @GreenAsJade's comment persistent:\n\nI think it's worth noting that this solution does precisely what the question asked for, but is not perhaps what many people looking at this question will have been looking for. This solution guarantees that the directory remains empty. It says \"I truly never want files checked in here\". As opposed to \"I don't have any files to check in here, yet, but I need the directory here, files may be coming later\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-blame" }, { "role": "assistant", "content": "Show what revision and author last modified each line of a file" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git revert <hash> not allowed due to a merge but no -m option was given\n\nI am trying to revert to a certain 'hash' number in git, by using the 'revert' command.\nI am using the following command:\ngit revert c14609d74eec3ccebafc73fa875ec58445471765\n\nBut, I am getting the following returned:\n\nerror: Commit c14609d74eec3ccebafc73fa875ec58445471765 is a merge but no -m option was given.\nfatal: revert failed\n\nWhat is happening & what should be done to resolve this?\n\nI want to revert back to this certain commit (c14609d74eec3ccebafc73fa875ec58445471765) that I see when running git log." }, { "role": "assistant", "content": "You are trying to revert a merge commit, and git doesn't know which parent to revert to. The -m allows us to choose which parent to choose. See the merge commit and note down which parent you want to go to. The parent information can be seen in git log, for example:\n\ncommit d02ee0f2179def10277f30c71c5d6f59ded3c595\nMerge: dd3a24c 2462a52\n\nand run:\ngit revert <hash> -m 1\n\nwhere 1 indicates parent number 1 (dd3a24c).\nIf you are trying to revert to that commit, do:\ngit reset --hard <hash>\n\nUnderstand the difference between git revert and git reset from the docs and decide which one you want. git revert is the safer option, but doesn't really do what you want. It just reverts the changes of a (set of) commit. git reset makes you move to a particular commit in history, and will rewrite your history." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Restore file from old commit in git\nI have an old commit that I did a few weeks ago. I want to restore only a single file from that commit. What do I do?" }, { "role": "assistant", "content": "git checkout 'master@{7 days ago}' -- path/to/file.txt\n\nThis will not alter HEAD, it will just overwrite the local file path/to/file.txt\nSee man git-rev-parse for possible revision specifications there (of course a simple hash (like dd9bacb) will do nicely)\nDon't forget to commit the change (after a review...)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub Windows client behind proxy\n\nI'm trying to get the GitHub client for Windows working. I am on a corporate Windows 7 x64 computer behind a corporate proxy and firewall.\nFollowing various other posts and experimenting with multiple combinations of environment variables and configuration variables, I have found the only way to get cloning and push updates to work is by using the HTTPS_PROXY environment variable, including my full corporate domain user ID and password.\nThis is unacceptable from a security standpoint. Is there another way to get this to work?\nAdditional notes:\nThe following worked:\n\nAdd an environment variable called HTTPS_PROXY with the value http://[domain]\\[userid]:[password]@someproxy.mycorp.com:8080\n\nThe following did not work:\n\nOmitting user id and password from HTTPS_PROXY variable\nUsing an environment variable called HTTP_PROXY (no S)\nAdding the http.proxy variable to the global configuration file (.gitconfig)\nAdding the https.proxy variable to the global configuration file\n\nIn all cases, the GitHub client still does not recognize the proxy: The content of the file TheLog.txt always shows the following on startup:\n[time]|INFO|thread:4|GitHub.Helpers.StartupLogger|Proxy information: (None)\n[time]|INFO|thread:4|GitHub.Helpers.StartupLogger|Couldn't fetch creds for proxy\n\nAnd it is followed by the output of several failed proxy authentication attempts, all of which indicate \"Credentials are missing.\"" }, { "role": "assistant", "content": "Add these entries to your '.gitconfig' file in your user directory (go to %USERPROFILE%):\n[http]\n proxy = http://<proxy address>:<proxy port>\n\n[https]\n proxy = https://<proxy address>:<proxy port>\n\nAnd if you don't want to store your password in plaintext, I would use a local proxy forwarder like CNTLM which allows you to direct all traffic through it and can store the passwords hashed.\n\nUnlike the original question, if you don't care if your password is in plain text add these:\n[http]\n proxy = http://<username>:<password>@<proxy address>:<proxy port>\n\n[https]\n proxy = https://<username>:<password>@<proxy address>:<proxy port>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-daemon - A really simple server for Git repositories <directory>" }, { "role": "assistant", "content": "The remaining arguments provide a list of directories. If any\ndirectories are specified, then the git-daemon process will\nserve a requested directory only if it is contained in one of\nthese directories. If --strict-paths is specified, then the\nrequested directory must match one of these directories exactly." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-daemon - A really simple server for Git repositories We assume the following in /etc/services" }, { "role": "assistant", "content": "$ grep 9418 /etc/services\ngit\t\t9418/tcp\t\t# Git Version Control System" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can git operate in \"silent mode\"?\nIs it possible to execute any git command in \"silent\" mode? For instance, can i say \"git push origin\" and see nothing displayed on the screen?\nI suppose i can redirect IO to /dev/null (works fine), but .. does git allow something like this naturally?\nBelow is a quick script that does automatic EOD commit, used when i need to catch the train and don't want to leave code on my local computer\n 1 clear\n 2\n 3 cd\n 4 cd repo/active\n 5\n 6 for i in *\n 7 do\n 8 cd $i\n 9 echo \"Pushing \" $i\n 10 git add . -A >> /dev/null \n 11 git commit -a -m \"EOD automatic commit\" >> /dev/null \n 12 git push origin >> /dev/null \n 13 echo\n 14 cd ..\n 15 done\n\nPlease let me know." }, { "role": "assistant", "content": "You can use --quiet or -q, which can also be used for other Git commands:\ngit commit --quiet\ngit push --quiet" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Where can I report a git bug\nI am trying to use the mailmap.file config option for git. The path is however not shell expanded, meaning I can't write $HOME/.mailmap or ~/.mailmap. This is quite annoying if you are synchronizing your dotfiles with something like homesick and are using the same .gitconfig for Windows, OS X and Linux.\nI can't find any bugtracker for git, and I don't want to spam the git mailinglist with something like that. How should I report this bug/minor annoyance?" }, { "role": "assistant", "content": "TLDR; as mentioned in the Git mailing list:\n\nRun git bugreport\nEdit the file by filling out the blanks and removing irrelevant stuff\n(follow the instructions)\nPost the report as an inline plaintext email to [email protected] (again: plaintext, not HTML)\n\n\nAs mentioned in code google git-core (and by Charles Bailey in the comments, which points to git-scm community page):\n\nQuestions or comments for the Git community can be sent to the mailing list by using the email address [email protected]. Bug reports should be sent to this mailing list.\n\n(mailing list archive here)\nUpdate Q2 2020, you now have an actual git bugreport command (see at the end below)\nUpdate 2015: the latest reference remains the Git community page, which, as smoothgrips points out in the comments, mentions:\n\nYou do not need to subscribe: you will be Cc'd in replies.\nPlease keep the Cc list intact when replying (use \"Reply to all\").\nGreylisting may delay your first post for a few hours.\n\nNote that the mail server will reject HTML messages with a \"failed permanently\" message, so use plain text.\nThe community page also points out to \"How to Report Bugs Effectively\"...\nIf you want to contribute a patch, go now to rtyley/submitgit, which helps you to follow the patch submission process:\n\nIf you create a pull request on github.com/git/git/, submitGit can send it to the mailing list for you, correctly formatting the patches.\nThe discussion stays where it is—on the list—but at least that initial step is a little easier.\n\nUpdate 2015: Git For Windows now lives on GitHub (github.com/git-for-windows), and produces very recent releases: 2.4.2+.\nMsysgit is phased out, using msys2 64-bits, and resulting in git-for-windows.github.io instead of the old and now obsolete msysgit.github.io.\nThe GitHub mirror repo image git/git is there, but not use for issues or pull request, unfortunately.\n\nUpdate 2019: submitGit has an alternative: GitGitGadget (gitgitgadget.github.io), mentioned in Git 2.22 (Q2 2019)\nSee commit c3a7dd7 (12 Mar 2019) by Jeff King (peff).\n(Merged by Junio C Hamano -- gitster -- in commit 2d33728, 09 Apr 2019)\n\npoint pull requesters to GitGitGadget\n\n\nIn the contributing guide and PR template seen by people who open pull requests on GitHub, we mention the submitGit tool, which gives an alternative to figuring out the mailing list.\nThese days we also have the similar GitGitGadget tool, and we should make it clear that this is also an option.\nWe could continue to mention both tools, but it's probably better to pick one in order to avoid overwhelming the user with choice.\nAfter all, one of the purposes here is to reduce friction for first-time or\ninfrequent contributors.\nAnd there are a few reasons to prefer GGG:\n\nsubmitGit seems to still have a few rough edges. E.g., it doesn't munge timestamps to help threaded mail readers handled out-of-order\ndelivery.\nSubjectively, GGG seems to be more commonly used on the list these days, especially by list regulars.\nGGG seems to be under more active development (likely related to point 2).\n\nSo let's actually swap out submitGit for GGG.\nWhile we're there, let's put another link to the GGG page in the PR template, because that's where users who are learning about it for the first time will want to go.\nto read more.\n\n\nWith Git 2.25 (Q1 2020), there is a tutorial on object enumeration, which provides a good example on how to contribute/test/report a bug.\nSee commit e0479fa (11 Oct 2019) by Emily Shaffer (nasamuffin).\n(Merged by Junio C Hamano -- gitster -- in commit 15d9f3d, 10 Nov 2019)\n\ndocumentation: add tutorial for object walking\nSigned-off-by: Emily Shaffer\nHelped-by: Eric Sunshine\n\n\nExisting documentation on object walks seems to be primarily intended as a reference for those already familiar with the procedure.\nThis tutorial attempts to give an entry-level guide to a couple of bare-bones object walks so that new Git contributors can learn the concepts without having to wade through options parsing or special casing.\nThe target audience is a Git contributor who is just getting started with the concept of object walking.\nThe goal is to prepare this contributor to be able to understand and modify existing commands which perform revision walks more easily, although it will also prepare contributors to create new commands which perform walks.\nThe tutorial covers a basic overview of the structs involved during object walk, setting up a basic commit walk, setting up a basic all-object walk, and adding some configuration changes to both walk types.\nIt intentionally does not cover how to create new commands or search for options from the command line or gitconfigs.\nThere is an associated patchset at https://github.com/nasamuffin/git/tree/revwalk that contains a reference implementation of the code generated by this tutorial.\n\nNote: that tutorial has been amended in Git 2.27 (Q2 2020):\nSee commit e3f53ce (28 Mar 2020) by Johannes Schindelin (dscho).\n(Merged by Junio C Hamano -- gitster -- in commit 7780604, 22 Apr 2020)\n\nMyFirstObjectWalk: remove unnecessary conditional statement\nSigned-off-by: Johannes Schindelin\nReviewed-by: Emily Shaffer\n\n\nIn the given example, commit cannot be NULL (because this is the loop condition: if it was NULL, the loop body would not be entered at all). It took this developer a moment or two to see that this is therefore dead code.\nLet's remove it, to avoid puzzling future readers.\n\n\nWith Git 2.25 (Q1 2020), GitGitGadget is documented.\nSee commit 3c8d754, commit 3ada78d, commit 4ed5562 (31 Oct 2019) by Emily Shaffer (nasamuffin).\n(Merged by Junio C Hamano -- gitster -- in commit f089ddd, 01 Dec 2019)\n\nmyfirstcontrib: hint to find gitgitgadget allower\nSigned-off-by: Emily Shaffer\n\n\nGitGitGadget, a handy tool for converting pull requests against Git into Git-mailing-list-friendly-patch-emails, requires as anti-spam that all new users be \"/allow\"ed by an existing user once before it will do anything for that new user.\nWhile this tutorial explained that mechanism, it did not give much hint on how to go about finding someone to allow your new pull request.\nSo, teach our new GitGitGadget user where to look for someone who can add their name to the list.\nThe advice in this patch is based on the advice proposed for GitGitGadget: gitgitgadget/gitgitgadget PR 138\n\n\nWith Git 2.25 (Q1 2020), there are documentation updates for the mailing list archiving and nntp service.\nSee commit 3eae30e, commit 46c6749 (27 Nov 2019) by Jeff King (peff).\n(Merged by Junio C Hamano -- gitster -- in commit 3b3d9ea, 06 Dec 2019)\n\ndoc: replace public-inbox links with lore.kernel.org\nSigned-off-by: Jeff King\n\n\nSince we're now recommending lore.kernel.org (and because the public-inbox.org domain might eventually go away), let's update our internal references to use it, too.\nThat future-proofs our references, and sets the example we want people to follow.\n\nSee \"This list is now also archived on lore.kernel.org/git\"\n\ndoc: replace MARC links with lore.kernel.org\nSigned-off-by: Denton Liu\n\n\nSince we're now recommending lore.kernel.org, replace marc.info links with lore.kernel.org.\nAlthough MARC has been around for a long time, nothing lasts forever (see Gmane).\nSince MARC uses opaque message identifiers, switching to lore.kernel.org should be a strict improvement since, even if lore.kernel.org goes down, the Message-ID will allow future readers to look up the referenced messages on any other archive.\nWe leave behind one reference to MARC in the README.md since it's a perfectly fine mail archive for personal reading, just not for linking messages for the future.\n\nAnd:\n\nRelNotes: replace Gmane with real Message-IDs\nSigned-off-by: Denton Liu\n\n\nThe only references to Gmane that remain are in RelNotes.\nAlthough these are definitely not in active use, they might be of historical interest for future readers so let's ensure that mail references are more robust.\nReplace links to Gmane with links to lore.kernel.org (which is our new preferred mailing list archive and has the Message-ID in the URL) and bare Gmane ID references with Message-IDs.\nThe Message-IDs were found by searching for \"gmane:<id>\" on https://public-inbox.org/git/ and taking the resulting message.\n\nAnd regarding lkml.org:\n\ndoc: replace LKML link with lore.kernel.org\nSigned-off-by: Denton Liu\n\n\nSince we're now recommending lore.kernel.org, replace LKML link with lore.kernel.org.\nAlthough LKML has been around for a long time, nothing lasts forever (see Gmane).\nSince LKML uses opaque message identifiers, switching to lore.kernel.org should be a strict improvement since, even if lore.kernel.org goes down, the Message-ID will allow future readers to look up the referenced messages on any other archive.\n\n\nWith Git 2.26 (Q1 2020), there is more documentation for new contributors.\nSee commit a2dc434 (14 Feb 2020), and commit 4bb4fd4 (24 Jan 2020) by Emily Shaffer (nasamuffin).\n(Merged by Junio C Hamano -- gitster -- in commit 325eb66, 25 Feb 2020)\n\nMyFirstContribution: add avenues for getting help\nSigned-off-by: Emily Shaffer\n\n\nWith https://lore.kernel.org/git/[email protected]/ we now have a mentoring mailing list, to which we should direct new contributors who have questions.\nMention #git-devel, which is targeted for Git contributors; asking for help with getting a first contribution together is on-topic for that channel. Also mention some of the conventions in case folks are unfamiliar with IRC.\nBecause the mentoring list and #git-devel are both a subset of Git contributors, finally list the main Git list and mention some of the posting conventions.\n\nAnd:\n\nMyFirstContribution: rephrase contact info\nSigned-off-by: Emily Shaffer\nReviewed-by: Jonathan Nieder\n\n\nMake an effort not to discourage new users from mailing questions to [email protected], and explain the purpose of the mentoring list in contrast to the main list.\n\n\nWith Git 2.27 (Q2 2020), before reporting a bug, read the (new) FAQ.\nSee commit 2149b67 (30 Mar 2020) by brian m. carlson (bk2204).\n(Merged by Junio C Hamano -- gitster -- in commit 06aaafb, 22 Apr 2020)\n\ndocs: add a FAQ\nSigned-off-by: brian m. carlson\n\n\nGit is an enormously flexible and powerful piece of software.\nHowever, it can be intimidating for many users and there are a set of common questions that users often ask.\nWhile we already have some new user documentation, it's worth adding a FAQ to address common questions that users often have.\nEven though some of this is addressed elsewhere in the documentation, experience has shown that it is difficult for users to find, so a centralized location is helpful.\nAdd such a FAQ and fill it with some common questions and answers. While there are few entries now, we can expand it in the future to cover more things as we find new questions that users have.\nThe FAQ also addresses common configuration questions that apply not only to Git as an independent piece of software but also the ecosystem of CI tools and hosting providers that people use, since these are the source of common questions.\n\n\nWith Git 2.27 (Q2 2020), you can use the \"bugreport\" tool.\nSee commit 8f0e984 (27 Apr 2020), and commit 69bcbbc, commit 1411914, commit 617d571, commit 238b439, commit 709df95 (16 Apr 2020) by Emily Shaffer (nasamuffin).\n(Merged by Junio C Hamano -- gitster -- in commit dd094c2, 01 May 2020)\n\nbugreport: add tool to generate debugging info\nSigned-off-by: Emily Shaffer\n\n\nTeach Git how to prompt the user for a good bug report: reproduction steps, expected behavior, and actual behavior. Later, Git can learn how to collect some diagnostic information from the repository.\nIf users can send us a well-written bug report which contains diagnostic information we would otherwise need to ask the user for, we can reduce the number of question-and-answer round trips between the reporter and the Git contributor.\nUsers may also wish to send a report like this to their local \"Git expert\" if they have put their repository into a state they are confused by.\n\nThe git bugreport documentation includes:\n\ngit bugreport [(-o | --output-directory) <path>] [(-s | --suffix) <format>]\n\n\n\nDESCRIPTION\n\n\nCaptures information about the user's machine, Git client, and repository state, as well as a form requesting information about the behavior the user observed, into a single text file which the user can then share, for example to the Git mailing list, in order to report an observed bug.\nThe following information is requested from the user:\n\nReproduction steps\nExpected behavior\nActual behavior\n\n\n\nWith Git 2.27 (Q2 2020), \"git bugreport\" learned to report enabled hooks in the repository.\nSee commit 788a776 (08 May 2020) by Emily Shaffer (nasamuffin).\n(Merged by Junio C Hamano -- gitster -- in commit 3583730, 14 May 2020)\n\nbugreport: collect list of populated hooks\nSigned-off-by: Emily Shaffer\n\n\nOccasionally a failure a user is seeing may be related to a specific hook which is being run, perhaps without the user realizing.\nWhile the contents of hooks can be sensitive - containing user data or process information specific to the user's organization - simply knowing that a hook is being run at a certain stage can help us to understand whether something is going wrong.\nWithout a definitive list of hook names within the code, we compile our own list from the documentation. This is likely prone to bitrot, but designing a single source of truth for acceptable hooks is too much overhead for this small change to the bugreport tool.\n\n\nWith Git 2.28 (Q3 2020), \"git bugreport\" learns to report what shell is in use.\nSee commit 4a4804e, commit 39f4919 (12 May 2020) by Emily Shaffer (nasamuffin).\n(Merged by Junio C Hamano -- gitster -- in commit ce095ec, 09 Jun 2020)\n\nhelp: add shell-path to --build-options\nSigned-off-by: Emily Shaffer\n\n\nIt may be useful to know which shell Git was built to try to point to, in the event that shell-based Git commands are failing.\n$SHELL_PATH is set during the build and used to launch the manpage viewer, as well as by git-compat-util.h, and it's used during tests.\n'git version --build-options' is encouraged for use in bug reports, so it makes sense to include this information there.\n\nAnd:\n\nbugreport: include user interactive shell\nSigned-off-by: Emily Shaffer\n\n\nIt's possible a user may complain about the way that Git interacts with their interactive shell, e.g. autocompletion or shell prompt. In that case, it's useful for us to know which shell they're using interactively.\n\n\nExpectation for the original contributor after responding to a review comment to use the explanation in a patch update has been described with Git 2.30 (Q1 2021).\nSee commit a6d8d11 (20 Nov 2020) by Junio C Hamano (gitster).\n(Merged by Junio C Hamano -- gitster -- in commit b94b1f9, 30 Nov 2020)\n\nMyFirstContribition: answering questions is not the end of the story\nReviewed-by: Emily Shaffer\n\n\nA review exchange may begin with a reviewer asking \"what did you mean by this phrase in your log message (or here in the doc)?\", the author answering what was meant, and then the reviewer saying \"ah, that is what you meant---then the flow of the logic makes sense\".\nBut that is not the happy end of the story.\nNew contributors often forget that the material that has been reviewed in the above exchange is still unclear in the same way to the next person who reads it, until it gets updated.\nWhile we are in the vicinity, rephrase the verb \"request\" used to refer to comments by reviewers to \"suggest\"---this matches the contrast between \"original\" and \"suggested\" that appears later in the same paragraph, and more importantly makes it clearer that it is not like authors are to please reviewers' wishes but rather reviewers are merely helping authors to polish their commits.\nmade the change suggested, feel the original is better, or that the comment\n\nMyFirstContribution now includes in its man page:\n\nReviewers may ask you about what you wrote in the patchset, either in\nthe proposed commit log message or in the changes themselves. You\nshould answer these questions in your response messages, but often the\nreason why reviewers asked these questions to understand what you meant\nto write is because your patchset needed clarification to be understood.\nDo not be satisfied by just answering their questions in your response\nand hear them say that they now understand what you wanted to say.\nUpdate your patches to clarify the points reviewers had trouble with,\nand prepare your v2; the words you used to explain your v1 to answer\nreviewers' questions may be useful thing to use. Your goal is to make\nyour v2 clear enough so that it becomes unnecessary for you to give the\nsame explanation to the next person who reads it.\n\n\nWith Git 2.30 (Q1 2021), the use of non-reentrant localtime() has been removed.\nSee commit 4f6460d (30 Nov 2020) by Taylor Blau (ttaylorr).\n(Merged by Junio C Hamano -- gitster -- in commit bb48056, 08 Dec 2020)\n\nbuiltin/bugreport.c: use thread-safe localtime_r()\nSigned-off-by: Taylor Blau\n\n\nTo generate its filename, the 'git bugreport'(man) builtin asks the system for the current time with 'localtime()'.\nSince this uses a shared buffer, it is not thread-safe.\nEven though 'git bugreport'(man) is not multi-threaded, using localtime() can trigger some static analysis tools to complain, and a quick\n$ git grep -oh 'localtime\\(_.\\)\\?' -- **/*.c | sort | uniq -c \n\nshows that the only usage of the thread-unsafe 'localtime' is in a piece of documentation.\nSo, convert this instance to use the thread-safe version for consistency, and to appease some analysis tools." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-branch - List, create, or delete branches -q --quiet" }, { "role": "assistant", "content": "Be more quiet when creating or deleting a branch, suppressing\nnon-error messages." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-archimport" }, { "role": "assistant", "content": "Import a GNU Arch repository into Git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Unignore subdirectories of ignored directories in Git\nLet's say I have ignored a directory, but I want to unignore specific subdirectories therein. So I have the setup:\n/uploads/\n/uploads/rubbish/\n/uploads/rubbish/stuff/KEEP_ME/\n/uploads/foo/\n/uploads/foo/bar/lose/\n\nAnd I want to ignore everything but the KEEP_ME directory. I would hope the ignore would look something like:\n/uploads/*\n!/uploads/rubbish/stuff/KEEP_ME/\n\nBut that's not working, and neither are several permutations on the same theme.\nOne that does work is\n/uploads/**/**/**/\n!/uploads/rubbish/stuff/KEEP_ME/\n\nBut that feels a little restrictive and verbose?" }, { "role": "assistant", "content": "According to pattern format section of the gitignore documentation:\n\nAn optional prefix \"!\" which negates the pattern; any matching file\n excluded by a previous pattern will become included again. It is not\n possible to re-include a file if a parent directory of that file is\n excluded. Git doesn’t list excluded directories for performance\n reasons, so any patterns on contained files have no effect, no matter\n where they are defined. Put a backslash (\"\\\") in front of the first\n \"!\" for patterns that begin with a literal \"!\", for example,\n \"!important!.txt\".\n\nTherefore the previously-excluded parent directory /uploads/rubbish/stuff/keep/ pattern must be exclusively negated before negating its content:\n#ignore everything within /uploads/ \n/uploads/*\n\n#include everything within /uploads/rubbish/stuff/keep\n!/uploads/rubbish/stuff/keep/ \n!/uploads/rubbish/stuff/keep/*\n\nTo include subdirectories inside /uploads/rubbish/stuff/keep/ add the third line:\n!/uploads/rubbish/stuff/keep/**/*" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to see untracked files in git instead of untracked directory\n\ngit status shows directory (e.g smaller_fc) is untracked. \nHowever, I want to see exactly which files inside the directories (e.g smaller_fc) are untracked.\nI would like to know if .gitignore is indeed ignoring certain subdir inside smaller_fc dir.\nHere is terminal output.\n$ git status\nOn branch master\nYour branch is ahead of 'origin/master' by 1 commit.\n (use \"git push\" to publish your local commits)\nChanges not staged for commit:\n (use \"git add ...\" to update what will be committed)\n (use \"git checkout -- ...\" to discard changes in working directory)\nmodified: .gitignore\n\nUntracked files:\n (use \"git add ...\" to include in what will be committed)\nnets/models/500K_iterations/500K_iteration_eval.txt\nnets/models/from_solverstate_150K/\nnets/models/pretrained_model/\nnets/models/smaller_fc/\n\n.gitignore file:\n.cproject\n.project\n.pydevproject\nbuild\n*~\n*.pyc\n*.caffemodel\n*/solverstate/*\n\ndirectory structure:\nroot\n-models\n--model1\n---solverstate\n----somefiles.txt\n--model2\n---solverstate\n----anotherfiles.txt\n.gitignore\n\nCould not find it on google." }, { "role": "assistant", "content": "If git only shows that the directory is untracked, then every file in it (including files in subdirectories) is untracked.\n\nIf you have some ignored files in the directory, pass the -u flag when running git status (i.e., git status -u) to show the status of individual untracked files." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can't push to GitHub because of large file which I already deleted\nCurrently I have\n\nEmpty GitHub repo\nSSH server repo (main)\nLocal Repo\n\nSSH server repo was the most up-to-date repo (production site) so I did a Git clone from there to local. I then tried to do a git push to GitHub.\nEverything went OK but then it said something about filename.gz being too large for GitHub. I didn't need this file so I ran several Git commands to get rid of it from Git cache then pushed back to SSH server.\nI don't see the large file locally but it's still on SSH server even though git diff returns nothing and git push returns \"Everything is up-to-date\" - And even though the file is not visible in local repo when I try to push to GitHub I still get error about it \n\nremote: error: File fpss.tar.gz is 135.17 MB; this exceeds GitHub's file size limit of 100 MB\n\nI followed steps under \"fixing the problem\" listed on GitHub help so shouldn't that have been enough?\nHow is the file still in the ether when it's not local or listed in git status/diff/push?" }, { "role": "assistant", "content": "You can use\ngit filter-branch --index-filter 'git rm -r --cached --ignore-unmatch <file/dir>' HEAD\n\nThis will delete everything in the history of that file. The problem is that the file is present in the history.\nThis command changes the hashes of your commits which can be a real problem, especially on shared repositories. It should not be performed without understanding the consequences.\nEdit: The git project now recommends that users use git filter-repo instead of git filter-branch.\n\nUsing git filter-repo\nWARNING: git-filter-branch has a glut of gotchas generating mangled history\n rewrites. Hit Ctrl-C before proceeding to abort, then use an\n alternative filtering tool such as 'git filter-repo'\n (https://github.com/newren/git-filter-repo/) instead. See the\n filter-branch manual page for more details; to squelch this warning,\n set FILTER_BRANCH_SQUELCH_WARNING=1.\n\nInstallation\n[brew|pip3|...] install git-filter-repo\n\nUsage\nTo remove any file with the path prefix example/path/to/something, you can run\ngit filter-repo --path example/path/to/something--invert-paths\n\nTo remove any file without the path prefix example/path/to/something, you can run\ngit filter-repo --path example/path/to/something" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitLab: Unable to fork my own project\n\nI am trying to fork one of my private projects in GitLab, But when I press the fork button I'll receive this:\n\nNo available namespaces to fork the project. \n You must have permission to create a project in a namespace before forking.\n\nBut I have Master privilege in the project." }, { "role": "assistant", "content": "From the top, blue navigation menu, go to Groups > Your Groups,\nClick the New group button on the top right corner,\nType in the details of your new group,\nClick the Create group button.\n\nOn the Members page of your new group, manage your members. Your account would probably already be added.\nNow you can fork that project." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fast-import - Backend for fast Git data importers alias" }, { "role": "assistant", "content": "Record that a mark refers to a given object without first\ncreating any new object. Using --import-marks and referring\nto missing marks will cause fast-import to fail, so aliases\ncan provide a way to set otherwise pruned commits to a valid\nvalue (e.g. the nearest non-pruned ancestor)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs log.abbrevCommit" }, { "role": "assistant", "content": "If true, makes git-log , git-show , and git-whatchanged assume --abbrev-commit . You may\noverride this option with --no-abbrev-commit ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the intended use-case for git stash?\nIf I work on branch A and suddenly need to work on branch B before being ready with a commit on branch A, I stash my changes on A, checkout B, do my work there, then checkout A and apply the stash.\nIf I work on A and I want to stop working for the day, should I stash my work and then apply it the next day (when I resume my work), or should I just leave things as they are—uncommitted modified files in the working directory? I don't see why I would need to use stash in this case, except if there is some security benefit.\nAlso, another scenario: I work both at work and at home. If I am not ready with a commit when I want to go home, can I stash my work, push it to GitHub and then pull that stash at home?" }, { "role": "assistant", "content": "Stash is just a convenience method. Since branches are so cheap and easy to manage in git, I personally almost always prefer creating a new temporary branch than stashing, but it's a matter of taste mostly.\nThe one place I do like stashing is if I discover I forgot something in my last commit and have already started working on the next one in the same branch:\n# Assume the latest commit was already done\n# start working on the next patch, and discovered I was missing something\n\n# stash away the current mess I made\ngit stash save\n\n# some changes in the working dir\n\n# and now add them to the last commit:\ngit add -u\ngit commit --amend\n\n# back to work!\ngit stash pop" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-shell" }, { "role": "assistant", "content": "Restricted login shell for Git-only SSH access" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs plain" }, { "role": "assistant", "content": "Show words as [-removed-] and {+added+} . Makes no\nattempts to escape the delimiters if they appear in the input,\nso the output may be ambiguous." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Jenkins linking to my local git repository\n\nI'm new to Jenkins and git too. I created a remote repository at github.com and made a local copy of it.\nThen I want to link it through Jenkins. I installed needed plugins for git integration, but I don't know what my local Repository URL is to set it when configuring the new project. Could someone help me where to find it?" }, { "role": "assistant", "content": "In this case, the URL should start with the file protocol followed by the path to the repository. E.g., file:///home/rbkcbeqc/dev/git/gitsandbox." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Best way to add Gradle support to IntelliJ Project\nI have looked around quite a bit and haven't found the best solution to convert an existing IntelliJ project to Gradle. I work in a team environment and we currently share the .ipr file as we have a few build configurations that we track. We will be getting rid of those in favor of Gradle eventually but I can't screw things up too much until the Gradle conversion is done.\nAlso, our Java source files are located in the root of the src directory instead of src/main/java as is standard.\nIs there a way I can add Gradle to my project that won't make me delete and recreate my IntelliJ project and won't screw everyone else up when they do a Git pull?" }, { "role": "assistant", "content": "Add:\nbuild.gradle \n\nin your root project folder, and use plugin for example:\napply plugin: 'idea'\n//and standard one\napply plugin: 'java'\n\nand with this fire from command line:\ngradle cleanIdea \n\nand after that:\ngradle idea\n\nAfter that everything should work" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --ita-invisible-in-index" }, { "role": "assistant", "content": "By default entries added by \"git add -N\" appear as an existing\nempty file in \"git diff\" and a new file in \"git diff --cached\".\nThis option makes the entry appear as a new file in \"git diff\"\nand non-existent in \"git diff --cached\". This option could be\nreverted with --ita-visible-in-index . Both options are\nexperimental and could be removed in future." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git" }, { "role": "assistant", "content": "BASIC EXAMPLES Tracking and contributing to the trunk of a Subversion-managed project\n(ignoring tags and branches): # Clone a repo (like git clone):\n\tgit svn clone http://svn.example.com/project/trunk\n# Enter the newly cloned directory:\n\tcd trunk\n# You should be on master branch, double-check with 'git branch'\n\tgit branch\n# Do some work and commit locally to Git:\n\tgit commit ...\n# Something is committed to SVN, rebase your local changes against the\n# latest changes in SVN:\n\tgit svn rebase\n# Now commit your changes (that were committed previously using Git) to SVN,\n# as well as automatically updating your working HEAD:\n\tgit svn dcommit\n# Append svn:ignore settings to the default Git exclude file:\n\tgit svn show-ignore >> .git/info/exclude Tracking and contributing to an entire Subversion-managed project\n(complete with a trunk, tags and branches): # Clone a repo with standard SVN directory layout (like git clone):\n\tgit svn clone http://svn.example.com/project --stdlayout --prefix svn/\n# Or, if the repo uses a non-standard directory layout:\n\tgit svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/\n# View all branches and tags you have cloned:\n\tgit branch -r\n# Create a new branch in SVN\n\tgit svn branch waldo\n# Reset your master to trunk (or any other branch, replacing 'trunk'\n# with the appropriate name):\n\tgit reset --hard svn/trunk\n# You may only dcommit to one branch/tag/trunk at a time. The usage\n# of dcommit/rebase/show-ignore should be the same as above. The initial git svn clone can be quite time-consuming\n(especially for large Subversion repositories). If multiple\npeople (or one person with multiple machines) want to use git svn to interact with the same Subversion repository, you can\ndo the initial git svn clone to a repository on a server and\nhave each person clone that repository with git clone : # Do the initial import on a server\n\tssh server \"cd /pub && git svn clone http://svn.example.com/project [options...]\"\n# Clone locally - make sure the refs/remotes/ space matches the server\n\tmkdir project\n\tcd project\n\tgit init\n\tgit remote add origin server:/pub/project\n\tgit config --replace-all remote.origin.fetch '+refs/remotes/*:refs/remotes/*'\n\tgit fetch\n# Prevent fetch/pull from remote Git server in the future,\n# we only want to use git svn for future updates\n\tgit config --remove-section remote.origin\n# Create a local branch from one of the branches just fetched\n\tgit checkout -b master FETCH_HEAD\n# Initialize 'git svn' locally (be sure to use the same URL and\n# --stdlayout/-T/-b/-t/--prefix options as were used on server)\n\tgit svn init http://svn.example.com/project [options...]\n# Pull the latest changes from Subversion\n\tgit svn rebase" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Do Visual Studio Database Project *.refactorlog Files Belong in Source Control?\nI am using git (via GitHub for Windows) and I am using the latest .gitignore for Visual Studio from GitHub\nI notice that my <ProjectName>.refactorlog files are being included in my commits.\nDo .refactorlog files belong in source control?" }, { "role": "assistant", "content": "The .refactorlog should be in source control if you intend to move database objects across schemas.\nSee: MSDN: Move a Database Object to a Different Schema\nRelevant section: Preserving Your Intent With The Refactoring Log\n\nWhen you move a database object to a different schema, an entry is\n added to the refactoring log for your database project. When you\n deploy your changes, this log helps ensure that the corresponding\n object in the target environment is renamed as you intended.\n Otherwise, the existing object would be dropped, and an object would be added with the new name. The log is maintained in an XML file that\n is named ProjectName.refactorlog. You check this file in to version control when you check in the other files that compose your database project. The ProjectName.refactorlog file contains only information\n about refactoring operations that require special handling during\n deployment." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I \"git clone\" a repo, including its submodules?\nHow do I clone a git repository so that it also clones its submodules?\nRunning git clone $REPO_URL merely creates empty submodule directories." }, { "role": "assistant", "content": "With version 2.13 of Git and later, --recurse-submodules can be used instead of --recursive:\ngit clone --recurse-submodules -j8 git://github.com/foo/bar.git\ncd bar\n\nEditor’s note: -j8 is an optional performance optimization that became available in version 2.8, and fetches up to 8 submodules at a time in parallel — see man git-clone.\nWith version 1.9 of Git up until version 2.12 (-j flag only available in version 2.8+):\ngit clone --recursive -j8 git://github.com/foo/bar.git\ncd bar\n\nWith version 1.6.5 of Git and later, you can use:\ngit clone --recursive git://github.com/foo/bar.git\ncd bar\n\nFor already cloned repos, or older Git versions, use:\ngit clone git://github.com/foo/bar.git\ncd bar\ngit submodule update --init --recursive" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_EDITOR" }, { "role": "assistant", "content": "This environment variable overrides $EDITOR and $VISUAL .\nIt is used by several Git commands when, on interactive mode,\nan editor is to be launched. See also git-var and the core.editor option in git-config ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fast-import - Backend for fast Git data importers tag" }, { "role": "assistant", "content": "Creates an annotated tag object from an existing commit or\nbranch. Lightweight tags are not supported by this command,\nas they are not recommended for recording meaningful points\nin time." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitattributes - Defining attributes per path Unspecified" }, { "role": "assistant", "content": "Use the value of the core.whitespace configuration variable to\ndecide what to notice as error." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to test git hooks\nSince \"testing\" is a common use for a Git hook, my question is hard to search for.\nI'm writing a fairly involved git post-receive hook and want to know what the best way to test it is. Currently my process is:\n\nmake changes to post-receive in a dummy \"remote\" repo\nmake a change to a dummy local repo\ncommit change in dummy local repo\npush change to dummy remote repo\n\nIs there any easier way to test this? Ideally it would look like:\n\nmake change(s) to post-receive in a dummy repo\nissue \"magic\" command to test post-receive\n\nPerhaps I can \"reissue\" a previous push or have the remote repo act as though it just received a push with a specific hash?" }, { "role": "assistant", "content": "Answer this four-years-old question.\nIf you'd like to test hook, you need to test in local environment first, I give the detail commands for following up, use post-receive as sample:\n$ mkdir /tmp/hook_test\n$ cd /tmp/hook_test\n\n$ # set local git repo, where you put hooks in it.\n$ git clone --bare https://github.com/git/git.git\n\n$ # set develop environment which is cloned from the new created repo. \n$ git clone git.git repo \n \n$ # copy and rename the hook you need test to \"post-receive\"\n$ cd git.git/hooks\n$ cp ~/post-receive-test post-receive\n\n$ # suppose the hook script is bash script.\n$ # edit \"post-receive\" and add \"set -x\" to second line in it to active debug\n\n$ cd /tmp/hook_test/repo\n$ # emulate a hook trigger, do some changes, \"git add\" and \"git commit\" it \n\n$ git push\n \n$ # Now you should see the script \"post-receive\" runs automatically with debug details.\n\nYou should be free to run git push, that the updates are only pushed to local repo /tmp/hook_test/git.git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to make git status show only staged files\nI would like to get a list of only the staged filenames. I can't find the equivalent flag for --name-only for the git status command. What is a good alternative?\nThe file list will be piped to php -l (PHP lint syntax checker).\nSolution: the complete command\ngit diff --name-only --cached | xargs -l php -l" }, { "role": "assistant", "content": "Use git diff --name-only (with --cached to get the staged files)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_WORK_TREE" }, { "role": "assistant", "content": "Set the path to the root of the working tree.\nThis can also be controlled by the --work-tree command-line\noption and the core.worktree configuration variable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary dangling object" }, { "role": "assistant", "content": "An unreachable object which is not reachable even from other unreachable objects; a\ndangling object has no references to it from any\nreference or object in the repository ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitLab-CI get pom version in pipeline\n\nI'd like to build docker image via gitlab CI with project's version as a tag:\ndocker build -t dockerimage:VERSION-IN-POM .\n\nIn jenkins' pipeline i'm getting the version like that: \n${pom.version}\n\nIs it possible to read the version in a similar, convenient way from gitlab CI? Or do I have to write scripts for that?" }, { "role": "assistant", "content": "Assuming you have maven in build environment, you could use maven help plugin and grep to extract version.\nVERSION=$(mvn --non-recursive help:evaluate -Dexpression=project.version | grep -v '\\[.*')\necho $VERSION" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --check" }, { "role": "assistant", "content": "Warn if changes introduce conflict markers or whitespace errors.\nWhat are considered whitespace errors is controlled by core.whitespace configuration. By default, trailing whitespaces (including\nlines that consist solely of whitespaces) and a space character\nthat is immediately followed by a tab character inside the\ninitial indent of the line are considered whitespace errors.\nExits with non-zero status if problems are found. Not compatible\nwith --exit-code." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-commit-tree - Create a new commit object" }, { "role": "assistant", "content": "FILES /etc/mailname" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is it possible to have a Subversion repository as a Git submodule?\nIs there a way to add a Subversion repository as a Git submodule in my Git repository?\nSomething like:\ngit-svn submodule add https://svn.foo.com/svn/proj --stdlayout svn-project\n\nWhere https://svn.foo.com/svn/proj points to a Subversion repository.\nI know there is git-svn which allows one to interact with a Subversion repository. So I am thinking, maybe there is a way to checkout a Subversion repository with git-svn and then use it as a submodule." }, { "role": "assistant", "content": "No. Your best bet would be to set up a mirror of the svn repository in a dedicated git repository. \ngit svn clone -s http://subversion.example.com/ mysvnclone\ncd mysvnclone\ngit remote add origin [email protected]:project.git\ngit push origin master\n\nThen you can add the git repository as a submodule to the original project\ncd /path/to/gitproject\ngit submodule add git://example.com/project.git -- svn-project\ngit add svn-project\ngit commit -m \"Add submodule\"\n\nThere is one conceptual difference between svn:externals and git submodule that may trip you up if you approach this from a subversion point of view. The git submodule is pegged to the revision that you give it. If \"upstream\" changes, then you have to update your submodule's reference. \nSo when we resync with the upstream subversion:\ncd /path/to/mysvnclone\ngit svn rebase\ngit push\n\n... the git project will still use the original revision that we committed earlier. To update to the svn HEAD, you would have to use\ncd /path/to/gitproject/svn-project\ngit checkout master\ngit pull\ncd ..\ngit add svn-project\ngit commit -m\"Update submodule\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters --keep-dashdash" }, { "role": "assistant", "content": "Only meaningful in --parseopt mode. Tells the option parser to echo\nout the first -- met instead of skipping it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Visual Studio Code is always asking for Git credentials\n\nI started using Visual Studio Code, and I was trying to save my test project into GitHub, but Visual Studio Code is always asking for my GitHub credentials.\nI have installed in my PC GitHub Desktop and also Git. I already ran:\n git config --global credential.helper wincred\n\nbut still Visual Studio Code is asking for the credentials.\nHow can I fix this?\nHere is my .gitconfig file located in the user profile folfer:\n [filter \"lfs\"]\n clean = git-lfs clean %f\n smudge = git-lfs smudge %f\n required = true\n[user]\n name = ddieppa\n[user]\n email = [email protected]\n[credential]\n helper = wincred\n\nHere is the popup windows asking for the credentials:\n\nI enter my GitHub credentials in the popup, but still getting this error in the Git output window in Visual Studio Code:\nremote: Anonymous access to ddieppa/LineOfBizApp.git denied.\nfatal: Authentication failed for 'https://github.com/ddieppa/LineOfBizApp.git/'" }, { "role": "assistant", "content": "Why does Visual Studio Code ask for a password? Because Visual Studio Code runs the auto-fetch feature, while the Git server doesn't have any information to authorize your identity. It happens when:\n\nYour Git repository has a https remote URL. Yes! This kind of remote will absolutely ask you every time. No exceptions here! (You can do a temporary trick to cache the authorization as the solution below, but this is not recommended.)\nYour Git repository has ssh remote URL, but you've not copied your ssh public key onto the Git server. Use ssh-keygen to generate your key and copy it to Git server. Done! This solution also helps you never retype password on terminal again. See a good instruction by @Fnatical here for the answer.\n\nThe updated part at the end of this answer doesn't really help you at all. (It actually makes you stagnant in your workflow.) It only stops things happening in Visual Studio Code and moves these happenings to the terminal.\nSorry if this bad answer has affected you for a long, long time.\n\nThe original answer (bad)\nI found the solution on Visual Studio Code document:\n\nTip: You should set up a credential helper to avoid getting asked\nfor credentials every time VS Code talks to your Git remotes. If you\ndon't do this, you may want to consider Disabling Autofetch in the ...\nmenu to reduce the number of prompts you get.\n\nSo, turn on the credential helper so that Git will save your password in memory for some time. By default, Git will cache your password for 15 minutes.\nIn Terminal, enter the following:\ngit config --global credential.helper cache\n# Set Git to use the credential memory cache\n\nTo change the default password cache timeout, enter the following:\ngit config --global credential.helper 'cache --timeout=3600'\n# Set the cache to timeout after 1 hour (setting is in seconds)\n\nIf the original answer doesn't work\nI installed Visual Studio Code and configuration same above, but as @ddieppa said, It didn't work for me too. So I tried to find an option in User Setting, and I saw \"git.autofetch\" = true, now set it's false! Visual Studio Code is no longer required to enter password repeatedly again!\nIn menu File → Preferences → User Setting:\nType these:\nPlace your settings in this file to overwrite the default settings:\n{\n \"git.autofetch\": false\n}" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is a changelist in IntelliJ IDEA?\nWhat is a changelist in IntelliJ IDEA? Is it similar to a commit? When adding one, I have the following options:\n\nName (text field)\nComment (text field)\nMake this changelist active (checkbox)\nTrack context (checkbox)" }, { "role": "assistant", "content": "Changelists, when used with Git, is a way to split your index (i.e. the files you have added to git) into logical filesets. See Using Git Locally with IntelliJ IDEA\nThose changelists can represent whatever you want (a task, a fix, a merge etc), but they are not git commits.\nYou can commit one or several changelists.\n\nWhen you add a file to the Git Index, IntelliJ IDEA adds your file to the default changelist, named... \"default\"." } ]
[ { "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": "git-branch - List, create, or delete branches branch.<name>.mergeOptions" }, { "role": "assistant", "content": "Sets default options for merging into branch <name>. The syntax and\nsupported options are the same as those of git-merge , but\noption values containing whitespace characters are currently not\nsupported." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --merge" }, { "role": "assistant", "content": "Show commits touching conflicted paths in the range HEAD...<other> ,\nwhere <other> is the first existing pseudoref in MERGE_HEAD , CHERRY_PICK_HEAD , REVERT_HEAD or REBASE_HEAD . Only works\nwhen the index has unmerged entries. This option can be used to show\nrelevant commits when resolving conflicts from a 3-way merge." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Host Key Verification Failed - GitLab with Visual Studio Code on macOS\n\nI keep getting a \"Host Key Verification Failed\" error when trying to push changes to a git controlled folder/project to Gitlab. For whatever reason, it works fine using Visual Studio for Mac, and I can login to my Gitlab account just fine via web browser." }, { "role": "assistant", "content": "Resolved by deleting any/all Known_hosts files in ~/.ssh/ and then executing ssh [email protected] in Terminal and answering \"yes\" (which re-adds [email protected] to known_hosts after re-creating a new known_hosts file).\nI did some messing around in known_hosts which probably caused the problem." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-commit-tree - Create a new commit object" }, { "role": "assistant", "content": "DESCRIPTION This is usually not what an end user wants to run directly. See git-commit instead. Creates a new commit object based on the provided tree object and\nemits the new commit object id on stdout. The log message is read\nfrom the standard input, unless -m or -F options are given. The -m and -F options can be given any number of times, in any\norder. The commit log message will be composed in the order in which\nthe options are given. A commit object may have any number of parents. With exactly one\nparent, it is an ordinary commit. Having more than one parent makes\nthe commit a merge between several lines of history. Initial (root)\ncommits have no parents. While a tree represents a particular directory state of a working\ndirectory, a commit represents that state in \"time\", and explains how\nto get there. Normally a commit would identify a new \"HEAD\" state, and while Git\ndoesn’t care where you save the note about that state, in practice we\ntend to just write the result to the file that is pointed at by .git/HEAD , so that we can always see what the last committed\nstate was." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to create a merge request at the end of a successful pipeline in Gitlab?\n\nI'm very new to gitlab and gitlab CI and I have put a pipeline in place that is successfully completing.\nMy master and development branches are protected so a merge request is required so that another dev in the group can review the code and comment before merging.\nI was wondering if it is possible to generate this merge request at the end of this pipeline. Is there a setting for this in the gitlab repository or do I have to create a script to achieve this?\nSide note : \nJust before posting this I came across this section of the gitlab docs \nI'm using gitlab-runner 11.0.0 on ubuntu 18.04" }, { "role": "assistant", "content": "In order to achieve my simple needs, I simply added a final stage to my pipeline which essentially executes a bash script adapted from this post.\nEDIT:\nAs requested by @Yuva\n# Create a pull request on pipeline success\ncreate_merge_request:\n stage: createMR\n tags:\n - autoMR\n script:\n - 'echo Merge request opened by $GITLAB_USER_NAME '\n - ~/commit.sh\n\n\nand in commit.sh\n#!/bin/bash\n# This script was adapted from:\n# https://about.gitlab.com/2017/09/05/how-to-automatically-create-a-new-mr-on-gitlab-with-gitlab-ci/\n\n# TODO determine URL from git repository URL\n[[ $HOST =~ ^https?://[^/]+ ]] && HOST=\"${BASH_REMATCH[0]}/api/v4/projects/\"\n\n# The branch which we wish to merge into\nTARGET_BRANCH=develop;\n\n# The user's token name so that we can open the merge request as the user\nTOKEN_NAME=`echo ${GITLAB_USER_LOGIN}_COMMIT_TOKEN | tr \"[a-z]\" \"[A-Z]\"`\n\n# See: http://www.tldp.org/LDP/abs/html/parameter-substitution.html search ${!varprefix*}, ${!varprefix@} section\nPRIVATE_TOKEN=`echo ${!TOKEN_NAME}`\n\n# The description of our new MR, we want to remove the branch after the MR has\n# been closed\nBODY=\"{\n\\\"project_id\\\": ${CI_PROJECT_ID},\n\\\"source_branch\\\": \\\"${CI_COMMIT_REF_NAME}\\\",\n\\\"target_branch\\\": \\\"${TARGET_BRANCH}\\\",\n\\\"remove_source_branch\\\": false,\n\\\"force_remove_source_branch\\\": false,\n\\\"allow_collaboration\\\": true,\n\\\"subscribed\\\" : true,\n\\\"title\\\": \\\"${GITLAB_USER_NAME} merge request for: ${CI_COMMIT_REF_SLUG}\\\"\n}\";\n\n# Require a list of all the merge request and take a look if there is already\n# one with the same source branch\n LISTMR=`curl --silent \"${HOST}${CI_PROJECT_ID}/merge_requests?state=opened\" --header \"PRIVATE-TOKEN:${PRIVATE_TOKEN}\"`;\n COUNTBRANCHES=`echo ${LISTMR} | grep -o \"\\\"source_branch\\\":\\\"${CI_COMMIT_REF_NAME}\\\"\" | wc -l`;\n\n# No MR found, let's create a new one\nif [ ${COUNTBRANCHES} -eq \"0\" ]; then\n curl -X POST \"${HOST}${CI_PROJECT_ID}/merge_requests\" \\\n --header \"PRIVATE-TOKEN:${PRIVATE_TOKEN}\" \\\n --header \"Content-Type: application/json\" \\\n --data \"${BODY}\";\n\n echo \"Opened a new merge request: WIP: ${CI_COMMIT_REF_SLUG} for user ${GITLAB_USER_LOGIN}\";\n exit;\nfi\n echo \"No new merge request opened\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker --glob-pathspecs" }, { "role": "assistant", "content": "Add \"glob\" magic to all pathspec. This is equivalent to setting\nthe GIT_GLOB_PATHSPECS environment variable to 1 . Disabling\nglobbing on individual pathspecs can be done using pathspec\nmagic \":(literal)\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository summary" }, { "role": "assistant", "content": "For a successfully fetched ref, the summary shows the old and new\nvalues of the ref in a form suitable for using as an argument to git log (this is <old>..<new> in most cases, and <old>...<new> for forced non-fast-forward updates)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_OPTIONAL_LOCKS" }, { "role": "assistant", "content": "If this Boolean environment variable is set to false, Git will complete any requested operation without\nperforming any optional sub-operations that require taking a lock.\nFor example, this will prevent git status from refreshing the\nindex as a side effect. This is useful for processes running in\nthe background which do not want to cause lock contention with\nother operations on the repository. Defaults to 1 ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-shortlog - Summarize git log output --alternate-refs" }, { "role": "assistant", "content": "Pretend as if all objects mentioned as ref tips of alternate\nrepositories were listed on the command line. An alternate\nrepository is any repository whose object directory is specified\nin objects/info/alternates . The set of included objects may\nbe modified by core.alternateRefsCommand , etc. See git-config ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Setting up Git on EC2 to pull from GitHub repo\nI'm kind of new to both EC2 and Git, and I have just set up my first instance of EC2, using a clean Amazon Linux AMI. I also installed MySQL, Apache and PHP and opened some ports to make it work as a normal web server, responding to an elastic IP as well.\nNow, my code is on a private repo on GitHub, and I would like to perform simple deployments by doing git pull or something like that. Git is also installed on the server already. I know I could set up my git repo on the server using my personal ssh key, but it seems odd. I guess another solution would be to create a new GitHub user and use it on the server, but it doesn't seem right either.\nHow do I achieve this in an elegant, safe way?" }, { "role": "assistant", "content": "To avoid having to keep an SSH private key on your EC2 instance, people often use a workflow that involves pushing to that remote server in order to deploy. Essentially, you set up a bare git repository there with a pre-receive hook that deploys to another directory. There is a simple example of doing this in this tutorial. Then you only need to have your SSH public key in ~/.ssh/authorized_keys on the server. However, with this workflow, you couldn't deploy directly from your GitHub repository - you would need to pull it locally and then push to the EC2 machine.\nAn alternative is to use GitHub's deploy keys mechanism. This would involve creating a new SSH key-pair on your EC2 instance, and adding the public key as a deploy key into your private repository on GitHub. Then you can pull directly from your private GitHub repository to your EC2 instance." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --no-diff-merges" }, { "role": "assistant", "content": "Synonym for --diff-merges=off ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-commit-tree - Create a new commit object" }, { "role": "assistant", "content": "Discussion Git is to some extent character encoding agnostic. The contents of the blob objects are uninterpreted sequences\nof bytes. There is no encoding translation at the core\nlevel. Path names are encoded in UTF-8 normalization form C. This\napplies to tree objects, the index file, ref names, as well as\npath names in command line arguments, environment variables\nand config files ( .git/config (see git-config ), gitignore , gitattributes and gitmodules ). Note that Git at the core level treats path names simply as\nsequences of non-NUL bytes, there are no path name encoding\nconversions (except on Mac and Windows). Therefore, using\nnon-ASCII path names will mostly work even on platforms and file\nsystems that use legacy extended ASCII encodings. However,\nrepositories created on such systems will not work properly on\nUTF-8-based systems (e.g. Linux, Mac, Windows) and vice versa.\nAdditionally, many Git-based tools simply assume path names to\nbe UTF-8 and will fail to display other encodings correctly. Commit log messages are typically encoded in UTF-8, but other\nextended ASCII encodings are also supported. This includes\nISO-8859-x, CP125x and many others, but not UTF-16/32,\nEBCDIC and CJK multi-byte encodings (GBK, Shift-JIS, Big5,\nEUC-x, CP9xx etc.). Although we encourage that the commit log messages are encoded\nin UTF-8, both the core and Git Porcelain are designed not to\nforce UTF-8 on projects. If all participants of a particular\nproject find it more convenient to use legacy encodings, Git\ndoes not forbid it. However, there are a few things to keep in\nmind. git commit and git commit-tree issue\na warning if the commit log message given to it does not look\nlike a valid UTF-8 string, unless you explicitly say your\nproject uses a legacy encoding. The way to say this is to\nhave i18n.commitEncoding in .git/config file, like this: [i18n]\n\tcommitEncoding = ISO-8859-1 Commit objects created with the above setting record the value\nof i18n.commitEncoding in their encoding header. This is to\nhelp other people who look at them later. Lack of this header\nimplies that the commit log message is encoded in UTF-8. git log , git show , git blame and friends look at the encoding header of a commit object, and try to re-code the\nlog message into UTF-8 unless otherwise specified. You can\nspecify the desired output encoding with i18n.logOutputEncoding in .git/config file, like this: [i18n]\n\tlogOutputEncoding = ISO-8859-1 If you do not have this configuration variable, the value of i18n.commitEncoding is used instead. Note that we deliberately chose not to re-code the commit log\nmessage when a commit is made to force UTF-8 at the commit\nobject level, because re-coding to UTF-8 is not necessarily a\nreversible operation." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "I need a workaround for Resharper when it says 'Failed to modify Documents'. Does anybody know why it does this and how to get around it?\nI have noticed a few times over the past months that sometimes I will use the little yellow lightbulb icon and right click it and select an option for it to fix something for me and then it just highlights what it was going to fix and pops up a message that says \"Failed to modify Documents\". \nHas anybody had this problem?\nDo you know how to overcome it?\nIt is almost as if resharper thinks that the document is read-only or something, even though I can manually edit the document." }, { "role": "assistant", "content": "Disable the Visual Studio source control plug-in. \n\nTools -> Options -> Source Control \nChange \"Current source control plug-in\" from \"Microsoft Git Provider\" to \"None\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs -l<num>" }, { "role": "assistant", "content": "The -M and -C options involve some preliminary steps that\ncan detect subsets of renames/copies cheaply, followed by an\nexhaustive fallback portion that compares all remaining\nunpaired destinations to all relevant sources. (For renames,\nonly remaining unpaired sources are relevant; for copies, all\noriginal sources are relevant.) For N sources and\ndestinations, this exhaustive check is O(N^2). This option\nprevents the exhaustive portion of rename/copy detection from\nrunning if the number of source/destination files involved\nexceeds the specified number. Defaults to diff.renameLimit.\nNote that a value of 0 is treated as unlimited." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-clone - Clone a repository into a new directory --bare" }, { "role": "assistant", "content": "Make a bare Git repository. That is, instead of\ncreating <directory> and placing the administrative\nfiles in <directory> `/.git`, make the <directory> itself the $GIT_DIR . This obviously implies the --no-checkout because there is nowhere to check out the working tree.\nAlso the branch heads at the remote are copied directly\nto corresponding local branch heads, without mapping\nthem to refs/remotes/origin/ . When this option is\nused, neither remote-tracking branches nor the related\nconfiguration variables are created." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git rebase interactive: squash merge commits together\nI wanted to have a simple solution to squash two merge commits together during an interactive rebase.\nMy repository looks like:\n X --- Y --------- M1 -------- M2 (my-feature)\n / / /\n / / /\na --- b --- c --- d --- e --- f (stable)\n\nThat is, I have a my-feature branch that has been merged twice recently, with no real commits in between. I don't just want to rebase the my-feature branch since it is a published branch of its own, I just want to squash together the last two merge commits into one (haven't published those commits yet)\n X --- Y ---- M (my-feature)\n / /\n / /\na --- ... -- f (stable)\n\nI tried:\ngit rebase -p -i M1^\n\nBut I got:\nRefusing to squash a merge: M2\n\nWhat I finally did is:\ngit checkout my-feature\ngit reset --soft HEAD^ # remove the last commit (M2) but keep the changes in the index\ngit commit -m toto # redo the commit M2, this time it is not a merge commit\ngit rebase -p -i M1^ # do the rebase and squash the last commit\ngit diff M2 HEAD # test the commits are the same\n\nNow, the new merge commit is not considered a merge commit anymore (it only kept the first parent). So:\ngit reset --soft HEAD^ # get ready to modify the commit\ngit stash # put away the index\ngit merge -s ours --no-commit stable # regenerate merge information (the second parent)\ngit stash apply # get the index back with the real merge in it\ngit commit -a # commit your merge\ngit diff M2 HEAD # test that you have the same commit again\n\nBut this can get complicated if I have many commits, do you have a better solution ?\nThanks.\nMildred" }, { "role": "assistant", "content": "This is an old topic, but I just ran across it while looking for similar information. \nA trick similar to the one described in Subtree octopus merge is a really good solution to this type of problem:\ngit checkout my-feature\ngit reset --soft Y\ngit rev-parse f > .git/MERGE_HEAD\ngit commit\n\nThat will take the index as it exists at the tip of my-feature, and use it to create a new commit off of Y, with 'f' as a second parent. The result is the same as if you'd never performed M1, but gone straight to performing M2." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Automatically track remote branch with git\nWhen I'm using a local branch mybranch, I'd like to be able to push to and pull from origin mybranch using just git push and git pull. As it is, I have to tediously write out git push origin mybranch and git pull origin mybranch. If I try to use just git pull for example, I get:\nThere is no tracking information for the current branch.\nPlease specify which branch you want to merge with.\nSee git-pull(1) for details\n\n git pull <remote> <branch>\n\nIf you wish to set tracking information for this branch you can do so with:\n\n git branch --set-upstream-to=origin/<branch> mybranch\n\nAnd if I enter git branch --set-upstream-to=origin/mybranch mybranch, then it works. But this is almost as tedious as the previous commands. Can I just have git do this as default behavior? I've seen similar questions asked and the answers tend to suggest that newer versions of git do this, but I'm using git version 2.1.3, which is fairly new, so it can't just be that." }, { "role": "assistant", "content": "As of git 2.37.0, this is now possible with git configuration.\nRun to update your configuration:\ngit config --global --add --bool push.autoSetupRemote true\n\nThen git push will automatically setup the remote branch.\nNote: The --global flag means this will apply to all git commands on your machine (regardless of which repo it is), you can omit the flag to make it specific to a single repo on your machine.\nDocumentation:\nhttps://git-scm.com/docs/git-config#Documentation/git-config.txt-pushautoSetupRemote\n\npush.autoSetupRemote\nIf set to \"true\" assume --set-upstream on default push when no upstream tracking exists for the current branch; this option takes effect with push.default options simple, upstream, and current. It is useful if by default you want new branches to be pushed to the default remote (like the behavior of push.default=current) and you also want the upstream tracking to be set. Workflows most likely to benefit from this option are simple central workflows where all branches are expected to have the same name on the remote." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git 1.6.4 beta on Windows (msysgit) - Unix or DOS line termination\nI am installing msysgit 1.6.4 beta on my Windows Vista development VPC. An install screen is requesting whether I want to use Unix line termination or DOS line termination. Ordinarily, I'd choose DOS, but the setup text indicates that DOS termination may mean files do not work with all of Git's command line tools. The Unix line termination states \"...most [Windows] applications can handle this...\".\nDoes anyone know which option I should choose to use Git via the shell for my VS 2008 work?" }, { "role": "assistant", "content": "That settings during the install process of msysgit is actually here to fix the value of the core.autocrlf config.\ncore.autocrlf\n\n\nIf true, makes git convert CRLF at the end of lines in text files to LF when reading from the filesystem, and convert in reverse when writing to the filesystem.\nThe variable can be set to 'input', in which case the conversion happens only while reading from the filesystem but files are written out with LF at the end of lines. \nCurrently, which paths to consider \"text\" (i.e. be subjected to the autocrlf mechanism) is decided purely based on the contents.\n\nI would insist on not trying to convert anything automagically, the side-effects are just too important (in term of potential merging conflict, especially on distributed development with different environments)\nIf your tools can handle Unix-style line termination, you should set them to produce Unix lines, which can then be read by Windows (VS2008, Notepad++, ...) and Unix alike, and can be processed by any 'sh' Git-scripts. \nBut with core.autocrlf set to false, the decision to transform a text line termination will be a voluntary explicit one, not a background invisible side-effect one.\n\nSee more at \"How line ending conversions work with git core.autocrlf between different operating systems\"\n\n | Resulting conversion when | Resulting conversion when \n | committing files with various | checking out FROM repo - \n | EOLs INTO repo and | with mixed files in it and\n | core.autocrlf value: | core.autocrlf value: \n--------------------------------------------------------------------------------\nFile | true | input | false | true | input | false\n--------------------------------------------------------------------------------\nWindows-CRLF | CRLF -> LF | CRLF -> LF | as-is | as-is | as-is | as-is\nUnix -LF | as-is | as-is | as-is | LF -> CRLF | as-is | as-is\nMac -CR | as-is | as-is | as-is | as-is | as-is | as-is\nMixed-CRLF+LF | as-is | as-is | as-is | as-is | as-is | as-is\nMixed-CRLF+LF+CR | as-is | as-is | as-is | as-is | as-is | as-is" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-branch - List, create, or delete branches -i --ignore-case" }, { "role": "assistant", "content": "Sorting and filtering branches are case insensitive." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-commit - Record changes to the repository Git internal format" }, { "role": "assistant", "content": "It is <unix-timestamp> <time-zone-offset> , where <unix-timestamp> is the number of seconds since the UNIX epoch. <time-zone-offset> is a positive or negative offset from UTC.\nFor example CET (which is 1 hour ahead of UTC) is +0100 ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to download .zip from GitHub for a particular commit sha?\nI want to download a .zip with the source of a library hosted on github, but I don't want the master, because every time I download I could be downloading a different version.\nThis particular library does not have tags, so I can't use that.\nSo how do I download the source.zip for a specific commit sha?" }, { "role": "assistant", "content": "You can put the sha that you want in the download url:\nhttps://github.com/{username}/{projectname}/archive/{sha}.zip\nAs a general rule, if you have a url that works, you can replace \"master\" with the specific sha you want.\nOn unix:\nwget https://github.com/{username}/{projectname}/archive/{sha}.zip\nKeep in mind that if this is a private repo then wget will not work unless you pass an OAuth token as well.\nHere's more info on that:\nHaving trouble downloading Git archive tarballs from Private Repo" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order --simplify-by-decoration" }, { "role": "assistant", "content": "Commits that are referred by some branch or tag are selected." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Bitbucket: Update a fork to merge changes of master repo?\nI am working with a bitbucket git repo I have read-only access to, so I created a fork to work on my features. \nQuestion: How do I update my fork to include changes made to the original repo made by the owner? \nOn github, it seems one has to do the following, so I suspect it's a similar to this: \n $ git remote add upstream git://github.com/octocat/Spoon-Knife.git\n $ git fetch upstream\n $ git merge upstream/master\n\nI couldn't find any information on this in the Bitbucket Documentation for forking" }, { "role": "assistant", "content": "Just like GitHub, you have to pull the commits down to your own machine, merge, and then push them back to your fork on Bitbucket.\nIf you go to your fork on Bitbucket you can click \"compare fork\" to get to a page where you see incoming and outgoing commits. If you go to the \"incoming\" tab, you will see instructions like\n$ git remote add <remote_name> [email protected]:<upstream>/<repo>.git\n$ git fetch <remote_name>\n$ git checkout master\n$ git merge <remote_name>/master\n\nwhich correspond closely to the GitHub instructions." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Pull request vs Merge request\nWhat is the difference between a Pull request and a Merge request?\nIn GitHub, it's a Pull Request while in GitLab, for example, it's a Merge Request. So, is there a difference between both of these?" }, { "role": "assistant", "content": "GitLab's \"merge request\" feature is equivalent to GitHub's \"pull request\" feature. Both are means of pulling changes from another branch or fork into your branch and merging the changes with your existing code. They are useful tools for code review and change management.\nAn article from GitLab discusses the differences in naming the feature:\n\nMerge or pull requests are created in a git management application and ask an assigned person to merge two branches. Tools such as GitHub and Bitbucket choose the name pull request since the first manual action would be to pull the feature branch. Tools such as GitLab and Gitorious choose the name merge request since that is the final action that is requested of the assignee. In this article we'll refer to them as merge requests.\n\nA \"merge request\" should not be confused with the git merge command. Neither should a \"pull request\" be confused with the git pull command. Both git commands are used behind the scenes in both pull requests and merge requests, but a merge/pull request refers to a much broader topic than just these two commands." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git revert --no-commit without staging\nUsually the command git revert automatically creates some commits with commit log messages stating which commits were reverted.\nTo avoid automatic commit there's the option -n (or --no-commit).\nBut after this command, the reverted files are in the staged area. I can unstage them by using the command git reset HEAD.\nIs there a direct way to revert a commit without committing and staging?\nIn other words: is there a direct command to revert a commit applying the changes only to the working directory, without touching the index?" }, { "role": "assistant", "content": "There is no single command for it. As you already noted, you can combine git revert -n with git reset to get the reversion undone in the index.\nBesides that method, you can use git apply -R to \"reverse apply\" a patch, and you can turn a commit into a patch with git show, so:\n$ git show <rev> | git apply -R\n\nhas the same effect, with one important (but subtle) difference. Let me quote from the git revert documentation and add my own emphasis:\n\n-n, --no-commit\n Usually the command automatically creates some commits with commit\n log messages stating which commits were reverted. This flag applies\n the changes necessary to revert the named commits to your working\n tree and the index, but does not make the commits. In addition,\n when this option is used, your index does not have to match the\n HEAD commit. The revert is done against the beginning state of your\n index.\n\nIn other words, git revert -n operates in, and on, the index, with a side effect of updating your work tree. The git apply command operates (by default anyway) on the work-tree only, and in fact can be used outside a git repository." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitrevisions - Specifying revisions and ranges for Git <describeOutput> , e.g. v1.7.4.2-679-g3bee7fb" }, { "role": "assistant", "content": "Output from git describe ; i.e. a closest tag, optionally\nfollowed by a dash and a number of commits, followed by a dash, a g , and an abbreviated object name." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs <revision-range>" }, { "role": "assistant", "content": "Show only commits in the specified revision range. When no\n<revision-range> is specified, it defaults to HEAD (i.e. the\nwhole history leading to the current commit). origin..HEAD specifies all the commits reachable from the current commit\n(i.e. HEAD ), but not from origin . For a complete list of\nways to spell <revision-range>, see the Specifying Ranges section of gitrevisions ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "how to create a gitlab bot to automate issues handling\n\nWe're working on a few project hosted on Gitlab and it would be really convenient for us to have a bot to automate some issues handling.\nE.g.: automatically close issues that have been tagged as 'waiting answer from client' more than 20 days ago\nI can't find any guide nor tutorial on how doing this, I don't even know if it could be done entirely in GitHub or do I need to create my bot from an external service." }, { "role": "assistant", "content": "Depending on exactly what you want to do, there are a number of options. I've used all of these approaches for different tasks:\n\nIf you want to write something from scratch, and have full control over every aspect of the bot's workflow, the python-gitlab library is very nice.\nIf you want something that mainly responds to events gidgetlab is great for this.\nIf you want something that automates a merge-request workflow, you might just want to run an instance of marge-bot.\nIf you want something more sophisticated, and you don't want to start from scratch, it might be worth forking some of GitLab's internal bot repos.\n\nThe triage-ops repo automates triage on labels and MRs, using the gitlab-triage gem.\nThe async-retrospectives repo automates the generation of end-of-sprint information, which is then posted as an issue. There's a blog post you can read about it.\n\n\n\nIn your case, if it's mostly a matter of closing stale issues, etc. I would be inclined to fork triage-ops, which already has policies for this already. The policies themselves are written as YAML files, and run as scheduled GitLab pipelines, so it's pretty easy to get started, you just have to specialise the policies to suit your workflow." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git for Windows doesn't execute my .bashrc file\nI've just installed Git for Windows 2.5.0 on Windows 7, and it appears that my .bashrc file is not being executed when I run Git Bash.\nI created the file like so:\nAdministrator@HintTech-Dev MINGW64 /\n$ pwd\n/\n\nAdministrator@HintTech-Dev MINGW64 /\n$ cd ~\n\nAdministrator@HintTech-Dev MINGW64 ~\n$ pwd\n/c/Users/Administrator\n\nAdministrator@HintTech-Dev MINGW64 ~\n$ touch .bashrc\n\nAdministrator@HintTech-Dev MINGW64 ~\n$ vi .bashrc\n\n[... I insert the line \"ZZZTESTVAR=234\" (without the quotes) into the file in vim ...]\n\nAdministrator@HintTech-Dev MINGW64 ~\n$ exit\n\nYet, when I next run Git Bash:\nAdministrator@HintTech-Dev MINGW64 /\n$ set | grep ZZZ\n\nAdministrator@HintTech-Dev MINGW64 /\n$ cat ~/.bashrc\nZZZTESTVAR=234\n\nAdministrator@HintTech-Dev MINGW64 /\n$ ZZZTESTVAR=234\n\nAdministrator@HintTech-Dev MINGW64 /\n$ set | grep ZZZ\nZZZTESTVAR=234\n\nAdministrator@HintTech-Dev MINGW64 /\n$\n\nWhy isn't my .bashrc being run? It seems to be in the right place and have the right permissions." }, { "role": "assistant", "content": "OK, I found out the problem. Quite simply, the bash terminal used by the latest Git for Windows 2.5.0 (mintty) doesn't bother to read .bashrc - it reads .bash_profile. So you can set up your environment in .bash_profile and/or put this code at the start to read .bashrc:\nif [ -f ~/.bashrc ]\nthen\n . ~/.bashrc\nfi" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I clean up my Github fork so I can make clean pull requests?\nI forked a repository on Github. I've made some minor changes and submitted pull requests to the upstream, but along the way my fork has become so mangled I'm unable to generate clean pull requests; when I start a pull request from a branch with six changes, Github wants to submit thirteen, with seven of them already existing upstream (natch). \nMy problem seems to be related to only pulling the latest commits, but when I create a new branch and cherry-pick commits I still have extras. I've futzed with rebasing as well, but now it looks like even my master is so messed up I can't generate a clean copy of upstream. This is apparently because I didn't understand that I needed to rebase instead of merging, so clearly I've made mistakes; what I'm trying to do is figure out how to unsnarl that knot and get back to a clean state where I can move forward usefully.\nI kind of want to blow away my fork and make a new fork of the upstream, but I gather that, too, is difficult. \nHaving confessed my Git sins, how do I obtain github absolution?" }, { "role": "assistant", "content": "Step 1: Pull upstream changes\nIt's recommended to add the upstream repo as \"upstream\" as explained on the Fork a Repo page:\ngit pull --rebase upstream master\n\nThe --rebase option places your changes on top of the latest commit without merges.\nStep 2: (Optional) Merge your commits into 1 commit\ngit reset --soft upstream/master\n\nThis command will \"undo\" all your commits, but won't change the files. So you can commit all your changes in a single commit.\ngit commit -a\n\nStep 3: Check & test your changes\nTo show the changes use a GUI like the built-in gitk, Sourcetree, TortoiseGit or Tower (paid), etc.\nStep 4: Push\ngit push will throw an error, because the push would change the target repository's history.\nIf you're confident the changes shown in step 3 are correct then push with \"-f\"\ngit push -f origin master\n\n\nAdditional information\nThe command to add a remote is:\ngit remote add upstream git://github.com/[username]/[project].git\n\nYou can also also pull from a direct URL:\ngit pull --rebase git://github.com/[username]/[project].git\n\nBut then you'll need the hash of the latest upstream commit instead of \"upstream/master\" in the other steps." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "View entire activities of an user in github [closed]\n\nClosed. This question is off-topic. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it's on-topic for Stack Overflow.\n\n\nClosed 12 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nHow can I view the entire activities of an user in github.com .\nSay Mr.Geos entire activites\n\nMr.Geo pushed to ..\nMr.Geo deleted ...\n..." }, { "role": "assistant", "content": "You can leverage the GitHub Events API to perform such task and retrieve a JSON formatted response.\n\nThe Events API is a read-only interface to all the event types that\n power the various activity streams on GitHub.\n\n\nsyntax: GET /users/:user/events \nexample: https://api.github.com/users/mojombo/events\n\nAn alternative way is to subscribe to the public RSS feed of a user. \nFor instance, Mojombo's public feed Url would be\n\nhttps://github.com/mojombo.atom\n\nAlso If you want to view Full activities performed by all contributors ,you can also go to \nIf Private\nhttps://github.com/orgs/YOURORGANISATION/dashboard\nIf Public\nhttps://github.com/REPOSITORYOWNER?tab=activity" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitLab CI script needs entry in /etc/hosts\n\nI have a GitLab CI docker runner to execute my automated tests when I push. One of my tests requires a custom entry in /etc/hosts. I can't figure out how to get the entry into that file.\nHere's basically what my .gitlab-ci.yml file looks like:\nbefore_script:\n - cat /etc/hosts # for debugging\n - ... # install app dependencies\nspecs:\n script:\n - rspec # <- a test in here fails without the /etc/hosts entry \n\nAll my tests pass, except for the one that requires that /etc/hosts entry.\nLet's say I'm trying to have the hostname myhost.local resolve to the IPv4 address XX.XX.XX.XX...\nI tried using extra_hosts on the runner config, but it didn't seem to have any effect (got idea from here):\n/etc/gitlab-runner/config.toml:\nconcurrent = 1\ncheck_interval = 0\n\n[[runners]]\n name = \"shell\"\n url = \"https://mygitlabinstance.com/\"\n token = \"THETOKEN\"\n executor = \"shell\"\n [runners.cache]\n\n[[runners]]\n name = \"docker-ruby-2.5\"\n url = \"https://mygitlabinstance.com/\"\n token = \"THETOKEN\"\n executor = \"docker\"\n [runners.docker]\n tls_verify = false\n image = \"ruby:2.5\"\n privileged = false\n disable_cache = false\n volumes = [\"/cache\"]\n shm_size = 0\n extra_hosts = [\"myhost.local:XX.XX.XX.XX\"]\n [runners.cache]\n\nBut the test still failed. The cat /etc/hosts shows that it's unchanged:\n# Your system has configured 'manage_etc_hosts' as True.\n# As a result, if you wish for changes to this file to persist\n# then you will need to either\n# a.) make changes to the master file in /etc/cloud/templates/hosts.tmpl\n# b.) change or remove the value of 'manage_etc_hosts' in\n# /etc/cloud/cloud.cfg or cloud-config from user-data\n#\n127.0.1.1 ip-172-31-2-54.ec2.internal ip-172-31-2-54\n127.0.0.1 localhost\n\n# The following lines are desirable for IPv6 capable hosts\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes\nff02::2 ip6-allrouters\nff02::3 ip6-allhosts\n\nI figured I could just add the entry myself in a before_script line, but I don't seem to be able to execute anything with root privileges in the container:\nbefore_script:\n - echo 'XX.XX.XX.XX myhost.local' >> /etc/hosts\n ...\n\nBut that just fails because the gitlab-runner user doesn't have permissions to write to that file. I tried to use sudo, but gitlab-runner can't do that either (echo 'XX.XX.XX.XX myhost.local' | sudo tee --non-interactive --append /etc/hosts --> sudo: a password is required)\nSo in summary, how can I get my container to have the host entry I need (or how can I execute a before_script command as root)?" }, { "role": "assistant", "content": "The following statement is incorrect:\n\n\"But that just fails because the gitlab-runner user doesn't have permissions to write to that file.\"\n\nThe gitlab-runner is not the user executing your before_script, it is the user that runs the container in which your job is executed.\nYou are using the ruby:2.5 Docker image as far as I can tell and that does not contain any USER reference in its or its parents Dockerfile.\nTry adding a whoami command right before your echo 'XX.XX.XX.XX myhost.local' >> /etc/hosts command to verify you are root.\nUpdate\nIf gitlab-runner is shown as the result of whoamithe docker-executor is not used and instead a shell-executor has picked up the job." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to remove a forked project in Gitlab\n\nI forked a project to a group. But there is no option to delete that forked project. I saw danger zone in Github. Is there any option available to delete forked project from Gitlab?" }, { "role": "assistant", "content": "login with master role in the repository.\ngo to forked project. then from left panel, go to Settings => General.\nlike this:\n\nclick the Expand from Advance settings panel.\n\ngo to bottom page and click Remove project.\n\nthen type your projectName and click Confirm.\n\nI hope is useful." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-stash - Stash the changes in a dirty working directory away" }, { "role": "assistant", "content": "NAME git-stash - Stash the changes in a dirty working directory away" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "I am unable to add hyperlinks to a mermaid flowchart within the wiki functionality of gitlab\n\nI want to use my flowchart as a table of contents that also represents the progression of parallel events vaguely in chronological order and their relation to one another.\nI know to create these charts using markdown. By adding the \"click\" line for the \"B\" node i can see my cursor change when hovering over the node as if it were a link but any attempt to select it doesn't work.\ngraph LR;\n A-->B;\n click B \"http://www.github.com\"\n\nIs this a limitation of Gitlab itself?" }, { "role": "assistant", "content": "Update:\nThis is now supported since GitLab 12.1.\nThe given example works in GitLab Wiki pages.\ngraph LR;\n A-->B;\n click B \"http://www.github.com\"\n\nThanks, KargWare for pointing this out in the comments.\n\nYes, this is a limitation of GitLab. There is an open issue requesting the feature:\nhttps://gitlab.com/gitlab-org/gitlab-ce/issues/50459\nHopefully, it will be implemented eventually." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Difference between git pull and git pull --rebase\nI started using git sometime back and do not fully understand the intricacies. My basic question here is to find out the difference between a git pull and git pull --rebase , since adding the --rebase option does not seem to do something very different : just does a pull.\nPlease help me with understanding the difference." }, { "role": "assistant", "content": "git pull = git fetch + git merge against tracking upstream branch\ngit pull --rebase = git fetch + git rebase against tracking upstream branch\nIf you want to know how git merge and git rebase differ, read this." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to move a branch backwards in git?\nThe title is not very clear. What I actually need to do often is the following:\nLet's say I have a development going on with several commits c1,c2,... and 3 branches A,B,C\nc1--c2--c3--(B)--c4--(A,C)\n\nBranch A and C are at the same commit.\nNow I want branch A to go back where B is, so that it looks like this:\nc1--c2--c3--(A,B)--c4--(C)\n\nImportant is that this has to happen locally and on GitHub." }, { "role": "assistant", "content": "Use the reset subcommand:\ngit checkout A\ngit reset --hard B\ngit push --force github\n\nAs a sidenote, you should be careful when using git reset while a branch has been pushed elsewhere already. This may cause trouble to those who have already checked out your changes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab CI/CD Pass artifacts/variables between pipelines\n\ntl;dr\nHow do I pass data, e.g. the $BUILD_VERSION variable, between jobs in different pipelines in Gitlab CI?\nSo (in my case) this:\nPipeline 1 on push ect. Pipeline 2 after merge\n\n `building` job ... `deploying` job\n │ ▲\n └─────── $BUILD_VERSION ─────────┘\n\n\nBackground\nConsider the following example (full yml below):\nbuilding:\n stage: staging\n # only on merge requests\n rules:\n # execute when a merge request is open\n - if: $CI_PIPELINE_SOURCE == \"merge_request_event\"\n when: always\n - when: never\n script:\n - echo \"BUILD_VERSION=1.2.3\" > build.env\n artifacts:\n reports:\n dotenv: build.env\n\ndeploying:\n stage: deploy\n # after merge request is merged\n rules:\n # execute when a branch was merged to staging\n - if: $CI_COMMIT_BRANCH == $STAGING_BRANCH\n when: always\n - when: never\n dependencies: \n - building\n script:\n - echo $BUILD_VERSION\n\nI have two stages, staging and deploy. The building job in staging builds the app and creates a \"Review App\" (no separate build stage for simplicity). The deploying job in deploy then uploads the new app.\nThe pipeline containing the building job runs whenever a merge request is opened. This way the app is built and the developer can click on the \"Review App\" icon in the merge request. The deploying job is run right after the merge request is merged. The idea is the following:\n *staging* stage (pipeline 1) *deploy* stage (pipeline 2)\n\n<open merge request> -> `building` job (and show) ... <merge> -> `deploying` job\n │ ▲\n └───────────── $BUILD_VERSION ───────────────┘\n\nThe problem for me is, that the staging/building creates some data, e.g. a $BUILD_VERSION. I want to have this $BUILD_VERSION in the deploy/deploying, e.g. for creating a new release via the Gitlab API.\nSo my question is: How do I pass the $BUILD_VERSION (and other data) from staging/building to deploy/deploying?\n\nWhat I've tried so far\nartifacts.reports.dotenv\nThe described case is more less handled in the gitlab docs in Pass an environment variable to another job. Also the yml file shown below is heavily inspired by this example. Still, it does not work.\nThe build.env artifact is created in building, but whenever the deploying job is executed, the build.env file gets removed as shown below in line 15: \"Removing build.env\". I tried to add build.env to the .gitignore but it still gets removed.\n\nAfter hours of searching I found in this gitlab issue comment and this stackoverflow post that the artifacts.reports.dotenv doesn't work with the dependencies or the needs keywords.\nRemoving dependencies doesn't work. Using needs only doesn't work either. Using both is not allowed.\nDoes anyone know a way how to get this to work? I feel like this is the way it should work.\nGetting the artifacts as a file\nThis answer of the stackoverflow post Gitlab ci cd removes artifact for merge requests suggests to use the build.env as a normal file. I also tried this. The (relevant) yml is the following:\nbuilding:\n # ...\n artifacts:\n paths:\n - build.env\n\ndeploying:\n # ...\n before_script:\n - source build.env\n\nThe result is the same as above. The build.env gets removed. Then the source build.env command fails because build.env does not exist. (Doesn't matter if build.env is in the .gitignore or not, tested both)\nGetting the artifacts from the API\nI also found the answer of the stackoverflow post Use artifacts from merge request job in GitLab CI which suggests to use the API together with $CI_JOB_TOKEN. But since I need the artifacts in a non-merge-request pipeline, I cannot use the suggested CI_MERGE_REQUEST_REF_PATH.\nI tried to use $CI_COMMIT_REF_NAME. The (important section of the) yml is then:\ndeploying:\n # ...\n script:\n - url=$CI_API_V4_URL/projects/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=building\n - echo \"Downloading $url\"\n - 'curl --header \"JOB-TOKEN: ${CI_JOB_TOKEN}\" --output $url'\n # ...\n\nBut this the API request gets rejected with \"404 Not Found\". Since commit SHAs are not supported, $CI_COMMIT_BEFORE_SHA or $CI_COMMIT_SHA do not work either.\nUsing needs\nUpdate: I found the section Artifact downloads between pipelines in the same project in the gitlab docs which is exactly what I want. But: I can't get it to work.\nThe yml looks like the following after more less copying from the docs:\nbuilding:\n # ...\n artifacts:\n paths:\n - version\n expire_in: never\n\ndeploying:\n # ...\n needs:\n - project: $CI_PROJECT_PATH\n job: building\n ref: staging # building runs on staging branch, main doesn't work either\n artifacts: true\n\nNow the deploying job instantly fails and I get the following error banner:\n\nI tried to set artifacts.expire_in = never (as shown) but I still get the same error. Also in Settings > CI/CD > Artifacts \"Keep artifacts from most recent successful jobs\" is selected. So the artifact should be present. What did I miss here? This should work according to the docs!\n\nI hope somebody can help me on getting the $BUILD_VERSION to the deploying job. If there are other ways than the ones I've tried, I'm very happy to hear them. Thanks in advance.\n\nThe example .gitlab-ci.yml:\nstages:\n - staging\n - deploy\n\nbuilding:\n tags: \n - docker\n image: bash\n stage: staging\n rules:\n - if: ($CI_PIPELINE_SOURCE == \"merge_request_event\") && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == \"staging\"\n when: always\n - when: never\n script:\n - echo \"BUILD_VERSION=1.2.3\" > build.env\n artifacts:\n reports:\n dotenv: build.env\n environment:\n name: Example\n url: https://example.com\n\ndeploying:\n tags: \n - docker\n image: bash\n stage: deploy\n rules:\n - if: $CI_COMMIT_BRANCH == \"staging\"\n when: always\n - when: never\n dependencies:\n - building\n script:\n echo $BUILD_VERSION" }, { "role": "assistant", "content": "Going by the Gitlab docs, it should be possible to download any job's artifact by URL, if it hasn't expired yet.\nIn addition, you can use the Gitlab API to download (unexpired) artifacts from other projects, too; and you can use the Gitlab API to mark a job's artifacts for keeping-regardless-of-expiry-policy, or to delete an artifact.\nBut I have not tried this myself.\nFor your case, assuming the 'building' and 'deploying' jobs both run on the main branch, you can hopefully pass the artifact like so.\nIf you have some other way of finding out in the deploying job what branch name X the building job ran on, then you can download the artefact from branch X instead of always from main like I do below.\n# Assuming\n# domain: example.com\n# namespace: mygroup\n# project: myproject\n\nbuilding:\n # on latest commit on `main`, because we need a predictable\n # branch name to save/retrieve the artifact.\n stage: staging\n script:\n - echo \"BUILD_VERSION=1.2.3\" > build.env\n artifacts:\n # 'paths', not 'reports'\n paths:\n - build.env\n\ndeploying:\n # after merge request is merged\n stage: deploy\n dependencies: \n - building\n script:\n # could use ${CI_PROJECT_URL} to get https://example.com/mygroup/myproj\n - curl https://${CI_SERVER_HOST}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/jobs/artifacts/main/raw/build.env?job=building > build.env\n - source build.env\n - echo $BUILD_VERSION # should print '1.2.3'.\n\n\nThe relevant parts of the docs, with links and excerpts:\nAccess a branch or tag's latest job artifacts by URL\nTo browse or download the latest artifacts of a branch, use one of these two urls. [I think the /file/ variant is used for Gitlab Pages artifacts, but I'm not sure. --Esteis]\n\nBrowse artifacts:\nhttps://example.com/<namespace>/<project>/-/jobs/artifacts/<ref>/browse?job=<job_name>\nDownload zip of all artifacts:\nhttps://example.com/<namespace>/<project>/-/jobs/artifacts/<ref>/download?job=<job_name>\nDownload one artifact file:\nhttps://example.com/<namespace>/<project>/-/jobs/artifacts/<ref>/raw/<path/to/file>?job=<job_name>\nDownload one artifact file (Gitlab Pages-related?):\nhttps://example.com/<namespace>/<project>/-/jobs/artifacts/<ref>/file/<path>?job=<job_name>\n\nFor example, to download an artifact with domain gitlab.com, namespace gitlab-org, project gitlab, latest commit on main branch, job coverage, file path review/index.html:\nhttps://gitlab.com/gitlab-org/gitlab/-/jobs/artifacts/main/raw/review/index.html?job=coverage\nConfig setting: Keep artifacts from each branch's most recent succesful jobs\n\nThis option is on by default\nAFAICT it keeps the most recent artifact for\n\nevery active branch or tag (a.k.a. a 'ref');\nif multiple pipelines are run on that ref, last pipeline's artifacts overwrite those produced by earlier pipelines.\n\n\nAll other artifacts are still governed by the expire_in setting in the .gitlab-ci.yml that produced them.\n\nGitlab API for job artifacts\nAdvantage of using the Gitlab API is that if you can get the right tokens, you can also download artifacts from other projects. You'll need the numeric project ID -- that's $CI_PROJECT_ID, if your script is running in Gitlab CI.\nTo download an artifact archive:\n\ncurl --header \"PRIVATE-TOKEN: <your_access_token>\" \"https://gitlab.example.com/api/v4/projects/${CI_PROJECT_ID}/jobs/artifacts/main/download?job=test\"\n\nTo download a single artifact file:\n\ncurl --location --header \"PRIVATE-TOKEN: <your_access_token>\" \"https://gitlab.example.com/api/v4/projects/${CI_PROJECT_ID}/jobs/artifacts/main/raw/some/release/file.pdf?job=pdf\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What are some good ways to manage a changelog using Git? [closed]\nClosed. This question needs to be more focused. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it focuses on one problem only by editing this post.\n\n\nClosed 3 years ago.\n\n\nThe community reviewed whether to reopen this question 3 months ago and left it closed:\n\nOriginal close reason(s) were not resolved\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI've been using Git for a while now, and I recently started using it to tag my releases so that I could more easily keep track of changes and be able to see which version each of our clients is running (unfortunately the code currently mandates that each client have their own copy of the PHP site; I'm changing this, but it's slow-going).\nIn any case, we're starting to build some momentum, and I thought it would be really good to be able to show people what has changed since the last release. The problem is, I haven't been maintaining a changelog, because I don't have a good idea of how to go about it. For this particular time, I can run through the log and manually create one, but that will get tiring very quickly.\nI tried googling \"git changelog\" and \"git manage changelog\", but I didn't find anything that really talked about the workflow of code changes and how that coincides with the changelog. We're currently following Rein Henrichs' development workflow and I would love something that went along with that.\nIs there a standard approach that I am missing, or is this an area where everybody does their own thing?" }, { "role": "assistant", "content": "This was in 2015, but for the sake of future searchers, it's now possible to generate gorgeous logs with:\ngit log --oneline --decorate\n\nOr, if you want it even prettier (with color for the terminal):\ngit log --oneline --decorate --color\n\nPiping that output to ChangeLog is what I currently use in all my projects, and it's simply amazing." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-apply - Apply a patch to files and/or to the index --summary" }, { "role": "assistant", "content": "Instead of applying the patch, output a condensed\nsummary of information obtained from git diff extended\nheaders, such as creations, renames, and mode changes.\nTurns off \"apply\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How does \"git push heroku master\" know where to push to and how to push to a different repo?\nWhen pushing to a repository hosted on Heroku one must execute the following command: \ngit push heroku master\n\nWhat do heroku and master indicate in this command? How does git know where to push to? (the git path)\nAlso, I didn't know I can use heroku rename to rename an app, so before, say I was using the app name trytryheroku and now I use heroku create real-thing but if I push, it still pushes to trytryheroku... is there a way to push to real-thing instead?" }, { "role": "assistant", "content": "The 'heroku' part is the name of the remote that you have setup - when you create a heroku app the first time it creates a git remote call 'heroku' pointing at your application - if you type 'git remote' within your project it will show you the remote endpoints. There's nothing locking you into using 'heroku' as the name of the remote - if you have multiple environments for your application you may have remotes named production or staging for example.\nThe 'master' part is the local branch you wish to push to the remote. If you develop in a feature branch for example named 'myfeature' and you want to deploy that to heroku you would do;\ngit push heroku myfeature:master\n\nthe additional :master here is saying push my local myfeature branch into the master branch on the remote - note: heroku can only deploy from the master branch.\nIf you rename an app the heroku git remote url will change - do a git remote -v which will show you the git repo your app is using, you will probably need to delete your old heroku origin and add the new one, git remote rm heroku then git remote add heroku git@newgitpathfromcontrolpanel\nTo learn more about Git I would recommend this book" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-mergetool - Run merge conflict resolution tools to resolve merge conflicts -t <tool> --tool=<tool>" }, { "role": "assistant", "content": "Use the merge resolution program specified by <tool>.\nValid values include emerge, gvimdiff, kdiff3,\nmeld, vimdiff, and tortoisemerge. Run git mergetool --tool-help for the list of valid <tool> settings. If a merge resolution program is not specified, git mergetool will use the configuration variable merge.tool . If the\nconfiguration variable merge.tool is not set, git mergetool will pick a suitable default. You can explicitly provide a full path to the tool by setting the\nconfiguration variable mergetool.<tool>.path . For example, you\ncan configure the absolute path to kdiff3 by setting mergetool.kdiff3.path . Otherwise, git mergetool assumes the\ntool is available in PATH. Instead of running one of the known merge tool programs, git mergetool can be customized to run an alternative program\nby specifying the command line to invoke in a configuration\nvariable mergetool.<tool>.cmd . When git mergetool is invoked with this tool (either through the -t or --tool option or the merge.tool configuration\nvariable), the configured command line will be invoked with $BASE set to the name of a temporary file containing the common base for\nthe merge, if available; $LOCAL set to the name of a temporary\nfile containing the contents of the file on the current branch; $REMOTE set to the name of a temporary file containing the\ncontents of the file to be merged, and $MERGED set to the name\nof the file to which the merge tool should write the result of the\nmerge resolution. If the custom merge tool correctly indicates the success of a\nmerge resolution with its exit code, then the configuration\nvariable mergetool.<tool>.trustExitCode can be set to true .\nOtherwise, git mergetool will prompt the user to indicate the\nsuccess of the resolution after the custom tool has exited." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "'ssh-keygen' is not recognized as an internal or external command\nI run git push -u origin master\nIt tells me that \"Permission denied (public key) fatal: The remote end hung up unexpectedly\"\nThen I looked up on the internet and found that I had to generate an ssh key for my account on GitHub. However, upon doing so, when I tried to do ssh-keygen -t rsa \"[email protected]\" it simply said ssh-keygen is not recognized. I tried doing mkdir C:\\ssh but that didn't work. If it helps I'm using Ruby Rails and I'm on a Windows computer. Could anyone help me?" }, { "role": "assistant", "content": "2012:\nssh-keygen.exe is part of msysgit:\n C:\\path\\to\\msysgit1.7.11\\bin\\ssh-keygen.exe\n\nif your %PATH% includes C:\\path\\to\\msysgit1.7.11\\bin\\, you will have ssh-keygen. \n\nUpdate 2015:\nssh-keygen.exe is part of Git For Windows, whose releases include PortableGit-2.4.3.1-2nd-release-candidate-64-bit.7z\nc:\\path\\to\\PortableGit-2.4.3.1-2nd-release-candidate-64-bit\\usr\\bin\\ssh-keygen.exe\n\nThat means the %PATH% must include c:\\path\\to\\PortableGit-2.4.3.1-2nd-release-candidate-64-bit\\usr\\bin (without the ssh-keygen.exe)\nAs I explained before, Git for Windows will soon phase out msysgit.\nI detailed in \"Why is it that if you download Git 2.0 from the net, you always get a 1.9.4 installer package?\" how this new version is based on the more recent msys2 project." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker gitrevisions" }, { "role": "assistant", "content": "Specifying revisions and ranges for Git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository --negotiation-tip=<commit|glob>" }, { "role": "assistant", "content": "By default, Git will report, to the server, commits reachable\nfrom all local refs to find common commits in an attempt to\nreduce the size of the to-be-received packfile. If specified,\nGit will only report commits reachable from the given tips.\nThis is useful to speed up fetches when the user knows which\nlocal ref is likely to have commits in common with the\nupstream ref being fetched. This option may be specified more than once; if so, Git will report\ncommits reachable from any of the given commits. The argument to this option may be a glob on ref names, a ref, or the (possibly\nabbreviated) SHA-1 of a commit. Specifying a glob is equivalent to specifying\nthis option multiple times, one for each matching ref name. See also the fetch.negotiationAlgorithm and push.negotiate configuration variables documented in git-config , and the --negotiate-only option below." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-commit-tree" }, { "role": "assistant", "content": "Create a new commit object" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git mv fails with Fatal: source directory is empty\nI would like to maintain history of files within a sub-folder of a repo. But I need to rename the top level folder name. When I run 'git mv dirName newDirName\nI get 'Fatal: source directory is empty;' \nMy source directory has the following structure:\ngitRepoDir\n--.git\n--Source \n-- -DirLevel2 \n-- --DirLevel3 \n-- --DirLevel4 \n-- --DirLevel5 \n+++ --DirNameToRename \n+++ --sub1dir \n+++ --File \n+++ --sub2dir \n+++ --File \n+++ --sub3dir \n+++ --File \n+++ --File \n+++ --sub4dir \n+++ --File\n\nIs there a way to rename the top level folder and maintain history of the files in the below subfolders? Or do I need to create the directory structure first then move the files with the git mv command?" }, { "role": "assistant", "content": "I think it, 'Fatal: source directory is empty;', means dirName is not under git control because it's not part of source.\nFor example, you can try \"git status\", to figure out whatever can be controlled by git." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-ls-tree - List the contents of a tree object --name-only --name-status" }, { "role": "assistant", "content": "List only filenames (instead of the \"long\" output), one per line.\nCannot be combined with --object-only ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Attempting push on git and receiving \"could not read Username for 'https://github.com': terminal prompts disabled\"\n\nI'm using Visual Studio, and the GitHub Extension. I am able to sign in, then clone my team's repository, and then pull changes successfully.\nWhen it comes time to push my changes back to remote, I get a blank command prompt appear on the screen briefly, and then the following errors in the output window:\n\nError encountered while pushing to the remote repository: Git failed with a fatal error. \nfatal: AggregateException encountered. One or more errors occurred. \nerror: cannot spawn askpass: No such file or directory \nfatal: could not read Username for 'https://github.com': terminal prompts disabled\n\nEDIT: pushing via the command line works, as does pushing via the GitHub desktop application, just not within this extension.\nAny ideas why this might be happening? I can't see why it needs the Username given that I have signed into the extension." }, { "role": "assistant", "content": "As per my comment. You can include your username in the remote URL (similar to FTP).\nExample without password (SSH):\ngit remote set-url origin [email protected]/username/repo.git\nExample with password (https)\nhttps://name:[email protected]/username/repo.git\nSource: Git push requires username and password\nUpdated 5/14/2018 to correct github.org to github.com in the original answer" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Hub Desktop on Mac, error: cannot run gpg: No such file or directory\n\nTrying to commit my changes by using GitHub Desktop and getting this:\n\n\nerror: cannot run gpg: No such file or directory\nerror: could not run gpg.\nfatal: failed to write commit object\n(128)\n\nFirstly that not worked for terminal too and i create gpg-key and plugged in to my GitHub Account\nNow it's working well in Terminal but Desktop version still not working.\n\nIn Oficial doccumentation for GitHub Desktop i found some notation:\nNote: GitHub Desktop does not support GPG signing." }, { "role": "assistant", "content": "Solved it.\nSo as GitHub Desktop was complaining about not being able to find gpg (I had installed it via homebrew), I figured there should be a way to tell git the exact path of gpg, turns out there is:\n\ngpg.program\nUse this custom program instead of \"gpg\" found on $PATH when making or verifying a PGP signature. The program must support the same command-line interface as GPG, namely, to verify a detached signature, \"gpg --verify $file - <$signature\" is run, and the program is expected to signal a good signature by exiting with code 0, and to generate an ASCII-armored detached signature, the standard input of \"gpg -bsau $key\" is fed with the contents to be signed, and the program is expected to send the result to its standard output.\nhttps://git-scm.com/docs/git-config\n\nSo running the following solved the problem:\ngit config --global gpg.program \"$(which gpg)\"\n\nGitHub got back to me and said that some users also need to use:\necho \"no-tty\" >> ~/.gnupg/gpg.conf" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-tag - Create, list, delete or verify a tag object signed with GPG --points-at <object>" }, { "role": "assistant", "content": "Only list tags of the given object (HEAD if not\nspecified). Implies --list ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GIT Fatal : refusing to merge unrelated histories\n$ git pull origin master\nFrom https://bitbucket.org/tecgenome/chl-v2.0-html\n * branch master -> FETCH_HEAD\nfatal: refusing to merge unrelated histories\n\nHow can I avoid or get past that error message?" }, { "role": "assistant", "content": "Since Git 2.9 (April 2016), you can try:\ngit pull --allow-unrelated-histories origin master\n\nBut check why those branches are no longer common though.\nMaybe there was a force push rewriting all the history of origin/master.\nIn which case, if you don't have local commits of your own, it is best to reset your branch to the new one:\nWarning: this will delete any untracked file, and reset your repository to origin/master\n(You can try it in a copy of your current local clone)\ngit fetch\n\n# Warning: RESET AHEAD\ngit reset --hard origin/master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "configure git so that \"git pull\" instead of \"git pull origin master\"?\nUsing git pull used to pull from the remote repository as expected - now, it's asking me to use git pull origin master. I don't quite understand the instructions it's giving me, saying I can add something to my configuration file:\n[branch \"master\"]\nremote = <nickname>\nmerge = <remote-ref>\n\n[remote \"<nickname>\"]\nurl = <url>\nfetch = <refspec>\n\nRight now my configuration file looks like\n[core]\n repositoryformatversion = 0\n filemode = true\n bare = false\n logallrefupdates = true\n ignorecase = true\n[remote \"origin\"]\n url = |redacted|\n fetch = +refs/heads/*:refs/remotes/origin/*\n\nSo I'm guessing I need to add\n[branch \"master\"]\n remote = origin\n merge = ??\n\nWhat does \"merge\" need as its argument? What's a remote-ref(erence?)? I tried looking at http://git-scm.com/docs/git-config but it seems to be more about the command itself.\nThanks in advance!" }, { "role": "assistant", "content": "try:\n[branch \"master\"]\n remote = origin\n merge = refs/heads/master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I generate a diff for a single file between two branches in github\n\nI need to generate a diff for a single file that will show the differences between two versions, which are actually tags in github. I then want to send this diff to someone via email so a github URL for the diff would be ideal. The github compare view will allow me to do this for all changed files, but that's no good as there are thousands of files in my repo.\nI can do this in the command line as follows, but this doesn't help as I need to send the diff to someone via email:\ngit diff tag1 tag2 -- path/to/file\n\nI found the command line version discussed here:\nhow can I see the differences in a designated file between a local branch and a remote branch?" }, { "role": "assistant", "content": "GitHub only exposes the way to show diff between two commits.\nProvided those tags actually point to commits, the Url format would be something like\nhttps://github.com/{user}/{repository}/compare/{from-tag}...{until-tag}\nAs an example, https://github.com/libgit2/libgit2sharp/compare/v0.9.0...v0.9.5 shows the diff between two versions of the LibGit2Sharp project. This diff includes all the modified files.\nIf you want to retrieve a URL that targets a specific file:\n\nSwitch to the Files Changed tab\n\n\n\nClick on the Show Diff Stats button (This will display the list of modified files as links)\n\n\n\nCopy to the clipboard the link of the specific file you're after... and Tada! You're done.\n\nFor instance, given the diff above, the link https://github.com/libgit2/libgit2sharp/compare/v0.9.0...v0.9.5#diff-11 will point to the LazyFixtures.cs changes that occured between version v0.9.0 and v0.9.5.\nUpdate\nFollowing your comment which states that your diff is too big to be rendered through the Web interface, how about reverting to good old command line tooling? You could redirect the output of the diff to a file and then send the file as an email attachment.\n$ git diff v0.9.0 v0.9.5 -- LibGit2Sharp.Tests/LazyFixture.cs > /tmp/lazyfixture.diff" } ]