messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to get all of a user's public github commits\n\nRegardless of project, I'd like to know if there's an easy way of getting all commits to all public repositories for a single username.\nSince I belong to multiple organizations, I'm trying to compile a list of the projects on which I'm a contributor, as well as projects that I have accepted pull requests.\nSo far my google-fu and looking through the github api docs has proved insufficient." }, { "role": "assistant", "content": "https://connectionrequired.com/gitspective is your friend. :-) Filter out all but \"Push\", and you have your view, albeit without the coding work to implement it yourself first.\nInspecting what goes on with the Chrome DevTools \"Network\" tab might help you mimic the API queries, if you want to redo the work yourself." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --exit-code" }, { "role": "assistant", "content": "Make the program exit with codes similar to diff(1).\nThat is, it exits with 1 if there were differences and\n0 means no differences." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Difference between git pull --rebase and git pull --ff-only\nLet's say origin/master has commit A--B--C and my local/master has commit A--B--D.\nWhat will happen if I use git pull --rebase ?\nWhat will happen if I use git pull --ff-only ?\nIs there any difference in the resulting commit tree ?" }, { "role": "assistant", "content": "What will happen if I use git pull --rebase ?\n\ngit pull --rebase is roughly equivalent to\ngit fetch\ngit rebase origin/master\n\ni.e. your remote changes (C) will be applied before the local changes (D), resulting in the following tree\nA -- B -- C -- D\n\n\n\nWhat will happen if I use git pull --ff-only ?\n\nIt will fail.\ngit pull --ff-only corresponds to\ngit fetch\ngit merge --ff-only origin/master\n\n--ff-only applies the remote changes only if they can be fast-forwarded. From the man:\n\nRefuse to merge and exit with a non-zero status unless the current HEAD is already up-to-date or the merge can be resolved as a fast-forward\n\nSince your local and remote branches have diverged, they cannot be resolved by a fast-forward and git pull --ff-only would fail." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git status shows fatal: bad object HEAD\n\nI have a problem with git on Windows Azure. Git status shows - \"fatal: bad object HEAD\" and I tried running:\n git fsck --full\n git gc\n\nBut git fsck shows:\nbroken link from commit 739df633f185ce5d1ab7eb97d619b28e7d81185a\n to tree 2a6d4876d135c1fa7cbe1348c62570006e895fc5\nbroken link from commit 9c7eae5ffed34dbfac977e515dee675626b59f93\n to tree 400132d215ab9aced883a9971e648b82624b2032\nbroken link from commit 9c7eae5ffed34dbfac977e515dee675626b59f93\n to commit 4a49af0a0cb64a0a0415734b11772d6df18561fb\nbroken link from commit bc3072f30e71c616a8196089e19a67a2c9c0a5ad\n to tree 0aa813c183487d0a1b1f7ae81501ca7a1168283f\nbroken link from commit d3bb4f8545e91ec8ace15ad31a3147d92a1d4242\n to tree 4682108accd8e72fe68858232386dffe60f9f02d\nbroken link from commit 6b34795c4b54286301bcdc0ed254a04c132cb2ad\n to tree 5c57dd3222d11924dba841d3cae517bdc9220601\nbroken link from commit d70172d855391b93bc1c5eeb9b4226df525dfc6e\n to commit 390c8cbd527c8e707c51e25142e54421f4dd3948\nbroken link from commit cc05e8d2e3733693ebb67d697ae4b65e51fea79a\n to commit 32f081f8b901425fd1e8898478f0551970bee0f5\nbroken link from tree 6a75ed6d0311d800078e77f43d427d128372d5bc\n to blob 4a064d610c0e7207967d59934c8bc5f491f26dae\nbroken link from tree 6a75ed6d0311d800078e77f43d427d128372d5bc\n to tree 5c06ec964dcbade49287d0f36efe1f7b60f446e3\nbroken link from tree b4855fa6734b5652a93a9b799eafe47fad0d13a0\n to blob 3e1fb421613dc9066cbf9c95eddc61619a9f8eed\nbroken link from tree b4855fa6734b5652a93a9b799eafe47fad0d13a0\n to tree 556a50048d42346c283c94b78ea278ba1d57d251\nbroken link from tree 289c03409370c4ca7c12266ce2822a2976bd032b\n to blob 3abf3c48ada45f63404dcf4d675ddfdadcfa83c6\nbroken link from tree 289c03409370c4ca7c12266ce2822a2976bd032b\n to blob 3fa569892003b468ed1301426dd6d96d9644be3c\nbroken link from tree 289c03409370c4ca7c12266ce2822a2976bd032b\n to blob 0a9a54a51e84f3bc34122dbce1146d895fcbe22c\nbroken link from tree 289c03409370c4ca7c12266ce2822a2976bd032b\n to blob 3fa48873564361b4d95830803ae77f79eeafaf5b\n\ngit branch shows - *master" }, { "role": "assistant", "content": "try this; it worked for me (Warning: this destroys work that exists only in your local repo):\n rm -rf .git \nYou can use mv instead of rm if you don't want to lose your stashed commits\nthen copy .git from other clone\n cp <pathofotherrepository>/.git . -r\nthen do\n git init \nthis should solve your problem , ALL THE BEST" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects %h" }, { "role": "assistant", "content": "abbreviated commit hash" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Remove folder and its contents from git/GitHub's history\n\nI was working on a repository on my GitHub account and this is a problem I stumbled upon.\n\nNode.js project with a folder with a few npm packages installed\nThe packages were in node_modules folder\nAdded that folder to git repository and pushed the code to github (wasn't thinking about the npm part at that time)\nRealized that you don't really need that folder to be a part of the code\nDeleted that folder, pushed it \n\nAt that instance, the size of the total git repo was around 6MB where the actual code (all except that folder) was only around 300 KB. \nNow what I am looking for in the end is a way to get rid of details of that package folder from git's history so if someone clones it, they don't have to download 6mb worth of history where the only actual files they will be getting as of the last commit would be 300KB.\nI looked up possible solutions for this and tried these 2 methods\n\nRemove file from git repository (history)\nhttp://help.github.com/remove-sensitive-data/\nhttps://gist.github.com/1588371\n\nThe Gist seemed like it worked where after running the script, it showed that it got rid of that folder and after that it showed that 50 different commits were modified. But it didn't let me push that code. When I tried to push it, it said Branch up to date but showed 50 commits were modified upon a git status. The other 2 methods didn't help either.\nNow even though it showed that it got rid of that folder's history, when I checked the size of that repo on my localhost, it was still around 6MB. (I also deleted the refs/originalfolder but didn't see the change in the size of the repo).\nWhat I am looking to clarify is, if there's a way to get rid of not only the commit history (which is the only thing I think happened) but also those files git is keeping assuming one wants to rollback.\nLets say a solution is presented for this and is applied on my localhost but cant be reproduced to that GitHub repo, is it possible to clone that repo, rollback to the first commit perform the trick and push it (or does that mean that git will still have a history of all those commits? - aka. 6MB). \nMy end goal here is to basically find the best way to get rid of the folder contents from git so that a user doesn't have to download 6MB worth of stuff and still possibly have the other commits that never touched the modules folder (that's pretty much all of them) in git's history.\nHow can I do this?" }, { "role": "assistant", "content": "WARNING: git filter-branch is no longer officially recommended. The official recommendation is to use git-filter-repo; see André Anjos' answer for details.\n\nIf you are here to copy-paste code:\nThis is an example which removes node_modules from history\ngit filter-branch --tree-filter \"rm -rf node_modules\" --prune-empty HEAD\ngit for-each-ref --format=\"%(refname)\" refs/original/ | xargs -n 1 git update-ref -d\necho node_modules/ >> .gitignore\ngit add .gitignore\ngit commit -m 'Removing node_modules from git history'\ngit gc\ngit push origin main --force\n\nWhat git actually does:\nThe first line iterates through all references on the same tree (--tree-filter) as HEAD (your current branch), running the command rm -rf node_modules. This command deletes the node_modules folder (-r, without -r, rm won't delete folders), with no prompt given to the user (-f). The added --prune-empty deletes useless (not changing anything) commits recursively.\nThe second line deletes the reference to that old branch.\nThe rest of the commands are relatively straightforward." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options mergetool.hideResolved" }, { "role": "assistant", "content": "During a merge, Git will automatically resolve as many conflicts as\npossible and write the MERGED file containing conflict markers around\nany conflicts that it cannot resolve; LOCAL and REMOTE normally\nrepresent the versions of the file from before Git’s conflict\nresolution. This flag causes LOCAL and REMOTE to be overwritten so\nthat only the unresolved conflicts are presented to the merge tool. Can\nbe configured per-tool via the mergetool.<tool>.hideResolved configuration variable. Defaults to false ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is it possible to include a file in your .gitconfig\n\nI'd like to include a file in my .gitconfig that has my github settings - is this possible?\nCan I do something like this:\n[core]\n include = /path/to/file" }, { "role": "assistant", "content": "Git (1.7.10+) now supports this syntax in .gitconfig:\n[include]\n path = /path/to/file\n\nSee here for a detailed description of the git change and its edge cases.\nBy the way, a couple of subtleties worth pointing out:\n\nEnvironment-variable expansion, e.g. $HOME, is not supported. (Expansion of ~ appeared in Git 1.7.10.2.)\nIf a relative path is specified, then it is relative to the .gitconfig file that has the [include] statement. This works correctly even across chained includes -- e.g. ~/.gitconfig can have:\n[include]\n path = subdir/gitconfig\n\nand subdir/gitconfig can have:\n[include]\n path = nested_subdir/gitconfig\n\n... which will cause subdir/nested_subdir/gitconfig to be loaded.\nIf git can't find the target file, it silently ignores the error. This appears to be by design." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch" }, { "role": "assistant", "content": "REMOTES The name of one of the following can be used instead\nof a URL as <repository> argument: a remote in the Git configuration file: $GIT_DIR/config , a file in the $GIT_DIR/remotes directory, or a file in the $GIT_DIR/branches directory. All of these also allow you to omit the refspec from the command line\nbecause they each contain a refspec which git will use by default. Named remote in configuration file You can choose to provide the name of a remote which you had previously\nconfigured using git-remote , git-config or even by a manual edit to the $GIT_DIR/config file. The URL of\nthis remote will be used to access the repository. The refspec\nof this remote will be used by default when you do\nnot provide a refspec on the command line. The entry in the\nconfig file would appear like this: [remote \"<name>\"]\n\t\turl = <URL>\n\t\tpushurl = <pushurl>\n\t\tpush = <refspec>\n\t\tfetch = <refspec> The <pushurl> is used for pushes only. It is optional and defaults\nto <URL> . Pushing to a remote affects all defined pushurls or all\ndefined urls if no pushurls are defined. Fetch, however, will only\nfetch from the first defined url if multiple urls are defined. Named file in $GIT_DIR/remotes You can choose to provide the name of a\nfile in $GIT_DIR/remotes . The URL\nin this file will be used to access the repository. The refspec\nin this file will be used as default when you do not\nprovide a refspec on the command line. This file should have the\nfollowing format: URL: one of the above URL formats\n\tPush: <refspec>\n\tPull: <refspec> Push: lines are used by git push and Pull: lines are used by git pull and git fetch .\nMultiple Push: and Pull: lines may\nbe specified for additional branch mappings. Named file in $GIT_DIR/branches You can choose to provide the name of a\nfile in $GIT_DIR/branches .\nThe URL in this file will be used to access the repository.\nThis file should have the following format: <URL>#<head> <URL> is required; #<head> is optional. Depending on the operation, git will use one of the following\nrefspecs, if you don’t provide one on the command line. <branch> is the name of this file in $GIT_DIR/branches and <head> defaults to master . git fetch uses: refs/heads/<head>:refs/heads/<branch> git push uses: HEAD:refs/heads/<head>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "SSL certificate rejected trying to access GitHub over HTTPS behind firewall\nI'm stuck behind a firewall, so I have to use HTTPS to access my GitHub repository. I'm using Cygwin 1.7.7 on Windows XP.\nI've tried setting the remote to https://[email protected]/username/ExcelANT.git, but pushing prompts for a password, but it doesn't do anything once I've entered it.\nhttps://username:<password>github.com/username/ExcelANT.git and cloning the empty repository from scratch, but each time it gives me the same error:\n\nerror: SSL certificate problem, verify that the CA cert is OK. Details:\nerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://github.com/username/ExcelANT.git/info/refs\n\nTurning on GIT_CURL_VERBOSE=1 gives me\n\n* About to connect() to github.com port 443 (#0)\n* Trying 207.97.227.239... * successfully set certificate verify locations:\n* CAfile: none\nCApath: /usr/ssl/certs\n* SSL certificate problem, verify that the CA cert is OK. Details:\nerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed\n* Expire cleared\n* Closing connection #0\n* About to connect() to github.com port 443 (#0)\n* Trying 207.97.227.239... * successfully set certificate verify locations:\n* CAfile: none\nCApath: /usr/ssl/certs\n* SSL certificate problem, verify that the CA cert is OK. Details:\nerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed\n* Expire cleared\n* Closing connection #0\nerror: SSL certificate problem, verify that the CA cert is OK. Details:\nerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://github.com/username/ExcelANT.git/info/refs\n\nfatal: HTTP request failed\n\nIs this a problem with my firewall, Cygwin or what?\nI hadn't set the HTTP proxy in the Git configuration. However, it's an ISA server that needs NTLM authentication, not basic, so unless anyone knows how to force Git to use NTLM, I'm scuppered." }, { "role": "assistant", "content": "The problem is that you do not have any of certificate authority (CA) certificates installed on your system. And these certificates cannot be installed with Cygwin's setup.exe.\nInstall Net/ca-certificates package in Cygwin (thanks dirkjot)\nThere are two solutions:\n\nActually install root certificates. The curl guys extracted the certificates from Mozilla for you.\n\ncacert.pem file is what you are looking for. This file contains more than 250 CA certificates (don't know how to trust this number of people). You need to download this file, split it to individual certificates put them to /usr/ssl/certs (your CApath) and index them.\nHere is how to do it. With Cygwin setup.exe install the curl and OpenSSL packages.\nExecute:\n<!-- language: lang-bash -->\n\n $ cd /usr/ssl/certs\n $ curl http://curl.haxx.se/ca/cacert.pem |\n awk '{print > \"cert\" (1+n) \".pem\"} /-----END CERTIFICATE-----/ {n++}'\n $ c_rehash\n\nImportant: In order to use c_rehash you have to install openssl-perl too.\n\nIgnore SSL certificate verification.\nWARNING: Disabling SSL certificate verification has security implications. Without verification of the authenticity of SSL/HTTPS connections, a malicious attacker can impersonate a trusted endpoint (such as GitHub or some other remote Git host), and you'll be vulnerable to a man-in-the-middle attack. Be sure you fully understand the security issues and your threat model before using this as a solution.\nenv GIT_SSL_NO_VERIFY=true git clone https://github..." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker gitrevisions" }, { "role": "assistant", "content": "Specifying revisions and ranges for Git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Where do I find the project ID for the GitLab API?\n\nI use GitLab on their servers. I would like to download my latest built artifacts (build via GitLab CI) via the API like this:\ncurl --header \"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK\" \"https://gitlab.com/api/v3/projects/1/builds/8/artifacts\"\n\nWhere do I find this project ID? Or is this way of using the API not intended for hosted GitLab projects?" }, { "role": "assistant", "content": "I just found out an even easier way to get the project id: just see the HTML content of the gitlab page hosting your project. There is an input with a field called project_id, e.g:\n<input type=\"hidden\" name=\"project_id\" id=\"project_id\" value=\"335\" />" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %h" }, { "role": "assistant", "content": "abbreviated commit hash" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to switch to a new remote git repository\n\nI've recently cloned a repo to my local drive, but now I'm trying to push all changes to a complete new repo. However, git keeps telling me that permission is denied, and that's because it's trying to push to the originally-cloned repo.\nDETAILS:\nI originally cloned from https://github.com/taylonr/intro-to-protractor (i.e. based on a Pluralsight course at https://app.pluralsight.com/library/courses/protractor-introduction/table-of-contents ) .\nNow that I've completed the course, I'd like to push my finalized code up to my own git repo (which I just created on github): \nhttps://github.com/robertmazzo/intro-to-protractor\nWhen I use the following git command: \n\ngit remote add origin https://github.com/robertmazzo/intro-to-protractor.git\n\nit tells me remote origin already exists , which I guess is fine because I already created it on github.com.\nHowever, when I push my changes up I'm getting an exception.\n\ngit push origin master\n\nremote: Permission to taylonr/intro-to-protractor.git denied to robertmazzo.\nfatal: unable to access 'https://github.com/taylonr/intro-to-protractor.git/':\nThe requested URL returned error: 403\nSo I'm investigating how I can switch to my new repository, but this is exactly where my issue is. I cannot figure this part out." }, { "role": "assistant", "content": "To change your current origin to a new one, use:\ngit remote set-url origin <url>\n\nSource:\nhttps://help.github.com/articles/changing-a-remote-s-url/" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch resolve" }, { "role": "assistant", "content": "This can only resolve two heads (i.e. the current branch\nand another branch you pulled from) using a 3-way merge\nalgorithm. It tries to carefully detect criss-cross\nmerge ambiguities. It does not handle renames." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab CI pipeline - continue to next stage only on a certain condition\n\nI am trying to build a Gitlab pipeline that is made up of 4 jobs. The stages I have are:\nstages:\n- compare\n- build\n- test\n- deploy\n\nThe compare stage is taking a dump from an API on another server, comparing it to the same dump from the last successful pipeline run (it's made available as an artifact) then comparing the two.\nIf there is any difference I would like the pipeline to move onto the next stage, if there is no difference then I would like it to exit gracefully. \nI have it working but rather than exiting gracefully if there are no differences it fails and the pipeline is marked as failed, here is how it looks.\n\nHere is the important code from my .gitlab-ci.yaml (with some identifying information removed )\nGet_inventory_dump:\n stage: compare \n only:\n - schedules\n script: \n - 'curl -k --output \"previous-inventory.json\" --header \"PRIVATE-TOKEN: $user_token\" \"https://url/to/get/artifact/from/last/successful/run\"'\n - python3 auto_config_scripts/dump_device_inventory_api_to_json.py -p $pass -o /inventory.json -u https://url/for/inventory/dump -y\n - /usr/bin/cmp previous-inventory.json inventory.json && echo \"No Change in inventory since last successful run\" && exit 1 || echo \"Inventory has changed since last run, continue\" && exit 0\n artifacts:\n when: on_success\n expire_in: 4 weeks\n paths:\n - inventory.json\n\nGenerate_icinga_config:\n stage: build\n only:\n - schedules\n when: on_success\n script: \n\nEverything is behaving as I would expect but I feel like there is a better way to do this. \nIs there a way, if the comparison is the same to simply skip the next stages of the pipeline but still have the pipeline completed as 'passed' rather than 'failed'?" }, { "role": "assistant", "content": "There are two solutions I can think of. Unfortunately, they either come slightly confusing UI behavior or you have to adapt all jobs.\nJob attributes like only or changes are only concerned with the state of or the files of the git repository (see https://docs.gitlab.com/ee/ci/yaml/) and therefore not of use here as the file is only created during CI and not part of the repository.\nSolution 1: You can allow_failure: true to the first job. This will mark the pipeline as successful despite the job failing and subsequent jobs will not be executed as the first job did not succeed. The drawback is that when you investigate the pipeline there will be an exclamation mark instead of a green check for this job.\nSolution 2: Instead of failing the first job when there are no changes the inventory.json file is removed. And all subsequent jobs directly terminate with exit code 0 when the file doesn't exist. Note that this only works because inventory.json is marked as an artifact." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-revert - Revert some existing commits -S[<keyid>] --gpg-sign[=<keyid>] --no-gpg-sign" }, { "role": "assistant", "content": "GPG-sign commits. The keyid argument is optional and\ndefaults to the committer identity; if specified, it must be\nstuck to the option without a space. --no-gpg-sign is useful to\ncountermand both commit.gpgSign configuration variable, and\nearlier --gpg-sign ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Export a repository from a Gitlab server to another Gitlab server\n\nJust installed a fresh new 6.8 Gitlab on a brand new high performance server.\nBefore considering to forget my repositories history (comments, issues, etc...), do one know of a way to export a repository data from a Gitlab server to another Gitlab Server ?\nI just failed to found anything on the documentation for exporting/migrating the whole project data (not just the git repository and its wiki)." }, { "role": "assistant", "content": "For GitLab versions >= 8.9 (released in June 2016) you can use the built-in export and import project feature.\nPlease not that for the existing installations of GitLab, this option has to be enabled in the application settings (URL: /admin/application_settings) under 'Import sources'. You have to be a GitLab admin user to enable and use the import functionality.\nHere is the feature complete documentation: https://gitlab.com/help/user/project/settings/import_export.md" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -b --ignore-space-change" }, { "role": "assistant", "content": "Ignore changes in amount of whitespace. This ignores whitespace\nat line end, and considers all other sequences of one or\nmore whitespace characters to be equivalent." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary" }, { "role": "assistant", "content": "SYNOPSIS *" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "XCode source control: view changes for one file\nIs it possible to view a \"timeline\" (history) for a selected file for like 50 commits? I mean changes made to this particular file and and view commits when they were made and users who changed them? I know Xcode got some powerful version control features, I just can not find this one." }, { "role": "assistant", "content": "What it sounds like you want is the \"Blame View\", if we were on the terminal you could write git blame <file-name> to see the commit/time/and user for every single line of a particular file. In Xcode you can accomplish the same thing by activating the blame view. I've posted a picture to show you where the Blame View button resides. From there you should be all set." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "heroku: src refspec master does not match any\nI'm hosting on Heroku. When I push:\ngit push master Heroku\n\nI get the error:\nerror: src refspec master does not match any.\nerror: failed to push some refs to '[email protected]: etc ...'" }, { "role": "assistant", "content": "This is work for me:-\ngit push heroku HEAD:master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitignore - Specifies intentionally untracked files to ignore" }, { "role": "assistant", "content": "DESCRIPTION A gitignore file specifies intentionally untracked files that\nGit should ignore.\nFiles already tracked by Git are not affected; see the NOTES\nbelow for details. Each line in a gitignore file specifies a pattern.\nWhen deciding whether to ignore a path, Git normally checks gitignore patterns from multiple sources, with the following\norder of precedence, from highest to lowest (within one level of\nprecedence, the last matching pattern decides the outcome): Patterns read from the command line for those commands that support\nthem. Patterns read from a .gitignore file in the same directory\nas the path, or in any parent directory (up to the top-level of the working\ntree), with patterns in the higher level files being overridden by those in\nlower level files down to the directory containing the file. These patterns\nmatch relative to the location of the .gitignore file. A project normally\nincludes such .gitignore files in its repository, containing patterns for\nfiles generated as part of the project build. Patterns read from $GIT_DIR/info/exclude . Patterns read from the file specified by the configuration\nvariable core.excludesFile . Which file to place a pattern in depends on how the pattern is meant to\nbe used. Patterns which should be version-controlled and distributed to\nother repositories via clone (i.e., files that all developers will want\nto ignore) should go into a .gitignore file. Patterns which are\nspecific to a particular repository but which do not need to be shared\nwith other related repositories (e.g., auxiliary files that live inside\nthe repository but are specific to one user’s workflow) should go into\nthe $GIT_DIR/info/exclude file. Patterns which a user wants Git to\nignore in all situations (e.g., backup or temporary files generated by\nthe user’s editor of choice) generally go into a file specified by core.excludesFile in the user’s ~/.gitconfig . Its default value is\n$XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either not set or\nempty, $HOME/.config/git/ignore is used instead. The underlying Git plumbing tools, such as git ls-files and git read-tree , read gitignore patterns specified by command-line options, or from\nfiles specified by command-line options. Higher-level Git\ntools, such as git status and git add ,\nuse patterns from the sources specified above." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Differences between Git-scm, msysGit & Git for Windows\nWhat is the difference between git-scm (downloaded from git-scm.com) and msysGit (hosted on Google Code, Github, and probably others)? They both seem pretty similar, and even though I have git-scm, I have applied fixes specified for msysGit and they seem to work fine.\nAlso, which one, if either, is Git for Windows, and are both called Git Bash, or do both have the Git Bash shell, or only one of the two?" }, { "role": "assistant", "content": "The website git-scm.com is the official website for Git, the version control software. There is no “Git-SCM”, that’s just the URL of the source control management (SCM) software—the name is just Git. Originally written for Linux, the original Git software is only available as a source that doesn’t compile easily on Windows.\n\nIf you are just interested in installing Git on Windows, then you can stop reading here and just download a Windows build from the official website.\n\nGit for Windows\nGit for Windows is the project dedicated to building native builds of Git for Windows. The Windows releases are available for download on the official Git website, they come as 32-bit and 64-bit builds.\nGit for Windows is built on top of MSYS2 (a part of MinGW) which provides a minimal unix-like shell environment which is used to run all the components of Git which are not written in native code (a lot of Git is written as shell scripts). In order to build Git with MSYS2, the project group has a special “Git for Windows SDK” which is basically the whole build environment needed to build Git on Windows, and comes with everything you need to start working on Git itself.\nThe project maintains its own fork of Git which is kept up to date with the original Git project but contains a set of patches necessary to build it on Windows. Git for Windows releases are usually released with a short delay after the official version is released (although versions are sometimes skipped).\nmsysGit\nPrior to Git version 2, the Git for Windows binaries were released by the project called msysGit, which is the predecessor of the Git for Windows project. The project was retired on August 18, 2015 in favor to launch the Git for Windows project with the rebuilt Git for Windows SDK development environment. The new project was mostly started with the same team.\nWhile many people thought of msysGit as the name of the Git binaries, that was actually the name of the development environment they created. It was based on MSYS, the older and kind-of outdated version before MSYS2 was started fresh. The bad state of MSYS was one of the reasons why the Git for Windows project was started with a completely revamped build environment.\nThe project essentially released three things: msysGit, Git for Windows, and a portable Git for Windows. The msysGit installer would install and set up the development environment required to build Git on Windows, just like the Git for Windows SDK does now. Git for Windows was an installer that would install Git on a Windows machine, and the portable Git for Windows were just the binaries you wouldn’t have to install. Note that all their releases were released as “preview” builds, meaning that they would not be fully supported releases. Despite that, the project was very mature and the releases were very stable and the de-facto best way to set up Git on Windows.\nGit Bash\nAs mentioned above, a lot of Git is written as shell scripts. In order to execute those scripts, Git for Windows uses Bash that comes bundled with MSYS2 (so Bash works as an interpreter for it).\nGit Bash commonly refers to the shortcut the Git for Windows installer creates. It launches a full featured console window running Bash, so you can use Git as well as a set of common command line tools or Unix programs (like less, awk, grep, or even the text editor vim). Especially for less experienced users, Git Bash is the common way to interact with Git, although you could easily use it from more Windows-centric environments like PowerShell.\nStarting with Git version 2, Git Bash will by default launch in MinTTY, a terminal emulator which comes with MSYS2, making it easily usable even for users not accustomed to a console experience.\nIt’s also useful to know that Git Bash will always work even if you decided not to add any Git executables to your PATH during the setup of Git for Windows. However, my personal recommendation is to add the Git executable (just the Git executable, choosing the option “Use Git from the Windows Command Prompt” during setup) to the PATH. That way, you can work with Git from other shells (cmd.exe or PowerShell), and other programs can access it too (e.g. many libraries or even IDE integrations expect a Git executable in the PATH to interact with Git repositories)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Do I need Git to use Github in JetBrains IntelliJ IDEA?\n\nJetBrains IntelliJ IDEA has 2 plugins: Git and Github. Do I need to install Git from http://git-scm.com on my local windows machine in order to upload my files to GitHub through IntelliJ IDEA?" }, { "role": "assistant", "content": "I just came up against the same problem.\nIf you choose not to do the full PATH (environment variable) integration when install git (on Windows) you'll need to tell IntelliJ where to find git.cmd; you can do this in\nSettings > Project Settings > Version Control > VCSs > Git\n\nExample in my case it was portable git looks like this on windows\n\nC:\\Users\\user\\AppData\\Local\\GitHub\\PortableGit_d7effa1a4a322478cd29c826b52a0c118ad3db11\\cmd\\git.exe" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git run shell command for each commit\nI would like to walk through a range of commits and perform a shell command on each. If the command fails, I would like the walk to stop, otherwise keep going. I have looked at filter-branch, but I don't want to re-write the commits, just check them out. for-each-ref does not seem to allow you to specify a range to act on.\nMy specific problem is that I created a bunch of commits and I would like to ensure that each commit is buildable. I would like to do something like:\ngit foreach origin/master..master 'git submodule update && make clean && make'\n\nI could of course write a shell script to do this, but it seems like the sort of thing that git might have a nice way to do." }, { "role": "assistant", "content": "You can use interactive rebase with an exec option.\ngit rebase -i --exec <build command> <first sha you want to test>~\n\n\n--exec <cmd> Append exec <cmd> after each line creating a commit in the final history. <cmd> will be interpreted as one or more shell\ncommands.\nReordering and editing commits usually creates untested intermediate\nsteps. You may want to check that your history editing did not break\nanything by running a test, or at least recompiling at intermediate\npoints in history by using the exec command (shortcut x).\nThe interactive rebase will stop when a command fails (i.e. exits with\nnon-0 status) to give you an opportunity to fix the problem." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is there a way to push changes with a GitHub action?\n\nThis question refers to this: https://github.com/features/actions\nI have written a GitHub action to build my code and create a production bundle. I'd like to have that included into my repository by committing the changes to origin/master. This seems like an obvious feature for GitHub actions to have but I can't find it anywhere. How do I commit changes with a GitHub action and push them?" }, { "role": "assistant", "content": "Update: Please see the following question/answer for full details about how to push changes back to the remote.\nPush to origin from GitHub action\nAn alternative option is create-pull-request action. It will automatically commit changes to a new branch and raise a pull request for you to review the changes. I wrote a detailed explanation about it as an answer to another question here:\nhttps://stackoverflow.com/a/58004257/11934042" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Meaning of Git checkout double dashes\nWhat is the meaning of the double dashes before the file name in this git command?\ngit checkout --ours -- path/to/file.txt\ngit checkout --theirs -- path/to/file.txt\n\nAre they mandatory? Is it equivalent to\ngit checkout --ours path/to/file.txt\ngit checkout --theirs path/to/file.txt" }, { "role": "assistant", "content": "Suppose I have a file named path/to/file.txt in my Git repository, and I want to revert changes on it.\ngit checkout path/to/file.txt\n\nNow suppose that the file is named master...\ngit checkout master\n\nWhoops! That changed branches instead. The -- separates the tree you want to check out from the files you want to check out.\ngit checkout -- master\n\nIt also helps us if some freako added a file named -f to our repository:\ngit checkout -f # wrong\ngit checkout -- -f # right\n\nThis is documented in git-checkout: Argument Disambiguation." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options remote.<name>.proxyAuthMethod" }, { "role": "assistant", "content": "For remotes that require curl (http, https and ftp), the method to use for\nauthenticating against the proxy in use (probably set in remote.<name>.proxy ). See http.proxyAuthMethod ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-credential-cache" }, { "role": "assistant", "content": "Helper to temporarily store passwords in memory" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-grep - Print lines matching a pattern --column" }, { "role": "assistant", "content": "Prefix the 1-indexed byte-offset of the first match from the start of the\nmatching line." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to override a gitlab group or project CD/CI variable in .gitlab-ci.yml?\n\nI have a project in Gitlab having defined variables in the Gitlab UI in the project group folder. On a new branch of one of my git repositories I need to override some of these variables.\nvariables:\n GLOBALLY_DEFINED_VARIABLE: \"branch_specific_value\"\n\nBut in a concrete build the value is still the original one from the global variable.\nHow do I get the value inside the .gitlab_ci.yml file to win over the project value?\nI know, the docs (https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence) say that variable in the yml have lower precedence, but this does not make any sense (the yml is inside a project, so it normally must have higher precedence than the project). Is there any way to make my yml file win? Note: I do not want to rule out all variables! Most of them are still needed, I just need to overwrite some.\nMy use case is this: the new branch prepares the code base to be able to run on a new webserver. So this branch obviously needs to have variables storing paths and similar of the new server. But of course the main branches of all repositories should still build to the current (old) live server until the migration on the main-new-server branch is finished and tested. So on this preparation branch I must be able to override the old-server settings. The old settings are stored in project group variables because they are the same for many repositories, but now need to change in a single branch of a single repository." }, { "role": "assistant", "content": "You could set the variable value from within your script or before_script:\nvariables:\n LOCALLY_DEFINED_VARIABLE: \"branch_specific_value\"\nbefore_script:\n - GLOBALLY_DEFINED_VARIABLE=$LOCALLY_DEFINED_VARIABLE" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order <paths>" }, { "role": "assistant", "content": "Commits modifying the given <paths> are selected." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --ignore-submodules[=<when>]" }, { "role": "assistant", "content": "Ignore changes to submodules in the diff generation. <when> can be\neither \"none\", \"untracked\", \"dirty\" or \"all\", which is the default.\nUsing \"none\" will consider the submodule modified when it either contains\nuntracked or modified files or its HEAD differs from the commit recorded\nin the superproject and can be used to override any settings of the ignore option in git-config or gitmodules . When\n\"untracked\" is used submodules are not considered dirty when they only\ncontain untracked content (but they are still scanned for modified\ncontent). Using \"dirty\" ignores all changes to the work tree of submodules,\nonly changes to the commits stored in the superproject are shown (this was\nthe behavior until 1.7.0). Using \"all\" hides all changes to submodules." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab-runner failed to remove permission denied\n\nI'm setting up a CI/CD pipeline with Gitlab. I've installed gitlab-runner on a Digital Ocean Ubuntu 18.04 droplet and gave permissions in /etc/sudoers to the gitlab-runner as:\ngitlab-runner ALL=(ALL:ALL)ALL\n\nThe first commit to the associated repository correctly build the docker-compose (the app itself is Django+postgres), but following commits are not able to clean previous builds and fail:\nRunning with gitlab-runner 12.8.0 (1b659122)\non ubuntu-s-4vcpu-8gb-fra1-01 52WypZsE\nUsing Shell executor...\n00:00\nRunning on ubuntu-s-4vcpu-8gb-fra1-01...\n00:00\nFetching changes with git depth set to 50...\n00:01\n Reinitialized existing Git repository in /home/gitlab-runner/builds/52WypZsE/0/lorePieri/djangocicd/.git/\n From https://gitlab.com/lorePieri/djangocicd\n * [new ref] refs/pipelines/120533457 -> refs/pipelines/120533457\n 0072002..bd28ba4 develop -> origin/develop\n Checking out bd28ba46 as develop...\n warning: failed to remove app/staticfiles/admin/img/selector-icons.svg: Permission denied\n warning: failed to remove app/staticfiles/admin/img/search.svg: Permission denied\n warning: failed to remove app/staticfiles/admin/img/icon-alert.svg: Permission denied\n warning: failed to remove app/staticfiles/admin/img/tooltag-arrowright.svg: Permission denied\n warning: failed to remove app/staticfiles/admin/img/icon-unknown-alt.svg: Permission denied\n\nThis is the relevant portion of the .gitlab-ci.yml file:\nimage: docker:latest\nservices:\n - docker:dind\n\nstages:\n - test\n - deploy_staging\n - deploy_production\n\nstep-test:\n stage: test\n before_script:\n - export DYNAMIC_ENV_VAR=DEVELOP\n only:\n - develop\n tags:\n - develop\n script:\n - echo running tests in $DYNAMIC_ENV_VAR\n - sudo apt-get install -y python-pip\n - sudo pip install docker-compose\n - sudo docker image prune -f\n - sudo docker-compose -f docker-compose.yml build --no-cache\n - sudo docker-compose -f docker-compose.yml up -d\n - echo do tests now\n - sudo docker-compose exec -T web python3 -m coverage run --source='.' manage.py test\n\n...\n\nWhat I've tried:\nusermod -aG docker gitlab-runner\nsudo service docker restart" }, { "role": "assistant", "content": "The best solution for me was adding\npre_clone_script = \"sudo chown -R gitlab-runner:gitlab-runner .\"\n\ninto /etc/gitlab-runner/config.toml\nEven if you won't have permissions after a previous job it'll set correct permissions before cleaning up the workdir and cloning the repo." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I change a git commit message in Bitbucket?\nI need to change an old git commit message in Bitbucket. I tried git rebase -i and reworded my message, but when I pulled and committed it just kept the old message in Bitbucket and merged my changes in." }, { "role": "assistant", "content": "It's basically 4 step process. But a bit risky if multiple team member are working on the same branch and have their own copies. (If you are the only one working on it, go for it)\nThis git manual explains it beautifully: Amending older or multiple commit messages\n\ngit rebase -i HEAD~X (X=No of commit messages you want to change)\nAbove command will open git file in editor. There replace text 'pick' with 'reword' and save the file.\nIt will open editor for every commit one by one, there you again change the commit message.\nAt the end: git push -f" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why doesn't my bash prompt update?\nI'm new to git and I'm trying to add the current git branch to my already existing prompt, which is defined as follows :\nRESET=\"\\[\\017\\]\"\nNORMAL=\"\\[\\033[0m\\]\"\nRED=\"\\[\\033[31;1m\\]\"\nYELLOW=\"\\[\\033[33;1m\\]\"\nWHITE=\"\\[\\033[37;1m\\]\"\nSMILEY=\"${WHITE}:)${NORMAL}\"\nFROWNY=\"${RED}:(${NORMAL}\"\nSELECT=\"if [ \\$? = 0 ]; then echo \\\"${SMILEY}\\\"; else echo \\\"${FROWNY}\\\"; fi\"\n\nexport PS1=\"${RESET}${YELLOW}\\u@\\h${NORMAL} \\`${SELECT}\\` ${YELLOW}\\w $(__git_ps1) >${NORMAL} \"\n\nI tried it (by sourcing my .bashrc file again) and it seemed to work, but then I went on another branch and it did not update. How can I make sure the $(__git_ps1) is not cached?" }, { "role": "assistant", "content": "You need a backslash on the $ so it isn't expanded immediately. (Compare to the `...`, which is a different way of writing $(...).)\nexport PS1=\"${RESET}${YELLOW}\\u@\\h${NORMAL} \\`${SELECT}\\` ${YELLOW}\\w \\$(__git_ps1) >${NORMAL} \"\n\nI would agree with @MikeSep about using single quotes, but it's actually a bit more optimal to let the colors and such be substituted immediately. Not necessary, just somewhat better. That said, it is easier to understand what's going on if you use the single quotes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub Atom - Remove the center line in the editor\n\nI just downloaded the GitHub Atom Editor and I'm customizing it.\nBut I couldn't remove the line that is the middle of the editor.\n\nAnyone help me out how to remove that line?" }, { "role": "assistant", "content": "This line is provided by the wrap-guide package. You have the following options to remove the line:\nOption 1\nDisable the wrap-guide package. Go to Atom > Preferences > Packages, type \"wrap\" into the search box, then wait for the wrap-guide package to show up under Core Packages, and click the Disable button there.\nOption 2\nOr add the following to your user stylesheet. Use Atom > Open Your Stylesheet to open the styles.less file in the editor, then add the following:\natom-text-editor::shadow {\n .wrap-guide {\n visibility: hidden;\n }\n}\n\nOnce you save the file, the line will be gone.\nMore info can be found here: https://discuss.atom.io/t/vertical-line-in-editor/2717\nUpdate 2015-06-28 Updated selector due to updates in the Atom style classes. The above now works in Atom 1.0+." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub Clone with OAuth Access Token\nInside a script I am trying to clone a GitHub repository with an OAuth token.\nAccording to this tutorial:\nhttps://github.com/blog/1270-easier-builds-and-deployments-using-git-over-https-and-oauth\nI should be able to build a command for it like this:\ngit clone https://<token>@github.com/owner/repo.git\n\nIf I try this manually with a proper access token, it still asks for my password.\nIf I try it on the commandline I am simply getting a repository not found error.\nThe article is from 2012 and I cannot find any API documentation for this. So I am wondering if this still works." }, { "role": "assistant", "content": "Just use the HTTPS address to clone with the key as the user, so:\ngit clone https://oauth2:[email protected]/username/repo.git\n\nor\ngit clone https://username:[email protected]/username/repo.git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab repository vs project vs submodule\n\nI started exploring Gitlab for version control management and I got an issue at the first step itsself. When ever I create a project its creating a new repository. I have few webapplications which are independent to each other. In that case do I need to use different repository for every project.\nWhat I am looking for is what is what and when to use what but not able to find what is repository and what is project in gitlab website as well as through other sources as well.\nAlso I came across a term submodule, when can it be used. Can I create one global project and have all the webapplications as different submodules.\nCan any one please help me in understanding the difference between those 3 and when to use what based on their intended way of usage. Also please help me by pointing to a good learning site where I can get the information of doing basic version control operations in gitlab. \nThanks." }, { "role": "assistant", "content": "Gitlab manages projects: a project has many features in addition of the Git repo it includes:\n\nissues: powerful, but lightweight issue tracking system.\nmerge requests: you can review and discuss code before it is merged in the branch of your code.\nwiki: separate system for documentation, built right into GitLab\nsnippets: Snippets are little bits of code or text.\n\nSo fear each repo you create, you get additional features in its associated project.\nAnd you can manage users associated to that project.\nSee GitLab documentation for more.\nThe Git repo and Git submodule are pure Git notions.\nIn your case, a submodule might not be needed, unless you want a convenient way to remember the exact versions of different webapp repo, recorded in one parent repo.\nBut if that is the case, then yes, you can create one global project and have all the webapplications as different submodules.\nEach of those submodules would have their own GitLab project (and Git repo)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git grep by file extensions\nI know that, if I wanted to grep for a pattern only on files with certain extensions, I could do this:\n// searches recursively and matches case insensitively in only javascript files\n// for \"res\" from the current directory\ngrep -iIr --include=*.js res ./\n\nI've been trying to search for a way to do this via git grep as well (to take advantage of git grep's speed from the indexes it stores with its tree), but to no avail. I saw here that excluding certain file types is not possible." }, { "role": "assistant", "content": "Yes, for example:\ngit grep res -- '*.js'" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git equivalents of most common Mercurial commands?\nI've been using Mercurial but would like to do a quick demo of Git.\nWhat are the Git equivalents of:\nhg init . # start a project in the current directory\nhg addremove # look for any added or deleted files\nhg commit -m \"comment\" # commit any uncomitted changes\nhg status # what have i changed since the last commit?" }, { "role": "assistant", "content": "The Git-HG rosetta stone is not bad\nThere are a few other gotchas between the two not mentioned there. This list was cribbed from my own blog post when I went the other way (git -> hg).\nHg .hgignore, syntax: glob is the same behaviour as git's .gitignore.\nGit .git/config, ~/.gitconfig, use git-config to modify the values\nHg .hg/hgrc, ~/.hgrc, use hg help -c config\nGit git commit -v<br>\nHg hg diff | less; hg commit\nGit gitk<br>\nHg hg view, or thg from [TortoiseHg][1]\nGit git gui<br>\nHg Mercurial doesn't ship GUI to select changesets, only console hg record command.\nGit git rebase<br>\nHg hg rebase. For git rebase --interactive there's hg histedit, or Mercurial Queues\nGit git push URL ; git remote add origin URL<br>\nHg hg push URL; $EDITOR .hg/hgrc ; [paths] default = URL\nGit gitk, git log origin/master..HEAD<br>\nHg hg outgoing\nGit git format-patch RANGE<br>\nHg hg email -m filename -o\nGit git add . ; Note the dot\nHg hg add ; No dot needed.\nGit git checkout REVISION-KEY<br>\nHg hg update CHANGESET\n\nJust to fill the blanks, some of the most useful commands from Mercurial:\nHg hg record\nGit git add -p; git commit\nHg hg inc [URL]\nGit No real equivalent. You can only do equivalent of hg pull; hg log -r .:\nHg hg out URL\nGit Please add if you know how.\nFor merge conflict resolution, the hg resolve command in Mercurial has a few options that change the behaviour:\nHg hg resolve -m FILE (marks the file as having been resolved by manually fixing up the conflict problem)\nGit git add FILE\nHg hg resolve -u FILE marks the file as having been unresolved\nGit git reset HEAD FILE to unstage the file\nHg hg resolve -l (lists files with resolved/unresolved conflicts)\nGit git status - files that merged cleanly are added to the index automatically, those that are not have conflicts\nHg hg resolve FILE (after a merge, attempts to re-merge the file)\nGit no equivalent for re-merging that I know of." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options commitBeforeMerge" }, { "role": "assistant", "content": "Shown when git-merge refuses to\nmerge to avoid overwriting local changes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Merge, update, and pull Git branches without using checkouts\nI work on a project that has 2 branches, A and B. I typically work on branch A, and merge stuff from branch B. For the merging, I would typically do:\ngit merge origin/branchB\n\nHowever, I would also like to keep a local copy of branch B, as I may occasionally check out the branch without first merging with my branch A. For this, I would do:\ngit checkout branchB\ngit pull\ngit checkout branchA\n\nIs there a way to do the above in one command, and without having to switch branch back and forth? Should I be using git update-ref for that? How?" }, { "role": "assistant", "content": "The Short Answer\nAs long as you're doing a fast-forward merge, then you can simply use\ngit fetch <remote> <sourceBranch>:<destinationBranch>\n\nExamples:\n# Merge local branch foo into local branch master,\n# without having to checkout master first.\n# Here `.` means to use the local repository as the \"remote\":\ngit fetch . foo:master\n\n# Merge remote branch origin/foo into local branch foo,\n# without having to checkout foo first:\ngit fetch origin foo:foo\n\nWhile Amber's answer will also work in fast-forward cases, using git fetch in this way instead is a little safer than just force-moving the branch reference, since git fetch will automatically prevent accidental non-fast-forwards as long as you don't use + in the refspec.\nThe Long Answer\nYou cannot merge a branch B into branch A without checking out A first if it would result in a non-fast-forward merge. This is because a working copy is needed to resolve any potential conflicts.\nHowever, in the case of fast-forward merges, this is possible, because such merges can never result in conflicts, by definition. To do this without checking out a branch first, you can use git fetch with a refspec.\nHere's an example of updating master (disallowing non-fast-forward changes) if you have another branch feature checked out:\ngit fetch upstream master:master\n\nThis use-case is so common, that you'll probably want to make an alias for it in your git configuration file, like this one:\n[alias]\n sync = !sh -c 'git checkout --quiet HEAD; git fetch upstream master:master; git checkout --quiet -'\n\nWhat this alias does is the following:\n\ngit checkout HEAD: this puts your working copy into a detached-head state. This is useful if you want to update master while you happen to have it checked-out. I think it was necessary to do with because otherwise the branch reference for master won't move, but I don't remember if that's really right off-the-top of my head.\n\ngit fetch upstream master:master: this fast-forwards your local master to the same place as upstream/master.\n\ngit checkout - checks out your previously checked-out branch (that's what the - does in this case).\n\n\nThe syntax of git fetch for (non-)fast-forward merges\nIf you want the fetch command to fail if the update is non-fast-forward, then you simply use a refspec of the form\ngit fetch <remote> <remoteBranch>:<localBranch>\n\nIf you want to allow non-fast-forward updates, then you add a + to the front of the refspec:\ngit fetch <remote> +<remoteBranch>:<localBranch>\n\nNote that you can pass your local repo as the \"remote\" parameter using .:\ngit fetch . <sourceBranch>:<destinationBranch>\n\nThe Documentation\nFrom the git fetch documentation that explains this syntax (emphasis mine):\n\n<refspec>\nThe format of a <refspec> parameter is an optional plus +, followed by the source ref <src>, followed by a colon :, followed by the destination ref <dst>.\nThe remote ref that matches <src> is fetched, and if <dst> is not empty string, the local ref that matches it is fast-forwarded using <src>. If the optional plus + is used, the local ref is updated even if it does not result in a fast-forward update.\n\nSee Also\n\nGit checkout and merge without touching working tree\n\nMerging without changing the working directory" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rm - Remove files from the working tree and from the index" }, { "role": "assistant", "content": "DESCRIPTION Remove files matching pathspec from the index, or from the working tree\nand the index. git rm will not remove a file from just your working\ndirectory. (There is no option to remove a file only from the working\ntree and yet keep it in the index; use /bin/rm if you want to do\nthat.) The files being removed have to be identical to the tip of the\nbranch, and no updates to their contents can be staged in the index,\nthough that default behavior can be overridden with the -f option.\nWhen --cached is given, the staged content has to\nmatch either the tip of the branch or the file on disk,\nallowing the file to be removed from just the index. When\nsparse-checkouts are in use (see git-sparse-checkout ), git rm will only remove paths within the sparse-checkout patterns." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git - Cherry pick a single commit for pull request\n\nI might not have the terminology down yet.\nI made file to be added to a open project on git.\nI forked the project.\nI made some changes and my last commit is the file I want to request to the project and not the small changes I made before hand.\nWhen I go to github site and make pull request, I get all the commits before the one I want (which is last one of a file).\nI don't want to submit all of the other commits, because I don't think it's necessary for the project. Just my own changes.\nWhat do I do?\nShould I just make another res, or attach the file singularly and submit?" }, { "role": "assistant", "content": "You need to create a fresh branch from the remote HEAD, cherry-pick the commit to that branch, push the branch to your repo on GitHub, then create a pull request.\ngit checkout -b mybranch\ngit fetch upstream\ngit reset --hard upstream/master\ngit cherry-pick <commit-hash>\ngit push origin mybranch:mybranch" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options core.fsyncMethod" }, { "role": "assistant", "content": "A value indicating the strategy Git will use to harden repository data\nusing fsync and related primitives. fsync uses the fsync() system call or platform equivalents. writeout-only issues pagecache writeback requests, but depending on the\nfilesystem and storage hardware, data added to the repository may not be\ndurable in the event of a system crash. This is the default mode on macOS. batch enables a mode that uses writeout-only flushes to stage multiple\nupdates in the disk writeback cache and then does a single full fsync of\na dummy file to trigger the disk cache flush at the end of the operation. Currently batch mode only applies to loose-object files. Other repository\ndata is made durable as if fsync was specified. This mode is expected to\nbe as safe as fsync on macOS for repos stored on HFS+ or APFS filesystems\nand on Windows for repos stored on NTFS or ReFS filesystems." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why is the Approve button disabled in GitHub \"pull request review\"?\nProblem Background:\nSo far I am the sole owner of a GitHub repo. I committed the code from my system to a branch called release (actually its a tag based on develop branch, if that matters). In GitHub, I created a pull request where base branch is master and compare branch is release. \nBut I am only allowed to comment on review, not allowed to approve. What may be the reason? \nNote: There is no merge conflicts and while creating the pull request the green signal of merging possible was displayed.\n\nHere is how the master branch is protected by me:" }, { "role": "assistant", "content": "If you were the one who has committed the pull request you cannot approve or request changes on this pull request. \nIt's only available when someone else requested such action. \nSo your only option is to comment it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --default-prefix" }, { "role": "assistant", "content": "Use the default source and destination prefixes (\"a/\" and \"b/\").\nThis overrides configuration variables such as diff.noprefix , diff.srcPrefix , diff.dstPrefix , and diff.mnemonicPrefix (see git-config (1))." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary literal" }, { "role": "assistant", "content": "Wildcards in the pattern such as * or ? are treated\nas literal characters." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to clone a Github Gist via SSH protocol?\n\nGithub really seems to want us to use the HTTPS protocol to use Gists, for example, they only list the HTTPS url on a Gist page - e.g. https://gist.github.com/donatello/5834862\nIs it possible to clone a Gist using SSH protocol?" }, { "role": "assistant", "content": "Yes, it is possible:\ngit clone [email protected]:5834862.git\n\nJust replace with your own Gist ID of course." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to manage one only key per each git repository?\n\nI use git under two scenarios:\n\nI use some Github repositories.\nI'm currently working with OpenShift, which uses ssh and git for deployment.\n\nFirst, I used ssh-keygen for generating a key which updated at OpenShift site. Such key is stored at ~/.ssh/ and created id_rsa and id_rsa.pub.\nThen I started cloning a repository from Github, I once did ssh-keygen again and started pushing, it worked ok. Then I cloned another repository and started having problems:\nI got problems when cloning to the second repository. Every time I try to push will show something like:\n\nERROR: Permission to diegoaguilar/cursoJava.git denied to diegoaguilar/cursoCannibalCreatures.\n fatal: The remote end hung up unexpectedly\n\nBut as it can be seen diegoaguilar/cursoCannibalCreatures isn't correct as it's another repository.\nI even tried removing such repository directory, and cloning it again, same happened.\nI already got under ~/.ssh:\nconfig:\nHost cursoJava\nHostname github.com\nUser git\nIdentityFile ~/.ssh/id_java\n\nHost cursoCannibalCreatures\nHostname github.com\nUser git\nIdentityFile ~/.ssh/id_cannibal\n\nHost openshift\nHostname openshift.com\nUser git\nIdentityFile ~/.ssh/openshift\n\nAnd so got:\nid_cannibal id_cannibal.pub id_java id_java.pub known_hosts\n\nSomething like id_openshift and id_openshift.pub isn't there but as it's not working, I don't care much now.\nI created such files and they're .pub by ssh-keygen -f <filename> and gave different pass phrases to each. I added the content of the .pub's as deploy keys at each Github repository settings.\nWhat am I doing wrong? How is this supposed to work? And, when working at another machine, how to properly obtain these keys, proof it's me and work transparently? \nEDIT\nOutput of git remote -v:\n\nFor cursoJava repository \n\norigin [email protected]:diegoaguilar/cursoJava.git (fetch)\n origin [email protected]:diegoaguilar/cursoJava.git (push)\n\nFor cursoCannibalCreatures\n\norigin [email protected]:diegoaguilar/cursoCannibalCreatures.git (fetch)\n origin [email protected]:diegoaguilar/cursoCannibalCreatures.git (push)" }, { "role": "assistant", "content": "As mentioned in \"ssh,github,it doesnot work\", the trick is to not use the default id_rsa(.pub) names for your public:private keys (because yo can only define one couple of those), but different names.\nBut that would be only if you were to access those repos as different users\nIn your case, you are accessing the repos with the same users, and one ssh key should be enough.\nSee \"GitHub help\":\n\nThis error means the key you are pushing with is attached to another repository as a deploy key, and does not have access to the repository you are trying to push to.\nTo remedy this, remove the deploy key from the repository, and attach the key to your user account instead.\n\n\nThis is for using GitHub for two different users.\nYou then define a ~/.ssh/config file in which you reference each private keys by their full path:\nHost github1\n HostName github.com\n User git\n IdentityFile ~/.ssh/id_repo1\n\nHost github2\n HostName github.com\n User git\n IdentityFile ~/.ssh/id_repo2\n\nInstead of using [email protected]:user/repo1, you would use:\ngithub1:user/repo1\n\nThat uses the key Host entry 'github1' to reference the user (git), hostname (github.com) and the exact private/public key to use ~/.ssh/id_repo1(.pub)\n\nSo if you have a second repo which use a second key stored as ~/.ssh/id_repo2(.pub), you need to use the entry 'github2' (you can name it as you want) defined above, and then change the url you have for origin:\ngit remote set-url origin github2:user/repo2\n\nThat way, a git push will use the right key (the one for the repo2)\nIf you don't, you will be able to push for one repo (using the default key ~/.ssh/id_rsa(.pub), default name), but you won't be able to push to the second repo, which need a different set of public/private key." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Error \"fatal: invalid branch name: init.defaultBranch =\"\n\nI getting this error when ever I do git clone\nError :-\nfatal: invalid branch name: init.defaultBranch =\nTried to reinstall git (latest)\nStill same error\nOS :- Windows" }, { "role": "assistant", "content": "It would appear that you have experimented with the new (2.28) init.defaultBranch configuration value.\nAssign it a proper value:\ngit config --global init.defaultBranch main" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why does ssh connection to gitlab not work (while http push and clone work fine)?\n\nI run a x86 raring ringtail on a old pc and having installed bitnami gitlab 5.3.\nHere is my error msg when trying to push the first master branch in SSH mode:\nfatal: Could not read from remote repository.\nPlease make sure you have the correct access rights and the repository exists.\n\n(it works in http protocol with the gitlab web dashboard credentials)\n\nI have launched bitnami-installer.run with root user so I think all the files went in /opt instead of /home (this was the good procedure?)\nI didn't have a git user before installing GitLab since I heard it could make a confusion in the .ssh/authorized_keys files and other permissions.\nWhen I run ssh -T [email protected] it says permission denied (public key) but the pub key on my client computer is also in .ssh/authorized_keys?\nauthorized_keys has the proper content also, with for each line:\ncommand= \"/opt/gitlab/apps/\"\n\nI have also noticed that I cannot display the content of authorized_keys file with a sudo -su git nano authorized_keys because:\n\nthe user is not in the sudoers file.\n\nBut sudo /opt/gitlab/apps/gitlab/gitlab-shell/bin/check returns ok for each verification (gitlab api, acces, repo and /home/git/.ssh/authorized_keys file (because i have set in th config.yml gitlab_url to : http://myserver.com/gitlab (local server ip address) instead of http://loopbackaddress.com/gitlab). I have noticed that i have « two versions » of the gitlab-shell directory, one in /opt and one in /home and i don't know if it it is the appropriated demeanor ?\nWhen i try a ssh -Tv it seems the ssh server does not even accept my key, fail to authenticate and return « permission denied » at last.\nAlso nothing special in the /var/log/auth.log files other than sshd[number] : connection closed by IP address.\nThe authorized_keys file path is set to the correct absolute url in the /etc/ssh/sshd_config file (/home/git/.ssh/authorized_keys)\nAnd finally i am unable to debug with « bundle exec bin/rake » since i am not able to make my ubuntu install all the required pacakge to execute bundle.\n\nI am almost sure it's either a simple ssh misconfiguration or something wrong when invoking the command=\"/opt/...../gitlab-shell\" in the authorized_keys file\nPS: using git with HTTP protocole would be enough for my home server but the interest of the gitlab dashboard is to easily add a contributors by filling the ssh key in the web form and using ssh after" }, { "role": "assistant", "content": "I've got the following error trying to clone repo via ssh from freshly installed gitlab:\n\nfatal: Could not read from remote repository.\nPlease make sure you have the correct access rights and the repository\n exists.\n\nSolution was found at https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide#ssh\nCheck ssh log /var/log/auth.log and if you find error:\nUser git not allowed because account is locked\n\nthen edit /etc/shadow and change git:!: to git:*:\nP.S. \nIn my case on CentOS 6.5 it was /var/log/secure and git:!!:" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git config: list all variables and their default values\nSimilar to the MySQL show variables command that shows all variables and not just the ones defined in my.ini, I would like to see a list of all config variables in git along with their default values, and not just those defined in my ~/.gitconfig. \nIs this possible?" }, { "role": "assistant", "content": "Edit Jan 23, 2022\n\ngit config --system -l for system-wide variables (retrieved from installation folder; references)\n\ngit config --global -l for global variables (retrieved from ~/.gitconfig or $XDG_CONFIG_HOME/git/config if the first doesn't exists; references)\n\ngit config --local -l or git config -l for repository variables (retrieved from .git/config; references)\n\n\nAlso note that although on docs it says\n\n--local [...] This is the default behavior.\n\nissuing git config -l --local shows a different result than git config -l, the latter (apparently) showing all the three command outputs merged (tested on Windows)\n\nOld answer\ngit config --global -l for global variables or git config -l for local repository variables\nP.S.: I know have passed 2 years since you posted the question, but I was looking for the same thing and I read this post so I guessed users like me would have wanted a solution to their problem and I posted a reply, even if you probabily have solved your problem long time ago." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker gitprotocol-v2" }, { "role": "assistant", "content": "Git Wire Protocol, Version 2" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database badObjectSha1" }, { "role": "assistant", "content": "(ERROR) An object has a bad sha1." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitlab 8.2.1, How to use cache in .gitlab-ci.yml\n\nI'm trying to use 'cache' in .gitlab-ci.yml (http://doc.gitlab.com/ce/ci/yaml/README.html#cache). My gitlab version is 8.2.1 and my Runner is: \n$ docker exec -it gitlab-runner gitlab-runner -v \ngitlab-runner version 0.7.2 (998cf5d)\n\nSo according to the doc, everything is up to date, but I'm unable to use the cache ;-(. All my files are always deleted. Am I doing something wrong?\nA cache archive is created, but not passed to the next jobs.\nHere is my .gitlab-ci.yml\n$ cat .gitlab-ci.yml\n stages:\n - createcache\n - testcache\n\n createcache:\n type: createcache\n cache:\n untracked: true\n paths:\n - doc/\n script:\n - touch doc/cache.txt\n\n testcache:\n type: testcache\n cache:\n untracked: true\n paths:\n - doc/\n script:\n - find .\n - ls doc/cache.txt\n\nOutput of the job 'createcache'\nRunning on runner-141d90d4-project-2-concurrent-0 via 849d416b5994...\nFetching changes...\nHEAD is now at 2ffbadb MUST BE REVERTED\n[...]\n$ touch doc/cache.txt\n[...]\nArchiving cache...\nINFO[0000] Creating archive cache.tgz ... \nINFO[0000] Done! \n\nBuild succeeded.\n\nOutput of the job 'testcache'\nRunning on runner-141d90d4-project-2-concurrent-0 via 849d416b5994...\nFetching changes...\nRemoving doc/cache.txt\n[...]\n$ ls doc/cache.txt\nls: cannot access doc/cache.txt: No such file or directory\n\nERROR: Build failed with: exit code 1\n\nMy workaround\nMy workaround is to manually untar what's in the /cache directory ... I'm pretty sure that's not the correct way to use cache ...\n$ cat .gitlab-ci.yml\n stages:\n - build\n - test\n - deploy\n\n image: ubuntu:latest\n\n before_script:\n - export CACHE_FILE=`echo ${CI_PROJECT_DIR}/createcache/${CI_BUILD_REF_NAME}/cache.tgz | sed -e \"s|/builds|/cache|\"`\n\n createcache:\n type: build\n cache:\n untracked: true\n paths:\n - doc/\n script:\n - find . | grep -v \".git\"\n - mkdir -p doc\n - touch doc/cache.txt\n\n testcache:\n type: test\n script:\n - env\n - find . | grep -v \".git\"\n - tar xvzf ${CACHE_FILE}\n - ls doc/cache.txt" }, { "role": "assistant", "content": "https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/327\nimage: java:openjdk-8-jdk\n\nbefore_script:\n - export GRADLE_USER_HOME=`pwd`/.gradle\n\ncache:\n paths:\n - .gradle/wrapper\n - .gradle/caches\n\nbuild:\n stage: build\n script:\n - ./gradlew assemble\n\ntest:\n stage: test\n script:\n - ./gradlew check" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-format-patch" }, { "role": "assistant", "content": "Prepare patches for e-mail submission" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options core.worktree" }, { "role": "assistant", "content": "Set the path to the root of the working tree.\nIf GIT_COMMON_DIR environment variable is set, core.worktree\nis ignored and not used for determining the root of working tree.\nThis can be overridden by the GIT_WORK_TREE environment\nvariable and the --work-tree command-line option.\nThe value can be an absolute path or relative to the path to\nthe .git directory, which is either specified by --git-dir\nor GIT_DIR, or automatically discovered.\nIf --git-dir or GIT_DIR is specified but none of\n--work-tree, GIT_WORK_TREE and core.worktree is specified,\nthe current working directory is regarded as the top level\nof your working tree. Note that this variable is honored even when set in a configuration\nfile in a \".git\" subdirectory of a directory and its value differs\nfrom the latter directory (e.g. \"/path/to/.git/config\" has\ncore.worktree set to \"/different/path\"), which is most likely a\nmisconfiguration. Running Git commands in the \"/path/to\" directory will\nstill use \"/different/path\" as the root of the work tree and can cause\nconfusion unless you know what you are doing (e.g. you are creating a\nread-only snapshot of the same index to a location different from the\nrepository’s usual working tree)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-rerere" }, { "role": "assistant", "content": "Reuse recorded resolution of conflicted merges" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "When to use the '--no-ff' merge option in Git\nA Successful Git Branching Model recommends to use --no-ff when merging branches:\n\nThe --no-ff flag causes the merge to always create a new commit\n object, even if the merge could be performed with a fast-forward. This\n avoids losing information about the historical existence of a feature\n branch and groups together all commits that together added the\n feature. […]\nYes, it will create a few more (empty) commit objects, but the gain is\n much bigger that that cost. Unfortunately, I have not found a way to\n make --no-ff the default behavior of git merge yet, but it really\n should be.\n\nUnderstanding the Git Workflow, however, recommends not to use --no-ff:\n\nSo you add a new rule: “When you merge in your feature branch, use\n –-no-ff to force a new commit.” This gets the job done, and you move\n on. […]\nThe --no-ff band-aid, broken bisect, and blame mysteries are all\n symptoms that you’re using a screwdriver as a hammer. […]\n\nBoth approaches seem reasonable for difference scenarios, but what is considered \"good practice?\"\nWhen do you use --no-ff, when do you not, why?" }, { "role": "assistant", "content": "It's really dependent on what you're trying to do. My rule of thumb is that if the merge \"means something\" I use the --no-ff option. When the merge doesn't really mean anything and you might have used a rebase there's no reason to use --no-ff.\nThe thing with git is that it's a very powerful tool, and you can use it in many ways - most of which are not wrong. Asking what's the \"right way\" to do it is like asking what's the right way to paint a picture.\nAt least for me it's an evolving set of ways I like to do it, with frequent discussions in the team of how we want to collaborate on the code - from this we try to derive a kind of \"how it's done here\" standard, but it's just our way of doing it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options diff.<driver>.command" }, { "role": "assistant", "content": "The custom diff driver command. See gitattributes for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters" }, { "role": "assistant", "content": "EXAMPLES Print the object name of the current commit: $ git rev-parse --verify HEAD Print the commit object name from the revision in the $REV shell variable: $ git rev-parse --verify --end-of-options $REV^{commit} This will error out if $REV is empty or not a valid revision. Similar to above: $ git rev-parse --default master --verify --end-of-options $REV but if $REV is empty, the commit object name from master will be printed." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to see code changes after git pull?\nI would like to inspect any code changes after doing a git pull. Currently it's just showing me which files changes. How can I see what code changed?" }, { "role": "assistant", "content": "git log --name-status -2\n\nWill show you the names of the files that changed for the last two commits.\ngit log -p -2\n\nWill show you the changes themselves.\nBefore you pull,\ngit fetch\ngit log --name-status origin/master..\n\nWill show you what commits you are about to retrieve, along with the names of the files." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to change a connection to GitHub from SSH to HTTPS?\n\nI created my first repository in GitHub yesterday. When making the connection I used SSH instead of HTTPS, so I went through a little painful SSH key creation and connection process. At some point I got stuck and the connection failed. I wondered at that moment how I could revert the process I started and begin with a HTTPS connection instead. Happily, today I got the connection working through SSH but I'm wondering about the value of being able to change the type of connection (SSH vs HTTPS) and if there is a way to do it." }, { "role": "assistant", "content": "Assuming your remote is called origin, run\n\ngit remote set-url origin https://...\ngit remote set-url --push origin https://...\n\nYou can view the configured remotes with git remote -v, which should now show your updated URLs.\nSee the documentation for git-remote for more details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options status.aheadBehind" }, { "role": "assistant", "content": "Set to true to enable --ahead-behind and false to enable --no-ahead-behind by default in git-status for\nnon-porcelain status formats. Defaults to true." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --default-prefix" }, { "role": "assistant", "content": "Use the default source and destination prefixes (\"a/\" and \"b/\").\nThis overrides configuration variables such as diff.noprefix , diff.srcPrefix , diff.dstPrefix , and diff.mnemonicPrefix (see git-config (1))." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Stash vs Shelve in IntelliJ IDEA/Netbeans\nI am very unfamiliar with the shelve aspect of Git (EDIT: not an aspect of Git, but rather IntelliJ IDEA feature of shelve).\nIf stash is used to put aside unfinished work what is shelve then? What would you use it for?\nFor example on Update Project (from VCS menu)\n\none will get (in IntelliJ IDEA 2019.2)" }, { "role": "assistant", "content": "git shelve doesn't exist in Git. \nOnly git stash:\n\nwhen you want to record the current state of the working directory and the index, but want to go back to a clean working directory. \nwhich saves your local modifications away and reverts the working directory to match the HEAD commit.\n\nYou had a 2008 old project git shelve to isolate modifications in a branch, but that wouldn't be very useful nowadays.\nAs documented in Intellij IDEA shelve dialog, the feature \"shelving and unshelving\" is not linked to a VCS (Version Control System tool) but to the IDE itself, to temporarily storing pending changes you have not committed yet in changelist.\nNote that since Git 2.13 (Q2 2017), you now can stash individual files too." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-pack-redundant" }, { "role": "assistant", "content": "Find redundant pack files" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options implicitIdentity" }, { "role": "assistant", "content": "Shown when the user’s information is guessed from the\nsystem username and domain name, to tell the user how to\nset their identity configuration." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I force user and password prompt when pushing to my git repository?\n\nI recently updated my local Git installation to 1.8.1 from 1.8.0.1. \nI'm noticing that, when I work on GitHub, it doesn't prompt me for username and password on push anymore. \nThis troubles me, as I see having to type user and password every time as a good security measure. (what if someone else uses my computer?) \nI checked the following: \n\n1.8.0.1 on another computer still asks for username and password.\nmy account on github still enforces private/security controls.\nI am using https remote references, rather than ssh.\nFor good measure, I checked in my ~/.ssh fonder. Nothing wrong there.\nI'm not storing the login details in ~/.gitconfig or individual <proj>/.git/config files.\nI'm also not storing anything github-related in ~/.netrc.\nI created a new dummy archive: still doesn't prompt me for login.\n\nI couldn't find anything in the git release notes archive. \nDoes anyone know if this is a new git behaviour? How do I restore the prompt?" }, { "role": "assistant", "content": "Add a -v flag with your git command . e.g.\ngit pull -v\n\nv stands for verify ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git pre- and post- commit hooks not running\nWhat could cause my git pre- and post- commit hooks to not run?\n(please note: this question is not a duplicate; the answer to each of the other questions is either chmod +x or \"don't have a file extension\", and neither are the issue here)\nThey are executable:\n$ ls -alh .git/hooks/*-commit\n-rwxr-xr-x … .git/hooks/post-commit\n-rwxr-xr-x … .git/hooks/pre-commit\nAnd this is the content of each of them:\n#!/bin/sh\necho \"$0 IS RUNNING\"\nexit 1\n\nRunning them manually works:\n$ .git/hooks/pre-commit\n.git/hooks/pre-commit IS RUNNING\n\nBut they aren't run by git on commit:\n$ git commit -am \"Test hooks\"\n[master d17c0f38] Test hooks\n 1 file changed, 1 insertion(+)\nThis is with git 2.16.2" }, { "role": "assistant", "content": "I have seen for instance the config core.hooksPath being set to another path than $GIT_DIR/hooks, making your hooks in that folder ignored.\nCheck your git config core.hooksPath output, and more generally git config -l for any out of the ordinary settings. \nNote that a git commit -n would skip the pre-commit hook.\nEdit by wolever:\nI've added this to the scripts in my core.hooksPath directory, which will run the repo's hooks if they exist:\n#!/bin/sh\nset -eu\nhook_name=\"$(basename \"$0\")\"\nhook_script=\".git/hooks/$hook_name\"\n[ -e \"$hook_script\" ] && \"$hook_script\"\nexit 0" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects -s --no-patch" }, { "role": "assistant", "content": "Suppress all output from the diff machinery. Useful for\ncommands like git show that show the patch by default to\nsquelch their output, or to cancel the effect of options like --patch , --stat earlier on the command line in an alias." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options log.abbrevCommit" }, { "role": "assistant", "content": "If true, makes git-log , git-show , and git-whatchanged assume --abbrev-commit . You may\noverride this option with --no-abbrev-commit ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to get commit history for just one branch?\nLet's say I created a new branch my_experiment from master and made several commits to my_experiment. If I do a git log when on my_experiment, I see the commits made to this branch, but also the commits made to master before the my_experiments branch was created.\nI would find it very useful to see the history of all commits to the my_experiments branch until it hits the creation of that branch - effectively a true history of just that branch. Otherwise it's not clear to me when looking through the log whether the commits were on the my_experiments branch or not.\nIs there a way to do this with Git?" }, { "role": "assistant", "content": "You can use a range to do that.\ngit log master..\n\nIf you've checked out your my_experiment branch. This will compare where master is at to HEAD (the tip of my_experiment)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options statusHints" }, { "role": "assistant", "content": "Show directions on how to proceed from the current\nstate in the output of git-status , in\nthe template shown when writing commit messages in git-commit , and in the help message shown\nby git-switch or git-checkout when switching branches." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to move a file from one git repository to another while preserving history\nI am trying to move a single file (call it foo.txt) from one repository to another (unrelated) repository, preserving its history. ebneter's question shows how to do this for a subdirectory. taw's question has some hints and suggestions, but not a step-by-step procedure to follow. jkeating's question looked promising, but didn't work for me. Google searches came up empty for this particular use case. What I am looking for is a clear sequence of commands to accomplish this.\nThe sequence of commands I started to follow was this:\n$ git clone source-repo/ source-repo-copy\n$ cd source-repo-copy\n$ git filter-branch --tree-filter 'test ! \"$@\" = \"foo.txt\" && \\\n git rm --cached --ignore-unmatch $@ || true' --prune-empty\n\nThe logic of my filter command is to git rm all files that are not foo.txt. I added the || true to the command to force it to have a zero return value to satisfy filter-branch.\nMy intention was to set source-repo-copy as a remote for my target repository (target-repo), and assuming git filter-branch filtered out everything but foo.txt, fetch and merge source-repo-copy into target-repo. Unfortunately, the git filter-branch command seemed to have no effect. It ran with no errors and appeared to grind through the 600+ commits in source-repo, but when it finished, the git log and files in source-repo-copy looked the same. Shouldn't all files but foo.txt be missing and all commits that didn't touch it be gone from the log?\nAt this point I don't know how to proceed. Any suggestions?" }, { "role": "assistant", "content": "This worked for me, but with a whole directory.\nAs shown here\n~$ cd neu\n~/neu$ git filter-branch --subdirectory-filter FooBar HEAD\n~/neu$ git reset --hard\n~/neu$ git remote rm origin\n~/neu$ rm -r .git/refs/original/\n~/neu$ git reflog expire --expire=now --all\n~/neu$ git gc --aggressive\n~/neu$ git prune\n~/neu$ git remote add origin git://github.com/FooBar/neu.git\n\nEDIT: For a single file:\nFilter the directory first:\n git filter-branch --prune-empty --subdirectory-filter myDirectory -- --all\n\nFilter the single file:\n git filter-branch -f --prune-empty --index-filter \"git rm --cached --ignore-unmatch $(git ls-files | grep -v 'keepthisfile.txt')\"\n\nDo some cleanup:\n git reset --hard\n git gc --aggressive\n git prune\n\nThis should do it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --name-only" }, { "role": "assistant", "content": "Show only names of changed files. The file names are often encoded in UTF-8.\nFor more information see the discussion about encoding in the git-log manual page." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why is git is ignoring files that aren't in the .gitignore file?\nI have a git repository that is ignoring image files as well as a few other files, but my .gitignore file only has it ignoring a config.php file. Is there some global ignore file somewhere that I can't seem to find? I have to specify files to add them now, and it's giving me this warning:\n\nThe following paths are ignored by one of your .gitignore files.\n\nThe contents of my ~/.gitconfig file are only my e-mail address." }, { "role": "assistant", "content": "git check-ignore\nUse git check-ignore command to debug your gitignore file (exclude files).\nFor example:\n$ git check-ignore -v config.php\n.gitignore:2:src config.php\n\nThe above output details about the matching pattern (if any) for each given pathname (including line).\nSo maybe your file extension is not ignored, but the whole directory.\nThe returned format is:\n<source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname>\n\nOr use the following command to print your .gitignore in user HOME and repository folder:\n\ncat ~/.gitignore \"$(git rev-parse --show-toplevel)\"/.gitignore \"$(git rev-parse --show-toplevel)\"/.git/info/exclude\n\nAlternatively use git add -f which allows adding otherwise ignored files.\nSee: man gitignore, man git-check-ignore for more details.\nSyntax\n\ngit check-ignore [options] pathname…​\ngit check-ignore [options] --stdin" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters --flags" }, { "role": "assistant", "content": "Do not output non-flag parameters." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-stash - Stash the changes in a dirty working directory away --pathspec-from-file=<file>" }, { "role": "assistant", "content": "This option is only valid for push command. Pathspec is passed in <file> instead of commandline args. If <file> is exactly - then standard input is used. Pathspec\nelements are separated by LF or CR/LF. Pathspec elements can be\nquoted as explained for the configuration variable core.quotePath (see git-config ). See also --pathspec-file-nul and\nglobal --literal-pathspecs ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --anchored=<text>" }, { "role": "assistant", "content": "Generate a diff using the \"anchored diff\" algorithm. This option may be specified more than once. If a line exists in both the source and destination, exists only once,\nand starts with this text, this algorithm attempts to prevent it from\nappearing as a deletion or addition in the output. It uses the \"patience\ndiff\" algorithm internally." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "IntelliJ cannot log in to GitHub\n\nFor some reason, a new IntelliJ installation is unable to log in to GitHub. (The credentials are correct.)\nIt happens both when I try to \"share project on githu\" and \"checkout project from version control\", select Git and then try to log in to GitHub.\nHere's the login prompt:\nServer: github.com\nLogin: <my username>\nPassword: <my password>\n\nAnd the error message:\nInvalid authentication data. Can't create token:\nscopes - [repo, gist] - not IntelliJ Plugin_1 422\nUnprocessable Entity - Validation Failed\n[OauthAccess; description]already_exists: null\n\nNow, this is on a freshly installed Windows 10 computer, with a freshly installed IntelliJ. So there are no old tokens or anything like that anywhere in the system. This is the first attempt to access GitHub from IntelliJ. Logging in via web works fine." }, { "role": "assistant", "content": "That kind of error messages can be frustrating, as it takes more than a little knowledge on the subject to understand exactly what is wrong. Usually, however, the problem is either the authentication (invalid username/email/password) or that there's a problem with git (locally).\nFirst of all, check that you have git installed by running \"git\" from the command prompt. This is a more common mistake than one would think.\nSecond, try y.bedrov's suggestion. Log in to github.com on the web. Settings -> Developer settings -> Personal access tokens. Create a new token and then, in IntelliJ, select Enter Token at the login prompt.\nTokens are considered a more secure way to authenticate, I believe." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I see a \"three way diff\" for a Git merge conflict?\nSuppose I'm on Git branch master and I git merge featurebranch. There is a conflict in foo.html.\nWhen I open foo.html, I see, in the area of the conflict, what master has and what featurebranch has. But I can't really tell what change was made on master that conflicted with featurebranch; I only know what master has now.\nI'd like to see the diff that each one applied.\nOr, to get the same information, I could see:\n\nThe version master has now\nThe version featurebranch has now\nThe version their common ancestor had\n\nHow can I see this?" }, { "role": "assistant", "content": "From git-merge(1),\n\nAn alternative style can be used by setting the \"merge.conflictstyle\" configuration variable to \"diff3\".\nIn addition to the <<<<<<<, =======, and >>>>>>> markers, it uses another ||||||| marker that is followed by the original text. ... You can sometimes come up with a better resolution by viewing the original.\n\nThis can be enabled using\ngit config --global merge.conflictstyle diff3\n\nor right in ~/.gitconfigfile\n[merge]\n conflictstyle = diff3" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-apply - Apply a patch to files and/or to the index --directory=<root>" }, { "role": "assistant", "content": "Prepend <root> to all filenames. If a \"-p\" argument was also passed,\nit is applied before prepending the new root. For example, a patch that talks about updating a/git-gui.sh to b/git-gui.sh can be applied to the file in the working tree modules/git-gui/git-gui.sh by\nrunning git apply --directory=modules/git-gui ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to create a new branch from a tag?\nI'd like to create a new master branch from an existing tag. Say I have a tag v1.0. How to create a new branch from this tag?" }, { "role": "assistant", "content": "Wow, that was easier than I thought:\ngit checkout -b newbranch v1.0\n\n\nIf running the above command you get an error\n\nwarning: refname 'v1.0' is ambiguous. \nfatal: ambiguous object name: 'v1.0'\n\nthis is because you also have a branch with name v1.0. In this case specify tags/ prefix:\ngit checkout -b newbranch tags/v1.0" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to undo git stash clear\nI executed git stash save \"ABC\".\nThen by mistake I did git stash clear .\nHow can I retrieve the data that was in stash ABC?" }, { "role": "assistant", "content": "As it may be found in the documentation of git stash, you may be lucky if this works:\n\nRecovering stashes that were cleared/dropped erroneously\nIf you mistakenly drop or clear stashes, they cannot be recovered through the normal safety mechanisms. However, you can try the following incantation to get a list of stashes that are still in your repository, but not reachable any more:\ngit fsck --unreachable |\n grep commit | cut -d\\ -f3 |\n xargs git log --merges --no-walk --grep=WIP\n\nIf you find the stash you cleared by mistake, then you can do:\ngit stash apply <stash>\n\nEDIT: Use this command instead git fsck --unreachable | grep commit | cut -d ' ' -f3 | xargs git log --merges --no-walk --grep=WIP" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --check" }, { "role": "assistant", "content": "Warn if changes introduce conflict markers or whitespace errors.\nWhat are considered whitespace errors is controlled by core.whitespace configuration. By default, trailing whitespaces (including\nlines that consist solely of whitespaces) and a space character\nthat is immediately followed by a tab character inside the\ninitial indent of the line are considered whitespace errors.\nExits with non-zero status if problems are found. Not compatible\nwith --exit-code." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rebase - Reapply commits on top of another base tip --abort" }, { "role": "assistant", "content": "Abort the rebase operation and reset HEAD to the original\nbranch. If <branch> was provided when the rebase operation was\nstarted, then HEAD will be reset to <branch> . Otherwise HEAD will be reset to where it was when the rebase operation was\nstarted." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "'Enter PIN for authenticator' Issue related to SSH\n\nBrief\nI attempted to generate a SSH key for my Github on a Macbook Pro. Yet I encountered the 'Enter PIN for authenticator' issue when I progressed to the step of adding it to the ssh-agent. The bizarre asking is from the following command:\n$ ssh-add -K ~/.ssh/id_rsa\nEnter PIN for authenticator:\n\nwhich I totally have no idea what I should type into for this asking. Yet as I typed with the following command, everything just worked as this page revealed.\n$ /usr/bin/ssh-add -K ~/.ssh/id_rsa\nIdentity added: /Users/${user_name}/.ssh/id_rsa ([email protected])\n\nWhy there exists this kind of difference ? What exactly you need to type for the asking of 'Enter PIN for authenticator:' ?\nSome Info\n\nversion information\n\n$ ssh -V\nOpenSSH_8.3p1, OpenSSL 1.1.1g 21 Apr 2020\n\n$ sw_vers -productVersion\n10.15.6\n\n\nI generated the key with the ed25519 algorithm." }, { "role": "assistant", "content": "If you use this command\n$ ssh-add -K ~/.ssh/id_rsa \n\nyou will be asked to enter the PIN for authentication\nso instead of that use\n$ ssh-add ~/.ssh/id_rsa" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git merge flattening\nIf I am working in multiple branches on a single feature, I use git pull branch1 branch2 branch3 to pull all the changes into my master branch. However, all the commit logs of each branch are copied as well. How do I flatten the commit log down to a single message?" }, { "role": "assistant", "content": "\"git merge --squash\" (after \"git fetch\"; \"git pull\" is just fetch+merge, pehaps it also allows --squash option) might be what you want.\nFrom git-merge(1):\n\n--squash\n\nProduce the working tree and index state as if a real merge happened, but do not actually make a commit or move the HEAD, nor record $GIT_DIR/MERGE_HEAD to cause the next git commit command to create a merge commit. This allows you to create a single commit on top of the current branch whose effect is the same as merging another branch (or more in case of an octopus)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "scrolling down git diff from mac terminal\nI am using git on terminal on OS X 10 Yosemite.\nWhen I do git diff I get long list of changes and sometimes I just need to scroll to the end but I couldn't figure out a way to do that other than to hold the keydown on MacBook pro and then it scrolls slowly.\nif I press FN+down key then it does not scroll unless I have made the scroll down journey already down using the down button, but does not go further down...\nany advice will be appreciate this is very annoying... :(" }, { "role": "assistant", "content": "git diff uses the same pager as less Unix command.\n\nUse keys d and u to go down / up half pages (forward / backward technically)\nJump to last line: G\nh for help\n! to input a command (eg. git add while scrolling)\n\n\nAnother trick is storing the diff as a patch file like they used to do in the email days! Then you can open up the patch in any program. Some examples:\ngit diff --staged > ~/patch\ngit show someCommitSHA > ~/patch\ngit diff main myBranch > ~/patch\ngit diff head '*pathWildcard*' > ~/patch\n\ngit apply ~/patch\nNormally you would use the patch by applying the diff, but you can just open the file in any text editor. It's useful if you don't want to make a full commit out of your diff, but still want to use it somewhere else or send it to a friend\n\nYou can also use git diff master | grep -C 2 someKeyword to show diff +/- 2 lines around some keyword" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-update-index - Register file contents in the working tree to the index" }, { "role": "assistant", "content": "SYNOPSIS git update-index [--add] [--remove | --force-remove] [--replace]\n\t [--refresh] [-q] [--unmerged] [--ignore-missing]\n\t [(--cacheinfo <mode>,<object>,<file>)…​]\n\t [--chmod=(+|-)x]\n\t [--[no-]assume-unchanged]\n\t [--[no-]skip-worktree]\n\t [--[no-]ignore-skip-worktree-entries]\n\t [--[no-]fsmonitor-valid]\n\t [--ignore-submodules]\n\t [--[no-]split-index]\n\t [--[no-|test-|force-]untracked-cache]\n\t [--[no-]fsmonitor]\n\t [--really-refresh] [--unresolve] [--again | -g]\n\t [--info-only] [--index-info]\n\t [-z] [--stdin] [--index-version <n>]\n\t [--verbose]\n\t [--] [<file>…​]" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git merge different repositories?\nI've been using SVN for all my projects.\nSometimes project B is originating as a copy from project A.\nWhen project A has a generic change, I can use svn merge A within directory B and it will merge those changes.\nNow, if I wanted to use git. I don't like having all my projects in the same repository since I then have to clone everything and can't pick just one project like in SVN.\nBut having one repository for each project, how do I go about doing the same like I did earlier with SVN?\nThe question is:\nWhat's the best way to structure it if I want several subprojects that really all relates to one original project and to keep them in sync? And that I also want to be able to check them out separately" }, { "role": "assistant", "content": "If you have two projects, proj1 and proj2 and want to merge changes of proj1 into proj2, you would do it like this:\n# in proj2:\ngit remote add proj1 path/to/proj1\ngit fetch proj1\ngit merge proj1/master # or whichever branch you want to merge\n\nI believe this does the same thing as what you were doing with SVN." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %ct" }, { "role": "assistant", "content": "committer date, UNIX timestamp" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary pathspec" }, { "role": "assistant", "content": "Pattern used to limit paths in Git commands. Pathspecs are used on the command line of \"git ls-files\", \"git\nls-tree\", \"git add\", \"git grep\", \"git diff\", \"git checkout\",\nand many other commands to\nlimit the scope of operations to some subset of the tree or\nworking tree. See the documentation of each command for whether\npaths are relative to the current directory or toplevel. The\npathspec syntax is as follows: any path matches itself the pathspec up to the last slash represents a\ndirectory prefix. The scope of that pathspec is\nlimited to that subtree. the rest of the pathspec is a pattern for the remainder\nof the pathname. Paths relative to the directory\nprefix will be matched against that pattern using fnmatch(3);\nin particular, * and ? can match directory separators. For example, Documentation/*.jpg will match all .jpg files\nin the Documentation subtree,\nincluding Documentation/chapter_1/figure_1.jpg. A pathspec that begins with a colon : has special meaning. In the\nshort form, the leading colon : is followed by zero or more \"magic\nsignature\" letters (which optionally is terminated by another colon : ),\nand the remainder is the pattern to match against the path.\nThe \"magic signature\" consists of ASCII symbols that are neither\nalphanumeric, glob, regex special characters nor colon.\nThe optional colon that terminates the \"magic signature\" can be\nomitted if the pattern begins with a character that does not belong to\n\"magic signature\" symbol set and is not a colon. In the long form, the leading colon : is followed by an open\nparenthesis ( , a comma-separated list of zero or more \"magic words\",\nand a close parentheses ) , and the remainder is the pattern to match\nagainst the path. A pathspec with only a colon means \"there is no pathspec\". This form\nshould not be combined with other pathspec. top The magic word top (magic signature: / ) makes the pattern\nmatch from the root of the working tree, even when you are\nrunning the command from inside a subdirectory. literal Wildcards in the pattern such as * or ? are treated\nas literal characters. icase Case insensitive match. glob Git treats the pattern as a shell glob suitable for\nconsumption by fnmatch(3) with the FNM_PATHNAME flag:\nwildcards in the pattern will not match a / in the pathname.\nFor example, \"Documentation/*.html\" matches\n\"Documentation/git.html\" but not \"Documentation/ppc/ppc.html\"\nor \"tools/perf/Documentation/perf.html\". Two consecutive asterisks (\" ** \") in patterns matched against\nfull pathname may have special meaning: A leading \" ** \" followed by a slash means match in all\ndirectories. For example, \" **/foo \" matches file or directory\n\" foo \" anywhere, the same as pattern \" foo \". \" **/foo/bar \"\nmatches file or directory \" bar \" anywhere that is directly\nunder directory \" foo \". A trailing \" /** \" matches everything inside. For example,\n\" abc/** \" matches all files inside directory \"abc\", relative\nto the location of the .gitignore file, with infinite depth. A slash followed by two consecutive asterisks then a slash\nmatches zero or more directories. For example, \" a/**/b \"\nmatches \" a/b \", \" a/x/b \", \" a/x/y/b \" and so on. Other consecutive asterisks are considered invalid. Glob magic is incompatible with literal magic. attr After attr: comes a space separated list of \"attribute\nrequirements\", all of which must be met in order for the\npath to be considered a match; this is in addition to the\nusual non-magic pathspec pattern matching.\nSee gitattributes . Each of the attribute requirements for the path takes one of\nthese forms: \" ATTR \" requires that the attribute ATTR be set. \" -ATTR \" requires that the attribute ATTR be unset. \" ATTR=VALUE \" requires that the attribute ATTR be\nset to the string VALUE . \" !ATTR \" requires that the attribute ATTR be\nunspecified. Note that when matching against a tree object, attributes are still\nobtained from working tree, not from the given tree object. exclude After a path matches any non-exclude pathspec, it will be run\nthrough all exclude pathspecs (magic signature: ! or its\nsynonym ^ ). If it matches, the path is ignored. When there\nis no non-exclude pathspec, the exclusion is applied to the\nresult set as if invoked without any pathspec." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-archive - Create an archive of files from a named tree tar.<format>.remote" }, { "role": "assistant", "content": "If true, enable the format for use by remote clients via git-upload-archive . Defaults to false for\nuser-defined formats, but true for the tar.gz and tgz formats." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What's the difference between tag and release?\nUsing GitHub's API, I can't get the releases list, but I can get the tags list.\nWhat's the difference between them?" }, { "role": "assistant", "content": "What's the difference between them?\n\nA tag is a pointer to a specific commit. This pointer can be super charged with some additional information (identity of the creator of the tag, a description, a GPG signature, ...).\nA tag is a git concept whereas a Release is GitHub higher level concept.\nAs stated in the official announcement post from the GitHub blog: \"Releases are first-class objects with changelogs and binary assets that present a full project history beyond Git artifacts.\"\nA Release is created from an existing tag and exposes release notes and links to download the software or source code from GitHub.\n\nUsing GitHub's API, I can't get the releases list, but I can get the tags list.\n\nThe current version of the GitHub API doesn't expose a way to manage Releases (create, update, ...). I'm pretty sure that this shouldn't take too long before it's exposed.\nHowever, it's currently possible to list the releases and tags of a specific repository.\nFor instance, the url below will list the 6 releases (as of today) from ReactiveUI\n\nhttps://api.github.com/repos/reactiveui/ReactiveUI/releases\n\nWhereas this one will list the 54 tags (as of today) from the same repository\n\nhttps://api.github.com/repos/reactiveui/ReactiveUI/tags\n\nCreating a release is currently in a process which involves a manual action (adding the release notes, uploading the packages, ...). This explains why tags are not transparently seen as Releases.\n\nIf you want to be notified of the API changes, you can subscribe to the GitHub API Changes blog.\nHowever, if you can't wait, the GitHub API home page states \"If you have any problems or requests please contact support.\". This can be done through an email to [email protected] or this contact form.\nUpdate:\nThe GitHub API now allows to manipulate Releases. See the announcement." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git push: \"fatal 'origin' does not appear to be a git repository - fatal Could not read from remote repository.\"\n\nI know similar questions have already been asked.\nBut, I believe my issue is due to a mistake I have previously made and therefore is different: let me explain.\nEverything was working smoothly, as I could:\n\ngit add . all the files from my local repository.\ngit commit -m \"message here\" to add messages to my commits.\ngit push origin master to upload my files to GitHub.\ngit push heroku master to upload my files to Heroku.\n\nHowever, at some point, I created a new branch locally called add-calendar-model in case next steps of the app development would go south...\n... which is exactly what happened.\nHowever, despite many attempts, I did not manage to get the initial code — i.e. the code from before I created the new branch — from the master branch to my local repository.\nSo, I decided to manually delete all the files from my local repository and git clone my master branch from GitHub.\nThis way, I got all my files back, but now, I cannot push any more to the remote repository.\nAny time I try to run git push origin add-calendar-model or git push origin master, I get the following error:\nfatal: 'origin' does not appear to be a git repository\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\nI am not very comfortable with Git and GitHub, as you may have guessed by now, and I have to admit that I have no clue about how to fix this.\nAny idea?" }, { "role": "assistant", "content": "First, check that your origin is set by running\ngit remote -v\n\nThis should show you all of the push / fetch remotes for the project.\nIf this returns with no output, skip to last code block.\nVerify remote name / address\nIf this returns showing that you have remotes set, check that the name of the remote matches the remote you are using in your commands.\n$git remote -v\nmyOrigin ssh://[email protected]:1234/myRepo.git (fetch)\nmyOrigin ssh://[email protected]:1234/myRepo.git (push)\n\n# this will fail because `origin` is not set\n$git push origin main\n\n# you need to use\n$git push myOrigin main\n\nIf you want to rename the remote or change the remote's URL, you'll want to first remove the old remote, and then add the correct one.\nRemove the old remote\n$git remote remove myOrigin\n\nAdd missing remote\nYou can then add in the proper remote using\n$git remote add origin ssh://[email protected]:1234/myRepo.git\n\n# this will now work as expected\n$git push origin main" } ]