messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_TRACE_PACK_ACCESS" }, { "role": "assistant", "content": "Enables trace messages for all accesses to any packs. For each\naccess, the pack file name and an offset in the pack is\nrecorded. This may be helpful for troubleshooting some\npack-related performance problems.\nSee GIT_TRACE for available trace output options." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitmodules - Defining submodule properties submodule.<name>.update" }, { "role": "assistant", "content": "Defines the default update procedure for the named submodule,\ni.e. how the submodule is updated by the git submodule update command in the superproject. This is only used by git\nsubmodule init to initialize the configuration variable of\nthe same name. Allowed values here are checkout , rebase , merge or none , but not !command (for security reasons).\nSee the description of the update command in git-submodule for more details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to find my GitHub username so that I can be found via the URL? [closed]\n\nClosed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\n This question does not appear to be about programming within the scope defined in the help center.\n\n\nClosed 10 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI'm confused about my GitHub username\n\nIs it the one that is being displayed on the top right corner of the window?\nOr is it the one I created using \"git config --global user.name\" from my shell?\n\nI need to give it in a job application form." }, { "role": "assistant", "content": "The one displayed in the top right corner in GitHub is your GitHub username - this is the one you use to login to GitHub when you enter the site and when you commit over HTTPS, and the one that appears in the URLs of your GitHub repositories.\nThe one you create using git config is your Git username - this is the one that appears as the author of your commits when you do git log or git blame.\nSince you can use Git outside of GitHub, those two usernames do not have to be the same. \nAlso, the GitHub username must be unique, but nothing forces uniqueness of Git usernames." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Recursively add the entire folder to a repository\nI am trying to add a branch to the master branch on GitHub and push a folder onto that branch.\nThe folder structure of the branch looks like -\nSocialApp/SourceCode/DevTrunk/SocialApp and all the source code files are in the last folder.\nI am using the following Git commands:\ngit add *\ngit commit -m with the message\ngit push\n\nThis is pushing only the first folder \"SocialApp\" onto GitHub and ignoring the folder SourceCode that is inside the folder. How do I fix this?" }, { "role": "assistant", "content": "Check the .gitignore file, if the subdirectory is ignored.\nThen try again\ngit add --all\ngit commit -am \"<commit message>\"\ngit push" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-update-server-info - Update auxiliary info file to help dumb servers" }, { "role": "assistant", "content": "NAME git-update-server-info - Update auxiliary info file to help dumb servers" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I remove a directory subtree from the staging area?\nI made a new repository, and ran git add -A. I then noticed that there was a folder containing about 100 files that shouldn't have been included, so I added it to .gitignore.\nHow do I now clear the staging area so that I can add all my files again taking into account the updated .gitignore?" }, { "role": "assistant", "content": "In #git, you said you unintentionally added a directory that should have been ignored, so run\ngit rm --cached -r directory-name\n\nto recursively remove the tree rooted at directory-name from the index.\nDon't forget to update .gitignore!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Set subdirectory as website root on Github Pages\n\nI'm using Github Pages to host & serve a static website.\nThe static website has the typical directory structure for an app:\n.\n├ source/\n├ build/\n│ └ index.html\n├ .gitignore\n├ config.rb\n├ Gemfile\n┆ ...\n└ README.MD\n\nindex.html is under build/, so I want to make that the default www path.\nSo when users hit username.github.io it renders the content within that subdirectory and yet it doesn't show \"/build/\" on the URL, cause that's set as the root folder.\nNotes:\n\nI don't have a custom domain nor planning to get one for this purpose. As you can see, I'm trying to leverage the default URL naming convention github provides.\nNot using Jekyll nor the automatic page generator function." }, { "role": "assistant", "content": "There is a detailed gist with all the required steps.\nThe gist is here:\nhttps://gist.github.com/cobyism/4730490\n\nFrom the gist\n\nDeploying a subfolder to GitHub Pages\nSometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.\nFor the sake of this example, let’s pretend the subfolder containing your site is named dist.\nStep 1\nRemove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).\nStep 2\nMake sure git knows about your subtree (the subfolder with your site).\ngit add dist && git commit -m \"Initial dist subtree commit\"\n\nStep 3\nUse subtree push to send it to the gh-pages branch on GitHub.\ngit subtree push --prefix dist origin gh-pages\n\nBoom. If your folder isn’t called dist, then you’ll need to change that in each of the commands above.\n\n\n\nIf you do this on a regular basis, you could also create a script containing the following somewhere in your path:\n\n#!/bin/sh\nif [ -z \"$1\" ]\nthen\n echo \"Which folder do you want to deploy to GitHub Pages?\"\n exit 1\nfi\ngit subtree push --prefix $1 origin gh-pages\n\n\nWhich lets you type commands like:\ngit gh-deploy path/to/your/site" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters [<branchname>]@{upstream} , e.g. master@{upstream} , @{u}" }, { "role": "assistant", "content": "A branch B may be set up to build on top of a branch X (configured with branch.<name>.merge ) at a remote R (configured with branch.<name>.remote ). B@{u} refers to the remote-tracking branch for\nthe branch X taken from remote R, typically found at refs/remotes/R/X ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %Cblue" }, { "role": "assistant", "content": "switch color to blue" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I make WinMerge my git mergetool?\nI'm trying to integrate WinMerge with Git as I've seen others done before on Windows 7 Ultimate.\nI've followed the following steps, but an error continues to show up when I do a git mergetool which defaults to vimdiff.\nCreated a file called winmerge.sh in the root directory of git: C/Program Files (x86)/Git/ with: WinMergeU is the correct location.\n#!/bin/sh\necho Launching WinMergeU.exe: $1 $2\n\"C:/Program Files (x86)/WinMerge/WinMergeU.exe\" \ngit /e /u /dl \"Base\" /dr \"Mine\" \"$1\" \"$2\"\n\nand used the following commands.\ngit config --global diff.tool winmerge\ngit config --global difftool.winmerge.cmd \"winmerge.sh \\\"$LOCAL\\\" \\\"$REMOTE\\\"\"\ngit config --global difftool.prompt false\n\nThe error shows up as:\ngit config option merge.tool set to unknown tool: winmerge" }, { "role": "assistant", "content": "You are talking about merge tool, yet you (and some other people with answers) are configuring it as a diff tool.\nTo configure a merge tool, you'd need to use merge.tool and mergetool configurations instead of diff.tool and difftool, like this:\ngit config --global merge.tool winmerge\ngit config --replace --global mergetool.winmerge.cmd \"\\\"C:\\Program Files (x86)\\WinMerge\\WinMergeU.exe\\\" -e -u -dl \\\"Base\\\" -dr \\\"Mine\\\" \\\"$LOCAL\\\" \\\"$REMOTE\\\" \\\"$MERGED\\\"\"\ngit config --global mergetool.prompt false\n\nAnd then you can use\ngit mergetool\n\nwhich will open you the two files to edit.\nKudos for @dvdvck mentioning in the comments that in command line parameters you can specify a third file for the result file for winmerge (outputpath parameter).\nFor completeness, I'll mention that there is also this gist aimed at full configuration of winmerge for both as diff and merge tool." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Updating pull request after review changes commit doesn't show up in the pull request\nI forked a GitHub repository and made some changes on my fork and submited a pull request but the owners of the original GitHub repository asked for some changes which they asked me for in the pull request. I assumed that adding additional changes to my fork will cause them to show up in the current pull request but to my surprise I can't see my changes in the pull request.\nThis is what I did after generating the original pull request:\n\nmade code changes\nadd the files 1git add -A`\ncommit the files git commit -m \"these are my suggested changes in pull request\"\nsubmit my changes with git push\n\nI can see changes on my own fork but I don't understand why I can't see any changes in the pull request.\nDoes anyone know what I need to do for my changes to show up in the current pull request?\nI'd really appreciate your help." }, { "role": "assistant", "content": "First, make sure that you did push to the right branch and that the commit still doesn't show up in the PR. For me, the commit showed up when I viewed the specific branch in the repo, but didn't show in the PR and didn't trigger CI.\nThis is what fixed the issue for me:\n\nClick on Edit in the top right corner.\nClick on the base selector and choose the same base branch.\nGitHub will ask you whether you want to change base, confirm.\nThe PR should update and the commit should show up." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I resolve cherry-pick conflicts using their changes?\nMy git cherry-pick FOO produced a conflict.\nI could go through the conflicting files and delete the lines between <<<<<<< and =======, and the conflict markers themselves, but I'm hoping there's an easier way.\nI think the svn equivalent was choosing theirs-conflict to resolve.\nHow do I do this in git?\nI don't want git checkout --theirs <file> as that seems to produce the same result as git checkout foo <file> instead of just getting git diff FOO~..FOO <file> applied." }, { "role": "assistant", "content": "First you should undo your cherry-pick, try to run this\ngit cherry-pick --abort\n\nSecond, try to make cherry-pick, but in this time you get their changes not yours, so make this:\ngit cherry-pick --strategy=recursive -X theirs {Imported_Commit}" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I automatically deploy my app after a git push ( GitHub and node.js)?\n\nI have my application (node.js) deployed on a VPS (linux). I'm using git hub as a repository. How can I deploy the application automatically, on git push ?" }, { "role": "assistant", "content": "Example in PHP:\nNavigate to github into your github repository add click \"Admin\"\nclick tab 'Service Hooks' => 'WebHook URLs' \nand add\nhttp://your-domain-name/git_test.php\n\nthen create git_test.php \n<?php \ntry\n{\n $payload = json_decode($_REQUEST['payload']);\n}\ncatch(Exception $e)\n{\n exit(0);\n}\n\n//log the request\nfile_put_contents('logs/github.txt', print_r($payload, TRUE), FILE_APPEND);\n\n\nif ($payload->ref === 'refs/heads/master')\n{\n // path to your site deployment script\n exec('./build.sh');\n}\n\nIn the build.sh you will need to put usual commands to retrieve your site from github" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: How to revert 2 files that are stubbornly stuck at \"Changed but not committed\"?\n\nI have a repo that has two files that supposedly I changed locally.\nSo I'm stuck with this:\n$ git status\n# On branch master\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: dir1/foo.aspx\n# modified: dir2/foo.aspx\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nDoing git diff says that the entire file contents have changed, even though from eyeballing it that seems untrue (there seem to be common line ranges that diff seems to be failing to see).\nInterestingly I don't remember changing these files locally. This repo is used with one remote repo (private, at GitHub.com, FWIW).\nNo matter what I've tried, I can't discard these local changes. I have tried all of:\n$ git checkout -- .\n$ git checkout -f\n$ git checkout -- dir1/checkout_receipt.aspx\n$ git reset --hard HEAD\n$ git stash save --keep-index && git stash drop\n$ git checkout-index -a -f\n\nIn other words I've tried everything described in How do I discard unstaged changes in Git? plus more. But the 2 files remain stuck as \"changed but not committed\".\nWhat the heck would cause two files to be stuck like this and seemingly \"un-revert-table\"??\nP.S. In the list above showing commands I'd already tried, I mistakenly wrote git revert when I meant git checkout. I'm sorry and thank you to those of you who answered that I should try checkout. I edited the question to correct it. I definitely did already try checkout." }, { "role": "assistant", "content": "I spent hours trying to solve a similar issue - a remote branch that I had checked out, which stubbornly showed four files as 'Changed but not updated', even when deleting all files and running git checkout -f again (or other variations from this post)!\nThese four files were necessary, but certainly hadn't been modified by me. My final solution - persuade Git that they had not been changed. The following works for all checked out files, showing 'modified' status - make sure you have already committed/stashed any that have really been modified!:\ngit ls-files -m | xargs -i git update-index --assume-unchanged \"{}\"\n\nOn Mac OSX, however xargs operates a little bit different (thx Daniel for the comment):\ngit ls-files -m | xargs -I {} git update-index --assume-unchanged {}\n\nI've added this as a placeholder for myself for next time." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Having a hard time understanding git-fetch\nI am having a hard time understanding the nuances of git-fetch. I understand that doing a fetch, fetches the remote refs into a local tracking branch.\nI have a few questions though:\n\nCan it be possible that a local tracking branch does not exist? If so, will it then be created automatically?\nWhat will happen if I do a fetch and specify a non tracking branch as the destination?\nThe man page for git-fetch specifies:\ngit-fetch <options> <repository> <refspec>\n\n\nHow would I use the refspec to fetch contents from my remote master into its remote tracking branch? I believe this may be possible if my current HEAD is on master and I run\ngit fetch origin master\nHowever, can I use the <+?src:dest> refspec to achieve the same thing? I think this will help me understand the concepts better.\nAnd one more question:\nMy .git/config file has the following line for fetching (showing only relevant lines):\nfetch = +refs/heads/*:refs/remotes/origin/*\n\nCan someone please explain what this line exactly means?" }, { "role": "assistant", "content": "First, there's no such concept of \"local tracking\" branches, only \"remote tracking\" branches. So origin/master is a remote tracking branch for master in the origin repo.\nTypically you do git fetch $remote which updates all your remote tracking branches, and creates new ones if needed.\nHowever, you can also specify a refspec, but that will not touch your remote tracking branches, instead, it will fetch the branch you specified and save it on FETCH_HEAD, unless you specify a destination. In general you don't want to mess with this.\nFinally:\nfetch = +refs/heads/*:refs/remotes/origin/*\n\nThat means if you do\ngit fetch origin\n\nIt will actually do:\ngit fetch origin +refs/heads/*:refs/remotes/origin/*\n\nWhich means a remote heads/foobar will be the local remotes/origin/foobar, and the plus sign means they'll be updated even if it's non-fast-forward.\nSo your local origin/foobar will always be the same as foobar on the origin remote (after running git fetch). And origin/master will obviously be the same as master on the origin remote. So will all the other remote tracking branches." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker -v --version" }, { "role": "assistant", "content": "Prints the Git suite version that the git program came from. This option is internally converted to git version ... and accepts\nthe same options as the git-version command. If --help is\nalso given, it takes precedence over --version ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index" }, { "role": "assistant", "content": "other diff formats The --summary option describes newly added, deleted, renamed and\ncopied files. The --stat option adds diffstat(1) graph to the\noutput. These options can be combined with other options, such as -p , and are meant for human consumption. When showing a change that involves a rename or a copy, --stat output\nformats the pathnames compactly by combining common prefix and suffix of\nthe pathnames. For example, a change that moves arch/i386/Makefile to arch/x86/Makefile while modifying 4 lines will be shown like this: arch/{i386 => x86}/Makefile | 4 +-- The --numstat option gives the diffstat(1) information but is designed\nfor easier machine consumption. An entry in --numstat output looks\nlike this: 1\t2\tREADME\n3\t1\tarch/{i386 => x86}/Makefile That is, from left to right: the number of added lines; a tab; the number of deleted lines; a tab; pathname (possibly with rename/copy information); a newline. When -z output option is in effect, the output is formatted this way: 1\t2\tREADME NUL\n3\t1\tNUL arch/i386/Makefile NUL arch/x86/Makefile NUL That is: the number of added lines; a tab; the number of deleted lines; a tab; a NUL (only exists if renamed/copied); pathname in preimage; a NUL (only exists if renamed/copied); pathname in postimage (only exists if renamed/copied); a NUL. The extra NUL before the preimage path in renamed case is to allow\nscripts that read the output to tell if the current record being read is\na single-path record or a rename/copy record without reading ahead.\nAfter reading added and deleted lines, reading up to NUL would yield\nthe pathname, but if that is NUL , the record will show two paths." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I have multiple git accounts on a single development machine?\n\nI am trying to work simultaneously on more than one (two or three) GitLab (or even GitHub) projects on a single development machine. Because upon configuration the IDEs and the git service has the data of my primary user when I try to checkout or clone another project with a different username / password the system says either project is not found or I do not have permissions to do that.\nHow can I configure and use more than one git user on a single development machine?" }, { "role": "assistant", "content": "By default, git is using a system-wide configuration file or the one stored at top of your home directory.\nBut you can also set a file .git/config inside each repository, either by editing manually or using git config. Inside, you may specify the following sections :\n[user]\n name = Your name\n email = [email protected]\n\n…\n\n[credential \"<your_project_hoster_url>\"]\n username = <username to log in with>\n\nYou can check git config in general or git credentials in particular for more information about it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-blame - Show what revision and author last modified each line of a file -C[<num>]" }, { "role": "assistant", "content": "In addition to -M , detect lines moved or copied from other\nfiles that were modified in the same commit. This is\nuseful when you reorganize your program and move code\naround across files. When this option is given twice,\nthe command additionally looks for copies from other\nfiles in the commit that creates the file. When this\noption is given three times, the command additionally\nlooks for copies from other files in any commit. <num> is optional but it is the lower bound on the number of\nalphanumeric characters that Git must detect as moving/copying\nbetween files for it to associate those lines with the parent\ncommit. And the default value is 40. If there are more than one -C options given, the <num> argument of the last -C will\ntake effect." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do you get a specific version from Git in Visual Studio 2015?\nIs there a way to get a specific version (from a specific commit) of a file in Visual Studio 2015 - Team Explorer/Team Services Git?\nI simply wish to run the solution with a previous version of a file just to see how things used to run and then come back to the latest version to continue development.\nI did not create any branches. I kept on committing in the \"master\" branch." }, { "role": "assistant", "content": "In Visual Studio 2015, if you do View History (from the Actions menu on the Changes panel in Team Explorer):\n\nThen right click on the commit you're interested in:\n\nYou can create a branch from there:\n\nI cannot see a way to just checkout to the commit in Visual Studio.\n\nWorking with the command line you can do a checkout of the commit SHA you want to use:\ngit checkout 9eab01d9\n\nWhen you are done, just check out master again:\ngit checkout master\n\nYou might get warnings about working on a detached head, in that case you could create a branch temporarily:\ngit checkout -b temp-branch-name 9eab01d9\n\nIt is a good idea to get comfortable with the Git command line, the Visual Studio tooling is coming along, but it misses a lot of features." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-archive - Create an archive of files from a named tree <path>" }, { "role": "assistant", "content": "Without an optional path parameter, all files and subdirectories\nof the current working directory are included in the archive.\nIf one or more paths are specified, only these are included." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options ssh.variant" }, { "role": "assistant", "content": "By default, Git determines the command line arguments to use\nbased on the basename of the configured SSH command (configured\nusing the environment variable GIT_SSH or GIT_SSH_COMMAND or\nthe config setting core.sshCommand ). If the basename is\nunrecognized, Git will attempt to detect support of OpenSSH\noptions by first invoking the configured SSH command with the -G (print configuration) option and will subsequently use\nOpenSSH options (if that is successful) or no options besides\nthe host and remote command (if it fails). The config variable ssh.variant can be set to override this detection.\nValid values are ssh (to use OpenSSH options), plink , putty , tortoiseplink , simple (no options except the host and remote command).\nThe default auto-detection can be explicitly requested using the value auto . Any other value is treated as ssh . This setting can also be\noverridden via the environment variable GIT_SSH_VARIANT . The current command-line parameters used for each variant are as\nfollows: ssh - [-p port] [-4] [-6] [-o option] [username@]host command simple - [username@]host command plink or putty - [-P port] [-4] [-6] [username@]host command tortoiseplink - [-P port] [-4] [-6] -batch [username@]host command Except for the simple variant, command-line parameters are likely to\nchange as git gains new features." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.statNameWidth" }, { "role": "assistant", "content": "Limit the width of the filename part in --stat output. If set, applies\nto all commands generating --stat output except format-patch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-notes - Add or inspect object notes notes.rewriteRef" }, { "role": "assistant", "content": "When copying notes during a rewrite, specifies the (fully\nqualified) ref whose notes should be copied. May be a glob,\nin which case notes in all matching refs will be copied. You\nmay also specify this configuration several times. Does not have a default value; you must configure this variable to\nenable note rewriting. Set it to refs/notes/commits to enable\nrewriting for the default commit notes. Can be overridden with the GIT_NOTES_REWRITE_REF environment variable.\nSee notes.rewrite.<command> above for a further description of its format." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-merge - Join two or more development histories together merge.defaultToUpstream" }, { "role": "assistant", "content": "If merge is called without any commit argument, merge the upstream\nbranches configured for the current branch by using their last\nobserved values stored in their remote-tracking branches.\nThe values of the branch.<current branch>.merge that name the\nbranches at the remote named by branch.<current branch>.remote are consulted, and then they are mapped via remote.<remote>.fetch to their corresponding remote-tracking branches, and the tips of\nthese tracking branches are merged. Defaults to true." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-daemon - A really simple server for Git repositories --syslog" }, { "role": "assistant", "content": "Short for --log-destination=syslog ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Merge Request approvals in GitLab CE\n\nWe would like to use Merge Request approvals similar to how it works in Stash where one person creates a PR and can assign multiple reviewers who can approve or decline. PR can be merged only when N reviewers approved (configurable per repository).\nIt seems that this feature is offered only in GitLab EE, is that right? Is there any free or cheap alternative to migrating from CE to EE?\nPerhaps a custom GitLab fork or an addon/plugin?" }, { "role": "assistant", "content": "Even though Merge Request Approvals are not part of the Free GitLab tier, the functionality is still available on the Merge Request user interface and data is available in the API, so as a workaround you can create a GitLab CI job that implements checking the number of approvals and fails if insufficient.\nFirst, ensure that in your project's Merge Request settings, Pipelines must succeed is enabled.\nThen create a new job in .gitlab-ci.yml that will fail when there are insufficient merge request approvals:\ncode_approved:\n rules:\n - if: $CI_MERGE_REQUEST_ID\n script:\n - apt-get update\n - apt-get install -y jq curl\n - >\n curl --header \"JOB-TOKEN: $CI_JOB_TOKEN\"\n \"$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/approvals\" \n | jq -e '.approved_by[0]'\n\n\napt-get ... : Install the curl and jq binaries.\ncurl --header \"JOB-TOKEN: $CI_JOB_TOKEN\": authenticates the call.\n\"$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/approvals\" GitLab API endpoint returning approval data for the current merge request. Note that on GitLab Free, a lot of data returned by this resource is missing or misleading, but approved_by is properly populated.You can also visit this API URL in a browser window to preview, e.g. https://gitlab.com/api/v4/projects/blaisekal%2Fmr-approvals/merge_requests/1/approvals\n| jq -e '.approved_by[0]' pipes the output to jq, attempts to fetch the first approved_by item from the list. -e ensures that when it cannot find that item, the command will return with an error exit status, which causes the CI job to fail, which causes the option to merge to be blocked. If you require two approvals, use jq filter '.approved_by[1]'.\n\n\nDemo: https://gitlab.com/blaisekal/mr-approvals/-/merge_requests\n\nThe biggest disadvantages of this workaround are that you need to run a job to determine approved status, you have to re-run the job manually if the number of approvals changes, and a malicious member of your team could remove the CI job before merging." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-send-email - Send a collection of patches as emails --dump-aliases" }, { "role": "assistant", "content": "Instead of the normal operation, dump the shorthand alias names from\nthe configured alias file(s), one per line in alphabetical order. Note\nthat this only includes the alias name and not its expanded email addresses.\nSee sendemail.aliasesFile for more information about aliases." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-restore - Restore working tree files --overlay --no-overlay" }, { "role": "assistant", "content": "In overlay mode, the command never removes files when\nrestoring. In no-overlay mode, tracked files that do not\nappear in the --source tree are removed, to make them match <tree> exactly. The default is no-overlay mode." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Embedding images inside a GitHub wiki (gollum) repository?\n\nThe Github wikis are backed by a separate git repository then the main project repository.\nThis post by the Github team makes it sound like you should be able to link to images stored in the wiki repository inside the wiki markup.\n\nImages and Folders\nYou can now reference images hosted inside the Git repository.\n\nI've checked out my wiki's repository and pushed a resource folder and an image into it. My question is, how do I go about using this image?\nIs this even possible or have I misunderstood something?" }, { "role": "assistant", "content": "For viewers wishing to view images on a github wiki I've found the following method to work:\n\nGo to the \"Git Access\" tab inside the wiki page of your repository and retrieve the SSH path which should be some thing like: [email protected]:USER/REPO.wiki.git where USER is your account name and REPO is the repository name.\nOn your local machine use whichever Git command line tool you wish to cd into your local directory of choice and get the repository via \n\ngit clone [email protected]:USER/REPO.wiki.git\n\nNow within this repository create an image directory, I'll call it \"images\" and put whatever images you want into the directory\nAnd then push your wiki git directory to github\nYou will not be able to physically see the images in say the \"Pages\" tab, but if you simply reference the images in a local link you should be able to see them. Example with Markdown below: \n![Alt attribute text Here](images/YOURIMAGE.ext) \nYou may also embed the image as a link itself by wrapping it further like so:\n[![Alt attribute text Here](images/YOURIMAGE.ext)](http://Yoursite.com)\n\nYou can also add subdirectories within your local copy to help organize the wiki since the \"pages\" tab simply lists them out. Keep in mind, however, that even when the new directory is pushed the \"pages\" tab doesn't list the directory." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git remote add with other SSH port\nIn Git, how can I add a remote origin server when my host uses a different SSH port? \ngit remote add origin ssh://user@host/srv/git/example" }, { "role": "assistant", "content": "You can just do this:\ngit remote add origin ssh://user@host:1234/srv/git/example\n\n1234 is the ssh port being used" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-checkout - Switch branches or restore working tree files -b <new-branch>" }, { "role": "assistant", "content": "Create a new branch named <new-branch> , start it at <start-point> , and check the resulting branch out;\nsee git-branch for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-commit - Record changes to the repository <pathspec>…​" }, { "role": "assistant", "content": "When pathspec is given on the command line, commit the contents of\nthe files that match the pathspec without recording the changes\nalready added to the index. The contents of these files are also\nstaged for the next commit on top of what have been staged before. For more details, see the pathspec entry in gitglossary ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc git-diff-index <tree-ish>" }, { "role": "assistant", "content": "compares the <tree-ish> and the files on the filesystem." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Installing Git with non-root user account\nI've already set up a Git repository on GitHub and committed a few changes from my Windows machine.\nBut tomorrow I'll have to work in this repository from a machine running Ubuntu with limited privilege (i.e. no sudo).\nIs there a portable version of Git for Linux? Or some source that allows me to compile and install Git only for the current user?" }, { "role": "assistant", "content": "You can download the git source and do make configure && ./configure --prefix=/home/user/myroot && make && make install to install git to your home directory provided you have the build tools. If you don't have the build-essential package installed (dpkg --list|grep build-essential), you will need to install those to your home directory as well." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Github: error cloning my private repository\nI'm trying to clone my GitHub project using the https-URL, but it fails with an error:\n$ git clone https://[email protected]/foo/foo-private.git\nCloning into foo-private...\nPassword:\nerror: error setting certificate verify locations:\n CAfile: /bin/curl-ca-bundle.crt\n CApath: none\n while accessing https://[email protected]/foo/foo-private.git/info/refs\n\nfatal: HTTP request failed\n\nWhat am I doing wrong?" }, { "role": "assistant", "content": "I have seen this on Windows, with msysgit 1.7.2.3. You have to fix the path to bin/curl-ca-bundle.crt. I had to specify the absolute path, using back-slashes:\ngit config --system http.sslcainfo \"C:\\Program Files (x86)\\git\\bin\\curl-ca-bundle.crt\"\nThis will result in changes to [git-install-dir]/etc/gitconfig file, which may be edited directly, too.\n(Original solutions found at http://github.com/blog/642-smart-http-support)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Pushing empty commits to remote\nI have pushed one commit to remote but now I realized that the commit message is not correct. I would like to change the commit message but AFAIK it is not possible. So i decided to create empty commit with correct message:\ngit commit --allow-empty\n\nAre there any disadvantages/consequences of pushing empty commits? Is there any problem I might face in future because of this empty commit??" }, { "role": "assistant", "content": "One use of an empty commit would be to force a build to occur in an environment where builds are triggered whenever new commits are pushed.\ngit commit --allow-empty -m \"Trigger Build\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I unstage my files again after making a local commit?\nI have executed the following command\ngit add <foo.java>\ngit commit -m \"add the foo.java file\"\n\nHow can I delete my local commit now and unstage foo.java?\nIf I type git reset --hard, I found that it reverts my modified foo.java to the original one." }, { "role": "assistant", "content": "git reset --soft HEAD~1 should do what you want. After this, you'll have the first changes in the index (visible with git diff --cached), and your newest changes not staged. git status will then look like this:\n# On branch master\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# modified: foo.java\n#\n# Changes not staged for commit:\n# (use \"git add <file>...\" to update what will be committed)\n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n# modified: foo.java\n#\n\nYou can then do git add foo.java and commit both changes at once." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: How do I list only local branches?\ngit branch -a shows both remote and local branches.\ngit branch -r shows remote branches.\nIs there a way to list just the local branches?" }, { "role": "assistant", "content": "Just git branch without options.\nFrom the manpage:\n\nWith no arguments, existing branches are listed and the current branch will be highlighted with an asterisk." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-add - Add file contents to the index" }, { "role": "assistant", "content": "SYNOPSIS git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p]\n\t [--edit | -e] [--[no-]all | -A | --[no-]ignore-removal | [--update | -u]] [--sparse]\n\t [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing] [--renormalize]\n\t [--chmod=(+|-)x] [--pathspec-from-file=<file> [--pathspec-file-nul]]\n\t [--] [<pathspec>…​]" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "unable to create file ... Permission denied\ni am currently working on windows.\nSometimes i have problems when i try :\ngit checkout origin develop\n\ni have this error :\nerror: unable to create file .... : Permission denied\n\"git status\" show me the file in error not staged so i have to commit\nWhat do i have to check ?\ni tried to do this command line on my computer :\nchown -R username directory\n\nWe are severals people to work on a git repository and they have the problem too.\nthanks for you help" }, { "role": "assistant", "content": "In my case, my angular app was still running from ng serve, giving this:\n\nSo I just had to close it with ctrl+c." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository --unshallow" }, { "role": "assistant", "content": "If the source repository is complete, convert a shallow\nrepository to a complete one, removing all the limitations\nimposed by shallow repositories. If the source repository is shallow, fetch as much as possible so that\nthe current repository has the same history as the source repository." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "github for mac doesn't allow to perform partial checkin/commit\n\nI am using GitHub for Mac, and have bunch of changes in my branch. I am have committed some of the changes and kept others as uncommitted as I am expecting some more changes. however, when I try to do sync in order to push those changes to Git repository it complains - 'Uncommitted Changes - Please commit all your changes before syncing.'\nAny idea? does it expects all the changes to be committed all the time when you do sync?" }, { "role": "assistant", "content": "Rather than \"syncing\" your changes, GitHub for Mac does offer you the ability to push, pull and sync changes. Unfortunately, the UI button is for sync only. However, if you go to the menu bar, under \"Repository\" you see there are two additional changes: push (command + P) or pull (shift + command + P)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I make a Git commit in the past?\nI'm converting everything over to Git for my own personal use and I found some old versions of a file already in the repository. How do I commit it to the history in the correct order according the file's \"date modified\" so I have an accurate history of the file?\nI was told something like this would work:\ngit filter-branch --env-filter=\"GIT_AUTHOR_DATE=... --index-filter \"git commit path/to/file --date \" --tag-name-filter cat -- --all" }, { "role": "assistant", "content": "This is what worked for me:\ngit commit --date \"10 day ago\" -m \"Your commit message\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %aL" }, { "role": "assistant", "content": "author local-part (see %al ) respecting .mailmap, see git-shortlog or git-blame )" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options diff.algorithm" }, { "role": "assistant", "content": "Choose a diff algorithm. The variants are as follows: default , myers The basic greedy diff algorithm. Currently, this is the default. minimal Spend extra time to make sure the smallest possible diff is\nproduced. patience Use \"patience diff\" algorithm when generating patches. histogram This algorithm extends the patience algorithm to \"support\nlow-occurrence common elements\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fast-import - Backend for fast Git data importers Reading from a named tree" }, { "role": "assistant", "content": "The <dataref> can be a mark reference ( :<idnum> ) or the\nfull 40-byte SHA-1 of a Git tag, commit, or tree object,\npreexisting or waiting to be written.\nThe path is relative to the top level of the tree\nnamed by <dataref> . 'ls' SP <dataref> SP <path> LF" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --ita-invisible-in-index" }, { "role": "assistant", "content": "By default entries added by \"git add -N\" appear as an existing\nempty file in \"git diff\" and a new file in \"git diff --cached\".\nThis option makes the entry appear as a new file in \"git diff\"\nand non-existent in \"git diff --cached\". This option could be\nreverted with --ita-visible-in-index . Both options are\nexperimental and could be removed in future." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options gui.copyBlameThreshold" }, { "role": "assistant", "content": "Specifies the threshold to use in git gui blame original location\ndetection, measured in alphanumeric characters. See the git-blame manual for more information on copy detection." } ]
[ { "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 -z" }, { "role": "assistant", "content": "\\0 line termination on output and do not quote filenames.\nSee OUTPUT below for more information." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index git-diff-files [<pattern>…​]" }, { "role": "assistant", "content": "compares the index and the files on the filesystem." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Changing Git remote URL updates fetch but not push\nI am attempting to change the remote URL of my origin branch in Git. All I want to change is the SSH port. First, listing my remote origins gives me this:\ngit remote -v\n\n\norigin [email protected]:package/name.git (fetch)\norigin [email protected]:package/name.git (push)\n\nThen, I run the set-url command to change my origin URL:\ngit remote set-url origin ssh://[email protected]:XX/package/name.git (XX is my port #)\n\nNow, I can fetch without issue, but pushing my branch to origin doesn't work, because the push URL didn't change. Listing my remotes again I get this:\ngit remote -v\n\n\norigin ssh://[email protected]:XX/package/name.git (fetch)\norigin [email protected]:package/name.git (push)\n\nWhy did my set-url command only change the fetch URL?" }, { "role": "assistant", "content": "From git-remote manual:\nset-url\n Changes URL remote points to. Sets first URL remote points to matching regex <oldurl> (first URL if no <oldurl> is given) to <newurl>. If <oldurl> doesn’t match any URL,\n error occurs and nothing is changed.\n\n With --push, push URLs are manipulated instead of fetch URLs.\n\nSo you should additionally execute:\ngit remote set-url --push origin ssh://[email protected]:XX/package/name.git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-sh-i18n" }, { "role": "assistant", "content": "Git’s i18n setup code for shell scripts" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I rename a Git repository?\ngit mv renames a file or directory in a repository. How do I rename the Git repository itself?" }, { "role": "assistant", "content": "There are various possible interpretations of what is meant by renaming a Git repository: the displayed name, the repository directory, or the remote repository name. Each requires different steps to rename.\nDisplayed Name\nRename the displayed name (for example, shown by gitweb):\n\nEdit .git/description to contain the repository's name.\nSave the file.\n\nRepository Directory\nTypically (with exceptions for worktrees and submodules explained below), Git does not reference the name of the directory containing the repository, so we can simply rename or move it:\n\nOpen a command prompt (or file manager window).\nChange to the directory that contains the repository directory (i.e., do not go into the repository directory itself).\nRename the directory (for example, using mv from the command line or the F2 hotkey from a GUI).\n\nMoving a repository that has worktrees\nIf you have created worktrees using the git worktree subcommands from the repository that is to be renamed, then each worktree directory will contain a .git file that contains\ngitdir: {full-path-to-parent-repository}/.git/worktrees/{worktree-name}\n\nSo if you move the location of the parent repository, for each such worktree you will also need to edit its .git file to change the parent path.\nMoving a directory that is a worktree\nUse the git worktree move command from the parent repository.\nMoving a repository that has submodules\nSimilarly to the worktree case, the submodule directory has a .git file pointing to its parent. The parent also has a .git/modules/{submodule}/config file which may contain absolute paths that need to be edited. See also this question.\nRenaming a submodule\nUse git mv as discussed in this answer.\nCorner cases involving both submodules and worktrees\nDon't do that. If you must, read the docs for git worktree repair and probably also the docs for submodules to understand how they are implemented.\nRemote Repository\nRename a remote repository as follows:\n\nGo to the remote host (for example, https://github.com/User/project).\n\nFollow the host's instructions to rename the project (will differ from host to host, but usually Settings is a good starting point).\n\nGo to your local repository directory (i.e., open a command prompt and change to the repository's directory).\n\nDetermine the new URL (for example, [email protected]:User/project-new.git)\n\nSet the new URL using Git:\ngit remote set-url origin [email protected]:User/project-new.git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc none" }, { "role": "assistant", "content": "Disable word diff again." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options format.notes" }, { "role": "assistant", "content": "Provides the default value for the --notes option to\nformat-patch. Accepts a boolean value, or a ref which specifies\nwhere to get notes. If false, format-patch defaults to --no-notes . If true, format-patch defaults to --notes . If\nset to a non-boolean value, format-patch defaults to --notes=<ref> , where ref is the non-boolean value. Defaults\nto false. If one wishes to use the ref refs/notes/true , please use that literal\ninstead. This configuration can be specified multiple times in order to allow\nmultiple notes refs to be included. In that case, it will behave\nsimilarly to multiple --[no-]notes[=] options passed in. That is, a\nvalue of true will show the default notes, a value of <ref> will\nalso show notes from that notes ref and a value of false will negate\nprevious configurations and not show notes. For example, [format]\n\tnotes = true\n\tnotes = foo\n\tnotes = false\n\tnotes = bar will only show notes from refs/notes/bar ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is there a Subversion user's guide to Git? [closed]\nAs it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.\n \n \n\n\n\nClosed 11 years ago.\n\n\n\nI am a new user in Git world. I used to use Subversion (using TortoiseSVN) and it is pretty easy. I would like to try Git but i got confused by the terms. Is there any documentation/guides that can explain me how to use Git?\nFor example, in Subversion I use checkout; in Git which commands should I use? Any good book about Git that I could use?" }, { "role": "assistant", "content": "Here are two good guides:\n\nGit - SVN Crash Course\n(Easy) Git for SVN users" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is difference between \"git checkout -f\" and \"git reset --hard HEAD\"?\nI need to revert local changes for deployments. (I'd used svn revert for this in old skool SVN days.)\nAnd im using git reset --hard HEAD for this. (Also git fetch and git merge origin/$branch --no-ff for syncronizing with upstream branch.)\nBut some articles points git checkout -f for reverting changes. \nWhat's key differences between this commands. Which way is the recommended?" }, { "role": "assistant", "content": "The two of them have the exact same effect. I recommend you to choose the solution you're the more comfortable with.\nBut if in this particular case the effect is the same, with different values it would be completely different. Basically (there is more, see linked topics) with a reset you move the current branch and the HEAD to a specific commit but with a checkout, you only move the HEAD . For more details see below.\n\nResources:\n\ngit reset\ngit checkout\n\nOn the same topic:\n\nIs there a difference between git reset --hard HEAD and git checkout .?\nIs there a difference between “git reset --hard hash” and “git checkout hash”?\nCan you explain to me git reset in plain english?" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-cherry-pick - Apply the changes introduced by some existing commits" }, { "role": "assistant", "content": "SYNOPSIS git cherry-pick [--edit] [-n] [-m <parent-number>] [-s] [-x] [--ff]\n\t\t [-S[<keyid>]] <commit>…​ git cherry-pick (--continue | --skip | --abort | --quit)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs log.excludeDecoration" }, { "role": "assistant", "content": "Exclude the specified patterns from the log decorations. This is\nsimilar to the --decorate-refs-exclude command-line option, but\nthe config option can be overridden by the --decorate-refs option." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker -C <path>" }, { "role": "assistant", "content": "Run as if git was started in <path> instead of the current working\ndirectory. When multiple -C options are given, each subsequent\nnon-absolute -C <path> is interpreted relative to the preceding -C\n<path> . If <path> is present but empty, e.g. -C \"\" , then the\ncurrent working directory is left unchanged. This option affects options that expect path name like --git-dir and --work-tree in that their interpretations of the path names would be\nmade relative to the working directory caused by the -C option. For\nexample the following invocations are equivalent: git --git-dir=a.git --work-tree=b -C c status\ngit --git-dir=c/a.git --work-tree=c/b status" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-cvsserver" }, { "role": "assistant", "content": "A CVS server emulator for Git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-restore - Restore working tree files --ignore-unmerged" }, { "role": "assistant", "content": "When restoring files on the working tree from the index, do\nnot abort the operation if there are unmerged entries and\nneither --ours , --theirs , --merge or --conflict is\nspecified. Unmerged paths on the working tree are left alone." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-notes - Add or inspect object notes GIT_NOTES_REF" }, { "role": "assistant", "content": "Which ref to manipulate notes from, instead of refs/notes/commits .\nThis overrides the core.notesRef setting." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I check write access to a remote Git repository (\"can I push?\")\nI am building a (somewhat limited) Git client. To set up a repository, you enter the URL to the remote repo. I want to check whether the user has read+write access to that repository. If not, I present an authentication dialog.\nI check 'read' access with git ls-remote <url>.\nIs there an analogous way to check 'write' access, without cloning the repo first? (I know I could git clone <url> and then git push --dry-run)" }, { "role": "assistant", "content": "If the git repo is in github, open any file in the repo, then click 'edit',\ngithub will show something like this:\n\nYou’re editing a file in a project you don’t have write access to. We’ve created a fork of this project for you to commit your proposed changes \n to. Submitting a change to this file will write it to a new branch in \n your fork, so you can send a pull request.enter code here" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I put a database under git (version control)?\nI'm doing a web app, and I need to make a branch for some major changes, the thing is, these changes require changes to the database schema, so I'd like to put the entire database under git as well.\nHow do I do that? is there a specific folder that I can keep under a git repository? How do I know which one? How can I be sure that I'm putting the right folder?\nI need to be sure, because these changes are not backward compatible; I can't afford to screw up.\nThe database in my case is PostgreSQL\nEdit:\nSomeone suggested taking backups and putting the backup file under version control instead of the database. To be honest, I find that really hard to swallow. \nThere has to be a better way.\nUpdate:\nOK, so there' no better way, but I'm still not quite convinced, so I will change the question a bit:\nI'd like to put the entire database under version control, what database engine can I use so that I can put the actual database under version control instead of its dump?\nWould sqlite be git-friendly?\nSince this is only the development environment, I can choose whatever database I want.\nEdit2:\nWhat I really want is not to track my development history, but to be able to switch from my \"new radical changes\" branch to the \"current stable branch\" and be able for instance to fix some bugs/issues, etc, with the current stable branch. Such that when I switch branches, the database auto-magically becomes compatible with the branch I'm currently on.\nI don't really care much about the actual data." }, { "role": "assistant", "content": "Take a database dump, and version control that instead. This way it is a flat text file.\nPersonally I suggest that you keep both a data dump, and a schema dump. This way using diff it becomes fairly easy to see what changed in the schema from revision to revision.\nIf you are making big changes, you should have a secondary database that you make the new schema changes to and not touch the old one since as you said you are making a branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-p4" }, { "role": "assistant", "content": "Import from and submit to Perforce repositories" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-grep - Print lines matching a pattern --break" }, { "role": "assistant", "content": "Print an empty line between matches from different files." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --show-signature" }, { "role": "assistant", "content": "Check the validity of a signed commit object by passing the signature\nto gpg --verify and show the output." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Should I have to add files to git every time I want to commit?\nI'm new to git, coming from SVN world. So far, it seems a lot more useful, but I am still working out the kinks. \nCurrently, my workflow is like this: \nmake changes > git add . > git commit > enter log message\nWhat I don't understand is why I seem to have to add all of my files before I commit. They are under version control already? Why does git commit tell me there are no changes added to the commit, but also point out that I have modified files? It says \"Changed but not updated:\". What does this mean??\nSorry if this is easy, I feel like I am missing some overarching point" }, { "role": "assistant", "content": "This allows you to separate commits by edits. If you only want to commit these files now, under one commit, and then these next files now, under a second commit, you could do:\ngit add files_under_one_topic\ngit commit -m \"this is about one thing\"\n\ngit add files_left_over_to_commit_about_a_completely_different_topic\ngit commit -m \"this is about another thing.\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository -n --no-tags" }, { "role": "assistant", "content": "By default, tags that point at objects that are downloaded\nfrom the remote repository are fetched and stored locally.\nThis option disables this automatic tag following. The default\nbehavior for a remote may be specified with the remote.<name>.tagOpt\nsetting. See git-config ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why .gitconfig [includeIf] does not work?\nSystem settings:\nMacOS Catalina 10.15.6\n> git --version\ngit version 2.24.3 (Apple Git-128)\n\nfile: ~/.gitconfig :\n[user]\n name = nickname\n email = [email protected]\n[includeIf \"gitdir:~/Business\"]\n path = ~/.gitconfig-work\n\nfile: ~/.gitconfig-work :\n[user]\n name = First Last\n email = [email protected]\n\nOutput when trying to check the configuration on terminal:\n(base) MBP-Name:~ myname$ cd ~/Business/\n(base) MBP-Name:Business myname$ git config --get user.name\nnickname\n\nI have tried both relative ~ and absolute / paths either for gitdir and path in the config file. On each change I am restarting the bash. Also, I have read several other stackoverflow questions with no success. Some of them where suggesting adding the i option for case insensitivity but it didn't fix the problem.\nAny ideas ?" }, { "role": "assistant", "content": "I know this is starting to be an old question, but I had a similar problem and the solution for it was dead simple, so I'll share it in case anyone has thee same problem: the problem was simply that your dir should have a slash (/) at the end...\nSo in the case of the OP,\n[includeIf \"gitdir:~/Business\"]\n\nShould simply become\n[includeIf \"gitdir:~/Business/\"]\n\nHope this helps!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Could not create work tree dir 'example.com'.: Permission denied\n\nI have got a virtual private server with nginx Virtual Hosts setup (Server Blocks).\nI've installed Git and got my ssh keys authenticated with GitHub.\nI have my website running in\n ~/var/www/example.com/public_html/\n\nI tried to run:\ngit clone [email protected]:example/example.co.uk.git\n\nto pull my files on GitHub to the /public_html/ directory but I get the error:\nfatal: could not create work tree dir 'example.com'.: Permission denied\n\nI've followed this tutorial including the same issue he has mentioned on the page, but it still won't work: http://machiine.com/2013/pulling-a-git-repo-from-github-to-your-ubuntu-server/\nI'm completely new to this, so your help would be much appreciated!" }, { "role": "assistant", "content": "I think you don't have your permissions set up correctly for /var/www\nChange the ownership of the folder.\nsudo chown -R $USER /var/www" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission" }, { "role": "assistant", "content": "BASE TREE INFORMATION The base tree information block is used for maintainers or third party\ntesters to know the exact state the patch series applies to. It consists\nof the base commit , which is a well-known commit that is part of the\nstable part of the project history everybody else works off of, and zero\nor more prerequisite patches , which are well-known patches in flight\nthat is not yet part of the base commit that need to be applied on top\nof base commit in topological order before the patches can be applied. The base commit is shown as \"base-commit: \" followed by the 40-hex of\nthe commit object name. A prerequisite patch is shown as\n\"prerequisite-patch-id: \" followed by the 40-hex patch id , which can\nbe obtained by passing the patch through the git patch-id --stable command. Imagine that on top of the public commit P, you applied well-known\npatches X, Y and Z from somebody else, and then built your three-patch\nseries A, B, C, the history would be like: ---P---X---Y---Z---A---B---C With git format-patch --base=P -3 C (or variants thereof, e.g. with --cover-letter or using Z..C instead of -3 C to specify the\nrange), the base tree information block is shown at the end of the\nfirst message the command outputs (either the first patch, or the\ncover letter), like this: base-commit: P\nprerequisite-patch-id: X\nprerequisite-patch-id: Y\nprerequisite-patch-id: Z For non-linear topology, such as ---P---X---A---M---C\n \\ /\n Y---Z---B You can also use git format-patch --base=P -3 C to generate patches\nfor A, B and C, and the identifiers for P, X, Y, Z are appended at the\nend of the first message. If set --base=auto in cmdline, it will automatically compute\nthe base commit as the merge base of tip commit of the remote-tracking\nbranch and revision-range specified in cmdline.\nFor a local branch, you need to make it to track a remote branch by git branch\n--set-upstream-to before using this option." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-bundle - Move objects and refs by archive <git-rev-list-args>" }, { "role": "assistant", "content": "A list of arguments, acceptable to git rev-parse and git rev-list (and containing a named ref, see SPECIFYING REFERENCES\nbelow), that specifies the specific objects and references\nto transport. For example, master~10..master causes the\ncurrent master reference to be packaged along with all objects\nadded since its 10th ancestor commit. There is no explicit\nlimit to the number of references and objects that may be\npackaged." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "fatal: could not create work tree dir 'kivy'\n\nI'm trying to clone my fork of the kivy git, but it's not working. I've made the fork correctly, I believe, but when I type this into my Mac terminal:\n\ngit clone https://github.com/mygitusername/kivy.git\n\nI get this error:\n\nfatal: could not create work tree dir 'kivy.: Permission denied\n\nAnyone see what I am doing wrong? Thanks!" }, { "role": "assistant", "content": "You should do the command in a directory where you have write permission. So:\ncd ~/\nmkdir code\ncd code\ngit clone https://github.com/kivy/kivy\n\nFor example." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_TRACE_SETUP" }, { "role": "assistant", "content": "Enables trace messages printing the .git, working tree and current\nworking directory after Git has completed its setup phase.\nSee GIT_TRACE for available trace output options." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Array variable inside .gitlab-ci.yml yaml\n\nI want to use arrays in variables of my gitlab ci/cd yml file, something like that:\nvariables:\n myarrray: ['abc', 'dcef' ]\n....\nscript: |\n echo myarray[0] myarray[1]\n\nBut Lint tells me that file is incorrect:\nvariables config should be a hash of key value pairs, value can be a hash\n\nI've tried the next:\nvariables:\n arr[0]: 'abc'\n arr[1]: 'cde'\n....\nscript: |\n echo $arr[0] $arr[1]\n\nBut build failed and prints out bash error:\nbash: line 128: export: `arr[0]': not a valid identifier\n\nIs there any way to use array variable in .gitlab-ci.yml file?" }, { "role": "assistant", "content": "According to the docs, this is what you should be doing:\n\nIt is not possible to create a CI/CD variable that is an array of values, but you can use shell scripting techniques for similar behavior.\nFor example, you can store multiple variables separated by a space in a variable, then loop through the values with a script:\n\njob1:\n variables:\n FOLDERS: src test docs\n script:\n - |\n for FOLDER in $FOLDERS\n do\n echo \"The path is root/${FOLDER}\"\n done" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Composer - using a local repository\nI am a Composer beginner and I am trying to make one project dependent of another one, while both project only exist on my local machine. \nThe composer.json in my library project (ProjectA) is:\n{\n \"name\" : \"project/util\",\n \"type\" : \"library\"\n}\n\nI initialized git in the base folder of this project. \nMy composer.json in the project depending on the first one (ProjectB):\n{\n \"repositories\": [\n {\n \"name\" : \"util\", \n \"type\" : \"git\",\n \"url\" : \"/d/workspaces/util\"\n } \n ],\n\n \"require\": {\n \"project/util\" : \"*\"\n },\n}\n\nWhen I run composer install from ProjectB, I get the following error:\n\n[RuntimeException]\nFailed to clone , could not read packages from it\nfatal: repository '' does not exist\n\n\nI asume something is wrong with the url of the repository, but I am not sure what else to write there." }, { "role": "assistant", "content": "Autoload local package using composer (without going to packagist every time you change).\nThere are many ways to do so, I will be covering 2 of them:\nIn all cases we have 2 main parties:\n - the local package (the code that we do not want to publish on packagist to be able to autoload it in our project composer).\n - the main project (the code base that needs to use the local package code, can be another package and or any project). \n\nMethod 1: (direct namespace) \nOpen the main project composer.json file and autoload the local package namespaces using any method (PSR-4, PSR-0, ...).\nexample:\nif in the composer.json of the local package we have:\n \"autoload\": {\n \"psr-4\": {\n “Local\\\\Pack\\\\\": \"library\"\n }\n },\n \"autoload-dev\": {\n \"psr-4\": {\n \"Local\\\\Pack\\\\Tests\\\\\": \"tests\"\n }\n },\n\nthen in the composer.json of the main project we should have:\n \"autoload\": {\n \"psr-4\": {\n \"Mahmoudz\\\\Project\\\\\": \"src\",\n \"Local\\\\Pack\\\\\": \"../path/to/local/pack/library” << referencing the other local package\n }\n },\n \"autoload-dev\": {\n \"psr-4\": {\n \"Mahmoudz\\\\Project\\\\Tests\\\\\": \"tests\"\n }\n },\n\nAdvantages:\n- you don’t touche the vendor directory (running composer update by mistake will not override your local changes)\n- you don’t need your package to be on packagist to use it\n- you work in one place (the local package) and the changes are automatically loaded in the main project\nDisadvantages:\n- you cannot publish the composer.json on production (needs editing before publishing to require the real package) \nMethod 2: (local repository)\nDownload the local package from a local repository. \nlocal package:\n 1. initialize git in the package (even if you don’t want to use it - no need to commit anything)\n 2. add composer.json file. In the file make sure you have the following: \n\"name\": \"vendor-name/package-name\", \n\n\"autoload\": { … // use whichever method you prefer, but make sure it’s being loaded correctly\n\n\"minimum-stability\": \"dev\" \n\n\ncomposer dump-autoload \n\nmain project:\n 1. edit your composer.json to contain the following:\n \"repositories\": [\n {\n \"type\": \"vcs\",\n \"url\": \"/full/path/to/the/local/package/package-name\"\n }\n ],\n \"require\": {\n \"vendor-name/package-name\": \"dev-master\"\n },\n\n\ncomposer update vendor-name/package-name\nnow check your vendor directory you should see the vendor-name/package- name \n\nNOTE: whenever you make change in the local package (not the vendor) you need to git commit then you can composer update the main project, it will get the latest copy of the repo to the main project vendor directory.\nAdvantage:\n- you don’t touch the vendor directory (running composer update by mistake will not override your local changes) - you don’t need your package to be on packagist to use it\nDisadvantage:\n- you have to keep committing your changes (in the local package) and then running composer update in the main project\n- you cannot publish the composer.json on production (needs editing before publishing to require the real package)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-daemon - A really simple server for Git repositories --base-path=<path>" }, { "role": "assistant", "content": "Remap all the path requests as relative to the given path.\nThis is sort of \"Git root\" - if you run git daemon with --base-path=/srv/git on example.com, then if you later try to pull git://example.com/hello.git , git daemon will interpret the path\nas /srv/git/hello.git ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options commitGraph.maxNewFilters" }, { "role": "assistant", "content": "Specifies the default value for the --max-new-filters option of git\ncommit-graph write (c.f., git-commit-graph )." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker --config-env=<name>=<envvar>" }, { "role": "assistant", "content": "Like -c <name>=<value> , give configuration variable <name> a value, where <envvar> is the name of an\nenvironment variable from which to retrieve the value. Unlike -c there is no shortcut for directly setting the value to an\nempty string, instead the environment variable itself must be\nset to the empty string. It is an error if the <envvar> does not exist\nin the environment. <envvar> may not contain an equals sign\nto avoid ambiguity with <name> containing one. This is useful for cases where you want to pass transitory\nconfiguration options to git, but are doing so on operating systems\nwhere other processes might be able to read your command line\n(e.g. /proc/self/cmdline ), but not your environment\n(e.g. /proc/self/environ ). That behavior is the default on\nLinux, but may not be on your system. Note that this might add security for variables such as http.extraHeader where the sensitive information is part of\nthe value, but not e.g. url.<base>.insteadOf where the\nsensitive information can be part of the key." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options color.remote.<slot>" }, { "role": "assistant", "content": "Use customized color for each remote keyword. <slot> may be hint , warning , success or error which match the\ncorresponding keyword." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission -N --no-numbered" }, { "role": "assistant", "content": "Name output in [PATCH] format." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-shortlog - Summarize git log output --first-parent" }, { "role": "assistant", "content": "When finding commits to include, follow only the first\nparent commit upon seeing a merge commit. This option\ncan give a better overview when viewing the evolution of\na particular topic branch, because merges into a topic\nbranch tend to be only about adjusting to updated upstream\nfrom time to time, and this option allows you to ignore\nthe individual commits brought in to your history by such\na merge." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git blame committed line\nIs it possible somehow for GIT to find which commit introduced a specific line of code in a specific file? This is assuming that there have been many commits since that line was added. Or is this something that must be done in a script while looking at the git blame of all the commits for the file in which the line is present?\nTo clarify\nOriginal file->Line Added to file and committed -> Many other commits adding other lines and changing the code" }, { "role": "assistant", "content": "You can use git blame -l filename to get the SHA1 hash from when the line was changed.\nYou also can use --reverse:\n\n--reverse\nWalk history forward instead of backward. Instead of showing the revision in which a line appeared, this shows the last revision in which a line has existed. This requires a range of revision like START..END where the path to blame exists in START.\n\nSee: http://www.kernel.org/pub/software/scm/git/docs/git-blame.html" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Change Gitlab CI Runner user\n\nCurrently when I start a build in GitlabCI it is running under gitlab-runner user. I want to change it the company's internal user. I didn't find any parameter to the /etc/gitlab-runner/config.toml which is solve that.\nMy current configuration: \nconcurrent = 1\n[[runners]]\n name = \"deploy\"\n url = \"\"\n token = \"\"\n executor = \"shell\"" }, { "role": "assistant", "content": "Running ps aux | grep gitlab you can see:\n/usr/bin/gitlab-ci-multi-runner run --working-directory /home/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitlab-runner --syslog --user gitlab-runner\n\nService is running with option --user.\nSo let's change this, it depends on what distro. you are running it. If systemd, there is a file:\n/etc/systemd/system/gitlab-runner.service:\n[Service]\nStartLimitInterval=5\nStartLimitBurst=10\nExecStart=/usr/bin/gitlab-ci-multi-runner \"run\" \"--working-directory\" \"/home/gitlab-runner\" \"--config\" \"/etc/gitlab-runner/config.toml\" \"--se\n\nBingo, let's change this file now:\ngitlab-runner uninstall\n\ngitlab-runner install --working-directory /home/ubuntu --user ubuntu\n\nreboot the machine or reload the service (i.e. systemctl daemon-reload), et voilà!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitLab Runner - How to allow only one Pipeline run at a time\n\nI am new to GitLab and facing a problem where if I trigger two pipelines at the same time on same gitlab-runner, they both run in parallel and results in failure. What I want is to limit the run to one pipeline at a time and others in queue. \nI have set the concurrent = 1 in config.toml and restarted the runner but it didn't help. My ultimate goal is to prevent multi-pipeline run on the runner.\nThanks." }, { "role": "assistant", "content": "Set resource_group in the Job, and give a unique name for all other tasks that should be blocked.\nExample from the documentation:\ndeploy-to-production:\n script: deploy\n resource_group: production" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "cannot validate certificate for <ip-address> because it doesn't contain any IP SANs\n\nI'm working on a GitLab CI pipeline that will deploy my docker stack. I'm trying to set the $DOCKER_HOST to be tcp://DROPLET_IP:2377, but I'm getting an error saying that my certificate does doesn't contain any IP SANs. I'm testing with a Digital Ocean Droplet, so I haven't set a domain name for my droplet yet. \ndeploy:\n stage: deploy\n image: docker:stable\n services:\n - docker:dind\n variables:\n DOCKER_HOST: \"tcp://$DROPLET_IP:2377\"\n DOCKER_TLS_VERIFY: 1\n before_script:\n - mkdir -p ~/.docker\n - echo \"$TLS_CA_CERT\" > ~/.docker/ca.pem\n - echo \"$TLS_CERT\" > ~/.docker/cert.pem\n - echo \"$TLS_KEY\" > ~/.docker/key.pem\n script:\n - docker login -u gitlab-ci-token -p \"$CI_JOB_TOKEN\" \"$CI_REGISTRY\"\n - docker info\n - docker stack deploy --with-registry-auth --compose-file=docker-stack.yml mystack\n\nHere's the error I'm getting in the output of my GitLab CI job:\n$ docker login -u gitlab-ci-token -p \"$CI_JOB_TOKEN\" \"$CI_REGISTRY\"\nWARNING! Using --password via the CLI is insecure. Use --password-stdin.\nerror during connect: Post https://<ip-address>:2377/v1.39/auth: x509: cannot validate certificate for <ip-address> because it doesn't contain any IP SANs\n\nI'm using the following set of commands to generate my certs (ca.pem, server-cert.pem and server-key.pem) that I'm trying to use in my deploy stage described above. I have saved TLS_CA_CERT, TLS_CERT and TLS_KEY to variables that are being used in GitLab CI. \nopenssl genrsa -aes256 -out ca-key.pem 4096\n\nopenssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem\n\nopenssl genrsa -out server-key.pem 4096\n\nopenssl req -subj \"/CN=<ip-address>\" -sha256 -new -key server-key.pem -out server.csr\n\necho subjectAltName = IP:<ip-address> >> extfile.cnf\n\necho extendedKeyUsage = serverAuth >> extfile.cnf\n\nopenssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem \\\n -CAcreateserial -out server-cert.pem -extfile extfile.cnf" }, { "role": "assistant", "content": "I see you have included the IP address in the subjectAltName\necho subjectAltName = IP:<ip-address> >> extfile.cnf\n\nCheck, as in here, if this is a configuration issue:\n\nI put subjectAltName in the wrong section. Working method: Basically I edited openssl.cnf, in section [v3_ca] I added 'subjectAltName = IP:192.168.2.107'.\n Produced new certificate and added to server + client.\n\nYou need to make sure your extension is declared in the v3_ca part, as shown here." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git merge with force overwrite\n\nI have a branch called demo which I need to merge with master branch. I can get the desired result with following commands:\ngit pull origin demo\ngit checkout master\ngit pull origin master\ngit merge demo\ngit push origin master\n\nMy only concern is, if there are any merge issues, I want to tell git to overwrite changes in master branch without giving me merge prompt. So basically changes in demo branch should automatically overwrite changes in master branch. \nI looked around there are multiple options but I don't want to take chances with merging." }, { "role": "assistant", "content": "Not really related to this answer, but I'd ditch git pull, which just runs git fetch followed by git merge. You are doing three merges, which is going to make your Git run three fetch operations, when one fetch is all you will need. Hence:\ngit fetch origin # update all our origin/* remote-tracking branches\n\ngit checkout demo # if needed -- your example assumes you're on it\ngit merge origin/demo # if needed -- see below\n\ngit checkout master\ngit merge origin/master\n\ngit merge -X theirs demo # but see below\n\ngit push origin master # again, see below\n\nControlling the trickiest merge\nThe most interesting part here is git merge -X theirs. As root545 noted, the -X options are passed on to the merge strategy, and both the default recursive strategy and the alternative resolve strategy take -X ours or -X theirs (one or the other, but not both). To understand what they do, though, you need to know how Git finds, and treats, merge conflicts.\nA merge conflict can occur within some file1 when the base version differs from both the current (also called local, HEAD, or --ours) version and the other (also called remote or --theirs) version of that same file. That is, the merge has identified three revisions (three commits): base, ours, and theirs. The \"base\" version is from the merge base between our commit and their commit, as found in the commit graph (for much more on this, see other StackOverflow postings). Git has then found two sets of changes: \"what we did\" and \"what they did\". These changes are (in general) found on a line-by-line, purely textual basis. Git has no real understanding of file contents; it is merely comparing each line of text.\nThese changes are what you see in git diff output, and as always, they have context as well. It's possible that things we changed are on different lines from things they changed, so that the changes seem like they would not collide, but the context has also changed (e.g., due to our change being close to the top or bottom of the file, so that the file runs out in our version, but in theirs, they have also added more text at the top or bottom).\nIf the changes happen on different lines—for instance, we change color to colour on line 17 and they change fred to barney on line 71—then there is no conflict: Git simply takes both changes. If the changes happen on the same lines, but are identical changes, Git takes one copy of the change. Only if the changes are on the same lines, but are different changes, or that special case of interfering context, do you get a modify/modify conflict.\nThe -X ours and -X theirs options tell Git how to resolve this conflict, by picking just one of the two changes: ours, or theirs. Since you said you are merging demo (theirs) into master (ours) and want the changes from demo, you would want -X theirs.\nBlindly applying -X, however, is dangerous. Just because our changes did not conflict on a line-by-line basis does not mean our changes do not actually conflict! One classic example occurs in languages with variable declarations. The base version might declare an unused variable:\nint i;\n\nIn our version, we delete the unused variable to make a compiler warning go away—and in their version, they add a loop some lines later, using i as the loop counter. If we combine the two changes, the resulting code no longer compiles. The -X option is no help here since the changes are on different lines.\nIf you have an automated test suite, the most important thing to do is to run the tests after merging. You can do this after committing, and fix things up later if needed; or you can do it before committing, by adding --no-commit to the git merge command. We'll leave the details for all of this to other postings.\n\n1You can also get conflicts with respect to \"file-wide\" operations, e.g., perhaps we fix the spelling of a word in a file (so that we have a change), and they delete the entire file (so that they have a delete). Git will not resolve these conflicts on its own, regardless of -X arguments.\n\nDoing fewer merges and/or smarter merges and/or using rebase\nThere are three merges in both of our command sequences. The first is to bring origin/demo into the local demo (yours uses git pull which, if your Git is very old, will fail to update origin/demo but will produce the same end result). The second is to bring origin/master into master.\nIt's not clear to me who is updating demo and/or master. If you write your own code on your own demo branch, and others are writing code and pushing it to the demo branch on origin, then this first-step merge can have conflicts, or produce a real merge. More often than not, it's better to use rebase, rather than merge, to combine work (admittedly, this is a matter of taste and opinion). If so, you might want to use git rebase instead. On the other hand, if you never do any of your own commits on demo, you don't even need a demo branch. Alternatively, if you want to automate a lot of this, but be able to check carefully when there are commits that both you and others, made, you might want to use git merge --ff-only origin/demo: this will fast-forward your demo to match the updated origin/demo if possible, and simply outright fail if not (at which point you can inspect the two sets of changes, and choose a real merge or a rebase as appropriate).\nThis same logic applies to master, although you are doing the merge on master, so you definitely do need a master. It is, however, even likelier that you would want the merge to fail if it cannot be done as a fast-forward non-merge, so this probably also should be git merge --ff-only origin/master.\nLet's say that you never do your own commits on demo. In this case we can ditch the name demo entirely:\ngit fetch origin # update origin/*\n\ngit checkout master\ngit merge --ff-only origin/master || die \"cannot fast-forward our master\"\n\ngit merge -X theirs origin/demo || die \"complex merge conflict\"\n\ngit push origin master\n\nIf you are doing your own demo branch commits, this is not helpful; you might as well keep the existing merge (but maybe add --ff-only depending on what behavior you want), or switch it to doing a rebase. Note that all three methods may fail: merge may fail with a conflict, merge with --ff-only may not be able to fast-forward, and rebase may fail with a conflict (rebase works by, in essence, cherry-picking commits, which uses the merge machinery and hence can get a merge conflict)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is there a way to show build status/code coverage per branch\n\nWe are setting the CI on our GitLab and we are able to show build status and code coverage on master using the following:\nREADME.md in root directory of myproject:\n[![build status](http://mygitlab/mygroup/myproject/badges/master/build.svg)](http://mygitlab/mygroup/myproject/commits/master) \n[![coverage report](http://mygitlab/mygroup/myproject/badges/master/coverage.svg)](http://mygitlab/mygroup/myproject/commits/master)\n\nSomething we would like is show build status/code coverage of current branch when viewing the README.md in the branch. Right now, the links have master hardcoded so the branches show the status of the master. \nIs there a way to use relative URL (or something else) so the build status / code coverage automatically adapt to the branch you're viewing? Looking at the documentation, it looks like it's impossible, because you have to specify the branch." }, { "role": "assistant", "content": "Starting in GitLab 9.3 (available only in Starter/Bronze and higher), code quality will be evaluated as part of the CI/CD pipeline and the results will display in the merge request. \nYou can see an example of how this looks in a merge request in the documentation at GitLab Code Quality. \nThis works 'automatically' via Auto DevOps or you can configure Code Quality manually by using the Code Quality examples\nThis doesn't address showing code quality and pipeline status for a given branch in the README. As mentioned, it does show the pipeline status and code quality in the MR itself. However, when viewing a particular branch, the commit at the top of the page does show the overall pipeline status. Click on that status to go to the pipeline for more detailed job information, including the Code Quality job itself. \n\nIt's not quite as handy as what you're looking for, but it is a workaround. Usually, concerns about quality and build status are most important on the proposed merge request itself, where fixes can be made prior to merging them into the master/target branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-commit - Record changes to the repository -a --all" }, { "role": "assistant", "content": "Tell the command to automatically stage files that have\nbeen modified and deleted, but new files you have not\ntold Git about are not affected." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %GT" }, { "role": "assistant", "content": "show the trust level for the key used to sign a signed commit" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I create a new Git branch from an old commit? [duplicate]\nThis question already has answers here:\n \n \n\n\n\nClosed 11 years ago.\n\n\n\n\nPossible Duplicate / a more recent/less clear question \nBranch from a previous commit using Git\n\nI have a Git branch called jzbranch and have an old commit id: a9c146a09505837ec03b.\nHow do I create a new branch, justin, from the information listed above?" }, { "role": "assistant", "content": "git checkout -b NEW_BRANCH_NAME COMMIT_ID\n\nThis will create a new branch called 'NEW_BRANCH_NAME' and check it out.\n(\"check out\" means \"to switch to the branch\")\ngit branch NEW_BRANCH_NAME COMMIT_ID\n\nThis just creates the new branch without checking it out.\n\nin the comments many people seem to prefer doing this in two steps. here's how to do so in two steps:\ngit checkout COMMIT_ID\n# you are now in the \"detached head\" state\ngit checkout -b NEW_BRANCH_NAME" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rebase - Reapply commits on top of another base tip ours" }, { "role": "assistant", "content": "This resolves any number of heads, but the resulting tree of the\nmerge is always that of the current branch head, effectively\nignoring all changes from all other branches. It is meant to\nbe used to supersede old development history of side\nbranches. Note that this is different from the -Xours option to\nthe recursive merge strategy." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git merge from someone else's fork\nI have a repository on github, and someone else has forked it and made changes.\nI want to:\n\nCreate a new branch\nMerge their changes into my branch\n\nI have created the new branch:\ngit commit -b my_new_branch\n\nHow do I merge their code into this new branch? \nThis is the branch that I have created: https://github.com/poundifdef/VirginMobileMinutesChecker/tree/widget_toast\nThis is the branch that I want to merge:\nhttps://github.com/xbakesx/VirginMobileMinutesChecker\nWhat is the best way to do this? I've tried a \"pull\" and it won't work. I honestly have no idea what I'm doing in gitland, so if there is a better way to accomplish this (besides my creating a branch and trying to merge) then I am all ears!" }, { "role": "assistant", "content": "Add their github fork repo as a remote to a clone of your own repo:\ngit remote add other-guys-repo <url to other guys repo>\n\nGet their changes:\ngit fetch other-guys-repo\n\nCheckout the branch where you want to merge:\ngit checkout my_new_branch\n\nMerge their changes in (assuming they did their work on the master branch):\ngit merge other-guys-repo/master\n\nResolve conflicts, commit the resolutions and voila." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why git can't do hard/soft resets by path?\n$ git reset -- <file_path> can reset by path.\nHowever, $ git reset (--hard|--soft) <file_path> will report an error like below:\nCannot do hard|soft reset with paths." }, { "role": "assistant", "content": "Because there's no point (other commands provide that functionality already), and it reduces the potential for doing the wrong thing by accident.\nA \"hard reset\" for a path is just done with git checkout HEAD -- <path> (checking out the existing version of the file).\nA soft reset for a path doesn't make sense.\nA mixed reset for a path is what git reset -- <path> does." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters [<branchname>]@{push} , e.g. master@{push} , @{push}" }, { "role": "assistant", "content": "The suffix @{push} reports the branch \"where we would push to\" if git push were run while branchname was checked out (or the current HEAD if no branchname is specified). Like for @{upstream} , we report\nthe remote-tracking branch that corresponds to that branch at the remote. Here’s an example to make it more clear: $ git config push.default current\n$ git config remote.pushdefault myfork\n$ git switch -c mybranch origin/master\n\n$ git rev-parse --symbolic-full-name @{upstream}\nrefs/remotes/origin/master\n\n$ git rev-parse --symbolic-full-name @{push}\nrefs/remotes/myfork/mybranch Note in the example that we set up a triangular workflow, where we pull\nfrom one location and push to another. In a non-triangular workflow, @{push} is the same as @{upstream} , and there is no need for it. This suffix is also accepted when spelled in uppercase, and means the same\nthing no matter the case." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters FETCH_HEAD" }, { "role": "assistant", "content": "records the branch which you fetched from a remote repository with\nyour last git fetch invocation." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-stash - Stash the changes in a dirty working directory away Testing partial commits" }, { "role": "assistant", "content": "You can use git stash push --keep-index when you want to make two or\nmore commits out of the changes in the work tree, and you want to test\neach change before committing: # ... hack hack hack ...\n$ git add --patch foo # add just first part to the index\n$ git stash push --keep-index # save all other changes to the stash\n$ edit/build/test first part\n$ git commit -m 'First part' # commit fully tested change\n$ git stash pop # prepare to work on all other changes\n# ... repeat above five steps until one commit remains ...\n$ edit/build/test remaining parts\n$ git commit foo -m 'Remaining parts'" } ]