messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --color-words[=<regex>]" }, { "role": "assistant", "content": "Equivalent to --word-diff=color plus (if a regex was\nspecified) --word-diff-regex=<regex> ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options merge.directoryRenames" }, { "role": "assistant", "content": "Whether Git detects directory renames, affecting what happens at\nmerge time to new files added to a directory on one side of\nhistory when that directory was renamed on the other side of\nhistory. If merge.directoryRenames is set to \"false\", directory\nrename detection is disabled, meaning that such new files will be\nleft behind in the old directory. If set to \"true\", directory\nrename detection is enabled, meaning that such new files will be\nmoved into the new directory. If set to \"conflict\", a conflict\nwill be reported for such paths. If merge.renames is false,\nmerge.directoryRenames is ignored and treated as false. Defaults\nto \"conflict\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to keep the local file or the remote file during merge using Git and the command line?\nI know how to merge modification using vimdiff, but, assuming I just know that the entire file is good to keep or to throw away, how do I do that? \nI don't want to open vimdiff for each of them, I change want a command that says 'keep local' or 'keep remote'.\nE.G: I got a merge with files marked as changed because somebody opened it under windows, changing the EOL, and then commited. When merging, I want to just keep my own version and discard his.\nI'm also interested in the contrary: I screwed up big time and want to accept the remote file, discarding my changes." }, { "role": "assistant", "content": "You can as well do:\ngit checkout --theirs /path/to/file\n\nto keep the remote file, and:\ngit checkout --ours /path/to/file\n\nto keep local file.\nThen git add them and everything is done.\nEdition:\nKeep in mind that this is for a merge scenario. During a rebase --theirs refers to the branch where you've been working." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Making git diff --stat show full file path\nOn doing git diff --stat some files are listed with full path from repository base but some files are listed as:\n.../short/path/to/filename. \n\nThat is the path starts with ... and only short path is shown.\nI would like git diff to list full file path for all files for it to be easily processed by a script. Is there some way I can get git diff to always show full path" }, { "role": "assistant", "content": "By default git diff truncates its output to fit into a 80-column terminal.\nYou can override this by specifying values using the --stat option:\n--stat[=<width>[,<name-width>[,<count>]]]\n Generate a diffstat. You can override the default output width for\n 80-column terminal by --stat=<width>. The width of the filename\n part can be controlled by giving another width to it separated by a\n comma. By giving a third parameter <count>, you can limit the\n output to the first <count> lines, followed by ... if there are\n more.\n\n These parameters can also be set individually with\n --stat-width=<width>, --stat-name-width=<name-width> and\n --stat-count=<count>.\n\nFor example, by setting the output value to a very large number:\ngit diff --stat=10000\n\nNote that produces the path relative to the root of the git repository.\n(For scripting you might want to use git diff-tree directly since it's more of a \"plumbing\" command, although I suspect you'll be fine either way. Note that you need the same extra text with --stat when using git diff-tree. The essential difference between using the git diff \"porcelain\" front end, and the git diff-tree plumbing command, is that git diff looks up your configured settings for options like diff.renames to decide whether to do rename detection. Well, that, plus the front end git diff will do the equivalent of git diff-index if you're comparing a commit with the index, for instance. In other words, git diff reads your config and invokes the right plumbing automatically.)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitLab CI - Cache not working\n\nI'm currently using GitLab in combination with CI runners to run unit tests of my project, to speed up the process of bootstrapping the tests I'm using the built-in cache functionality, however this doesn't seem to work.\nEach time someone commits to master, my runner does a git fetch and proceeds to remove all cached files, which means I have to stare at my screen for around 10 minutes to wait for a test to complete while the runner re-downloads all dependencies (NPM and PIP being the biggest time killers).\nOutput of the CI runner:\nFetching changes...\n\nRemoving bower_modules/jquery/ --+-- Shouldn't happen!\nRemoving bower_modules/tether/ |\nRemoving node_modules/ |\nRemoving vendor/ --'\nHEAD is now at 7c513dd Update .gitlab-ci.yml\n\nCurrently my .gitlab-ci.yml\nimage: python:latest\n\nservices:\n - redis:latest\n - node:latest\n\ncache:\n key: \"$CI_BUILD_REF_NAME\"\n untracked: true\n paths:\n - ~/.cache/pip/\n - vendor/\n - node_modules/\n - bower_components/\n\n\nbefore_script:\n - python -V\n\n # Still gets executed even though node is listed as a service??\n - '(which nodejs && which npm) || (apt-get update -q && apt-get -o dir::cache::archives=\"vendor/apt/\" install nodejs npm -yqq)'\n - npm install -g bower gulp\n\n # Following statements ignore cache!\n - pip install -r requirements.txt\n - npm install --only=dev\n - bower install --allow-root\n - gulp build\n\ntest:\n variables:\n DEBUG: \"1\"\n script:\n - python -m unittest myproject\n\nI've tried reading the following articles for help however none of them seem to fix my problem:\n\nhttp://docs.gitlab.com/ce/ci/yaml/README.html#cache\nhttps://fleschenberg.net/gitlab-pip-cache/\nhttps://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/336" }, { "role": "assistant", "content": "Turns out that I was doing some things wrong:\n\nYour script can't cache files outside of your project scope, creating a virtual environment instead and caching that allows you to cache your pip modules.\nMost important of all: Your test must succeed in order for it to cache the files. \n\nAfter using the following config I got a -3 minute time difference:\n\nCurrently my configuration looks like follows and works for me.\n# Official framework image. Look for the different tagged releases at:\n# https://hub.docker.com/r/library/python\nimage: python:latest\n\n# Pick zero or more services to be used on all builds.\n# Only needed when using a docker container to run your tests in.\n# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service\nservices:\n- mysql:latest\n- redis:latest\n\ncache:\n untracked: true\n key: \"$CI_BUILD_REF_NAME\"\n paths:\n - venv/\n - node_modules/\n - bower_components/\n\n\n# This is a basic example for a gem or script which doesn't use\n# services such as redis or postgres\nbefore_script:\n\n# Check python installation\n- python -V\n\n# Install NodeJS (Gulp & Bower)\n# Default repository is outdated, this is the latest version\n- 'curl -sL https://deb.nodesource.com/setup_8.x | bash -'\n- apt-get install -y nodejs\n- npm install -g bower gulp\n\n# Install dependencie\n- pip install -U pip setuptools\n- pip install virtualenv\n\n\ntest:\n\n # Indicate to the framework that it's being unit tested\n variables:\n DEBUG: \"1\"\n\n # Test script\n script:\n\n # Set up virtual environment\n - virtualenv venv -ppython3\n - source venv/bin/activate\n - pip install coverage\n - pip install -r requirements.txt\n\n # Install NodeJS & Bower + Compile JS\n - npm install --only=dev\n - bower install --allow-root\n - gulp build\n\n # Run all unit tests\n - coverage run -m unittest project.tests\n - coverage report -m project/**/*.py\n\nWhich resulted in the following output:\nFetching changes...\nRemoving .coverage --+-- Don't worry about this\nRemoving bower_components/ |\nRemoving node_modules/ |\nRemoving venv/ --`\nHEAD is now at 24e7618 Fix for issue #16\nFrom https://git.example.com/repo\n85f2f9b..42ba753 master -> origin/master\nChecking out 42ba7537 as master...\nSkipping Git submodules setup\nChecking cache for master... --+-- The files are back now :)\nSuccessfully extracted cache --`\n\n...\n\nproject/module/script.py 157 9 94% 182, 231-244\n---------------------------------------------------------------------------\nTOTAL 1084 328 70%\nCreating cache master...\nCreated cache\nUploading artifacts...\nvenv/: found 9859 matching files \nnode_modules/: found 7070 matching files \nbower_components/: found 982 matching files \nTrying to load /builds/repo.tmp/CI_SERVER_TLS_CA_FILE ... \nDialing: tcp git.example.com:443 ... \nUploading artifacts to coordinator... ok id=127 responseStatus=201 Created token=XXXXXX\nJob succeeded\n\nFor the coverage report, I used the following regular expression:\n^TOTAL\\s+(?:\\d+\\s+){2}(\\d{1,3}%)$" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why can't a branch name contain the 'space' char?\nI tried:\ngit branch \"MyProj/bin/ ignored\"\n\nand received:\nfatal: 'MyProj/bin/ ignored' is not a valid branch name.\n\nThe git-branch man page points to the git-check-ref-format man page to get the actual rules for a valid branch name.\nSure enough, the reason for the above fatal error appears to be the inclusion of a space character.\nAny idea why, in this day and age, spaces are still excluded from a branch name (I would have expected it in ancient CVS, for example, but Git?)\nWhat could be valid technical reasons for that?" }, { "role": "assistant", "content": "I do not know if you are going to find a pure, technical reason down at the bottom of this. However, I can offer that spaces tend to throw wrenches in all sorts of *nix utilities and filename processing, so it may have been to avoid accidentally doing anything wrong further down the line. After all, a git branch boils down to a file in the repo and this avoids dealing with spaces in that file's name (specifically, a branch is a file in .git/refs/heads/, as mentioned in the comment).\nMostly I would guess the reason is philosophical, and meant to keep things simple. Branch names are human-readable names that have no real reason to be complicated (and require typing two extra chars each time haha, to invoke the ghost of the sysadmin who has aliased every command to an indecipherable three letter combination). Otherwise known as the \"why cd is not chdir\" argument." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects separate" }, { "role": "assistant", "content": "Show full diff with respect to each of parents.\nSeparate log entry and diff is generated for each parent." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-init - Create an empty Git repository or reinitialize an existing one" }, { "role": "assistant", "content": "TEMPLATE DIRECTORY Files and directories in the template directory whose name do not start with a\ndot will be copied to the $GIT_DIR after it is created. The template directory will be one of the following (in order): the argument given with the --template option; the contents of the $GIT_TEMPLATE_DIR environment variable; the init.templateDir configuration variable; or the default template directory: /usr/share/git-core/templates . The default template directory includes some directory structure, suggested\n\"exclude patterns\" (see gitignore ), and sample hook files. The sample hooks are all disabled by default. To enable one of the\nsample hooks rename it by removing its .sample suffix. See githooks for more general info on hook execution." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to force push to Gitlab\ngit push --force gitlab master \nEnumerating objects: 50, done.\nCounting objects: 100% (50/50), done.\nDelta compression using up to 8 threads\nCompressing objects: 100% (29/29), done.\nWriting objects: 100% (40/40), 12.22 KiB | 4.07 MiB/s, done.\nTotal 40 (delta 26), reused 18 (delta 11)\nremote: GitLab: You are not allowed to force push code to a protected branch on this project.\nTo gitlab.com:xxx/yyyy.git\n ! [remote rejected] master -> master (pre-receive hook declined)\nerror: failed to push some refs to '[email protected]:xxx/yyyy.git'\n\nWhat should I do to push my commits to Gitlab? I use several remotes, and other remotes are OK and I was able to finish\ngit push --force some_other_remote master" }, { "role": "assistant", "content": "From the official documentation on dealing with Protected Branches:\n\nNavigate to your project’s Settings ➔ Repository\nScroll to find the Protected branches section.\nFrom the Branch dropdown menu, select the branch you want to protect and click Protect.\n\nFollowing the steps above, you should be greeted with a box similar to this one below.\n\nThere, you can click either:\n\n\"Allowed to force push\" toggle button, or\nthe orange Unprotect button\n\nfor the branch you want to force push to, e.g., master.\nIf you don't want to navigate through the navigation bars, you can also fill out this URL template:\nhttps://gitlab.com/<USERNAME>/<PROJECTNAME>/settings/repository#js-protected-branches-settings\n\nand replace <USERNAME> and <PROJECTNAME> with your specific username and project name, respectively.\nNote, the \"Allowed to force push\" button is probably favored over un-selecting the Unprotect button because branch protection gives you additional safety from accidentally deleting your branch. But either option appears to work.\nMore help:\n\nCommunity discussion on force pushing on branch https://gitlab.com/gitlab-com/support-forum/issues/93\nOfficial documentation to do so https://docs.gitlab.com/ee/user/project/protected_branches.html" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-branch - List, create, or delete branches --no-color" }, { "role": "assistant", "content": "Turn off branch colors, even when the configuration file gives the\ndefault to color output.\nSame as --color=never ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Undo git reset --hard with uncommitted files in the staging area\nI am trying to recover my work. I stupidly did git reset --hard, but before that I've done only get add . and didn't do git commit. Please help! Here is my log:\nMacBookPro:api user$ git status\n# On branch master\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n\n# modified: .gitignore\n...\n\n\nMacBookPro:api user$ git reset --hard\nHEAD is now at ff546fa added new strucuture for api\n\nIs it possible to undo git reset --hard in this situation?" }, { "role": "assistant", "content": "You should be able to recover any files back that you added to the index (e.g, as in your situation, with git add .) although it might be a bit of work. In order to add a file to the index, git adds it to the object database, which means it can be recovered so long as garbage collection hasn't happened yet. There's an example of how to do this given in Jakub Narębski's answer here:\n\nRecovering added file after doing git reset --hard HEAD^\n\nHowever, I tried that out on a test repository, and there were a couple of problems - --cached should be --cache, and I found that it didn't actually create the .git/lost-found directory. However, the following steps worked for me:\ngit fsck --cache --unreachable $(git for-each-ref --format=\"%(objectname)\")\n\nThat should output all objects in the object database that aren't reachable by any ref, in the index, or via the reflog. The output will look something like this:\nunreachable blob 907b308167f0880fb2a5c0e1614bb0c7620f9dc3\nunreachable blob 72663d3adcf67548b9e0f0b2eeef62bce3d53e03\n\n... and for each of those blobs, you can do:\ngit show 907b308\n\nTo output the contents of the file.\n\nToo much output?\nUpdate in response to sehe's comment below:\nIf you find that you have many commits and trees listed in the output from that command, you may want to remove from the output any objects which are referenced from unreferenced commits. (Typically you can get back to these commits via the reflog anyway - we're just interested in objects that have been added to the index but can never be found via a commit.)\nFirst, save the output of the command, with:\ngit fsck --cache --unreachable $(git for-each-ref --format=\"%(objectname)\") > all\n\nNow the object names of those unreachable commits can be found with:\negrep commit all | cut -d ' ' -f 3\n\nSo you can find just the trees and objects that have been added to the index, but not committed at any point, with:\ngit fsck --cache --unreachable $(git for-each-ref --format=\"%(objectname)\") \\\n $(egrep commit all | cut -d ' ' -f 3)\n\nThat enormously cuts down the number of objects you'll have to consider.\n\nUpdate: Philip Oakley below suggests another way of cutting down the number of objects to consider, which is to just consider the most recently modified files under .git/objects. You can find these with:\nfind .git/objects/ -type f -printf '%TY-%Tm-%Td %TT %p\\n' | sort\n\n(I found that find invocation here.) The end of that list might look like:\n2011-08-22 11:43:43.0234896770 .git/objects/b2/1700b09c0bc0fc848f67dd751a9e4ea5b4133b\n2011-09-13 07:36:37.5868133260 .git/objects/de/629830603289ef159268f443da79968360913a\n\nIn which case you can see those objects with:\ngit show b21700b09c0bc0fc848f67dd751a9e4ea5b4133b\ngit show de629830603289ef159268f443da79968360913a\n\n(Note that you have to remove the / at the end of the path to get the object name.)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Out of a git console: how do I execute a batch file and then return to git console?\nI have a small utility script called clear.bat that does some housekeeping work on my sources.\nIt is a .bat file so that I could easily double-click it in Windows Explorer.\nSometimes, I find it more handy to execute it from my Git bash (msysgit, if this matters).\nTo do this, I type\ncmd\nclear.bat\nexit\n\ncmd turns my Git bash into a normal cmd window where I could easily execute my batch. When I type exit, the cmd environment is terminated and I'm back in my Git bash.\nCould this be achieved in an easier way?\nI tried cmd /C clean.bat since the docs say \nSyntax\n CMD [charset] [options]\n\n CMD [charset] [options] [/c Command] \n\n CMD [charset] [options] [/k Command] \n\nOptions \n /C Run Command and then terminate\n\n /K Run Command and then return to the CMD prompt.\n This is useful for testing, to examine variables\n\n\nEdit:\nJust noticed that the post is broken. \nWhat I want is to execute clean.bat from within the Git bash without having to type the three commands above (cmd, clear.bat, exit). I just want to execute the .bat file from within my Git bash. Obvious way would be to create a separate .sh file that does the same work but this will lead to double code.\n\nEdit 2:\nWhen I execute cmd /C clean.bat, the Git bash turns into a plain CMD environment and only displays the prompt. The file clean.bat does not get executed. It's the same as if I just type cmd.\nAlso, adding a /debug switch does literally nothing. Seems like only cmd gets evaluated and all further parameters are getting ignored." }, { "role": "assistant", "content": "After playing around a bit more, I found the solution myself:\ncmd \"/C clean.bat\"\n\ndoes the trick. But I got no clue, why..." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to force image (cache) update in README.rst on GitHub\n\nIn one of my project I'm using an external image link to display a screenshot via the GitHub page, which automatically parses the README.rst\nGitHub page of ROyWeb\nI updated this screenshot on my web server several times in the last weeks and I just realised that it is not updated on the GitHub page since... well I think it never updated ;-)\nGitHub somehow downloaded the image and loads it from it's cache servers.\nWithin the README.rst, there is clearly the correct link:\nActual link to the ROyWeb screenshot\nWhich you can confirm, when you load the raw file:\nraw README.txt on GitHub\nBut when I check the URL of the displayed image on the GitHub page, I get:\nGitHub cached screenshot of ROyWeb\nDoes anyone know how to force a \"recache\"?" }, { "role": "assistant", "content": "curl -X PURGE {url of cached badge image}" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can you execute Gitlab stages conditionally?\nThere are 3 stages - build, test and deploy in .gitlab-ci.yml.\nA nightly regression test stage needs to be run nightly.\nHere's the relevant .gitlab-ci.yml code:\nstages:\n - build\n - test\n - deploy\n\nbuild_project:\n stage: build\n script:\n - cd ./some-dir\n - build-script.sh\n except:\n - tags\n\n#Run this only when say variable 'NIGHTLY_TEST == True'. But HOW?\nnightly_regression_test_project:\n stage: test\n script:\n - cd ./some-dir\n - execute test-script\n\nTagging daily to only run the test stage is not preferable.\nAny other ideas?" }, { "role": "assistant", "content": "except and only can specify variables that will trigger them.\nYou can use the following in your .gitlab-ci.yml:\nbuild1:\n stage: build\n script:\n - echo \"Only when NIGHTLY_TEST is false\"\n except:\n variables:\n - $NIGHTLY_TEST \n \ntest1:\n stage: test\n script: \n - echo \"Only when NIGHTLY_TEST is true\"\n only:\n variables:\n - $NIGHTLY_TEST" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-index-pack" }, { "role": "assistant", "content": "Build pack index file for an existing packed archive" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: Easiest way to reset git config file\nI am finally getting around to learning git. However, I unwisely started messing around with it awhile back (before I really knew what I was doing) via Sourcetree. Now that I'm trying to go through it, I have a pretty large list of settings. When I input: \ngit config --list\n\nI get the following result:\ncore.excludesfile=~/.gitignore\ncore.legacyheaders=false\ncore.quotepath=false\ncore.pager=less -r\nmergetool.keepbackup=true\npush.default=simple\ncolor.ui=auto\ncolor.interactive=auto\nrepack.usedeltabaseoffset=true\nalias.s=status\nalias.a=!git add . && git status\nalias.au=!git add -u . && git status\nalias.aa=!git add . && git add -u . && git status\nalias.c=commit\nalias.cm=commit -m\nalias.ca=commit --amend\nalias.ac=!git add . && git commit\nalias.acm=!git add . && git commit -m\nalias.l=log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'\nalias.ll=log --stat --abbrev-commit\nalias.lg=log --color --graph --pretty=format:'%C(bold white)%h%Creset -%C(bold green)%d%Creset %s %C(bold green)(%cr)%Creset %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative\nalias.llg=log --color --graph --pretty=format:'%C(bold white)%H %d%Creset%n%s%n%+b%C(bold blue)%an <%ae>%Creset %C(bold green)%cr (%ci)' --abbrev-commit\nalias.d=diff\nalias.master=checkout master\nalias.spull=svn rebase\nalias.spush=svn dcommit\nalias.alias=!git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\ => \\2/' | sort\ninclude.path=~/.gitcinclude\ninclude.path=.githubconfig\ninclude.path=.gitcredential\ndiff.exif.textconv=exif\ncredential.helper=osxkeychain\ncore.excludesfile=/Users/myusername/.gitignore_global\ndifftool.sourcetree.cmd=opendiff \"$LOCAL\" \"$REMOTE\"\ndifftool.sourcetree.path=\nmergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"\nmergetool.sourcetree.trustexitcode=true\nuser.name=My Name\n[email protected]\n\nAnd that seems like more than what I want to start with since the tutorial that I'm working through doesn't pull all of that up.\nIs there a way to \"Reset\" the config file to a default state?" }, { "role": "assistant", "content": "Note that git config --list does display both\n\nthe system (<path/to/git/config>), meaning where Git has been installed.\n(By default, on Windows: C:\\Program Files\\Git)\nglobal ($HOME/.gitconfig).\nOn Windows, $HOME would be %USERPROFILE%\nand local (path/to/repo/.git/config) settings.\n\nTo see the ones you have added to your repo:\ngit config --local --list\n\nTo remove multiple values:\ngit config [<file-option>] --unset-all name [value_regex]\ngit config [<file-option>] --remove-section name\n\nFor instance: git config --local --remove-section alias would get rid of the aliases.\nThat is a bit more precise that just getting rid of the .git/config file.\n\n\nwhy git config --local --list doesn't show my proxy setting?\n\nTypically because a proxy setting could have been added for all repository, globally.\n git config --global --list\n\nThat would be in ~/.gitconfig or %USERPROFILE%\\.gitconfig.\n\nNote: if you want to remove a specific value (not a regex), use Git 2.30 (Q1 2021)\nVarious subcommands of \"git config\"(man) that takes value_regex learn the \"--literal-value\" option to take the value_regex option as a literal string.\nSee commit c902618 (25 Nov 2020) by Junio C Hamano (gitster).\nSee commit 3f1bae1, commit c90702a, commit fda4394, commit d156719, commit 2076dba, commit 247e2f8, commit 504ee12 (25 Nov 2020) by Derrick Stolee (derrickstolee).\n(Merged by Junio C Hamano -- gitster -- in commit a10e784, 08 Dec 2020)\n\nconfig: add --fixed-value option, un-implemented\nSigned-off-by: Derrick Stolee\n\n\nThe 'git config'(man) builtin takes a 'value-pattern' parameter for several actions.\nThis can cause confusion when expecting exact value matches instead of regex matches, especially when the input string contains metacharacters. While callers can escape the patterns themselves, it would be more friendly to allow an argument to disable the pattern matching in favor of an exact string match.\nAdd a new '--fixed-value' option that does not currently change the behavior.\nThe implementation will be filled in by later changes for each appropriate action. For now, check and test that --fixed-value will abort the command when included with an incompatible action or without a 'value-pattern' argument.\nThe name '--fixed-value' was chosen over something simpler like '--fixed' because some commands allow regular expressions on the key in addition to the value.\n\ngit config now includes in its man page:\n\n--fixed-value\nWhen used with the value-pattern argument, treat value-pattern as\nan exact string instead of a regular expression. This will restrict\nthe name/value pairs that are matched to only those where the value\nis exactly equal to the value-pattern." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What exactly does git's \"rebase --preserve-merges\" do (and why?)\nGit's documentation for the rebase command is quite brief:\n--preserve-merges\n Instead of ignoring merges, try to recreate them.\n\nThis uses the --interactive machinery internally, but combining it\nwith the --interactive option explicitly is generally not a good idea\nunless you know what you are doing (see BUGS below).\n\nSo what actually happens when you use --preserve-merges? How does it differ from the default behavior (without that flag)? What does it mean to \"recreate\" a merge, etc." }, { "role": "assistant", "content": "As with a normal git rebase, git with --preserve-merges first identifies a list of commits made in one part of the commit graph, and then replays those commits on top of another part. The differences with --preserve-merges concern which commits are selected for replay and how that replaying works for merge commits.\nTo be more explicit about the main differences between normal and merge-preserving rebase:\n\nMerge-preserving rebase is willing to replay (some) merge commits, whereas normal rebase completely ignores merge commits.\nBecause it's willing to replay merge commits, merge-preserving rebase has to define what it means to replay a merge commit, and deal with some extra wrinkles\n\n\nThe most interesting part, conceptually, is perhaps in picking what the new commit's merge parents should be. \nReplaying merge commits also require explicitly checking out particular commits (git checkout <desired first parent>), whereas normal rebase doesn't have to worry about that.\n\nMerge-preserving rebase considers a shallower set of commits for replay:\n\n\nIn particular, it will only consider replaying commits made since the most recent merge base(s) -- i.e. the most recent time the two branches diverged --, whereas normal rebase might replay commits going back to the first time the two branches diverged.\nTo be provisional and unclear, I believe this is ultimately a means to screen out replaying \"old commits\" that have already been \"incorporated into\" a merge commit.\n\n\nFirst I will try to describe \"sufficiently exactly\" what rebase --preserve-merges does, and then there will be some examples. One can of course start with the examples, if that seems more useful.\nThe Algorithm in \"Brief\"\nIf you want to really get into the weeds, download the git source and explore the file git-rebase--interactive.sh. (Rebase is not part of Git's C core, but rather is written in bash. And, behind the scenes, it shares code with \"interactive rebase\".)\nBut here I will sketch what I think is the essence of it. In order to reduce the number of things to think about, I have taken a few liberties. (e.g. I don't try to capture with 100% accuracy the precise order in which computations take place, and ignore some less central-seeming topics, e.g. what to do about commits that have already been cherry-picked between branches).\nFirst, note that a non-merge-preserving rebase is rather simple. It's more or less:\nFind all commits on B but not on A (\"git log A..B\")\nReset B to A (\"git reset --hard A\") \nReplay all those commits onto B one at a time in order.\n\nRebase --preserve-merges is comparatively complicated. Here's as simple as I've been able to make it without losing things that seem pretty important:\nFind the commits to replay:\n First find the merge-base(s) of A and B (i.e. the most recent common ancestor(s))\n This (these) merge base(s) will serve as a root/boundary for the rebase.\n In particular, we'll take its (their) descendants and replay them on top of new parents\n Now we can define C, the set of commits to replay. In particular, it's those commits:\n 1) reachable from B but not A (as in a normal rebase), and ALSO\n 2) descendants of the merge base(s)\n If we ignore cherry-picks and other cleverness preserve-merges does, it's more or less:\n git log A..B --not $(git merge-base --all A B)\nReplay the commits:\n Create a branch B_new, on which to replay our commits.\n Switch to B_new (i.e. \"git checkout B_new\")\n Proceeding parents-before-children (--topo-order), replay each commit c in C on top of B_new:\n If it's a non-merge commit, cherry-pick as usual (i.e. \"git cherry-pick c\")\n Otherwise it's a merge commit, and we'll construct an \"equivalent\" merge commit c':\n To create a merge commit, its parents must exist and we must know what they are.\n So first, figure out which parents to use for c', by reference to the parents of c:\n For each parent p_i in parents_of(c):\n If p_i is one of the merge bases mentioned above:\n # p_i is one of the \"boundary commits\" that we no longer want to use as parents\n For the new commit's ith parent (p_i'), use the HEAD of B_new.\n Else if p_i is one of the commits being rewritten (i.e. if p_i is in R):\n # Note: Because we're moving parents-before-children, a rewritten version\n # of p_i must already exist. So reuse it:\n For the new commit's ith parent (p_i'), use the rewritten version of p_i.\n Otherwise:\n # p_i is one of the commits that's *not* slated for rewrite. So don't rewrite it\n For the new commit's ith parent (p_i'), use p_i, i.e. the old commit's ith parent.\n Second, actually create the new commit c':\n Go to p_1'. (i.e. \"git checkout p_1'\", p_1' being the \"first parent\" we want for our new commit)\n Merge in the other parent(s):\n For a typical two-parent merge, it's just \"git merge p_2'\".\n For an octopus merge, it's \"git merge p_2' p_3' p_4' ...\".\n Switch (i.e. \"git reset\") B_new to the current commit (i.e. HEAD), if it's not already there\n Change the label B to apply to this new branch, rather than the old one. (i.e. \"git reset --hard B\")\n\nRebase with an --onto C argument should be very similar. Just instead of starting commit playback at the HEAD of B, you start commit playback at the HEAD of C instead. (And use C_new instead of B_new.)\nExample 1\nFor example, take commit graph\n B---C <-- master\n / \nA-------D------E----m----H <-- topic\n \\ /\n F-------G\n\nm is a merge commit with parents E and G.\nSuppose we rebased topic (H) on top of master (C) using a normal, non-merge-preserving\nrebase. (For example, checkout topic; rebase master.) In that case, git would select\nthe following commits for replay:\n\npick D\npick E\npick F\npick G\npick H\n\nand then update the commit graph like so:\n B---C <-- master\n / \\ \nA D'---E'---F'---G'---H' <-- topic\n\n(D' is the replayed equivalent of D, etc..)\nNote that merge commit m is not selected for replay.\nIf we instead did a --preserve-merges rebase of H on top of C. (For example, checkout topic; rebase --preserve-merges master.) In this new case, git would select the following commits for replay:\n\npick D\npick E\npick F (onto D' in the 'subtopic' branch)\npick G (onto F' in the 'subtopic' branch)\npick Merge branch 'subtopic' into topic\npick H\n\nNow m was chosen for replay. Also note that merge parents E and G were\npicked for inclusion before merge commit m.\nHere is the resulting commit graph:\n B---C <-- master\n/ \\ \nA D'-----E'----m'----H' <-- topic\n \\ / \n F'-------G'\n\nAgain, D' is a cherry-picked (i.e. recreated) version of D. Same for E', etc.. Every commit not on master has been replayed. Both E and G (the merge parents of m) have been recreated as E' and G' to serve as the parents of m' (after rebase, the tree history still remains the same).\nExample 2\nUnlike with normal rebase, merge-preserving rebase can create multiple\nchildren of the upstream head.\nFor example, consider:\n B---C <-- master\n / \nA-------D------E---m----H <-- topic\n \\ |\n ------- F-----G--/ \n\nIf we rebase H (topic) on top of C (master), then the commits chosen for rebase are:\n\npick D\npick E\npick F\npick G\npick m\npick H\n\nAnd the result is like so:\n B---C <-- master\n / | \\ \nA | D'----E'---m'----H' <-- topic\n \\ |\n F'----G'---/\n\nExample 3\nIn the above examples, both the merge commit and its two parents are replayed commits, rather than the original parents that the original merge commit have. However, in other rebases a replayed merge commit can end up with parents that were already in the commit graph before the merge.\nFor example, consider:\n B--C---D <-- master\n / \\ \nA---E--m------F <-- topic\n\nIf we rebase topic onto master (preserving merges), then the commits to replay will be\n\npick merge commit m\npick F\n\nThe rewritten commit graph will look like so:\n B--C--D <-- master\n / \\ \n A-----E---m'--F'; <-- topic\n\nHere replayed merge commit m' gets parents that pre-existed in the commit graph, namely D (the HEAD of master) and E (one of the parents of the original merge commit m).\nExample 4\nMerge-preserving rebase can get confused in certain \"empty commit\" cases. At least this is true only some older versions of git (e.g. 1.7.8.)\nTake this commit graph:\n A--------B-----C-----m2---D <-- master\n \\ \\ /\n E--- F--\\--G----/\n \\ \\\n ---m1--H <--topic\n\nNote that both commit m1 and m2 should have incorporated all the changes from B and F.\nIf we try to do git rebase --preserve-merges of H (topic) onto D (master), then the following commits are chosen for replay:\n\npick m1\npick H\n\nNote that the changes (B, F) united in m1 should already be incorporated into D. (Those changes should already be incorporated into m2, because m2 merges together the children of B and F.) Therefore, conceptually, replaying m1 on top of D should probably either be a no-op or create an empty commit (i.e. one where the diff between successive revisions is empty).\nInstead, however, git may reject the attempt to replay m1 on top of D. You can get an error like so:\nerror: Commit 90caf85 is a merge but no -m option was given.\nfatal: cherry-pick failed\n\nIt looks like one forgot to pass a flag to git, but the underlying problem is that git dislikes creating empty commits." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Changed GitHub password, no longer able to push back to the remote\n\nAfter I changed my GitHub password, I am unable to push to the remote:\n$ git push origin master\nremote: Invalid username or password.\n\nIs there only re clone the repository?" }, { "role": "assistant", "content": "If you had your remote's password changed only, not the username, then try the following command to check remote's info:-\n\ngit remote show origin\n\nThis will ask for your password for the given git user, fill that in correctly, and now try:-\n\ngit pull\n\nor,\n\ngit push\n\nIt should work unless you have to change other things like username or remote URL, you can take a look at the following Git documentation:-\n\nhttps://help.github.com/articles/setting-your-username-in-git/\nhttps://help.github.com/articles/changing-a-remote-s-url/" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-grep - Print lines matching a pattern <tree>…​" }, { "role": "assistant", "content": "Instead of searching tracked files in the working tree, search\nblobs in the given trees." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options man.<tool>.path" }, { "role": "assistant", "content": "Override the path for the given tool that may be used to\ndisplay help in the man format. See git-help ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git stash apply and drop\nIs there a git command that both applies the stash and removes it?\nThis as one command: \ngit stash apply\ngit stash drop" }, { "role": "assistant", "content": "You want git stash pop!\npop [--index] [-q|--quiet] [<stash>]\n Remove a single stashed state from the stash list and apply it on\n top of the current working tree state, i.e., do the inverse\n operation of git stash save. The working directory must match the\n index." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --textconv --no-textconv" }, { "role": "assistant", "content": "Allow (or disallow) external text conversion filters to be run\nwhen comparing binary files. See gitattributes for\ndetails. Because textconv filters are typically a one-way\nconversion, the resulting diff is suitable for human\nconsumption, but cannot be applied. For this reason, textconv\nfilters are enabled by default only for git-diff and git-log , but not for git-format-patch or\ndiff plumbing commands." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-apply - Apply a patch to files and/or to the index --directory=<root>" }, { "role": "assistant", "content": "Prepend <root> to all filenames. If a \"-p\" argument was also passed,\nit is applied before prepending the new root. For example, a patch that talks about updating a/git-gui.sh to b/git-gui.sh can be applied to the file in the working tree modules/git-gui/git-gui.sh by\nrunning git apply --directory=modules/git-gui ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub: Is it possible to collaborate with someone on a private gist?\nI have a private gist. If I send the URL to a friend he can view it, but cannot edit it, unless he forks it.\nIs there a way to edit it directly without forking it?" }, { "role": "assistant", "content": "No. Your friend should fork the repo, and make her changes there.\nYou can then merge in your friend’s commits by:\n\nClone your gist repo locally\nAdd your friend’s fork as a remote\n\ne.g. if your friend is named Cindy: git remote add-url cindy https://gist.github.com/cindy/df03bdacaef75a80f310\n\nFetch your friend’s commits: git fetch cindy/master\nMerge your friend’s changes into your repo: git merge cindy/master\nPush the changes back to GitHub: git push origin/master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options gpg.ssh.defaultKeyCommand" }, { "role": "assistant", "content": "This command will be run when user.signingkey is not set and a ssh\nsignature is requested. On successful exit a valid ssh public key\nprefixed with key:: is expected in the first line of its output.\nThis allows for a script doing a dynamic lookup of the correct public\nkey when it is impractical to statically configure user.signingKey .\nFor example when keys or SSH Certificates are rotated frequently or\nselection of the right key depends on external factors unknown to git." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --date-order" }, { "role": "assistant", "content": "Show no parents before all of its children are shown, but\notherwise show commits in the commit timestamp order." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab-runner + Docker + Windows - Invalid volume specification\n\nI'm trying to run my Gitlab CI locally using Gitlab-runner and docker before committing to make sure they work okay. But I'm having some strange issues!\nUnfortunately I have no choice but to use windows (I've had success in the past on Linux).\nEvery time I run a job in powershell:\nC:/Gitlab-runner/gitlab-runner exec docker npm\nI get an error:\nJob failed (system failure): Error response from daemon: invalid volume specification: '/host_mnt/c/builds/project-0/Users/Lewsmith/api:C:/Users/Lewsmith/api:ro' (executor_docker.go:921:0s)\nI've tried setting docker volumes (nemerous combinations) and builds-dir:\nC:/Gitlab-runner/gitlab-runner exec docker --builds-dir /builds --docker-privileged --docker-volumes \"/builds:C:/Gitlab-runner/builds\" npm\nThat fails with Error response from daemon: invalid mode: /Gitlab-runner/builds because of the colon after the C..\nCan anyone point me in the right direction as I'm stumped? \nUsing gitlab-runner version 11.5.0" }, { "role": "assistant", "content": "Docker is not fully supported by GitLab Runner on Windows yet.\nThe workaround is to use Windows Subsystem for Linux and install gitlab-runner there:\ncurl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash\nsudo apt-get install gitlab-runner\ngitlab-runner exec docker build" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Stage only deleted files with git add\nI have run git status and see several modified files and several deleted files.\nIs it possible to stage only deleted or only modified files?" }, { "role": "assistant", "content": "If you have a mix of modified and deleted files and only want to stage deleted files to the index, you can use git ls-files as a filter.\ngit ls-files --deleted | xargs git add\n\nIf you only want this to apply to part of the file tree, give one or more subdirectories as arguments to ls-files:\ngit ls-files --deleted -- lib/foo | xargs git add\n\nTo do the same for only modified files, use the --modified (-m) option instead of --deleted (-d)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-notes - Add or inspect object notes -c <object> --reedit-message=<object>" }, { "role": "assistant", "content": "Like -C , but with -c the editor is invoked, so that\nthe user can further edit the note message." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git push requires username and password\n\nI cloned a Git repository from my GitHub account to my PC.\nI want to work with both my PC and laptop, but with one GitHub account.\nWhen I try to push to or pull from GitHub using my PC, it requires a username and password, but not when I'm using the laptop!\nI don't want to type my username and password every time I interact with origin. What am I missing here?" }, { "role": "assistant", "content": "A common cause is cloning using the default (HTTPS) instead of SSH. You can correct this by going to your repository, clicking \"Clone or download\", then clicking the \"Use SSH\" button above the URL field and updating the URL of your origin remote like this:\ngit remote set-url origin [email protected]:username/repo.git\n\nYou can check if you have added the remote as HTTPS or SSH using:\ngit remote -v\n\nThis is documented at GitHub: Switching remote URLs from HTTPS to SSH." } ]
[ { "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 --ignore-revs-file <file>" }, { "role": "assistant", "content": "Ignore revisions listed in file , which must be in the same format as an fsck.skipList . This option may be repeated, and these files will be\nprocessed after any files specified with the blame.ignoreRevsFile config\noption. An empty file name, \"\" , will clear the list of revs from\npreviously processed files." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub commits aren't recorded in the 'Your Contributions` calendar\n\nI've been making continuous commits to my GitHub repos from my Linux shell and they show up nicely on the website just as they should. The only problem is that \"Your Contributions\" section doesn't show any recent activity. I have one green square from some day in November which I don't know how I got but all the other contributions don't show up in the calendar (but again, they do show up in their repos).\nWhat am I missing here?\nMy github site" }, { "role": "assistant", "content": "For me this problem was caused by me committing from my work computer where I was using a different email in my gitconfig. Adding my work email address to my github account didn't make the past commits show up in the summary, but new commits are now showing up as they should.\nYou can find the email address you are using for a repository with git config user.email." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options gui.trustmtime" }, { "role": "assistant", "content": "Determines if git-gui should trust the file modification\ntimestamp or not. By default the timestamps are not trusted." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options --get-colorbool <name> [<stdout-is-tty>]" }, { "role": "assistant", "content": "Find the color setting for <name> (e.g. color.diff ) and output\n\"true\" or \"false\". <stdout-is-tty> should be either \"true\" or\n\"false\", and is taken into account when configuration says\n\"auto\". If <stdout-is-tty> is missing, then checks the standard\noutput of the command itself, and exits with status 0 if color\nis to be used, or exits with status 1 otherwise.\nWhen the color setting for name is undefined, the command uses color.ui as fallback." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-send-email - Send a collection of patches as emails --in-reply-to=<identifier>" }, { "role": "assistant", "content": "Make the first mail (or all the mails with --no-thread ) appear as a\nreply to the given Message-ID, which avoids breaking threads to\nprovide a new patch series.\nThe second and subsequent emails will be sent as replies according to\nthe --[no-]chain-reply-to setting. So for example when --thread and --no-chain-reply-to are specified, the\nsecond and subsequent patches will be replies to the first one like in the\nillustration below where [PATCH v2 0/3] is in reply to [PATCH 0/2] : [PATCH 0/2] Here is what I did...\n [PATCH 1/2] Clean up and tests\n [PATCH 2/2] Implementation\n [PATCH v2 0/3] Here is a reroll\n [PATCH v2 1/3] Clean up\n [PATCH v2 2/3] New tests\n [PATCH v2 3/3] Implementation Only necessary if --compose is also set. If --compose\nis not set, this will be prompted for." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options receive.hideRefs" }, { "role": "assistant", "content": "This variable is the same as transfer.hideRefs , but applies\nonly to receive-pack (and so affects pushes, but not fetches).\nAn attempt to update or delete a hidden ref by git push is\nrejected." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.<driver>.wordRegex" }, { "role": "assistant", "content": "The regular expression that the diff driver should use to\nsplit words in a line. See gitattributes for\ndetails." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git commit against tag with no branch\nIf I check out a tagged version of my source code without creating a branch, Git indicates that I'm not associated with any branch at all. It's happy to let me make changes and check them in though. Where do those changes go? If I switch back to 'master' they disappear (overwritten by what was in master) and I can't seem to find them again. What gives? If Git lets me commit changes against what's essentially an anonymous branch, surely I can get them back?" }, { "role": "assistant", "content": "Because your commit isn't on any branch, you can't see it in the working directory unless you checkout that specific commit, using its SHA1. You can find the commit by looking at the reflog which tracks changes in what you have checked out from the repo. If your tag was XXX you'll see something like:\n$ git reflog\n7a30fd7... HEAD@{0}: checkout: moving from master to XXX\nddf751d... HEAD@{1}: checkout: moving from 96c3b0300ccf16b64efc260c21c85ba9030f2e3a to master\n96c3b03... HEAD@{2}: commit: example commit on tag XXX, not on any branch\n7a30fd7... HEAD@{3}: checkout: moving from master to XXX\n\nThat tells you the SHA1 that you would have to checkout in order to see your commit in the working directory. \n$ git checkout 96c3b03\nNote: moving to \"96c3b03\" which isn't a local branch\nIf you want to create a new branch from this checkout, you may do so\n(now or later) by using -b with the checkout command again. Example:\n git checkout -b <new_branch_name>\nHEAD is now at 96c3b03... example commit on tag XXX, not on any branch\n$ git checkout -b newbranch\n$ git branch #lists all branches\n feature1\n master\n * newbranch\n\nThis all seemed a little weird to me at first, until I realized that git checkout places all the project files as of a particular commit into my file system (working directory). In effect, the working directory acts as a browser on the local Git repository. So your changes haven't been overwritten in the repository, they're just not being shown in your working directory when you've checked out the master." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Delete local Git branches after deleting them on the remote repo\nI want to have my local and remote repositories always in sync in terms of branches.\nAfter a Pull Request review on GitHub, I merge and remove my branch there (remote).\nHow could I fetch this information in my local repository and get Git to remove my local version of the branch as well?" }, { "role": "assistant", "content": "The quick way\ngit branch --merged | grep -v \"\\*\" | xargs -n 1 git branch -d\n\nNB: if you're not on master, this has the potential to delete the branch. Keep reading for the \"better way\".\nMake sure we keep master\nYou can ensure that master, or any other branch for that matter, doesn't get removed by greping for more. In that case you would go:\ngit branch --merged | grep -v \"\\*\" | grep -v \"YOUR_BRANCH_TO_KEEP\" | xargs -n 1 git branch -d\n\nSo if we wanted to keep master, develop and staging for instance, we would go:\ngit branch --merged | grep -v \"\\*\" | grep -Ev \"(\\*|master|develop|staging)\" | xargs -n 1 git branch -d\n\nMake this an alias\nSince it's a bit long, you might want to add an alias to your .zshrc or .bashrc. Mine is called gbpurge (for git branches purge):\nalias gbpurge='git branch --merged | grep -Ev \"(\\*|master|develop|staging)\" | xargs -n 1 git branch -d'\n\nThen reload your .bashrc or .zshrc:\n. ~/.bashrc\n\nor\n. ~/.zshrc" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %ci" }, { "role": "assistant", "content": "committer date, ISO 8601-like format" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to `git pull` while ignoring local changes?\nIs there a way to do a git pull that ignores any local file changes without blowing the directory away and having to perform a git clone?" }, { "role": "assistant", "content": "If you mean you want the pull to overwrite local changes, doing the merge as if the working tree were clean, well, clean the working tree:\ngit reset --hard\ngit pull\n\nIf there are untracked local files you could use git clean to remove them.\n\ngit clean -f to remove untracked files\n-df to remove untracked files and directories\n-xdf to remove untracked or ignored files or directories\n\nIf on the other hand you want to keep the local modifications somehow, you'd use stash to hide them away before pulling, then reapply them afterwards:\ngit stash\ngit pull\ngit stash pop\n\nI don't think it makes any sense to literally ignore the changes, though - half of pull is merge, and it needs to merge the committed versions of content with the versions it fetched." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-send-email" }, { "role": "assistant", "content": "Send a collection of patches as emails" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects %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 could I use git bisect to find the first GOOD commit?\nI have the following problem:\n\nthe version at master works fine\nthe version of the last tag before master (say last) has a bug\na colleague needs a patch for his last revision for that certain bug\n\nOkay. Let's ask our friend git bisect for the revision that fixed the bug:\ngit bisect start\ngit bisect bad last\ngit bisect good master\n\nBut that's not going to work:\n\nSome good revs are not ancestor of the bad rev.\n git bisect cannot work properly in this case.\n Maybe you mistake good and bad revs?\n\nAny hints to overcome this? Did I miss something in the docs?" }, { "role": "assistant", "content": "As of git 2.7, you can use the arguments --term-old and --term-new.\nFor instance, you can identify a problem-fixing commit thus:\ngit bisect start --term-new=fixed --term-old=unfixed\ngit bisect fixed master\ngit bisect unfixed $some-old-sha1\n\nAs you test, say git bisect fixed or git bisect unfixed as appropriate.\nOld answer, for versions of git prior to 2.7\nInstead of temporarily training yourself to think that bad means good and good means bad, why not create some aliases?\nIn ~/.gitconfig add the following:\n[alias]\n bisect-fixed = bisect bad\n bisect-unfixed = bisect good\n\nYou can start identifying a problem-fixing commit thus:\n$ git bisect start\n$ git bisect-fixed master\n$ git bisect-unfixed $some-old-sha1\n\nAs you test, say git bisect-fixed or git bisect-unfixed as appropriate." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-symbolic-ref - Read, modify and delete symbolic refs -d --delete" }, { "role": "assistant", "content": "Delete the symbolic ref <name>." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker" }, { "role": "assistant", "content": "SYNOPSIS git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\n [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n [-p|--paginate|-P|--no-pager] [--no-replace-objects] [--bare]\n [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n [--config-env=<name>=<envvar>] <command> [<args>]" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %P" }, { "role": "assistant", "content": "parent hashes" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitrevisions - Specifying revisions and ranges for Git" }, { "role": "assistant", "content": "SYNOPSIS gitrevisions" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-cvsexportcommit" }, { "role": "assistant", "content": "Export a single commit to a CVS checkout" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.mnemonicPrefix" }, { "role": "assistant", "content": "If set, git diff uses a prefix pair that is different from the\nstandard \"a/\" and \"b/\" depending on what is being compared. When\nthis configuration is in effect, reverse diff output also swaps\nthe order of the prefixes: git diff compares the (i)ndex and the (w)ork tree; git diff HEAD compares a (c)ommit and the (w)ork tree; git diff --cached compares a (c)ommit and the (i)ndex; git diff HEAD:file1 file2 compares an (o)bject and a (w)ork tree entity; git diff --no-index a b compares two non-git things (1) and (2)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git rebase" }, { "role": "assistant", "content": "This fetches revisions from the SVN parent of the current HEAD\nand rebases the current (uncommitted to SVN) work against it. This works similarly to svn update or git pull except that\nit preserves linear history with git rebase instead of git merge for ease of dcommitting with git svn . This accepts all options that git svn fetch and git rebase accept. However, --fetch-all only fetches from the current\n[svn-remote], and not all [svn-remote] definitions. Like git rebase ; this requires that the working tree be clean\nand have no uncommitted changes. This automatically updates the rev_map if needed (see $GIT_DIR/svn/**/.rev_map.* in the FILES section below for details). -l --local Do not fetch remotely; only run git rebase against the\nlast fetched commit from the upstream SVN." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Partially stage files with Visual Studio\nIs there any way to just stage pieces of code in a file instead of the whole file?\nJust wondering if this is possible.\nUsing Visual Studio 2015, TFS 2015 (Git)." }, { "role": "assistant", "content": "2022\nThis has shipped with Visual Studio 17.3.\n\nVisual Studio 2022 has recently introduced staging lines and chunks!\nSee:\nLine-staging (interactive staging)\nLine-staging support, a.k.a. interactive staging is one of our most popular Git suggestion tickets. Line-staging can be helpful when you need to split changes across different commits. This preview includes few of the Line-staging features that we are still working on enhancing. The easiest way to enable this early version of line-staging support is to use CTRL+Q, type “preview” and open the preview features pane. Scroll to “Enable line-staging support” and toggle the checkbox.\n\nNote: line-staging is still a preview feature\nThis functionality is still a preview feature, which means we are working hard to add more support in the coming releases. In the meantime, we’re depending on your feedback, the community, to build what you need\nOnce you switch on the line-staging preview flag and restart your Visual Studio, you can start staging chunks of your changes by clicking on files in the Git Changes window. Then hover over the sections of code you would like to stage and click Stage Change.\n\nTip: use line-staging with your preferred diff layout\nLine-staging is supported on both inline and side-by-side diff modes:\nImage staging a chunk in line view\nThis early version of line-staging support has a number of known issues and limitations.\n2019 and below\nNo, neither Visual Studio 2015, 2017, 2019 nor 2022 pre 17.3 support staging hunks (partial files). You'll need to use another client to stage these partial changes.\nStaging hunks is a client feature, any client that supports it can be used to stage a hunk. The command line or a 3rd party client like Tower or SourceTree will do. Once staged, committing the staged changes can be done using Visual Studio or any other client that can commit changes (that would be pretty much every git client out there).\nOnce a hunk is staged, Visual Studio will show the file as \"Staged\" and also as \"Unstaged\". The staged file contains the hunk you staged. The unstaged file contains the hunks you haven't staged. When you commit the staged hunk(s) will be committed. You can repeat this cycle as many times as you want." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --ignore-cr-at-eol" }, { "role": "assistant", "content": "Ignore carriage-return at the end of line when doing a comparison." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I understand the role of \"/bin/true\" command in \"docker run ...\" command?\n\nI am following this document to install gitlab docker image, and get confused with the command: \ndocker run --name gitlab_data genezys/gitlab:7.5.2 /bin/true\n\nI know \"/bin/true\" command just returns a success status code, but how can I understand the role of /bin/true in this docker run ... command?" }, { "role": "assistant", "content": "Running and thus creating a new container even if it terminates still keeps the resulting container image and metadata lying around which can still be linked to.\nSo when you run docker run ... /bin/true you are essentially creating a new container for storage purposes and running the simplest thing you can.\nIn Docker 1.5 was introduced the docker create command so I believe you can now \"create\" containers without confusingly running something like /bin/true\nSee: docker create\nThis is new method of managing data volume containers is also clearly documented in the section Creating and mounting a Data Volume Container" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is there a way to use a Mercurial repository as Git submodule?\nI been happily using submodules to track all the libraries my project depends from. \nThe thing is I'm using a library called core-plot that only has a public mercurial repository. \nI can probably mirror it in a readonly Git repository, but is this the best option I got? \nI had seen there is modules in Mercurial to track things in Git. Someone know if the other way around exists?" }, { "role": "assistant", "content": "Using git-hg. \nFirst, make sure there is a (non-Mercurial) git submodule under your main repository. If you don't have other submodules yet, just create a dummy submodule for some library other than core-plot, for instance:\nmain-repo $ git submodule add https://repo.url.com/repo.git repo\n\nSecond, clone the core-plot library into some directory.\nmain-repo $ git-hg clone https://code.google.com/p/core-plot/ core-plot\n\nAdd the new repo to the submodule list.\nmain-repo $ git submodule add ./core-plot core-plot\nmain-repo $ git commit -am \"added core-plot submodule\"\n\nFrom now on, any clone from this repo will pull both repositories. (After submodule init and update).\nSome problems I found out so far are:\n\nIf you push to a bare, then the repo link and the directory will be created in the bare, but the repository will not be cloned inside it and others pulling from that bare will not be able to get the core-plot lib.\nIf core-plot needs to be updated the one with the git-hg will have to git-hg pull.\n\nThe converse question git submodule from Hg repo? is also asked on StackOverflow. The best answer mentions projects hg-git and git-hg. Another related converse question is, How to deal with Git submodules on a repo that is converted to Mercurial." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can not push changes after using git reset --hard\nI had a mistake and commit some changes to git which I should not have committed.\nAfter I made the commit, I pushed my changes. \nI then used the following commands to try and reset my changes.\n git reset --hard head\n\nNow I want to push this 'reset' to the remote repository with this command:\ngit push MyBranch\n\nBut I am getting this error:\nremote: error: denying non-fast-forward refs/heads/branch (you should pull first)\n\nI tried to use this command without any success: \ngit push -f \"origin\" \n\nAny idea what I can do?" }, { "role": "assistant", "content": "git push -f origin myBranch \n\nshould work (provided you are aware this can be dangerous if MyBranch was already fetched by others in their own repo)\nSince 2012, you also have:\n\ngit push --force-with-lease (Git 1.8.5+ Q3 2013) which is safer, and\ngit push --force-if-includes (Git 2.30+, Q1 2021), which attempts to ensure that what is being force-pushed was created after examining the commit at the tip of the remote ref that is about to be force-replaced.\n\nNote: if your remote repo ('origin') has its config set with\nreceive.denyNonFastForwards true\n\nit will deny any non fast-forward push (even when forced).\nSee \"Is there a way to configure git repository to reject 'git push --force'?\".\n\nThe OP user654019 reports\n\nI managed to solve the problem this time by setting denyNonFastForwards to false and using -f to force the push\n\nIf the OP didn't have access to the repo, he/she would have to:\n\nreset the local HEAD to its original position (see \"Recover from git reset --hard?\"):\ngit reset HEAD@{1}\nmake a new commit which cancel your merge, as described in the ProGit book, with git revert:\ngit revert -m 1 HEAD~ (in your case)\n\nBy example:\n$ git revert -m 1 [sha_of_C8]\nFinished one revert.\n[master 88edd6d] Revert \"Merge branch 'jk/post-checkout'\"\n 1 files changed, 0 insertions(+), 2 deletions(-)\n\n\nA complete discussion on how to revert a merge can be found here.\nThe idea remains to generate only new commits, including one reverting the changes introduced by the merge commit.\nYou then can push that new commit, as a fast-forward change." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Using Git on Windows, behind an HTTP proxy, without storing proxy password on disk\nI'm using Git on Windows, on a corporate network where I'm behind an HTTP proxy with Basic authentication. Outbound SSH doesn't work, so I have to use HTTPS through the proxy.\nI'm aware of how to use git config http.proxy to configure the settings as http://[username]:[password]@[proxy]:[port].\nHowever, particularly as this is a shared machine, I'd rather not store my password in my .gitconfig. Additionally, changing my .gitconfig using the git config command leaves my password in my bash history, so even if I remember to clear my .gitconfig at the end of the session, I'll almost certainly forget to clear my history as well.\nI've tried setting http.proxy without a password, in the vain hope that I'd get a prompt asking me for my password when I try to push/pull, but I only get a 407 Proxy Authentication Required. All the information I've found online seems to either ignore the issues with having the password saved in plaintext in .gitconfig, or deals with NTLM proxies.\nI'm quite happy to type my proxy details every time I need to connect - the best solution I can see at the moment is writing a wrapper script that will prompt for my password and set that as an environment variable when calling git proper. Is this a decent solution, and are there any security implications to setting an environment variable for a single call in a script? Preferably, are there any built-in settings or existing tools that I can use for this?" }, { "role": "assistant", "content": "since git 2.8.0\ngit config --global http.proxy http://[user]@proxyhost:port\ngit config --global credential.helper wincred" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to get SHA of the latest commit from remote git repository?\nDoes anyone know how to get the latest SHA of a given branch from outside a git repository?\nIf you are inside a git repository, you can do:\ngit log origin/branch_X | head -1\n\nHowever, I am not inside a git repository, and I would like to avoid having to clone a repository just to get the latest SHA of a tag/branch. Is there a clever way of doing this?" }, { "role": "assistant", "content": "Use rev-parse\ngit rev-parse origin/master # to get the latest commit on the remote\n\ngit rev-parse HEAD # to get the latest commit on the local" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters <rev>^! , e.g. HEAD^!" }, { "role": "assistant", "content": "A suffix ^ followed by an exclamation mark is the same\nas giving commit <rev> and all its parents prefixed with ^ to exclude them (and their ancestors)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options http.extraHeader" }, { "role": "assistant", "content": "Pass an additional HTTP header when communicating with a server. If\nmore than one such entry exists, all of them are added as extra\nheaders. To allow overriding the settings inherited from the system\nconfig, an empty value will reset the extra headers to the empty list." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker --man-path" }, { "role": "assistant", "content": "Print the manpath (see man(1) ) for the man pages for\nthis version of Git and exit." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I configure Git to trust certificates from the Windows Certificate Store?\nCurrently I have the following entry in my .gitconfig in my user directory.\n...\n[http]\n sslCAInfo=C:\\\\Users\\\\julian.lettner\\\\.ssh\\\\git-test.pem\n...\n\nThis sets the certificate to use when interacting with the git server (required by my company's git server).\nBut now I cannot clone other repositories (for example a public repository on GitHub), because the client always uses the configured certificate which gets rejected by other servers.\nHow can I circumvent this certification issue? Can I configure Git to use the Windows Certificate Store to authenticate?" }, { "role": "assistant", "content": "Beginning with Git for Windows 2.14, you can now configure Git to use SChannel, the built-in Windows networking layer. This means that it will use the Windows certificate storage mechanism and you do not need to explicitly configure the curl CA storage mechanism.\nFrom the Git for Windows 2.14 release notes:\n\nIt is now possible to switch between Secure Channel and OpenSSL for Git's HTTPS transport by setting the http.sslBackend config variable to \"openssl\" or \"schannel\"; This is now also the method used by the installer (rather than copying libcurl-4.dll files around).\n\nYou can choose the new SChannel mechanism during the installation of Git for Windows 2.14. You can also update an existing installation to use SChannel by running:\ngit config --global http.sslBackend schannel\n\nOnce you have configured this, Git will use the Windows certificate store and should not require (and, in fact, should ignore) the http.sslCAInfo configuration setting." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Command to open file with git\nI have sublime text as the default editor in git (and it works)\ngit config --edit opens the config file in sublime text (Awesome)\n\nMy Question:\nWhat is the command to open say index.html or style.css from inside the project directory?\nBasically when I'm working on a project I would like to be able to open a file from git. How to do this. Every tutorial seems to go over merge, clone, commit yes we all know these, how to do this simple command. Or is this not possible from within git?\n\nwindows 7\nmsysgit version 1.8.0\n\nI understand git is not a launcher and is strictly for version control. Just want to know what options I have with the tools at hand.\nThe question came up while i was commiting a project and realized i needed to make a small edit to a css file i had closed already and was wondering if i could open to edit the file from within git since i had it up. \nSeems this is not possible (not the end of the world) I just like to understand all of my options with the tools i use is all" }, { "role": "assistant", "content": "Git has nothing to do with how you open/edit files in your project. Configuring the editor in git is only so that git internal things that require an editor (commit messages for example) can use your preferred editor.\nIf you just want to open files from the command line (cmd.exe) as if they were double clicked in the windows explorer, I think you can use start <filename>." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I accept all current changes in VSCode at once?\nI tried to merge one file with another file, but there are many HEADs with Accept Current Change | Accept Incoming Change | ...\nIs there a way to accept all current changes at once?" }, { "role": "assistant", "content": "It's very easy just go to vs code and press\nCtrl+shift+p (command palette) or go to view and open command palette manually and type \"merge\" in your command palette, now you can see the Accept all current changes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Merging between forks in GitHub\nI forked a GitHub repository. Then I pushed some changes to my fork. Then the original repository merged my changes and some others. Now, I want to merge those changes I'm missing. I tried a simple pull followed by push, but this yield my commits in duplicate. What's the best way to do it?" }, { "role": "assistant", "content": "You probably have a \"remote\" for each repository. You need to pull from one remote and push to the other.\nIf you originally cloned from your fork, that remote will be called \"origin\". If you haven't added it already, you'll need to add the other repository as another remote:\ngit remote add <shortname> git://github.com/<ownerName>/repo.git\n\nAfter that's all set up, you should indeed be able to (github changed default branch from master to main, change as necessary)\ngit pull <shortname> master\ngit push origin\n\nRemember, git pull is nothing more than a macro that does git fetch and git merge, in that order. You just need to fetch the list of commits from the other repository and then merge his branch into your tree. Merging should do the right thing with your commits on both branches.\nGitHub, in all its perpetual awesomeness, gives you a shortcut, of course. There's a \"fast-forward\" button on your fork of the repository that you can use to catch your fork up if you're entirely merged into the other side." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Undoing a git pull --rebase\nHey I'm new to git and I need to undo a pull, can anyone help?!? So what I've done is...\n\ngit commit\ngit stash\ngit pull --rebase\ngit stash pop\n\nthis created a bunch of conflicts and went a bit wrong. Now doing 'git stash list' reveals that my stash is still there. Is it possible to revert my repo back to the point just after doing git commit. So effectively my repo only contains only changes I have made and nothing new from the server?" }, { "role": "assistant", "content": "Actually, to make this easier Git keeps a reference named ORIG_HEAD that points where you were before the rebase. So, it's as easy as:\ngit reset --hard ORIG_HEAD" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --ws-error-highlight=<kind>" }, { "role": "assistant", "content": "Highlight whitespace errors in the context , old or new lines of the diff. Multiple values are separated by comma, none resets previous values, default reset the list to new and all is a shorthand for old,new,context . When\nthis option is not given, and the configuration variable diff.wsErrorHighlight is not set, only whitespace errors in new lines are highlighted. The whitespace errors are colored\nwith color.diff.whitespace ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options format.to format.cc" }, { "role": "assistant", "content": "Additional recipients to include in a patch to be submitted\nby mail. See the --to and --cc options in git-format-patch ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Create a GitHub webhook for when a pull request is accepted & merged to master\n\nI have a webhook that currently fires on push to any branch. This triggers the webhook far too frequently. Ideally, the webhook would only fire when a pull request is merged into master. I don't see that as an option, though:\n\nIs there a way to get additional webhook options or to customize the webhook somehow?" }, { "role": "assistant", "content": "So, you can't customize the conditions of the trigger, but as LeGec mentions you can customize your code to only trigger when the Pull Request is merged.\nTo do that, make sure your script responds to the PullRequestEvent. The conditions to test are:\n\n\"action\" is \"closed\"\n\"merged\" (inside of \"pull_request\") is true\n\nThis way your script can ignore all the pings it receives when any other activity occurs on the Pull Request (including closing without merging)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to rebase after git-subtree add?\nI'm trying to learn the new git-subtree command which was added in Git 1.7.11. I seem to lose ability to rebase after I add a subtree. I have the primary repository with README file and a library repository which also has a README file. I add it to lib directory with subtree add:\n$ git subtree add -P lib/mylib myliborigin master\n\nThis works fine, but now the history looks like this:\n* 22c1fe6 (HEAD, master) Merge commit 'b6e698d9f4985825efa06dfdd7bba8d2930cd40e' as 'lib/mylib' - \n|\\ \n| * b6e698d Squashed 'lib/mylib/' content from commit d7dbd3d\n* b99d55b Add readme\n* 020e372 Initial\n\nNow when I want to rebase my repo against origin/master and it fails because the squash commit is applied directly against its parent commit which does not apply, because it is applied to the root of the repo and not the prefix I gave it to it when adding the subtree.\nThe reason for this is pretty clear if I look at the squash commit. There is no information about the prefix. It is just the original mylib commits squashed together. Only the next merge commit knows anything about it, but rebase does not take it to account here.\nAre there any workarounds (besides never rebasing over the subtree commits)?" }, { "role": "assistant", "content": "This works in simple cases:\ngit rebase --preserve-merges master\n\nThanks to @Techlive Zheng in the comments.\n\nYou may see\nfatal: refusing to merge unrelated histories\nError redoing merge a95986e...\n\nWhich means that git failed to automatically apply your subtree. This puts you in the situation @ericpeters described in his answer. Solution:\nRe-add your subtree (use the same command you originally used):\ngit subtree add -P lib lib-origin master\n\nContinue the rebase:\ngit rebase --continue\n\nAnd you're all set!\n\nIf you're wondering if it worked successfully, you can compare with your original version after rebasing to make sure you didn't change anything:\ngit diff <ref-before-rebase> <ref-after-rebase> -- .\n\n(the -- . at the end instructs git to only diff the files in your current directory).\n\nIf all else fails and you don't care about preserving the commits themselves, you can simply git cherry-pick the original subtree commit.\nThe commit message will look something like Add 'lib/' from commit '9767e6...' -- that's the one you want." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gittutorial - A tutorial introduction to Git" }, { "role": "assistant", "content": "NAME gittutorial - A tutorial introduction to Git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-notes - Add or inspect object notes notes.<name>.mergeStrategy" }, { "role": "assistant", "content": "Which merge strategy to choose when doing a notes merge into\nrefs/notes/<name>. This overrides the more general\n\"notes.mergeStrategy\". See the \"NOTES MERGE STRATEGIES\" section in git-notes for more information on the available strategies." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What does tree-ish mean in Git?\nI'm very confused about how to use git archive.\nI have a git repository with folder Foo, Bar and Baz at the top level. I need to export folder Foo in a SVN-ish sort of way for quick test deployment.\nI learned that I could use git-archive in an SVN-ish export sort of way.\nBut here's the thing, The following works fine:\ngit archive master | tar -x -C ~/destination\n\nit results in Foo, Bar, Baz folders in the destination folder.\nHowever, the following will error out with fatal not a valid object name:\ngit archive master/foo | tar -x -C ~/destination\n\nThe Documentation\nLooking as the synopsis for the git archive program I see that it can take a <tree-ish> [path] as a parameter (synopsis summarized to relevant parts):\ngit archive <tree-ish> [path...]\n\nIf master/foo is not tree-ish, then what is?" }, { "role": "assistant", "content": "The Short Answer (TL;DR)\n\"Tree-ish\" is a term that refers to any identifier (as specified in the Git\nrevisions documentation) that ultimately leads to a (sub)directory\ntree (Git refers to directories as \"trees\" and \"tree objects\").\nIn the original poster's case, foo is a directory that he wants to\nspecify. The correct way to specify a (sub)directory in Git is to use this\n\"tree-ish\" syntax (item #15 from the Git revisions documentation):\n\n<rev>:<path>, e.g. HEAD:README, :README, master:./README\nA suffix : followed by a path names the blob or tree at the given path in\n the tree-ish object named by the part before the colon.\n\nSo, in other words, master:foo is the correct syntax, not master/foo.\nOther \"Tree-ish\" (Plus Commit-ish)\nHere's a complete list of commit-ish and tree-ish identifiers (from the Git\nrevisions documentation, thanks to LopSae for pointing it\nout):\n----------------------------------------------------------------------\n| Commit-ish/Tree-ish | Examples\n----------------------------------------------------------------------\n| 1. <sha1> | dae86e1950b1277e545cee180551750029cfe735\n| 2. <describeOutput> | v1.7.4.2-679-g3bee7fb\n| 3. <refname> | master, heads/master, refs/heads/master\n| 4. <refname>@{<date>} | master@{yesterday}, HEAD@{5 minutes ago}\n| 5. <refname>@{<n>} | master@{1}\n| 6. @{<n>} | @{1}\n| 7. @{-<n>} | @{-1}\n| 8. <refname>@{upstream} | master@{upstream}, @{u}\n| 9. <rev>^ | HEAD^, v1.5.1^0\n| 10. <rev>~<n> | master~3\n| 11. <rev>^{<type>} | v0.99.8^{commit}\n| 12. <rev>^{} | v0.99.8^{}\n| 13. <rev>^{/<text>} | HEAD^{/fix nasty bug}\n| 14. :/<text> | :/fix nasty bug\n----------------------------------------------------------------------\n| Tree-ish only | Examples\n----------------------------------------------------------------------\n| 15. <rev>:<path> | HEAD:README, :README, master:./README\n----------------------------------------------------------------------\n| Tree-ish? | Examples\n----------------------------------------------------------------------\n| 16. :<n>:<path> | :0:README, :README\n----------------------------------------------------------------------\n\nIdentifiers #1-14 are all \"commit-ish\", because they all lead to commits, but\nbecause commits also point to directory trees, they all ultimately lead to\n(sub)directory tree objects, and can therefore also be used as \"tree-ish\".\n#15 can also be used as tree-ish when it refers to a (sub)directory, but it\ncan also be used to identify specific files. When it refers to files, I'm not\nsure if it's still considered \"tree-ish\", or if acts more like \"blob-ish\" (Git\nrefers to files as \"blobs\").\nThe Long Answer\nAt its lowest levels, Git keeps track of source code using four fundamental\nobjects:\n\nAnnotated tags, which point to commits.\nCommits, which point to the root directory tree of your project.\nTrees, which are directories and subdirectories.\nBlobs, which are files.\n\nEach of these objects has its own sha1 hash ID, since Linus Torvalds designed\nGit like an content- addressable filesystem, i.e. files can be retrieved\nbased on their content (sha1 IDs are generated from file content). The Pro Git\nbook gives this example diagram:\n\nMany Git commands can accept special identifiers for commits and (sub)directory\ntrees:\n\n\"Commit-ish\" are identifiers that ultimately lead to a commit object. For example,\ntag -> commit\n\"Tree-ish\" are identifiers that ultimately lead to tree (i.e. directory) objects.\ntag -> commit -> project-root-directory\n\nBecause commit objects always point to a directory tree object (the root\ndirectory of your project), any identifier that is \"commit-ish\" is, by\ndefinition, also \"tree-ish\". In other words, any identifier that leads to a\ncommit object can also be used to lead to a (sub)directory tree object.\nBut since directory tree objects never point to commits in Git's versioning\nsystem, not every identifier that points to a (sub)directory tree can also be\nused to point to a commit. In other words, the set of \"commit-ish\" identifiers\nis a strict subset of the set of \"tree-ish\" identifiers.\nAs explained in the documentation (thanks to Trebor for helping\nme find it):\n\n<tree>\n\nIndicates a tree object name.\n<commit>\n\nIndicates a commit object name.\n<tree-ish>\n\nIndicates a tree, commit or tag object name. A command that takes a <tree-ish>\n argument ultimately wants to operate on a <tree> object but automatically\n dereferences <commit> and <tag> objects that point at a <tree>.\n<commit-ish>\n\nIndicates a commit or tag object name. A command that takes a <commit-ish>\n argument ultimately wants to operate on a <commit> object but automatically\n dereferences <tag> objects that point at a <commit>.\n\nThe set of tree-ish identifiers that cannot be used as commit-ish are\n\n<rev>:<path>, which leads directly to directory trees, not commit\nobjects. For example, HEAD:subdirectory.\nSha1 identifiers of directory tree objects." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects %ci" }, { "role": "assistant", "content": "committer date, ISO 8601-like format" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %<|( <M> )" }, { "role": "assistant", "content": "make the next placeholder take at least until Mth\ndisplay column, padding spaces on the right if necessary.\nUse negative M values for column positions measured\nfrom the right hand edge of the terminal window." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-notes - Add or inspect object notes notes.displayRef" }, { "role": "assistant", "content": "Which ref (or refs, if a glob or specified more than once), in\naddition to the default set by core.notesRef or GIT_NOTES_REF , to read notes from when showing commit\nmessages with the git log family of commands. This setting can be overridden with the GIT_NOTES_DISPLAY_REF environment variable, which must be a colon separated list of refs or\nglobs. A warning will be issued for refs that do not exist,\nbut a glob that does not match any refs is silently ignored. This setting can be disabled by the --no-notes option to the git\nlog family of commands, or by the --notes=<ref> option accepted by\nthose commands. The effective value of \"core.notesRef\" (possibly overridden by\nGIT_NOTES_REF) is also implicitly added to the list of refs to be\ndisplayed." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-send-email - Send a collection of patches as emails --to-cmd=<command>" }, { "role": "assistant", "content": "Specify a command to execute once per patch file which\nshould generate patch file specific \"To:\" entries.\nOutput of this command must be single email address per line.\nDefault is the value of sendemail.toCmd configuration value." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs log.date" }, { "role": "assistant", "content": "Set the default date-time mode for the log command.\nSetting a value for log.date is similar to using git log 's --date option. See git-log for details. If the format is set to \"auto:foo\" and the pager is in use, format\n\"foo\" will be used for the date format. Otherwise, \"default\" will\nbe used." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --relative[=<path>] --no-relative" }, { "role": "assistant", "content": "When run from a subdirectory of the project, it can be\ntold to exclude changes outside the directory and show\npathnames relative to it with this option. When you are\nnot in a subdirectory (e.g. in a bare repository), you\ncan name which subdirectory to make the output relative\nto by giving a <path> as an argument. --no-relative can be used to countermand both diff.relative config\noption and previous --relative ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_DIR" }, { "role": "assistant", "content": "If the GIT_DIR environment variable is set then it\nspecifies a path to use instead of the default .git for the base of the repository.\nThe --git-dir command-line option also sets this value." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database gitmodulesName" }, { "role": "assistant", "content": "(ERROR) A submodule name is invalid." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git svn - Can I use git and svn at the same time? no need interaction between git and svn\nI am doing a development project.\nThe company is using SVN, so for main commit and checkout should be done via SVN.\nHowever, I don't like SVN and am a git user. Since only when I think my code is good I will commit to the company SVN, I would like to use git for my own history keeper.\nI don't need to use git to do SVN thing, nor vice versa. \nCan I version control my same code using SVN and git at the same time? No interaction between them." }, { "role": "assistant", "content": "You can clone a subversion repository to your machine using git svn clone <SVN repo URL>. The code will be available as a git repository. You can do your work there and make local commits as you please. There is a command line option to get a \"shallow\" checkout rather than the entire repository which is often useful. I forget what it is. \nAnytime, you want to run the equivalent of svn update, do a git svn rebase. This will fetch new commits which were checked into SVN after you last synchronised and then rebase your changes onto the new tip. \nWhen you're ready with your commits, do a git svn dcommit. This will send all your new commits to svn one by one. You can also squash your local commits into a single one and send it by first doing a local rebase and then an svn dcommit. This should be done on the initial branch (usually master). \nThe very fact that you're checking out from subversion and then working locally in git means that there is \"interaction\" between them so your last statement is not valid." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --ignore-missing" }, { "role": "assistant", "content": "Upon seeing an invalid object name in the input, pretend as if\nthe bad input was not given." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "HTTP Basic: Access denied fatal: Authentication failed\n\nI use GitLab Community Edition 9.1.3 2e4e522 on Windows 10 Pro x64. With Git client.\nError\nCloning into 'project_name'...\nremote: HTTP Basic: Access denied\nfatal: Authentication failed for 'http://[email protected]/my_user_name/project_name.git/'\n\nHow to fix it?" }, { "role": "assistant", "content": "Open CMD (Run as administrator)\ntype command:\ngit config --system --unset credential.helper\n\nthen enter new password for Git remote server." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git repository sync between computers, when moving around?\nLet's say that I have a desktop pc and a laptop, \nand sometimes I work on the desktop and sometimes I work on the laptop.\nWhat is the easiest way to move a git repository back and forth?\nI want the git repositories to be identical, \nso that I can continue where I left of at the other computer.\nI would like to make sure that I have the same branches and tags on both of the computers.\nThanks\nJohan\nNote: I know how to do this with SubVersion, but I'm curious on how this would work with git. If it is easier, I can use a third pc as classical server that the two pc:s can sync against.\nNote: Both computers are running Linux.\n\nUpdate:\nSo let's try XANI:s idea with a bare git repo on a server, \nand the push command syntax from KingCrunch.\nIn this example there is two clients and one server.\nSo let's create the server part first.\nssh user@server\nmkdir -p ~/git_test/workspace\ncd ~/git_test/workspace\ngit --bare init\n\nSo then from one of the other computers I try to get a copy of the repo with clone:\ngit clone user@server:~/git_test/workspace/\nInitialized empty Git repository in /home/user/git_test/repo1/workspace/.git/\nwarning: You appear to have cloned an empty repository.\n\nThen go into that repo and add a file:\ncd workspace/\necho \"test1\" > testfile1.txt\ngit add testfile1.txt\ngit commit testfile1.txt -m \"Added file testfile1.txt\"\ngit push origin master\n\nNow the server is updated with testfile1.txt.\nAnyway, let's see if we can get this file from the other computer.\nmkdir -p ~/git_test/repo2\ncd ~/git_test/repo2\ngit clone user@server:~/git_test/workspace/\ncd workspace/\ngit pull\n\nAnd now we can see the testfile.\nAt this point we can edit it with some more content and update the server again.\necho \"test2\" >> testfile1.txt\ngit add testfile1.txt\ngit commit -m \"Test2\"\ngit push origin master\n\nThen we go back to the first client and do a git pull to see the updated file.\nAnd now I can move back and forth between the two computers, \nand add a third if I like to." }, { "role": "assistant", "content": "I think, there are multiple approaches. I will just describe, how I handle this\nI have one netbook as a 24/7 server, that holds multiple git-repositories. From/To there I push and pull changes via SSH. For access from outside I use dyndns.org. It works fine, especially because I have more than two systems, that needs access to some of the repositories.\nUpdate: A little example.\nLets say my netbook is called \"netbook\". I create a repository there\n$ ssh [email protected]\n$ cd ~/git\n$ mkdir newThing\n$ cd newThing\n$ git init --bare\n\nOn my desktop I will than create a clone of it. Maybe I will add some files also\n$ git clone [email protected]:/home/username/git/newThing\n$ git add .\n$ git commit -m \"Initial\"\n$ git push origin master\n\nOn my portables I will (first) do the same, but for remote access (from outside my LAN), I will also add the external address.\n$ git clone [email protected]:/home/username/git/newThing\n$ git remote add externalName [email protected]:/home/username/git/newThing\n$ git pull externalName master\n\nIts just the way git (/git workflows) works. You can add as many remote repositories as you like. It doesnt matters, if two or more refers to the same \"physical\" repositories. You dont need an own local \"server\", you can use any public server, to which you have ssh access. And of course you dont need a public server at all, if you dont need access from outside. The bare repository can also be on the desktop system and you can then create a working-copy-repository within the local filesystem.\n$ mkdir myRepo; cd myRepo\n$ git init --bare\n$ cd /path/to/myProject\n$ git remote add origin /path/to/myRepo\n$ git add .; git commit -m \"Initial\"; git push origin master\n\nThis is the way, how I handle this, and I for me it works quite fine (if not perfect ;))\nSomething to read: http://progit.org/\nReally good book.-" } ]
[ { "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": "Gitlab webhook does not trigger a build on jenkins\n\nI've a group of multibranch pipeline jobs generated with the following piece groovy script:\n[\n 'repo1',\n 'repo2',\n].each { service ->\n\n multibranchPipelineJob(service) {\n\n displayName(service)\n\n branchSources {\n git {\n remote(\"[email protected]:whatever/${service}.git\")\n credentialsId('gitlab-ssh-key')\n }\n }\n\n orphanedItemStrategy {\n discardOldItems {\n daysToKeep(0)\n numToKeep(30)\n }\n }\n\n triggers {\n periodic(5)\n }\n\n }\n}\n\nand in each repo a Jenkinsfile that looks as follows:\n#!/usr/bin/env groovy\n\nproperties([\n gitLabConnection('[email protected]'),\n pipelineTriggers([\n [\n $class : 'GitLabPushTrigger',\n triggerOnPush : true,\n triggerOnMergeRequest: true,\n ]\n ]),\n disableConcurrentBuilds(),\n overrideIndexTriggers(false)\n])\n\nnode {\n\n def sbtHome = tool name: 'sbt-0.13.15', type: 'org.jvnet.hudson.plugins.SbtPluginBuilder\\$SbtInstallation'\n\n stage('Checkout') {\n checkout scm\n }\n\n stage('Build') {\n sh \"'${sbtHome}/bin/sbt' clean compile\"\n }\n\n stage('Test') {\n sh \"'${sbtHome}/bin/sbt' test\"\n }\n\n if (env.BRANCH_NAME == 'develop' || env.BRANCH_NAME == 'master') {\n stage('Publish') {\n sh \"'${sbtHome}/bin/sbt' publish\"\n }\n }\n}\n\nIt all works correctly. The seeder project generates all the folders from the first script and all the branches for given repo are built correctly.\nUnfortunately I've problems with triggering a build for any branch after commit + push has been made to gitlab. \nI've jenkins configured correctly - I mean the gitlab plugin, there is a connection and it all works well. \nI've also added a webhook on the gitlab side and it also runs correctly. After a test push is sent I receive 200 OK from jenkins and I do see in logs that scanning the branches has started and detected the changes correctly. Unfortunately the build for the changed branch does not start. Here's an extract from branch scan log: \n Checking branch ci\n ‘Jenkinsfile’ found\n Met criteria\nChanges detected: ci (a7b9ae2f930b0b10d52bb42f1ecf96a68bba4a30 → 39a4c1a65051d5e90079feec14ad22455a77c58e)\nDid not schedule build for branch: ci\n\nI'm 100% sure that this not a problem with communication between my jenkins instance and gitlab account. I see the webhook being triggered after push to gitlab, I see the request being send and branch scan being run. Changes are also detected but why on earth the job isn't started? I've also read the docs thoroughly and have it all configured correctly. \nJenkins version: 2.150.3\nGitlab version: 11.8.1-ee\n\nEDIT\nIt seems that after upgrading jenkins to v.2.164.1 it all started working correctly." }, { "role": "assistant", "content": "I found this very useful Setup Example (Continuous Integration with Jenkins and GitLab) . Especially the part Source Code management: \n\nWe need to specify the name as “origin”, which will be used by the other sections. For the Refspec we need to input: +refs/heads/*:refs/remotes/origin/* +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*\n\nAnd also:\n\nBranch Specifier we need origin/${gitlabSourceBranch} which will be filled in based on the web hook we’ll be setting up next.\n\n\nEdit1\nYou could try the following for one multibranch pipeline:\n\nSelect a branch, for example ci\nSelect \"View Configuration\" \nUnder \"Build Triggers\" select the checkbox \"Build when a change is pushed to GitLab\"\nMake some changes to the code and push to ci\n\n\nEdit2\nI could not find a suitable git-project to run and try to reproduce this behaviour. So if someone know a similar project and could share, please comment and I could do some more testing.\nFor Gitlab (requested a trial key, otherwise it will be a GitLab Community Edition): \nsudo docker run --detach --hostname gitlab.example.com --publish 443:443 --publish 80:80 --publish 22:22 --name gitlab --restart always --volume /srv/gitlab/config:/etc/gitlab --volume /srv/gitlab/logs:/var/log/gitlab --volume /srv/gitlab/data:/var/opt/gitlab gitlab/gitlab-ee:11.8.1-ee.0\n\nFor Jenkins:\nsudo docker run -u root --rm -d -p 8080:8080 -p 50000:50000 -v jenkins-data:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkins/jenkins:2.150.3\n\nThen \"Integration\" —> \"Jenkins CI\" in Gitlab as in this image:\nHope this can help you!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Registered as a Git root, but no Git repositories were found there\nIn Android Studio, when I import a project downloaded from link,\nI get an error as\n\n\"Invalide VCS root mapping\" The directory C:\\Users\\username\\Desktop\\video_diary-master is registered as a Git root, but no Git repositories were found there." }, { "role": "assistant", "content": "In my situation I didn't have to work with git, I just wanted to run the project that I had downloaded and that was prompting me this error\nOn Android Studio 3.0 I clicked on Configure in the popup window appeared on the bottom right corner\n\nThis automatically opened a window [accessible as well through File->Settings] on Version Control tab. I selected the first item in the bigger list and I removed it clicking on the red minus sign \n\nAfter this the error should disappear" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to convert `git:` urls to `http:` urls\nI'm working behind an http proxy. I'm trying to clone Android's source tree using their \"repo\" tool. \nThis tool insists on using git:// URLs, even though http:// URLs also work. As a result, I can't download the source.\nIs it possible to force git to always use http?\nEdit: my http_proxy is configured correctly. For example, this works:\ngit clone http://android.git.kernel.org/platform/manifest.git\n\nBut this doesn't (errno=Connection timed out):\ngit clone git://android.git.kernel.org/platform/manifest.git\n\nSo this answer does not really help me." }, { "role": "assistant", "content": "Here's an example of rewriting the default protocol for GitHub:\ngit config --global url.https://github.com/.insteadOf git://github.com/\n\nThe exact values depend on the protocol in use. For example, the above command for git over ssh will look like:\ngit config --global url.https://github.com/.insteadOf [email protected]:\n\nGit documentation for url.<base>.insteadOf:\n\ngit config [--global] url.<base>.insteadOf <other_url>\nAny URL that starts with this value will be rewritten to start, instead, with <base>. When more than one insteadOf strings match a given URL, the longest match is used." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git status shows modifications, git checkout -- <file> doesn't remove them\nI would like to remove all changes to my working copy.\nRunning git status shows files modified.\nNothing I do seems to remove these modifications.\nE.g.:\nrbellamy@PROMETHEUS /d/Development/rhino-etl (master)\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: Rhino.Etl.Core/Enumerables/CachingEnumerable.cs\n# modified: Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs\n# modified: Rhino.Etl.Tests/Rhino.Etl.Tests.csproj\n# modified: Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nrbellamy@PROMETHEUS /d/Development/rhino-etl (master)\n$ git checkout -- Rhino.Etl.Core/Enumerables/CachingEnumerable.cs\n\nrbellamy@PROMETHEUS /d/Development/rhino-etl (master)\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: Rhino.Etl.Core/Enumerables/CachingEnumerable.cs\n# modified: Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs\n# modified: Rhino.Etl.Tests/Rhino.Etl.Tests.csproj\n# modified: Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nrbellamy@PROMETHEUS /d/Development/rhino-etl (master)\n$ git checkout `git ls-files -m`\n\nrbellamy@PROMETHEUS /d/Development/rhino-etl (master)\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: Rhino.Etl.Core/Enumerables/CachingEnumerable.cs\n# modified: Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs\n# modified: Rhino.Etl.Tests/Rhino.Etl.Tests.csproj\n# modified: Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nrbellamy@PROMETHEUS /d/Development/rhino-etl (master)\n$ git reset --hard HEAD\nHEAD is now at 6c857e7 boo libraries updated to 2.0.9.2 and rhino.dsl.dll updated.\n\nrbellamy@PROMETHEUS /d/Development/rhino-etl (master)\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: Rhino.Etl.Core/Enumerables/CachingEnumerable.cs\n# modified: Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs\n# modified: Rhino.Etl.Tests/Rhino.Etl.Tests.csproj\n# modified: Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")" }, { "role": "assistant", "content": "I was having this problem on Windows but wasn't prepared to look into the ramifications of using config --global core.autocrlf false I also wasn't prepared to abandon other private branches and goodies in my stash and start with a fresh clone. I just need to get something done. Now.\nThis worked for me, on the idea that you let git rewrite your working directory completely:\ngit rm --cached -r .\ngit reset --hard\n\n(Note that running just git reset --hard wasn't good enough nor was a plain rm on the files before the reset as are suggested in the comments to the original question)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Checkout old commit and make it a new commit [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do I revert a Git repository to a previous commit?\n\n (41 answers)\n \n\nClosed 9 years ago.\n\n\n\nOn Git, say I mess up my commits, and I want to make the version 3 commits ago as the new version. If I do git checkout xxxx, it creates a new branch and it seems like I can only merge it? Could I make this the new \"master version\"?\nI want:\nA-B-C-D-E\n\nto become\nA-B-C-D-E-F\n\nwhere F has exactly the same content as C\nIf I use git revert xxxx instead, it seems like it definitely will have conflicts and I need to manually resolve it.\nWhat I really want is just make the old commit at some point the new commit, regardless of what's in my working directory or the latest commit.\nHow would I go about doing this?" }, { "role": "assistant", "content": "git rm -r .\ngit checkout HEAD~3 .\ngit commit\n\nAfter the commit, files in the new HEAD will be the same as they were in the revision HEAD~3." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "IntelliJ doesn't recognize java project after cloning\nI've cloned my repo from bitbucket and I am trying to open it in IntelliJ IDE, but i can't set Debug Configuration, can't set Main class in Application menu. I can't also add new Java class into project. I think that Intellij can't recognize this project is Java.\nIs it possible to make it right?" }, { "role": "assistant", "content": "You have to mark your src directory as Source Root.\nRight-click on the src folder and select Sources Root:\n\nThen you'll see that the icons will change:\n\n\n\nEDIT\nCheck the output path by bringing up the Project Structure view.\nPress Ctrl+Alt+Shift+S" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Jenkins - how to build a specific branch\nThis isn't as simple as just doing a parametrized build. I've already got a specific build process that will build and deploy whenever any of these branches are pushed to GitHub:\n\nSo if I've just pushed develop and it built successfully, how do I trigger a manual build and have it pull feature/my-new-feature (without doing a git push)? I tried enabling parametrized build, adding a new string called branch, and then adding a new branch specifier, */$branch. I then ran a build and set branch to feature/my-new-feature and it still pulled from develop." }, { "role": "assistant", "content": "Best solution can be:\nAdd a string parameter in the existing job \nThen in the Source Code Management section update Branches to build to use the string parameter you defined: \nIf you see a checkbox labeled Lightweight checkout, make sure it is unchecked.\nThe configuration indicated in the images will tell the jenkins job to use master as the default branch, and for manual builds it will ask you to enter branch details (FYI: by default it's set to master)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: How to make outer repository and embedded repository work as common/standalone repository?\n\nI have a big project(let's say A repo), and it there one child folder which is come from B repo. I would meet warning like below when I commit from A repo\nwarning: adding embedded git repository: extractor/annotator-server\nhint: You've added another git repository inside your current repository.\nhint: Clones of the outer repository will not contain the contents of\nhint: the embedded repository and will not know how to obtain it.\nhint: If you meant to add a submodule, use:\nhint:\nhint: git submodule add <url> extractor/annotator-server\nhint:\nhint: If you added this path by mistake, you can remove it from the\nhint: index with:\nhint:\nhint: git rm --cached extractor/annotator-server\nhint:\nhint: See \"git help submodule\" for more information.\n\nI have seen git-submodule and git-subtree:\nMaintaining Git repo inside another git repo\nhttps://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree\nBut I don't like them , because they need extra config.\n\nWhat I want is , for example:\nstructure like:\nA/\n--- a.py\n\n--- B/\n--- B/b.py\n\nWhen I change B/b.py .\n\nIf I am on path A/ , git add can detect B/b.py changed, git push only commit that to A repo. \ngit add . (would add changes under A/ )\ngit push (would push changes under A/ )\ngit pull (would pull changes under A/ )\ngit clone XXX:A (would clone all files under A/ , A/B/ is just looks like plain folder with all files, not a repo )\n\nIf I am on path A/B/ , git add only add B/b.py changes to B repo, and git push only commit that to B repo. \ngit add . (would add changes under B/ , but not add changes to A repo)\ngit push (would push changes under B/ , but not push changes to A repo)\ngit pull (would clone changes under B/ , )\ngit clone XXX:B (would clone all files under B/ )\n\nOnce I want to snyc A and B in another machine, just do\ngit clone A\nrm -rf A/B/\ngit clone B ./B\ngit add . && git commit 'sync with B'\n\n\nIn another word, A and B act as a standalone repo.\nBut the truth is , A repo treat B repo as submodule: \nA repo\nhttps://github.com/eromoe/test\nB repo\nhttps://github.com/eromoe/test2\n\nHow do I force A repo track all files under A/ , and B repo track all files under A/B/ ? I want A and B act as a self-contain repo , without any other config." }, { "role": "assistant", "content": "You can use below commands to add files from test2 repo to test repo as below:\n# In local test repo\nrm -rf test2\ngit clone https://github.com/eromoe/test2\ngit add test2/\ngit commit -am 'add files from test2 repo to test repo'\ngit push\n\nNote: \nYou should use git add test2/ (with slash, not git add test2).\ngit add test2/ will treat test2 folder and it's files as ordinary folder and file for test repo (create mode 100644). \ngit add test2 will treat test2 folder as a submodule for test repo (create mode 160000)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Restart/undo conflict resolution in a single file\nIn a larger git merge with several conflicting files, I incorrectly marked a file as resolved (using git add FILE after some editing)\nNow I'd like to undo my conflict resolution attempt and start over resolving that file.\nHow can I do that?" }, { "role": "assistant", "content": "Use git checkout with flag --merge (short version -m):\ngit checkout --merge FILE\n\nThis restores the unresolved state, including all information about parent and merge base, which allows restarting the resolution.\nThis command can also be used to \"undo\" automatic merge conflict resolution, if rerere is enabled in your git config. This is especially useful with enabled rerere.autoUpdate after it records incorrect merge conflict resolution and you notice too late.\nFound the solution here: http://gitster.livejournal.com/43665.html" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Creating a branch from issue in GitLab\n\nI've just started using GitLab, and have created a set of issues, in order to keep an overview of what needs to be done for my application. I was wondering if it was possible to create a branch from these issues, such that the branch and issues are linked, similar as in jira and Stash from atlassian?" }, { "role": "assistant", "content": "If you create a branch with the name <issue-number>-issue-description and push that branch to gitlab, it will automatically be linked to that issue. For instance, if you have an issue with id 654 and you create a branch with name 654-some-feature and push it to gitlab, it will be linked to issue 654.\nGitlab will even ask you if you want to create a merge request and will automatically add Closes #654 to the merge request description which will close issue 654 when the merge request is accepted.\nAlso if you go to a given issue page on gitlab, you should see a New Branch button which will automatically create a branch with a name of the form <issue-number>-issue-description." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_AUTHOR_NAME" }, { "role": "assistant", "content": "The human-readable name used in the author identity when creating commit or\ntag objects, or when writing reflogs. Overrides the user.name and author.name configuration settings." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to push new (rewritten) history to remote repository\n\nBasically, I have an open pull request that I want to fix and at the same time I want to make 1 commit that contains 2 features into 2 seperate commits.\nGithub repository now looks like this where fix is a new branch:\nmaster c-c-c\n \\\n fix c-c-c-c\n\nI created a pull request from fix.\nI wanted to change the last commit in fix into 2 commits in my local repository as follows:\nmaster c-c-c\n \\\n fix c-c-c-n-n\n\nwhere n-n are my 2 new commits.\nTo get to this point locally, I did this:\n1. git rebase -i HEAD~2\n2. Changed my last commit line to \"edit\", saved and closed the file\n3. git reset HEAD^\n4. git stash save\n5. Removed the changes I don't want in the first commit\n6. git commit -m \"commit a\" -a\n7. git stash apply\n8. git commit -m \"commit b\"\n\nSo now I have 2 commits the way I want. The problem is I found a bug that ended up in the pull request. Since I have already pushed to the remote repository, it won't accept my new commits (as the original one is now missing).\nI run:\ngit push origin fix --dry-run\n\nand I get the message:\nTo [email protected]:<UserName>/<Repository>.git\n! [rejected] fix -> fix (non-fast-forward)\nerror: failed to push some refs to '[email protected]:<UserName>/<Repository>.git'\n\nI have seen other posts suggest to pull my changes from origin before pushing back again, but won't that basically reset my 2 commits back into the one?\nIdeally, what I would like to do is assign the same commit ID to the last commit so it can replace the current one as is. Is there a way to do that? (Note that I didn't run git reset with --hard)" }, { "role": "assistant", "content": "When faced with that problem, a force push has worked for me:\ngit push --force origin fix\n\nEDIT: Per comments below, --force-with-lease is preferred over a direct --force because it includes some protections in case there has been an intervening commit. This article describes it as \"--force with a seatbelt\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %cI" }, { "role": "assistant", "content": "committer date, strict ISO 8601 format" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options commit.gpgSign" }, { "role": "assistant", "content": "A boolean to specify whether all commits should be GPG signed.\nUse of this option when doing operations such as rebase can\nresult in a large number of commits being signed. It may be\nconvenient to use an agent to avoid typing your GPG passphrase\nseveral times." } ]