messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to completely remove an issue from GitHub?\n\nIs it possible to completely remove an issue from the GitHub issue tracker?" }, { "role": "assistant", "content": "No, the github API only allows you to open/close/reopen issues. Here's the Issues API docs." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to remove merge request from GitLab server\n\nI created a merge request on gitlab (local) server. Now whenever I click on the merge request, the request times out with error 500. Before that I used to get an error code 504 and I applied the change mentioned in this gitlab support topic.\nAll I want to do is remove the merge request. Is there a manual way of doing this?" }, { "role": "assistant", "content": "Web UI Option\nToday I discovered a way to do this with the Web UI.\nSo for Merge Request 14\nhttps://gitlab.example.com/MyGroup/MyProject/merge_requests/14/edit\nOn the bottom Right you should see a red Delete button.\n\nPowerShell Option\nInvoke-RestMethod -Method Delete -Uri 'https://gitlab.example.com/api/v4/projects/PROJECT_ID_GOES_HERE/merge_requests/14' -Headers @{'PRIVATE-TOKEN'='PRIVATE_TOKEN_GOES_HERE'}" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git error: RPC failed; result=22, HTTP code = 404\nI'm using SourceTree on OSX and using Git to push to Visual Studio Online. I get the following error:\n\nPOST git-receive-pack (490857233 bytes)\n error: RPC failed; result=22, HTTP code = 404\n fatal: The remote end hung up unexpectedly\n Everything up-to-date\n Completed with errors, see above\n\nI have already tried the following:\ngit config --global http.postBuffer 524288000" }, { "role": "assistant", "content": "I just ran into a very similar error (for which this answer is the top google result) - the solution was in a comment by @Liviu Chircu\nThe solution was to put the .git on the end of the url\ngit clone http://myURL/projectname\nCloning into 'projectname'...\nerror: RPC failed; result=22, HTTP code = 404\nfatal: The remote end hung up unexpectedly\n\nHowever:\ngit clone http://myURL/projectname.git\n\nsucceeded.\nThe strange thing is that the original URL without .git succeeded on two linux machines and a windows desktop, but failed on a third linux machine. Including .git makes it work on all machines." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --ext-diff" }, { "role": "assistant", "content": "Allow an external diff helper to be executed. If you set an\nexternal diff driver with gitattributes , you need\nto use this option with git-log and friends." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Github push event signature don't match\n\nI'm coding a Webhook for GitHub, and implemented secure verification in KOA.js as:\nfunction sign(tok, blob) {\n var hmac;\n\n hmac = crypto\n .createHmac('sha1', tok)\n .update(blob)\n .digest('hex');\n\n return 'sha1=' + hmac;\n}\n\n...\n\nkey = this.request.headers['x-hub-signature'];\nblob = JSON.stringify(this.request.body);\n\nif (!key || !blob) {\n this.status = 400;\n this.body = 'Bad Request';\n}\n\nlock = sign(settings.api_secret, blob);\n\nif (lock !== key) {\n console.log(symbols.warning, 'Unauthorized');\n this.status = 403;\n this.body = 'Unauthorized';\n return;\n}\n\n...\n\nfor pull_requests and create events this works ok, even pushing new branches works, but for push commits events the x-hub-signature and the computed hash from the payload don't match, so it always get 403 unauthorized.\nUpdate\nI've noticed that for this kind of push payloads the commits and head_commit are added to the payload. I've tried removing the commits and the head_commit from the body but it didn't work.\nUpdate\nFor more information please review these example payloads. I've also included url for the test repo and token info: https://gist.github.com/marcoslhc/ec581f1a5ccdd80f8b33" }, { "role": "assistant", "content": "The default encoding of Crypto hash.update() is binary as detailed in the answer to Node JS crypto, cannot create hmac on chars with accents. This causes a problem in your push-event payload, which contains the character U+00E1 LATIN SMALL LETTER A WITH ACUTE in Hernández four times, and GitHub services is hashing the payload as utf-8 encoded. Note that your Gist shows these incorrectly-encoded in ISO-8859-1, so also make sure that you are handling the incoming request character-encoding properly (but this should happen by-default).\nTo fix this you need to either use a Buffer:\nhmac = crypto.createHmac('sha1', tok).update(new Buffer(blob, 'utf-8')).digest('hex');\n\n... or pass the encoding directly to update:\nhmac = crypto.createHmac('sha1', tok).update(blob, 'utf-8').digest('hex');\n\nThe correct hash of 7f9e6014b7bddf5533494eff6a2c71c4ec7c042d will then be calculated." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-blame - Show what revision and author last modified each line of a file --first-parent" }, { "role": "assistant", "content": "Follow only the first parent commit upon seeing a merge\ncommit. This option can be used to determine when a line\nwas introduced to a particular integration branch, rather\nthan when it was introduced to the history overall." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I remove a submodule?\nHow do I remove a Git submodule?\nWhy can't I do\ngit submodule rm module_name?" }, { "role": "assistant", "content": "In modern git (I'm writing this in 2022, with an updated git installation), this has become quite a bit simpler:\n\nRun git rm <path-to-submodule>, and commit.\n\nThis removes the filetree at <path-to-submodule>, and the submodule's entry in the .gitmodules file. I.e. all traces of the submodule in your repository proper are removed.\nAs the docs note however, the .git dir of the submodule is kept around (in the modules/ directory of the main project's .git dir), \"to make it possible to checkout past commits without requiring fetching from another repository\".\nIf you nonetheless want to remove this info, manually delete the submodule's directory in .git/modules/, and remove the submodule's entry in the file .git/config. These steps can be automated using the commands\n\nrm -rf .git/modules/<path-to-submodule>, and\ngit config --remove-section submodule.<path-to-submodule>.\n\n\n\nOlder community wiki instructions:\nVia the page Git Submodule Tutorial:\nTo remove a submodule you need to:\n\nDelete the relevant section from the .gitmodules file.\nStage the .gitmodules changes:git add .gitmodules\nDelete the relevant section from .git/config.\nRemove the submodule files from the working tree and index:git rm --cached path_to_submodule (no trailing slash).\nRemove the submodule's .git directory:rm -rf .git/modules/path_to_submodule\nCommit the changes:git commit -m \"Removed submodule <name>\"\nDelete the now untracked submodule files:rm -rf path_to_submodule\n\nSee also: alternative steps below." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-upload-pack" }, { "role": "assistant", "content": "Send objects packed back to git-fetch-pack" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker --namespace=<path>" }, { "role": "assistant", "content": "Set the Git namespace. See gitnamespaces for more\ndetails. Equivalent to setting the GIT_NAMESPACE environment\nvariable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-for-each-ref - Output information on each ref color" }, { "role": "assistant", "content": "Change output color. Followed by :<colorname> , where color\nnames are described under Values in the \"CONFIGURATION FILE\"\nsection of git-config . For example, %(color:bold red) ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary shallow clone" }, { "role": "assistant", "content": "Mostly a synonym to shallow repository but the phrase makes it more explicit that it was created by\nrunning git clone --depth=... command." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to sync gitlab with github\n\nI have several developers working on a local Gitlab instance. The client requires that their Github repo is kept updated. So our Gitlab repo should push any commits directly to Github. Any commits to Github should likewise be pulled into Gitlab. \nI could do the first part (dev --> gitlab --> github) with jenkins or something, but am stuck on the reverse. Our Gitlab and Jenkins run inside our firewall. \nAny hints or pointers (or drop in solutions!) would be very appreciated." }, { "role": "assistant", "content": "It's only in the enterprise edition and on GitLab.com, but GitLab has introduced this feature directly, without any workarounds.\nThey've documented pulling/pushing from/to a remote repository in GitLab Docs → User Docs → Projects → Repositories → Mirroring.\nIt's in the same section of configuration that you can push, too:\n\nFrom within a project use the gear icon to select Mirror Repository\nScroll down to Push to a remote repository\nCheckmark Remote mirror repository: Automatically update the remote mirror's branches, tags, and commits from this repository every hour.\nEnter the repository you want to update; for GitHub you can include your username and password in the URL, like so: https://yourgithubusername:[email protected]/agaric/guts_discuss_resource.git\n\nNote that I haven't tried it, but you should be able to push to and pull from the same repository. It's working great for me pulling from a remote repository (drupal.org), and pushing to a different remote repository (gitlab.com)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-commit - Record changes to the repository" }, { "role": "assistant", "content": "SYNOPSIS git commit [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend]\n\t [--dry-run] [(-c | -C | --squash) <commit> | --fixup [(amend|reword):]<commit>)]\n\t [-F <file> | -m <msg>] [--reset-author] [--allow-empty]\n\t [--allow-empty-message] [--no-verify] [-e] [--author=<author>]\n\t [--date=<date>] [--cleanup=<mode>] [--[no-]status]\n\t [-i | -o] [--pathspec-from-file=<file> [--pathspec-file-nul]]\n\t [(--trailer <token>[(=|:)<value>])…​] [-S[<keyid>]]\n\t [--] [<pathspec>…​]" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database --[no-]dangling" }, { "role": "assistant", "content": "Print objects that exist but that are never directly used (default). --no-dangling can be used to omit this information from the output." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options index.sparse" }, { "role": "assistant", "content": "When enabled, write the index using sparse-directory entries. This\nhas no effect unless core.sparseCheckout and core.sparseCheckoutCone are both enabled. Defaults to false ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-send-email - Send a collection of patches as emails sendemail.smtpEncryption" }, { "role": "assistant", "content": "See git-send-email for description. Note that this\nsetting is not subject to the identity mechanism." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary object database" }, { "role": "assistant", "content": "Stores a set of \"objects\", and an individual object is\nidentified by its object name . The objects usually\nlive in $GIT_DIR/objects/ ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects on, m" }, { "role": "assistant", "content": "Make diff output for merge commits to be shown in the default\nformat. The default format can be changed using log.diffMerges configuration variable, whose default value\nis separate ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-ls-files - Show information about files in the index and the working tree" }, { "role": "assistant", "content": "NAME git-ls-files - Show information about files in the index and the working tree" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc minimal" }, { "role": "assistant", "content": "Spend extra time to make sure the smallest possible diff is\nproduced." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git clone from another directory\nI am trying to clone repo from another directory.\nLets say I have one repo in C:/folder1 and C:/folder2\nI want to clone the work in folder1 into folder2.\nWhat would I type into the command prompt to do this? \nIt seems that often when cloning a URL is provided rather then a file path, however, at this moment I am just practicing and trying to get use to Git." }, { "role": "assistant", "content": "cd /d c:\\\ngit clone C:\\folder1 folder2\n\nFrom the documentation for git clone:\n\nFor local repositories, also supported by git natively, the following syntaxes may be used:\n/path/to/repo.git/\n\nfile:///path/to/repo.git/\n\nThese two syntaxes are mostly equivalent, except the former implies --local option." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git: How do you add an external directory to the repository?\nI want to add an external directory to an existing repository.\nExternal Dir:\n/home/some/directory\nWorking Dir:\n/htdocs/.git\nIf I attempt the following command from the /htdocs dir:\n\ngit add /home/some/directory\n\nI get an error:\nfatal: '/home/some/directory' is outside repository" }, { "role": "assistant", "content": "If I need to do something like that I would normally move that external file or directory into my git repo and symlink it's original location to the new one.\nmv /home/some/directory /htdocs/directory\nln -s /htdocs/directory /home/some/\ngit add ./directory\n\nI use this technique when I am developing a plug-in for an application that I want to keep under version control but have to store in a specific location." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to escape a pipe char in a code statement in a markdown table?\n\nOn GitHub I want to build a table containing pieces of code in Markdown. It works fine except when I put a pipe char (i.e. | ) between the backtick (i.e. ` ) chars.\nHere is what I want:\n a | r \n------------|-----\n `a += x;` | r1\n `a |= y;` | r2\n\nThe problem is that the vertical bar in the code statement of the second line is interpreted as a column delimiter. Then the table rendering looks pretty ugly. How could I avoid that?\nNote that I already tried to use the &#124; HTML code, but it produces a &#124;= y;." }, { "role": "assistant", "content": "As of March 2017 using escaped pipes is much easier: \\| See other answers.\n\nIf you remove the backticks (`), using the &#124; hack works\n a | r \n------------|-----\n `a += x;` | r1\n a &#124;= y; | r2\n\nand produces the following output\n\nAlternatively, you can replace the backticks (`) with a <code></code> markup which fixes the issues more nicely by preserving the rendering\n a | r \n------------|-----\n `a += x;` | r1\n<code>a &#124;= y;</code> | r2\n\ngenerating the following output" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-send-email - Send a collection of patches as emails --xmailer --no-xmailer" }, { "role": "assistant", "content": "Add (or prevent adding) the \"X-Mailer:\" header. By default,\nthe header is added, but it can be turned off by setting the sendemail.xmailer configuration variable to false ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-replay" }, { "role": "assistant", "content": "EXPERIMENTAL: Replay commits on a new base, works with bare repos too" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options format.useAutoBase" }, { "role": "assistant", "content": "A boolean value which lets you enable the --base=auto option of\nformat-patch by default. Can also be set to \"whenAble\" to allow\nenabling --base=auto if a suitable base is available, but to skip\nadding base info otherwise without the format dying." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options uploadpackfilter.allow" }, { "role": "assistant", "content": "Provides a default value for unspecified object filters (see: the\nbelow configuration variable). If set to true , this will also\nenable all filters which get added in the future.\nDefaults to true ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-stash - Stash the changes in a dirty working directory away apply [--index] [-q|--quiet] [<stash>]" }, { "role": "assistant", "content": "Like pop , but do not remove the state from the stash list. Unlike pop , <stash> may be any commit that looks like a commit created by stash push or stash create ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-verify-pack - Validate packed Git archive files" }, { "role": "assistant", "content": "SYNOPSIS git verify-pack [-v | --verbose] [-s | --stat-only] [--] <pack>.idx…​" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Are dependent pull requests in GitHub possible?\nCurrently I am working on a really big pull request. In order to keep code reviews somehow manageable, the idea was to split the complete pull request into isolated parts which, however, depend on each other.\nAn example would be:\n\nPull request 1: Create interfaces: Interface A & B and restructure code.\nPull request 2: Interface A implementation and Tests (depends on pull request 1).\nPull request 3: Interface B implementation and Tests (depends on pull request 2).\nPull request 4: Mixed test of Implementations (depends on 2 + 3).\n\nIs there a way in GitHub to file all four pull requests at the same time reflecting the dependencies?" }, { "role": "assistant", "content": "Update 2022: While GitHub still has no native support for dependent/stacked pull requests, a few tools now exist that make it easier to manage a GitHub-friendly hierarchy of branches. My favorite is ghstack, which takes a stack of commits and turns each one into its own branch that GitHub can understand without losing PR history. You can then edit, reorder, split, and drop commits using interactive rebase and the PRs will be updated accordingly.\n\nAs far as I can see, this is impossible, and in my opinion it's one of the major downsides of GitHub compared with other code review tools. Gerrit automatically sets up dependent code reviews when you push commits that depend on each other, and in Phabricator it's more of a pain, but still possible.\nIt's also good to keep in mind that there multiple ways that people use GitHub PRs. The normal open source collaboration way is to fork a repo and submit a cross-repo pull request, but in other cases (e.g. within an organization), you might submit pull requests for diffs all within the same repository. I think within a single repository it's more reasonable to get something along the lines of dependent pull requests, since you can set up the commit/branch structure within that repo.\nHere's a blog post that describes how to get some advantages of dependent pull requests, which I think requires all commits to be in the same repo:\nhttp://graysonkoonce.com/stacked-pull-requests-keeping-github-diffs-small/\nA summary:\n\nTo submit 5 dependent pull requests, create a 5-level-deep branch hierarchy and submit each PR as as that branch based on the previous branch.\nTo update review 2 of 5, push an update to branch 2, then do 3 merge operations to integrate the changes into reviews 3, 4, and 5.\nYou need to land all changes at once, since GitHub doesn't support updating the target branch of PRs. In the example, all 5 code reviews were landed as a single commit. GitHub now supports updating the base branch of a PR, so the PRs can be landed one at a time.\n\nThat approach seems to work ok for giant changes that are best reviewed in smaller pieces (although maintaining an n-level-deep branch hierarchy is a pain compared with something like git rebase -i), but it doesn't really allow for a \"code review pipeline\" where you can have dependent diffs in different stages of review and can land earlier ones as they're reviewed.\nSome other internet resources that seem to also call out the limitation:\nhttps://www.quora.com/Is-there-a-good-system-for-adding-multiple-pull-requests-to-GitHub\nhttps://muffinresearch.co.uk/how-do-you-deal-with-dependent-branches-on-github/\nMy understanding is that people using GitHub PRs generally just try to structure their workflow to not rely on dependent code reviews. Some examples:\n\nInstead of breaking up a change into independently-reviewable incremental steps, submit it as a monolithic code review that will land all at once. GitHub still lets you split code reviews up into multiple commits that the reviewer can view, but they can't be approved/landed independently.\nTry to structure your work so you make changes in unrelated parts of the code, and put them on independent branches that you can use to submit independent PRs. You can still keep a local branch with all changes applied using cherry-picking or other approaches.\nIf you have a change that depends on an outstanding PR, simply wait for the PR to get accepted and merged before submitting the new PR. You could mention somewhere that you have another PR that depends on that one, and maybe that will motivate the code reviewer to get to that one earlier." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git gc --aggressive push to server?\nIt seems like git gc --aggressive really cleans up my repo, but when I do git push everything is already up-to-date. Is there a way to clean up the server?" }, { "role": "assistant", "content": "2012: I know that GitHub will run git gc periodically, as the GitHub support mentioned in this thread.\n\nSince 2012 (up to 2023):\nI don't know if you can force it yourself, though.\nI didn't see such a service in the GitHub hooks.\nAs illustrated by \"How to remove a dangling commit from GitHub?\", no git gc seems to be ever performed on remote GitHub repository.\nThat means any remote repository cleanup would be the result of an explicit request to GitHub Support." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub \"Failed to publish this branch\" error on Windows\nI'm new to Git, and I just downloaded it yesterday. As a test for my first online (not local) repository, I committed a useless text file and then hit publish. After a short while, I got this very non-descriptive error:\n\nSo I know that I can't publish to this branch. There's only one and it's the master branch. Is there any further information on what might be causing this error?\nAs a side note, my partner has successfully uploaded files to the same repository, but I haven't gotten any sort of indication that this has happened. Does this mean I'm not connected to the repository properly in some way? I was the one who set it up!" }, { "role": "assistant", "content": "In Windows, right click on your repository → click on Open a shell here.\nYou will see a command prompt.\nType git push in it. (been aware after seeing SimonBoudrias comment)\nThe command prompt will suggest you to type some other command or shows an error.\nIf the command prompt suggest you to type something else, then type that. It will work. \nIf the command prompt shows an error, then please post the detailed error here.\nInformation: You might want to check this app" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git failed to push (LFS upload missing objects)\n\nI’ve been using Gitlab with LFS just fine for a while now but somehow ran into this problem today:\nme@some-PC MINGW32 /b/Unity Projects/Platballer (master)\n$ git push\nLFS upload missing objects: (32/33), 30 MB | 0 B/s\nUploading LFS objects: 97% (32/33), 30 MB | 0 B/s, done\n (missing) Assets/External Assets/TimelineEvents/setup-guide.pdf (6ef8ef61e49821309de416925bf4e068ebb10a57f3398cb926e967eeb90cf034)\nCounting objects: 401, done.\nDelta compression using up to 16 threads.\nCompressing objects: 100% (400/400), done.\nWriting objects: 100% (401/401), 1.40 MiB | 9.56 MiB/s, done.\nTotal 401 (delta 177), reused 0 (delta 0)\nremote: Resolving deltas: 100% (177/177), completed with 31 local objects.\nremote: GitLab: LFS objects are missing. Ensure LFS is properly set up or try a manual \"git lfs push --all\".\nTo arvzrg.asuscomm.com:arvz/platballer.git\n ! [remote rejected] master -> master (pre-receive hook declined)\nerror: failed to push some refs to '[email protected]:me/project.git'\n\nSo I did what they said and ran git lfs push --all origin master\nwhich gives me:\nUploading LFS objects: 100% (330/331), 52 MB | 0 B/s, done\nLFS upload missing objects:\n (missing) Assets/External Assets/TimelineEvents/setup-guide.pdf (6ef8ef61e49821309de416925bf4e068ebb10a57f3398cb926e967eeb90cf034)\n\nIt seems like that did whatever needed doing, right? So I tried pushing again, but I still get the exact same problem I did before.\nI'm running my own installation of GitLab on a server on my network.\nWhat else can I do here?" }, { "role": "assistant", "content": "Check if this is similar to gitlab-org/gitlab-ce issue 40616:\n\nI've verified that it is possible to push to GitLab if the LFS objects are stored elsewhere, but LFS must be disabled for the project so that the LFS validation is disabled.\nDisabled LFS for the project using the API (I'm using HTTPie)\nhttp PUT https://gitlab.com/api/v4/projects/<id> name=<project-name> lfs_enabled=false Private-Token:<your token>\nAdd the lfs.url to the lfs config (for example GitHub)\ngit config -f .lfsconfig lfs.url https://github.com/<user>/<project>.git/info/lfs\n\nPush to GitLab should now work" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Rails : why is there .keep file in every directory [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nRandom 'concerns' folders and '.keep' files\n\n (3 answers)\n \n\nClosed 9 years ago.\n\n\n\nI see .keep file in every directory in rails skeleton.\nwhat is that file for?\nWhat is its significance?" }, { "role": "assistant", "content": "This is not for Rails actually, this is for git.\nGit doesn't track \"empty\" directories, so, the directories like eg. \"/logs\" wouldn't end up in the repository. Having a .keep in it, marks the directory to be tracked.\nUpdates:\nIn Unix based systems, files starting with a dot(.) are considered hidden and do not appear in the UI. Hence they might not disturb you." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to remove a branch locally?\nI have a master and a dev branch in my repository. I want to remove the master branch from my computer so that I don't accidentally commit to it (it's happened..). \nThere are questions on here about how to delete branches locally and remotely, but I haven't been able to find out how to only delete a branch locally.\nOne answer said to use this:\ngit branch -d local_branch_name\n\nBut I tried that and the branch still shows up in the GitHub application." }, { "role": "assistant", "content": "To Force Delete a Local Branch:\n$ git branch -D <branch-name>\n\n\n[NOTE]:\n-D is a shortcut for --delete --force." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to separate changed files from untracked files in vscode?\nI am checking out vscode to see if it does anything better than other options out there. I have the native version control and GitLens installed. I am trying to figure out how to work with version control and one thing has been puzzling. Both GitLens and native source control list both files that are not in the repository and the files that have changed since the last commit in the same list. Is there any way to group these files separately, the way git status does in either of the interfaces?" }, { "role": "assistant", "content": "VSCode 1.40 (Oct. 2019) seems to provide just that:\n\nGit: Improved untracked files management\nYou can now manage untracked files separately by using the Git: Untracked Changes setting.\n\nChoose the separate option, if you'd like to see untracked files in a separate group in the Source Control view.\nChoose hidden if you'd like to never see them.\n\nThe default commit action will adjust itself to this setting and will only include untracked changes in a commit when using the mixed setting value.\n\n\n\nWith VSCode 1.67 (Apr. 2022), setting untrackedChanges to mixed will avoid performance issue.\nSee issue 140755:\n\nFor very large git repositories, the -u option (an alias for -uall) can sometimes make git status take a large amount of time and CPU.\nWould like to have an option (off by default) to ignore individual files in untracked directories, which is the default behavior of git status with no arguments (equivalent to -unormal)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Changing image size in Markdown on Gitlab\n\nI'm trying to post a picture to a file on my Gitlab using markdown\n ![](test/media/screenshot.png)\n\nseems to work but is far too large.\nOther solutions I've tried and don't seem to work are as follows:\n <img src=\"https://gitlab.com/example/screenshot\" width=\"48\">\n ![](test/media/screenshot.png =100x20)\n ![](test/media/screenshot.png =250x)\n <img src=\"https://gitlab.com/example/screenshot\" alt=\"Drawing\" style=\"width: 200px;\"/>\n\nAny ideas on what I can do rather than re-sizing every image I have?" }, { "role": "assistant", "content": "Raw HTML works\nTry the following: after uploading your image, use img tag with src pointing to the path of uploaded image, for me it's working:\nThe following is from one of my files\n![](/uploads/d19fcc3d3b4d313c8cd7960a343463b6/table.png)\n<img src=\"/uploads/d19fcc3d3b4d313c8cd7960a343463b6/table.png\" width=\"120\" height=\"120\">\n\n\nCheck this link, where I've put different size of same image https://gitlab.com/Basel.issmail/resize-image/wikis/resizing-image\nThere is an issue on gitlab discuss Add control over images with Markdown" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Print commit message of a given commit in git\nI need a plumbing command to print the commit message of one given commit - nothing more, nothing less." }, { "role": "assistant", "content": "It's not \"plumbing\", but it'll do exactly what you want:\n$ git log --format=%B -n 1 <commit>\n\nIf you absolutely need a \"plumbing\" command (not sure why that's a requirement), you can use rev-list:\n$ git rev-list --format=%B --max-count=1 <commit>\n\nAlthough rev-list will also print out the commit sha (on the first line) in addition to the commit message." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Github commit message links\n\nIs it possible to create a commit message with link to other repository commit?\nEg. something like [Username\\Repo\\commitHash]\nUsage example: if some bc break would happen in some framework's commit, I'd like to link to this very commit in my own commits updating my code which uses this framework." }, { "role": "assistant", "content": "I was searching for something like this myself. Found it on:\nhttps://help.github.com/articles/autolinked-references-and-urls/#commit-shas\n<<username>>/<<repo>>@<<commitHash>>\n\nWithout the angle brackets of course :)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-daemon - A really simple server for Git repositories --pid-file=<file>" }, { "role": "assistant", "content": "Save the process id in file . Ignored when the daemon\nis run under --inetd ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I get the commit id of the head of master in git?\nI want to display the git commit id (i.e. SHA) of the head of master on my website as an identifier.\nHow can I pull this information from git?" }, { "role": "assistant", "content": "This command will get you the latest commit's SHA-1\ngit rev-parse HEAD" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why isn't my updated .gitignore working for files that are being tracked?\nI have the following .gitignore file\n# file named .gitignore\n\nsystem/application/config/database.php\nsystem/application/config/config.php\nsystem/logs\nmodules/recaptcha/config/*\n\nHowever when I add any changes in config and recapcha.php, git status warns me as following.\nWhen I add any changes to database.php. it does not show it in status\nshin@shin-Latitude-E5420:/var/www/myapp$ git status\n# On branch master\n# Your branch is ahead of 'origin/master' by 1 commit.\n#\n# Changes not staged for commit:\n# (use \"git add <file>...\" to update what will be committed)\n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n# modified: modules/recaptcha/config/recaptcha.php\n# modified: system/application/config/config.php\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nHow can I fix this?\nI am using git version 1.7.5.1 on Ubuntu 11.04" }, { "role": "assistant", "content": "The files are already stored in your local commit tree. You'll need to first remove them from the repository. This can be done via:\ngit rm --cached system/application/config/config.php modules/recaptcha/config/recaptcha.php\n\nAfter that you'll need to make one more commit and you're good to go." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How resolve multiple conflicts with \"git mergetool\" without having to close the editor between files?\nI've found git mergetool to be a handy utility for merging diffs visually, but the way I'm going about it seems really wonky. Essentially, my process looks like this when conflicts are reported:\n\nExecute a git mergetool\nAt the prompt, hit Enter to launch my diff tool (Meld or FileMerge, depending on which computer)\nResolve the conflicts\nSave the changes\nClose the diff tool\n\nIf I have more than one conflict, rinse, repeat. Yep, that's me opening and closing my diff viewer once for each conflict in the merge. Since it's launched from the command line, closing it is the only way I know of to tell git mergetool that I've resolved this particular conflict and that it can move on to the next.\nSurely there's a better way, but I have no idea. Li'l help, please? This process seems crazy inefficient." }, { "role": "assistant", "content": "At first glance, it does not seem possible to reuse an external diff tool session.\nThe git-mergetool documentation clearly states:\n\nIf the custom merge tool correctly indicates the success of a merge resolution with its exit code, then the configuration variable mergetool.<tool>.trustExitCode can be set to true.\n Otherwise, git-mergetool will prompt the user to indicate the success of the resolution after the custom tool has exited.\n\nSo the exit code (or the validation of the user after the exit of the diff tool) is needed, implying that the user first close the external diff tool.\nThat seems a great incentive to reduce the number of conflicts on each merge/rebase one attempts ;) (whatever the VCScs tool used)\nNote:\nTwo other git external diff tools settings (\"Setting up diff and merge tools for Git on Windows\" and \"Setting up SourceGear DiffMerge with Git\") do not give more hopes when it come to not closing the external diff tool..." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I delete a specific revision of a github gist?\n\nI created a Gist on GitHub and I saw information I don't want anyone to see.\nI updated the file since, but everybody can still access the old revision of the file.\nExcept deleting the Gist, is there a way to delete that particular revision definitely?\nI saw that I'm not the only one having that kind of problem (Git: delete a single remote revision) but I didn't manage to remove the revision.\nThe process indicated here seems to help remove some files. I want to remove the whole revision." }, { "role": "assistant", "content": "Github has a help page about removing sensitive data:\nhttp://help.github.com/removing-sensitive-data/\nAs gists are just git repositories, you should be able to locally clone your gist, do the clean-up there and do a forced push to overwrite the github version with the cleaned repo.\nYes, after thinking about it: If <commit> is the commit you want to \"remove\", do\n git rebase -i <commit>^\n\nmark the line for <commit> as edit, save and quit.\ngit will set up the working directory to the state after you comitted <commit>. Fix the file, use git add and git commit --amend to fix the commit. Then do git rebase --continue. If the only thing, the next commit did, was to remove the sensitive data, it will probably be automatically dropped because it doesn't contain any changes after the now-amended commit.\nThen, do a git push -f to force the update (because it is now non-fast-forward, meaning it changes already published git history)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options color.ui" }, { "role": "assistant", "content": "This variable determines the default value for variables such\nas color.diff and color.grep that control the use of color\nper command family. Its scope will expand as more commands learn\nconfiguration to set a default for the --color option. Set it\nto false or never if you prefer Git commands not to use\ncolor unless enabled explicitly with some other configuration\nor the --color option. Set it to always if you want all\noutput not intended for machine consumption to use color, to true or auto (this is the default since Git 1.8.4) if you\nwant such output to use color when written to the terminal." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-mailinfo" }, { "role": "assistant", "content": "Extracts patch and authorship from a single e-mail message" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What does the warning \"redirecting to\" actually mean?\nI have noticed that sometimes when I git pull a project, there is a message saying: \n\"warning: redirecting to <url>\"\n\nI tried searching what it means but I find nothing useful. What is it?" }, { "role": "assistant", "content": "Check you remote:\ngit remote -v\n\nProbably, your remote is https://server/../project and does not end with .git (https://server/../project.git)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why isn't the git stash unique per branch?\nI suppose it allows for moving changes from one branch to the next but that's what cherry picking is for and if you're not making a commit of your changes, perhaps you shouldn't be moving them around?\nI have on occasion applied the wrong stash at the wrong branch, which left me wondering about this question." }, { "role": "assistant", "content": "As mentioned, if you want a “per-branch stash,” you really want a new branch forking off from the existing branch.\nAlso, besides the already mentioned fact that the stash allows you to pull into a branch that you’re working on, it also allows you to switch branches before you have committed everything. This is useful not for cherry-picking in the usual sense so much as for cherry-picking your working copy.\nF.ex., while working on a feature branch, I will often notice minor bugs or cosmetic impurities in the code that aren’t relevant to that branch. Well, I just fix those right away. When time comes to commit, I selectively commit the relevant changes but not the fixes and cosmetics. Instead I stash those, which allows me to switch to my minor-fixes-on-stable branch, where I can then apply the stash and commit each minor fix separately. (Depending on the changes in question, I will also stash some of them yet again, to switch to a different feature branch, where I apply those.)\nThis allows me to go deep into programming mode when I am working, and not worry about proper librarianship of my code. Then when I take a mental break, I can go back and carefully sort my changes into all the right shelves.\nIf the stash weren’t global, this type of workflow would be far more difficult to do." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "\"git diff\" does nothing\nI presume this is a configuration error somewhere, but I can't figure out where. Regular git commands appear to work fine, but \"git diff\" does nothing. To be safe, I removed external diff tools from my .gitconfig file. This was installed via MacPorts and is the lates version (1.7.2.2).\nWhat I see is that when I run \"git diff\" from my workspace, it simply exits, doing nothing.\n$ git --version\ngit version 1.7.2.2\n$ git diff\n$ \n\nIf I back up one directory, out of my root workspace, typing \"git diff\" gives me this:\n$ git diff\nusage: git diff [--no-index] <path> <path>\n\nThis may be expected behavior since I'm not under a git repository.\nAny ideas on what I can do to troubleshoot this?" }, { "role": "assistant", "content": "The default output for git diff is the list of changes which have not been committed / added to the index. If there are no changes, then there is no output.\n\ngit diff [--options] [--] […]\nThis form is to view the changes you made relative to the index (staging area for the next commit). In other words, the differences are what you could tell git to further add to the index but you still haven't.\n\nSee the documentation for more details. In particular, scroll down to the examples, and read this section:\n$ git diff # (1)\n$ git diff --cached # (2)\n$ git diff HEAD # (3)\n\n\nDiff the working copy with the index\nDiff the index with HEAD \nDiff the working copy with HEAD\n\nOutside your workspace, as you guessed, git won't know what to diff, so you have to explicitly specify two paths to compare, hence the usage message." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "TypeError: Request path contains unescaped characters, how can I fix this\n\n/*Making http request to the api (Git hub)\ncreate request\nparse responce\nwrap in a function\n*/\nvar https = require(\"https\");\n\nvar username = 'lynndor';\n//CREATING AN OBJECT\nvar options = {\n host: 'api.github.com',\n path: ' /users/'+ username +'/repos',\n method: 'GET'\n};\n\nvar request = https.request(options, function(responce){\n var body = ''\n responce.on(\"data\", function(chunk){\n body += chunk.toString('utf8')\n });\n responce.on(\"end\", function(){\n console.log(\"Body\", body);\n });\n});\nrequest.end();\n\n\nIm trying to create a request to the git hub api, the aim is to get the list repository for the specified you, but i keep getting the above mentioned error, please help" }, { "role": "assistant", "content": "for other situation can be helpful\nJavaScript encodeURI() Function\nvar uri = \"my test.asp?name=ståle&car=saab\";\nvar res = encodeURI(uri);" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Proper way to use Gitflow with pull requests\nI would like to adopt the git-flow tool inside my team.\nThe problem is that \"git flow feature finish\" merges the branches locally.\nAnd I want to create a pull request instead. Thus, the merge will happen in the origin.\nSo, what is the right way to use the git-flow tool in teams that also work with pull requests?\nTried to google it but could not find something meaningful." }, { "role": "assistant", "content": "You can just use the git flow feature publish <name>this will publish your feature branch to your origin (like Bitbucket). Then you can create the pull request there and merge it into develop. After that is done, you need to manually delete the local feature branch.\nThe only command you can not use is git flow feature finish <name>. This works fairly well and you can still use most of the git flow helpers.\nThe same goes for releases. I found this article helpfull: https://blog.axosoft.com/pull-requests-gitflow/\nAs well as https://community.atlassian.com/t5/Bitbucket-questions/git-flow-feature-finish-and-pull-request/qaq-p/347877\nHope this helps a little. There is just not the one perfect solution to this problem." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs git log --name-status release..test" }, { "role": "assistant", "content": "Show the commits that are in the \"test\" branch but not yet\nin the \"release\" branch, along with the list of paths\neach commit modifies." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitrevisions - Specifying revisions and ranges for Git <refname>@{<n>} , e.g. master@{1}" }, { "role": "assistant", "content": "A ref followed by the suffix @ with an ordinal specification\nenclosed in a brace pair (e.g. {1} , {15} ) specifies\nthe n-th prior value of that ref. For example master@{1} is the immediate prior value of master while master@{5} is the 5th prior value of master . This suffix may only be used\nimmediately following a ref name and the ref must have an existing\nlog ( $GIT_DIR/logs/<refname> )." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to receive local Git branch name with Jenkins Git plugin?\nI am using Branch Specifier option of Jenkins Git plugin (v2.0) to run build on specific branch, e.g. 1.4.\n${GIT_BRANCH} in this case contains origin/1.4 value.\nHow can I receive a name of the local Git branch used for cloning (i.e. just 1.4 without origin/ prefix?\nI've tried Check out to specific local branch Additional Behaviour with branch name 1.4, but nothing had changed.\nI've seen related PR on GitHub, but it was declined (as it fixes only one case with just origin remote)." }, { "role": "assistant", "content": "You can strip the prefix from the variable pretty easily: ${GIT_BRANCH##origin/}\nAlthough this is not a very general solution, it's quite simple and I haven't seen a repository cloned by Jenkins, which would use something else than origin for the remote name.\nUpdate: Actually, ${GIT_BRANCH#*/} will work for any origin and even for branches containing slashes. The # does non-greedy glob matching, ## enables greedy matching. See Bash Reference Manual for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to know if latest commit to master has been pushed to the remote?\nI have merged a branch in to master and now I can see that in my git log\nSome time has passed and now I want to know whether I previously also pushed master (with that commit) to the remote. How can I tell if it has been pushed?\nI can think of a few workaround such as recloning the repository elsewhere, or resetting and checking and then re-merging but I feel that there's probably a somewhat simpler answer.\nfyi this is different from How can I know in git if a branch has been already merged into master? as I know it has been merged, just don't know about the remote push." }, { "role": "assistant", "content": "Do\n> git status\n\nIf the output is\n# On branch master\nnothing to commit, working directory clean\n\nThen you have pushed the current commit.\nIf the output instead begins with \n# On branch master\n# Your branch is ahead of 'origin/master' by 1 commit.\n# (use \"git push\" to publish your local commits)\n\nThen you have a local commit that has not yet been pushed. You see this because the remote branch, origin/master, points to the commit that was last pushed to origin. However, your branch is ahead of 'origin/master', meaning that you have a local commit that has been created after the last pushed commit.\nIf the commit you are interested in is not the latest, then you can do\n> git log --decorate --oneline\n\nto find out if the commit in question is before or after the commit pointed to by origin/master.\nIf the commit is after (higher up in the log than) origin/master, then it has not been pushed." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What exactly do we mean by \"branch\"?\nLong story short...\nAs far as I can tell, the term \"branch\" (in Git parlance) may refer to related but different things:\n\na non-symbolic reference/pointer to a commit,\nthe name of such a reference (e.g. \"master\"),\nthe subgraph of the repository's commit DAG composed of all the commits reachable from the commit pointed to by such a reference.\n\nHowever, I've seen the term used to apparently refer to something other than those three possible usages (more details below). In a Git context, are there other valid and unambiguous usages of the term \"branch\" that my list above is missing?\nMore details\nAfter using Git for about a year, I'm preparing a short tutorial for CS students. I really want to nail down the Git terminology, so as to avoid any confusion.\nOf course, I've been using Git branches for a while now; I'm comfortable using them and find the Git branching model awesome. However, I still find the term \"branch\" problematic and ambiguous, because it seems to refer to at least two different things, depending on the context in which it's used... sometimes even in the same tutorial/manual.\nUsage 1: branch = pointer/reference to a commit\nThe Pro Git book (in 3.1 - What a branch is), after showing the following diagram,\n\ngoes on to define a branch as\n\nsimply a lightweight movable pointer to one of these commits.\n\nAs far as I can tell, this is also the meaning \"branch\" has in the Git man pages.\nI'm perfectly comfortable with this definition. I think of a branch as just a reference that points to a particular commit in the DAG, and the \"tip commit\" of a branch is the commit pointed to by that reference. So far, so good. But wait...\nUsage 2: branch = a subgraph of the DAG\nThe Atlassian Git tutorial introduces branches as follows:\n\nA branch represents an independent line of development.\n\nWhat they mean by that, I guess, is a string of commits. Let me refine that thought... The only interpretation that makes sense to me is that the term \"branch\" can also refer to the subgraph of the repository's commit DAG composed of all the commits reachable from the tip commit considered.\nHowever, the Pro Git book, for instance, also contains the following diagram (see 3.4 - Branching workflows),\n\nwhich seems to contradict my interpretation, because it seems to imply that only commits C2-C5 (not C1) belong to the develop branch, and that only commits C6-C7 (not C1-C5) belong to the topic branch. \nI find this usage ambiguous and vague because, if I were to draw the DAG at that stage, without knowing where the branch references have pointed to in the past, and without any assumption of any hierarchy between the three branches, all I would get is\n\nI also find some diagrams in other Git learning resources confusing. Consider, in particular, the following one (taken from the introduction video of the Lynda.com - Git Essential Training):\n\nHere, the tip of master is actually 534de (and HEAD points to master), but the position of the \"master\" label on the diagram is very misleading. What that label is supposed to describe in this case is unclear to me...\nEdit: I've since found this excellent post on Marc's blog; the Branches section echoes my remarks above." }, { "role": "assistant", "content": "You are correct.\nWe can further split your item 1 by separating \"local\" and \"remote\" branch labels: local branches (local labels) are names that start (internally—many front-end command hide this) with refs/heads/, while \"remote branches\"—which are also called \"remote-tracking branches\"—start with refs/remotes/ and then have one more path component naming the specific remote before the part naming the branch. (Edit, April 2018: I dislike the phrase \"remote branch\" or \"remote-tracking branch\"; I think it's better to just call these remote-tracking names. But there is a lot of existing documentation that uses the other two phrases, so we need to be aware of this usage.)\nFor instance, you are no doubt familiar with refs/remotes/origin/master, but if you have a remote named bob you might also have refs/remotes/bob/hacks/feep that tracks Bob's hacks/feep.\nA local branch name refs/heads/branch has the distinguishing feature that git checkout will put you \"on\" that branch by default, by writing that name into the special HEAD reference; and once it you are set up this way, new commits (created by git commit, git merge, git cherry-pick, etc.) cause the new commit's SHA-1 to be written into the branch-file. (The new commit has as its parent, or one of its parents, the old tip-of-branch.)\nI have attempted to use terms like \"branch tip\" to denote specifically the commit to which a branch name like refs/heads/master points, \"branch name\" or \"local branch name\" to refer to the name itself (whether prefixed by refs/heads/ or not), and—I think this is the least successful—\"branch structure\" to refer to the DAG subset. However, given a DAG with a fork-and-merge like this:\n o--o\n / \\\n...-o--o o--o-...\n \\ /\n o--o\n\nI sometimes want to refer to one or the other half of the little benzene-ring-like object as \"a branch\" as well, and I have no really good term for this.\n(Incidentally, if you were a topologist, the fact that the Atlassian diagram can also be drawn linearly would not bother you. However, as the old joke goes, topologists keep trying to drink out of their donuts and eat their coffee mugs since each one is just a torus.)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-push - Update remote refs along with associated objects -q --quiet" }, { "role": "assistant", "content": "Suppress all output, including the listing of updated refs,\nunless an error occurs. Progress is not reported to the standard\nerror stream." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Should the package-lock.json file be added to .gitignore? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nDo I commit the package-lock.json file created by npm 5?\n\n (15 answers)\n \n\nClosed 5 years ago.\nThe community reviewed whether to reopen this question 2 months ago and left it closed:\n\nOriginal close reason(s) were not resolved\n\n\n\n\nTo lock the versions of dependencies that are installed over a project, the command npm install creates a file called package-lock.json. This was made since Node.js v8.0.0 and npm v5.0.0, as several of you might know.\nDespite of Node.js and npm recommendations about committing this file, several concerns regarding when you should avoid to do it, are also an option. Typically we commit in our projects, nevertheless, it is a peculiar question.\nWhile we should commit the package-lock.json file by default, we have a specific case we should not. For instance, if we want to test the latest version of our project dependencies, it can be an option to add package-lock.json into .gitignore.\nSo, the questions are as follows:\n\nShould the package-lock.json file be added to .gitignore?\nIs there any particular situation that we MUST or MUST NOT do it?" }, { "role": "assistant", "content": "No, the package-lock.json SHOULD NOT be added to .gitignore. Instead, I strongly advise:\n\nAdd the package-lock.json you to your version control repository\nUse npm ci instead of npm install when building your application both locally and in your deployment pipeline.\n(The ci command is available since [email protected], if in doubt upgrade your npm via: npm install -g npm.)\n\n\nOne of the biggest downside of the npm install command is its unexpected behavior that it may mutate the package-lock.json, whereas npm ci only uses the version in the lockfile and produces an error if the package-lock.json and package.json are out of sync.\nAlso, npm ci requires the existence of a package-lock.json and would print an error if it wasn't there.\nThere is a strong use-case for being able to trust that the project's dependencies resolve repeatably in a reliable way across different machines.\nFurthermore, npm ci nukes the entire node_modules folder before adding the dependencies making sure you work with your actual dependencies instead of local changes while still being faster than a normal npm install.\nFrom a package-lock.json you get exactly that: a known-to-work state with always exactly the same dependency tree.\nIn the past, I had projects without package-lock.json / npm-shrinkwrap.json / yarn.lock files whose build would fail one day because a random dependency got a breaking update. (While a lot of libraries respect the semvar versioning guideline, you have no guarantee they won't break on a minor upgrade.)\nThose issue are hard to resolve as you sometimes have to guess what the last working version was.\nIn regards to testing the latest dependencies for your project: This is what npm update is for and I argue that it should be run by a developer, who also runs the test locally, who resolves issue if they may arise, and who then commits the changed package-lock.json. (If an upgrade fails, they can revert to the last working package-lock.json.)\nFurthermore, I rarely upgrade all the dependencies at once (as that too might require further maintenance) but I rather cherry-pick the update I need (e.g. npm update {dependency}, or npm install {dependency}@2.1.3). Which is another reason why I would see it as a manual maintenance step.\nIf you really want to have it automated you could create a job for:\n\ncheckout repository\nrun npm update\nrun tests\n\nif tests passes, then commit and push to repository\nelse fail and report issue to be manually resolved\n\n\n\nThis is something I would see hosted on a CI server, e.g. Jenkins, and it should not be achieved through aforementioned reason through adding the file to the .gitignore.\n\nOr to quote npm doc:\n\nIt is highly recommended you commit the generated package lock to\nsource control: this will allow anyone else on your team, your\ndeployments, your CI/continuous integration, and anyone else who runs\nnpm install in your package source to get the exact same dependency\ntree that you were developing on. Additionally, the diffs from these\nchanges are human-readable and will inform you of any changes npm has\nmade to your node_modules, so you can notice if any transitive\ndependencies were updated, hoisted, etc.\n\nAnd in regards to the difference between npm ci vs npm install:\n\n\nThe project must have an existing package-lock.json or npm-shrinkwrap.json.\nIf dependencies in the package lock do not match those in package.json, npm ci will exit with an error, instead of updating\nthe package lock.\nnpm ci can only install entire projects at a time: individual dependencies cannot be added with this command.\nIf a node_modules is already present, it will be automatically removed before npm ci begins its install.\nIt will never write to package.json or any of the package-locks: installs are essentially frozen." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-clone - Clone a repository into a new directory clone.defaultRemoteName" }, { "role": "assistant", "content": "The name of the remote to create when cloning a repository. Defaults to origin .\nIt can be overridden by passing the --origin command-line\noption." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker gitformat-pack" }, { "role": "assistant", "content": "Git pack format" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "In a Git cherry-pick or rebase merge conflict, how are BASE (aka \"the ancestor\"), LOCAL, and REMOTE determined?\nIn a normal Git merge conflict, the three versions of a file in play for the three-way merge are roughly as follows:\n\nLOCAL: the version from my branch\nREMOTE: the version from the other branch\nBASE: the version from the common ancestor of the two branches (in particular, the common ancestor of my branch's HEAD and the other branch's HEAD)\n\nWhen a Git cherry-pick generates a merge conflict, there is no common ancestor, properly speaking, so how are these things determined? The same could be asked about rebase." }, { "role": "assistant", "content": "cherry-pick\nUnless I have misled myself, then if you do \"git cherry-pick <commit C>\", then you get:\n\nLOCAL: the commit you're merging on top of (ie the HEAD of your branch)\nREMOTE: the commit you're cherry picking (i.e. <commit C>)\nBASE: the parent of the commit you're cherry-picking (ie C^, ie the parent of C)\n\nIf it's not immediately clear why BASE should be C^, see the \"why\" section below.\nMeanwhile, let's take an example, and see that BASE can be but often won't be a common ancestor during a cherry-pick. Suppose the commit graph looks like this\nE <-- master\n|\nD \n| C <-- foo_feature(*)\n|/\nB\n|\nA\n\nand you are in branch foo_feature (hence the asterisk). If you do \"git cherry-pick <commit D>\", then BASE for that cherry-pick will be commit B, which is a common ancestor of C and D. (C will be LOCAL and D will be REMOTE.) However, if you instead do \"git cherry-pick <commit E>, then BASE will be commit D. (C will be LOCAL and E will be REMOTE.)\nrebase\nFor background context, rebase is approximately iterated cherry-picking. In particular, rebasing topic on top of master (ie \"git checkout topic; git rebase master\") means approximately :\ngit checkout master # switch to master's HEAD commit\ngit checkout -b topic_rebased # create new branch rooted there\nfor each commit C in master..topic # for each topic commit not already in master...\n git cherry-pick C # bring it over to the new branch\nfinally, forget what \"topic\" used to mean and now defined \"topic\" as the HEAD of topic_rebased.\n\nThe labels that apply during this process are extensions of the normal cherry-pick rules:\n\nLOCAL: the commit you're cherry-picking on top of\n\nThis is the HEAD of the new topic_rebased branch\nFor the first commit only, this will be the same as the HEAD of master\n\nREMOTE: the commit you're cherry picking (i.e. <commit C>)\nBASE: the parent of the commit you're cherry-picking (C^, ie the parent of C)\n\nThis implies something to keep in mind about LOCAL vs REMOTE, if you want to avoid confusion:\n\nEven though you were on branch topic when you initiated the rebase, LOCAL never refers to a commit on the topic branch while a rebase is in progress. Instead, LOCAL always refers to a commit on the new branch being created (topic_rebased).\n\n(If one fails to keep this in mind, then during a nasty merge one may start asking oneself, \"Wait, why is it saying these are local changes? I swear they were changes made on master, not on my branch.\")\nTo be more concrete, here is an example:\nSay we have commit graph\nD <-- foo_feature(*)\n|\n| C <-- master\nB |\n|/\n|\nA\n\nand we are currently on branch foo_feature (indicated by \"*\"). If we run \"git rebase master\", the rebase will proceed in two steps:\nFirst, changes from B will be replayed on top of C. During this, C is LOCAL, B is REMOTE, and A is BASE. Note that A is a real common ancestor of B and C. After this first step, you have a graph approximately like so:\n B' <-- foo_feature\nD |\n| |\n| C <-- master\nB /\n|/\n|\nA\n\n(In real life, B and D might have already been pruned out of the tree at this point, but I'm leaving them in here, in order to make it easier to spot any potential common ancestors.)\nSecond, changes from D will be replayed on top of B'. During this, B' is LOCAL, D is REMOTE, and B is BASE. Note that B is not a relevant common ancestor of anything. (For example, it's not a common ancestor of the current LOCAL and REMOTE, B' and D. And it's not a common ancestor of the original branch heads, C and D). After this step, you have a branch approximately like so:\n D' <-- foo_feature\n |\n B'\nD |\n| |\n| C <-- master\nB /\n|/\n|\nA\n\nFor completeness, note by the end of the rebase B and D are removed from the graph, yielding:\nD' <-- foo_feature\n|\nB'\n|\nC <-- master\n|\nA\n\nWhy is BASE defined as it is?\nAs noted above, both for a cherry-pick and for a rebase, BASE is the parent (C^) of the the commit C being pulled in. In the general case C^ isn't a common ancestor, so why call it BASE? (In a normal merge BASE is a common ancestor. And part of git's successes in merging are due to its ability to find a good common ancestor.) \nEssentially, one does this as a way to implement \"patch\" functionality via the normal three-way merge algorithm. In particular you get these \"patchy\" properties:\n\nIf <commit C> doesn't modify a given given region of the file, then the version of that region from your branch will prevail. (This is, regions that the \"patch\" doesn't call for changing don't get patched.)\nIf <commit C> modifies a given region of the file and your branch leaves that region alone, then the version of that region from <commit x> will prevail. (That is, regions that the \"patch\" calls for changing get patched.)\nIf <commit C> modifies a given region of the file but your branch has also modified that region, then you get a merge conflict." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Suddenly getting \"No supported authentication methods available\" when pushing to github\nI started a github project a few weeks ago. I was able to push changes without any problems (I'm using TortoiseGIT).\nSuddenly today when I tried to push my changes, I got \"PuTTY Fatal Error\" \"Disconnected: No supported authentication methods availble\" error window.\nAnything you can recommend to remedy the problem?" }, { "role": "assistant", "content": "For me there was a problem to perform actions against the remote repository only when using TortoiseGit, through CMD / GitBash there have been no issue at all.\nSo what I did was Very simple:\nI opened TortoiseGit-->Settings --> Network and in SSH Client I changed to \"C:\\Program Files\\Git\\usr\\bin\\ssh.exe\" instead of \"TortoiseGitPlink.exe\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary unreachable object" }, { "role": "assistant", "content": "An object which is not reachable from a branch , tag , or any other reference." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: show total file size difference between two commits?\nIs it possible to show the total file size difference between two commits? Something like:\n$ git file-size-diff 7f3219 bad418 # I wish this worked :)\n-1234 bytes\n\nI’ve tried:\n$ git diff --patch-with-stat\n\nAnd that shows the file size difference for each binary file in the diff — but not for text files, and not the total file size difference.\nAny ideas?" }, { "role": "assistant", "content": "git cat-file -s will output the size in bytes of an object in git. git diff-tree can tell you the differences between one tree and another.\nPutting this together into a script called git-file-size-diff located somewhere on your PATH will give you the ability to call git file-size-diff <tree-ish> <tree-ish>. We can try something like the following:\n#!/bin/bash\nUSAGE='[--cached] [<rev-list-options>...]\n\nShow file size changes between two commits or the index and a commit.'\n\nSUBDIRECTORY_OK=1\n. \"$(git --exec-path)/git-sh-setup\"\nargs=$(git rev-parse --sq \"$@\")\n[ -n \"$args\" ] || usage\ncmd=\"diff-tree -r\"\n[[ $args =~ \"--cached\" ]] && cmd=\"diff-index\"\neval \"git $cmd $args\" | {\n total=0\n while read A B C D M P\n do\n case $M in\n M) bytes=$(( $(git cat-file -s $D) - $(git cat-file -s $C) )) ;;\n A) bytes=$(git cat-file -s $D) ;;\n D) bytes=-$(git cat-file -s $C) ;;\n *)\n echo >&2 warning: unhandled mode $M in \\\"$A $B $C $D $M $P\\\"\n continue\n ;;\n esac\n total=$(( $total + $bytes ))\n printf '%d\\t%s\\n' $bytes \"$P\"\n done\n echo total $total\n}\n\nIn use this looks like the following:\n$ git file-size-diff HEAD~850..HEAD~845\n-234 Documentation/RelNotes/1.7.7.txt\n112 Documentation/git.txt\n-4 GIT-VERSION-GEN\n43 builtin/grep.c\n42 diff-lib.c\n594 git-rebase--interactive.sh\n381 t/t3404-rebase-interactive.sh\n114 t/test-lib.sh\n743 tree-walk.c\n28 tree-walk.h\n67 unpack-trees.c\n28 unpack-trees.h\ntotal 1914\n\nBy using git-rev-parse it should accept all the usual ways of specifying commit ranges.\nEDIT: updated to record the cumulative total. Note that bash runs the while read in a subshell, hence the additional curly braces to avoid losing the total when the subshell exits.\nEDIT: added support for comparing the index against another tree-ish by using a --cached argument to call git diff-index instead of git diff-tree. eg:\n$ git file-size-diff --cached master\n-570 Makefile\n-134 git-gui.sh\n-1 lib/browser.tcl\n931 lib/commit.tcl\n18 lib/index.tcl\ntotal 244\n\nEDIT: Mark script as capable of running in a subdirectory of a git repository." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Difference between Git GUI, Git Bash, Git CMD\nWhat is the difference between Git GUI, Git Bash and Git CMD?\nI'm a beginner, and for doing my installations I usually find myself using both git bash and git CMD" }, { "role": "assistant", "content": "Git CMD is just like regular Windows command prompt with the git command. It lets you use all of Git features through command line. Useful if you are already familiar with Windows cmd and you only work on Windows.\nGit Bash emulates a bash environment on windows. It lets you use all git features in command line plus most of standard unix commands. Useful if you are used to Linux and want to keep the same habits. \nGit GUI is a Graphical User Interface letting you use Git without touching command line. It is an alternative among other Git clients. Since Git GUI is very minimal, you could also look at other alternatives if GUIs interest you.\nIt is up to you to decide which you want to use. As many others, I recommend you to learn Git with command line before switching to a graphical interface. If you don't know which to choose between Git Bash and Git CMD, I'd go for Git Bash since bash is a really useful tool to learn." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options imap.sslverify" }, { "role": "assistant", "content": "A boolean to enable/disable verification of the server certificate\nused by the SSL/TLS connection. Default is true . Ignored when\nimap.tunnel is set." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_COMMIT_GRAPH_PARANOIA" }, { "role": "assistant", "content": "When loading a commit object from the commit-graph, Git performs an\nexistence check on the object in the object database. This is done to\navoid issues with stale commit-graphs that contain references to\nalready-deleted commits, but comes with a performance penalty. The default is \"false\", which disables the aforementioned behavior.\nSetting this to \"true\" enables the existence check so that stale commits\nwill never be returned from the commit-graph at the cost of performance." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Setting up and using Meld as your Git difftool and mergetool\nThere are a lot of different programs that can be used as your Git difftool and mergetool, and there certainly isn't any consensus as to which is the best (opinions, requirements, and OSes will clearly differ).\nMeld is a popular free, open-source, and cross-platform (Unix/Linux, OS X, Windows) choice as shown in the Stack Overflow question, What's the best visual merge tool for Git?, in which the answer proposing Meld has more than three times the votes as any other tool.\nThe following two questions will be answered in my answer below:\n\nHow do I set up and use Meld as my Git difftool?\nHow do I set up and use Meld as my Git mergetool?\n\nNote: It is not necessary to use the same program as both your difftool and mergetool. Different programs can be set for both.\nAlthough much of the information in this question and answer is available on Stack Overflow, it is spread out over lots of pages and among other answers which are either wrong or misleading. It took me a while to piece together everything I wanted to know." }, { "role": "assistant", "content": "How do I set up and use Meld as my Git difftool?\ngit difftool displays the diff using a GUI diff program (i.e., Meld) instead of displaying the diff output in your terminal.\nAlthough you can set the GUI program on the command line using -t <tool> / --tool=<tool> it makes more sense to configure it in your .gitconfig file. (Note: See the sections about escaping quotes and Windows paths at the bottom.)\n# Add the following to your .gitconfig file.\n[diff]\n tool = meld\n[difftool]\n prompt = false\n[difftool \"meld\"]\n cmd = meld \"$LOCAL\" \"$REMOTE\"\n\n(Note: These settings will not alter the behaviour of git diff which will continue to function as usual.)\nYou use git difftool in exactly the same way as you use git diff. E.g.,\ngit difftool <COMMIT_HASH> file_name\ngit difftool <BRANCH_NAME> file_name\ngit difftool <COMMIT_HASH_1> <COMMIT_HASH_2> file_name\n\nIf properly configured, a Meld window will open displaying the diff using a GUI interface.\nThe order of the Meld GUI window panes can be controlled by the order of $LOCAL and $REMOTE in cmd, that is to say which file is shown in the left pane and which in the right pane. If you want them the other way around simply swap them around like this:\ncmd = meld \"$REMOTE\" \"$LOCAL\"\n\nFinally, the prompt = false line simply stops Git from prompting you as to whether you want to launch Meld or not, by default Git will issue a prompt.\n\nHow do I set up and use Meld as my Git mergetool?\ngit mergetool allows you to use a GUI merge program (i.e., Meld) to resolve the merge conflicts that have occurred during a merge.\nLike difftool, you can set the GUI program on the command line using -t <tool> / --tool=<tool> but, as before, it makes more sense to configure it in your .gitconfig file. (Note: See the sections about escaping quotes and Windows paths at the bottom.)\n# Add the following to your .gitconfig file.\n[merge]\n tool = meld\n[mergetool \"meld\"]\n # Choose one of these two lines (not both!) explained below.\n cmd = meld \"$LOCAL\" \"$MERGED\" \"$REMOTE\" --output \"$MERGED\"\n cmd = meld \"$LOCAL\" \"$BASE\" \"$REMOTE\" --output \"$MERGED\"\n\nYou do not use git mergetool to perform an actual merge. Before using git mergetool you perform a merge in the usual way with Git. E.g.,\ngit checkout master\ngit merge branch_name\n\nIf there is a merge conflict, Git will display something like this:\ngit merge branch_name\n\nOutput:\nAuto-merging file_name\nCONFLICT (content): Merge conflict in file_name\nAutomatic merge failed; fix conflicts and then commit the result.\n\nAt this point file_name will contain the partially merged file with the merge conflict information (that's the file with all the >>>>>>> and <<<<<<< entries in it).\nMergetool can now be used to resolve the merge conflicts. You start it very easily with:\ngit mergetool\n\nIf properly configured, a Meld window will open displaying three files. Each file will be contained in a separate pane of its GUI interface.\nIn the example .gitconfig entry above, two lines are suggested as the [mergetool \"meld\"] cmd line. In fact there are all kinds of ways for advanced users to configure the cmd line, but that is beyond the scope of this answer.\nThis answer has two alternative cmd lines which, between them, will cater for most users, and will be a good starting point for advanced users who wish to take the tool to the next level of complexity.\nFirstly here is what the parameters mean:\n\n$LOCAL is the file in the current branch (e.g., master).\n$REMOTE is the file in the branch being merged (e.g., branch_name).\n$MERGED is the partially merged file with the merge conflict information in it.\n$BASE is the shared commit ancestor of $LOCAL and $REMOTE, this is to say the file as it was when the branch containing $REMOTE was originally created.\n\nI suggest you use either:\n[mergetool \"meld\"]\n cmd = meld \"$LOCAL\" \"$MERGED\" \"$REMOTE\" --output \"$MERGED\"\n\nor:\n[mergetool \"meld\"]\n cmd = meld \"$LOCAL\" \"$BASE\" \"$REMOTE\" --output \"$MERGED\"\n # See 'Note On Output File' which explains --output \"$MERGED\".\n\nThe choice is whether to use $MERGED or $BASE in between $LOCAL and $REMOTE.\nEither way Meld will display three panes with $LOCAL and $REMOTE in the left and right panes and either $MERGED or $BASE in the middle pane.\nIn both cases the middle pane is the file that you should edit to resolve the merge conflicts. The difference is just in which starting edit position you'd prefer; $MERGED for the file which contains the partially merged file with the merge conflict information or $BASE for the shared commit ancestor of $LOCAL and $REMOTE. [Since both cmd lines can be useful I keep them both in my .gitconfig file. Most of the time I use the $MERGED line and the $BASE line is commented out, but the commenting out can be swapped over if I want to use the $BASE line instead.]\nNote On Output File: Do not worry that --output \"$MERGED\" is used in cmd regardless of whether $MERGED or $BASE was used earlier in the cmd line. The --output option simply tells Meld what filename Git wants the conflict resolution file to be saved in. Meld will save your conflict edits in that file regardless of whether you use $MERGED or $BASE as your starting edit point.\nAfter editing the middle pane to resolve the merge conflicts, just save the file and close the Meld window. Git will do the update automatically and the file in the current branch (e.g. master) will now contain whatever you ended up with in the middle pane.\nGit will have made a backup of the partially merged file with the merge conflict information in it by appending .orig to the original filename. e.g. file_name.orig. After checking that you are happy with the merge and running any tests you may wish to do, the .orig file can be deleted.\nAt this point you can now do a commit to commit the changes.\nIf, while you are editing the merge conflicts in Meld, you wish to abandon the use of Meld, then quit Meld without saving the merge resolution file in the middle pane. Git will respond with the message file_name seems unchanged and then ask Was the merge successful? [y/n], if you answer n then the merge conflict resolution will be aborted and the file will remain unchanged. Note that if you have saved the file in Meld at any point then you will not receive the warning and prompt from Git. [Of course you can just delete the file and replace it with the backup .orig file that Git made for you.]\nIf you have more than one file with merge conflicts then Git will open a new Meld window for each, one after another until they are all done. They won't all be opened at the same time, but when you finish editing the conflicts in one, and close Meld, Git will then open the next one, and so on until all the merge conflicts have been resolved.\nIt would be sensible to create a dummy project to test the use of git mergetool before using it on a live project. Be sure to use a filename containing a space in your test, in case your OS requires you to escape the quotes in the cmd line, see below.\n\nEscaping quote characters\nSome operating systems may need to have the quotes in cmd escaped. Less experienced users should remember that configuration command lines should be tested with filenames that include spaces, and if the cmd lines don't work with the filenames that include spaces then try escaping the quotes. E.g.,\ncmd = meld \\\"$LOCAL\\\" \\\"$REMOTE\\\"\n\nIn some cases more complex quote escaping may be needed. The 1st of the Windows path links below contains an example of triple-escaping each quote. It's a bore, but it is sometimes necessary. E.g.,\ncmd = meld \\\\\\\"$LOCAL\\\\\\\" \\\\\\\"$REMOTE\\\\\\\"\n\nWindows paths\nWindows users will probably need extra configuration added to the Meld cmd lines. They may need to use the full path to meldc, which is designed to be called on Windows from the command line, or they may need or want to use a wrapper. They should read the Stack Overflow pages linked below which are about setting the correct Meld cmd line for Windows. Since I am a Linux user, I am unable to test the various Windows cmd lines and don't have any further information on the subject other than to recommend using my examples with the addition of a full path to Meld or meldc, or adding the Meld program folder to your path.\n\nGit Diff and Meld on Windows\nHow to set Meld as git mergetool\nGit mergetool with Meld on Windows\n\nIgnoring trailing whitespace with Meld\nMeld has a number of preferences that can be configured in the GUI.\nIn the preferences Text Filters tab there are several useful filters to ignore things like comments when performing a diff. Although there are filters to ignore All whitespace and Leading whitespace, there isn't any ignore the Trailing whitespace filter (this has been suggested as an addition in the Meld mailing list, but it is not available in my version).\nIgnoring trailing whitespace is often very useful, especially when collaborating, and can be manually added easily with a simple regular expression in the Meld preferences Text Filters tab.\n# Use either of these regexes depending on how comprehensive you want it to be.\n[ \\t]*$\n[ \\t\\r\\f\\v]*$" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --description-file=<file>" }, { "role": "assistant", "content": "Use the contents of <file> instead of the branch’s description\nfor generating the cover letter." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Search for a particular file in all the gitlab repositories\n\nSimple and very much needed feature, just would like to know if it's possible to search for a particular file in GITLAB in all the repositories instead of a particular repository. There's a huge search icon on the right corner of the GITLAB which will search corresponding maching repository names BUT NOT the files.\nI would like to search for a particular file through all the repositories which I have access to in GITLAB.\nPlease note that the GITLAB is hosted in the private domain of my organization. So googling filename:something.txt or something.txt in:path doesn't work (this was suggested by one of the user in some post for GITHUB)." }, { "role": "assistant", "content": "Yes it's possible using Advanced Search feature by enabling Elastic Search integration.\nOnce that is configured you can use Advanced Syntax Search with search filters to find what you need.\nFor example, you could search the .gitlab-ci.yml files of all projects for the text tags.yml inside of it typing this in global search bar:\ntags.yml filename:gitlab-ci\n\nAnother example to search abc.txt file in all repositories (ensure Group and Project dropdown menu are set to Any) :\n* filename:abc.txt" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository -k --keep" }, { "role": "assistant", "content": "Keep downloaded pack." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is it possible to search through Git stash items?\nSo I'm learning about using Git stash this week and figured out all of these stashes have been accumulating on my system. I've misplaced some code and I now have a dozen stashes of code 0-11.\nIs there a way that I can search through these stashes for a string value in the files within the stash to find the code I'm looking for?\nOr do I just have to go through and reapply each stash to search/look in them for the code I'm trying to find?\n\n2021/03/18: I have found other information that sort of relates.\nYou can create a Git alias to search all your stashes. Modify your .gitconfig file and call git stash-search <pattern>.\n[alias]\n stash-search = \"!f() { git show $(git stash list | cut -d\\\":\\\" -f 1) | grep \\\"$@\\\" ; }; f\"" }, { "role": "assistant", "content": "There are some helpful ideas in this Gist and discussion thread.\nFirst, just listing matching stashes is easy (with or without -i, depending if case matters)\ngit stash list -i -G<regexp>\n\nIf there's not that much to dig through, you can just add -p to print the matching stashes in their entirety.\ngit stash list -i -p -G<regexp>\n\nWith more power for \"real\" cases, add it to .gitconfig:\n[alias]\n stashgrep = \"!f() { for i in `git stash list --format=\\\"%gd\\\"` ; \\\n do git stash show -p $i | grep -H --label=\\\"$i\\\" \\\"$@\\\" ; done ; }; f\"\n\nand then you can call git stashgrep with any grep arguments you like (-w, -i). e.g.,\ngit stashgrep -i <regexp>\n\nThis differs from some answers above, in that it prepends the stash ID to show you where each difference came from:\n% git stashgrep -i tooltip\nstash@{5}: // resetBatchActionTooltip();\nstash@{5}: addAcceleratorsAndTooltips(lToolMenu, lToolButton, iListener, iTool);\nstash@{5}: private void addAcceleratorsAndTooltips(AbstractButton lToolMenu,\nstash@{5}:+ String lToolTip = iTool.getToolTipText();\nstash@{5}: lToolButton.setToolTipText(lToolTip);\nstash@{20}:+ private static final String invalidSelectionTooltip = \"Invalid selection. Please choose another.\";\nstash@{20}:- private final String invalidSelectionTooltip = \"Invalid selection. Please choose another.\";\nstash@{20}: ((JTextField)lComponent).setToolTipText(" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git missing in VS Code – No source control providers\nI just installed Visual Studio Code 1.17 and opened a Git repository folder. When entering the Source Control tab I see a message \"There are no active source control providers\". I thought Git was baked into VSCode!?\nTo make matters worse, when I attempt to install additional SCM providers there is no option for Git. How do I get my Git back!?" }, { "role": "assistant", "content": "Wow I spent so long on this. For me I had to go to the Extensions area > then click the ... at top right of menu > Show built-in Extensions\nGit built-in extension was disabled!!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.<driver>.xfuncname" }, { "role": "assistant", "content": "The regular expression that the diff driver should use to\nrecognize the hunk header. A built-in pattern may also be used.\nSee gitattributes for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %cD" }, { "role": "assistant", "content": "committer date, RFC2822 style" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to use git commands after enable gitlab's second-factor authentication\nToday I've enabled Gitlab's 2nd-factor authentication. After that, since I logged in the Gitlab website, I need to use my cell phone to pass a 6-digits plus my password, that's good, it makes me feel safe.\nHowever, when I use the general operations, for example git clone some-repo.git, I got the error:\nCloning into 'some-repo'...\nremote: HTTP Basic: Access denied\nremote: You must use a personal access token with 'api' scope for Git over HTTP.\nremote: You can generate one at https://gitlab.com/profile/personal_access_tokens\nfatal: Authentication failed for 'some-repo.git'\n\nThen I try existing cloned local repo, using git pull, the same error occurs. Before I enabled the 2nd-factor authentication, all the above operation worked fine.\nFlowing the above error's instructions, I went to the mentioned address: https://gitlab.com/profile/personal_access_tokens. I created the following token, and save the token's key.\n\nHowever, I don't know what to do with this key. Can someone tell me how to use this key to enable the basic operations like git pull, git clone, git push etc...\nEdit\nI had many repos on local before I enabled the 2nd-factor authentication. I want these to work too." }, { "role": "assistant", "content": "As explained in using gitlab token to clone without authentication, you can clone a GitLab repo using your Personal Access Token like this:\ngit clone https://oauth2:[email protected]/yourself/yourproject.git\n\nAs for how to update your existing clones to use the GitLab Personal Access Token, you should edit your .git/config file in each local git directory, which will have an entry something like this:\n[remote \"origin\"]\n url = https://[email protected]/yourself/yourproject.git\n\nChange the url:\n[remote \"origin\"]\n url = https://oauth2:[email protected]/yourself/yourproject.git\n\nNow you can continue using this existing git clone as you did before you enabled 2FA." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-rev-list" }, { "role": "assistant", "content": "Lists commit objects in reverse chronological order" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitLab email setup: sending via another mail server\n\nBy default gitlab has the next configuration in gitlab.yml :\nemail:\n from: [email protected]\n host: gitlabhq.com\n\nbut, I need to specify other variables (host, port, user, password, etc) to use another mail server.\nHow I do that?" }, { "role": "assistant", "content": "Now it is totally different in Gitlab 5.2+.\nIt is in \"/home/git/gitlab/config/initializers/smtp_settings.rb.sample\" and we just need to follow the instructions in that." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Using git repository as a database backend\nI'm doing a project that deals with structured document database. I have a tree of categories (~1000 categories, up to ~50 categories on each level), each category contains several thousands (up to, say, ~10000) of structured documents. Each document is several kilobytes of data in some structured form (I'd prefer YAML, but it may just as well be JSON or XML).\nUsers of this systems do several types of operations:\n\nretrieving of these documents by ID\nsearching for documents by some of the structured attributes inside them\nediting documents (i.e. adding/removing/renaming/merging); each edit operation should be recorded as a transaction with some comment\nviewing a history of recorded changes for particular document (including viewing who, when and why changed the document, getting earlier version - and probably reverting to this one if requested)\n\nOf course, the traditional solution would be using some sort of document database (such as CouchDB or Mongo) for this problem - however, this version control (history) thing tempted me to a wild idea - why shouldn't I use git repository as a database backend for this application?\nOn the first glance, it could be solved like this:\n\ncategory = directory, document = file\ngetting document by ID => changing directories + reading a file in a working copy\nediting documents with edit comments => making commits by various users + storing commit messages\nhistory => normal git log and retrieval of older transactions\nsearch => that's a slightly trickier part, I guess it would require periodic export of a category into relational database with indexing of columns that we'll allow to search by\n\nAre there any other common pitfalls in this solution? Have anyone tried to implement such backend already (i.e. for any popular frameworks - RoR, node.js, Django, CakePHP)? Does this solution have any possible implications on performance or reliability - i.e. is it proven that git would be much slower than traditional database solutions or there would be any scalability/reliability pitfalls? I presume that a cluster of such servers that push/pull each other's repository should be fairly robust & reliable.\nBasically, tell me if this solution will work and why it will or won't do?" }, { "role": "assistant", "content": "Answering my own question is not the best thing to do, but, as I ultimately dropped the idea, I'd like to share on the rationale that worked in my case. I'd like to emphasize that this rationale might not apply to all cases, so it's up to architect to decide.\nGenerally, the first main point my question misses is that I'm dealing with multi-user system that work in parallel, concurrently, using my server with a thin client (i.e. just a web browser). This way, I have to maintain state for all of them. There are several approaches to this one, but all of them are either too hard on resources or too complex to implement (and thus kind of kill the original purpose of offloading all the hard implementation stuff to git in the first place):\n\n\"Blunt\" approach: 1 user = 1 state = 1 full working copy of a repository that server maintains for user. Even if we're talking about fairly small document database (for example, 100s MiBs) with ~100K of users, maintaining full repository clone for all of them makes disc usage run through the roof (i.e. 100K of users times 100MiB ~ 10 TiB). What's even worse, cloning 100 MiB repository each time takes several seconds of time, even if done in fairly effective maneer (i.e. not using by git and unpacking-repacking stuff), which is non acceptable, IMO. And even worse — every edit that we apply to a main tree should be pulled to every user's repository, which is (1) resource hog, (2) might lead to unresolved edit conflicts in general case.\nBasically, it might be as bad as O(number of edits × data × number of users) in terms of disc usage, and such disc usage automatically means pretty high CPU usage.\n\"Only active users\" approach: maintain working copy only for active users. This way, you generally store not a full-repo-clone-per-user, but:\n\nAs user logs in, you clone the repository. It takes several seconds and ~100 MiB of disc space per active user.\nAs user continues to work on the site, he works with the given working copy.\nAs user logs out, his repository clone is copied back to main repository as a branch, thus storing only his \"unapplied changes\", if there are any, which is fairly space-efficient.\n\nThus, disc usage in this case peaks at O(number of edits × data × number of active users), which is usually ~100..1000 times less than number of total users, but it makes logging in/out more complicated and slower, as it involves cloning of a per-user branch on every login and pulling these changes back on logout or session expiration (which should be done transactionally => adds another layer of complexity). In absolute numbers, it drops 10 TiBs of disc usage down to 10..100 GiBs in my case, that might be acceptable, but, yet again, we're now talking about fairly small database of 100 MiBs.\n\"Sparse checkout\" approach: making \"sparse checkout\" instead of full-blown repo clone per active user doesn't help a lot. It might save ~10x of disc space usage, but at expense of much higher CPU/disc load on history-involving operations, which kind of kills the purpose.\n\"Workers pool\" approach: instead of doing full-blown clones every time for active person, we might keep a pool of \"worker\" clones, ready to be used. This way, every time a users logs in, he occupies one \"worker\", pulling there his branch from main repo, and, as he logs out, he frees the \"worker\", which does clever git hard reset to become yet again just a main repo clone, ready to be used by another user logging in. Does not help much with disc usage (it's still pretty high — only full clone per active user), but at least it makes logging in/out faster, as expense of even more complexity.\n\nThat said, note that I intentionally calculated numbers of fairly small database and user base: 100K users, 1K active users, 100 MiBs total database + history of edits, 10 MiBs of working copy. If you'd look at more prominent crowd-sourcing projects, there are much higher numbers there:\n│ │ Users │ Active users │ DB+edits │ DB only │\n├──────────────┼───────┼──────────────┼──────────┼─────────┤\n│ MusicBrainz │ 1.2M │ 1K/week │ 30 GiB │ 20 GiB │\n│ en.wikipedia │ 21.5M │ 133K/month │ 3 TiB │ 44 GiB │\n│ OSM │ 1.7M │ 21K/month │ 726 GiB │ 480 GiB │\n\nObviously, for that amounts of data/activity, this approach would be utterly unacceptable.\nGenerally, it would have worked, if one could use web browser as a \"thick\" client, i.e. issuing git operations and storing pretty much the full checkout on client's side, not on the server's side.\nThere are also other points that I've missed, but they're not that bad compared to the first one:\n\nThe very pattern of having \"thick\" user's edit state is controversial in terms of normal ORMs, such as ActiveRecord, Hibernate, DataMapper, Tower, etc.\nAs much as I've searched for, there's zero existing free codebase for doing that approach to git from popular frameworks.\nThere is at least one service that somehow manages to do that efficiently — that is obviously github — but, alas, their codebase is closed source and I strongly suspect that they do not use normal git servers / repo storage techniques inside, i.e. they basically implemented alternative \"big data\" git.\n\nSo, bottom line: it is possible, but for most current usecases it won't be anywhere near the optimal solution. Rolling up your own document-edit-history-to-SQL implementation or trying to use any existing document database would be probably a better alternative." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I count number of commits between two branches?\nUsing the git diff --shortstat my_branch master is a great way to tell how many files changes and the insertions and deletions. I read the git diff documentation, but I couldn't find a way to tell the number of commits between my_branch and master. Does that exist?" }, { "role": "assistant", "content": "I think you could try:\n\ngit log --oneline mybranch ^master\n\nFor the exact count:\n\ngit log --oneline mybranch ^master | wc -l\n\nShould give you the information you want." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %Cgreen" }, { "role": "assistant", "content": "switch color to green" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to open multiple pull requests on GitHub\nWhen I open a pull request on GitHub.\nAll commits since my last request and all new ones are automatically added to this request. \nI can't seem to control which commits are added and which are not.\nWhen I try to open another pull request, I get an \"Oops! There's already a pull request\" error. \nIs there any easy way to open multiple pull requests without having to mess around with the command line?" }, { "role": "assistant", "content": "Pull requests are based on a branch.\nThe only way to open up a pull request for multiple commits is: \n\nIsolate them into their own branch. \nOpen the pull requests from there." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs porcelain" }, { "role": "assistant", "content": "Use a special line-based format intended for script\nconsumption. Added/removed/unchanged runs are printed in the\nusual unified diff format, starting with a + / - /` `\ncharacter at the beginning of the line and extending to the\nend of the line. Newlines in the input are represented by a\ntilde ~ on a line of its own." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options http.version" }, { "role": "assistant", "content": "Use the specified HTTP protocol version when communicating with a server.\nIf you want to force the default. The available and default version depend\non libcurl. Currently the possible values of\nthis option are: HTTP/2 HTTP/1.1" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Private pages for a private Github repo\n\nCouldn't find anything in the github documentation and also here on SO. But I was wondering if there could be a http://foo.github.com for a private repository named foo which is accessible only one had access to the foo repository itself.\nI remember having read something about github pages always being public but can't seem to find that anymore.\nAnd surprisingly, I can't seem to find anyone else asking the question either." }, { "role": "assistant", "content": "I had raised a support ticket against Github and got a response confirming the fact that ALL pages are public. I've now requested them to add a note to help.github.com/pages." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to prepare a Unity project for git (step-by-step)? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow to use Git for Unity3D source control?\n\n (18 answers)\n \n\nClosed 7 years ago.\nThis post was edited and submitted for review 1 year ago and failed to reopen the post:\n\nOriginal close reason(s) were not resolved\n\n\n\n\nWhat are the detailed steps necessary to prepare a Unity project for committing to a git repository eg. github? I don't want to store unnecessary files (specially temp files and avoid binary formats as much as possible) and I would appreciate a walk-through." }, { "role": "assistant", "content": "On the Unity Editor open your project and:\n\nEnable External option in Unity → Preferences → Packages → Repository (only if Unity ver < 4.5)\nSwitch to Visible Meta Files in Edit → Project Settings → Editor → Version Control Mode\nSwitch to Force Text in Edit → Project Settings → Editor → Asset Serialization Mode\nSave Scene and Project from File menu.\nQuit Unity and then you can delete the Library and Temp directory in the project directory. You can delete everything but keep the Assets and ProjectSettings directory.\n\nIf you already created your empty git repo on-line (eg. github.com) now it's time to upload your code. Open a command prompt and follow the next steps:\ncd to/your/unity/project/folder\n\ngit init\n\ngit add *\n\ngit commit -m \"First commit\"\n\ngit remote add origin [email protected]:username/project.git\n\ngit push -u origin master\n\nYou should now open your Unity project while holding down the Option or the Left Alt key. This will force Unity to recreate the Library directory (this step might not be necessary since I've seen Unity recreating the Library directory even if you don't hold down any key).\nFinally have git ignore the Library and Temp directories so that they won’t be pushed to the server. Add them to the .gitignore file and push the ignore to the server. Remember that you'll only commit the Assets and ProjectSettings directories.\nAnd here's my own .gitignore recipe for my Unity projects:\n# =============== #\n# Unity generated #\n# =============== #\nTemp/\nObj/\nUnityGenerated/\nLibrary/\nAssets/AssetStoreTools*\n\n# ===================================== #\n# Visual Studio / MonoDevelop generated #\n# ===================================== #\nExportedObj/\n*.svd\n*.userprefs\n*.csproj\n*.pidb\n*.suo\n*.sln\n*.user\n*.unityproj\n*.booproj\n\n# ============ #\n# OS generated #\n# ============ #\n.DS_Store\n.DS_Store?\n._*\n.Spotlight-V100\n.Trashes\nIcon?\nehthumbs.db\nThumbs.db" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-archive - Create an archive of files from a named tree --add-file=<file>" }, { "role": "assistant", "content": "Add a non-tracked file to the archive. Can be repeated to add\nmultiple files. The path of the file in the archive is built by\nconcatenating the value of the last --prefix option (if any)\nbefore this --add-file and the basename of <file>." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to push multiple branches from multiple commits?\nI never used git before GitHub released the Windows app, so I've never used it in command line.\nSo here's my situation:\nI did some commits on master, then switched branch and did some commits there too. All without pushing to GitHub.\nWhen I then clicked sync in the the windows app (which I assume does git push), to my surprise, all my commits were pushed to my new branch - even the commits I made while I was in master.\nSince this is the behavior of the windows app, I guess I have to use the command line.\nWhat is the correct git push command to push the commits to the correct branches on the remote?" }, { "role": "assistant", "content": "If you want to push several specific branches (for example branch1 and branch2) you can use:\ngit push origin branch1 branch2 \n\nIn Git >= 2.4 this operation can be done atomically (i.e. if it fails to push any of the branches specified nothing will be pushed):\ngit push --atomic origin branch1 branch2" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-blame - Show what revision and author last modified each line of a file -S <revs-file>" }, { "role": "assistant", "content": "Use revisions from revs-file instead of calling git-rev-list ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git -d<path> --destination=<path>" }, { "role": "assistant", "content": "If more than one --branches (or --tags) option was given to the init or clone command, you must provide the location of the branch (or\ntag) you wish to create in the SVN repository. <path> specifies which\npath to use to create the branch or tag and should match the pattern\non the left-hand side of one of the configured branches or tags\nrefspecs. You can see these refspecs with the commands git config --get-all svn-remote.<name>.branches\ngit config --get-all svn-remote.<name>.tags where <name> is the name of the SVN repository as specified by the -R option to init (or \"svn\" by default)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitlab - push using https, specifying username & password\n\nI am trying to push a newly created repository to gitlab. Here's what I did:\n\nCreate a project in gitlab. Example URL: https://gitlab.example.com/group1/project1.git\nInitiated a local bare repo:\ncd ~/projects\ngit init --bare ./project1.git\ncd project1.git\n\n\nQuestion:\nNext step is to push all of my local repo into gitlab. \nBut I want to specify username and password using https. How do I change the following to do it? \ngit remote add origin https://gitlab.example.com:group1/project1.git\ngit push --all\ngit push --tags" }, { "role": "assistant", "content": "Like others mentioned here, ssh is preferred. But for those you want to use just http/https, you can specify credentials like this:\ngit remote add origin https://username:[email protected]:group1/project1.git\n\nVerified for gitlab 9.0\nNote: Please replace '@' symbols in username with '%40' to work this." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Get gitlab-ci token with gitlab API\n\nThis question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.\n \n \n\n\n\n\n\n\nIt's unclear from the API how to get the token that can be used to clone http repositories.\nFrom the documentation here: \nhttp://doc.gitlab.com/ee/ci/api/README.html\nIt should be possible to GET this url:\nhttp://gitlab.com/ci/api/v1/projects?private_token=QVy1PB7sTxfy4pqfZM1U&url=http://demo.gitlab.com/\n\nI'm not sure where the url parameter is taken from but even with just my private token, it receive a 404 error page.\nI tried with the ci subdomain but it simply redirect me to gitlab.com.\nThat said, I'll explain a bit more the reason why I need that. I have a server that could have multiple projects. Each projects will contain a list of repositories private/public each project has to be cloned/pulled and whatever regularly. Unlike github, gitlab doesn't provide a oauth2 token that is sitewide and instead provide a CI-token for each project. I could make sure that the user enter the token for each project but that is way more complicated than entering the private token.\nOn the other hand, I could generate SSH keys for each users and add the public key to their account and this way it would be possible to fetch/clone with ssh instead of http. But that is a bit more work on my end than just fetching a token and cloning with a basic auth url\ngit clone https://gitlab-ci-token:[email protected]/project.git" }, { "role": "assistant", "content": "You can find the token by doing the following from gitlab.com\n\nClick on the project you are working on from the starting screen\nClick \"Settings\" on the left hand navigation\nScroll down to the bottom and click \"CI / CD\" which is nested in Settings\nUnder the \"Runners\" section click expand\nToken is hidden here.\n\nTook me 10 minutes to find this... not documented anywhere." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --no-color-moved-ws" }, { "role": "assistant", "content": "Do not ignore whitespace when performing move detection. This can be\nused to override configuration settings. It is the same as --color-moved-ws=no ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I reword the very first git commit message?\nI have a working tree containing 3 commmits:\n➜ ~myproject git:(master) git log\ncommit a99cce8240495de29254b5df8745e41815db5a75\nAuthor: My Name <[email protected]>\nDate: Thu Aug 16 00:59:05 2012 +0200\n\n .gitignore edits\n\ncommit 5bccda674c7ca51e849741290530a0d48efd69e8\nAuthor: My Name <[email protected]>\nDate: Mon Aug 13 01:36:39 2012 +0200\n\n Create .gitignore file\n\ncommit 6707a66191c84ec6fbf148f8f1c3e8ac83453ae3\nAuthor: My Name <[email protected]>\nDate: Mon Aug 13 01:13:05 2012 +0200\n\n Initial commit (with a misleading message)\n\nNow I wish to reword the commit message of my first commit (6707a66)\n➜ ~myproject git:(master) git rebase -i 6707\n(…entering vim)\npick 5bccda6 Create .gitignore file\npick a99cce8 .gitignore edits\n\n# Rebase 6707a66..a99cce8 onto 6707a66\n#\n# Commands:\n# p, pick = use commit\n# r, reword = use commit, but edit the commit message\n# e, edit = use commit, but stop for amending\n# s, squash = use commit, but meld into previous commit\n# f, fixup = like \"squash\", but discard this commit's log message\n# x, exec = run command (the rest of the line) using shell\n#\n# These lines can be re-ordered; they are executed from top to bottom.\n#\n# If you remove a line here THAT COMMIT WILL BE LOST.\n# However, if you remove everything, the rebase will be aborted.\n#\n# Note that empty commits are commented out\n\nIn this case, I wish to correct (reword in git parlance) the commit message in question:\n\nInitial commit (with a misleading message)\n\n…to something appropriate.\nUnsurprisingly, my attempt above didn't succeed since the first commit obviously doesn't have any parent commit. (And when you rebase, you need to reference the next oldest commit prior to the one you wish to reword, right?)\nThe gist of my question, thus, can you achieve this by any other means of doing it?" }, { "role": "assistant", "content": "Do git rebase -i --root\n(point to root instead of pointing to a specific commit)\nThis way, the first commit is also included and you can just reword it like any other commit.\nThe --root option was introduced in Git v1.7.12 (2012). Before then the only option was to use filter-branch or --amend, which is typically harder to do.\nNote: see also this similar question and answer." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to create a patch without commit in Git?\nI did some search online. I know that you can use format-patch after commit, but my situation is a little different.\nI want to create a patch, similar to \"dpk\" in SVN, so I can send it out for code review, but I don't yet want to commit it.\nHow can I achieve this with Git?" }, { "role": "assistant", "content": "When other guys had already given some answer which comply with git convention, the OP's question, \"create a patch without commit\", can be also solved in this way:\ngit diff > my_patch.txt\n\nLater you can apply this patch, also without a commit, by:\ngit apply my_patch.txt\n\nBut if you are just working locally, a git checkout another_branch -m is good enough to bring all your current uncommit changes to that another_branch, without even patch and apply." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options fetch.fsck.<msg-id>" }, { "role": "assistant", "content": "Acts like fsck.<msg-id> , but is used by git-fetch-pack instead of git-fsck . See\nthe fsck.<msg-id> documentation for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to git commit nothing without an error?\nI'm trying to write a script that does a git commit; however, if there is nothing to commit, git exits with a status of 1. The deploy script takes that as unsuccessful, and quits. How can I allow empty-commit failures to be ignored so that the script can continue, but still catch errors caused when a real commit fails?\ngit add -p && git commit" }, { "role": "assistant", "content": "Catch this condition beforehand by checking the exit code of git diff-index?\nFor example (in shell):\ngit add -A\ngit diff-index --quiet HEAD || git commit -m 'bla'\n\nEDIT: Fixed git diff command according to Holger's comment." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-branch - List, create, or delete branches <oldbranch>" }, { "role": "assistant", "content": "The name of an existing branch. If this option is omitted,\nthe name of the current branch will be used instead." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "You asked me to pull without telling me which branch you want to merge with\nTL;DR: I have a \"tracked\" branch that I can't pull.\nSo here I am in \"bucket-4\":\n$ git branch -v\n bucket-1 410f7b5 * gh-53 * gh-48 * \"Share App\"\n bucket-2 7ed70a2 * upgrade to SOLR 3.3.0\n bucket-3 400ffe4 * emergency fix prod issue\n* bucket-4 64c2414 Merge branch 'bucket-3' into bucket-4\n master 8dc4854 [ahead 1] * gh-73\n\nI'd like to pull in changes from my remote:\n$ git pull\n\nYou asked me to pull without telling me which branch you\nwant to merge with, and 'branch.bucket-4.merge' in\nyour configuration file does not tell me, either. Please\nspecify which branch you want to use on the command line and\ntry again (e.g. 'git pull <repository> <refspec>').\nSee git-pull(1) for details.\n\nIf you often merge with the same branch, you may want to\nuse something like the following in your configuration file:\n\n [branch \"bucket-4\"]\n remote = <nickname>\n merge = <remote-ref>\n\n [remote \"<nickname>\"]\n url = <url>\n fetch = <refspec>\n\nSee git-config(1) for details.\n\nHmm, odd, I thought I already added \"bucket-4\" as a tracking branch. Let's see:\n$ git remote show origin\n* remote origin\n Fetch URL: [email protected]:abcd/main.git\n Push URL: [email protected]:abcd/main.git\n HEAD branch (remote HEAD is ambiguous, may be one of the following):\n bucket-3\n master\n Remote branches:\n bucket-1 tracked\n bucket-2 tracked\n bucket-3 tracked\n bucket-4 tracked\n master tracked\n Local branches configured for 'git pull':\n bucket-1 merges with remote bucket-1\n bucket-2 merges with remote bucket-2\n bucket-3 merges with remote bucket-3\n master merges with remote master\n Local refs configured for 'git push':\n bucket-1 pushes to bucket-1 (up to date)\n bucket-2 pushes to bucket-2 (up to date)\n bucket-3 pushes to bucket-3 (up to date)\n bucket-4 pushes to bucket-4 (local out of date)\n master pushes to master (fast-forwardable)\n\nIndeed, bucket-4 is marked as \"tracked\", yet somehow it's configured for push, but not pull. \nLooking at my .git/config file, I see that I have \"remote\" and \"merge\" entries for most of my branches, but not for bucket-4. How is it even considered \"tracked\" without this?\n[remote \"origin\"]\n url = [email protected]:abcd/main.git\n fetch = +refs/heads/*:refs/remotes/origin/*\n[branch \"master\"]\n remote = origin\n merge = refs/heads/master\n[branch \"rel-2011-07-07\"]\n remote = origin\n merge = refs/heads/rel-2011-07-07\n[branch \"bucket-1\"]\n remote = origin\n merge = refs/heads/bucket-1\n[branch \"bucket-2\"]\n remote = origin\n merge = refs/heads/bucket-2\n[branch]\n autosetupmerge = true\n[branch \"bucket-3\"]\n remote = origin\n merge = refs/heads/bucket-3\n\nI see that the likely solution here is to add remote/merge entries for bucket-4 in my config file. But how is it considered \"tracked\" without this? bucket-4 was created locally, then pushed to the server from this repo, so I suspect that somehow I didn't set up tracking properly for this branch.\nIs there some configuration I can add in order to make all local branches track their remotes properly in the future?" }, { "role": "assistant", "content": "It says bucket-4 pushes to bucket-4 just because the default when pushing a branch is to push it to one with a matching name on the remote. (Note that this is still the default, even if the local branch is tracking a remote-tracking branch and the remote-tracking branch corresponds to a branch with a different name in the remote repository.)\nThe simplest way to set up the association between your bucket-4 and bucket-4 in origin is to make sure that the next time you push, you do:\ngit push -u origin bucket-4\n\nAlternatively, you can do:\ngit branch --set-upstream-to origin/bucket-4\n\n\nTo answer a couple of your questions directly:\n\nHow is it even considered \"tracked\" without this?\n\nIn this case it isn't - it's not tracking the remote-tracking branch in any sense if there's no branch.bucket-4.merge or branch.bucket-4.remote in your git config. The output from git remote show origin is just showing you where the branch would be pushed by default.\n\nIs there some configuration I can add in order to make all local branches track their remotes properly in the future?\n\nI don't think that there is. When you created bucket-4 locally, as I assume happened, the remote-tracking branch didn't exist, so it can't be set up at that point - it would be very confusing default behaviour. You just need to remember to add -u to your first git push of that branch to its upstream repository.\nI hope that's of some help." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What do these words mean in Git: Repository, fork, branch, clone, track?\nI'm honestly not clear on the semantics here. They're all about copies/variants of a code+history unit, but past that I'm not sure I could say. Is this logical structure explained somewhere?" }, { "role": "assistant", "content": "A repository is simply a place where the history of your work is stored. It often lives in a .git subdirectory of your working copy - a copy of the most recent state of the files you're working on.\nTo fork a project (take the source from someone's repository at certain point in time, and apply your own diverging changes to it), you would clone the remote repository to create a copy of it, then do your own work in your local repository and commit changes.\nWithin a repository you have branches, which are effectively forks within your own repository. Your branches will have an ancestor commit in your repository, and will diverge from that commit with your changes. You can later merge your branch changes. Branches let you work on multiple disparate features at once.\nYou can also track individual branches in remote repositories. This allows you to pull in changes from another individual's branches and to merge them into a branch of your own. This may be useful if you and a friend are working on a new feature together.\nThere are lots of great git books online. Have a look at ProGit and Git Magic to get started, as well as the official tutorials and community book." } ]