messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "remote: repository not found fatal: not found\n\nWhy won't my git push? I created the repository and I keep getting this message:\nC:\\Users\\petey_000\\rails_projects\\first_app>git push -u github master\nUsername for 'https://github.com': ***@gmail.com\nPassword for 'https://***@[email protected]':\nremote: Repository not found.\nfatal: repository 'https://github.com/pete/first_app.git/' not found" }, { "role": "assistant", "content": "Your username shouldn't be an email address, but your GitHub user account: pete.\nAnd your password should be your GitHub account password (2014).\nUpdate 2021: your password should be (since Aug. 2021) a PAT (Personal Access Token).\nYou actually can set your username directly in the remote url, in order for Git to request only your password:\ncd C:\\Users\\petey_000\\rails_projects\\first_app\ngit remote set-url origin https://[email protected]/pete/first_app\n\nAnd you need to create the fist_app repo on GitHub first: make sure to create it completely empty, or, if you create it with an initial commit (including a README.md, a license file and a .gitignore file), then do a git pull first, before making your git push." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitk: command not found\nEnvironment: Mac OSX 10.10. When I was trying to use gitk, it shows:\nCoda-2:~ Coda$ gitk\n-bash: gitk: command not found\n\nI think the reason is the old version of git. Here is some information, and I have already typed brew update.\nCoda-2:~ Coda$ git --version\ngit version 1.9.3 (Apple Git-50)\nCoda-2:~ Coda$ brew install git \nWarning: git-2.4.0 already installed, it's just not linked\n\nWhat is this message: it's just not linked? \nFurthermore, I check the path of git:\nCoda-2:~ Coda$ which git\n/usr/bin/git\n\nIt should be in /usr/bin/local/git? How to fix it?\nUPDATE\nI figure it out, thank @TimCastelijns.\nbrew doctor said:\nWarning: You have unlinked kegs in your Cellar\nLeaving kegs unlinked can lead to build-trouble and cause brews that depend on\nthose kegs to fail to run properly once built. Run `brew link` on these:\n\n git\n\nSo, I typed:\nCoda-2:~ Coda$ brew link git\nLinking /usr/local/Cellar/git/2.4.0... 220 symlinks created\n\nThen I typed gitk, and it worked and the path changed to /usr/local/bin/git. However, when I want to check the version of git. It still showed the old version, why?\nCoda-2:~ Coda$ git --version\ngit version 1.9.3 (Apple Git-50)" }, { "role": "assistant", "content": "I just installed the latest version of git via homebrew on macos.\n11:28 $ git --version\ngit version 2.25.0\n\nIt doesn't seem to have gitk and git gui so I noticed the answer for linux and tried to install the same package git-gui via homebrew and it worked.\nbrew install git-gui\n\nFound the bug here.\nI'm running macos 10.14.5 Mojave." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-credential" }, { "role": "assistant", "content": "Retrieve and store user credentials" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options matchContext" }, { "role": "assistant", "content": "matching text in context lines" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Keep git history when splitting a file\nI want to take a function out of one file and put it into another, but keep the blame history.\ncp a.php b.php\n\nvim b.php\n# delete everything but 1 function\n\nvim a.php\n# delete the 1 function\n\ngit add a.php b.php\ngit commit\n\nBut if I run git blame b.php I only see it blaming to this new commit." }, { "role": "assistant", "content": "The general rule to maintaining blame history is to make a separate move commit first before any edits. It has been my experience that this allows git blame to work without the need for the -C option. So in the case of splitting the file up into new files, this can be done in two commits:\n\nDuplicate the original to the new destinations, making sure to delete the original\nRemove the extra sections from the duplicated files\n\nIn the example provided, this would be:\ncp a.php b.php\nmv a.php c.php\ngit add a.php b.php c.php\ngit commit\nvim b.php # delete everything but 1 function\nvim c.php # delete the 1 function\ngit add b.php c.php\ngit commit" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_TRACE_REDACT" }, { "role": "assistant", "content": "By default, when tracing is activated, Git redacts the values of\ncookies, the \"Authorization:\" header, the \"Proxy-Authorization:\"\nheader and packfile URIs. Set this Boolean environment variable to false to prevent this\nredaction." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git push failed, \"Non-fast forward updates were rejected\"\nI've edited my GIT repositories via Git Online. After I tried to push my local code changes, I got an error: \nGit push failed, To prevent from losing history, non-fast forward updates were rejected.\n\nHow can I fix this?" }, { "role": "assistant", "content": "Pull changes first:\ngit pull origin branch_name" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to add /usr/local/bin in $PATH on Mac\nWhen I do 'open .profile' in the terminal I have the following:\nexport PATH=$PATH:/usr/local/git/bin \n\nNow I installed node.js for Mac and it says, \n\nMake sure that /usr/local/bin is in your $PATH.\n\nHow can I add /usr/local/bin to export PATH=$PATH:/usr/local/git/bin?" }, { "role": "assistant", "content": "The PATH variable holds a list of directories separated by colons, so if you want to add more than one directory, just put a colon between them:\nexport PATH=$PATH:/usr/local/git/bin:/usr/local/bin\n\nThat syntax works in any Bourne-compatible shell (sh, ksh, bash, zsh...). But zsh, which is the default shell in recent versions of MacOS, also exposes the PATH another way - as a variable named (lowercase) $path, which is an array instead of a single string. So you can do this instead:\npath+=(/usr/local/git/bin /usr/local/bin) \n\nIn either case, you may want to check to make sure the directory isn't already in the PATH before adding it. Here's what that looks like using the generic syntax:\nfor dir in /usr/local/git/bin /usr/local/bin; do\n case \"$PATH\" in \n $dir:*|*:$dir:*|*:$dir) :;; # already there, do nothing\n *) PATH=$PATH:$dir # otherwise add it\n esac\ndone\n\nAnd here's a zsh-specific version:\nfor dir in /usr/local/git/bin /usr/local/bin; do\n if (( ${path[(i)$dir]} > $#path )); then\n path+=($dir)\n fi\ndone\n\nBut in Zsh you can also just mark the array vars as accepting only unique entries:\ntypeset -TU PATH path\n\nand even make your own pathlike variables mirrored in arrays:\ntypeset -TU PYTHONPATH pythonpath" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I revert uncommitted changes including files and folders?\nIs there a Git command to revert all uncommitted changes in a working tree and index and to also remove newly created files and folders?" }, { "role": "assistant", "content": "You can run these two commands:\n# Revert changes to modified files.\ngit reset --hard\n\n# Remove all untracked files and directories.\n# '-f' is force, '-d' is remove directories.\ngit clean -fd" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is there a naming convention for git repositories?\n\nFor example, I have a RESTful service called Purchase Service. Should I name my repository:\n\npurchaserestservice\npurchase-rest-service\npurchase_rest_service\nor something else?\n\nWhat's the convention? How about in GitHub? Should public repositories follow some standard?" }, { "role": "assistant", "content": "I'd go for purchase-rest-service. Reasons:\n\nWhat is \"pur chase rests ervice\"? Long, concatenated words are hard to understand. I know, I'm German. \"Donaudampfschifffahrtskapitänspatentausfüllungsassistentenausschreibungsstellenbewerbung.\"\n\"_\" is harder to type than \"-\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git error: \"Please make sure you have the correct access rights and the repository exists\"\nI am using TortoiseGit on Windows. When I am trying to Clone from the context menu of the standard Windows Explorer, I get this error:\n\nPlease make sure you have the correct access rights and the repository exists\n\nMore precisely, the snapshot of terminal is the following:\n\ngit.exe clone --progress -v \"git@arobotdev:\\git\\AlfaRobot.git\" \"C:\\Work\\AlfaRobot\"\n\n Cloning into 'C:\\Work\\AlfaRobot'...\n Permission denied, please try again.\n Permission denied, please try again.\n Permission denied (publickey,password).\n fatal: Could not read from remote repository.\n\n Please make sure you have the correct access rights\n and the repository exists.\n\n git did not exit cleanly (exit code 128) (21450 ms @ 19.09.2014 10:36:58)\n\nWhat should I do to make git work properly ?" }, { "role": "assistant", "content": "Your git URL might have changed. Change the URL in the local directory by using the following command:\nfor https protocol\ngit remote set-url origin https://github.com/username/repository.git\n\nfor ssh protocol\ngit remote set-url origin [email protected]:username/repository.git\n\nThere might be multiple causes for the issue:\n\nIf the issue is with your ssh identity, see onkar-m18's answer here\nIf ssh key is not added to hosting server, see lovekush-vishwakarma's answer here" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Add tab completion for Git branches in Powershell\nWhen inside a Git repository, is it possible to add tab completion for branches to Powershell? For example:\nPS> git checkout maTAB\nwould result in\nPS> git checkout master" }, { "role": "assistant", "content": "For that to be possible, a git provider for PowerShell would need to exist.\nAfter a quick search, something similar apparently exists, the bizarre but aptly named posh-git:\nhttp://github.com/dahlbyk/posh-git\n\nA set of PowerShell scripts which\n provide Git/PowerShell integration\n\nPrompt for Git repositories: The prompt within Git repositories can\n show the current branch and the state\n of files (additions, modifications,\n deletions) within.\nTab completion: Provides tab completion for common commands when\n using git. E.g. git ch<tab> -->\n git checkout\n\nUsage\nSee profile.example.ps1 as to how you\n can integrate the tab completion\n and/or git prompt into your own\n profile. You can also choose whether\n advanced git commands are shown in the\n tab expansion or only simple/common\n commands. Default is simple." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Move branch pointer to different commit without checkout\nTo move the branch pointer of a checked out branch, one can use the git reset --hard command. But how to move the branch pointer of a not-checked out branch to point at a different commit (keeping all other stuff like tracked remote branch)?" }, { "role": "assistant", "content": "git branch --force <branch-name> [<new-tip-commit>]\n\nIf new-tip-commit is omitted, it defaults to the current commit.\nnew-tip-commit can be a branch name (e.g., master, origin/master)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "The authenticity of host 'github.com (192.30.252.128)' can't be established\nI am trying to use\nsudo npm install\n\nto install all my dependencies for an application written in nodejs. My OS is Ubuntu 13.04\nHowever, I keep getting this warning:\nThe authenticity of host 'github.com (192.30.252.131)' can't be established.\nRSA key fingerprint is 16:27:ac:a5:76:28:1d:52:13:1a:21:2d:bz:1d:66:a8.\nAre you sure you want to continue connecting (yes/no)?\n\nHas anyone encountered this warning before? Is it possible to authenticate and store the fingerprint locally? So I won't need to authenticate again when I enter sudo npm install another time.\nRight now, I am unable to enter anything, not even \"yes\". My terminal just gets stuck, i have to press Ctrl+C to terminate." }, { "role": "assistant", "content": "Danger ahead, unless you actually don't care about secure communication with github on your local account\nSsh rightly complains that they can't make sure you are indeed connecting to github's server through a secure channel. That might be why github is recommending https access, which works out-of-the-box thanks to its public key infrastructure.\nNow, you can have it work, but be aware that it involves caching a public key fingerprint which, if done incorrectly, provides an attacker permanent man-in-the-middle attack.\nHow to proceed safely?\nOption 1 is use https url instead of ssh.\nOption 2 is have ssh access work.\nOkay, show me option 2\n\nDo ssh -T [email protected] but don't just type \"yes\".\nCheck if the hash that is shown matches one of the hashed shown in https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints (in your question it does, and see, the page is fetched through https for the same public key infrastructure reasons).\n\nIf the hash matches, then connection is indeed safe you can answer \"yes\" to ssh's question.\nOkay, I checked and typed yes, how do I know it works?\nSsh will show something like:\n\nWarning: Permanently added the RSA host key for IP address\n'192.30.252.128' to the list of known hosts.\n\nAfter that, you will either see a message like\n\nPermission denied (publickey).\n\nwhich is good but shows that you need further configuration, or simply\n\nHi yourlogin! You've successfully authenticated, but GitHub does not\nprovide shell access.\n\nwhich means that all works well and you can retry your first operation.\nNotice that if you retry the same ssh command, it should no longer ask the question." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-branch - List, create, or delete branches branch.<name>.remote" }, { "role": "assistant", "content": "When on branch <name>, it tells git fetch and git push which remote to fetch from or push to. The remote to push to\nmay be overridden with remote.pushDefault (for all branches).\nThe remote to push to, for the current branch, may be further\noverridden by branch.<name>.pushRemote . If no remote is\nconfigured, or if you are not on any branch and there is more than\none remote defined in the repository, it defaults to origin for\nfetching and remote.pushDefault for pushing.\nAdditionally, . (a period) is the current local repository\n(a dot-repository), see branch.<name>.merge 's final note below." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-update-index - Register file contents in the working tree to the index" }, { "role": "assistant", "content": "SKIP-WORKTREE BIT Skip-worktree bit can be defined in one (long) sentence: Tell git to\navoid writing the file to the working directory when reasonably\npossible, and treat the file as unchanged when it is not\npresent in the working directory. Note that not all git commands will pay attention to this bit, and\nsome only partially support it. The update-index flags and the read-tree capabilities relating to the\nskip-worktree bit predated the introduction of the git-sparse-checkout command, which provides a much easier\nway to configure and handle the skip-worktree bits. If you want to\nreduce your working tree to only deal with a subset of the files in\nthe repository, we strongly encourage the use of git-sparse-checkout in preference to the low-level\nupdate-index and read-tree primitives. The primary purpose of the skip-worktree bit is to enable sparse\ncheckouts, i.e. to have working directories with only a subset of\npaths present. When the skip-worktree bit is set, Git commands (such\nas switch , pull , merge ) will avoid writing these files.\nHowever, these commands will sometimes write these files anyway in\nimportant cases such as conflicts during a merge or rebase. Git\ncommands will also avoid treating the lack of such files as an\nintentional deletion; for example git add -u will not stage a\ndeletion for these files and git commit -a will not make a commit\ndeleting them either. Although this bit looks similar to assume-unchanged bit, its goal is\ndifferent. The assume-unchanged bit is for leaving the file in the\nworking tree but having Git omit checking it for changes and presuming\nthat the file has not been changed (though if it can determine without\nstat’ing the file that it has changed, it is free to record the\nchanges). skip-worktree tells Git to ignore the absence of the file,\navoid updating it when possible with commands that normally update\nmuch of the working directory (e.g. checkout , switch , pull ,\netc.), and not have its absence be recorded in commits. Note that in\nsparse checkouts (setup by git sparse-checkout or by configuring\ncore.sparseCheckout to true), if a file is marked as skip-worktree in\nthe index but is found in the working tree, Git will clear the\nskip-worktree bit for that file." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I add Git submodule to a sub-directory?\nI have a Git repo in ~/.janus/ with a bunch of submodules in it. I want to add a submodule in ~/.janus/snipmate-snippets/snippets/, but when I run git submodule add <[email protected]:...> in the snipmate-snippets directory, I get the following error message:\nYou need to run this command from the top level of the working tree.\n\nSo the question is: How do I add a submodule to the snipmate-snippets directory?" }, { "role": "assistant", "content": "You go into ~/.janus and run:\ngit submodule add <git@github ...> snipmate-snippets/snippets/\n\nIf you need more information about submodules (or git in general) ProGit is pretty useful." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc git-diff-files [<pattern>…​]" }, { "role": "assistant", "content": "compares the index and the files on the filesystem." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I avoid the specification of the username and password at every git push?\n\nI git push my work to a remote Git repository.\nEvery push will prompt me to input username and password. I would like to avoid it for every push, but how to configure to avoid it?" }, { "role": "assistant", "content": "1. Generate an SSH key\nLinux/Mac\nOpen terminal to create ssh keys:\ncd ~ #Your home directory\nssh-keygen -t rsa #Press enter for all values\n\nFor Windows\n(Only works if the commit program is capable of using certificates/private & public ssh keys)\n\nUse Putty Gen to generate a key\nExport the key as an open SSH key\n\nHere is a walkthrough on putty gen for the above steps\n2. Associate the SSH key with the remote repository\nThis step varies, depending on how your remote is set up.\n\nIf it is a GitHub repository and you have administrative privileges, go to settings and click 'add SSH key'. Copy the contents of your ~/.ssh/id_rsa.pub into the field labeled 'Key'.\nIf your repository is administered by somebody else, give the administrator your id_rsa.pub.\nIf your remote repository is administered by your, you can use this command for example: \nscp ~/.ssh/id_rsa.pub YOUR_USER@YOUR_IP:~/.ssh/authorized_keys/id_rsa.pub\n\n3. Set your remote URL to a form that supports SSH 1\nIf you have done the steps above and are still getting the password prompt, make sure your repo URL is in the form\ngit+ssh://[email protected]/username/reponame.git\n\nas opposed to\nhttps://github.com/username/reponame.git\n\nTo see your repo URL, run:\ngit remote show origin\n\nYou can change the URL with:\ngit remote set-url origin git+ssh://[email protected]/username/reponame.git\n\n[1] This section incorporates the answer from Eric P" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Amend a commit that wasn't the previous commit [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do I modify a specific commit?\n\n (22 answers)\n \n\nClosed 9 years ago.\n\n\n\nFrequently I'll have a workflow like the following:\n\nCommit changes to a group of files\nCommit changes to a different group of files\nRealize I missed some changes that belong in the first commit\nCurse\n\nI can't make use of git commit --amend because it's not the most recent commit that I need to change. What's the best way to add changes to the first commit without touching the second one?" }, { "role": "assistant", "content": "You can use git rebase to solve this. Run git rebase -i sha1~1 where sha1 is the commit hash of the one you want to change. Find the commit you want to change, and replace \"pick\" with \"edit\" as described in the comments of the rebase editor. When you continue from there, you can edit that commit.\nNote that this will change the sha1 of that commit as well as all children -- in other words, this rewrites the history from that point forward. You can break repositories doing this, but if you haven't pushed, it's not as much of a big deal." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-push" }, { "role": "assistant", "content": "Update remote refs along with associated objects" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options diff.external" }, { "role": "assistant", "content": "If this config variable is set, diff generation is not\nperformed using the internal diff machinery, but using the\ngiven command. Can be overridden with the ‘GIT_EXTERNAL_DIFF’\nenvironment variable. The command is called with parameters\nas described under \"git Diffs\" in git . Note: if\nyou want to use an external diff program only on a subset of\nyour files, you might want to use gitattributes instead." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can't push to the heroku\nI was pushing the current git repository into the heroku.\nThat online application was developed using Scala and IntelliJ.\nAnd I don't know how to fix this error.\n$ git push heroku master\nCounting objects: 3, done.\nDelta compression using up to 4 threads.\nCompressing objects: 100% (3/3), done.\nWriting objects: 100% (3/3), 531 bytes | 0 bytes/s, done.\nTotal 3 (delta 0), reused 0 (delta 0)\nremote: Compressing source files... done.\nremote: Building source:\nremote: \nremote: ! No default language could be detected for this app.\nremote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.\nremote: See https://devcenter.heroku.com/articles/buildpacks\nremote: \nremote: ! Push failed\nremote: Verifying deploy....\nremote: \nremote: ! Push rejected to salty-coast-14102.\nremote: \nTo https://git.heroku.com/salty-coast-14102.git\n ! [remote rejected] master -> master (pre-receive hook declined)\nerror: failed to push some refs to 'https://git.heroku.com/salty-coast-14102.git'" }, { "role": "assistant", "content": "Read this doc which will explain to you what to do.\nhttps://devcenter.heroku.com/articles/buildpacks\n\nSetting a buildpack on an application\nYou can change the buildpack used by an application by setting the buildpack value.\n When the application is next pushed, the new buildpack will be used.\n$ heroku buildpacks:set heroku/php\n\nBuildpack set. Next release on random-app-1234 will use heroku/php.\n Run git push heroku master to create a new release using this buildpack.\n\nThis is whay its not working for you since you did not set it up.\n... When the application is next pushed, the new buildpack will be used.\nYou may also specify a buildpack during app creation:\n$ heroku create myapp --buildpack heroku/python" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --no-indent-heuristic" }, { "role": "assistant", "content": "Disable the indent heuristic." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Execute a script before the branch is deleted in GitLab-CI\n\nGitLab-CI executes the stop-environment script in dynamic environments after the branch has been deleted. This effectively forces you to put all the teardown logic into the .gitlab-ci.yml instead of a script that .gitlab-ci.yml just calls.\nDoes anyone know a workaround for this? I have a shell script that removes the deployment. This script is part of the repository and can also be called locally (i.e. not onli in an CI environment). I want GitLab-CI to call this script when removing a dynamic environment but it's obviously not there anymore when the branch has been deleted. I also cannot put this script to the artifacts as it is generated before the build by a configure script and contains secrets. It would be great if one could execute the teardown script before the branch is deleted.\nHere's a relevant excerpt from the .gitlab-ci.yml\ndeploy_dynamic_staging:\n stage: deploy\n variables:\n SERVICE_NAME: foo-service-$CI_BUILD_REF_SLUG\n script:\n - ./configure\n - make deploy.staging\n environment:\n name: staging/$CI_BUILD_REF_SLUG\n on_stop: stop_dynamic_staging\n except:\n - master\n\nstop_dynamic_staging:\n stage: deploy\n variables:\n GIT_STRATEGY: none\n script:\n - make teardown # <- this fails\n when: manual\n environment:\n name: staging/$CI_BUILD_REF_SLUG\n action: stop" }, { "role": "assistant", "content": "Probably not ideal, but you can curl the script using the gitlab API before running it:\ncurl \\\n -X GET https://gitlab.example. com/raw/master/script.sh\\\n -H 'PRIVATE-TOKEN: ${GITLAB_TOKEN}' > script.sh" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What's recommended .gitignore for Scala/sbt project in IntelliJ IDEA?\nI created a new Scala/sbt project in IntelliJ IDEA 13. Since other team members will be working on this project (presumably with other IDEs), what should I put in the .gitignore? It seems some of the project dependencies are defined in the .idea folder, so I wasn't sure if I can put the whole directory in .gitignore or not." }, { "role": "assistant", "content": "EDIT After discovering Joe:\nJust ask Joe to take care of your .gitignore\nOriginal Answer:\nSince you're using Scala you should add: \ntarget\n*.class\n\nThese can be generated back easily and could be machine dependent.\nIf you're going to use IntelliJ then the following: \n*.iml\n*.ipr\n*.iws\n.idea\nout\n\nThe .idea folder and the .iml files are created and used only by IntelliJ, other IDEs will just ignore them. They can be generated easily by IntelliJ if needed, try deleting your .idea folder and then open the project in IntelliJ and, lo and behold the first thing it does is generate the .idea folder and it's contents.\nFor Vim: \ntags\n.*.swp\n.*.swo\n\nFor Eclipse(Scala IDE): \nbuild\n.classpath\n.project\n.settings\norg.scala-ide.sdt.core/META-INF/MANIFEST.MF\norg.scala-ide.sdt.update-site/site.xml`\n\nFor macOS: \n.DS_Store\n\nI think this covers the most popular IDEs for Scala. If someone's using an IDE not covered, you'll have to look around for what temporary and build files they create." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker gitformat-index" }, { "role": "assistant", "content": "Git index format" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git merge diff3 style need explanation\nI've merged 2 branches and conflicts appeared, I would need some hints where it starts where it ends, etc. I've replaced the code with some faked data to make it easier to read and talk about.\n<<<<<<< HEAD\n aaaaaa\n||||||| merged common ancestors\n<<<<<<< Temporary merge branch 1\n bbbbbb\n=======\n cccccc\n>>>>>>> mybranch\n dddddd\n<<<<<<< HEAD\n eeeeee\n||||||| merged common ancestors\n ffffff\n||||||| merged common ancestors\n gggggg\n=======\n>>>>>>> Temporary merge branch 2\n=======\n hhhhhh\n>>>>>>> mybranch" }, { "role": "assistant", "content": "What you're seeing in this example (with Temporary merge branch markers) is the result of diff3 with a criss-cross merge conflict. I'll explain this with a sequence of definitions.\nDefinitions\n\nmerge base: The commit where the two merging branches most recently diverged from. When a merge conflict occurs, different changes were made to the same lines in both branches. The merge base contains what those lines were before either branch changed them.\nmerged common ancestors: diff3 outputs an additional \"middle\" section showing the lines as they were in the merge base. This is the starting point for both branches.\nCriss-cross merge: A merge history where two branches merge into each other in ways that one could not have been a fast-forward merge. I give an example below. In a criss-cross merge situation, there are multiple merge bases.\nTemporary merge branch: When there are multiple merge bases, diff3 attempts to merge them together (using temporary merge branches) to form a single common ancestor to show in diff3's middle section. This works seamlessly when there are no conflicts, but when there are conflicts, you see the temporary merge branch's conflict markers inside the middle merged common ancestors section.\n\nExample criss-cross merge conflict scenario\nA criss-cross merge occurs whenever two branches merge into each other at different points in time.\nm3 *\n |\\\n | \\\n | * B1\n | |\nm2 * * B0\n |\\/|\n |/\\|\nm1 * * A\n | /\n |/\nm0 *\n\nConsider this sequence of events:\n\nm0 exists as origin/master\nI create a feature branch feature-A with one commit A\nm1 gets committed to master by someone else\nI start a new feature branch feature-B that builds on A\nI merge origin/master (m1) into feature-B. It conflicts, and I resolve it. The merge commit is B0.\nI implement feature-B and commit the work as B1.\nfeature-A is ready to ship, so someone merges it into master. It conflicts. They resolve it, but their resolution differs from the resolution in B0. The merge commit is m2.\nfeature-B is ready to ship, so someone merges it into master. git tries to determine the merge base, but m1 and A both qualify equally as merge bases. git merges m1 and A in a temporary merge branch, which results in a conflict. We see diff3 output in the merged common ancestors section, similar to the OP's question.\n\nReading the output\nWith diff3 off, this merge conflict would look simply like this:\n<<<<<<< HEAD\n aaaaaa\n=======\n hhhhhh\n>>>>>>> mybranch\n\nFirst, with all the extra markers, you'll want to determine what the actual conflicting lines are, so you can differentiate it from the diff3 common ancestor output.\n\naaaaaahhhhhh, that's a little better. ;-)\nIn the case where two conflict resolutions are conflicting, aaaaaa and hhhhhh are the two resolutions.\nNext, examine the content of the merged common ancestor.\n\nWith this particular merge history, there were more than 2 merge bases, which required multiple temporary merge branches which were then merged together. The result when there are many merge bases and conflicts can get pretty hairy and difficult to read. Some say don't bother, just turn off diff3 for these situations.\nAlso be aware that git internally may decide to use different merge strategies to auto-resolve conflicts, so the output can be hard to understand. Make sense out of it if you can, but know that it was not intended for human consumption. In this case, a conflict occurred when merging mybranch into Temporary merge branch 1 between bbbbbb and cccccc. Line dddddd had no conflicts between the temporary merge branches. Then a separate conflict occurred when merging Temporary merge branch 2 into HEAD, with multiple common ancestors. HEAD had resolved the conflict by merging ffffff and gggggg as eeeeee, but Temporary merge branch 2 resolved that same conflict by deleting (or moving) the line (thus no lines between ====== and Temporary merge branch 2.\nHow do you resolve a conflict like this? While technical analysis may be possible, your safest option is usually to go back and review the history in all the involved branches around the conflict, and manually craft a resolution based on your understanding.\nAvoiding all this\nThese conflicts are the worst, but there are some behaviors that will help prevent them.\n\nAvoid criss-cross merges. In the example above, feature-B merged origin/master as B0. It's possible that this merge to stay up-to-date with master wasn't necessary (though sometimes it is). If origin/master was never merged into feature-B, there would have been no merge criss-cross, and m3 would have been a normal conflict with A as the only merge base.\nm3 * m3 *\n |\\ |\\\n | \\ | \\\n | * B1 | * B1\n | | | |\nm2 * * B0 VS m2 * |\n |\\/| |\\ |\n |/\\| | \\|\nm1 * * A m1 * * A\n | / | /\n |/ |/\nm0 * m0 *\n\nBe consistent with conflict resolutions. In the example, the Temporary merge base conflict only occurred because m2 and B0 had different conflict resolutions. If they had resolved the conflict identically, m3 would have been a clean merge. Realize though that this is a simple criss-cross merge that ought to have had the same resolution. Other situations may rightly have different resolutions. Things get more complicated when there are more than 2 merge bases and multiple commits between the merge points. That said, if you are knowingly inconsistent with conflict resolutions in criss-cross situations, expect headaches later." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --dirstat-by-file[=<param1,param2>…​]" }, { "role": "assistant", "content": "Synonym for --dirstat=files,<param1>,<param2>…​" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options diff.<driver>.xfuncname" }, { "role": "assistant", "content": "The regular expression that the diff driver should use to\nrecognize the hunk header. A built-in pattern may also be used.\nSee gitattributes for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitLab container registry: Any way to automate deletion of old containers?\n\nWe have a GitLab CI pipeline which builds a new Docker image based on an external ETCD snapshot of a Hashicorp Vault secrets back-end. The image is for disaster recovery so we don't have any interest in keeping old versions in the registry. \nIs there any way of purging GitLab registry container images which are older than a certain date. Or to keep a maximum number of recent images and delete the rest?\nThanks\nS" }, { "role": "assistant", "content": "run this command:\nsudo gitlab-ctl registry-garbage-collect -m" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --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 - the stupid content tracker git-archive" }, { "role": "assistant", "content": "Create an archive of files from a named tree" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Make .gitignore ignore everything except a few files\nI understand that a .gitignore file cloaks specified files from Git's version control.\nHow do I tell .gitignore to ignore everything except the files I'm tracking with Git? Something like:\n# Ignore everything:\n*\n\n# Do not ignore these files:\nscript.pl\ntemplate.latex" }, { "role": "assistant", "content": "An optional prefix ! which negates the pattern; any matching file excluded by\na previous pattern will become included again. If a negated pattern matches,\nthis will override lower precedence patterns sources.\n\n# Ignore everything\n*\n\n# But not these files...\n!.gitignore\n!script.pl\n!template.latex\n# etc...\n\n# ...even if they are in subdirectories\n!*/" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs git log --no-merges" }, { "role": "assistant", "content": "Show the whole commit history, but skip any merges" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_COMMITTER_EMAIL" }, { "role": "assistant", "content": "The email address used in the author identity when creating commit or\ntag objects, or when writing reflogs. Overrides the user.email and committer.email configuration settings." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-worktree - Manage multiple working trees -f --force" }, { "role": "assistant", "content": "By default, add refuses to create a new worktree when <commit-ish> is a branch name and is already checked out by\nanother worktree, or if <path> is already assigned to some\nworktree but is missing (for instance, if <path> was deleted\nmanually). This option overrides these safeguards. To add a missing but\nlocked worktree path, specify --force twice. move refuses to move a locked worktree unless --force is specified\ntwice. If the destination is already assigned to some other worktree but is\nmissing (for instance, if <new-path> was deleted manually), then --force allows the move to proceed; use --force twice if the destination is locked. remove refuses to remove an unclean worktree unless --force is used.\nTo remove a locked worktree, specify --force twice." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs i18n.logOutputEncoding" }, { "role": "assistant", "content": "Encoding to use when displaying logs. (See Discussion above.)\nDefaults to the value of i18n.commitEncoding if set, and UTF-8\notherwise." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Unstaged changes left after git reset --hard\nAfter git reset --hard, git status gives me files within the Changes not staged for commit: section.\nI've also tried git reset ., git checkout -- . and git checkout-index -f -a, to no avail.\nSo, how can I get rid of those unstaged changes?\nThis seems to hit only Visual Studio project files. Weird. See this paste: http://pastebin.com/eFZwPn9Z. What is special with those files, is that in .gitattributes I have:\n*.sln eol=crlf\n*.vcproj eol=crlf\n*.vcxproj* eol=crlf\n\nAlso, autocrlf is set to false in my global .gitconfig. Could that be somehow relevant?" }, { "role": "assistant", "content": "I had the same problem and it was related to the .gitattributes file.\nHowever the file type that caused the problem was not specified in the .gitattributes.\nI was able to solve the issue by simply running\ngit rm .gitattributes\ngit add -A\ngit reset --hard" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to link folder from a git repo to another repo?\nI want to create a public repo to put some sample files from my main repo (private). Is there any way to soft link few folders from a git repo to another git repo?" }, { "role": "assistant", "content": "Then you should use submodules for this task.\nSubmodule are different git repositories under the same root.\nThis way you can manage 2 different project at folder level inside the root repository\n\nSubmodules allow foreign repositories to be embedded within a dedicated subdirectory of the source tree, always pointed at a particular commit.\n\n\ngit submodule\nBreak your big project to sub projects as you did so far.\nNow add each sub project to you main project using :\ngit submodule add <url>\n\nOnce the project is added to your repo, you have to init and update it.\ngit submodule init\ngit submodule update\n\nAs of Git 1.8.2 new option --remote was added\ngit submodule update --remote --merge\n\nwill fetch the latest changes from upstream in each submodule, merge them in, and check out the latest revision of the submodule.\nAs the docs describe it:\n\n--remote\nThis option is only valid for the update command. Instead of using the superproject’s recorded SHA-1 to update the submodule, use the status of the submodule’s remote-tracking branch.\n\nThis is equivalent to running git pull in each submodule.\n\n\nHowever, how would I push a commit in the scenario of bug fix in C which affects the code shared with the parent layers?\n\nAgain: using submodule will place your code inside your main project as part of its content. The difference between having it locally inside the folder or having it as part of a submodule is that in submodule the content is managed (commited) to a different standalone repository.\n\nThis is an illustration of submodule - project inside another project in which each project is a standalone project.\n\n\ngit subtree\nGit subtree allows you to insert any repository as a sub-directory of another one\nVery similar to submodule but the main difference is where your code is managed. In submodules the content is placed inside a separate repo and is managed there which allow you to clone it to many other repos as well.\nsubtree is managing the content as part of the root project and not in a separate project.\nInstead of writing down how to set it up and to understand how to use it you can simply read this excellent post which will explain it all.\nhttps://developer.atlassian.com/blog/2015/05/the-power-of-git-subtree/" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-clone - Clone a repository into a new directory clone.filterSubmodules" }, { "role": "assistant", "content": "If a partial clone filter is provided (see --filter in git-rev-list ) and --recurse-submodules is used, also apply\nthe filter to submodules." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to rename a directory/folder on GitHub website?\n\nI was able to find a way on GitHub Website to rename a single file and did so with success.\nI was also able to find a way to rename a whole repository and did that with success.\nDoes anyone know how to do this to a single directory without using command line? For reference, I am trying to change a directory named InterviewTesting (that contains source files, etc) to something else. I tried doing it the single file way. But this didn't allow me to change the name of the directory (InterviewTesting), only the actual file name." }, { "role": "assistant", "content": "Actually, there is a way to rename a folder using web interface.\n\nSee https://github.com/blog/1436-moving-and-renaming-files-on-github" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %GP" }, { "role": "assistant", "content": "show the fingerprint of the primary key whose subkey was used\nto sign a signed commit" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I print out the value of a git configuration setting (core.autocrlf) on Windows?\nI'm trying to fix a problem with CRLF on Windows.\nHow do I see what the value of the configuration setting core.autocrlf is set to on my system?" }, { "role": "assistant", "content": "If you're using Git Bash:\ngit config --get core.autocrlf\n\nAnd for the global config:\ngit config --global --get core.autocrlf" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -G<regex>" }, { "role": "assistant", "content": "Look for differences whose patch text contains added/removed\nlines that match <regex>. To illustrate the difference between -S<regex> --pickaxe-regex and -G<regex> , consider a commit with the following diff in the same\nfile: + return frotz(nitfol, two->ptr, 1, 0);\n...\n- hit = frotz(nitfol, mf2.ptr, 1, 0); While git log -G\"frotz\\(nitfol\" will show this commit, git log\n-S\"frotz\\(nitfol\" --pickaxe-regex will not (because the number of\noccurrences of that string did not change). Unless --text is supplied patches of binary files without a textconv\nfilter will be ignored. See the pickaxe entry in gitdiffcore for more\ninformation." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-shortlog - Summarize git log output --ancestry-path[=<commit>]" }, { "role": "assistant", "content": "Limit the displayed commits to those which are an ancestor of\n<commit>, or which are a descendant of <commit>, or are <commit>\nitself. As an example use case, consider the following commit history: D---E-------F\n\t / \\ \\\n\t B---C---G---H---I---J\n\t / \\\n\tA-------K---------------L--M A regular D..M computes the set of commits that are ancestors of M ,\nbut excludes the ones that are ancestors of D . This is useful to see\nwhat happened to the history leading to M since D , in the sense\nthat “what does M have that did not exist in D ”. The result in this\nexample would be all the commits, except A and B (and D itself,\nof course). When we want to find out what commits in M are contaminated with the\nbug introduced by D and need fixing, however, we might want to view\nonly the subset of D..M that are actually descendants of D , i.e.\nexcluding C and K . This is exactly what the --ancestry-path option does. Applied to the D..M range, it results in: E-------F\n\t\t \\ \\\n\t\t G---H---I---J\n\t\t\t \\\n\t\t\t\tL--M We can also use --ancestry-path=D instead of --ancestry-path which\nmeans the same thing when applied to the D..M range but is just more\nexplicit. If we instead are interested in a given topic within this range, and all\ncommits affected by that topic, we may only want to view the subset of D..M which contain that topic in their ancestry path. So, using --ancestry-path=H D..M for example would result in: E\n\t\t \\\n\t\t G---H---I---J\n\t\t\t \\\n\t\t\t\tL--M Whereas --ancestry-path=K D..M would result in K---------------L--M" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Show sha1 only with git log\nI want to write a Bash script that loops over the sha1s of commits output by an invocation of git log. However, git log gives me much more output than I want:\ncommit 0375602ba2017ba8750a58e934b41153faee6fcb\nAuthor: Mark Amery <[email protected]>\nDate: Wed Jan 1 21:35:07 2014 +0000\n\n Yet another commit message\n\n This one even has newlines.\n\ncommit 4390ee9f4428c84bdbeb2fed0a461099a6c81b39\nAuthor: Mark Amery <[email protected]>\nDate: Wed Jan 1 21:30:19 2014 +0000\n\n Second commit message.\n\ncommit bff53bfbc56485c4c1007b0884bb1c0d61a1cf71\nAuthor: Mark Amery <[email protected]>\nDate: Wed Jan 1 21:28:27 2014 +0000\n\n First commit message.\n\nHow can I get git log to just output sha1s so that I can loop over them conveniently?" }, { "role": "assistant", "content": "You can use the --format argument with a custom format that only includes the sha1:\ngit log --format=format:%H\n\nThe above command yields output like the following:\n0375602ba2017ba8750a58e934b41153faee6fcb\n4390ee9f4428c84bdbeb2fed0a461099a6c81b39\nbff53bfbc56485c4c1007b0884bb1c0d61a1cf71\n\nYou can loop over the commit hashes in Bash like this:\nfor sha1 in $(git log --format=format:%H); do\n : # Do something with $sha1\ndone\n\nThis is slightly more verbose than using git rev-list, but may be your only option if you want to use ordering or filtering arguments for git log that are not supported by git rev-list, like -S." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitosis vs gitolite? [closed]\nClosed. This question is seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. It does not meet Stack Overflow guidelines. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\n We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.\n\n\nClosed 8 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI am looking for installing a git server to share projects with my team. I don't want to create a user account on the server with SSH access for each developer that needs a git access.\nIt seems there is two concurrent solutions that cover this issue : gitosis & gitolite.\nI could not find any comparison between both solutions. What are the main differences between them? Are there other similar solution?" }, { "role": "assistant", "content": "I am looking for installing a git server to share projects with my team.\n\nYou can just use git.\nTo have a git server the only thing you need on the remote server is git. If you don't require fine-grained permissions (sharing with only your team suggests that's a possibility) or any extra features, you don't need gitolite, or similar.\nThe no-install solution\nIf git is available on the remote server, you can do what you're asking right now, without doing anything\nssh [user@]server\ncd repos/are/here/\nmkdir project.git\ncd project.git\ngit init --bare\n\nLocally:\ncd projects/are/here/project\ngit remote add origin [user@]server:repos/are/here/project.git\ngit push -u origin master\n\nSetting up a git server is easy.\nIf you want to do things with a dedicated git user, the docs for setting up a git server are short - because it really is quite easy to do.\nIn summary:\n\nInstall git\nCreate a user named git\nAdd your and your team's public keys to the git user's .ssh/authorized_keys file\nChange the git user's shell to be git-shell\nCreate repos on the server\nstart git pull/pushing to [email protected]\n\nThe only difference between using a dedicated git user and not, is that if you setup the git user to use git-shell it won't allow itself to do anything else. In terms of acting as a git server though, it's identical to the no-install solution" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to resume a git pull/clone after a hung up unexpectedly?\nI do a git pull/clone to some repository (mainly github ones).\nSometimes after a few minutes the download crashes.\nHere is a log.\nremote: Counting objects: 2284, done.\nremote: Compressing objects: 100% (713/713), done.\nfatal: The remote end hung up unexpectedlyiB | 5 KiB/s \nfatal: early EOF\nfatal: index-pack failed\n\nIn my following of the process, i have noticed that i have already fetched about 4 MBs of objects.\nWhen i start the process again, it starts from the beginning.\nMy Internet connection sucks, some times it crashes and i get disconnected unexpectedly.\nMy question is: Is there any way to resume the pull/clone to rescue those 4 MBs i have already fetched, and not to start again?" }, { "role": "assistant", "content": "If a pull hung up, it will not write any changes to your filesystem. This is because, if it would, your local repository would not be in a stable state. \nThere is no way to resume a pull/clone. So your only choice is to pull/clone again." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to get the parent of a specific commit in Git\nI have a commit number. I would like to get the previous commit number (parent). I need commits from the current branch." }, { "role": "assistant", "content": "git log --pretty=%P -n 1 \"$commit_from\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I Re-root a git repo to a parent folder while preserving history?\nI have a git repo in /foo/bar/baz with a large commit history and multiple branches.\nI now want /foo/qux to be in the same repo as /foo/bar/baz, which means that I need them both to be in a repo rooted at /foo. However, I want to preserve history of changes that I've made to /foo/bar/baz.\nI first thought of git format-patch followed by apply, but commit messages aren't preserved.\nSo,\nI need to reroot the repo\n(1) to an arbitrarily higher ancestor directory\n(2) while preserving my commit history by making it look like I've been comitting to /foo/bar/baz all along" }, { "role": "assistant", "content": "What you want is git filter-branch, which can move a whole repository into a subtree, preserving history by making it look as if it's always been that way. Back up your repository before using this!\nHere's the magic. In /foo/bar, run:\ngit filter-branch --commit-filter '\n TREE=\"$1\";\n shift;\n SUBTREE=`echo -e 040000 tree $TREE\"\\tbar\" | git mktree`\n git commit-tree $SUBTREE \"$@\"' -- --all\n\nThat will make the /foo/bar repository have another 'bar' subdirectory with all its contents throughout its whole history. Then you can move the entire repo up to the foo level and add baz code to it.\nUpdate:\nOkay, here's what's going on. A commit is a link to a \"tree\" (think of it as a SHA representing a whole filesystem subdirectory's contents) plus some \"parent\" SHA's and some metadata link author/message/etc. The git commit-tree command is the low-level bit that wraps all this together. The parameter to --commit-filter gets treated as a shell function and run in place of git commit-tree during the filter process, and has to act like it.\nWhat I'm doing is taking the first parameter, the original tree to commit, and building a new \"tree object\" that says it's in a subfolder via git mktree, another low-level git command. To do that, I have to pipe into it something that looks like a git tree i.e. a set of (mode SP type SP SHA TAB filename) lines; thus the echo command. The output of mktree is then substituted for the first parameter when I chain to the real commit-tree; \"$@\" is a way to pass all the other parameters intact, having stripped the first off with shift. See git help mktree and git help commit-tree for info.\nSo, if you need multiple levels, you have to nest a few extra levels of tree objects (this isn't tested but is the general idea):\ngit filter-branch --commit-filter '\n TREE=\"$1\"\n shift\n SUBTREE1=`echo -e 040000 tree $TREE\"\\tbar\" | git mktree`\n SUBTREE2=`echo -e 040000 tree $SUBTREE1\"\\tb\" | git mktree`\n SUBTREE3=`echo -e 040000 tree $SUBTREE2\"\\ta\" | git mktree`\n git commit-tree $SUBTREE3 \"$@\"' -- --all\n\nThat should shift the real contents down into a/b/bar (note the reversed order).\nUpdate: Integrated improvements From Matthew Alpert's answer below. Without -- --all this only works on the currently-checked out branch, but since the question is asking about a whole repo, it makes more sense to do it this way than branch-by-branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "CocoaPods and GitHub forks\n\nThis is my first time forking a GitHub project, and I'm not too competent with CocoaPods either, so please bear with me.\nBasically, I forked a project on GitHub using the following in my Podfile:\npod 'REActivityViewController', '~> 1.6.7', :git => 'https://github.com/<username>/REActivityViewController.git'\n\nI then made some changes to the fork, and of course when I did a pod install to install another pod it reinstalled the original REActivityViewController and erased my changes.\nI'm realizing I need to push my changes to my fork before another pod install, but how do I know it is the fork being installed, considering that this is a repo installed by CocoaPods? I looked in the REActivityViewController folder installed under the Pods folder and there aren't any git files. \nDo I need to work on my fork outside of my project and then use CocoaPods to install the changes? That's too cumbersome of a workflow. \nOr do I need to do something with submodules?" }, { "role": "assistant", "content": "I will answer this question using an example. I have a fork of TTTAttributedLabel with some extra functionality I added here:\n\nhttps://github.com/getaaron/TTTAttributedLabel\n\nIn order to use this in a Cocoapods project, I:\n\nPush my changes to my fork\nConfigure my Podfile to get the changes & update\n\nOnce you've pushed your changes to your fork, get the SHA of your last commit. You can do this using git rev-parse origin/master | pbcopy or on the GitHub commits page for your project:\n\nThen, you can specify the specific commit on your fork in your Podfile like this:\npod 'TTTAttributedLabel', :git => 'https://github.com/getaaron/TTTAttributedLabel.git', :commit => 'd358791c7f593d6ea7d6f8c2cac2cf8fae582bc1'\n\nAfter that, pod update will update this particular commit from your fork. If you want, you can also make a podspec for your fork, but I find this approach simpler and I don't make changes frequently enough to justify a new workflow.\n\nDo I need to work on my fork outside of my project and then use Cocoapods to install the changes? That's way to cumbersome of a workflow.\n\nYou can do it this way, but I usually:\n\nEdit the code inside my project and make sure it works\nCopy the changes over to my fork, by\n\n\nexporting a patch, or\ncopying over the entire source code file\n\nCommit & push to GitHub\nUpdate the Podfile with the new SHA\nRun pod update.\n\n\nOr do I need to do something with submodules?\n\nNo, you don't need to." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-remote" }, { "role": "assistant", "content": "Manage set of tracked repositories" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker" }, { "role": "assistant", "content": "Terminology Please see gitglossary ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_REF_PARANOIA" }, { "role": "assistant", "content": "If this Boolean environment variable is set to false, ignore broken or badly named refs when iterating\nover lists of refs. Normally Git will try to include any such\nrefs, which may cause some operations to fail. This is usually\npreferable, as potentially destructive operations (e.g., git-prune ) are better off aborting rather than\nignoring broken refs (and thus considering the history they\npoint to as not worth saving). The default value is 1 (i.e.,\nbe paranoid about detecting and aborting all operations). You\nshould not normally need to set this to 0 , but it may be\nuseful when trying to salvage data from a corrupted repository." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-clean - Remove untracked files from the working tree -e <pattern> --exclude=<pattern>" }, { "role": "assistant", "content": "Use the given exclude pattern in addition to the standard ignore rules\n(see gitignore )." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "is there any way to auto merge branches in gitlab?\n\nIn my gitlab project there are 3 main branches: develop, stage and master.\nEach time when updated code is pushed to develop branch, I have to merge it to stage branch and then merge it again to master branch manually.\nThis doesn't seem efficient.\nIs there any way to merge branches automatically when there is no conflict?\nFurthermore, it is possible to use a file named \"gitlab-ci.yml \" for auto merge something like\n# merge develop branch to stage branch\nmerge-to-stage:\n only:\n - develop\n script:\n - merge (develop) to (stage) << something like this\n\n# merge stage branch to master branch when the job above is completed\nstage-to-master:\n only:\n - stage\n script:\n - merge (stage) to (master) << something like this\n\n\nPlease give me your kind advice." }, { "role": "assistant", "content": "There is no way to automate this within GitLab. But you can automate this using GitLab CI.\nBe aware that the GitLab CI Runners are independent from GitLab and just get a local copy of a Git repository. So your CI script wont be able to run git merge & git push out of the box.\nWhat you need to do is set up a SSH connection from the GitLab CI Runner to your GitLab instance. Use a before script for this. There are several answers on StackOverflow and a good blog post on GitLab how to achive this.\nmerge-job:\n before_script:\n - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'\n - eval $(ssh-agent -s)\n - ssh-add <(echo \"$GIT_SSH_PRIV_KEY\")\n - mkdir -p ~/.ssh\n - cat gitlab-known-hosts >> ~/.ssh/known_hosts\n\nThen run your Git commands like git merge. Then push.\nmerge-to-stage:\n only:\n - develop\n script:\n # If this is the last job you can stay here, otherwise better clone the repo into a working directory\n # git clone <URL> <working-directory> && cd <working directory>\n - git checkout stage\n - git merge develop\n - git push origin stage\n\nThe schema of your next pipeline jobs depend on what you mean with when there is no conflict. In your example code you merge all stage branches into the higher branch (feature to develop, develop to stage, stage to main). If so, then you should make sure that there is a merge job for each stage and these merge jobs are placed at the end of the pipeline. Then the merge won't happen if there was a CI error or a merge conflict before.\nAlternatively you could also have just one job, which uses GitLabs push options. With these options you may create merge requests for your feature branch which are automatically merged and closed when a CI Pipeline is successful. This strategy would only merge your feature branch changes and not the whole stage branches.\nmerge-to-stage-branches:\n only:\n - <feature branch names that are no WIP anymore>\n script:\n # <scripts to merge feature into develop>\n git push -o merge_request.create -o merge_request.target=develop -o merge_request.merge_when_pipeline_succeeds\n # <repeat merge for each stage branch>\n # <repeat push for each stage branch>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: How to update/checkout a single file from remote origin master?\nThe scenario:\n\nI make some changes in a single file locally and run git add, git commit and git push\nThe file is pushed to the remote origin master repository\nI have another local repository that is deployed via Capistrano with the \"remote_cache\" method from that remote repository\nNow I don't want to deploy the whole application but just update/checkout that single file.\n\nIs this somehow possible with git? I wasn't able to find anything that would work nor was I able to figure it out. With SVN I just did svn up file and voila." }, { "role": "assistant", "content": "It is possible to do (in the deployed repository)\ngit fetch\ngit checkout origin/master -- path/to/file\n\nThe fetch will download all the recent changes, but it will not put it in your current checked out code (working area).\nThe checkout will update the working tree with the particular file from the downloaded changes (origin/master).\nAt least this works for me for those little small typo fixes, where it feels weird to create a branch etc just to change one word in a file." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options protocol.version" }, { "role": "assistant", "content": "If set, clients will attempt to communicate with a server\nusing the specified protocol version. If the server does\nnot support it, communication falls back to version 0.\nIf unset, the default is 2 .\nSupported versions: 0 - the original wire protocol. 1 - the original wire protocol with the addition of a version string\nin the initial response from the server. 2 - Wire protocol version 2, see gitprotocol-v2 ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to make Git pull use rebase by default for all my repositories?\nIs there a way to setup the host Git repository such that any git pull done from its (local) clones uses --rebase by default? By searching on Stack Overflow, I learned about branch.autosetuprebase, but it needs to be configured per clone individually. \nMy project flow is set up such that we pull the develop branch before mergeing a feature branch to it. This pull nearly always uses --rebase, so I am trying to figure out if this can be the default." }, { "role": "assistant", "content": "There are now 3 different levels of configuration for default pull behaviour. From most general to most fine grained they are:\n1. pull.rebase\nSetting this to true means that git pull is always equivalent to git pull --rebase (unless branch.<branchname>.rebase is explicitly set to false). This can also be set per repository or globally.\n2. branch.autosetuprebase\nSetting this to always means that whenever a tracking branch is created, a configuration entry like the one below will be created for it. For finer grained control, this can also be set to never, local or remote and can be set per repository or globally. See git config --help for further details.\n3. branch.<branchname>.rebase\nSetting this to true means that that particular branch will always pull from its upstream via rebasing, unless git pull --no-rebase is used explicitly.\nConclusion\nSo while you can't change the default behaviour for all future clones of a repository, you can change the default for all of the current user's (existing and future) repositories via git config --global pull.rebase true." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Bash is extremely slow on Windows 7 x64\nI've been using Git on both Windows and Ubuntu during the development of a small project, frequently flipping back and forth between the two. The issue is that Git Bash consistently becomes slow.\nWhen I say slow, I mean that running cd takes anywhere from 8-25 seconds, running git commands take from 5-20 seconds, and ls can take up to 30 seconds sometimes. Needless to say, this is not fun, not to mention unproductive. I know Git is slower on Windows, but this is ridiculous.\nThe one solution which has worked--temporarily--for me has been to disable my network connection (as suggested in this answer), start Git Bash, and then reconnect. Sometimes it continues to run quickly for days after doing that, but the performance always degrades eventually. I've trawled through the msysgit discussion group, Stack Overflow, msysgit issue list, etc. on and off for weeks, but I haven't been able to turn up solutions which work.\nSo far, I've tried:\n\nAdding Git & project folders to the virus scanner's exclusion list\nDisabling my virus scanner completely (Kaspersky IS 2011)\nEnsuring that Outlook is not running (Outlook 2007)\nShutting down all other applications\nRunning Git Bash as administrator\nDisabling network connection, starting Git Bash, and keeping connection disabled\nDisabling network connection, starting Git Bash, re-enabling connection (works only occasionally)\nRunning git gc\nAnd combinations of the above\n\nI did read that a couple of people had success disabling Bash completion, but ideally I'd like to keep that active. The version of msysgit is 1.7.3.1-preview20101002 & the OS is Windows 7 x64. Running the same things on Linux is, predictably, lightning fast. I would use Linux exclusively, but I need to run stuff in Windows, too (certain applications, testing, etc.).\nHas anyone encountered a similar issue? If so, what was the underlying problem and what was the solution (if any)?\nThis extends beyond just the Git repositories, but just for reference, the repositories I've been using Git with have been pretty small: ~4-50 files maximum." }, { "role": "assistant", "content": "You can significantly speed up Git on Windows by running three commands to set some config options:\ngit config --global core.preloadindex true\ngit config --global core.fscache true\ngit config --global gc.auto 256\n\nNotes:\n\ncore.preloadindex does filesystem operations in parallel to hide latency (update: enabled by default in Git 2.1)\ncore.fscache fixes UAC issues so you don't need to run Git as administrator (update: enabled by default in Git for Windows 2.8)\ngc.auto minimizes the number of files in .git/" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Error \"Updates were rejected because the remote contains work that you do not have locally\"\nI'm working on a team with a few developers using Git on Bitbucket. We are all working on a dev branch, not pushing to master until a release.\nOne of the developers committed incorrect code that overwrote my own by accident, and now I am trying to push the correct code back to the repository. I have been reading about this error for a few days now, and I can't push to the repository any more, because I am getting the following error:\n ! [rejected] master -> dev (fetch first)\nerror: failed to push some refs to 'https://[email protected]/repo_user/repo_name.git'\nhint: Updates were rejected because the remote contains work that you do\nhint: not have locally. This is usually caused by another repository pushing\nhint: to the same ref. You may want to first integrate the remote changes\nhint: (e.g., 'git pull ...') before pushing again.\nhint: See the 'Note about fast-forwards' in 'git push --help' for details.\n\nI follow the instructions and pull, but then I receive a merge conflict. After entering a message for the merge conflict, my local code is now the incorrect code that the other developer uploaded by accident (as expected from the pull). So I replace the incorrect code with the backup I copied before committing, and when I try to push again, I get the same error.\nHow can I solve this issue?\nThese are the commands I run in order to commit:\ngit pull remotename master:dev\ngit add --all\ngit commit -m \"some message\"\ngit pull remotename master:dev\ngit push remotename master:dev\n\nI would have thought that if I kept this order, I would not receive merge conflicts. I guess I was wrong.\nI have looked for a few hours on Google and Stack Overflow, and followed different instructions, but I still can't do a Git push to the dev branch." }, { "role": "assistant", "content": "You can override any checks that Git does by using \"force push\". Use this command in the terminal:\ngit push -f origin master\n\nHowever, you will potentially ignore the existing work that is in remote. You are effectively rewriting the remote's history to be exactly like your local copy." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is \"git remote add ...\" and \"git push origin master\"?\nQuite often, Git and Ruby on Rails looks like magic... such as in the first chapter of Ruby on Rails 3 Tutorial book, it talks about Git:\ngit remote add origin [email protected]:peter/first_app.git\ngit push origin master\n\nAnd it pretty much says \"it just works\" without saying too much about what they are and start talking about branching. Searching on the Internet shows that git remote add is to add a \"short name\", such as origin, and it can be any name as well, which is like an alias to a URL.\nAnd origin is the usual path of where the remote repository points to (in http://git-scm.com/book/en/Git-Basics-Working-with-Remotes under \"Adding Remote Repositories\").\nSo why is the URL not git://[email protected]/peter/first_app.git, but in the other syntax -- what syntax is it? Why must it end with .git? I tried not using .git at the end and it works too. If not .git, what else can it be? The git in [email protected] seems to be a user account on the Git server?\nAlso, why does it need to be so verbose to use git push origin master? Can't the default be origin and master? I found that the first time, the origin master is needed, but after a small edit and commit, then git push is all it needs (no need origin master). Can somebody who knows what is going on give some details?\nSometimes it feels like a lot of magic without explanation... and sometimes the person using it is so confident and when asked why, can't explain it, and respond with something like \"that's the way it is\". Sometimes very practical and pragmatic. It is not bad to be practical, but probably not practical to the point to not know what is going on." }, { "role": "assistant", "content": "Git is like Unix. It is user-friendly, but it is picky about its friends. It's about as powerful and as user-friendly as a shell pipeline.\nThat being said, once you understand its paradigms and concepts, it has the same Zenlike clarity that I've come to expect from Unix command-line tools. You should consider taking some time off to read one of the many good Git tutorials available online. The Pro Git book is a good place to start.\nTo answer your first question.\n\nWhat is git remote add ...?\nAs you probably know, Git is a distributed version control system. Most operations are done locally. To communicate with the outside world, Git uses what are called \"remotes\". These are repositories other than the one on your local disk which you can push your changes into (so that other people can see them) or pull from (so that you can get others changes). The command git remote add origin [email protected]:peter/first_app.git creates a new remote called origin located at [email protected]:peter/first_app.git. Once you do this, in your push commands, you can push to origin instead of typing out the whole URL.\n\nWhat is git push origin master?\nThis is a command that says \"push the commits in the local branch named master to the remote named origin\". Once this is executed, all the stuff that you last synchronised with origin will be sent to the remote repository and other people will be able to see them there.\n\n\nNow about transports (i.e., what git://) means. Remote repository URLs can be of many types (file://, https://, etc.). Git simply relies on the authentication mechanism provided by the transport to take care of permissions and stuff. This means that for file:// URLs, it will be Unix file permissions, etc. The git:// scheme is asking Git to use its own internal transport protocol, which is optimised for sending Git changesets around. As for the exact URL, it's the way it is because of the way GitHub has set up its Git server.\nNow the verbosity. The command you've typed is the general one. It's possible to tell Git something like \"the branch called master over here is local mirror of the branch called foo on the remote called bar\". In Git speak, this means that master tracks bar/foo. When you clone for the first time, you will get a branch called master and a remote called origin (where you cloned from) with the local master set to track the master on origin.\nOnce this is set up, you can simply say git push and it'll do it. The longer command is available in case you need it (e.g., git push might push to the official public repository and git push review master can be used to push to a separate remote which your team uses to review code). You can set your branch to be a tracking branch using the --set-upstream option of the git branch command.\nI've felt that Git (unlike most other applications I've used) is better understood from the inside out. Once you understand how data is stored and maintained inside the repository, the commands and what they do become crystal clear. I do agree with you that there's some elitism amongst many Git users, but I also found that with Unix users once upon a time, and it was worth ploughing past them to learn the system. Good luck!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Error pushing to GitHub - insufficient permission for adding an object to repository database\nI'm getting back an unusual error while trying to do a \"git push\" to my GitHub repository:\n\nCounting objects: 8, done.\nDelta compression using 2 threads.\nCompressing objects: 100% (4/4), done.\nWriting objects: 100% (5/5), 1.37 KiB, done.\nTotal 5 (delta 2), reused 0 (delta 0)\nerror: insufficient permission for adding an object to repository database ./objects\n\nfatal: failed to write object\nerror: unpack-objects exited with error code 128\nerror: unpack failed: unpack-objects abnormal exit\nTo [email protected]:bixo/bixo.git\n ! [remote rejected] master -> master (n/a (unpacker error))\nerror: failed to push some refs to '[email protected]:bixo/bixo.git'\n\n\nAfter a clean clone from GitHub, I can edit/add/commit/push a modified file.\nIf I then repeat this a second time I get the above error.\nI can push to other GitHub repositories just fine.\nI've checked file/directory permissions on my side, and they seem OK.\nI'm running git 1.6.2.3 on Mac OS X 10.5.8\n\nThe above repository was the source of my fun for a previous Stack Overflow question (SO 1904860), so maybe the GitHub repo got corrupted. The only similar issue I've found via searching was an unpack failed problem reported on github. Has anybody else run into this issue before, especially when not using GitHub?" }, { "role": "assistant", "content": "When you see this error outside of github, here's a remedy.\nGot this from:\nhttp://mapopa.blogspot.com/2009/10/git-insufficient-permission-for-adding.html\nssh me@myserver\ncd repository/.git\n\nsudo chmod -R g+ws *\nsudo chgrp -R mygroup *\n\ngit config core.sharedRepository true\n\nAfter this the git daemon should use the group file permissions when writing to .git/objects." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-commit-graph" }, { "role": "assistant", "content": "Write and verify Git commit-graph files" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I tell who forked my repository on GitHub?\n\nIs there a way to know who has forked my repository on GitHub? I can see the number of forks, but I'd like to know who forked my repository and what kind of changes they made to it.\nI know they can send me a pull request if they're interested in contributing back to my repository, but is there some other way for me to find out who forked my repository?" }, { "role": "assistant", "content": "Clicking the number of forks shows you the full network. From there you can click \"members\" to see who forked the repo. Example for ExpressJS: https://github.com/expressjs/express/network/members." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "hg equivalent of git add -p?\nIs there a mercurial equivalent of git add -p?\nQuoting from man, git-add with the option -p (or --patch) does the following:\n\nInteractively choose hunks of patch between the index and the work\n tree and add them to the index. This gives the user a chance to\n review the difference before adding modified contents to the index." }, { "role": "assistant", "content": "Have a look at the record extension (which comes bundled with Mercurial).\nNote that since Mercurial doesn't have the concept of the staging area like git, running hg record will simply allow you to examine, hunk by hunk, the modifications in your working copy. Any changes you choose to record will be committed, and any changes you choose not to record are simply left as modifications in your working copy." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to make shallow git submodules?\nIs it possible to have shallow submodules? I have a superproject with several submodules, each with a long history, so it gets unnecessarily big dragging all that history.\nAll I have found is this unanswered thread.\nShould I just hack git-submodule to implement this?" }, { "role": "assistant", "content": "TLDR;\ngit clone --recurse-submodules --shallow-submodules\n\n(But see caveat with Ciro Santilli answer)\nOr: record that a submodule should be shallow cloned:\ngit config -f .gitmodules submodule.<name>.shallow true\n\nWhich means the next git clone --recurse-submodules will shallow clone the submodule '<name>' (depth 1), even without the --shallow-submodules.\n\nWhat follows is the evolution of git submodule/git clone when it comes to shallow clones, starting (in 2013) with Git 1.8.4, and going from there.\n\nNew in the upcoming Git 1.8.4 (July 2013):\n\n\"git submodule update\" can optionally clone the submodule repositories shallowly.\n\n(And git 2.10 Q3 2016 allows to record that with git config -f .gitmodules submodule.<name>.shallow true.\nSee the end of this answer)\nSee commit 275cd184d52b5b81cb89e4ec33e540fb2ae61c1f:\n\nAdd the --depth option to the add and update commands of \"git submodule\", which is then passed on to the clone command. This is useful when the submodule(s) are huge and you're not really interested in anything but the latest commit.\nTests are added and some indention adjustments were made to conform to the rest of the testfile on \"submodule update can handle symbolic links in pwd\".\nSigned-off-by: Fredrik Gustafsson <[email protected]>\nAcked-by: Jens Lehmann <[email protected]>\n\nThat means this works:\n# add shallow submodule\ngit submodule add --depth 1 <repo-url> <path>\ngit config -f .gitmodules submodule.<path>.shallow true\n\n# later unshallow\ngit config -f .gitmodules submodule.<path>.shallow false\ngit submodule update <path>\n\nThe commands can be ran in any order. The git submodule command perform the actual clone (using depth 1 this time). And the git config commands make the option permanent for other people who will clone the repo recursively later.\nAs an example, suppose you have the repo https://github.com/foo/bar and you want to add https://github.com/lorem/ipsum as a submodule, in your repo at path/to/submodule. The commands may look like like the following:\ngit submodule add --depth 1 [email protected]:lorem/ipsum.git path/to/submodule\ngit config -f .gitmodules submodule.path/to/submodule.shallow true\n\nThe following results in the same thing too (opposite order):\ngit config -f .gitmodules submodule.path/to/submodule.shallow true\ngit submodule add --depth 1 [email protected]:lorem/ipsum.git path/to/submodule\n\nThe next time someone runs git clone --recursive [email protected]:foo/bar.git, it will pull in the whole history of https://github.com/foo/bar, but it will only shallow-clone the submodule as expected.\nWith:\n\n--depth\n\nThis option is valid for add and update commands.\nCreate a 'shallow' clone with a history truncated to the specified number of revisions.\n\n\natwyman adds in the comments:\n\nAs far as I can tell this option isn't usable for submodules which don't track master very closely. If you set depth 1, then submodule update can only ever succeed if the submodule commit you want is the latest master. Otherwise you get \"fatal: reference is not a tree\".\n\nThat is true.\nThat is, until git 2.8 (March 2016). With 2.8, the submodule update --depth has one more chance to succeed, even if the SHA1 is directly reachable from one of the remote repo HEADs.\nSee commit fb43e31 (24 Feb 2016) by Stefan Beller (stefanbeller).\nHelped-by: Junio C Hamano (gitster).\n(Merged by Junio C Hamano -- gitster -- in commit 9671a76, 26 Feb 2016)\n\nsubmodule: try harder to fetch needed sha1 by direct fetching sha1\n\n\nWhen reviewing a change that also updates a submodule in Gerrit, a common review practice is to download and cherry-pick the patch locally to test it.\nHowever when testing it locally, the 'git submodule update' may fail fetching the correct submodule sha1 as the corresponding commit in the submodule is not yet part of the project history, but also just a proposed change.\nIf $sha1 was not part of the default fetch, we try to fetch the $sha1 directly. Some servers however do not support direct fetch by sha1, which leads git-fetch to fail quickly.\nWe can fail ourselves here as the still missing sha1 would lead to a failure later in the checkout stage anyway, so failing here is as good as we can get.\n\n\nMVG points out in the comments to commit fb43e31 (git 2.9, Feb 2016)\n\nIt would seem to me that commit fb43e31 requests the missing commit by SHA1 id, so the uploadpack.allowReachableSHA1InWant and uploadpack.allowTipSHA1InWant settings on the server will probably affect whether this works.\nI wrote a post to the git list today, pointing out how the use of shallow submodules could be made to work better for some scenarios, namely if the commit is also a tag.\nLet's wait and see.\nI guess this is a reason why fb43e31 made the fetch for a specific SHA1 a fallback after the fetch for the default branch.\nNevertheless, in case of “--depth 1” I think it would make sense to abort early: if none of the listed refs matches the requested one, and asking by SHA1 isn't supported by the server, then there is no point in fetching anything, since we won't be able to satisfy the submodule requirement either way.\n\n\nUpdate August 2016 (3 years later)\nWith Git 2.10 (Q3 2016), you will be able to do\n git config -f .gitmodules submodule.<name>.shallow true\n\nSee \"Git submodule without extra weight\" for more.\n\nGit 2.13 (Q2 2017) do add in commit 8d3047c (19 Apr 2017) by Sebastian Schuberth (sschuberth).\n(Merged by Sebastian Schuberth -- sschuberth -- in commit 8d3047c, 20 Apr 2017)\n\na clone of this submodule will be performed as a shallow clone (with a history depth of 1)\n\nHowever, Ciro Santilli adds in the comments (and details in his answer)\n\nshallow = true on .gitmodules only affects the reference tracked by the HEAD of the remote when using --recurse-submodules, even if the target commit is pointed to by a branch, and even if you put branch = mybranch on the .gitmodules as well.\n\n\nGit 2.20 (Q4 2018) improves on the submodule support, which has been updated to read from the blob at HEAD:.gitmodules when the .gitmodules file is missing from the working tree.\nSee commit 2b1257e, commit 76e9bdc (25 Oct 2018), and commit b5c259f, commit 23dd8f5, commit b2faad4, commit 2502ffc, commit 996df4d, commit d1b13df, commit 45f5ef3, commit bcbc780 (05 Oct 2018) by Antonio Ospite (ao2).\n(Merged by Junio C Hamano -- gitster -- in commit abb4824, 13 Nov 2018)\n\nsubmodule: support reading .gitmodules when it's not in the working tree\n\n\nWhen the .gitmodules file is not available in the working tree, try\nusing the content from the index and from the current branch.\nThis covers the case when the file is part of the repository but for some\nreason it is not checked out, for example because of a sparse checkout.\nThis makes it possible to use at least the 'git submodule' commands\nwhich read the gitmodules configuration file without fully populating\nthe working tree.\nWriting to .gitmodules will still require that the file is checked out,\nso check for that before calling config_set_in_gitmodules_file_gently.\nAdd a similar check also in git-submodule.sh::cmd_add() to anticipate the eventual failure of the \"git submodule add\" command when .gitmodules is not safely writeable; this prevents the command from leaving the repository in a spurious state (e.g. the submodule repository was cloned but .gitmodules was not updated because config_set_in_gitmodules_file_gently failed).\nMoreover, since config_from_gitmodules() now accesses the global object\nstore, it is necessary to protect all code paths which call the function\nagainst concurrent access to the global object store.\nCurrently this only happens in builtin/grep.c::grep_submodules(), so call\ngrep_read_lock() before invoking code involving config_from_gitmodules().\nNOTE: there is one rare case where this new feature does not work\nproperly yet: nested submodules without .gitmodules in their working tree.\n\n\nNote: Git 2.24 (Q4 2019) fixes a possible segfault when cloning a submodule shallow.\nSee commit ddb3c85 (30 Sep 2019) by Ali Utku Selen (auselen).\n(Merged by Junio C Hamano -- gitster -- in commit 678a9ca, 09 Oct 2019)\n\nGit 2.25 (Q1 2020), clarifies the git submodule update documentation.\nSee commit f0e58b3 (24 Nov 2019) by Philippe Blain (phil-blain).\n(Merged by Junio C Hamano -- gitster -- in commit ef61045, 05 Dec 2019)\n\ndoc: mention that 'git submodule update' fetches missing commits\nHelped-by: Junio C Hamano\nHelped-by: Johannes Schindelin\nSigned-off-by: Philippe Blain\n\n\n'git submodule update' will fetch new commits from the submodule remote if the SHA-1 recorded in the superproject is not found. This was not mentioned in the documentation.\n\n\nWarning: With Git 2.25 (Q1 2020), the interaction between \"git clone --recurse-submodules\" and alternate object store was ill-designed.\n\nThe documentation and code have been taught to make more clear recommendations when the users see failures.\n\nSee commit 4f3e57e, commit 10c64a0 (02 Dec 2019) by Jonathan Tan (jhowtan).\n(Merged by Junio C Hamano -- gitster -- in commit 5dd1d59, 10 Dec 2019)\n\nsubmodule--helper: advise on fatal alternate error\nSigned-off-by: Jonathan Tan\nAcked-by: Jeff King\n\n\nWhen recursively cloning a superproject with some shallow modules defined in its .gitmodules, then recloning with \"--reference=<path>\", an error occurs. For example:\ngit clone --recurse-submodules --branch=master -j8 \\\n https://android.googlesource.com/platform/superproject \\\n master\ngit clone --recurse-submodules --branch=master -j8 \\\n https://android.googlesource.com/platform/superproject \\\n --reference master master2\n\nfails with:\nfatal: submodule '<snip>' cannot add alternate: reference repository\n'<snip>' is shallow\n\nWhen a alternate computed from the superproject's alternate cannot be added, whether in this case or another, advise about configuring the \"submodule.alternateErrorStrategy\" configuration option and using \"--reference-if-able\" instead of \"--reference\" when cloning.\n\nThat is detailed in:\nWith Git 2.25 (Q1 2020), The interaction between \"git clone --recurse-submodules\" and alternate object store was ill-designed.\n\nDoc: explain submodule.alternateErrorStrategy\nSigned-off-by: Jonathan Tan\nAcked-by: Jeff King\n\n\nCommit 31224cbdc7 (\"clone: recursive and reference option triggers submodule alternates\", 2016-08-17, Git v2.11.0-rc0 -- merge listed in batch #1) taught Git to support the configuration options \"submodule.alternateLocation\" and \"submodule.alternateErrorStrategy\" on a superproject.\n\n\nIf \"submodule.alternateLocation\" is configured to \"superproject\" on a superproject, whenever a submodule of that superproject is cloned, it instead computes the analogous alternate path for that submodule from $GIT_DIR/objects/info/alternates of the superproject, and references it.\nThe \"submodule.alternateErrorStrategy\" option determines what happens if that alternate cannot be referenced.\nHowever, it is not clear that the clone proceeds as if no alternate was specified when that option is not set to \"die\" (as can be seen in the tests in 31224cbdc7).\nTherefore, document it accordingly.\n\nThe config submodule documentation now includes:\n\nsubmodule.alternateErrorStrategy::\n\nSpecifies how to treat errors with the alternates for a submodule as computed via submodule.alternateLocation.\nPossible values are ignore, info, die.\nDefault is die.\nNote that if set to ignore or info, and if there is an error with the computed alternate, the clone proceeds as if no alternate was specified.\n\n\nNote: \"git submodule update --quiet\"(man) did not propagate the quiet option down to underlying git fetch(man), which has been corrected with Git 2.32 (Q2 2021).\nSee commit 62af4bd (30 Apr 2021) by Nicholas Clark (nwc10).\n(Merged by Junio C Hamano -- gitster -- in commit 74339f8, 11 May 2021)\n\nsubmodule update: silence underlying fetch with \"--quiet\"\nSigned-off-by: Nicholas Clark\n\n\nCommands such as\n$ git submodule update --quiet --init --depth=1\n\ninvolving shallow clones, call the shell function fetch_in_submodule, which in turn invokes git fetch.\nPass the --quiet option onward there." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Checkout to a specific folder\nI want to use something similar to:\ngit checkout -- <path>/<file>\n\nbut I want to checkout the file to some folder I choose, rather than the overwriting the local <path>/<file>.\nAny idea?" }, { "role": "assistant", "content": "Another solution which is a bit cleaner - just specify a different work tree.\nTo checkout everything from your HEAD (not index) to a specific out directory:\ngit --work-tree=/path/to/outputdir checkout HEAD -- .\n\nTo checkout a subdirectory or file from your HEAD to a specific directory:\ngit --work-tree=/path/to/outputdir checkout HEAD -- subdirname" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I generate a diff for a single file between two branches in github\nI need to generate a diff for a single file that will show the differences between two versions, which are actually tags in github. I then want to send this diff to someone via email so a github URL for the diff would be ideal. The github compare view will allow me to do this for all changed files, but that's no good as there are thousands of files in my repo.\nI can do this in the command line as follows, but this doesn't help as I need to send the diff to someone via email:\ngit diff tag1 tag2 -- path/to/file\n\nI found the command line version discussed here:\nhow can I see the differences in a designated file between a local branch and a remote branch?" }, { "role": "assistant", "content": "GitHub only exposes the way to show diff between two commits.\nProvided those tags actually point to commits, the Url format would be something like\nhttps://github.com/{user}/{repository}/compare/{from-tag}...{until-tag}\nAs an example, https://github.com/libgit2/libgit2sharp/compare/v0.9.0...v0.9.5 shows the diff between two versions of the LibGit2Sharp project. This diff includes all the modified files.\nIf you want to retrieve a URL that targets a specific file:\n\nSwitch to the Files Changed tab\n\n\n\nClick on the Show Diff Stats button (This will display the list of modified files as links)\n\n\n\nCopy to the clipboard the link of the specific file you're after... and Tada! You're done.\n\nFor instance, given the diff above, the link https://github.com/libgit2/libgit2sharp/compare/v0.9.0...v0.9.5#diff-11 will point to the LazyFixtures.cs changes that occured between version v0.9.0 and v0.9.5.\nUpdate\nFollowing your comment which states that your diff is too big to be rendered through the Web interface, how about reverting to good old command line tooling? You could redirect the output of the diff to a file and then send the file as an email attachment.\n$ git diff v0.9.0 v0.9.5 -- LibGit2Sharp.Tests/LazyFixture.cs > /tmp/lazyfixture.diff" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I remove deleted branch names from autocomplete?\nI used git branch -d myBranch to delete a branch. However, when I am on master and try to checkout a new branch with git checkout, myBranch still appears in the tab-autocomplete.\nHow do I remove the name myBranch from tab-autocomplete for git checkout?" }, { "role": "assistant", "content": "git fetch --prune --all\nPosting this as its own answer since it's a one-line fix, but if you vote be sure to vote for twalberg's answer.\ntwalberg's suggestion to git branch -a led me on the right track; my coworker suggested git fetch --prune --all to prune all the dead branches from all the remotes, which is useful when working with lots of devs with lots of forks." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs -U<n> --unified=<n>" }, { "role": "assistant", "content": "Generate diffs with <n> lines of context instead of\nthe usual three.\nImplies --patch ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-ls-tree - List the contents of a tree object" }, { "role": "assistant", "content": "DESCRIPTION Lists the contents of a given tree object, like what \"/bin/ls -a\" does\nin the current working directory. Note that: the behaviour is slightly different from that of \"/bin/ls\" in that the <path> denotes just a list of patterns to match, e.g. so specifying\ndirectory name (without -r ) will behave differently, and order of the\narguments does not matter. the behaviour is similar to that of \"/bin/ls\" in that the <path> is\ntaken as relative to the current working directory. E.g. when you are\nin a directory sub that has a directory dir , you can run git\nls-tree -r HEAD dir to list the contents of the tree (that is sub/dir in HEAD ). You don’t want to give a tree that is not at the\nroot level (e.g. git ls-tree -r HEAD:sub dir ) in this case, as that\nwould result in asking for sub/sub/dir in the HEAD commit.\nHowever, the current working directory can be ignored by passing\n--full-tree option." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "oh-my-zsh slow, but only for certain Git repo\nI recently started using Zsh and it's awesome. Unfortunately, for the project I consider my \"main\" project, everything is slow. What I mean is that every time I run a command - ls, for example - there's about a five-second delay between the time the command is executed and the time I can use the terminal again.\nWhat could be different about this one repo that makes Zsh so slow? I assume it's a Zsh-specific thing because there was no problem before I started using Zsh. I tried doing a git clean but it didn't make any noticeable difference.\nI'm on Mac OS X if that matters.\nUpdate: Turns out this line of my .zshenv is what was making it slow:\n[[ -s \"$HOME/.rvm/scripts/rvm\" ]] && . \"$HOME/.rvm/scripts/rvm\" # Load RVM function\n\nIf I comment that line, it goes from taking about 3 seconds to taking about 1 second. Unfortunately, I need that line, since many of my projects use RVM. I don't know what to do now.\nUpdate 2: this seems to be specifically an oh-my-zsh thing. If I don't load ~/.oh-my-zsh/oh-my-zsh.sh, I don't have a problem." }, { "role": "assistant", "content": "You can add this to your git config and zsh won't check the status anymore \ngit config --add oh-my-zsh.hide-status 1\ngit config --add oh-my-zsh.hide-dirty 1\n\n\nExplanation\nThere are two central git functions in in lib/git.zsh: \n\ngit_prompt_info()\nparse_git_dirty()\n\nEach Method has a git config switch to disable it:\n\noh-my-zsh.hide-status\noh-my-zsh.hide-dirty\n\nSome themes create their own git queries and sometimes ignore these flags." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git commit with no email\nI'am currently converting a svn repository into a git one. As I proceed manually, I regularly change the user.name and user.email to set the author of the commit. Everything seems to work fine, but now I have to commit something from a user which has no email address. I removed email property from .gitconfig file and tried, but then in git log, email field shows user_login@user_login.(none). Is it possible to set no email and prevent git guessing one ?" }, { "role": "assistant", "content": "I think that you can only do this with an explicit author specification:\ngit commit --author \"Snail Mail <>\"\n\nYou need the angle brackets so that git knows that you really are passing an empty email address." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git push existing repo to a new and different remote repo server?\n\nSay I have a repository on git.fedorahosted.org and I want to clone this into my account at github to have my own playground aside from the more \"official\" repo on fedorahosted.\nWhat would be the steps to initially copy that over?\nWithin github there is this nice \"fork\" button, but I can't use this for obvious reasons.\nAnd how would I track changes in the fedorahosted repo into the github one?" }, { "role": "assistant", "content": "Create a new repo at github.\nClone the repo from fedorahosted to your local machine.\ngit remote rename origin upstream\ngit remote add origin URL_TO_GITHUB_REPO\ngit push origin master\n\nNow you can work with it just like any other github repo. To pull in patches from upstream, simply run git pull upstream master && git push origin master.\nGitHub has recently renamed its master branch to main so (depending on whether your branch is called master or main) in step 5 you might have to use git push origin main and for pulling patches from upstream git pull upstream main && git push origin main, otherwise you will receive an error message." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options core.eol" }, { "role": "assistant", "content": "Sets the line ending type to use in the working directory for\nfiles that are marked as text (either by having the text attribute set, or by having text=auto and Git auto-detecting\nthe contents as text).\nAlternatives are lf , crlf and native , which uses the platform’s\nnative line ending. The default value is native . See gitattributes for more information on end-of-line\nconversion. Note that this value is ignored if core.autocrlf is set to true or input ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-worktree - Manage multiple working trees" }, { "role": "assistant", "content": "SYNOPSIS git worktree add [-f] [--detach] [--checkout] [--lock [--reason <string>]]\n\t\t [--orphan] [(-b | -B) <new-branch>] <path> [<commit-ish>] git worktree list [-v | --porcelain [-z]] git worktree lock [--reason <string>] <worktree> git worktree move <worktree> <new-path> git worktree prune [-n] [-v] [--expire <expire>] git worktree remove [-f] <worktree> git worktree repair [<path>…​] git worktree unlock <worktree>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gpg failed to sign the data fatal: failed to write commit object [Git 2.10.0]\n\nI followed few articles over the pretty attributes on Git 2.10 release note. Going through which upgraded the git to 2.10.0 and made changes to global .gitconfig resulting as follows - \n[filter \"lfs\"]\n clean = git-lfs clean %f\n smudge = git-lfs smudge %f\n required = true\n[user]\n name = xyz\n email = [email protected]\n signingkey = AAAAAAA\n[core]\n excludesfile = /Users/xyz/.gitignore_global\n editor = 'subl' --wait\n[difftool \"sourcetree\"]\n cmd = opendiff \\\"$LOCAL\\\" \\\"$REMOTE\\\"\n path = \n[mergetool \"sourcetree\"]\n cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \\\"$LOCAL\\\" \\\"$REMOTE\\\" -ancestor \\\"$BASE\\\" -merge \\\"$MERGED\\\"\n trustExitCode = true\n[alias]\n lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative\n[color \"diff\"]\n old = red strike\n new = green italic\n\nBut now that I try to sign my commits using \ngit commit -a -S -m \"message\"\n\nI get to see the following error - \n\nYou need a passphrase to unlock the secret key for \nuser: \"XYZ (Digitally Signed) \" \n2048-bit RSA key, ID AAAAAAAA, created 2016-07-01\nerror: gpg failed to sign the data fatal: failed to write commit\n object\n\nNote - I can still commit changes using git commit -a -m \"message\"\nIs there a way to overcome the same? Or any change required in gpg configs to get along with the upgradation of git?\n\nUpdate 1\nAlso seeking further usefulness, following Is there a way to \"autosign\" commits in Git with a GPG key?. I've already configured the key using \ngit config --global user.signingkey ED5CDE14(with my key) \ngit config --global commit.gpgsign true\n\nand quite obviously getting the same error anyway." }, { "role": "assistant", "content": "I ran into this issue with macOS.\nOriginal answer:\nIt seems like a gpg update (of brew) changed to location of gpg to gpg1, you can change the binary where git looks up the gpg:\ngit config --global gpg.program gpg1\n\nIf you don't have gpg1: brew install gpg1.\nUpdated answer:\nIt looks like gpg1 is being deprecated/\"gently nudged out of usage\", so you probably should actually update to gpg2, unfortunately this involves quite a few more steps/a bit of time:\nbrew upgrade gnupg # This has a make step which takes a while\nbrew link --overwrite gnupg\nbrew install pinentry-mac\necho \"pinentry-program $(brew --prefix)/bin/pinentry-mac\" >> ~/.gnupg/gpg-agent.conf\nkillall gpg-agent\n\nThe first part installs gpg2, and latter is a hack required to use it. For troubleshooting, see this answer (though that is about linux not brew), it suggests a good test:\necho \"test\" | gpg --clearsign # on linux it's gpg2 but brew stays as gpg\n\nIf this test is successful (no error/output includes PGP signature), you have successfully updated to the latest gpg version.\nYou should now be able to use git signing again!\nIt's worth noting you'll need to have:\ngit config --global gpg.program gpg # perhaps you had this already? On linux maybe gpg2\ngit config --global commit.gpgsign true # if you want to sign every commit\n\nNote: After you've run a signed commit, you can verify it signed with:\ngit log --show-signature -1\n\nwhich will include gpg info for the last commit." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "In Git, what does `--` (dash dash) mean?\nWhen reading the man pages for Git commands, you will often see an optional -- (dash dash). In my experience, the -- is not necessary and makes no difference. When do you need it? What does it mean in general, given that it appears in so many commands?" }, { "role": "assistant", "content": "The double dash -- in git means different things to different commands, but in general it separates options from parameters.\nIn git specifically, the meaning of -- depends on which subcommand you are using it with. It usually separates subcommand arguments (like the branch name in git checkout) from revisions or filenames. Sometimes it is completely optional and used only to prevent an unusual filename from being interpreted as program options.\nFor Example\n\ngit checkout. To check out a \"commit\" (referred to as \"tree-ish\" in the manual, because you can actually specify a range of object types) you use\ngit checkout <commit>\nTo refine the checkout to just a file or two, use -- to separate the \"tree-ish\" parameters from the \"filenames\" you wish to check out.\n\ngit commit. To commit whatever is in the \"index\" (ie, what you have staged via git add, simply issue the git commit command.\ngit commit [-m message]\nTo ignore whatever you have added via git add and commit the changes in a specific file, use\ngit commit -- <filename>\n\ngit add. To commit a file whose name begins with a - or a --, you must tell git add to stop reading parameters, and start reading filenames; -- does that.\ngit add -- -sample.txt\n\ngit log. To see the commit history restricted to only commits affecting a file use\ngit log -- <filename>\n\n\nYou need to check the man pages for any git command you use if you need to understand its specific meaning." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters @{<n>} , e.g. @{1}" }, { "role": "assistant", "content": "You can use the @ construct with an empty ref part to get at a\nreflog entry of the current branch. For example, if you are on\nbranch blabla then @{1} means the same as blabla@{1} ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What do raw.githubusercontent.com URLs represent?\n\nI want to learn how to use rawgit.com to serve other applications from github.com.\nSo we have a usual way to download and install homebrew on osx.\nruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"\n\nI can't find the install file on GitHub. Where is it?" }, { "role": "assistant", "content": "The raw.githubusercontent.com domain is used to serve unprocessed versions of files stored in GitHub repositories. If you browse to a file on GitHub and then click the Raw link, that's where you'll go.\nThe URL in your question references the install file in the master branch of the Homebrew/install repository. The rest of that command just retrieves the file and runs ruby on its contents." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker HEAD" }, { "role": "assistant", "content": "indicates the head of the current branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to view the committed files you have not pushed yet?\n\nFor example I commit some files, the next day some more files, and so on. After some days I want to view all my committed files and view their difference with the remote repo. Note that I have not pushed anything. I just want to verify that if I push some thing then it will go to the remote repo as I expect." }, { "role": "assistant", "content": "Assuming you're on local branch master, which is tracking origin/master:\ngit diff --stat origin/master.." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "On GitHub, what's the difference between reviewer and assignee?\n\nA feature added on Dec, 7, 2016, announced on GitHub blog, introduced the option to add reviewers to a Pull Request\n\n\nYou can now request a review explicitly from collaborators, making it easier to specify who you'd like to review your pull request.\nYou can also see a list of people who you are awaiting review from in the pull request page sidebar, as well as the status of reviews from those who have already left them.\n\nHowever, explicit setting a reviewer for a PR was already done by assigning people (assignees option).\nWith both options now available, what's the role of each option since they both share the same end goal?" }, { "role": "assistant", "content": "EDIT:\n\nAfter discussing with several OSS maintainers, reviewers is defined as what the word supposed to be: to review (someone's code) and \"assignee\" has a looser definiton explained below.\n\nFor \"reviewer\": someone you want to review the code. Not necessarily the person responsible for that area or responsible for merging the commit. Can be someone who worked on that chunk of code before, as GitHub auto-suggests.\nFor \"assignee\": up to the project's team/maintainer what it means and there's no strict definition. It can be the PR opener, or someone responsible for that area (who is going to accept the PR after the review is done or just close it). It's not up to GitHub to define what it is leaving it open for project maintainers what fits best for their project.\nPrevious answer:\nOk I'll go ahead and answer my own question.\nFor PR of users with write-access: the Assignee would be the same person who opened the PR, and reviewer would replace the old assignee function (reviewing code), being this one someone of assignee choice.\nFor PR of users without write-access (outside contributors): Someone with write-access would assign herself (or other write-priviledge member), to review the PR (Reviewer). Assignee is blank.\nFor unfinished PR from outside contributors: the write-access member would take the unfinished work and assign for her. She will be responsible for finishing the task, being the Assignee. Since the main reason of PRs is reviewing changes, she would select some other people to review the changes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I add files and folders into GitHub repos?\n\nI created an account on GitHub and I'm facing a problem with adding files. I have added readme.txt. Also, I have 3 other PHP files and a folder including images.\nHow do I add the files and folder? I tried it with git pull because git push origin -u master showed me an error." }, { "role": "assistant", "content": "You can add files using git add, example git add README, git add <folder>/*, or even git add *\nThen use git commit -m \"<Message>\" to commit files\nFinally git push -u origin master to push files.\nWhen you make modifications run git status which gives you the list of files modified, add them using git add * for everything or you can specify each file individually, then git commit -m <message> and finally, git push -u origin master\nExample - say you created a file README, running git status gives you\n$ git status\n# On branch master\n# Untracked files:\n# (use \"git add <file>...\" to include in what will be committed)\n#\n# README\n\nRun git add README, the files are staged for committing. Then run git status again, it should give you - the files have been added and ready for committing.\n$ git status\n# On branch master\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# new file: README\n#\n\nnothing added to commit but untracked files present (use \"git add\" to track)\n\nThen run git commit -m 'Added README'\n$ git commit -m 'Added README'\n[master 6402a2e] Added README\n 0 files changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 README\n\nFinally, git push -u origin master to push the remote branch master for the repository origin.\n$ git push -u origin master\nCounting objects: 4, done.\nDelta compression using up to 2 threads.\nCompressing objects: 100% (2/2), done.\nWriting objects: 100% (3/3), 267 bytes, done.\nTotal 3 (delta 1), reused 0 (delta 0)\nTo [email protected]:xxx/xxx.git\n 292c57a..6402a2e master -> master\nBranch master set up to track remote branch master from origin.\n\nThe files have been pushed successfully to the remote repository.\nRunning a git pull origin master to ensure you have absorbed any upstream changes\n$ git pull origin master\nremote: Counting objects: 12, done.\nremote: Compressing objects: 100% (4/4), done.\nremote: Total 8 (delta 4), reused 7 (delta 3)\nUnpacking objects: 100% (8/8), done.\nFrom xxx.com:xxx/xxx\n * branch master -> FETCH_HEAD\nUpdating e0ef362..6402a2e\nFast-forward\n public/javascript/xxx.js | 5 ++---\n 1 files changed, 2 insertions(+), 3 deletions(-)\n create mode 100644 README\n\nIf you do not want to merge the upstream changes with your local repository, run git fetch to fetch the changes and then git merge to merge the changes. git pull is just a combination of fetch and merge.\nI have personally used gitimmersion - http://gitimmersion.com/ to get upto curve on git, its a step-by-step guide, if you need some documentation and help" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Resync git repo with new .gitignore file\nIs it possible to \"refresh\" a git repository after updating the gitignore file?\nI just added more ignorations(?) to my gitignore and would like to remove stuff already in the repo matching the new file." }, { "role": "assistant", "content": "The solution mentioned in \".gitignore file not ignoring\" is a bit extreme, but should work:\n# rm all files\ngit rm -r --cached .\n# add all files as per new .gitignore\ngit add .\n# now, commit for new .gitignore to apply\ngit commit -m \".gitignore is now working\"\n\n(make sure to commit first your changes you want to keep, to avoid any incident as jball037 comments below.\nThe --cached option will keep your files untouched on your disk though.)\nYou also have other more fine-grained solution in the blog post \"Making Git ignore already-tracked files\":\ngit rm --cached `git ls-files -i --exclude-standard`\n\n\nBassim suggests in his edit:\nFiles with space in their paths\n\nIn case you get an error message like fatal: path spec '...' did not match any files, there might be files with spaces in their path.\nYou can remove all other files with option --ignore-unmatch:\n\ngit rm --cached --ignore-unmatch `git ls-files -i --exclude-standard`\n\n\nbut unmatched files will remain in your repository and will have to be removed explicitly by enclosing their path with double quotes:\n\ngit rm --cached \"<path.to.remaining.file>\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options difftool.guiDefault" }, { "role": "assistant", "content": "Set true to use the diff.guitool by default (equivalent to specifying\nthe --gui argument), or auto to select diff.guitool or diff.tool depending on the presence of a DISPLAY environment variable value. The\ndefault is false , where the --gui argument must be provided\nexplicitly for the diff.guitool to be used." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-merge - Join two or more development histories together --edit -e --no-edit" }, { "role": "assistant", "content": "Invoke an editor before committing successful mechanical merge to\n\tfurther edit the auto-generated merge message, so that the user\n\tcan explain and justify the merge. The --no-edit option can be\n\tused to accept the auto-generated message (this is generally\n\tdiscouraged).\nThe --edit (or -e ) option is still useful if you are\ngiving a draft message with the -m option from the command line\nand want to edit it in the editor. Older scripts may depend on the historical behaviour of not allowing the\nuser to edit the merge log message. They will see an editor opened when\nthey run git merge . To make it easier to adjust such scripts to the\nupdated behaviour, the environment variable GIT_MERGE_AUTOEDIT can be\nset to no at the beginning of them." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GIT pull error - remote object is corrupted\n$ git pull\n\nremote: fatal: object 21f3981dd35fccd28febabd96f27241eea856c50 is corrupted\nerror: git upload-pack: git-pack-objects died with error.\nfatal: git upload-pack: aborting due to possible repository corruption on the remote side.\nremote: aborting due to possible repository corruption on the remote side.\nfatal: protocol error: bad pack header\n\nAny ideas why this is failing?\nWhen I run git --bare fsck-objects --full I just see dangling links but no broken links. Also git gc didn't help in any way. When I reclone or do pull from another clone, I don't see this error." }, { "role": "assistant", "content": "As Julian said see https://confluence.atlassian.com/display/FISHKB/Git+indexing+fails+due+to+bad+pack+header\nIt really can be a memory issue, and to make sure we don't lose the solution here it is:\ngit config --global pack.windowMemory \"100m\"\ngit config --global pack.SizeLimit \"100m\" \ngit config --global pack.threads \"1\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --first-parent" }, { "role": "assistant", "content": "When finding commits to include, follow only the first\nparent commit upon seeing a merge commit. This option\ncan give a better overview when viewing the evolution of\na particular topic branch, because merges into a topic\nbranch tend to be only about adjusting to updated upstream\nfrom time to time, and this option allows you to ignore\nthe individual commits brought in to your history by such\na merge. This option also changes default diff format for merge commits\nto first-parent , see --diff-merges=first-parent for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to discard uncommitted changes in SourceTree?\nI'm new to the Git environment, and I'm using BitBucket with SourceTree on Mac. All I want to do now is to discard the changes since last commit. How should I do this? I haven't found anything like \"discard changes\", and directly pulling from the last commit doesn't seem to work. Solutions done with either the GUI or command line will be good." }, { "role": "assistant", "content": "On SourceTree for Mac, right click the files you want to discard (in the Files in the working tree list), and choose Reset.\nOn SourceTree for Windows, right click the files you want to discard (in the Working Copy Changes list), and choose Discard.\nOn git, you'd simply do:\ngit reset --hard to discard changes made to versioned files;\ngit clean -xdf to erase new (untracked) files, including ignored ones (the x option). d is to also remove untracked directories and f to force." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Best practices for storing kubernetes configuration in source control [closed]\nClosed. This question is opinion-based. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it can be answered with facts and citations by editing this post.\n\n\nClosed 3 years ago.\n\n\nThe community reviewed whether to reopen this question 2 years ago and left it closed:\n\nOriginal close reason(s) were not resolved\n\n\n\n\n\n\n Improve this question\n \n\n\n\nIn several places on the Kubernetes documentation site they recommend that you store your configuration YAML files inside source control for easy version-tracking, rollback, and deployment. \nMy colleagues and I are currently in the process of trying to decide on the structure of our git repository. \n\nWe have decided that since configuration can change without any changes to the app code, that we would like to store configurations in a separate, shared repository.\nWe may need multiple versions of some components running side-by-side within a given environment (cluster). These versions may have different configurations.\n\nThere seem to be a lot of potential variations, and all of them have shortcomings. What is the accepted way to structure such a repository?" }, { "role": "assistant", "content": "There is no established standard yet, I believe. I find helm's charts too complicated to start with, especially having another unmanaged component running on the k8s cluster. This is a workflow that we follow that works quite well for a setup of 15ish microservices, and 5 different environments (devx2, staging, qa, prod).\nThe 2 key ideas:\n\nStore kubernetes configurations in the same source repo that has the\nother build tooling. Eg: alongside the microservice source code which has the tooling for building/releasing that particular microservice. \nTemplate the kubernetes configuration with something like jinja and render the templates according to the environment you're targeting.\n\nThe tooling is reasonably straightforward to figure out by putting together a few bash scripts or integrating with a Makefile etc.\nEDIT: to answer some of the questions in the comment\nThe application source code repository is used as the single source of truth. So that means that if everything works as it should, changes should never be moved from the kubernetes cluster to the repository.\nChanges directly on the server are prohibited in our workflow. If it ever does happen, we have to manually make sure they enter the application repository again.\nAgain, just want to note that the configurations stored in the source code are actually templates and use secretKeyRef quite liberally. This means that some configurations are coming in from the CI tooling as they are rendered and some are coming in from secrets that live only on the cluster (like database passwords, API tokens etc.)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Should I use SVN or Git? [closed]\nAs it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.\n \n \n\n\n\nClosed 12 years ago.\n\n\n\nI am starting a new distributed project. Should I use SVN or Git, and why?" }, { "role": "assistant", "content": "SVN is one repo and lots of clients. Git is a repo with lots of client repos, each with a user. It's decentralised to a point where people can track their own edits locally without having to push things to an external server.\nSVN is designed to be more central where Git is based on each user having their own Git repo and those repos push changes back up into a central one. For that reason, Git gives individuals better local version control. \nMeanwhile you have the choice between TortoiseGit, GitExtensions (and if you host your \"central\" git-repository on github, their own client – GitHub for Windows).\nIf you're looking on getting out of SVN, you might want to evaluate Bazaar for a bit. It's one of the next generation of version control systems that have this distributed element. It isn't POSIX dependant like git so there are native Windows builds and it has some powerful open source brands backing it.\nBut you might not even need these sorts of features yet. Have a look at the features, advantages and disadvantages of the distributed VCSes. If you need more than SVN offers, consider one. If you don't, you might want to stick with SVN's (currently) superior desktop integration." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I determine the source branch of a particular branch?\nI have a branch in git and want to figure out from what branch it originally was branched and at what commit.\nGithub seems to know, since when you do a pull request it usually automatically sets up what branch it should go into, but I can't figure out how to do this manually from the command line.\nLet me add a concrete example:\nmaster -- ongoing development\n2.2 -- stable maintenance\n\nA feature branch feature was created (at commit B below) and worked on (B', C' & E') and merged against the source branch to pick up C and D\n feature branch: B'-C'-C--D--E'\n / / \n source branch: A--B--C--D--E-- ...\n\nNow I want to merge feature back into its source, but I am not sure whether it was originally a branch off master or 2.2. In order to merge the feature into the correct source, is there a programmatic way to find out if source branch is master or 2.2?" }, { "role": "assistant", "content": "Git only tracks \"upstream\" information in individual repositories and this information is not static nor shared between separate clones of the same repository.\nThe command to set this relationship from the command line is:\ngit branch --set-upstream <branch> [<start-point>]\n\nLooking at the output of git-diff might give you a clue:\ngit diff <mybranch>..master # commits in master that are not in mybranch\ngit diff <mybranch>..2.2 # commits in 2.2 that are not in mybranch\n\nIt is likely that the one with fewer commits listed is the branch point (but that is not guaranteed, obviously.\nYou can also use gitk, or git log to take a look around:\ngitk --all\ngit log --graph --color --decorate --oneline --all" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_ALLOW_PROTOCOL" }, { "role": "assistant", "content": "If set to a colon-separated list of protocols, behave as if protocol.allow is set to never , and each of the listed\nprotocols has protocol.<name>.allow set to always (overriding any existing configuration). See the description of protocol.allow in git-config for more details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-shortlog - Summarize git log output --single-worktree" }, { "role": "assistant", "content": "By default, all working trees will be examined by the\nfollowing options when there are more than one (see git-worktree ): --all , --reflog and --indexed-objects .\nThis option forces them to examine the current working tree\nonly." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git svn-remote.<name>.automkdirs" }, { "role": "assistant", "content": "Normally, the \"git svn clone\" and \"git svn rebase\" commands\nattempt to recreate empty directories that are in the\nSubversion repository. If this option is set to \"false\", then\nempty directories will only be created if the \"git svn mkdirs\"\ncommand is run explicitly. If unset, git svn assumes this\noption to be \"true\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitfaq - Frequently asked questions about using Git I’m on Windows and git diff shows my files as having a ^M at the end." }, { "role": "assistant", "content": "By default, Git expects files to be stored with Unix line endings. As such,\nthe carriage return ( ^M ) that is part of a Windows line ending is shown\nbecause it is considered to be trailing whitespace. Git defaults to showing\ntrailing whitespace only on new lines, not existing ones. You can store the files in the repository with Unix line endings and convert\nthem automatically to your platform’s line endings. To do that, set the\nconfiguration option core.eol to native and see the following entry for\ninformation about how to configure files as text or binary. You can also control this behavior with the core.whitespace setting if you\ndon’t wish to remove the carriage returns from your line endings." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-grep - Print lines matching a pattern -o --only-matching" }, { "role": "assistant", "content": "Print only the matched (non-empty) parts of a matching line, with each such\npart on a separate output line." } ]