messages listlengths 3 3 |
|---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options mergetool.prompt"
},
{
"role": "assistant",
"content": "Prompt before each invocation of the merge resolution program."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git mergetool reports \"No files need merging\"\nFor some reason lately, every time I pull and get a merge conflict, running git mergetool reports \"No files need merging\":\n$ git pull\nFirst, rewinding head to replay your work on top of it...\nApplying: replaced home button with Cancel\nUsing index info to reconstruct a base tree...\nFalling back to patching base and 3-way merge...\nerror: Your local changes to the following files would be overwritten by merge:\n Classes/Controllers/HomeController.m\nPlease, commit your changes or stash them before you can merge.\nAborting\nFailed to merge in the changes.\nPatch failed at 0002 moved rollback into cancel button in log watching\n\nWhen you have resolved this problem run \"git rebase --continue\".\nIf you would prefer to skip this patch, instead run \"git rebase --skip\".\nTo check out the original branch and stop rebasing run \"git rebase --abort\".\n\n$ git mergetool\nNo files need merging\n\nIf I run git rebase --abort and pull again, either the same thing happens on a different conflict, or the pull succeeds with no merge conflict. There are no remote changes between these pulls, so it's not as though the conflict went away.\nHere's how this branch and the remote are configured:\n[branch \"develop\"]\n remote = origin\n merge = refs/heads/develop\n rebase = true\n[remote \"origin\"]\n url = <my repo url>\n fetch = +refs/heads/*:refs/remotes/origin/*"
},
{
"role": "assistant",
"content": "This fixed it for me:\ngit mergetool . \nI found this fix here"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Remove/hide git branches without deleting commit histories\nSituation:\nI have a main repo with a main dev branch and lots of \"experiment\" branches sprouting off from it (e.g., exp1 and exp2). The purpose of these experiment branches is to serve as placeholders for experiments that generate numerical results. I record the branch name (and commit ID) of the experiment branches so I can return to the commits to see precisely the code and history behind the results.\nBut, now, there are so many experiment branches that it's getting hard to see the main tree. So, I'm rethinking my strategy for keeping placeholders to the code behind each set of results (i.e., each experiment). Obviously I could just save the working dir at each branch, but it would be nice to keep the commit history also.\nPossible solution:\nOne way to deal with this is to move the experiment branches into their own independent repos, each being rooted at the child node of the appropriate node in the commit history of the dev branch. Here's an illustration of what I mean:\n\nClick here for larger version of image (on imgur.com).\nSo, for example, for branch exp1, I would like to export commits A->B->C to a separate repo rooted at commit A. Then, I can just record the hash of commit P1 so that I know where the exp1 branch descended from.\nQuestion:\nHow can I do that?\nBetter question:\nOn the other hand, I strongly suspect there is a much better strategy for doing what I want to do---namely, unclutter the tree for visual inspection but keep placeholders to prior branches so I can return to them if needed. So, can anyone recommend a strategy for this?"
},
{
"role": "assistant",
"content": "Here's one alternative: use non-branch references to save the branch-tips before deleting the branch names.\nSince these are non-branch references, they won't show up in git branch output, nor in stuff shown by git log --branches and gitk --branches, for instance. However, they will show up in --all listings, and will retain repository objects.\nTo create or update a non-branch reference, use git update-ref. Choose a name-space within refs/ that you think will not collide with some future use (current uses are refs/heads/ for branches, refs/tags/ for tags, refs/remotes/ for remote branches, refs/notes/ for notes, and refs/stash for the stash). [Edit, July 2022: refs/namespaces/ is now reserved as well, and refs/replace/ is used by git replace. refs/bisect/, refs/rewritten/, and refs/worktree/ are reserved; refs/original/ is reserved if you will use git filter-branch. Gerrit, if you use it, has more reserved names. The list never seems to stop growing, so use care here.]"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %C(…)"
},
{
"role": "assistant",
"content": "color specification, as described under Values in the\n\"CONFIGURATION FILE\" section of git-config . By\ndefault, colors are shown only when enabled for log output\n(by color.diff , color.ui , or --color , and respecting\nthe auto settings of the former if we are going to a\nterminal). %C(auto,...) is accepted as a historical\nsynonym for the default (e.g., %C(auto,red) ). Specifying %C(always,...) will show the colors even when color is\nnot otherwise enabled (though consider just using --color=always to enable color for the whole output,\nincluding this format and anything else git might color). auto alone (i.e. %C(auto) ) will turn on auto coloring\non the next placeholders until the color is switched\nagain."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options auto"
},
{
"role": "assistant",
"content": "show in columns if the output is to the terminal"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Search for code or text in GitLab\n\nIs it possible to search for code or text in GitLab inside of files? I can search for files, issues, milestones, etc., but could not find a way to search for code in source files or text in the documentation i.e .doc files."
},
{
"role": "assistant",
"content": "We have a paid gitlab account such that our domain is gitlab.ourcompany.com - so this answer might not apply to all. There have been a few occassions where I needed to search for a \"string\" across all files in a Gitlab project, but there is no clear 'search' button. The search bar only searches for matching project names - so not what I was looking for. This method below is the easiest to use and easiest to remember.\n\nhttps://gitlab.xxxxx.com/search"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to install Github for Windows offline?\nAs the question says how to install Github for Windows without an internet connection? \nIf it is not possible then is there some alternative client with the following features:\n\nSupport for proxy\nOffline installer\n\nI found smartgit which has an offline installer but it seems it doesn't have proxy support.\nIf there is no such client then what can be done to extend the functionality of github for windows or some other client? I mean is there a way to use some API to extend it? Any links for that would be helpful."
},
{
"role": "assistant",
"content": "This is the answer I received from the support today (2015-06-30):\n\nUnfortunately we do not have a standalone installer at this time.\n GitHub for Windows makes use of Microsoft's ClickOnce technology for\n installation and updates.\nWe are currently working on an open source replacement for ClickOnce\n here: \nhttps://github.com/squirrel/squirrel.windows\nOnce that technology is complete and ready for use, we hope to switch\n GitHub for Windows to use that. It would allow for a standalone\n installer.\nIn the meantime, you can find a list of alternate GUIs available\n here:\nhttp://git-scm.com/downloads/guis"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to manage configuration files when collaborating?\nI'm writing a short script with a few simple variables at the top of the page. I want to work on them with a friend, but we aren't sure how to manage the variables needing to be changed after pulling each time for one of us, adding unnecessary junk to git status. I thought about just creating different named branches for each of us, and then the master will just have example usernames set, but it seems silly to have to do all that extra work merging. We could have the variables passed to the script as options, but that isn't desired, nor is separating it out to another separate configuration file. It would be great to have something like a .gitignore but for only ignore a few lines in a file.\nHow can this be elegantly managed? How is this problem usually managed?"
},
{
"role": "assistant",
"content": "You can't easily just ignore changes to particular lines of a file, I'm afraid, so you're probably stuck with having a separate configuration file. Below I've listed two typical ways of dealing with this, and one slightly more exotic one:\nHave a sample configuration file in git\nHere, you would keep a file config.sample in git as an example, but the application would actually use the values in a file config which is in .gitignore. The application would then produce an error unless config is present. You have to remember to change values in the sample file when you add new configuration variables to your personal config file. In this case it's also a good idea to have your application check that all the required configuration variables are actually set, in case someone has forgotten to update their config file after changes to the sample.\nHave a file of default values in git\nYou keep a file config.defaults in git, which has sensible default configuration values as far as possible. Your application first sources configuration from config.defaults and then from config (which is in .gitignore) to possibly override any of the default values. With this method, typically you wouldn't make it an error for config not to exist, so the application can work out of the box for people who haven't bothered to create config.\nUsing a single configuration file with --assume-unchanged\nA third possibility, which I wouldn't recommend in this case, personally, would be to have a single configuration file which is committed in git, but to use git update-index --assume-unchanged <FILE>, to tell git to ignore changes to it. (This is described further in this useful blog post.) That means that your local changes to the configuration file won't be committed with git commit -a or show up in git status."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab 'Gateway Timeout' behind traefik proxy\n\nSo I'm trying to set up a gitlab-ce instance on docker swarm using traefik as reverse proxy.\nThis is my proxy stack;\nversion: '3'\n\nservices:\n traefik:\n image: traefik:alpine\n command: --entryPoints=\"Name:http Address::80 Redirect.EntryPoint:https\" --entryPoints=\"Name:https Address::443 TLS\" --defaultentrypoints=\"http,https\" --acme --acme.acmelogging=\"true\" --acme.email=\"[email protected]\" --acme.entrypoint=\"https\" --acme.storage=\"acme.json\" --acme.onhostrule=\"true\" --docker --docker.swarmmode --docker.domain=\"mydomain.com\" --docker.watch --web\n ports:\n - 80:80\n - 443:443\n - 8080:8080\n networks:\n - traefik-net\n volumes:\n - /var/run/docker.sock:/var/run/docker.sock\n deploy:\n placement:\n constraints:\n - node.role == manager\n\nnetworks:\n traefik-net:\n external: true\n\nAnd my gitlab stack\nversion: '3'\n\nservices:\n omnibus:\n image: 'gitlab/gitlab-ce:latest'\n hostname: 'lab.mydomain.com'\n environment:\n GITLAB_OMNIBUS_CONFIG: |\n external_url 'https://lab.mydomain.com'\n nginx['listen_port'] = 80\n nginx['listen_https'] = false\n registry_external_url 'https://registry.mydomain.com'\n registry_nginx['listen_port'] = 80\n registry_nginx['listen_https'] = false\n gitlab_rails['gitlab_shell_ssh_port'] = 2222\n gitlab_rails['gitlab_email_from'] = '[email protected]'\n gitlab_rails['gitlab_email_reply_to'] = '[email protected]'\n ports:\n - 2222:22\n volumes:\n - gitlab_config:/etc/gitlab\n - gitlab_logs:/var/log/gitlab\n - gitlab_data:/var/opt/gitlab\n networks:\n - traefik-net\n deploy:\n labels:\n traefik.enable: \"port\"\n traefik.frontend.rule: 'Host: lab.mydomain.com, Host: registry.mydomain.com'\n traefik.port: 80\n placement:\n constraints:\n - node.role == manager\n\n runner:\n image: 'gitlab/gitlab-runner:v1.11.4'\n volumes:\n - gitlab_runner_config:/etc/gitlab-runner\n - /var/run/docker.sock:/var/run/docker.sock\n\nvolumes:\n gitlab_config:\n gitlab_logs:\n gitlab_data:\n gitlab_runner_config:\n\nnetworks:\n traefik-net:\n external: true\n\n\ntraefik-net is an overlay network\n\nSo when I deploy using docker stack deploy and visit lab.mydomain.com, i get the Gateway Timeout error. When I execute curl localhost within the gitlab container, it seems to work fine. Not sure what the problem is, any pointers would be appreciated"
},
{
"role": "assistant",
"content": "Turns out all I had to do was set the traefik label, traefik.docker.network to traefik-net, see https://github.com/containous/traefik/issues/1254"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs default , myers"
},
{
"role": "assistant",
"content": "The basic greedy diff algorithm. Currently, this is the default."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-mergetool - Run merge conflict resolution tools to resolve merge conflicts mergetool.<tool>.cmd"
},
{
"role": "assistant",
"content": "Specify the command to invoke the specified merge tool. The\nspecified command is evaluated in shell with the following\nvariables available: BASE is the name of a temporary file\ncontaining the common base of the files to be merged, if available; LOCAL is the name of a temporary file containing the contents of\nthe file on the current branch; REMOTE is the name of a temporary\nfile containing the contents of the file from the branch being\nmerged; MERGED contains the name of the file to which the merge\ntool should write the results of a successful merge."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-cat-file - Provide contents or details of repository objects objectsize:disk"
},
{
"role": "assistant",
"content": "The size, in bytes, that the object takes up on disk. See the\nnote about on-disk sizes in the CAVEATS section below."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --raw"
},
{
"role": "assistant",
"content": "Generate the diff in raw format."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options status.showStash"
},
{
"role": "assistant",
"content": "If set to true, git-status will display the number of\nentries currently stashed away.\nDefaults to false."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-tag - Create, list, delete or verify a tag object signed with GPG --merged [<commit>]"
},
{
"role": "assistant",
"content": "Only list tags whose commits are reachable from the specified\ncommit ( HEAD if not specified)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git error when trying to push -- pre-receive hook declined\nWhen I try and push a change I've committed, I get the following error:\ngit.exe push -v --progress \"origin\" iteration1:iteration1\n\nremote: *********************************************************************\nTo ssh://git@mycogit/cit_pplus.git\n! [remote rejected] iteration1 -> iteration1 (pre-receive hook declined)\nerror: failed to push some refs to 'ssh://git@mycogit/cit_pplus.git'\n\nWhat's going on ?"
},
{
"role": "assistant",
"content": "You should ask whoever maintains the repo at git@mycogit/cit_pplus.git.\nYour commits were rejected by the pre-receive hook of that repo (that's a user-configurable script that is intended to analyze incoming commits and decide if they are good enough to be accepted into the repo). \nIt is also a good idea to ask that person to update the hook, so it would print the reasons for the rejection.\nIf the maintainer is you yourself, then it looks like you've got a problem with your setup on the server-side. Please share more information then."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to use ssh authentication with github API?\n\nIs there some way to use ssh-based authentication when accessing the GitHub API through the command line (via, e.g., curl, etc.?).\nFWIW, I tried many variations of the following (varying the way I specified my public ssh key file) but in every case I was still prompted for my password:\n% curl --pubkey ~/.ssh/id_rsa.pub --user yrstruly https://api.github.com/user/repos"
},
{
"role": "assistant",
"content": "If you are using ssh, then you would never logon as 'yrstruly'. You would always connect as 'git'.\nYour public key would be enough for GitHub to recognize you as 'yrstruly'.\nAnd since you are using an https address, and not an ssh one, that --pubkey option is likely to be ignored.\nA valid ssh address would be: ssh://[email protected], and I don't think Github proposes that kind of access for its api.\nThe curl --user option would be necessary for https address only, as in \"Having trouble downloading Git archive tarballs from Private Repo\":\ncurl -sL --user \"${username}:${password}\" https://github.com..."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-am"
},
{
"role": "assistant",
"content": "Apply a series of patches from a mailbox"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-ls-tree - List the contents of a tree object --format=<format>"
},
{
"role": "assistant",
"content": "A string that interpolates %(fieldname) from the result\nbeing shown. It also interpolates %% to % , and %xNN where NN are hex digits interpolates to character\nwith hex code NN ; for example %x00 interpolates to \\0 (NUL), %x09 to \\t (TAB) and %x0a to \\n (LF).\nWhen specified, --format cannot be combined with other\nformat-altering options, including --long , --name-only and --object-only ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Storing SSH Private Key in GitLab repository variables\n\nUsing GitLab CI, I want to push production code to a remote webhost.\nTo connect with SSH, I am storing the key pair's private key in the variables of my GitLab repository. I've also copied the public key to the authorized keys of the server. This is (part of) my .gitlab-ci.yml.\nimage: ubuntu\n\nbefore_script:\n # Setup SSH credentials and known host\n - which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )\n - mkdir -p ~/.ssh\n - echo \"$SSH_PRIVATE\" | tr -d '\\r' > ~/.ssh/id_rsa\n - chmod 700 ~/.ssh/id_rsa\n - eval \"$(ssh-agent -s)\"\n - ssh-add ~/.ssh/id_rsa\n - echo \"$SSH_KNOWN_HOSTS\"\n - echo \"$SSH_KNOWN_HOSTS\" > ~/.ssh/known_hosts\n - chmod 644 ~/.ssh/known_hosts\n\nThis method works, but I'm questioning the security of it. Is my private key safe this way? How else can I achieve the result that I'm looking for?\nEDIT: I'm particularly questioning the security of this method in a production environment."
},
{
"role": "assistant",
"content": "The official example is in gitlab-examples/ssh-private-key\nIts .gitlab-ci.yml uses a custom environment variable SSH_PRIVATE_KEY, as described in \"How to simplify your smart home configuration with GitLab CI/CD / Preparing the server (and GitLab) for SSH access\".\nAs long as that variable is masked, this should be secure enough.\n\nsneaky suggests in the comments to create a pre-processing file:\n\ncat id_rsa | base64 -w0 insert into script-part of your job in .gitlab-ci.yml:\nmkdir -p ~/.ssh && echo \"$SSH_PRIVATE_KEY\" | \\\n base64 -d > ${SSH_KEY_FILE} && chmod 0600 ${SSH_KEY_FILE}"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc -B[<n>][/<m>] --break-rewrites[=[<n>][/<m>]]"
},
{
"role": "assistant",
"content": "Break complete rewrite changes into pairs of delete and\ncreate. This serves two purposes: It affects the way a change that amounts to a total rewrite of a file\nnot as a series of deletion and insertion mixed together with a very\nfew lines that happen to match textually as the context, but as a\nsingle deletion of everything old followed by a single insertion of\neverything new, and the number m controls this aspect of the -B\noption (defaults to 60%). -B/70% specifies that less than 30% of the\noriginal should remain in the result for Git to consider it a total\nrewrite (i.e. otherwise the resulting patch will be a series of\ndeletion and insertion mixed together with context lines). When used with -M, a totally-rewritten file is also considered as the\nsource of a rename (usually -M only considers a file that disappeared\nas the source of a rename), and the number n controls this aspect of\nthe -B option (defaults to 50%). -B20% specifies that a change with\naddition and deletion compared to 20% or more of the file’s size are\neligible for being picked up as a possible source of a rename to\nanother file."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitrepository-layout"
},
{
"role": "assistant",
"content": "Git Repository Layout"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-bundle - Move objects and refs by archive"
},
{
"role": "assistant",
"content": "BUNDLE FORMAT Bundles are .pack files (see git-pack-objects ) with a\nheader indicating what references are contained within the bundle. Like the packed archive format itself bundles can either be\nself-contained, or be created using exclusions.\nSee the \"OBJECT PREREQUISITES\" section below. Bundles created using revision exclusions are \"thin packs\" created\nusing the --thin option to git-pack-objects , and\nunbundled using the --fix-thin option to git-index-pack . There is no option to create a \"thick pack\" when using revision\nexclusions, and users should not be concerned about the difference. By\nusing \"thin packs\", bundles created using exclusions are smaller in\nsize. That they’re \"thin\" under the hood is merely noted here as a\ncuriosity, and as a reference to other documentation. See gitformat-bundle for more details and the discussion of\n\"thin pack\" in gitformat-pack for further details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gettext .po files under version control\nCurrently using Gettext on a project and the .po files are nicely kept\nunder version control.\nPO files of course contain translations, but in addition to that they\nalso contain some metadata - information about the exact files and\nline numbers where the translatable strings are located.\nThe problem is that each time you update the PO files the metadata\nchanges a whole lot more than the actual translations. This makes it\nreally hard to later see from version control diff what actually was\nchanged - you just see a myriad of changes to file names and line\nnumbers. Like that:\n- #: somefile.js:43\n- #: somefile.js:45\n- #: somefile.js:118\n+ #: somefile.js:203\n+ #: somefile.js:215\n msgid \"Translate me please\"\n msgstr \"Tõlgi mind palun\"\n\n- #: somefile.js:23\n- #: somefile.js:135\n+ #: otherfile.js:23\n+ #: otherfile.js:135\n msgid \"Note\"\n msgstr \"Märkus\"\n\n- #: andThatFile.js:18\n #: orThisFile.js:131\n- msgid \"Before I was like this\"\n- msgstr \"Selline olin ma enne\"\n+ msgid \"I happen to be changed\"\n+ msgstr \"Paistab, et mind muudeti\"\n\nOf course, a simple fix would be to just disable the generation of\nfilename/linenumber comments in xgettext output. But I actually find\nthose file names to be quite useful hints when translating.\nI surely cannot be the only one who doesn't like the diffs of his PO files.\nSuggestions?"
},
{
"role": "assistant",
"content": "A simple fix would be to apply a grep filter to remove comment metadata from the viewed diff. You can either do this to the output of the version control diff utility:\nmyVersionControl diff REV1 REV2 filea | grep -v '^..#'\n\nor you may be able to instruct the version control diff utility to ignore these before it makes the comparison, which will likely result in a more reliable and prettier output:\nI don't know what version control system you use, but git (for example) allows you to preprocess the input to diff and remove the comment lines for certain file types (thanks VonC), see man gitattributes and search for Performing text diffs of binary files. Here's the body of a sample script to save as /usr/local/bin/strippocomments which will do that:\ngrep -v '^#:' $1\n\nYou can then tell git to use this script to preprocess po files, by adding the following to the file .git/info/attributes in your repository:\n*.po diff=podiff\n\nand to the file .git/config in your repository:\n[diff \"podiff\"]\n textconv = /usr/local/bin/strippocomments\n\nUsing git diff should then not include any lines starting with #:.\nNote that the diffs generated from git diff using this approach should not be used for patching - but git format-patch will still use the default diff, so patches generated for emailing will still be ok."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs -l<num>"
},
{
"role": "assistant",
"content": "The -M and -C options involve some preliminary steps that\ncan detect subsets of renames/copies cheaply, followed by an\nexhaustive fallback portion that compares all remaining\nunpaired destinations to all relevant sources. (For renames,\nonly remaining unpaired sources are relevant; for copies, all\noriginal sources are relevant.) For N sources and\ndestinations, this exhaustive check is O(N^2). This option\nprevents the exhaustive portion of rename/copy detection from\nrunning if the number of source/destination files involved\nexceeds the specified number. Defaults to diff.renameLimit.\nNote that a value of 0 is treated as unlimited."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary master"
},
{
"role": "assistant",
"content": "The default development branch . Whenever you\ncreate a Git repository , a branch named\n\"master\" is created, and becomes the active branch. In most\ncases, this contains the local development, though that is\npurely by convention and is not required."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Pull remote branch into local repo with different name?\n\nAlright I did a little bit of research on this but I couldn't find an exact answer, so I have to ask.\nI have 2 remotes: origin and repo2.\nI'd like to do something like\ngit pull repo2 master\n\nBut this would pull the master branch of the repo2 into my master. Can I specify a different branch to pull into, for my local branch ?"
},
{
"role": "assistant",
"content": "git checkout -b myBranchName repo2/master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitcli - Git command-line interface and conventions"
},
{
"role": "assistant",
"content": "DESCRIPTION This manual describes the convention used throughout Git CLI. Many commands take revisions (most often \"commits\", but sometimes\n\"tree-ish\", depending on the context and command) and paths as their\narguments. Here are the rules: Options come first and then args.\nA subcommand may take dashed options (which may take their own\narguments, e.g. \"--max-parents 2\") and arguments. You SHOULD\ngive dashed options first and then arguments. Some commands may\naccept dashed options after you have already given non-option\narguments (which may make the command ambiguous), but you should\nnot rely on it (because eventually we may find a way to fix\nthese ambiguities by enforcing the \"options then args\" rule). Revisions come first and then paths.\nE.g. in git diff v1.0 v2.0 arch/x86 include/asm-x86 , v1.0 and v2.0 are revisions and arch/x86 and include/asm-x86 are paths. When an argument can be misunderstood as either a revision or a path,\nthey can be disambiguated by placing -- between them.\nE.g. git diff -- HEAD is, \"I have a file called HEAD in my work\ntree. Please show changes between the version I staged in the index\nand what I have in the work tree for that file\", not \"show the difference\nbetween the HEAD commit and the work tree as a whole\". You can say git diff HEAD -- to ask for the latter. Without disambiguating -- , Git makes a reasonable guess, but errors\nout and asks you to disambiguate when ambiguous. E.g. if you have a\nfile called HEAD in your work tree, git diff HEAD is ambiguous, and\nyou have to say either git diff HEAD -- or git diff -- HEAD to\ndisambiguate. Because -- disambiguates revisions and paths in some commands, it\ncannot be used for those commands to separate options and revisions.\nYou can use --end-of-options for this (it also works for commands\nthat do not distinguish between revisions in paths, in which case it\nis simply an alias for -- ). When writing a script that is expected to handle random user-input, it is\na good practice to make it explicit which arguments are which by placing\ndisambiguating -- at appropriate places. Many commands allow wildcards in paths, but you need to protect\nthem from getting globbed by the shell. These two mean different\nthings: $ git restore *.c\n$ git restore \\*.c The former lets your shell expand the fileglob, and you are asking\nthe dot-C files in your working tree to be overwritten with the version\nin the index. The latter passes the *.c to Git, and you are asking\nthe paths in the index that match the pattern to be checked out to your\nworking tree. After running git add hello.c; rm hello.c , you will not see hello.c in your working tree with the former, but with the latter\nyou will. Just as the filesystem . (period) refers to the current directory,\nusing a . as a repository name in Git (a dot-repository) is a relative\npath and means your current repository. Here are the rules regarding the \"flags\" that you should follow when you are\nscripting Git: Splitting short options to separate words (prefer git foo -a -b to git foo -ab , the latter may not even work). When a command-line option takes an argument, use the stuck form. In\nother words, write git foo -oArg instead of git foo -o Arg for short\noptions, and git foo --long-opt=Arg instead of git foo --long-opt Arg for long options. An option that takes optional option-argument must be\nwritten in the stuck form. When you give a revision parameter to a command, make sure the parameter is\nnot ambiguous with a name of a file in the work tree. E.g. do not write git log -1 HEAD but write git log -1 HEAD -- ; the former will not work\nif you happen to have a file called HEAD in the work tree. Many commands allow a long option --option to be abbreviated\nonly to their unique prefix (e.g. if there is no other option\nwhose name begins with opt , you may be able to spell --opt to\ninvoke the --option flag), but you should fully spell them out\nwhen writing your scripts; later versions of Git may introduce a\nnew option whose name shares the same prefix, e.g. --optimize ,\nto make a short prefix that used to be unique no longer unique."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git magic keywords in commit messages (Signed-off-by, Co-authored-by, Fixes, ...)\n\nGit command itself supports the Signed-off-by: Person's name <persons@email> line.\nGitHub adds Co-authored-by: line, which then shows both the committer and the referenced person as commit authors in the UI. (See Q: GitHub co-authored-by with private noreply address for discussion how to avoid exposing email addresses.)\nFuthermore, GitHub and GitLab each recognize a set of keywords to close issues when a commit is merged.\nIs the list of Git magic keywords above complete? Is there a standardization process for adding these lines and keywords? Are these defined to be case insensitive?"
},
{
"role": "assistant",
"content": "From the OP:\n\nThe git command itself supports the Signed-off-by: Person's name <persons@email> line.\n\nStarting with Git 2.32 (Q2 2021), the git command itself supports... any trailer you want!\n\"git commit\"(man) learned --trailer <key>[=<value>] option; together with the interpret-trailers command, this will make it easier to support custom trailers.\nSee commit 2daae3d (23 Mar 2021) by ZheNing Hu (adlternative).\n(Merged by Junio C Hamano -- gitster -- in commit 68e15e0, 07 Apr 2021)\n\ncommit: add --trailer option\nSigned-off-by: ZheNing Hu\n\n\nHistorically, Git has supported the 'Signed-off-by' commit trailer using the '--signoff' and the '-s' option from the command line.\nBut users may need to provide other trailer information from the command line such as \"Helped-by\", \"Reported-by\", \"Mentored-by\",\nNow implement a new --trailer <token>[(=|:)<value>] option to pass other trailers to interpret-trailers and insert them into commit messages.\n\ngit commit now includes in its man page:\n\n--trailer <token>[(=|:)<value>]\nSpecify a (<token>, <value>) pair that should be applied as a\ntrailer.\nFor instance:\ngit commit --trailer \"Signed-off-by:C O Mitter <[email protected]>\" \\\n --trailer \"Helped-by:C O Mitter <[email protected]>\"\n\nThat will add the \"Signed-off-by\" trailer and the \"Helped-by\" trailer to the commit message.\nThe trailer.* configuration variables\n(git interpret-trailers) can be used to define if\na duplicated trailer is omitted, where in the run of trailers\neach trailer would appear, and other details.\n\n\nRegarding that trailer.xxx configuration, consider an initial commit that you want to amend with additional trailers:\nSigned-off-by: C O Mitter <[email protected]>\nSigned-off-by: C1 E1\nReported-by: C3 E3\nMentored-by: C4 E4\nHelped-by: C3 E3\n\nA trailer.ifexists=\"replace\" config would, if you amend it by adding the same Reported-by, keep the message unchanged:\ngit -c trailer.ifexists=\"replace\" \\\n commit --trailer \"Mentored-by: C4 E4\" \\\n --trailer \"Helped-by: C3 E3\" \\\n --amend\n\nBut if you amend the same commit with trailer.ifexists=\"add\" would means:\nSigned-off-by: C O Mitter <[email protected]>\nSigned-off-by: C1 E1\nHelped-by: C2 E2\nReported-by: C3 E3\nMentored-by: C4 E4\nReported-by: C3 E3 <<<< added twice\nMentored-by: C4 E4 <<<< added twice\n\nAnd using trailer.ifexists=\"addIfDifferent\"\ngit -c trailer.ifexists=\"addIfDifferent\" \\\n commit --trailer \"Reported-by: C3 E3\" \\\n --trailer \"Mentored-by: C5 E5\" \\\n --amend\n\nAnd you get:\nSigned-off-by: C O Mitter <[email protected]>\nSigned-off-by: C1 E1\nHelped-by: C2 E2\nReported-by: C3 E3\nMentored-by: C4 E4\nMentored-by: C5 E5 <<<< Only C5 E5 is added\n\n\nAnd, still With Git 2.32 (Q2 2021), the way the command line specified by the trailer.<token>.command configuration variable receives the end-user supplied value was both error prone and misleading.\nAn alternative to achieve the same goal in a safer and more intuitive way has been added, as the trailer.<token>.cmd configuration variable, to replace it.\nSee commit c364b7e, commit 57dcb65 (03 May 2021) by ZheNing Hu (adlternative).\n(Merged by Junio C Hamano -- gitster -- in commit 2cd6ce2, 11 May 2021)\n\ntrailer: add new .cmd config option\nHelped-by: Junio C Hamano\nHelped-by: Christian Couder\nSigned-off-by: ZheNing Hu\n\n\nThe trailer.<token>.command configuration variable specifies a command (run via the shell, so it does not have to be a single name or path to the command, but can be a shell script), and the first occurrence of substring $ARG is replaced with the value given to the interpret-trailer command for the token in a '--trailer <token>=<value>' argument.\nThis has three downsides:\n\nThe use of $ARG in the mechanism misleads the users that\nthe value is passed in the shell variable, and tempt them to use $ARG more than once, but that would not work, as the second and subsequent $ARG are not replaced.\nBecause $ARG is textually replaced without regard to the\nshell language syntax, even '$ARG' (inside a single-quote pair), which a user would expect to stay intact, would be replaced, and worse, if the value had an unmatched single quote (imagine a name like \"O'Connor\", substituted into NAME='$ARG' to make it NAME='O'Connor'), it would result in a broken command that is not syntactically correct (or worse).\nThe first occurrence of substring $ARG will be replaced with the empty string, in the command when the command is first called to add a trailer with the specified <token>.\nThis is a bad design, the nature of automatic execution causes it to add a trailer that we don't expect.\n\nIntroduce a new trailer.<token>.cmd configuration that takes higher precedence to deprecate and eventually remove trailer.<token>.command, which passes the value as an argument to the command.\nInstead of \"$ARG\", users can refer to the value as positional argument, $1, in their scripts.\nAt the same time, in order to allow git interpret-trailers(man) to better simulate the behavior of git command -s, 'trailer.<token>.cmd' will not automatically execute.\n\ngit interpret-trailers now includes in its man page:\n\nThis option behaves in the same way as 'trailer.<token>.cmd', except\nthat it doesn't pass anything as argument to the specified command.\nInstead the first occurrence of substring $ARG is replaced by the\nvalue that would be passed as argument.\nThe 'trailer.<token>.command' option has been deprecated in favor of\n'trailer.<token>.cmd' due to the fact that $ARG in the user's command is\nonly replaced once and that the original way of replacing $ARG is not safe.\nWhen both 'trailer.<token>.cmd' and 'trailer.<token>.command' are given\nfor the same <token>, 'trailer.<token>.cmd' is used and\n'trailer.<token>.command' is ignored.\ntrailer.<token>.cmd\n\ngit interpret-trailers now includes in its man page:\n\nof these arguments, if any, will be passed to the command as its\nfirst argument.\nThis way the command can produce a computed\nfrom the <value> passed in the '--trailer <token>=<value>' argument.\n\ngit interpret-trailers now includes in its man page:\n\n\nConfigure a 'help' trailer with a cmd use a script glog-find-author\nwhich search specified author identity from git log in git repository\nand show how it works:\n\n$ cat ~/bin/glog-find-author\n#!/bin/sh\ntest -n \"$1\" && git log --author=\"$1\" --pretty=\"%an <%ae>\" -1 || true\n$ git config trailer.help.key \"Helped-by: \"\n$ git config trailer.help.ifExists \"addIfDifferentNeighbor\"\n$ git config trailer.help.cmd \"~/bin/glog-find-author\"\n$ git interpret-trailers --trailer=\"help:Junio\" --trailer=\"help:Couder\" <<EOF\n> subject\n>\n> message\n>\n> EOF\nsubject\n\nmessage\n\nHelped-by: Junio C Hamano <[email protected]>\nHelped-by: Christian Couder <[email protected]>\n\n\nConfigure a 'ref' trailer with a cmd use a script glog-grep\nto grep last relevant commit from git log in the git repository\nand show how it works:\n\n$ cat ~/bin/glog-grep\n#!/bin/sh\ntest -n \"$1\" && git log --grep \"$1\" --pretty=reference -1 || true\n$ git config trailer.ref.key \"Reference-to: \"\n$ git config trailer.ref.ifExists \"replace\"\n$ git config trailer.ref.cmd \"~/bin/glog-grep\"\n$ git interpret-trailers --trailer=\"ref:Add copyright notices.\" <<EOF\n> subject\n>\n> message\n>\n> EOF\nsubject\n\nmessage\n\nReference-to: 8bc9a0c769 (Add copyright notices., 2005-04-07)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Gui: Perpetually getting \"This repository currently has approximately 320 loose objects.\"\nEvery time I start Git Gui on a particular project I get this message:\n\nThis repository currently has approximately 320 loose objects.\n\n\nI then proceed to click Yes, and I get this dialog:\n\nThe thing is, when I open Git Gui again, I get the exact same message, again about 320 loose objects! It's as if clicking Yes had no effect at all."
},
{
"role": "assistant",
"content": "Just simply skipping the pop up, as How to skip \"Loose Object\" popup when running 'git gui' suggests in the accepted answer is overlooking the fact that Git is communicating a possible performance issue to you. This should be fixable by running this command from the command line:\ncd path/to/your/git/repo\ngit gc --aggressive\n\nFrom the output of git help gc:\n\nRuns a number of housekeeping tasks within the current repository, such as compressing file revisions (to reduce disk space and increase performance) and removing unreachable objects which may have been created from prior invocations of git add.\nUsers are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good operating performance.\n--aggressive\n\nUsually git gc runs very quickly while providing good disk space utilization and performance. This option will cause git gc to more aggressively optimize the repository at the expense of taking much more time. The effects of this optimization are persistent, so this option only needs to be used occasionally; every few hundred changesets or so.\n\n\nThis should keep the prompt from popping up for a while."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to convert a Git shallow clone to a full clone?\nFollow-up of this so-question: if I have a shallow clone, how to fetch all older commits to make it a full clone?"
},
{
"role": "assistant",
"content": "The below command (git version 1.8.3) will convert the shallow clone to regular one\ngit fetch --unshallow\n\nThen, to get access to all the branches on origin (thanks @Peter in the comments)\ngit config remote.origin.fetch \"+refs/heads/*:refs/remotes/origin/*\"\ngit fetch origin"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Rebasing a branch including all its children\nI have the following Git repository topology:\nA-B-F (master)\n \\ D (feature-a)\n \\ /\n C (feature)\n \\\n E (feature-b)\n\nBy rebasing feature branch I expected to rebase the whole subtree (including child branches):\n$ git rebase feature master\n\nA-B-F (master)\n \\ D (feature-a)\n \\ /\n C (feature)\n \\\n E (feature-b)\n\nHowever, this is the actual result:\n C' (feature)\n /\nA-B-F (master)\n \\ D (feature-a)\n \\ /\n C\n \\\n E (feature-b)\n\nI know I can easily fix it manually by executing:\n$ git rebase --onto feature C feature-a\n$ git rebase --onto feature C feature-b\n\nBut is there a way to automatically rebase branch including all its children/descendants?"
},
{
"role": "assistant",
"content": "git branch --format='%(refname:short)' --contains C | \\\nxargs -n 1 \\\ngit rebase --committer-date-is-author-date --onto F C^"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to trigger fail CI/CD on eslint warning\n\nI would like to trigger fail CI/CD gitlab job on eslint warnings.\nEslint will fail on error, but in CI/CD I would like to fail on warnings too.\nHow can I do it?"
},
{
"role": "assistant",
"content": "You can fail eslint on any warnings by adding the --max-warnings=0 flag. For example:\neslint '**/*.js' --max-warnings=0"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to get notified when someone pushes into a GitHub branch?\n\nWe're are using GitHub Enterprise in our company. We have a “develop” branch where every programmer must push their work. Is there a way to get notified when someone pushes into the develop branch along with a link to a diff view, like the one you get for a pull request?"
},
{
"role": "assistant",
"content": "Not quite - but close enough. (You'll get notified for every commit, not push.)\nFor GitHub Enterprise as of mid 2014:\n\nGo into your repository's Settings\nOpen the \"Webhooks and Services\" tab\nClick \"Add Service\" button\nSelect \"Email\" from the long list of services\nPut in an e-mail address. This can be an e-mail address that forwards to multiple e-mail addresses, or just your own if only one person/account needs e-mail notifications.\nCheck \"Send From Author\" (probably) and \"Active\" (definitely).\n\nFor older versions of GitHub Enterprise:\n\nGo into your repository's Settings\nOpen the \"Service Hooks\" tab\nSelect \"Email\" from the long list of services\nPut in an e-mail address. This can be an e-mail address that forwards to multiple e-mail addresses, or just your own if only one person/account needs e-mail notifications.\nCheck \"Send From Author\" (probably) and \"Active\" (definitely).\n\nDone!\nUpdate GitHub plans on shutting down GitHub services before the end of the year. Refer"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Refname is ambiguous\nYesterday, I created a branch from a branch, pushed it to origin, and merged it back into master. You can see that here:\n$ history |less\n 8358 git co master\n 8359 commit # shortcut that adds all and commits\n 8360 push # shortcut that `git push`'s\n 8361 git lg # shortcut that logs my output\n 8362 git co 1600\n 8363 git co -b 1601\n 8364 npm run test\n 8365 npm run test\n 8366 npm run test\n 8367 npm run test\n 8368 npm run test\n 8369 npm run test\n 8370 npm run test\n 8371 npm run test\n 8372 npm run test\n 8373 npm run test\n 8374 npm run test\n 8375 npm run test\n 8376 npm run test\n 8377 ./release.sh\n 8378 ./release.sh\n 8379 commit\n 8380 push\n 8381 git push --set-upstream origin 1601\n 8382 git lg\n 8383 git co master\n 8384 git merge --no-ff -\n 8385 git st\n 8386 commit \n 8387 push \n\nI'm including irrelevant stuff in this list so I don't accidentally cut out something that is relevant; as you can see, all of this history is sequential. Here is everything in my history that refers to 1601:\n$ history | grep 1601\n 1601 npm run test\n 8363 git co -b 1601\n 8381 git push --set-upstream origin 1601\n 8438 git co 1601\n 8445 git co 1601\n 8446 git show-ref 1601\n 8447 history | grep 1601\n 8449 git show-ref | grep 1601\n 8458 git show-ref --heads --tags | grep 1601\n 8460 history | grep 1601\n 8461 history | grep (1601|merge)\n 8462 history | grep -p (1601|merge)\n 8464 history | grep -E (1601|merge)\n 8466 history | grep -E -e (1601|merge)\n 8467 history | grep -E -e \\(1601|merge\\)\n 8468 history | grep -E -e '(1601|merge)'\n 8469 history | grep -E -e '(1601|merge|master)'\n 8470 history | grep -E -e '(1601|1601|merge|master)'\n 8472 history | grep -E -e '(1601|1601|merge|master)'\n 8474 history | grep -E -e '(1601|1601|merge|master)'\n 8480 history | grep 1601\n\nSomehow, after these steps, whenever I git co 1601, it gives me this warning:\n$ git co 1601\nwarning: refname '1601' is ambiguous.\nAlready on '1601'\nYour branch is up to date with 'origin/1601'.\n\nI've been googling for a while, looking for others that have had this issue, but none of them seem to have the same situation. Here is what I've looked at that hasn't helped:\n\nGit warning: refname 'xxx' is ambiguous\nGit: refname 'master' is ambiguous\ngit refname 'origin/master' is ambiguous\nhttp://thesimplesynthesis.com/post/git-error-warning-refname-originbranch-name-is-ambiguous\n\nThe following output is to help with troubleshooting:\n$ git show-ref | grep 1601\n137b74c8ff6807f07bb32ba0d2f76a3ba287e981 refs/heads/1601\n137b74c8ff6807f07bb32ba0d2f76a3ba287e981 refs/remotes/origin/1601\n\n$ git tag -l\n\n\n$ git show-ref --heads --tags | grep 1601\n137b74c8ff6807f07bb32ba0d2f76a3ba287e981 refs/heads/1601\n\ncat .git/config\n# this is the only place where it mentions 1601\n[branch \"1601\"]\n remote = origin\n merge = refs/heads/1601\n\n$ cat .git/config | grep 1601\n[branch \"1601\"]\n merge = refs/heads/1601\n\n\n$ git checkout 1601 --\nwarning: refname '1601' is ambiguous.\nAlready on '1601'\nYour branch is up to date with 'origin/1601'.\n\n$ git ls-remote . \\*1601*\nbeea6ee68d6fe6b4f5222c0efe0e206e23af993c refs/heads/1601\nbeea6ee68d6fe6b4f5222c0efe0e206e23af993c refs/remotes/origin/1601\n\n$ git show 1601 # this only shows one log message\nwarning: refname '1601' is ambiguous.\ncommit beea6ee68d6fe6b4f5222c0efe0e206e23af993c (HEAD -> 1601, origin/1601)\n...\n\n$ git --version\ngit version 2.31.1\n\n$ type git\ngit is hashed (/usr/bin/git)\n\nFWIW, I am using cygwin on Windows.\nWhy am I getting this warning, how do I get rid of it, and how do I prevent it in the future?"
},
{
"role": "assistant",
"content": "I can get this behavior by giving a branch a name that matches the SHA1 prefix of a commit.\n$ git rev-list @ | egrep '^[0-9]{4}'\n7802d6937673dbff4d26dc906c714a054c9e883e\n81070af68e1b254c7f36eccb1261050a5a4a133a\n7537dac08fd165845b6300f32c19a52fc7fa7299\n$ git branch 7802\n$ git branch 9999\n$ git checkout 7802\nwarning: refname '7802' is ambiguous.\nSwitched to branch '7802'\n$ git checkout 9999\nSwitched to branch '9999'\n$\n\nSince object id prefixes at least four digits long are legitimate ways of referring to objects, making a ref name that's also a four-or-more-long hex string is likely to produce this kind of ambiguity. So, don't do that. If you want to number something, include a type marker, like bugfix/1601 or something."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "HTML code into README.md on Github\n\nI tried to put some HTML snippets into my README.md on Github but the HTML codes are parsed.\nHow do I do it?\n<h2>Example of code</h2>\n\n<pre>\n <div class=\"container\">\n <div class=\"block two first\">\n <h2>Your title</h2>\n <div class=\"wrap\">\n //Your content\n </div>\n </div>\n </div>\n</pre>"
},
{
"role": "assistant",
"content": "Try putting your HTML snippet inside an ```HTML block like this:\n```html\n<h2>Example of code</h2>\n\n<pre>\n <div class=\"container\">\n <div class=\"block two first\">\n <h2>Your title</h2>\n <div class=\"wrap\">\n //Your content\n </div>\n </div>\n </div>\n</pre>\n```"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to include git changelog in Jenkins emails?\nIs there any way to import the changelog that is generated by Jenkins to the subject of an email (either through the default email, or the email-ext plugin)? \nI am new to Jenkins configuration, so I apologize if this is a simple issue, but I was not able to find anything on the email-ext documentation."
},
{
"role": "assistant",
"content": "I configured my Email-ext plug-in to use the CHANGES Token (official documentation here):\nChanges:\n${CHANGES, showPaths=true, format=\"%a: %r %p \\n--\\\"%m\\\"\", pathFormat=\"\\n\\t- %p\"}\n\nThat prints the following in my build notifications:\nChanges:\nUsername: 123\n - Project/Filename1.m\n - Project/Filename2.m\n -- \"My log message\"\n\nFor HTML messages, I placed the same code within a div and added formatting:\n<div style=\"padding-left: 30px; padding-bottom: 15px;\">\n${CHANGES, showPaths=true, format=\"<div><b>%a</b>: %r %p </div><div style=\\\"padding-left:30px;\\\"> — “<em>%m</em>”</div>\", pathFormat=\"</div><div style=\\\"padding-left:30px;\\\">%p\"}\n</div>\n\nHere's a sample screenshot of how it looks in the e-mails sent out by Jenkins now (this particular commit came from Subversion, but it works exactly the same for Git and other version control systems):"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How does Git(Hub) handle possible collisions from short SHAs?\n\nBoth Git and GitHub display short versions of SHAs -- just the first 7 characters instead of all 40 -- and both Git and GitHub support taking these short SHAs as arguments.\nE.g. git show 962a9e8\nE.g. https://github.com/joyent/node/commit/962a9e8\nGiven that the possibility space is now orders of magnitude lower, \"just\" 268 million, how do Git and GitHub protect against collisions here? And how do they handle them?"
},
{
"role": "assistant",
"content": "These short forms are just to simplify visual recognition and to make your life easier. Git doesn't really truncate anything, internally everything will be handled with the complete value. You can use a partial SHA-1 at your convenience, though:\n\nGit is smart enough to figure out what commit you meant to type if you provide the first few characters, as long as your partial SHA-1 is at least four characters long and unambiguous — that is, only one object in the current repository begins with that partial SHA-1."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects --no-color-moved-ws"
},
{
"role": "assistant",
"content": "Do not ignore whitespace when performing move detection. This can be\nused to override configuration settings. It is the same as --color-moved-ws=no ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker scalar"
},
{
"role": "assistant",
"content": "A tool for managing large Git repositories"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitattributes - Defining attributes per path Unspecified"
},
{
"role": "assistant",
"content": "A path to which the diff attribute is unspecified\nfirst gets its contents inspected, and if it looks like\ntext and is smaller than core.bigFileThreshold, it is treated\nas text. Otherwise it would generate Binary files differ ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --decorate-refs=<pattern> --decorate-refs-exclude=<pattern>"
},
{
"role": "assistant",
"content": "For each candidate reference, do not use it for decoration if it\nmatches any patterns given to --decorate-refs-exclude or if it\ndoesn’t match any of the patterns given to --decorate-refs . The log.excludeDecoration config option allows excluding refs from\nthe decorations, but an explicit --decorate-refs pattern will\noverride a match in log.excludeDecoration . If none of these options or config settings are given, then references are\nused as decoration if they match HEAD , refs/heads/ , refs/remotes/ , refs/stash/ , or refs/tags/ ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the difference between an annotated and unannotated tag?\nIf I want to tag the current commit. I know both of the following command lines work:\ngit tag <tagname>\n\nand\ngit tag -a <tagname> -m '<message>'\n\nWhat is the difference between these commands?"
},
{
"role": "assistant",
"content": "TL;DR\nThe difference between the commands is that one provides you with a tag message while the other doesn't. An annotated tag has a message that can be displayed with git-show(1), while a tag without annotations is just a named pointer to a commit.\nMore About Lightweight Tags\nAccording to the documentation: \"To create a lightweight tag, don’t supply any of the -a, -s, or -m options, just provide a tag name\". There are also some different options to write a message on annotated tags:\n\nWhen you use git tag <tagname>, Git will create a tag at the current revision but will not prompt you for an annotation. It will be tagged without a message (this is a lightweight tag).\nWhen you use git tag -a <tagname>, Git will prompt you for an annotation unless you have also used the -m flag to provide a message.\nWhen you use git tag -a -m <msg> <tagname>, Git will tag the commit and annotate it with the provided message.\nWhen you use git tag -m <msg> <tagname>, Git will behave as if you passed the -a flag for annotation and use the provided message.\n\nBasically, it just amounts to whether you want the tag to have an annotation and some other information associated with it or not."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options receive.certNonceSeed"
},
{
"role": "assistant",
"content": "By setting this variable to a string, git receive-pack will accept a git push --signed and verify it by using\na \"nonce\" protected by HMAC using this string as a secret\nkey."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-am - Apply a series of patches from a mailbox --keep-non-patch"
},
{
"role": "assistant",
"content": "Pass -b flag to git mailinfo (see git-mailinfo )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How come npm install doesn't work on git bash\nI have git bash open and I type in npm install and then it returns:\nbash: npm command not found\n\nI don't understand, because I have node.js command prompt and when I type in npm -v then it returns 3.7.3. How come it doesn't work in git?"
},
{
"role": "assistant",
"content": "In our case, the solution was simply to close the Git bash window and re-open it."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index --ignore-blank-lines"
},
{
"role": "assistant",
"content": "Ignore changes whose lines are all blank."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitmodules - Defining submodule properties submodule.<name>.fetchRecurseSubmodules"
},
{
"role": "assistant",
"content": "This option can be used to control recursive fetching of this\nsubmodule. If this option is also present in the submodule’s entry in .git/config of the superproject, the setting there will override the\none found in .gitmodules .\nBoth settings can be overridden on the command line by using the --[no-]recurse-submodules option to git fetch and git pull ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git merge errors\nI have a git branch called 9-sign-in-out with perfectly working code, and I want to turn it into the master. I'm currently on the master branch.\n$ git branch\n9-sign-in-out\n* master\n\nI'm trying to switch to 9-sign-in-out branch, but it doesn't allow me to:\n$ git checkout 9-sign-in-out\napp/helpers/application_helper.rb: needs merge\nconfig/routes.rb: needs merge\nerror: you need to resolve your current index first\n\nAny idea how can I ignore all the master branch errors and turn the 9-sign-in-out branch into the master? Maybe git rebase? But I don't want to lose the code in 9-sign-in-out branch."
},
{
"role": "assistant",
"content": "It's worth understanding what those error messages mean - needs merge and error: you need to resolve your current index first indicate that a merge failed, and that there are conflicts in those files. If you've decided that whatever merge you were trying to do was a bad idea after all, you can put things back to normal with:\ngit reset --merge\n\nHowever, otherwise you should resolve those merge conflicts, as described in the git manual.\n\nOnce you've dealt with that by either technique you should be able to checkout the 9-sign-in-out branch. The problem with just renaming your 9-sign-in-out to master, as suggested in wRAR's answer is that if you've shared your previous master branch with anyone, this will create problems for them, since if the history of the two branches diverged, you'll be publishing rewritten history.\nEssentially what you want to do is to merge your topic branch 9-sign-in-out into master but exactly keep the versions of the files in the topic branch. You could do this with the following steps:\n# Switch to the topic branch:\ngit checkout 9-sign-in-out\n\n# Create a merge commit, which looks as if it's merging in from master, but is\n# actually discarding everything from the master branch and keeping everything\n# from 9-sign-in-out:\ngit merge -s ours master\n\n# Switch back to the master branch:\ngit checkout master\n\n# Merge the topic branch into master - this should now be a fast-forward\n# that leaves you with master exactly as 9-sign-in-out was:\ngit merge 9-sign-in-out"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %w([<w>[,<i1>[,<i2>]]])"
},
{
"role": "assistant",
"content": "switch line wrapping, like the -w option of git-shortlog ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc"
},
{
"role": "assistant",
"content": "Generating patch text with -p Running git-diff , git-log , git-show , git-diff-index , git-diff-tree , or git-diff-files with the -p option produces patch text.\nYou can customize the creation of patch text via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables\n(see git ), and the diff attribute (see gitattributes ). What the -p option produces is slightly different from the traditional\ndiff format: It is preceded by a \"git diff\" header that looks like this: diff --git a/file1 b/file2 The a/ and b/ filenames are the same unless rename/copy is\ninvolved. Especially, even for a creation or a deletion, /dev/null is not used in place of the a/ or b/ filenames. When a rename/copy is involved, file1 and file2 show the\nname of the source file of the rename/copy and the name of\nthe file that the rename/copy produces, respectively. It is followed by one or more extended header lines: old mode <mode>\nnew mode <mode>\ndeleted file mode <mode>\nnew file mode <mode>\ncopy from <path>\ncopy to <path>\nrename from <path>\nrename to <path>\nsimilarity index <number>\ndissimilarity index <number>\nindex <hash>..<hash> <mode> File modes are printed as 6-digit octal numbers including the file type\nand file permission bits. Path names in extended headers do not include the a/ and b/ prefixes. The similarity index is the percentage of unchanged lines, and\nthe dissimilarity index is the percentage of changed lines. It\nis a rounded down integer, followed by a percent sign. The\nsimilarity index value of 100% is thus reserved for two equal\nfiles, while 100% dissimilarity means that no line from the old\nfile made it into the new one. The index line includes the blob object names before and after the change.\nThe <mode> is included if the file mode does not change; otherwise,\nseparate lines indicate the old and the new mode. Pathnames with \"unusual\" characters are quoted as explained for\nthe configuration variable core.quotePath (see git-config ). All the file1 files in the output refer to files before the\ncommit, and all the file2 files refer to files after the commit.\nIt is incorrect to apply each change to each file sequentially. For\nexample, this patch will swap a and b: diff --git a/a b/b\nrename from a\nrename to b\ndiff --git a/b b/a\nrename from b\nrename to a Hunk headers mention the name of the function to which the hunk\napplies. See \"Defining a custom hunk-header\" in gitattributes for details of how to tailor this to\nspecific languages."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "ToC or Sidebar in GitHub Wiki\n\nHow do I create a ToC or a sidebar menu in a GitHub Wiki?\nI saw some mentions of it and gollum the backend seems to support it, but how do I do it in a current GitHub project?\nIt should best be based on the headers I have in the page automatically.\nThese links all mention it, but do not show how to do it:\n\nhttps://gist.github.com/379469 - some JavaScript hack\nhttps://github.com/blog/774-git-powered-wikis-improved - GitHub mentioning it:\n\"GitHub Wikis have a little-documented ability for footers and sidebars, something which some of\nour git-based Wiki authors are familiar with. The new Wiki editor gives you limited web-based\nediting of the footers and sidebars you have on your site. \""
},
{
"role": "assistant",
"content": "While your solution works, there's an easier way to do it using GitHub's web interface. You can simply create a page named _Sidebar and/or _Footer.\nSee detailed instructions in Github Wiki sidebar menu builder with multi-level.\nEdit The original article is gone and I can't find it in the cache so I've updated the link."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Intuitive way to view most active fork in GitHub\n\nThis is a network graph of a GitHub repository:\n\nThere is no indication of which fork has the most stars and watchers. The commits may be simple updates to documentation files, for example.\nIs there a way to evaluate forks in GitHub to determine which ones are more active/popular?"
},
{
"role": "assistant",
"content": "I don't know of one, but you could probably write one easily given the breadth of API wrappers out there. An example with github3.py would be\nimport github3\n\nr = github3.repository('owner', 'repo_name')\nmost_watched = next(r.iter_forks(sort='watchers', number=1))\n\nAs best I know, you cannot sort on stars and repositories don't have that information returned to them. You could, however, sort on forks but you would have to do it by hand.\nThe above example is two lines but you can achieve the same thing like so:\ncurl https://api.github.com/repos/owner/repo_name/forks?sort=watchers\n\nThat won't limit how many results you get, though."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options user.signingKey"
},
{
"role": "assistant",
"content": "If git-tag or git-commit is not selecting the\nkey you want it to automatically when creating a signed tag or\ncommit, you can override the default selection with this variable.\nThis option is passed unchanged to gpg’s --local-user parameter,\nso you may specify a key using any method that gpg supports.\nIf gpg.format is set to ssh this can contain the path to either\nyour private ssh key or the public key when ssh-agent is used.\nAlternatively it can contain a public key prefixed with key:: directly (e.g.: \"key::ssh-rsa XXXXXX identifier\"). The private key\nneeds to be available via ssh-agent. If not set Git will call\ngpg.ssh.defaultKeyCommand (e.g.: \"ssh-add -L\") and try to use the\nfirst key available. For backward compatibility, a raw key which\nbegins with \"ssh-\", such as \"ssh-rsa XXXXXX identifier\", is treated\nas \"key::ssh-rsa XXXXXX identifier\", but this form is deprecated;\nuse the key:: form instead."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Duplicated file with different case in git origin (bitbucket)\nI am trying to rename files from foobar.php to FooBar.php which is quite a challenge in Git. So far I have found out that I had to set up the git config value of ignorecase to false (why it was set to true on Mac OS X, anyway?). I have managed to rename those files successfully in my local repository, but after I pushed it to BitBucket I've got FooBar.php as well as foobar.php there. How do I get rid of these duplicates? Thanks."
},
{
"role": "assistant",
"content": "Case-insensitive, case-preserving\nThe problem you likely have is that the default file system on a mac is case-insensitive but case preserving; it is not possible in that circumstance for file.php and File.php to exist at the same time - they are considered the same file.\nThis is easy to demonstrate:\n$ cd /tmp\n$ mkdir example\n$ cd example/\n$ git init\nInitialized empty Git repository in /private/tmp/so/.git/ \n$ touch readme\n$ git add readme \n$ git commit -m \"adding readme\"\n[master (root-commit) 05fdf7d] adding readme\n 0 files changed\n create mode 100644 readme\n$ mv readme x\n$ git status \n# On branch master\n# Changes not staged for commit:\n# (use \"git add/rm <file>...\" to update what will be committed)\n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n# deleted: readme\n#\n# Untracked files:\n# (use \"git add <file>...\" to include in what will be committed)\n#\n# x\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n$ mv x README\n$ git status \n# On branch master\nnothing to commit (working directory clean)\n$ ls -l\ntotal 0\n-rw-r--r-- 1 andy wheel 0 Aug 1 19:38 README\n\nIn the above the file is now named README yet according to git the file readme exists and is unmodified.\nUse two commits\nSo instead of renaming the file (which on a case-insensitive system is problematic) do it as two steps:\n$ mv file.php /tmp\n$ git rm file.php\n$ git commit -m \"deleting file\"\n$ git push\n\nMake sure that the undesired file is gone from the repository. Then, move the file back to the right location and add it.\n$ mv /tmp/file.php File.php\n$ git add File.php\n$ git commit -m \"adding File\"\n$ git push"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "View a file's history in Magit?\nView the change history of a file using Git versioning talks about other ways of viewing history of a file in Git.\nCan it be done in Emacs Magit?"
},
{
"role": "assistant",
"content": "Since magit 2.1: magit-log-buffer-file (as per comment below)\nBefore magit 2.1: magit-file-log is what you are looking for. It will show you all commits for the file in the current buffer in the standard magit log view."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options http.sslTry"
},
{
"role": "assistant",
"content": "Attempt to use AUTH SSL/TLS and encrypted data transfers\nwhen connecting via regular FTP protocol. This might be needed\nif the FTP server requires it for security reasons or you wish\nto connect securely whenever remote FTP server supports it.\nDefault is false since it might trigger certificate verification\nerrors on misconfigured servers."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-parse - Pick out and massage parameters --path-format=(absolute|relative)"
},
{
"role": "assistant",
"content": "Controls the behavior of certain other options. If specified as absolute, the\npaths printed by those options will be absolute and canonical. If specified as\nrelative, the paths will be relative to the current working directory if that\nis possible. The default is option specific. This option may be specified multiple times and affects only the arguments that\nfollow it on the command line, either to the end of the command line or the next\ninstance of this option."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is it possible to create merge requests in pure Git from the command line?\nI'm using a behind-firewall install of Gitorious.\nI can go into the web application and create a pull request from a clone and target the master repo from which it was cloned.\nI'd like to be able to do this on the command line. More specifically, I'd like to be able to open merge requests from the command line from one branch to another (rather than from clone to seed repo). \nSince I'm not using Github, I can't use Github specific tools or libraries. Is this possible?"
},
{
"role": "assistant",
"content": "The answer given by svick is not correct. It is possible.\nThere's git request-pull which is part of the Git suite. Using that command line tool, you could create a pull request that could be sent per E-Mail.\nExample:\nyour origin holds a branch master. Now you create a local bugfix branch fix, implement the bug fix and push that fix branch to origin:\ngit push origin fix:fix\n\nThen, you want someone to merge the changes made in the fix branch into master. Create the pull request with\ngit request-pull master origin\n\nThis will create a text formatted as follows:\nThe following changes since commit <SHA of master>:\n\n <commit message of SHA of mster>\n\nare available in the git repository at:\n <repo location> fix\n\n<User Name> (<Number of Commits>):\n <messages of the commits>\n ...\n\n <changed files>\n ...\n <file statistics>\n\n\nIf the merge request shall go to somebody that cannot access your repo where you pushed your changes, there's always the opportunity of doing it with git format-patch.\nAfter pushing your fix branch to origin (you don't even need to do that), while being on the fix branch create the patch using\ngit format-patch master..\n\nThis will create a patch file for each commit you did in fix since branching off master. You could bundle the generated .patch files with\ntar czf fix.tgz *.patch\n\nand then send to someone e.g. via E-Mail to review and apply.\nFor the sake of completeness: applying the patches could be done with git am."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options http.<url>.*"
},
{
"role": "assistant",
"content": "Any of the http.* options above can be applied selectively to some URLs.\nFor a config key to match a URL, each element of the config key is\ncompared to that of the URL, in the following order: Scheme (e.g., https in https://example.com/ ). This field\nmust match exactly between the config key and the URL. Host/domain name (e.g., example.com in https://example.com/ ).\nThis field must match between the config key and the URL. It is\npossible to specify a * as part of the host name to match all subdomains\nat this level. https://*.example.com/ for example would match https://foo.example.com/ , but not https://foo.bar.example.com/ . Port number (e.g., 8080 in http://example.com:8080/ ).\nThis field must match exactly between the config key and the URL.\nOmitted port numbers are automatically converted to the correct\ndefault for the scheme before matching. Path (e.g., repo.git in https://example.com/repo.git ). The\npath field of the config key must match the path field of the URL\neither exactly or as a prefix of slash-delimited path elements. This means\na config key with path foo/ matches URL path foo/bar . A prefix can only\nmatch on a slash ( / ) boundary. Longer matches take precedence (so a config\nkey with path foo/bar is a better match to URL path foo/bar than a config\nkey with just path foo/ ). User name (e.g., user in https://user@example.com/repo.git ). If\nthe config key has a user name it must match the user name in the\nURL exactly. If the config key does not have a user name, that\nconfig key will match a URL with any user name (including none),\nbut at a lower precedence than a config key with a user name. The list above is ordered by decreasing precedence; a URL that matches\na config key’s path is preferred to one that matches its user name. For example,\nif the URL is https://user@example.com/foo/bar a config key match of https://example.com/foo will be preferred over a config key match of https://user@example.com . All URLs are normalized before attempting any matching (the password part,\nif embedded in the URL, is always ignored for matching purposes) so that\nequivalent URLs that are simply spelled differently will match properly.\nEnvironment variable settings always override any matches. The URLs that are\nmatched against are those given directly to Git commands. This means any URLs\nvisited as a result of a redirection do not participate in matching."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects -X[<param1,param2,…>] --dirstat[=<param1,param2,…>]"
},
{
"role": "assistant",
"content": "Output the distribution of relative amount of changes for each\nsub-directory. The behavior of --dirstat can be customized by\npassing it a comma separated list of parameters.\nThe defaults are controlled by the diff.dirstat configuration\nvariable (see git-config ).\nThe following parameters are available: changes Compute the dirstat numbers by counting the lines that have been\nremoved from the source, or added to the destination. This ignores\nthe amount of pure code movements within a file. In other words,\nrearranging lines in a file is not counted as much as other changes.\nThis is the default behavior when no parameter is given. lines Compute the dirstat numbers by doing the regular line-based diff\nanalysis, and summing the removed/added line counts. (For binary\nfiles, count 64-byte chunks instead, since binary files have no\nnatural concept of lines). This is a more expensive --dirstat behavior than the changes behavior, but it does count rearranged\nlines within a file as much as other changes. The resulting output\nis consistent with what you get from the other --*stat options. files Compute the dirstat numbers by counting the number of files changed.\nEach changed file counts equally in the dirstat analysis. This is\nthe computationally cheapest --dirstat behavior, since it does\nnot have to look at the file contents at all. cumulative Count changes in a child directory for the parent directory as well.\nNote that when using cumulative , the sum of the percentages\nreported may exceed 100%. The default (non-cumulative) behavior can\nbe specified with the noncumulative parameter. <limit> An integer parameter specifies a cut-off percent (3% by default).\nDirectories contributing less than this percentage of the changes\nare not shown in the output. Example: The following will count changed files, while ignoring\ndirectories with less than 10% of the total amount of changed files,\nand accumulating child directory counts in the parent directories: --dirstat=files,10,cumulative ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --ita-invisible-in-index"
},
{
"role": "assistant",
"content": "By default entries added by \"git add -N\" appear as an existing\nempty file in \"git diff\" and a new file in \"git diff --cached\".\nThis option makes the entry appear as a new file in \"git diff\"\nand non-existent in \"git diff --cached\". This option could be\nreverted with --ita-visible-in-index . Both options are\nexperimental and could be removed in future."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs -S<string>"
},
{
"role": "assistant",
"content": "Look for differences that change the number of occurrences of\nthe specified string (i.e. addition/deletion) in a file.\nIntended for the scripter’s use. It is useful when you’re looking for an exact block of code (like a\nstruct), and want to know the history of that block since it first\ncame into being: use the feature iteratively to feed the interesting\nblock in the preimage back into -S , and keep going until you get the\nvery first version of the block. Binary files are searched as well."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab account acces error: \"422 The change you requested was rejected.\"\n\nThis question asked by coderss but restarting the computer seems to noneffective.\n422\nThe change you requested was rejected.\nMake sure you have access to the thing you tried to change.\nPlease contact your GitLab administrator if you think this is a mistake.\nI have above error in Firefox under Linux but I have access in Chromium.\nThat's looks like typical cookie problem.\nI tried clear all Gitlab related cookies then restarted computer without any new sign in attempt. and restarted computer :) yeah I just try\nBut still same error, same browser.\nHow can I handle this problem?\nThis error also occurs at forgot password section and in private tab of Firefox.\nIs there another Gitlab related cookie?"
},
{
"role": "assistant",
"content": "The issue should be fixed not only with cookies as discribed, but also with a correction of time system.\nI faced exactly the same problem: unable to connect with Firefox, even with a reset of cookies, but I was able to connect with Chrome. (That sounds strange because my clock system was false even on Chrome.)\nThe solution came with this very short explanation:\n\n\"it's was because my local time zone wasn't set up properly (and was messing with cookies)\"\nSource: https://www.reddit.com/r/gitlab/comments/cv7pov/422_error_on_wwwgitlabcomuserssignin_and/ey7l7lz?utm_source=share&utm_medium=web2x&context=3"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Rebuild Docker container on file changes\nFor running an ASP.NET Core application, I generated a dockerfile which build the application and copys the source code in the container, which is fetched by Git using Jenkins. So in my workspace, I do the following in the dockerfile: \nWORKDIR /app\nCOPY src src\n\nWhile Jenkins updates the files on my host correctly with Git, Docker doesn't apply this to my image. \nMy basic script for building:\n#!/bin/bash\nimageName=xx:my-image\ncontainerName=my-container\n\ndocker build -t $imageName -f Dockerfile .\n\ncontainerRunning=$(docker inspect --format=\"{{ .State.Running }}\" $containerName 2> /dev/null)\n\nif [ \"$containerRunning\" == \"true\" ]; then\n docker stop $containerName\n docker start $containerName\nelse\n docker run -d -p 5000:5000 --name $containerName $imageName\nfi\n\nI tried different things like --rm and --no-cache parameter for docker run and also stopping/removing the container before the new one is build. I'm not sure what I'm doing wrong here. It seems that docker is updating the image correctly, as the call of COPY src src would result in a layer id and no cache call: \nStep 6 : COPY src src\n ---> 382ef210d8fd\n\nWhat is the recommended way to update a container? \nMy typical scenario would be: The application is running on the server in a Docker container. Now parts of the app are updated, e.g. by modifying a file. Now the container should run the new version. Docker seems to recommend building a new image instead of modifying a existing container, so I think the general way of rebuilding like I do is right, but some detail in the implementation has to be improved."
},
{
"role": "assistant",
"content": "Video with visual explanation (from 2022)\n\nSince I got a lot of positive feedback to my previous, first visual explanation, I decided to create another video for this question and answer since there are some things which can be visualized better in a graphical video. It visualizes and also updates this answer with the knowledge and experience which I got in the last years using Docker on multiple systems (and also K8s).\nWhile this question was asked in the context of ASP.NET Core, it is not really related to this framework. The problem was a lack of basic understanding of Docker concepts, so it can happen with nearly every application and framework. For that reason, I used a simple Nginx webserver here since I think many of you are familiar with web servers, but not everyone knows how specific frameworks like ASP.NET Core works.\nThe underlying problem is to understand the difference between containers vs images and how they are different in their lifecycle, which is the basic topic of this video.\nTextual answer (Originally from 2016)\nAfter some research and testing, I found that I had some misunderstandings about the lifetime of Docker containers. Simply restarting a container doesn't make Docker use a new image, when the image was rebuilt in the meantime. Instead, Docker is fetching the image only before creating the container. So the state after running a container is persistent.\nWhy removing is required\nTherefore, rebuilding and restarting isn't enough. I thought containers work like a service: Stop the service, do your changes, restart it and they would apply. That was my biggest mistake.\nBecause containers are permanent, you have to remove them using docker rm <ContainerName> first. After a container is removed, you can't simply start it by docker start. This has to be done using docker run, which itself uses the latest image for creating a new container instance.\nContainers should be as independent as possible\nWith this knowledge, it's comprehensible why storing data in containers is considered a bad practice and Docker recommends data volumes/mounting host directories instead: Since a container has to be destroyed to update applications, the stored data inside would be lost too. This causes extra work to shutdown services, back up data and so on.\nSo it's a smart solution to exclude those data completely from the container: We don't have to worry about our data, when it's stored safely on the host and the container only holds the application itself.\nWhy -rf may not really help you\nThe docker run command, has a clean up switch called -rf. It will stop the behavior of keeping Docker containers permanently. Using -rf, Docker will destroy the container after it has been exited. But this switch has a problem: Docker also removes the volumes without a name associated with the container, which may kill your data.\nWhile the -rf switch is a good option to save work during development for quick tests, it's less suitable in production. Especially because of the missing option to run a container in the background, which would mostly be required.\nHow to remove a container\nWe can bypass those limitations by simply removing the container:\ndocker rm --force <ContainerName>\n\nThe --force (or -f) switch which uses SIGKILL on running containers. Instead, you could also stop the container before:\ndocker stop <ContainerName>\ndocker rm <ContainerName>\n\nBoth are equal. docker stop also uses SIGTERM. But using the --force switch will shorten your script, especially when using CI servers: docker stop throws an error if the container is not running. This would cause Jenkins and many other CI servers to consider the build wrongly as failed. To fix this, you have to check first if the container is running as I did in the question (see containerRunning variable).\nThere is a better way (Added 2016)\nWhile plain docker commands like docker build, docker run and others are a good way for beginners to understand basic concepts, it's getting annoying when you're already familiar with Docker and want to get productive. A better way is to use Docker-Compose. While it's designed for multi-container environments, it also gives you benefits when using standalone with a single container. Although multi-container environments aren't really uncommon. Nearly every application has at least an application server and some database. Some even more like caching servers, cron containers or other things.\nversion: \"2.4\"\nservices:\n my-container:\n build: .\n ports:\n - \"5000:5000\"\n\nNow you can just use docker-compose up --build and compose will take care of all the steps which I did manually. I'd prefer this one over the script with plain Docker commands, which I added as an answer from 2016. It still works, but is more complex and it won't handle certain situations as well as docker-compose would. For example, compose checks if everything is up to date and only rebuilds those things which need to be rebuilt because of changes.\nEspecially when you're using multiple containers, compose offers way more benefits. For example, linking the containers which requires creating/maintaining networks manually otherwise. You can also specify dependencies so that a database container is started before the application server, which depends on the DB at startup.\nIn the past with Docker-Compose 1.x I noticed some issues, especially with caching. This results in containers not being updated, even when something had changed. I have tested compose v2 for some time now without seeing any of those issues again, so it seems to be fixed now.\nFull script for rebuilding a Docker container (original answer from 2016)\nAccording to this new knowledge, I fixed my script in the following way:\n#!/bin/bash\nimageName=xx:my-image\ncontainerName=my-container\n\ndocker build -t $imageName -f Dockerfile .\n\necho Delete old container...\ndocker rm -f $containerName\n\necho Run new container...\ndocker run -d -p 5000:5000 --name $containerName $imageName\n\nThis works perfectly :)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.colorMoved"
},
{
"role": "assistant",
"content": "If set to either a valid <mode> or a true value, moved lines\nin a diff are colored differently, for details of valid modes\nsee --color-moved in git-diff . If simply set to\ntrue the default color mode will be used. When set to false,\nmoved lines are not colored."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-ls-files - Show information about files in the index and the working tree M"
},
{
"role": "assistant",
"content": "tracked file that is unmerged"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do you tell git to stash the index only?\nI have just used git add -p to add a bunch of changes to the index, and I just realised that I missed a change that should've gone into the previous commit.\nI can't commit --amend now because I've added all these new changes to the index, and I don't want to use 'git reset' to remove them all from the index as it will take ages to add them all back in again.\nWhat I need is something like git stash that will only stash the index – it should leave the working files alone. Then I can stash the index, add the missing change, commit it, then pop the stash and have my index back the way it was.\nIt doesn't look like git stash is able to do this, but am I missing something? Thanks!"
},
{
"role": "assistant",
"content": "The closest thing I've found is git stash --patch. It walks you through each of the changes to working tree and index letting you choose what to stash. \nhttp://www.kernel.org/pub/software/scm/git/docs/git-stash.html"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options http.sslVerify"
},
{
"role": "assistant",
"content": "Whether to verify the SSL certificate when fetching or pushing\nover HTTPS. Defaults to true. Can be overridden by the GIT_SSL_NO_VERIFY environment variable."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I get Composer to download the latest commit in the master branch from GitHub for a package?\nI am trying to get Composer do download the latest commit for the Behat/MinkSelenium2Driver package. That particular repo only has a master branch. I have tried every method I can think of, including deleting the files and letting it pull them back in, to get it to work but it doesn't.\nHow would I get it to pull in latest committed files or at least those from the commit I list below?\nSpecifically I want to get this commit:\nhttps://github.com/Behat/MinkSelenium2Driver/commit/2e73d8134ec8526b6e742f05c146fec2d5e1b8d6\nThanks,\nPatrick"
},
{
"role": "assistant",
"content": "There is only one way to grab the head of the repository: \n\"require\": { \"behat/mink-selenium2-driver\" : \"dev-master\" }\n\"minimum-stability\": \"dev\"\n\nOh well, at least two ways:\n\"require\": { \"behat/mink-selenium2-driver\" : \"dev-master as 1.1.x-dev\" }\n\"minimum-stability\": \"dev\"\n\nProbably at least three ways:\n\"require\": { \"behat/mink-selenium2-driver\" : \"dev-master#2e73d8134ec8526b6e742f05c146fec2d5e1b8d6\" }\n\"minimum-stability\": \"dev\"\n\nBecause that repository actually aliased the master branch as 1.1.x-dev, this would also work without the minimum-stability affecting all other packages:\n\"require\": { \"behat/mink-selenium2-driver\" : \"1.1.*@dev\" }"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Undoing a git bisect mistake\nI'm doing a non-automated git bisect via command line. All is going well until I accidentally hit return on the wrong line in my command history, and rather than running the test, I run 'git bisect good' (or bad). Oops - I don't yet know if this commit should be marked good or bad, yet that's what I've done. \nCan I undo the 'git bisect good' command, or make git forget the result of it, and go back and run the test for that commit?"
},
{
"role": "assistant",
"content": "From the git-bisect documentation:\n\nBisect log and bisect replay\nAfter having marked revisions as good or bad, issue the following command to show what has been done so far:\n$ git bisect log\n\nIf you discover that you made a mistake in specifying the status of a revision, you can save the output of this command to a file, edit it to remove the incorrect entries, and then issue the following commands to return to a corrected state:\n$ git bisect reset\n$ git bisect replay that-file"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker -c <name>=<value>"
},
{
"role": "assistant",
"content": "Pass a configuration parameter to the command. The value\ngiven will override values from configuration files.\nThe <name> is expected in the same format as listed by git config (subkeys separated by dots). Note that omitting the = in git -c foo.bar ... is allowed and sets foo.bar to the boolean true value (just like [foo]bar would in a\nconfig file). Including the equals but with an empty value (like git -c\nfoo.bar= ... ) sets foo.bar to the empty string which git config\n--type=bool will convert to false ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "error: RPC failed; curl transfer closed with outstanding read data remaining\n\nI'm facing this error when I try to clone a repository from GitLab (GitLab 6.6.2 4ef8369):\nremote: Counting objects: 66352, done.\nremote: Compressing objects: 100% (10417/10417), done.\nerror: RPC failed; curl 18 transfer closed with outstanding read data remaining\nfatal: The remote end hung up unexpectedly\nfatal: early EOF\nfatal: index-pack failed\n\nThe clone is then aborted. How can I avoid this?"
},
{
"role": "assistant",
"content": "It happens more often than not, I am on a slow internet connection and I have to clone a decently huge git repository. The most common issue is that the connection closes and the whole clone is cancelled.\nCloning into 'large-repository'...\nremote: Counting objects: 20248, done.\nremote: Compressing objects: 100% (10204/10204), done.\nerror: RPC failed; curl 18 transfer closed with outstanding read data remaining \nfatal: The remote end hung up unexpectedly\nfatal: early EOF\nfatal: index-pack failed\n\nAfter a lot of trial and errors and a lot of “remote end hung up unexpectedly” I have a way that works for me. The idea is to do a shallow clone first and then update the repository with its history.\n$ git clone http://github.com/large-repository --depth 1\n$ cd large-repository\n$ git fetch --unshallow"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-svn - Bidirectional operation between a Subversion repository and Git --preserve-empty-dirs"
},
{
"role": "assistant",
"content": "Create a placeholder file in the local Git repository for each\nempty directory fetched from Subversion. This includes directories\nthat become empty by removing all entries in the Subversion\nrepository (but not the directory itself). The placeholder files\nare also tracked and removed when no longer necessary."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Setting up a Github Commit RSS feed\n\nI am trying to have my github commits as an RSS feed but so far I have not managed to figure it out. I know that a private feed is available with the following syntax:\nhttps://github.com/username.atom?token=token\n\nBut this the user's activity feed. I would like a commit feed of one of my projects.\nUpdate: This was the final syntax:\nhttps://github.com/username/repository_name/commits/branch_name.atom?login=login&token=token. \n\nStill can't view commits on all branches though."
},
{
"role": "assistant",
"content": "You want https://github.com/whatever/commits/master.atom, like for the Cloudera flume repository it's https://github.com/cloudera/flume/commits/master.atom."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --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": "git-push - Update remote refs along with associated objects push.negotiate"
},
{
"role": "assistant",
"content": "If set to \"true\", attempt to reduce the size of the packfile\nsent by rounds of negotiation in which the client and the\nserver attempt to find commits in common. If \"false\", Git will\nrely solely on the server’s ref advertisement to find commits\nin common."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-clean - Remove untracked files from the working tree"
},
{
"role": "assistant",
"content": "SYNOPSIS git clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] [<pathspec>…]"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-add - Add file contents to the index diff"
},
{
"role": "assistant",
"content": "This lets you review what will be committed (i.e. between\nHEAD and index)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs -m"
},
{
"role": "assistant",
"content": "Show diffs for merge commits in the default format. This is\nsimilar to --diff-merges=on , except -m will\nproduce no output unless -p is given as well."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-read-tree - Reads tree information into the index --aggressive"
},
{
"role": "assistant",
"content": "Usually a three-way merge by git read-tree resolves\nthe merge for really trivial cases and leaves other\ncases unresolved in the index, so that porcelains can\nimplement different merge policies. This flag makes the\ncommand resolve a few more cases internally: when one side removes a path and the other side leaves the path\nunmodified. The resolution is to remove that path. when both sides remove a path. The resolution is to remove that path. when both sides add a path identically. The resolution\nis to add that path."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index --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": "I can't delete a remote master branch on git\n\nI need to delete a master branch, but it's proving to be hard. I just want to clean that branch out and start new. I am deleting from the dev branch. I want master on GitHub to be clean.\n # git push origin --delete master\n\n> To https://github.com/mymasterb.git ! [remote rejected] master\n> (deletion of the current branch prohibited) error: failed to push some\n> refs to 'https://github.com/mymaster.git'\n\nHow do I quite simply start my master with a fresh slate?"
},
{
"role": "assistant",
"content": "As explained in \"Deleting your master branch\" by Matthew Brett, you need to change your GitHub repo default branch.\n\nYou need to go to the GitHub page for your forked repository, and click on the “Settings” button.\nClick on the \"Branches\" tab on the left hand side. There’s a “Default branch” dropdown list near the top of the screen. \nFrom there, select placeholder (where placeholder is the dummy name for your new default branch).\nConfirm that you want to change your default branch.\nNow you can do (from the command line):\n\ngit push origin :master\n\nOr, since 2012, you can delete that same branch directly on GitHub:\n\nThat was announced in Sept. 2013, a year after I initially wrote that answer.\n\nFor small changes like documentation fixes, typos, or if you’re just a walking software compiler, you can get a lot done in your browser without needing to clone the entire repository to your computer.\n\n\nNote: for BitBucket, Tum reports in the comments:\n\nAbout the same for Bitbucket\nRepo -> Settings -> Repository details -> Main branch"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to unfork a GitHub repository?\n\nHow can I unfork a GitHub repository?\nI have never seen unfork option — is it possible to do that?"
},
{
"role": "assistant",
"content": "As of now Github doesn't have an unfork option, so the only solution is to delete the forked repo.\n\nWarning: The following solution will delete your cloned repo.\nIf you want unfork without your repo is being deleted try this https://stackoverflow.com/a/41486339/6335029\n\nStep 1: Goto Settings of Repo you want to unfork\nStep 2: Click Delete this Repository\n\nStep 3: Enter your name / Repo name\nStep 4: click \"I understand the consequences, delete this repository\" button"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Recursive git update-index --assume-unchanged\nI'm trying to run the following:\ngit update-index --assume-unchanged myFolderToIgnore\n\nWhere myFolderToIgnore is a folder. However it fails saying its \"unable to mark\" it.\nSo I tried:\ngit update-index --assume-unchanged myFolderToIgnore/\n\nWhich GIT responds to with Ignoring path myFolderToIgnore/ but doesn't do anything (it still sees my changes and tries to check them in).\nIn the end I had to go in and manually mark each individual file as unchanged. What am I missing here?"
},
{
"role": "assistant",
"content": "update-index is an internal plumbing command and thus not as comfortable as the real front-end commands. You will have to handle the recursion bit yourself:\ngit ls-files -z myFolderToIgnore/ | xargs -0 git update-index --assume-unchanged\n\n\nPSA: There is a high chance that assume-unchanged is not what you are looking for and you should use skip-worktree instead. See here for more info."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs git log --no-merges"
},
{
"role": "assistant",
"content": "Show the whole commit history, but skip any merges"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "The shortest possible output from git log containing author and date\nHow can I show a git log output with (at least) this information: \n* author\n* commit date\n* change\n\nI want it compressed to one line per log entry. What's the shortest possible format for that?\n(tried --format=oneline but that does not show the date)"
},
{
"role": "assistant",
"content": "git log --pretty=format:\"%h%x09%an%x09%ad%x09%s\"\n\ndoes the job. This outputs:\n fbc3503 mads Thu Dec 4 07:43:27 2008 +0000 show mobile if phone is null... \n ec36490 jesper Wed Nov 26 05:41:37 2008 +0000 Cleanup after [942]: Using timezon\n ae62afd tobias Tue Nov 25 21:42:55 2008 +0000 Fixed #67 by adding time zone supp\n 164be7e mads Tue Nov 25 19:56:43 2008 +0000 fixed tests, and a 'unending appoi\n 93f1526 jesper Tue Nov 25 09:45:56 2008 +0000 adding time.ZONE.now as time zone \n 2f0f8c1 tobias Tue Nov 25 03:07:02 2008 +0000 Timezone configured in environment\n a33c1dc jesper Tue Nov 25 01:26:18 2008 +0000 updated to most recent will_pagina\n \n\nInspired by stackoverflow question: \"git log output like svn ls -v\", I found out that I could add the exact params I needed.\nTo shorten the date (not showing the time) use --date=short\nIn case you were curious what the different options were:\n%h = abbreviated commit hash\n%x09 = tab (character for code 9)\n%an = author name\n%ad = author date (format respects --date= option)\n%s = subject\nFrom kernel.org/pub/software/scm/git/docs/git-log.html (PRETTY FORMATS section) by comment of Vivek."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rebase - Reapply commits on top of another base tip ort"
},
{
"role": "assistant",
"content": "This is the default merge strategy when pulling or merging one\nbranch. This strategy can only resolve two heads using a\n3-way merge algorithm. When there is more than one common\nancestor that can be used for 3-way merge, it creates a merged\ntree of the common ancestors and uses that as the reference\ntree for the 3-way merge. This has been reported to result in\nfewer merge conflicts without causing mismerges by tests done\non actual merge commits taken from Linux 2.6 kernel\ndevelopment history. Additionally this strategy can detect\nand handle merges involving renames. It does not make use of\ndetected copies. The name for this algorithm is an acronym\n(\"Ostensibly Recursive’s Twin\") and came from the fact that it\nwas written as a replacement for the previous default\nalgorithm, recursive . The ort strategy can take the following options: ours This option forces conflicting hunks to be auto-resolved cleanly by\nfavoring our version. Changes from the other tree that do not\nconflict with our side are reflected in the merge result.\nFor a binary file, the entire contents are taken from our side. This should not be confused with the ours merge strategy, which does not\neven look at what the other tree contains at all. It discards everything\nthe other tree did, declaring our history contains all that happened in it. theirs This is the opposite of ours ; note that, unlike ours , there is\nno theirs merge strategy to confuse this merge option with. ignore-space-change ignore-all-space ignore-space-at-eol ignore-cr-at-eol Treats lines with the indicated type of whitespace change as\nunchanged for the sake of a three-way merge. Whitespace\nchanges mixed with other changes to a line are not ignored.\nSee also git-diff -b , -w , --ignore-space-at-eol , and --ignore-cr-at-eol . If their version only introduces whitespace changes to a line, our version is used; If our version introduces whitespace changes but their version includes a substantial change, their version is used; Otherwise, the merge proceeds in the usual way. renormalize This runs a virtual check-out and check-in of all three stages\nof a file when resolving a three-way merge. This option is\nmeant to be used when merging branches with different clean\nfilters or end-of-line normalization rules. See \"Merging\nbranches with differing checkin/checkout attributes\" in gitattributes for details. no-renormalize Disables the renormalize option. This overrides the merge.renormalize configuration variable. find-renames[=<n>] Turn on rename detection, optionally setting the similarity\nthreshold. This is the default. This overrides the merge.renames configuration variable.\nSee also git-diff --find-renames . rename-threshold=<n> Deprecated synonym for find-renames=<n> . subtree[=<path>] This option is a more advanced form of subtree strategy, where\nthe strategy makes a guess on how two trees must be shifted to\nmatch with each other when merging. Instead, the specified path\nis prefixed (or stripped from the beginning) to make the shape of\ntwo trees to match."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-update-ref - Update the object name stored in a ref safely"
},
{
"role": "assistant",
"content": "NAME git-update-ref - Update the object name stored in a ref safely"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I undo pushed commits using git?\nI have a project in a remote repository, synchronized with a local repository (development) and the server one (prod). I've been making some commited changes already pushed to remote and pulled from the server. Now, I want to undo those changes. So I could just git checkout to the commit before the changes and commit the new changes, but I'm guessing that there will be problems to push them again to remote. Any suggestion on how should I proceed?"
},
{
"role": "assistant",
"content": "You can revert individual commits with:\ngit revert <commit_hash>\n\nThis will create a new commit which reverts the changes of the commit you specified. Note that it only reverts that specific commit, and not commits that come after that. If you want to revert a range of commits, you can do it like this:\ngit revert <oldest_commit_hash>..<latest_commit_hash>\n\nIt reverts all the commits after <oldest_commit_hash> up to and including <latest_commit_hash>. Some versions of git also revert the <oldest_commit_hash> itself, so double check if that commit gets reverted or not. You can always drop the latest revert commit (which reverts the oldest commit) with g reset --hard HEAD~.\nTo find out the hash of the commit(s) you can use git log.\nLook at the git-revert man page for more information about the git revert command. Also, look at this answer for more information about reverting commits.\nExtra note for re-applying reverted commits:\nUsually you revert commits because you discovered the commits that you pushed turn out to have an issue. Then you first want to restore the repo to a stable state, before you continue to fix the issue. So then you would first do the git revert, as described before. Then push those revert commits, so the remote is stable. After that you would want to re-apply the reverted commits locally, so your local repo's files are back to the state before the revert. Then you can fix the issue.\nTo re-apply the reverted commits, you have to revert the revert commits. So what you would do, is to again execute the git revert command, but then with the range of commits of the revert commits. So your new revert commits will revert the previous revert commits. Then your files are back to the state before the first revert. Then you can fix the issue, create a new commit with the fix, and then push the new commits."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can't seem to discard changes in Git\nAfter seeing the following from the command line:\n# On branch RB_3.0.10\n# Changed but not updated:\n# (use \"git add <file>...\" to update what will be committed)\n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n# modified: index.htm\n\nI am trying to discard my changes by typing the command:\ngit checkout -- index.htm\n\nbut when I re-run git status, it looks exactly the same. The checkout doesn't seem to be working. Am I doing something wrong? I am using GIT 1.6.1.2 on windows/cygwin.\n# On branch RB_3.0.10\n# Changed but not updated:\n# (use \"git add <file>...\" to update what will be committed)\n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n# modified: index.htm"
},
{
"role": "assistant",
"content": "This has been bothering me for a while, almost every repo I'd check out had changes that I couldn't discard. Long story short, I tried all of the above, nothing worked. This is what I did to get things back to normal (on a Mac):\nCompletely remove the autocrlf & safecrlf settings from ~/.gitconfig\nCompletely remove the autocrlf & safecrlf settings from your repo's local config ./.git/config\ngit rm --cached -r .\ngit reset --hard"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitremote-helpers"
},
{
"role": "assistant",
"content": "Helper programs to interact with remote repositories"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-fetch-pack"
},
{
"role": "assistant",
"content": "Receive missing objects from another repository"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options log.decorate"
},
{
"role": "assistant",
"content": "Print out the ref names of any commits that are shown by the log\ncommand. If short is specified, the ref name prefixes refs/heads/ , refs/tags/ and refs/remotes/ will not be printed. If full is\nspecified, the full ref name (including prefix) will be printed.\nIf auto is specified, then if the output is going to a terminal,\nthe ref names are shown as if short were given, otherwise no ref\nnames are shown. This is the same as the --decorate option\nof the git log ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_ALLOW_PROTOCOL"
},
{
"role": "assistant",
"content": "If set to a colon-separated list of protocols, behave as if protocol.allow is set to never , and each of the listed\nprotocols has protocol.<name>.allow set to always (overriding any existing configuration). See the description of protocol.allow in git-config for more details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the best way to resolve Rails orphaned migrations?\nI have been switching between branches in a project and each of them have different migrations... This is the scenario:\n\n$ rake db:migrate:status\n\n Status Migration ID Migration Name\n--------------------------------------------------\n ...\n up 20130307154128 Change columns in traffic capture\n up 20130311155109 Remove log settings\n up 20130311160901 Remove log alarm table\n up 20130320144219 ********** NO FILE **********\n up 20130320161939 ********** NO FILE **********\n up 20130320184628 ********** NO FILE **********\n up 20130322004817 Add replicate to root settings\n up 20130403190042 ********** NO FILE **********\n up 20130403195300 ********** NO FILE **********\n up 20130403214000 ********** NO FILE **********\n up 20130405164752 Fix ap hostnames\n up 20130410194222 ********** NO FILE **********\n\nThe problem is rake db:rollback don't work at all because of the missing files...\nWhat should I do to be able to rollback again and get rid of the NO FILE messages?\nBtw, rake db:reset or rake db:drop are not an option, I cannot lose data from other tables..."
},
{
"role": "assistant",
"content": "I ended up solving the problem like this:\n(1) Go to the branches that has the migration files and roll them back. This is not trivial when you have many branches which are will result in many conflicts if you try to merge them. So I use this commands to find out the branches of each orphan migration belongs to.\nSo, I need to find commit of the last time the migration was modified.\ngit log --all --reverse --stat | grep <LASTEST_ORPHAN_MIGRATION_ID> -C 10\n\nI take the commit hash and determine which branch it belongs like this:\ngit branch --contains <COMMIT_HASH>\n\nThen I can go back to that branch, do a rollback and repeat this process for all the missing files.\n(2) Run migrations: checkout the branch you finally want to work on and run the migrations and you should be good to go.\nTroubleshooting\nI also ran in some cases where orphaned migrations where on deleted branches.\nTo solve this I created dummy migration files with the same migration_id of the missing files and roll them back. After that, I was able to delete they dummy migrations and have a clean migration status :)\nAnother alternative is deleting the missing files from the database directly (rails dbconsole):\ndelete from schema_migrations where version='<MIGRATION_ID>';"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to remove specific commits from Git? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nRemove specific commit\n\n (17 answers)\n \n\nClosed 6 years ago.\n\n\n\nI want to remove few commits from my remote repository. I have few commits like this in my repo:\ncommits messages\n\nabcd123 some message\nxyze456 another commit message\n98y65r4 this commit is not required\n987xcrt this commit is not required\nbl8976t initial commit\n\nI want to remove commit 98y65r4 and 987xcrt from my repo. How to achieve it?"
},
{
"role": "assistant",
"content": "There are two alternatives to this: the safe one that leaves you with a dirty git history, or the unsafe one that leaves you with a clean git history. You pick:\nOption 1: Revert\nYou can tell git to \"Revert a commit\". This means it will introduce a change that reverts each change you made in a commit. You would need to execute it twice (once per commit):\ngit revert 98y65r4\ngit revert 987xcrt\n\nThis solution will leave your git history like this (you can execute gitk --all to see a graphical representation of the state of your repo):\n2222222 revert of 987xcrt: this commit is not required\n1111111 revert of 98y65r4: this commit is not required\nabcd123 some message\nxyze456 another commit message\n98y65r4 this commit is not required\n987xcrt this commit is not required\nbl8976t initial commit\n\nThen you can push the new 2 commits to your remote repo:\ngit push\n\nThis solution is safe because it does not make destructive operations on your remote repo.\nOption 2: Interactive rebase\nYou also can use an interactive rebase for that. The command is:\ngit rebase -i bl8976t\n\nIn it, you are telling git to let you select which commits you want to mix together, reorder or remove.\nWhen you execute the command an editor will open with a text similar to this:\npick bl8976t initial commit\npick 987xcrt this commit is not required\npick 98y65r4 this commit is not required\npick xyze456 another commit message\npick abcd123 some message\n\nJust go on and delete the lines you don't want, like this:\npick bl8976t initial commit\npick xyze456 another commit message\npick abcd123 some message\n\nSave the file and close the editor.\nSo far, this has only modified the local copy of your repository (you can see the tree of commits with gitk --all).\nNow you need to push your changes to your repo, which is done with a \"push force\", but before you execute the command bear in mind that push force is a destructive operation, it will overwrite the history of your remote repository and can cause merge troubles to other people working on it. If you are ok and want to do the push force, the command is:\ngit push -f"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Export git with version history\nI need to export a git repository content and import it in a target repository. I know of two alternatives to do it, but they do not solve my problem\na) Add the source repository as a remote and do a merge to the target. I cannot use this as both repositories are not on the same network\nb) Use git archive and copy the contents to the target. In this git archive the revision info is lost.\nI need something that does an archive along with the version history and enables me to merge in the target. How can this be done?"
},
{
"role": "assistant",
"content": "git bundle is provided for this exact purpose.\nExample:\n\nBundle your source repository in its entirety\ngit bundle create my_repo.bundle --all\nTake ``my_repo.bundle'' to where your target is\nFrom your target, load up your source commit objects\ngit bundle unbundle my_repo.bundle\n...from which point you can merge/rebase/cherry-pick your desired source commits into your target repository to your heart's content.\nOtherwise, pulling works just the same:\ngit pull my_repo.bundle\n\nCompared to cloning, bundles are easier to transfer because they're smaller as your files aren't carried in their checked out state.\nOther reasons for using bundle:\n\nUnlike using clone --bare (which doesn't checkout your files),\nbundles are created and packed as a single file so you don't need\nadditional compressing/tarballing.\nYou could also simply tarball your source repository (or just the\n.git directory), but you'll be carrying over all the excess cache and\ngarbage that builds up under .git/."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-commit - Record changes to the repository"
},
{
"role": "assistant",
"content": "DISCUSSION Though not required, it’s a good idea to begin the commit message\nwith a single short (no more than 50 characters) line summarizing the\nchange, followed by a blank line and then a more thorough description.\nThe text up to the first blank line in a commit message is treated\nas the commit title, and that title is used throughout Git.\nFor example, git-format-patch turns a commit into email, and it uses\nthe title on the Subject line and the rest of the commit in the body. Git is to some extent character encoding agnostic. The contents of the blob objects are uninterpreted sequences\nof bytes. There is no encoding translation at the core\nlevel. Path names are encoded in UTF-8 normalization form C. This\napplies to tree objects, the index file, ref names, as well as\npath names in command line arguments, environment variables\nand config files ( .git/config (see git-config ), gitignore , gitattributes and gitmodules ). Note that Git at the core level treats path names simply as\nsequences of non-NUL bytes, there are no path name encoding\nconversions (except on Mac and Windows). Therefore, using\nnon-ASCII path names will mostly work even on platforms and file\nsystems that use legacy extended ASCII encodings. However,\nrepositories created on such systems will not work properly on\nUTF-8-based systems (e.g. Linux, Mac, Windows) and vice versa.\nAdditionally, many Git-based tools simply assume path names to\nbe UTF-8 and will fail to display other encodings correctly. Commit log messages are typically encoded in UTF-8, but other\nextended ASCII encodings are also supported. This includes\nISO-8859-x, CP125x and many others, but not UTF-16/32,\nEBCDIC and CJK multi-byte encodings (GBK, Shift-JIS, Big5,\nEUC-x, CP9xx etc.). Although we encourage that the commit log messages are encoded\nin UTF-8, both the core and Git Porcelain are designed not to\nforce UTF-8 on projects. If all participants of a particular\nproject find it more convenient to use legacy encodings, Git\ndoes not forbid it. However, there are a few things to keep in\nmind. git commit and git commit-tree issue\na warning if the commit log message given to it does not look\nlike a valid UTF-8 string, unless you explicitly say your\nproject uses a legacy encoding. The way to say this is to\nhave i18n.commitEncoding in .git/config file, like this: [i18n]\n\tcommitEncoding = ISO-8859-1 Commit objects created with the above setting record the value\nof i18n.commitEncoding in their encoding header. This is to\nhelp other people who look at them later. Lack of this header\nimplies that the commit log message is encoded in UTF-8. git log , git show , git blame and friends look at the encoding header of a commit object, and try to re-code the\nlog message into UTF-8 unless otherwise specified. You can\nspecify the desired output encoding with i18n.logOutputEncoding in .git/config file, like this: [i18n]\n\tlogOutputEncoding = ISO-8859-1 If you do not have this configuration variable, the value of i18n.commitEncoding is used instead. Note that we deliberately chose not to re-code the commit log\nmessage when a commit is made to force UTF-8 at the commit\nobject level, because re-coding to UTF-8 is not necessarily a\nreversible operation."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-difftool - Show changes using common diff tools difftool.<tool>.path"
},
{
"role": "assistant",
"content": "Override the path for the given tool. This is useful in case\nyour tool is not in the PATH."
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.