messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: How to squash all commits on branch\nI make new branch from master with: \ngit checkout -b testbranch\n\nI make 20 commits into it.\nNow I want to squash those 20 commits. I do that with:\ngit rebase -i HEAD~20\n\nWhat about if I don't know how many commits? Is there any way to do something like:\ngit rebase -i all on this branch" }, { "role": "assistant", "content": "Another way to squash all your commits is to reset the index to master:\n\nNote: Git's default branch name is still master with Git version 2.41 (Q3 2023), as seen in git init man page.\nGit version 2.28 (Q3 2020) introduced configurable default branch names, which means your remote repository may optionally use another default branch name such as main. In order to provide the most universally applicable examples, as well as avoid confusion, this answer shall assume Git's default configuration.\nIf you need the following commands to work for any default branch, replace master with ${defaultBranch}.\nAnd define defaultBranch=$(git config --get init.defaultBranch || echo main).\n\nBack to the solution: (to squash all your commit) reset the index to master:\ngit checkout yourBranch\ngit reset $(git merge-base master $(git branch --show-current))\ngit add -A\ngit commit -m \"one commit on yourBranch\"\n\nThis isn't perfect as it implies you know from which branch \"yourBranch\" is coming from.\nNote: finding that origin branch isn't easy/possible with Git (the visual way is often the easiest, as seen here).\nNote: git branch --show-current has been introduced with Git 2.22 (Q2 2019).\n\nOr, as noted by Hiroki Osame in the comments:\ngit switch yourBranch\ngit reset --soft $(git merge-base master HEAD)\ngit commit -m \"one commit on yourBranch\"\n\n\nno need for git branch --show-current since HEAD is already a reference to that branch.\nno need for git add -A, since git reset --soft only moves HEAD, and leaves the index untouched (in other words, the files are already \"added\").\n\n\nEDIT: you will need to use git push --force (or git push --force-with-lease)\nSee \"git push --force-with-lease vs. --force\"\n\nKarlotcha Hoa adds in the comments:\n\nFor the reset, you can do\ngit reset $(git merge-base master $(git rev-parse --abbrev-ref HEAD)) \n\n[That] automatically uses the branch you are currently on.\nAnd if you use that, you can also use an alias, as the command doesn't rely on the branch name." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Undo a particular commit in Git that's been pushed to remote repos\nWhat is the simplest way to undo a particular commit that is:\n\nnot in the head or HEAD\nHas been pushed to the remote.\n\nBecause if it is not the latest commit, \ngit reset HEAD\n\ndoesn't work. And because it has been pushed to a remote,\ngit rebase -i\n\nand\ngit rebase --onto\n\nwill cause some problem in the remotes. \nMore so, I don't want to modify the history really. If there was bad code, it was there in the history and can be seen. I just want it out in the working copy, and I don't mind a reverse merge commit.\nIn other words, what is the Git equivalent of the following svn commands:\nsvn merge -r 303:295 http://svn.example.com/repos/calc/trunk\n\nwhich removes all changes from 295 to 302 by reverse merging all changes in those revisions, as a new commit.\nsvn merge -c -302 ^/trunk\n\nwhich undoes the 302 commit, of course by adding another commit that reverse merges the changes from that respective commit.\nI thought it should be a fairly simple operation in Git and a fairly common use case. What else is the point of atomic commits? \nWe have staging stashing and all to ensure the commits are perfectly atomic, shouldn't you be able to undo one or more of those atomic commits easily?" }, { "role": "assistant", "content": "Identify the hash of the commit, using git log, then use git revert <commit> to create a new commit that removes these changes. In a way, git revert is the converse of git cherry-pick -- the latter applies the patch to a branch that's missing it, the former removes it from a branch that has it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-daemon - A really simple server for Git repositories --timeout=<n>" }, { "role": "assistant", "content": "Timeout (in seconds) for specific client sub-requests. This includes\nthe time it takes for the server to process the sub-request and the\ntime spent waiting for the next client’s request." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Generate diff file of a specific commit in Git\nWhen the head is at a particular commit, I want to get a diff file so that I can reduce the head to one more level down and then try the testing functionality with and without applying the diff file. So is there a way to generate a diff file of a specific commit.\nEven though there is a way to change the head before and after commit, this method comes in more handy." }, { "role": "assistant", "content": "See the changes of a specific commit:\ngit diff <commit-sha> -p\n\nOr,\ngit show --decorate <commit-sha> # See 'Author', 'Date' and 'diff'\n\nSee the diff of two commits:\ngit diff <commit1> <commit2>\n\nSee the file changes for a specific commit:\ngit show <commit>:<file>\n\nSee all the changes for a time duration (say, 1 day):\ngit whatchanged --since=\"1 day ago\" -p\ngit whatchanged --since=\"1 day ago\" -p <file> # See changes for a specific file only" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Hanging at \"POST git-receive-pack (chunked)\"\nI will be honest, I know very little about the internals of git.\nI have staged and commit a 40mb directory, but when I come to push...\n$ git push --verbose --progress\nPushing to https://[email protected]/acron0/project.git\nPassword for 'https://[email protected]':\nPOST git-receive-pack (chunked)\n\nIt's been like this for 20 minutes. I am assuming it's hanging but...is there anything I can do to find out why?" }, { "role": "assistant", "content": "This is a bug in Git; when using HTTPS it will use chunked encoding for uploads above a certain size. Those do not work.\nA trivial fix is to tell git to not chunk until some ridiculously large size value, such as:\ngit config http.postBuffer 524288000" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Mercurial (and, I guess Git) with Dropbox: any drawbacks?\nI have a Mercurial repository for a personal project, and I have been storing the master repository in my Dropbox for a few weeks now (something along this line; and I understand it's also possible with git). \nThe idea is that it serves both as a way to work with multiple machines and as a remote backup. I clone the repository and work on the non-Dropbox copy, and only push updates once in a while, the same way I would, I suppose, work with Bitbucket. \nCan you think of any drawbacks to this idea, compared to using dedicating hosting (BitBucket in the case of Mercurial)? I know Bitbucket has free accounts for single users, which is great, but they are limited to 150M, which isn't a huge. \nIn particular, is it possible that Dropbox's sync process would corrupt the repository? I had to run hg recover once on the master repository, but it might be unrelated (and anyway it happily recovered). Does anyone have a bad experience with the idea? Does anyone have a longer good experience and can alleviate my worries? Does anyone have an opinion based on better understanding of the internals of these things?\nedit: I added some clarifications to the questions. They are in italics." }, { "role": "assistant", "content": "I'd advise against it for the reasons stated above, but more strenuously stated. Both mercurial and git have their own protocols for moving changesets between repositories. These protocols are optimized/built for:\n\nefficiency\nconsistency (never can you pull from a repo in a half-updated state)\nhooks/triggers -- doing things on push/pull including quality (no tabs allowed, etc.) filters\n\nWhen you just let a directory sync handle the keeping of the .hg (or .git) directories in sync then during that sync you've got a remote store that's in an inconsistent state and doesn't know it.\nAdditionally both hg and git have a separation of what's local-only and what's remote-okay within their disk state. They know what info to share (example: commited changesets) and what not to (example: current, local working directory parent revision).\nIn other answers folks are saying \"you'll probably be fine\" or \"I've never had a problem\" and that's likely true, but it's not guaranteed true, and revision control isn't a place to play the odds. Use the proper, better, safer, more efficient, more full featured synchronization protocol for your source control system." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-ls-files - Show information about files in the index and the working tree --deduplicate" }, { "role": "assistant", "content": "When only filenames are shown, suppress duplicates that may\ncome from having multiple stages during a merge, or giving --deleted and --modified option at the same time.\nWhen any of the -t , --unmerged , or --stage option is\nin use, this option has no effect." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub: \"failed to connect to github 443 windows/ Failed to connect to gitHub - No Error\"\n\nI installed Git to get the latest version of Angular. When I tried to run\ngit clone https://github.com/angular/angular-phonecat.git\n\nI got:\n\nfailed to connect to github 443 error\n\nI even tried\ngit clone git://github.com/angular/angular-phonecat.git\n\nThat gave me\n\nfailed to connect no error message\n\nI am behind my company firewall. I can not see my proxy details when I go to Control Panel → Internet Options → Connections → LAN setting. The IT guys are not sharing proxy information with me. What can do?\n\nI finally managed to do it. I will update the procedure that I had taken in order to.\nI just wanted to compile all the steps that I did to get it to work." }, { "role": "assistant", "content": "Well, I did the following steps\n\nGoogle the error\n\nGot to SO links (here, here) which suggested the same thing that I have to update the Git configuration for proxy setting\n\nDamn, I can not see proxy information from Control Panel. The IT guys must have hidden it. I can not even change the setting to not to use a proxy.\n\nI found this wonderful tutorial of finding which proxy your are connected to\n\nUpdated the http.proxy key in the Git configuration by the following command\ngit config --global http.proxy http[s]://userName:password@proxyaddress:port\n\n\nError - \"could not resolve proxy some@proxyaddress:port\". It turned out my password had a @ symbol in it.\n\nEncode @ in your password to %40, because Git splits the proxy setting by @\n\nIf your userName is an email address, which has @, also encode it to %40. (see this answer)\n git config --global http.proxy http[s]://userName(encoded):password(encoded)@proxyaddress:port\n\n\n\nBaam! It worked!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I stop Git from tracking any changes to a file from this commit forward?\nI have a database configuration file that has default values that are unimportant. However, any changes to this file would contain sensitive information that should not be tracked in the repo. \nI would like future pulls of the Git repository to include the default version but disregard any changes made by any user. \nThe following keeps a local configuration but pushes the delete to the repo resulting in issues for future pulls.\ncat \"app/dir/config.file\" >> .gitignore\ngit rm --cached app/dir/config.file\n\nThe following does the job but does not persist past the push to the repo.\ngit update-index --assume-unchanged app/dir/config.file\n\nThis seems like a common requirement for version control around sensitive information but I can't seem to find a solution." }, { "role": "assistant", "content": "As usual github has a great doc on this.\nhttps://help.github.com/articles/ignoring-files#ignoring-versioned-files\nHere's the relevant snippet:\n\nIgnoring versioned files\nSome files in a repository change often but are rarely committed. Usually, these are various local configuration files that are edited, but should never be committed upstream. Git lets you ignore those files by assuming they are unchanged.\n\nIn Terminal, navigate to the location of your Git repository.\nRun the following command in your terminal:\n\ngit update-index --assume-unchanged path/to/file.txt\nOnce you mark a file like this, Git completely ignores any changes on it. It will never show up when running git status or git diff, nor will it ever be committed.\nTo make Git track the file again, simply run:\ngit update-index --no-assume-unchanged path/to/file.txt." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "how to make pull requests *without* a github account?\n\nOne of the goals of git is to be decentralized. If Github is to be the ... hub of git, then maybe it could take into account that there are other hubs out there, and allow pull requests to happen on git URLs that are not hosted on github.\nThe documentation is fairly clear about this: pull requests require that you have a Github account and that you fork a repository on github. Is this a real current technical limitation or is there a way to workaround that on Github?\nIf not, is it eventually planned to allow Github's \"pull requests\" tool to actually allow to pull from repositories outside of the Github silo?" }, { "role": "assistant", "content": "You can use git request-pull to achieve the same kind of workflow (which is improved with Git1.7.9+).\nSee the article \"using signed tag in pull-requests\"\n\nA typical distributed workflow using Git is for a contributor to fork a project, build on it, publish the result to her public repository, and ask the \"upstream\" person (often the owner of the project where she forked from) to pull from her public repository. Requesting such a \"pull\" is made easy by the git request-pull command.\n\n\nStarting from Git release v1.7.9, a contributor can add a signed tag to the commit at the tip of the history and ask the integrator to pull that signed tag.\nWhen the integrator runs git pull:\n\n\n\nthe signed tag is automatically verified to assure that the history is not tampered with.\n\n\n\nIn addition, the resulting merge commit records the content of the signed tag, so that other people can verify that the branch merged by the integrator was signed by the contributor, without fetching the signed tag used to validate the pull request separately and keeping it in the refs namespace.\n\n\nWith Git 2.40 (Q1 2023), \"git request-pull\"(man) can strip embedded signature from signed tags using non-PGP signatures.\nSee commit a9cad02 (25 Jan 2023) by Gwyneth Morgan (gwymor).\n(Merged by Junio C Hamano -- gitster -- in commit ad7fd3c, 08 Feb 2023)\n\nrequest-pull: filter out SSH/X.509 tag signatures\nSigned-off-by: Gwyneth Morgan\n\n\ngit request-pull(man) filters PGP signatures out of the tag message, but not SSH or X.509 signatures." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_TRACE2_PERF" }, { "role": "assistant", "content": "In addition to the text-based messages available in GIT_TRACE2 , this\nsetting writes a column-based format for understanding nesting\nregions.\nSee GIT_TRACE2 for available trace output options and Trace2 documentation for full details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "ssh: connect to host bitbucket.org port 22: Connection timed out\nEverything was working perfectly fine. Did some git pushes with no problems.\nToday I decided to update my framework to the latest version, so it changed the directory structure of my project a bit. So within Bitbucket, I created a new repository (dev1.project.com) and renamed my project's folder from OldName to dev1.project.com.\nI edited .git/config to point my new repository:\n[core]\n repositoryformatversion = 0\n filemode = true\n bare = false\n logallrefupdates = true\n[branch \"master\"]\n[remote \"origin\"]\n url = https://bitbucket.org/user/dev1.project.com.git\n fetch = +refs/heads/*:refs/remotes/origin/*\n\nWhen I do git remote -v, I get :\norigin ssh://[email protected]/user/dev1.project.com.git (fetch)\norigin ssh://[email protected]/user/dev1.project.com.git (push)\n\nI go back to my project folder, and type:\ngit init\ngit add . \ngit commit -m 'my first commit'\ngit push -u origin master\n\nbut I keep getting the following error:\nssh: connect to host bitbucket.org port 22: Connection timed out\nfatal: The remote end hung up unexpectedly\n\nThe command ssh -T [email protected] gets me the same messages as above.\nThe command: git config --get remote.origin.url shows:\n[email protected]:user/dev1.project.com.git\n\nstatus.bitbucket.org shows that everything works fine on their side.\nNot sure why it was working before, and not working now.\nI'm on CentOS and i'm not sure what I should do next. I've seen a couple iptables-related answers, so I tried this:\niptables -t filter -A OUTPUT -p tcp --match multiport --dport 22 -j ACCEPT\n\nservice iptables stop\nservice ip6tables stop\nservice sshd reload\nservice iptables start\nservice ip6tables start\n\nBut still nothing, any ideas?\nPs: I've also updated CentOS from 6.6 to 6.7 and PHP 5.4 to 5.6, but didn't think it would matter.\nUpdate #1\nRan the following commands:\nps x | grep ssh-agent\neval `ssh-agent -s`\nssh-add # then it asked for my password\n\nGot the message:\nIdentity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)\n\nThen\nservice sshd restart\n\nBut still nothing\nUpdate #2\nI email my VPS hosting company, asking if there is anything I can do to open port 22, and they answered:\n\nI have disabled the monitoring system on the host node blocking traffic to Bitbucket.\n\nI don't know what it means, but everything was working after that, and apparently I couldn't do anything about it." }, { "role": "assistant", "content": "I have done below mentioned things and it started working.\n vim ~/.ssh/config\n\nAdd these lines and save it.\nHost bitbucket.org\n Hostname altssh.bitbucket.org\n Port 443\n\nFor Windows:\n\nGo to the place where your .ssh folder is located (run %USERPROFILE%).\n\nopen the .ssh folder and create a file with the name config without any extension.\n\nPaste the below content and save it.\nHost github.com\n Hostname ssh.github.com\n Port 443\n\nHost bitbucket.org\n Hostname altssh.bitbucket.org\n Port 443" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I update or sync a forked repository on GitHub?\n\nI forked a project, made changes, and created a pull request which was accepted. New commits were later added to the repository. How do I get those commits into my fork?" }, { "role": "assistant", "content": "In your local clone of your forked repository, you can add the original GitHub repository as a \"remote\". (\"Remotes\" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:\n# Add the remote, call it \"upstream\":\n\ngit remote add upstream https://github.com/whoever/whatever.git\n\n# Fetch all the branches of that remote into remote-tracking branches\n\ngit fetch upstream\n\n# Make sure that you're on your main branch:\n\ngit checkout main\n\n# Rewrite your main branch so that any commits of yours that\n# aren't already in upstream/main are replayed on top of that\n# other branch:\n\ngit rebase upstream/main\n\nIf you don't want to rewrite the history of your main branch, (for example because other people may have cloned it) then you should replace the last command with git merge upstream/main. However, for making further pull requests that are as clean as possible, it's probably better to rebase.\n\nIf you've rebased your branch onto upstream/main you may need to force the push in order to push it to your own forked repository on GitHub. You'd do that with:\ngit push -f origin main\n\nYou only need to use the -f the first time after you've rebased." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Installing gitLab missing modernizer?\n\nI try to install gitlab on debian with this turotial: https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md \nI'm at step \"Install Gems\" and try to run: \nsudo -u git -H bundle install --deployment --without development test postgres aws\n\ni get this echo: \nFetching source index from https://rubygems.org/\nCould not find modernizr-2.6.2 in any of the sources\n\nI don't find a solution for this error I run it as root as well.\nThanks for help." }, { "role": "assistant", "content": "I ran into this same problem a few minutes ago. Looks like the classy folks behind Modernizr's Rubygem yanked the most recent versions. You can download the latest gem (Modernizr-2.5.2 as required in the docs there) running the following command inside your /home/git/gitlab directory:\nwget http://rubygems.org/downloads/modernizr-2.6.2.gem\n\nThen, go ahead and run gem install modernizr (without changing directories) and the utility will search in the local directory for the gem file before trying to fetch it remotely. This is the gem we're looking for.\nNOTE: It looks like some people are still having problems with this solution, so something else we can do is replace a few lines in Gemfile and Gemfile.lock (both on /home/git/gitlab), switching modernizr for modernizr-rails:\n\nin Gemfile, line 164, change \"modernizr\", \"2.6.2\" to \"modernizr-rails\", \"2.7.1\" \nin Gemfile.lock, line 292, change modernizr (2.6.2) to modernizr-rails (2.7.1) \nin Gemfile.lock, line 626, change modernizr (= 2.6.2) to modernizr-rails (= 2.7.1)\n\nThis second solution is thanks to csj4032 on Github." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database missingObject" }, { "role": "assistant", "content": "(ERROR) Missing object line in tag object." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options pack.writeBitmaps (deprecated)" }, { "role": "assistant", "content": "This is a deprecated synonym for repack.writeBitmaps ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --diff-algorithm={patience|minimal|histogram|myers}" }, { "role": "assistant", "content": "Choose a diff algorithm. The variants are as follows: default , myers The basic greedy diff algorithm. Currently, this is the default. minimal Spend extra time to make sure the smallest possible diff is\nproduced. patience Use \"patience diff\" algorithm when generating patches. histogram This algorithm extends the patience algorithm to \"support\nlow-occurrence common elements\". For instance, if you configured the diff.algorithm variable to a\nnon-default value and want to use the default one, then you\nhave to use --diff-algorithm=default option." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can I revert commits directly on GitHub?\n\nIt seems like you can do just about everything else directly on GitHub using the web interface, like edit and create and delete files, but I am unable to find a way to revert a commit, like you can in the GitHub local apps (Windows, and Mac) and like you can do on the git command line.\nI'm just wondering am I just missing something. Is the revert button hidden?\nI tried searching online and came across something that seemed to suggest that this was to prevent synchronization errors when working with lots of people. Is this correct?" }, { "role": "assistant", "content": "No, that feature isn't directly available on the GitHub web interface (as opposed to the \"Revert\" button recently added for GitHub for Mac/Windows)\nActually, it is for pull requests only, since June 24th, 2014:\nIntroducing the Revert Button\n\nyou can easily revert a pull request on GitHub by clicking Revert:\n\n\n\nYou'll be prompted to create a new pull request with the reverted changes:\n\n\n\ngit revert is a bit more complex to manage through the web as it can accept a range of commits.\nIt shouldn't be an issue in terms of collaboration though: a revert adds a new commit, it doesn't change the history of existing commits." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Push git commits & tags simultaneously\ngit push --tags is a separate operation to git push since pushing tags should be a conscious choice to avoid accidentally pushing the wrong one. That's fine. But how do I push them both simultaneously / atomically? (git push && git push --tags is not perfectly atomic.)" }, { "role": "assistant", "content": "Update August 2020\nAs mentioned originally in this answer by SoBeRich, and in my own answer, as of git 2.4.x\ngit push --atomic origin <branch name> <tag>\n\n(Note: this actually work with HTTPS only with Git 2.24)\nUpdate May 2015\nAs of git 2.4.1, you can do\ngit config --global push.followTags true\n\n\nIf set to true enable --follow-tags option by default.\nYou may override this configuration at time of push by specifying --no-follow-tags.\n\nAs noted in this thread by Matt Rogers answering Wes Hurd:\n--follow-tags only pushes annotated tags.\ngit tag -a -m \"I'm an annotation\" <tagname>\n\nThat would be pushed (as opposed to git tag <tagname>, a lightweight tag, which would not be pushed, as I mentioned here)\nUpdate April 2013\nSince git 1.8.3 (April 22d, 2013), you no longer have to do 2 commands to push branches, and then to push tags:\n\nThe new \"--follow-tags\" option tells \"git push\" to push relevant annotated tags when pushing branches out.\n\nYou can now try, when pushing new commits:\ngit push --follow-tags\n\nThat won't push all the local tags though, only the one referenced by commits which are pushed with the git push.\nGit 2.4.1+ (Q2 2015) will introduce the option push.followTags: see \"How to make “git push” include tags within a branch?\".\nOriginal answer, September 2010\nThe nuclear option would be git push --mirror, which will push all refs under refs/.\nYou can also push just one tag with your current branch commit:\ngit push origin : v1.0.0 \n\nYou can combine the --tags option with a refspec like:\ngit push origin --tags :\n\n(since --tags means: All refs under refs/tags are pushed, in addition to refspecs explicitly listed on the command line)\n\nYou also have this entry \"Pushing branches and tags with a single \"git push\" invocation\"\n\nA handy tip was just posted to the Git mailing list by Zoltán Füzesi:\nI use .git/config to solve this:\n\n[remote \"origin\"]\n url = ...\n fetch = +refs/heads/*:refs/remotes/origin/*\n push = +refs/heads/*\n push = +refs/tags/*\n\n\nWith these lines added git push origin will upload all your branches and tags. If you want to upload only some of them, you can enumerate them.\nHaven't tried it myself yet, but it looks like it might be useful until some other way of pushing branches and tags at the same time is added to git push.\nOn the other hand, I don't mind typing:\n$ git push && git push --tags\n\n\nBeware, as commented by Aseem Kishore\npush = +refs/heads/* will force-pushes all your branches.\n\nThis bit me just now, so FYI.\n\n\nRené Scheibe adds this interesting comment:\n\nThe --follow-tags parameter is misleading as only tags under .git/refs/tags are considered.\nIf git gc is run, tags are moved from .git/refs/tags to .git/packed-refs. Afterwards git push --follow-tags ... does not work as expected anymore." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to check merge conflicts of two branches, without merging them?\nI can't merge two branches because of a release step of our project, but I want to know whether there are merge conflicts between them. How can I do this?" }, { "role": "assistant", "content": "Suppose you are on the master branch and you would like to test if the dev branch can be merged without conflict into the master.\n# In the master branch\ngit merge dev --no-ff --no-commit\n\nAfter that, you will be able to know if there's a conflict or not.\nTo return in a normal situation, just abort the merge:\ngit merge --abort\nAccording to the git documentation:\n\n--ff\n Do not generate a merge commit if the merge resolved as a fast-forward, only update the branch pointer. This is the default behavior.\n-no-ff\n Generate a merge commit even if the merge resolved as a fast-forward.\n--commit\n Perform the merge and commit the result. This option can be used to override --no-commit.\n--no-commit\n With --no-commit perform the merge but pretend the merge failed and do not autocommit, to give the user a chance to inspect and further tweak the merge result before committing." } ]
[ { "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": "How do I make Git forget about a file that was tracked, but is now in .gitignore?\nI put a file that was previously being tracked by Git onto the .gitignore list. However, the file still shows up in git status after it is edited. How do I force Git to completely forget the file?" }, { "role": "assistant", "content": ".gitignore will prevent untracked files from being added (without an add -f) to the set of files tracked by Git. However, Git will continue to track any files that are already being tracked.\nTo stop tracking a file, we must remove it from the index:\ngit rm --cached <file>\n\nTo remove a folder and all files in the folder recursively:\ngit rm -r --cached <folder>\n\nThe removal of the file from the head revision will happen on the next commit.\nWARNING: While this will not remove the physical file from your local machine, it will remove the files from other developers' machines on their next git pull." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I make the Mylyn GitHub Connector for Eclipse run authenticated requests?\n\nI'm using the very cool Github Mylyn Connector for Eclipse Indigo. However, since I use it for many projects on GitHub, I run very quickly into the 60 requests per second rate limit enforced on unauthenticated requests against the GitHub v3 API.\nThe Symptom is that refreshing any query (however small — again, the limiting factor here is more that I deal with may repositories) I get the error:\nUnexpected error : API Rate Limit Exceeded for XXX.XXX.XXX.XXX\n\nWhere XXX.XXX.XXX.XXX is of course my IP.\nI have configured the GitHub repositories in the Task Repository View with my GitHub username and password, but the connector doesn't seem to make use of those for either OAuth or Basic Authentication. I have read the FAQ of the GitHub connector plugin and haven't found anything of use there.\nIs there a way to get the GitHub connector to make authenticated requests (that would count against the much more relaxed rate limit of 5K/hour ?) ?\n\nEdit: I have tried with a private repository (which has at least one active issue) to check whether some credentials were sent there. I got Unexpected error: Issues are disabled for this repo.\n\nEdit: I noticed the problem with the version of the plugin on the Eclipse Marketplace, then switched to getting my EGit plugin from the nightlies repo, and likewise for the Mylyn Github Connector. It didn't help" }, { "role": "assistant", "content": "Eclipse Neon with Mylyn Github connector 4.4.\nTested with 2-factor access token. Anonymous rate limit successfully exceeded on a public repository with hundreds of issues. I did not test with simple login but it should work." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git --limit=<n>" }, { "role": "assistant", "content": "is NOT the same as --max-count, doesn’t count\nmerged/excluded commits" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_GLOB_PATHSPECS" }, { "role": "assistant", "content": "Setting this Boolean environment variable to true will cause Git to treat all\npathspecs as glob patterns (aka \"glob\" magic)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git push failed, \"Non-fast forward updates were rejected\"\n\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": "Git fatal: Reference has invalid format: 'refs/heads/master\nI am using Dropbox to sync a git repository, but now when I try and push I am getting an error:\nfatal: Reference has invalid format: 'refs/heads/master (MacBook-Pro's conflicted copy 2012-10-07)'\n\nSo, it seems that Dropbox detected a conflict and created a copy. Ok, no problem, so I deleted the conflicted file. Still, getting the above git error though.\n$ git checkout master\n M index.html\n Already on 'master'\n$ git add .\n$ git commit -a -m \"Cleanup repo\"\n [master ff6f817] Cleanup repo\n 1 file changed, 5 insertions(+), 5 deletions(-)\n$ git push\n fatal: Reference has invalid format: 'refs/heads/master (MacBook-Pro's conflicted copy 2012-10-07)'\n The remote end hung up unexpectedly`\n\nHow can I fix this? Thanks." }, { "role": "assistant", "content": "make a backup of your repo if you aren't sure about this one, because these commands are irreversible. \nfirst, go to your repo directory.\ncd myrepo\n\nthen recursively search for the conflicted files and delete them\nfind . -type f -name \"* conflicted copy*\" -exec rm -f {} \\;\n\nlastly, remove any \"conflicted\" references from git's packed-refs file\nawk '!/conflicted/' .git/packed-refs > temp && mv temp .git/packed-refs" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to migrate GitLab to a new server?\n\nI am trying to migrate an GitLab setup from 7.8.2 to 7.12.2. I am not really sure how to go about this. I have installed a new box, on Ubuntu 14.04.2.\nNow I would really like to just export the old user/group database and import it on the new server, then copy all the repositories from the old server to the new one. And tell the users to start using the new one.\nI do not know which database my new gitlab installation uses, neither the old one.\nI have been up and down the gitlab documentation, but cannot find sufficient information on how to migrate from one server to another.\nI followed the instructions on https://about.gitlab.com/downloads/ for ubuntu, and all seems to work fine. I am looking for a way to export the users/groups from the old gitlab box and import it on the new gitlab box. and then just copy all the repositories from the old box to the new one.\nAny assistance? I know next to nothing about gitlab :(" }, { "role": "assistant", "content": "I would take the following steps\n\nFind out if gitlab is installed by hand or with gitlab-omnibus. This you need to know for the exact backup and update steps.\nDo a backup of the old version just to be safe\nUpdate the current 7.8.2 instance to 7.12.2 instance by following the update guideline\nBack up the newly updated gitlab system \nRestore the backup on the new system\n\nBackup & restore documentation can be found here" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository -a --append" }, { "role": "assistant", "content": "Append ref names and object names of fetched refs to the\nexisting contents of .git/FETCH_HEAD . Without this\noption old data in .git/FETCH_HEAD will be overwritten." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-for-each-ref - Output information on each ref signature:primarykeyfingerprint" }, { "role": "assistant", "content": "The primary key fingerprint of the GPG signature of a commit." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - gpg onto mac osx: error: gpg failed to sign the data\nI installed GPG from brew.\nbrew install gpg\n\nIt is gnupg2-2.0.30_2.\nWhen I commit, I do get a error message:\nYou need a passphrase to unlock the secret key for\nuser: \"Max Mustermann (mycomment) <[email protected]>\"\n2048-bit RSA key, ID 1111AAAA, created 2017-01-05 \n\nerror: gpg failed to sign the data\nfatal: failed to write commit object\n\nI used the command:\ngpg --list-secret-keys | grep ^sec\n\nand it gives me back:\nsec 2048R/1111AAAA 2017-01-05\n\nThen I used this command:\ngit config --global user.signingkey 1111AAAA\n\ncommit gives me back the same error message.\nHow can I solve this problem?" }, { "role": "assistant", "content": "If you’re not getting prompted at all for a passphrase, the solution may just be to install a program to facilitate that. The most common is pinentry.\nbrew install pinentry-mac\n\nSo installing that and trying again may get things working. But if not, another thing to do is make sure git it using/finding the right GPG program. These days you really should be using gpg2, so if you don’t already have that installed, do this:\ngpg --version\n\n…and make sure it indicates you have GnuPG version 2+ (not version 1) installed.\nIf you already have GnuPG 2+ and pinentry installed, then try this:\necho \"pinentry-program /usr/local/bin/pinentry-mac\" >> ~/.gnupg/gpg-agent.conf\n\n…or, more robustly:\necho \"pinentry-program $(which pinentry-mac)\" >> ~/.gnupg/gpg-agent.conf\n\n…and then try again.\nAnd you may also need to stop gpg-agent:\ngpgconf --kill gpg-agent\n\nYou don’t need to manually restart it — it will get restarted automatically when it’s needed.\nNote: Some commenters mention needing to reboot after making changes — but it seems likely the only effect of that is to cause gpg-agent to be restarted. So manually killing gpg-agent as described above should be sufficient." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-commit - Record changes to the repository --pathspec-file-nul" }, { "role": "assistant", "content": "Only meaningful with --pathspec-from-file . Pathspec elements are\nseparated with NUL character and all other characters are taken\nliterally (including newlines and quotes)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "rsync exclude according to .gitignore & .hgignore & svn:ignore like --filter=:C\nRsync includes a nifty option --cvs-exclude to “ignore files in the same way CVS does”, but CVS has been obsolete for years. Is there any way to make it also exclude files which would be ignored by modern version control systems (Git, Mercurial, Subversion)?\nFor example, I have lots of Maven projects checked out from GitHub. Typically they include a .gitignore listing at least target, the default Maven build directory (which may be present at top level or in submodules). Since the contents of these directories are entirely disposable, and they can be far larger than source code, I would like to exclude them when using rsync for backups.\nOf course I can explicitly --exclude=target/ but that will accidentally suppress unrelated directories that just happen to be named target and are not supposed to be ignored.\nAnd I could supply a complete list of absolute paths for all file names and patterns mentioned in any .gitignore, .hgignore, or svn:ignore property on my disk, but this would be a huge list that would have to be produced by some sort of script.\nSince rsync has no built-in support for VCS checkouts other than CVS, is there any good trick for feeding it their ignore patterns? Or some kind of callback system whereby a user script can be asked whether a given file/directory should be included or not?\nUpdate: --filter=':- .gitignore' as suggested by LordJavac seems to work as well for Git as --filter=:C does for CVS, at least on the examples I have found, though it is unclear if the syntax is an exact match. --filter=':- .hgignore' does not work very well for Mercurial; e.g. an .hgignore containing a line like ^target$ (the Mercurial equivalent of Git /target/) is not recognized by rsync as a regular expression. And nothing seems to work for Subversion, for which you would have to parse .svn/dir-prop-base for a 1.6 or earlier working copy, and throw up your hands in dismay for a 1.7 or later working copy." }, { "role": "assistant", "content": "As mentioned by luksan, you can do this with the --filter switch to rsync. I achieved this with --filter=':- .gitignore' (there's a space before \".gitignore\") which tells rsync to do a directory merge with .gitignore files and have them exclude per git's rules. You may also want to add your global ignore file, if you have one. To make it easier to use, I created an alias to rsync which included the filter." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "\"Missing CI config file\" message on run pipeline, but .gitlab-ci.yml exists\n\n3 screenshots to explain the issue\nWhen I run the pipeline I've an error...\n\nBut the file exists\n\nAnd it's good" }, { "role": "assistant", "content": "GitLab shows this error message when trying to execute an empty .gitlab-ci.yml file\nCheck your configured .gitlab-ci.yml file location (Settings > CI/CD > General Pipelines), make sure that it points to the correct place in the repository" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-notes - Add or inspect object notes -q --quiet" }, { "role": "assistant", "content": "When merging notes, operate quietly." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-push - Update remote refs along with associated objects --[no-]force-if-includes" }, { "role": "assistant", "content": "Force an update only if the tip of the remote-tracking ref\nhas been integrated locally. This option enables a check that verifies if the tip of the\nremote-tracking ref is reachable from one of the \"reflog\" entries of\nthe local branch based in it for a rewrite. The check ensures that any\nupdates from the remote have been incorporated locally by rejecting the\nforced update if that is not the case. If the option is passed without specifying --force-with-lease , or\nspecified along with --force-with-lease=<refname>:<expect> , it is\na \"no-op\". Specifying --no-force-if-includes disables this behavior." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Best practice for using multiple .gitignore files\nThere exists a collection of useful .gitignore files at\nhttps://github.com/github/gitignore. Every ignores file there has an extension .gitignore, e.g. Java.gitignore, vim.gitignore. When I put these files directly into a workdir, they don't work.\nIs it necessary to create a single file .gitignore and merge the constituent files into it?\nAccordingly, when using a --global .gitignore file, it seems the config points to a single file. If for instance I want to apply all .gitignore files in a Global/ directory, should I manually merge them into a single file? If so, it's extra work to keep this merged file up to date with the \"official\" collection.\nTo reiterate, I acknowledge that we can use different .gitignore files in different directories, but it is not what I want. I want to apply multiple .gitignore files in a single directory." }, { "role": "assistant", "content": "To clarify: a projects gitignore file is called .gitignore\n\nBackground:\nA .gitignore refers to the directory that it's in, which is either the top level or descendent of a directory with a .git repository, i.e. a \".git/\" directory.\nThere can be multiple .gitignore files in any sub directories but the Best Practice is to have one .gitignore in a given projects root and have that file reference sub-directories as necessary, e.g. images/yearly/recent Otherwise it is be tricky to know \"which\" .gitignore file to look at to find something that's being ignored. Given that you can use patterns as file names that could be pretty tricky!\nI also recommend avoiding using a global .gitignore file which applies to all projects on your machine, although you might keep a template around for using with new projects. The main consideration here is that your .gitignore will be different from other developers (which may or may not exist) and so the result is undetermined. One example of an exception to this is using a global .gitignore file for IDE files that I don't want in any project that I open on my machine so I use a global .gitigore with an entry for .idea/ files (rubyMine).\n\nThe intent of the templates you see listed is that normally you are writing the code for a given file in a specific language. Given this, a template that is based on the language is frequently sufficient. \nIf there are multiple languages in the code base, then used you will need to combine multiple .gitignore's for those languages, which can be done in a multitude of ways such as:\ncat .gitignore1 .gitignore2 > .gitignore # if .gitignore doesn't exist yet\ncat .gitignore1 >> .gitignore # Add to it if it already exists\npaste .gitignore1 .gitignore # Add to it if it already exists\n\n\nHot(ish) off the press (summer 2014):\nGitignorer is a simple utility that aids in the creation of .gitignore files. It pulls specific (specified) .gitignore templates, with common files to exclude, from github.com/github/gitignore, mashes them together, and saves them to a .gitignore in the current directory.\nExample usage:\ngitignorer create c java python\n\nGitignorer is currently available in the AUR over at https://aur.archlinux.org/packages/gitignorer/ and on GitHub at https://github.com/zachlatta/gitignorer" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub: A tag but not a release\n\nI want to tag a certain commit. When I push the tag, GitHub assumes it's a release, I don't want that.\nIs there a way to just push the tag without releasing?" }, { "role": "assistant", "content": "GitHub, by default, creates a \"release\" point when you push a tag (like you can see in my project), but that doesn't mean it creates an actual release.\nBy default, a tag has one deliverable associated to the tag, and that is the compressed sources of the repo.\nCreating a release means associating other deliverables (executables or other binaries) that you may wish to publish under that tag/release.\nBut you don't have to add any more files (other then the sources) if you don't want to.\nSo: by default, you don't have any release, only \"release placeholders\" (one per tag), for you to create a release.\nAs long as you don't upload a binary to a new release, the tags that you have pushed don't represent a release.\n\nUpdate\nAs of 2017-05-31, Github support has stated it's \"not currently possible as all tags will appear in [the release] list\" - they said they'd pass it along as a feature request, though.\n\n2018-04-17 A \"new request on Github community\" says it is in the feature request.\n\n2021-10-04: a new public beta of GitHub Releases states:\n\nTags no longer show in the Release list view" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-check-ignore - Debug gitignore / exclude files" }, { "role": "assistant", "content": "DESCRIPTION For each pathname given via the command-line or from a file via --stdin , check whether the file is excluded by .gitignore (or other\ninput files to the exclude mechanism) and output the path if it is\nexcluded. By default, tracked files are not shown at all since they are not\nsubject to exclude rules; but see ‘--no-index’." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database missingTagEntry" }, { "role": "assistant", "content": "(ERROR) Missing tag line in a tag object." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to create a milestones in GitLab\n\nI'm kind of new to Git and I'm using a GitLab repository to track my issue list. I wanted to create milestones but I can not find where. Are milestones and issue tracking part of the git itself and not of Gitlab?\nEDIT: This is my milestones page screenshot:\nThere is no new Milestone button on it" }, { "role": "assistant", "content": "Are milestones and issue tracking part of the git itself and not of Gitlab?\n\nNo, they are part of GitLab only, not git.\nIf that hasn't change from issue 339, you have a \"new milestone\" button in the Issues section, tab 'Milestones':\n\n\nAs the OP Hoffmann reports: the presence of this button depends on your role (or abilities).\nAs you can see in ability.rb, only the ability 'master' allows to create / manage milestones:\ndef project_master_rules\n project_dev_rules + [\n :push_code_to_protected_branches,\n :modify_issue,\n :modify_project_snippet,\n :modify_merge_request,\n :admin_issue,\n :admin_milestone, <=============\n :admin_project_snippet,\n :admin_team_member,\n :admin_merge_request,\n :admin_note,\n :admin_wiki,\n :admin_project\n ]\nend" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "WARNING: this script is deprecated, please see git-completion.zsh\nI'm using oh-my-zsh and I get this error every time I open terminal: \nWARNING: this script is deprecated, please see git-completion.zsh\n\nis there any solution to that?" }, { "role": "assistant", "content": "Might seems silly, but make sure that you source your ~/.zshrc file (create one if it does not exists). On OSX I completely forgot that I had switched to zsh, and got the error you mentioned because I was doing source ~/.bashrc\n\nThe easiest way to get auto-completion working is to install it through Homebrew (it will work for zsh as well as bash.):\n\nbrew install bash-completion\n\n\nPut this into your ~/.zshrc:\n\n# auto-completion\nif [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then\n . /opt/local/etc/profile.d/bash_completion.sh\nfi\n\n\nSave the file and do a source ~/.zshrc and you will be good" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-daemon - A really simple server for Git repositories" }, { "role": "assistant", "content": "NAME git-daemon - A really simple server for Git repositories" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "docker login in custom gitlab-runner: No such host (http://docker:2375/v1.39/auth: dial tcp: lookup docker on 172.31.0.2:53: no such host)\n\nI have a private repo on gitlab.com. I have already setup a CI/CD pipeline using gitlab shared runners. On code push, a docker image is built, login to gitlab private docker registry and push the image. It works fine with the shared runners. Now I'm trying to create custom runners for the pipeline.\nI've created a droplet on DigitalOcean (Docker 18.09.2~3 on Ubuntu 18.04 - 8 GB / 4 CPUs / 160 GB SSD)\nssh into the droplet\ncreate a runner (from https://docs.gitlab.com/runner/install/docker.html#docker-image-installation-and-configuration)\ndocker run -d --name gitlab-runner --restart always \\\n -v /srv/gitlab-runner/config:/etc/gitlab-runner \\\n -v /var/run/docker.sock:/var/run/docker.sock \\\n gitlab/gitlab-runner:latest\n\nand register it (from https://docs.gitlab.com/runner/register/index.html#one-line-registration-command)\ndocker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \\\n --non-interactive \\\n --executor \"docker\" \\\n --docker-image alpine:3 \\\n --url \"https://gitlab.com/\" \\\n --registration-token \"MY_TOKEN\" \\\n --description \"docker-runner\" \\\n --tag-list \"docker,digitalocean\" \\\n --run-untagged=\"true\" \\\n --locked=\"false\"\n\non running the pipeline, it fails at this command\ndocker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY\n\nalso if I use\ndocker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com \n\nwith this error message\nerror during connect: Post http://docker:2375/v1.39/auth: dial tcp: lookup docker on 67.207.67.2:53: no such host\n\nI also get the same error if I use my local PC.\nI have tried editing /etc/hosts with no success.\nIt still works with the shared runners, but fails with my custom runners. What am I missing?\ndocker info\nContainers: 4\nRunning: 1\nPaused: 0\n Stopped: 3\nImages: 4\nServer Version: 18.09.2\nStorage Driver: overlay2\n Backing Filesystem: extfs\n Supports d_type: true\n Native Overlay Diff: true\nLogging Driver: json-file\nCgroup Driver: cgroupfs\nPlugins:\n Volume: local\n Network: bridge host macvlan null overlay\n Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog\nSwarm: inactive\nRuntimes: runc\nDefault Runtime: runc\nInit Binary: docker-init\ncontainerd version: 9754871865f7fe2f4e74d43e2fc7ccd237edcbce\nrunc version: 09c8266bf2fcf9519a651b04ae54c967b9ab86ec\ninit version: fec3683\nSecurity Options:\n apparmor\n seccomp\n Profile: default\nKernel Version: 4.15.0-45-generic\nOperating System: Ubuntu 18.04.2 LTS\nOSType: linux\nArchitecture: x86_64\nCPUs: 4\nTotal Memory: 7.79GiB\nName: docker-s-4vcpu-8gb-sgp1-01\nID: XF6Y:25TY:YXNO:RDHT:PEGU:KGR7:GPEM:DDBE:MAQ5:5VIJ:4GHB:Q7TF\nDocker Root Dir: /var/lib/docker\nDebug Mode (client): false\nDebug Mode (server): false\nRegistry: https://index.docker.io/v1/\nLabels:\nExperimental: false\nInsecure Registries:\n 127.0.0.0/8\nLive Restore Enabled: false\nProduct License: Community Engine\n\nthis is the /etc/hosts file on the shared runner that processes the pipeline successfully\n127.0.0.1 localhost\n::1 localhost ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes\nff02::2 ip6-allrouters\n127.0.0.1 0hshit.hopto.org\n127.0.0.1 daymndaymn.myftp.org\n127.0.0.1 loba.webhop.me\n172.17.0.3 docker 50d9e6c88489 runner-72989761-project-11958054-concurrent-0-docker-0\n172.17.0.4 runner-72989761-project-11958054-concurrent-0" }, { "role": "assistant", "content": "In GitLab 13.3 you can do the following in config.toml file of the runner:\nAdd in [[runners]] section:\n pre_build_script = \"export DOCKER_HOST=tcp://docker:2375\"\n environment = [\"DOCKER_DRIVER=overlay2\", \"DOCKER_TLS_CERTDIR=\"]\n\nand in [runners.docker] section\nadd:\ntls_cert_path = \"\"\n\nand change privileged to true.\nIn the end you will have something like this:\nconcurrent = 1\ncheck_interval = 0\n\n[session_server]\n session_timeout = 1800\n\n[[runners]]\n name = \"some_name\"\n url = \"https://my.url.com\"\n token = \"a_token\"\n executor = \"docker\"\n pre_build_script = \"export DOCKER_HOST=tcp://docker:2375\"\n environment = [\"DOCKER_DRIVER=overlay2\", \"DOCKER_TLS_CERTDIR=\"]\n [runners.custom_build_dir]\n [runners.cache]\n [runners.cache.s3]\n [runners.cache.gcs]\n [runners.cache.azure]\n [runners.docker]\n tls_cert_path = \"\"\n tls_verify = false\n image = \"ruby:2.6\"\n privileged = true\n disable_entrypoint_overwrite = false\n oom_kill_disable = false\n disable_cache = false\n volumes = [\"/cache\"]\n shm_size = 0\n\nIn .gitlab-ci.yml\nYou only have to do this to user docker:\nservices:\n - docker:dind" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-merge" }, { "role": "assistant", "content": "Join two or more development histories together" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I programmatically determine if there are uncommitted changes?\nIn a Makefile, I'd like to perform certain actions if there are uncommitted changes (either in the working tree or the index). What's the cleanest and most efficient way to do that? A command that exits with a return value of zero in one case and non-zero in the other would suit my purposes.\nI can run git status and pipe the output through grep, but I feel like there must be a better way." }, { "role": "assistant", "content": "UPDATES:\n\ntrusktr mentions in the comments of Josh Lee's answer\n\nOther methods using porcelain assume you're in bash, and that's not cross-shell or cross-platform compatible.\nThis one works everywhere:\ngit add . && git diff --quiet && git diff --cached --quiet \n\nseems like it catches every case I need (including untracked files, and git submodules with unstaged modifications which git add . will not stage)\n\n\nthe OP Daniel Stutzbach points out in the comments that this simple command git diff-index worked for him:\ngit update-index --refresh \ngit diff-index --quiet HEAD --\n\n\n\nA more precise option would be to test git status --porcelain=v1 2>/dev/null | wc -l, using the porcelain option.\nSee Myridium's answer.\n(nornagon mentions in the comments that, if there are files that have been touched, but whose contents are the same as in the index, you'll need to run git update-index --refresh before git diff-index, otherwise diff-index will incorrectly report that the tree is dirty)\nYou can then see \"How to check if a command succeeded?\" if you are using it in a bash script:\ngit diff-index --quiet HEAD -- || echo \"untracked\"; // do something about it\n\nNote: as commented by Anthony Sottile\n\ngit diff-index HEAD ... will fail on a branch which has no commits (such as a newly initialized repository).\nOne workaround I've found is git diff-index $(git write-tree) ...\n\nAnd haridsv points out in the comments that git diff-files on a new file doesn't detect it as a diff.\nThe safer approach seems to be to run git add on the file spec first and then use git diff-index to see if anything got added to index before running git commit.\n\ngit add ${file_args} && \\\ngit diff-index --cached --quiet HEAD || git commit -m '${commit_msg}'\n\n\nAnd 6502 reports in the comments:\n\nOne problem I bumped in is that git diff-index will tell that there are differences when indeed there is none except for timestamps of the files.\nRunning git diff once solves the issue (surprisingly enough, git diff does actually change the content of the sandbox, meaning here .git/index)\n\nThese timestamp issues can also occur if git is running in docker.\n\nOriginal answer:\n\"Programmatically\" means never ever rely on porcelain commands.\nAlways rely on plumbing commands.\nSee also \"Checking for a dirty index or untracked files with Git\" for alternatives (like git status --porcelain)\nYou can take inspiration from the new \"require_clean_work_tree function\" which is written as we speak ;) (early October 2010)\nrequire_clean_work_tree () {\n # Update the index\n git update-index -q --ignore-submodules --refresh\n err=0\n\n # Disallow unstaged changes in the working tree\n if ! git diff-files --quiet --ignore-submodules --\n then\n echo >&2 \"cannot $1: you have unstaged changes.\"\n git diff-files --name-status -r --ignore-submodules -- >&2\n err=1\n fi\n\n # Disallow uncommitted changes in the index\n if ! git diff-index --cached --quiet HEAD --ignore-submodules --\n then\n echo >&2 \"cannot $1: your index contains uncommitted changes.\"\n git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2\n err=1\n fi\n\n if [ $err = 1 ]\n then\n echo >&2 \"Please commit or stash them.\"\n exit 1\n fi\n}" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do you commit code as a different user?\nI want to be able to do this for a script. I'm essentially re-creating the entire version history of some code in Git - it currently uses a different version control system. I need the script to be able to add in the commits to Git while preserving the commit's original author (and date).\nAssuming I know the commit author and the date/time the change was made, is there a Git command that allows me to do this? I'm assuming there is, because git-p4 does something similar. I'm just asking for the best way to do it." }, { "role": "assistant", "content": "Check out the --author option for git commit:\nFrom the man page:\n\n--author=<author>\nOverride the commit author. Specify an explicit author\nusing the standard A U Thor <[email protected]> format. Otherwise\n<author> is assumed to be a pattern\nand is used to search for an existing\ncommit by that author (i.e. rev-list --all -i --author=<author>); the commit author is then copied from the\nfirst such commit found." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to fix: error: '<filename>' does not have a commit checked out fatal: adding files failed when inputting \"git add .\" in command prompt\n\nI'm trying to add a ruby rails file to my repository in gitlab, but it doesn't allow me to add the file saying that my file does not have a commit checked out.\nI've tried git pull, and making the the file again and git adding it, but it still doesn't work. This is the error message I get:\nerror: '172069/08_lab_routes_controllers_views_172069_172188-Copy/adventure_game/' does not have a commit checked out\nfatal: adding files failed" }, { "role": "assistant", "content": "If you have a subdirectory with a .git directory and try to git add . you will see this message.\nThis can happen if you have a git repo and then create/clone another repo in a subdirectory under that repo." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "301 redirect for site hosted at github?\n\nHere's a Github repository of mine: https://github.com/n1k0/casperjs\nThere's a gh-pages branch to hold the project documentation, which is basically the project website: https://github.com/n1k0/casperjs/tree/gh-pages\nThis branch setups the documentation site at http://n1k0.github.com/casperjs/ — hurray.\nIn the meanwhile, I've bough the casperjs.org domain to get this website available through it, so I put a CNAME file as recommended in the docs: https://github.com/n1k0/casperjs/blob/gh-pages/CNAME — in their example, the operation is supposed to create redirects from www.example.com and charlie.github.com to example.com…\nWhile the website now points to http://casperjs.org/, there's no 301 redirect from http://n1k0.github.com/casperjs/ (the old site url) to the new domain name.\nAny idea how to setup such a redirect, if it's even possible? Is it a bug? If it is, where should I open an issue?" }, { "role": "assistant", "content": "Bringing this topic back from the dead to mention that GH now supports redirect-from's redirect-to parameter https://github.com/jekyll/jekyll-redirect-from#redirect-to\nSimply add this to your _config.yml\ngems:\n - jekyll-redirect-from\n\nAnd this to the top of your index page.\n---\nredirect_to: \"http://example.com\"\n---" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-restore - Restore working tree files --ours --theirs" }, { "role": "assistant", "content": "When restoring files in the working tree from the index, use\nstage #2 ( ours ) or #3 ( theirs ) for unmerged paths.\nThis option cannot be used when checking out paths from a\ntree-ish (i.e. with the --source option). Note that during git rebase and git pull --rebase , ours and theirs may appear swapped. See the explanation of the same options\nin git-checkout for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-branch - List, create, or delete branches -l --list" }, { "role": "assistant", "content": "List branches. With optional <pattern>... , e.g. git\nbranch --list 'maint-*' , list only the branches that match\nthe pattern(s)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I create a commit without a parent in Git? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nIn git, is there a simple way of introducing an unrelated branch to a repository?\n\n (10 answers)\n \n\nClosed 4 years ago.\n\n\n\nI have a small project I was working on without any kind of version control software, and I ended up with three different versions of the same script, where each one does something slightly different from the others. I initialized a git repo with one of the versions, and I'd really like to commit each of the other two without parents. That way, I can merge the differences as though each of the three versions of the script were the tips of different branches.\nI'm not even sure whether this is necessarily a sane or reasonable way to go about solving this problem... Any advice on how to do things this way, or advice on a better way to handle this situation would be much appreciated." }, { "role": "assistant", "content": "From my comment:\n\nWhy don't you create two branches and add the two other versions to them and then work on the branches?\n\nWhich I think would agree with ctcherry's answer as well.\n\nBut if you really do want to create a completely different \"branch\" that is unrelated to master, then you can do it with git checkout --orphan. The manual for git checkout describes to work of the option --orphan:\n\nCreate a new orphan branch, named <new_branch>, started from <start_point> and switch to it. The first commit made on this new branch will have no parents and it will be the root of a new history totally disconnected from all the other branches and commits.\n\nYou might use it like this:\ngit checkout --orphan version2\ngit rm -rf .\n<add version2 script>\ngit add your files\ngit commit -m 'Initial commit for version 2'\n\nIf your Git is older than 1.7.2 (when git checkout --orphan was introduced), then you can use the alternate command sequence from “Creating New Empty Branches” in the Git Community Book:\n\nOcasionally, you may want to keep branches in your repository that do not share an ancestor with your normal code. Some examples of this might be generated documentation or something along those lines. If you want to create a new branch head that does not use your current codebase as a parent, you can create an empty branch like this:\ngit symbolic-ref HEAD refs/heads/newbranch \nrm .git/index \ngit clean -fdx \n<do work> \ngit add your files \ngit commit -m 'Initial commit'" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-submodule - Initialize, update or inspect submodules -f --force" }, { "role": "assistant", "content": "This option is only valid for add, deinit and update commands.\nWhen running add, allow adding an otherwise ignored submodule path.\nWhen running deinit the submodule working trees will be removed even\nif they contain local changes.\nWhen running update (only effective with the checkout procedure),\nthrow away local changes in submodules when switching to a\ndifferent commit; and always run a checkout operation in the\nsubmodule, even if the commit listed in the index of the\ncontaining repository matches the commit checked out in the\nsubmodule." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Authenticate with GitHub using a token\n\nI am trying to authenticate with GitHub using a personal access token. In the help files at GitHub, it states to use the cURL method to authenticate (Creating a personal access token). I have tried this, but I still cannot push to GitHub. Please note, I am trying to push from an unauthenticated server (Travis CI).\ncd $HOME\ngit config --global user.email \"[email protected]\"\ngit config --global user.name \"username\"\n\ncurl -u \"username:<MYTOKEN>\" https://github.com/username/ol3-1.git\ngit clone --branch=gh-pages https://github.com/username/ol3-1.git gh-pages\n\ncd gh-pages\nmkdir buildtest\ncd buildtest\ntouch asdf.asdf\n\ngit add -f .\ngit commit -m \"Travis build $TRAVIS_BUILD_NUMBER pushed to gh-pages\"\ngit push -fq origin gh-pages\n\nThis code causes the errors:\n\nremote: Anonymous access to scuzzlebuzzle/ol3-1.git denied.\n\n\nfatal: Authentication failed for 'https://github.com/scuzzlebuzzle/ol3-1.git/'\"" }, { "role": "assistant", "content": "Your curl command is entirely wrong. You should be using the following\ncurl -H 'Authorization: token <MYTOKEN>' ...\n\nThat aside, that doesn't authorize your computer to clone the repository if in fact it is private. (Taking a look, however, indicates that it is not.) What you would normally do is the following:\ngit clone https://scuzzlebuzzle:<MYTOKEN>@github.com/scuzzlebuzzle/ol3-1.git --branch=gh-pages gh-pages\n\nThat will add your credentials to the remote created when cloning the repository. Unfortunately, however, you have no control over how Travis clones your repository, so you have to edit the remote like so.\n# After cloning\ncd gh-pages\ngit remote set-url origin https://scuzzlebuzzle:<MYTOKEN>@github.com/scuzzlebuzzle/ol3-1.git\n\nThat will fix your project to use a remote with credentials built in.\n\nWarning: Tokens have read/write access and should be treated like passwords. If you enter your token into the clone URL when cloning or adding a remote, Git writes it to your .git/config file in plain text, which is a security risk." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --inter-hunk-context=<lines>" }, { "role": "assistant", "content": "Show the context between diff hunks, up to the specified number\nof lines, thereby fusing hunks that are close to each other.\nDefaults to diff.interHunkContext or 0 if the config option\nis unset." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects cumulative" }, { "role": "assistant", "content": "Count changes in a child directory for the parent directory as well.\nNote that when using cumulative , the sum of the percentages\nreported may exceed 100%. The default (non-cumulative) behavior can\nbe specified with the noncumulative parameter." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to add file to a previous commit?\nIn last hour or so i have modified files \nA\nATest\nB\nBTest\n\nIn order to make sure my commit messages line up with the actual change, committed A with a description. Unfortunately i have not included ATest into that commit.\nMeanwhile, still not committed are B and BTest. \nWhat is the best way to proceed at this point? I'd like to either:\n\nRevert previous commit without affecting my currently uncommitted files?\nAdd another file under the same description to the previous commit?" }, { "role": "assistant", "content": "To add a new file to the previous commit:\n$ git add new-file\n$ git commit --amend\n\nYou can use git commit --amend --no-edit if you don't want to change the commit message." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why should I use core.autocrlf=true in Git?\nI have a Git repository that is accessed from both Windows and OS X, and that I know already contains some files with CRLF line-endings. As far as I can tell, there are two ways to deal with this:\n\nSet core.autocrlf to false everywhere,\nFollow the instructions here (echoed on GitHub's help pages) to convert the repository to contain only LF line-endings, and thereafter set core.autocrlf to true on Windows and input on OS X. The problem with doing this is that if I have any binary files in the repository that: \n\nare not correctly marked as binary in gitattributes, and \nhappen to contain both CRLFs and LFs,\n\nthey will be corrupted. It is possible my repository contains such files.\n\nSo why shouldn't I just turn off Git's line-ending conversion? There are a lot of vague warnings on the web about having core.autocrlf switched off causing problems, but very few specific ones; the only that I've found so far are that kdiff3 cannot handle CRLF endings (not a problem for me), and that some text editors have line-ending issues (also not a problem for me).\nThe repository is internal to my company, and so I don't need to worry about sharing it with people with different autocrlf settings or line-ending requirements.\nAre there any other problems with just leaving line-endings as-is that I am unaware of?" }, { "role": "assistant", "content": "The only specific reasons to set autocrlf to true are:\n\navoid git status showing all your files as modified because of the automatic EOL conversion done when cloning a Unix-based EOL Git repo to a Windows one (see issue 83 for instance)\nand your coding tools somehow depends on a native EOL style being present in your file:\n\n\nfor instance, a code generator hard-coded to detect native EOL\nother external batches (external to your repo) with regexp or code set to detect native EOL\nI believe some Eclipse plugins can produce files with CRLF regardless on platform, which can be a problem.\nYou code with Notepad.exe (unless you are using a Windows 10 2018.09+, where Notepad respects the EOL character detected).\n\n\nUnless you can see specific treatment which must deal with native EOL, you are better off leaving autocrlf to false (git config --global core.autocrlf false).\nNote that this config would be a local one (because config isn't pushed from repo to repo)\nIf you want the same config for all users cloning that repo, check out \"What's the best CRLF handling strategy with git?\", using the text attribute in the .gitattributes file.\nExample:\n*.vcproj text eol=crlf\n*.sh text eol=lf\n\n\nNote: starting git 2.8 (March 2016), merge markers will no longer introduce mixed line ending (LF) in a CRLF file.\nSee \"Make Git use CRLF on its “<<<<<<< HEAD” merge lines\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Extensions: Squash commits?\nTo squash multiple commits, I have always used:\ngit reset --soft HEAD~<number of commits to squash> && git commit\n\nBut I wonder if there is a good way to do this in a good git client like git extensions? It would be cool if you could just select consecutive commits and squash them." }, { "role": "assistant", "content": "There are multiple ways of doing a squash.\nHere's how you can easily squash the current and all its immediate parent commits into a single commit in Git Extensions:\n\nRight click on a commit you wish to squash to and select \"Reset the current branch to here\"\nSelect either \"Soft reset\" (retain staged files) or \"Mixed reset\" (unstage all files)\nStage, if necessary\nCommit\n\nHere's an animation of the above:\n\n\nAnother way is to do an \"interactive rebase\" either\n\nvia a command line (git rebase -i, read docs), or\nvia UI (e.g. Git Extensions).\n\nTo do an interactive rebase in Git Extensions:\n\nRight click on a commit you wish to squash to and select \"Rebase current branch on > Selected commit interactively...\"\nIn the presented dialog alter the history, such as choose which commits to squash or reword\nSave and close\n\nHere's an animation of the above:" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I have Github on my own server? [closed]\n\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 9 months ago.\n\n\nThe community reviewed whether to reopen this question 9 months 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\nIs there anything out there like Github that is for your own local server? I am curious if there is like a PHP script or even a desktop client that mimics Github's functionality, I love Github but it would be nice to host on my own server.\nApologies if this isn't considered \"programming\" enough but generally only programmers use GIT and Github\n\nUpdate\nFirst of all thanks for all the great suggestions, it is great to see there are options out there. From what is posted here and from my googling I can say it looks like the best looking/most alike to Github solutions are coded in Ruby, which is great for some but I am a PHP kind of guy (for now).\nMost of the PHP GIT viewers either are outdated and abandoned projects or they just look like crap ( I realize I could fix them up to be more like Github) but I ran across something in PHP that looks promising so far. It is called Glip it is on Github here https://github.com/patrikf/glip and to me it is the most attractive and easy to use solution I have found for PHP so far. For the advanced Git user, it may not be enough but for me, I just wanted to be able to view a git repo and that provides that functionality.\nNow my search still continues for the perfect solution, will I ever find it? I hope so but, for now, this is we got. I am considering writing my own, one that is attractive like Github and has other features like an Issue tracker for bug and feature requests. All the ones I have seen so far are not so good" }, { "role": "assistant", "content": "There is GitHub Enterprise (administration documentation) to satisfy your needs. And there is an open source \"clone\" of Github Enterprise.\nPS: Now Github provides unlimited private repositories, bitbucket does the same. you can give a try to both. There are several other solutions as well." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options --replace-all" }, { "role": "assistant", "content": "Default behavior is to replace at most one line. This replaces\nall lines matching the key (and optionally the value-pattern )." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options blame.markUnblamableLines" }, { "role": "assistant", "content": "Mark lines that were changed by an ignored revision that we could not\nattribute to another commit with a * in the output of git-blame ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options help.htmlPath" }, { "role": "assistant", "content": "Specify the path where the HTML documentation resides. File system paths\nand URLs are supported. HTML pages will be prefixed with this path when\nhelp is displayed in the web format. This defaults to the documentation\npath of your Git installation." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Push branches to Git\nI have a local repository I'm working on and its remote is hosted on GitHub. I recently created a branch and started working on it, making several commits and now wish to push the branch to GitHub and be able to pull it to another cloned repository. How do I do this?" }, { "role": "assistant", "content": "git push origin <local-branch-name>:<remote-branch-name>\n\nSubstitute for <local-branch-name> and <remote-branch-name>. They may be same or different, as you wish." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I clone a subdirectory only of a Git repository?\nI have my Git repository which, at the root, has two subdirectories:\n/finisht\n/static\n\nWhen this was in SVN, /finisht was checked out in one place, while /static was checked out elsewhere, like so:\nsvn co svn+ssh://[email protected]/home/admin/repos/finisht/static static\n\nIs there a way to do this with Git?" }, { "role": "assistant", "content": "What you are trying to do is called a sparse checkout, and that feature was added in Git 1.7.0 (Feb. 2012). The steps to do a sparse clone are as follows:\nmkdir <repo>\ncd <repo>\ngit init\ngit remote add -f origin <url>\n\nThis creates an empty repository with your remote, and fetches all objects but doesn't check them out. Then do:\ngit config core.sparseCheckout true\n\nNow you need to define which files/folders you want to actually check out. This is done by listing them in .git/info/sparse-checkout, eg:\necho \"some/dir/\" >> .git/info/sparse-checkout\necho \"another/sub/tree\" >> .git/info/sparse-checkout\n\nLast but not least, update your empty repo with the state from the remote:\ngit pull origin master\n\nYou will now have files \"checked out\" for some/dir and another/sub/tree on your file system (with those paths still), and no other paths present.\nYou might want to have a look at the extended tutorial and you should probably read the official documentation for sparse checkout and read-tree.\nAs a function:\nfunction git_sparse_clone() (\n rurl=\"$1\" localdir=\"$2\" && shift 2\n\n mkdir -p \"$localdir\"\n cd \"$localdir\"\n\n git init\n git remote add -f origin \"$rurl\"\n\n git config core.sparseCheckout true\n\n # Loops over remaining args\n for i; do\n echo \"$i\" >> .git/info/sparse-checkout\n done\n\n git pull origin master\n)\n\nUsage:\ngit_sparse_clone \"http://github.com/tj/n\" \"./local/location\" \"/bin\"\n\n\nNote that this will still download the whole repository from the server – only the checkout is reduced in size. At the moment it is not possible to clone only a single directory. But if you don't need the history of the repository, you can at least save on bandwidth by creating a shallow clone. See udondan's answer below for information on how to combine shallow clone and sparse checkout.\n\nAs of Git 2.25.0 (Jan 2020) an experimental sparse-checkout command is added in Git:\ngit sparse-checkout init\n# same as:\n# git config core.sparseCheckout true\n\ngit sparse-checkout set \"A/B\"\n# same as:\n# echo \"A/B\" >> .git/info/sparse-checkout\n\ngit sparse-checkout list\n# same as:\n# cat .git/info/sparse-checkout" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to push multiple images needed for docker-compose to GitLab registry in GitLab CI?\n\nI recently got into CI/CD, and a good starting point for me was GitLab, since they provide an easy interface for that and i got started about what pipelines and stages are, but i have run into some kind of contradictory thought about GitLab CI running on Docker.\nMy app runs on Docker Compose. It contains (blah blah) that makes it easy to build & run containers. Each service in the Docker Compose creates a single Docker container, excepting the php-fpm one, which is able to do the thing called \"horizontal scale\", so I can scale it later.\nI will use that Docker Compose for production, I am currently using it in development and I want to use it too in CI/CD pipelines.\nHowever the .gitlab-ci.yml provides support for only one image, so I have to build it and push it to either their GitLab Registry or Docker Hub in order to pull it later in the CI/CD process.\nHow can I build my Docker Compose's service as a single image in order to push it to the Registry/Docker so I can pull it in the CI/CD?\nMy project contains a docker folder and a docker-compose.yml. In the docker folder, each service has its own separate directory (php-fpm, nginx, mysql, etc.) and each one (prepare yourself) contains a Dockerfile with build details, especially the php-fpm one (deps and libs are strong with this one)\nEach service in the docker-compose.yml has a build context in each of their own folder.\nIf I was unclear, I can provide additonal info." }, { "role": "assistant", "content": "However the .gitlab-ci.yml provides support for only one image\n\nThis is not true. From the official documentation:\n\nYour image will be named after the following scheme:\n<registry URL>/<namespace>/<project>/<image>\n\nGitLab supports up to three levels of image repository names.\nFollowing examples of image tags are valid:\nregistry.example.com/group/project:some-tag\nregistry.example.com/group/project/image:latest\nregistry.example.com/group/project/my/image:rc1\n\n\nSo the solution to your problem is simple - just build individual images and push them to GitLab container registry under different image name.\n\nIf you would like an example, my pipelines are set up like this:\n.template: &build_template\n image: docker:stable\n services:\n - docker:dind\n before_script:\n - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY\n script:\n - docker pull $CI_REGISTRY_IMAGE/$IMAGE_NAME:latest || true\n - if [ -z ${CI_COMMIT_TAG+x} ];\n then docker build\n --cache-from $CI_REGISTRY_IMAGE/$IMAGE_NAME:latest\n --file $DOCKERFILE_NAME\n --tag $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHA\n --tag $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_TAG\n --tag $CI_REGISTRY_IMAGE/$IMAGE_NAME:latest . ;\n else docker build\n --cache-from $CI_REGISTRY_IMAGE/$IMAGE_NAME:latest\n --file $DOCKERFILE_NAME\n --tag $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHA\n --tag $CI_REGISTRY_IMAGE/$IMAGE_NAME:latest . ;\n fi\n - docker push $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHA\n - if [ -z ${CI_COMMIT_TAG+x} ]; then\n docker push $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_TAG;\n fi\n - docker push $CI_REGISTRY_IMAGE/$IMAGE_NAME:latest\n\nbuild:image1:\n <<: *build_template\n variables:\n IMAGE_NAME: image1\n DOCKERFILE_NAME: Dockerfile.1\n\nbuild:image2:\n <<: *build_template\n variables:\n IMAGE_NAME: image2\n DOCKERFILE_NAME: Dockerfile.2\n\nAnd you should be able to pull the same image using $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHA in later pipeline jobs or your compose file (provided that the variables are passed to where you run your compose file)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What does the “@@…@@” meta line with at signs in svn diff or git diff mean?\nWhen I use svn diff or git diff it shows lines like:\n@@ -1,5 +1,9 @@\n\nWhat do they mean?" }, { "role": "assistant", "content": "Those are called (c)hunk headers and contain the range information.\nThey are surrounded by double at signs @@. They are of the format:\n@@ -l,s +l,s @@\n\nwhere l is the starting line number and s is the number of lines the change (c)hunk applies to for each respective file. The - indicates the original file and the + indicates the new (modified) file. Note that it not only shows affected lines, but also context lines.\nThe -1,5 is in the original file (indicated by the -). It shows that that first line is the start and 5 affected / context lines\nThe +1,9 is in the new (modified) file (indicated by the +) and again first line is the start and 9 affected / context lines.\nMore details here: http://en.wikipedia.org/wiki/Diff#Unified_format" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to write setup.py to include a Git repository as a dependency\nI am trying to write setup.py for my package. My package needs to specify a dependency on another Git repository.\nThis is what I have so far:\nfrom setuptools import setup, find_packages\n\nsetup(\n name='abc',\n packages=find_packages(),\n url='https://github.abc.com/abc/myabc',\n description='This is a description for abc',\n long_description=open('README.md').read(),\n install_requires=[\n \"requests==2.7.0\",\n \"SomePrivateLib>=0.1.0\",\n ],\n dependency_links = [\n \"git+git://github.abc.com/abc/SomePrivateLib.git#egg=SomePrivateLib\",\n ],\n include_package_data=True,\n)\n\nWhen I run:\npip install -e https://github.abc.com/abc/myabc.git#egg=analyse\n\nI get\n\nCould not find a version that satisfies the requirement\nSomePrivateLib>=0.1.0 (from analyse) (from versions: ) No matching\ndistribution found for SomePrivateLib>=0.1.0 (from analyse)\n\nWhat am I doing wrong?" }, { "role": "assistant", "content": "Note: this answer is now outdated. Have a look at this answer for up-to-date instructions: https://stackoverflow.com/a/54701434/212774\n\nAfter digging through the pip issue 3939 linked by @muon in the comments above and then the PEP-508 specification, I found success getting my private repo dependency to install via setup.py using this specification pattern in install_requires (no more dependency_links):\ninstall_requires = [\n 'some-pkg @ git+ssh://[email protected]/someorgname/[email protected]#egg=some-pkg',\n]\n\nThe @v1.1 indicates the release tag created on github and could be replaced with a branch, commit, or different type of tag." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Intellij git revert a commit\nI was using Eclipse and Egit for a long time and decided to try Intellij. So far so good, except one thing... I can't find an easy way to revert an old commit from my repo!!!\nIn Eclipse the standard process was: Go to Git Workspace -> Click Show History(Right Click Project) -> RIght-Click on the commit I want to revert and press Revert Commit. \nIn Intellij I can't find anything equivalent. Tried VCS -> Show Changes View but there I can only cherry pick a commit. I also played with the revert option under VCS -> git but got confused by the changelist thing(That may hide the answer, but I don't understand how it works).\nI can still revert the commit by issuing git revert <sha> from terminal but that's what I was trying to avoid in the first place by using git from Intellij and not pure terminal.\nIs there a way to do easily the revert in Intellij?" }, { "role": "assistant", "content": "If you go to Changelist -> Log, and there select the commit, you've got a change detail in the right panel.\nThere you can select all and click a button (or right click -> revert selected changes)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "TortoiseGit not showing icon overlays\nI have been using TortoiseGit for almost a full year now. It has been working very well for me until yesterday, when I encountered a problem. I was deleting a folder when Windows Explorer sort of crashed on me (it hung on \"discovering items\") for over an hour, then I restarted the system.\nSince that time (and I am not sure if the incident described has anything to do with it), TortoiseGit has stopped showing icon overlays in explorer. The behaviour is, however, not like any of the others who posted questions here, because:\n\nIn the open file dialogue of all programs, the icons still exist (!).\n\nHere is a list of things I tried:\n\nI changed TortoiseGit settings to show different icons.\nReinstall TortoiseGit (uninstall, restart, install, restart).\nI deleted all icon overlays starting with \"Tortoise\" in HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer \n\\ShellIconOverlayIdentifiers, then uninstalled TortoiseGit, restarted the computer and reinstalled TortoiseGit.\n\n\nEdit:\nI tried to create a new user on my computer, and the new user has icon overlays working just fine. I am now even more confused.\nNothing helped so far. Any ideas?" }, { "role": "assistant", "content": "I had the same problem and I got it to work by following instructions from a forum. What I did was this (copied):\n\nI find solution :)\nWrapping with \"\" all tortoise keys under HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers\n\n\non 1TortoiseNormal and etc...\nI understood the problem, seeing as Dropbox and it worked regedit there was the sign (\"\") to Dropbox but not tortoise.\nSo I added the signs, close explorer.exe and hop it was good :)\n\nSo what I did was rename the key 1TortoiseNormal to \"1TortoiseNormal\" etc. I have no idea why wrapping it inside a double quote makes it work again. Note that a restart of Windows Explorer is required for the changes to take effect.\nThe original forum is gone, but a good summary is supplied in the comments." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-reflog - Manage reflog information --verbose" }, { "role": "assistant", "content": "Print extra information on screen." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Always use the pager for git diff\nI'm using less as my Git pager.\nIf the git diff output is readable on one page, my Git prints the output to the screen.\nSometimes I'm too fast with typing Ctrl + D (half page down), which kills my terminal. Is there an option to enable the pager for git diff, even if the output is very small?\nThis doesn't work:\n\ngit -p diff\ngit --paginate diff\ngit settings: pager.diff = true" }, { "role": "assistant", "content": "This is controlled by the -F (--quit-if-one-screen) option to less.\nGit uses the options FRSX for/of less by default, if none are specified by the $LESS or $GIT_PAGER environment variables. To change it, specify the core.pager option and set it to RSX:\ngit config --global core.pager 'less -+F'\n\n\nOlder versions of Git used to recommend the following in their documentation:\ngit config --global core.pager 'less -+$LESS -RSX'" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "change the data directory gitlab to store repos elsewhere\n\nmy basic disk is full for my gitlab installation, is it possible to move the repositories and their data to some other folder and make sure that the upcoming push's data is sent to those directories?\nI tried stopping the gitlab and copying over the entire folder, but to no avail.\nPS - I am not an IT guy, I am just pitching in to see how could we get out of this issue; so please be verbose when answering." }, { "role": "assistant", "content": "Just updating in case people still refer to this. From the GitLab documentation:\n\nBy default, omnibus-gitlab stores the Git repository data under\n /var/opt/gitlab/git-data. The repositories are stored in a subfolder\n repositories. You can change the location of the git-data parent\n directory by adding the following line to /etc/gitlab/gitlab.rb.\ngit_data_dirs({\"default\" => \"/mnt/nas/git-data\"})\n\nStarting from GitLab 8.10 you can also add more than one git data\n directory by adding the following lines to /etc/gitlab/gitlab.rb\n instead.\ngit_data_dirs({\n \"default\" => \"/var/opt/gitlab/git-data\",\n \"alternative\" => \"/mnt/nas/git-data\"\n})\n\nNote that the target directories and any of its subpaths must not be a\n symlink.\nRun sudo gitlab-ctl reconfigure for the changes to take effect.\nIf you already have existing Git repositories in\n /var/opt/gitlab/git-data you can move them to the new location as\n follows:\n# Prevent users from writing to the repositories while you move them.\nsudo gitlab-ctl stop\n\n# Note there is _no_ slash behind 'repositories', but there _is_ a\n# slash behind 'git-data'.\nsudo rsync -av /var/opt/gitlab/git-data/repositories /mnt/nas/git-data/\n\n# Fix permissions if necessary\nsudo gitlab-ctl reconfigure\n\n# Double-check directory layout in /mnt/nas/git-data. Expected output:\n# gitlab-satellites repositories\nsudo ls /mnt/nas/git-data/\n\n# Done! Start GitLab and verify that you can browse through the repositories in\n# the web interface.\nsudo gitlab-ctl start" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to remove the shallow clone warning from HomeBrew\n➜ ~ brew info test \nError: No available formula with the name \"test\" \n==> Searching for a previously deleted formula...\nWarning: homebrew/core is shallow clone. To get complete history run:\n git -C \"$(brew --repo homebrew/core)\" fetch --unshallow\n\nError: No previously deleted formula found.\n\nI have modified the git remote address to mirror address of homebrew before. Maybe it's relevant to this but I don't know." }, { "role": "assistant", "content": "As of Oct 2020 Homebrew no longer creates shallow clones when being installed, and as of Dec 2020 updating existing shallow clones is not allowed either.\n(This makes the original question about silencing the warning moot).\n\nIf a shallow clone is configured, a message containing text like the below will be shown:\n\n\nError:\n homebrew-core is a shallow clone.\n homebrew-cask is a shallow clone.\nTo `brew update`, first run:\n git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow\n git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow\n\n\nIt is now required to perform the unshallow process by running the git command(s) in the error message.\nNote: This process may take a long time to complete without providing feedback.\n\nFor some details about the motivation for this change, see this discussion on Homebrew's GitHub page, specifically:\n\nThere are two major downsides of shallow cloning:\n\nIt places a massive computation burden on GitHub's servers, which have to dynamically compute a fresh delta between what you have and the latest commit, on every brew update. (With full clones, GitHub can simply send you all the commits that happened after your last pull, and your local Git client takes care of the rest.)\nBecause of [1], it makes it far more likely that GitHub will rate-limit Homebrew operations, which will make it suck for everyone.\n\n\n--gromgit Dec 5, 2020, 12:29 AM EST\nAnd also this additional text added to the error message:\n\nThis restriction has been made on GitHub's request because updating shallow\nclones is an extremely expensive operation due to the tree layout and traffic of\nHomebrew/homebrew-core and Homebrew/homebrew-cask." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "how to use private GitLab repository as npm dependency with private token through https\n\nI'm trying to use a private GitLab repo as npm dependency in my node js app, with a private token key, something like this:\n\"dependencies\": {\n \"my-module\": \"git+https://<privateToken>:x-oauth-basic@<myGitLabURL>/<MyUser>/my-module.git\"\n}\n\nwhen I run npm install I get errors about the git clone with fatal: unable to access <git repo path> with 443 Connection refused replies.\nI couldn't find a lot of documentation of how to do this through https and not through ssh.\nIt seems like it does work on GitHub\nAnybody have experience with this on GitLab with Https?" }, { "role": "assistant", "content": "This answer worked for me.\n\"my-module\": \"https://oauth2:<PersonalAccessToken>@gitlab.com/<group>/<repository-name>.git\n\nYou can create a Personal Access Token under User Settings->Access Tokens (GitLab.com Link)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Create a new file in git bash\n\nI've got Git for Windows running, I'm not sure if it's supposed to function as a text editor though?\nI think I installed it with the Vim editor, but in a Git Bash shell how do I create a file, such as webpage.html?\n$ git add webpage.html\n\ncomes back as\nfatal: pathspec 'webpage.html' did not match any files\n\nbecause it tries to track a non-existing file.\nI understand I can create a new file on the github.com interface, that's easy enough, I'm wondering if I can create a new file (like echo in cmd) and whether this file will actually be blank (echo in cmd creates non-blank files) and how I can write into that file from the git bash shell?\nIf not, I'm guessing I should just create a new file in windows explorer? Is that the norm...?\nEdit\nWow, I was new to all this when I asked the above. No, Git Bash isn't a text editor, it's a Windows version of the git facility on Unix, and only handles the file versioning. git add, git rm, and other git commands just handle how the version control file manager handles the files and folders, and the only things it changes as a result are in a hidden folder named .git. Sorry if this has confused anyone.\nI was confused at the time because, as the name suggests, Git Bash has bash shell commands shipped with it, not just git - e.g. ls (list files), mkdir (make new folder), and -- what I was looking for -- touch (make a new file or update timestamp on existing file), and echo (print text to the command line, or direct that text to a file). \nI could have made my new file webpage.html with:\ntouch webpage.html\n\nThen written to it with:\necho \"<!DOCTYPE html>\" > webpage.html\n\nThen appended lines to it with:\necho \"<html\" >> webpage.html\necho \"<head>\" >> webpage.html\n\nand so on - but I don't think there's any text editor (according to this list of commands). See this thread for details of setting up a text editor with Git on Windows." }, { "role": "assistant", "content": "If you are using the Git Bash shell, you can use the following trick:\n> webpage.html\n\nThis is actually the same as:\necho \"\" > webpage.html\n\nThen, you can use git add webpage.html to stage the file." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker --icase-pathspecs" }, { "role": "assistant", "content": "Add \"icase\" magic to all pathspec. This is equivalent to setting\nthe GIT_ICASE_PATHSPECS environment variable to 1 ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I determine when a Git branch was created?\nIs there a way to determine when a Git branch was created?\nI have a branch in my repository, and and I don't remember creating it and thought maybe seeing the creation timestamp would jog my memory." }, { "role": "assistant", "content": "As pointed out in the comments and in Jackub's answer, as long as your branch is younger than the number of days set in the config setting gc.reflogexpire (the default is 90 days), then you can utilize your reflog to find out when a branch reference was first created.\nNote that git reflog can take most git log flags. Further note that the HEAD@{0} style selectors are effectively notions of time and, in fact, are handled (in a hacked sort of way) as date strings. This means that you can use the flag --date=local and get output like this:\n$ git reflog --date=local\n763008c HEAD@{Fri Aug 20 10:09:18 2010}: pull : Fast-forward\nf6cec0a HEAD@{Tue Aug 10 09:37:55 2010}: pull : Fast-forward\ne9e70bc HEAD@{Thu Feb 4 02:51:10 2010}: pull : Fast forward\n836f48c HEAD@{Thu Jan 21 14:08:14 2010}: checkout: moving from master to master\n836f48c HEAD@{Thu Jan 21 14:08:10 2010}: pull : Fast forward\n24bc734 HEAD@{Wed Jan 20 12:05:45 2010}: checkout: moving from 74fca6a42863ffacaf7ba6f1936a9f228950f657 \n74fca6a HEAD@{Wed Jan 20 11:55:43 2010}: checkout: moving from master to v2.6.31\n24bc734 HEAD@{Wed Jan 20 11:44:42 2010}: pull : Fast forward\n964fe08 HEAD@{Mon Oct 26 15:29:29 2009}: checkout: moving from 4a6908a3a050aacc9c3a2f36b276b46c0629ad91 \n4a6908a HEAD@{Mon Oct 26 14:52:12 2009}: checkout: moving from master to v2.6.28\n\nIt may also be useful at times to use --date=relative:\n$ git reflog --date=relative\n763008c HEAD@{4 weeks ago}: pull : Fast-forward\nf6cec0a HEAD@{6 weeks ago}: pull : Fast-forward\ne9e70bc HEAD@{8 months ago}: pull : Fast forward\n836f48c HEAD@{8 months ago}: checkout: moving from master to master\n836f48c HEAD@{8 months ago}: pull : Fast forward\n24bc734 HEAD@{8 months ago}: checkout: moving from 74fca6a42863ffacaf7ba6f1936a9f228950f657 to master\n74fca6a HEAD@{8 months ago}: checkout: moving from master to v2.6.31\n24bc734 HEAD@{8 months ago}: pull : Fast forward\n964fe08 HEAD@{11 months ago}: checkout: moving from 4a6908a3a050aacc9c3a2f36b276b46c0629ad91 to master\n4a6908a HEAD@{11 months ago}: checkout: moving from master to v2.6.28\n\nOne last note: the --all flag (which is really a git-log flag understood by git-reflog) will show the reflogs for all known refs in refs/ (instead of simply, HEAD) which will show you branch events clearly:\ngit reflog --date=local --all\n860e4e4 refs/heads/master@{Sun Sep 19 23:00:30 2010}: commit: Second.\n17695bc refs/heads/example_branch@{Mon Sep 20 00:31:06 2010}: branch: Created from HEAD" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index" }, { "role": "assistant", "content": "DESCRIPTION Compare the content and mode of the blobs found in a tree object\nwith the corresponding tracked files in the working tree, or with the\ncorresponding paths in the index. When <path> arguments are present,\ncompare only paths matching those patterns. Otherwise all tracked\nfiles are compared." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-send-email - Send a collection of patches as emails --subject=<string>" }, { "role": "assistant", "content": "Specify the initial subject of the email thread.\nOnly necessary if --compose is also set. If --compose\nis not set, this will be prompted for." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Different .gitconfig for a given subdirectory?\nI use two different git emails, one for work and one for public projects. Initially I thought that I could create a separate .gitconfig with a different email in a folder where all my public repos are in, and that git would respect that, but alas it seems that doesn't work. What's the best way to easily setup something similar? I want to avoid having to specifically change the email in each public repo." }, { "role": "assistant", "content": "The best way to do this since git 2.13 is to use Conditional includes.\nAn example (copied from an answer here):\nGlobal config ~/.gitconfig\n[user]\n name = John Doe\n email = [email protected]\n\n[includeIf \"gitdir:~/work/**\"]\n path = ~/work/.gitconfig\n\nWork specific config ~/work/.gitconfig\n[user]\n email = [email protected]" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Show diff between commits\nI am using Git on Ubuntu 10.04 (Lucid Lynx).\nI have made some commits to my master.\nHowever, I want to get the difference between these commits. All of them are on my master branch.\nFor example:\ncommit dj374\nmade changes\n\ncommit y4746\nmade changes\n\ncommit k73ud\nmade changes\n\nI want to get the difference between k73ud and dj374. However, when I did the following I couldn't see the changes I made in k73ud.\ngit diff k73ud..dj374 > master.patch" }, { "role": "assistant", "content": "Try\ngit diff k73ud^..dj374\n\nto make sure to include all changes of k73ud in the resulting diff.\ngit diff compares two endpoints (instead of a commit range).\nSince the OP wants to see the changes introduced by k73ud, they need to differentiate between the first parent commit of k73ud: k73ud^ (or k73ud^1 or k73ud~).\nThat way, the diff results will include changes since k73ud parent (meaning including changes from k73ud itself), instead of changes introduced since k73ud (up to dj374).\nAlso you can try:\ngit diff oldCommit..newCommit\ngit diff k73ud..dj374 \n\nand (1 space, not more):\ngit diff oldCommit newCommit\ngit diff k73ud dj374\n\nAnd if you need to get only files names (e.g. to copy hotfix them manually):\ngit diff k73ud dj374 --name-only\n\nAnd you can get changes applied to another branch:\ngit diff k73ud dj374 > my.patch\ngit apply my.patch" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I create a GitLab webhook?\n\nI've read that GitLab is capable of sending messages to other servers via \"web hooks\" but I can't find where one would create one.\nCan someone point me in the right direction?" }, { "role": "assistant", "content": "All the answers I've found in official documentation and on Stack Overflow for finding web hooks are incorrect. The admin area > hooks page does NOT contain web hooks. It contains system hooks, which fire when you create/delete projects and users and things like that. This is not what you want.\nTo find your web hooks, go to the specific project > settings > web hooks (on sidebar in GitLab 6.1.0) page. These will fire on post-receive for the project in question. You can use a service like RequestBin to see what the payload looks like and to ensure you're firing these off correctly for debugging purposes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-daemon - A really simple server for Git repositories --user-path --user-path=<path>" }, { "role": "assistant", "content": "Allow ~user notation to be used in requests. When\nspecified with no parameter, a request to\ngit://host/~alice/foo is taken as a request to access foo repository in the home directory of user alice .\nIf --user-path=<path> is specified, the same request is\ntaken as a request to access <path>/foo repository in\nthe home directory of user alice ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-mergetool" }, { "role": "assistant", "content": "Run merge conflict resolution tools to resolve merge conflicts" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Jenkins and Gitlab: Webhook isn't running\n\nI have a couple of servers:\n\nJenkins\nGitlab\n\nOn gitlab, I have a webhook:\nOn Push events -> http://{jenkinsIP}:8080/gitlab/build_now\n\nOn Jenkins, I have a job:\n\nSource Code Management:\nGit:\nRepository URL : git@{GitlabIP}:{Gitlabgroup}/{project}.git (copy from gitlab)\n\nCredential: key-pair working\nBranches to build: */master\nRepository browser: gitlab\nurl: http://{GitlabIP}/{Gitlabgroup}/{project}\n\nVersion: 6.5.1\nPoll SCM\nSchedule H/1 * * * *\n\n\nAny clue why Jenkins isn't running the job?" }, { "role": "assistant", "content": "On Jenkins, you should disable \"Poll SCM\" and set the \"Branches to build\" to \"master\" (not \"*/master\")" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Permission denied (public key) during fetch from GitHub with Jenkins user on Ubuntu\n\nHere is my setup:\n\nJenkins is running on my linux machine as 'jenkins' user.\nI have generated a ssh key-pair as described in Linux - Setup Git, for the 'jenkins' user.\nWhen I sudo su jenkins and try ssh -vT [email protected], I am always asked my passphrase, but I am always eventually authenicated. (the verbose option shows which key is used, among others).\nI could clone my repo from GitHub using jenkins:\n\nThusly:\njenkins@alpm:~/jobs/test git/workspace$ git pull \nEnter passphrase for key '/var/lib/jenkins/.ssh/id*_rsa':\nAlready up-to-date.\n\nUp to this point I have followed the instructions to the letter. The problem is that the Jenkins job fails with the following error:\nstatus code 128:\nstdout: \nstderr: Permission denied (publickey).\nfatal: The remote end hung up unexpectedly\n\nThis is same error as I get when I typo the passphrase (but of course, Jenkins does not ask me for the passphrase). The following pages:\n\nGitHub - SSH Issues\nUsing SSH Agent Forwarding\n\nindicate to me that ssh-agent could help remember the passphrase, which it does when I am using my own user, but not the jenkins id. Note that while running as my normal user yields:\necho \"$SSH_AUTH_SOCK\"\n/tmp/keyring-nQlwf9/ssh\n\nWhile running the same command as my 'jenkins' yields nothing (not even permission denied)\nMy understanding of the problem is that the passphrase is not remembered.\nDo you have any idea? \nShall I start a ssh-agent or key ring manager for the jenkins user? How?\nOr is ssh forwarding suitable when forwarding to the same machine?\nAny brighter idea?\nps: I never sudo gitted, I always used jenkins or my user account (as mentioned in this SO post - Ubuntu/GitHub SSH Key Issue)" }, { "role": "assistant", "content": "Since nobody wrote the answer from the comments for several months, I will quickly do so.\nThere are 2 possible problems/solutions:\n\nid_rsa created with wrong user\nCreate id_rsa as the jenkins user (see hudson cannot fetch from git repository)\n\nLeave passphrase empty" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_TRACE" }, { "role": "assistant", "content": "Enables general trace messages, e.g. alias expansion, built-in\ncommand execution and external command execution. If this variable is set to \"1\", \"2\" or \"true\" (comparison\nis case insensitive), trace messages will be printed to\nstderr. If the variable is set to an integer value greater than 2\nand lower than 10 (strictly) then Git will interpret this\nvalue as an open file descriptor and will try to write the\ntrace messages into this file descriptor. Alternatively, if the variable is set to an absolute path\n(starting with a / character), Git will interpret this\nas a file path and will try to append the trace messages\nto it. Unsetting the variable, or setting it to empty, \"0\" or\n\"false\" (case insensitive) disables trace messages." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-daemon - A really simple server for Git repositories git daemon as inetd server" }, { "role": "assistant", "content": "To set up git daemon as an inetd service that handles any\nrepository within /pub/foo or /pub/bar , place an entry like\nthe following into /etc/inetd all on one line: git stream tcp nowait nobody /usr/bin/git\n\t\tgit daemon --inetd --verbose --export-all\n\t\t/pub/foo /pub/bar" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-apply - Apply a patch to files and/or to the index -3 --3way" }, { "role": "assistant", "content": "Attempt 3-way merge if the patch records the identity of blobs it is supposed\nto apply to and we have those blobs available locally, possibly leaving the\nconflict markers in the files in the working tree for the user to\nresolve. This option implies the --index option unless the --cached option is used, and is incompatible with the --reject option.\nWhen used with the --cached option, any conflicts are left at higher stages\nin the cache." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Setting up Git on EC2 to pull from GitHub repo\n\nI'm kind of new to both EC2 and Git, and I have just set up my first instance of EC2, using a clean Amazon Linux AMI. I also installed MySQL, Apache and PHP and opened some ports to make it work as a normal web server, responding to an elastic IP as well.\nNow, my code is on a private repo on GitHub, and I would like to perform simple deployments by doing git pull or something like that. Git is also installed on the server already. I know I could set up my git repo on the server using my personal ssh key, but it seems odd. I guess another solution would be to create a new GitHub user and use it on the server, but it doesn't seem right either.\nHow do I achieve this in an elegant, safe way?" }, { "role": "assistant", "content": "To avoid having to keep an SSH private key on your EC2 instance, people often use a workflow that involves pushing to that remote server in order to deploy. Essentially, you set up a bare git repository there with a pre-receive hook that deploys to another directory. There is a simple example of doing this in this tutorial. Then you only need to have your SSH public key in ~/.ssh/authorized_keys on the server. However, with this workflow, you couldn't deploy directly from your GitHub repository - you would need to pull it locally and then push to the EC2 machine.\nAn alternative is to use GitHub's deploy keys mechanism. This would involve creating a new SSH key-pair on your EC2 instance, and adding the public key as a deploy key into your private repository on GitHub. Then you can pull directly from your private GitHub repository to your EC2 instance." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options http.maxRequests" }, { "role": "assistant", "content": "How many HTTP requests to launch in parallel. Can be overridden\nby the GIT_HTTP_MAX_REQUESTS environment variable. Default is 5." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What does \"1 line adds whitespace errors\" mean when applying a patch?\nI'm editing some markdown files of a cloned remote repository, and wanted to test creating and applying patches from one branch to another. However, every time I make any change at all, I get the following message during git apply:\n0001-b.patch:16: trailing whitespace.\nwarning: 1 line adds whitespace errors.\n\n(This is happening on my Mac, and I don't know where the original code was created.)\nWhat does the warning message mean, and do I need to care?" }, { "role": "assistant", "content": "You don't need to care.\nThe warning enacts a standard of cleanliness of text files in regard to whitespace, the kind of thing that many programmers tend to care about. As the manual explains:\n\nWhat are considered whitespace errors is controlled\n by core.whitespace configuration. By default, trailing whitespaces\n (including lines that solely consist of whitespaces) and a space\n character that is immediately followed by a tab character inside the\n initial indent of the line are considered whitespace errors.\nBy default, the command outputs warning messages but applies the patch.\n\nSo, the \"error\" means that the change introduces a trailing whitespace, a whitespace-only line, or a space that precedes a tab. Other than that fact, there is nothing erroneous about the change, and it will apply cleanly and correctly. In other words, if you don't care about the \"incorrect\" whitespace, feel free to ignore the warning or turn it off with git config apply.whitespace nowarn." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rebase - Reapply commits on top of another base tip" }, { "role": "assistant", "content": "INTERACTIVE MODE Rebasing interactively means that you have a chance to edit the commits\nwhich are rebased. You can reorder the commits, and you can\nremove them (weeding out bad or otherwise unwanted patches). The interactive mode is meant for this type of workflow: have a wonderful idea hack on the code prepare a series for submission submit where point 2. consists of several instances of a) regular use finish something worthy of a commit commit b) independent fixup realize that something does not work fix that commit it Sometimes the thing fixed in b.2. cannot be amended to the not-quite\nperfect commit it fixes, because that commit is buried deeply in a\npatch series. That is exactly what interactive rebase is for: use it\nafter plenty of \"a\"s and \"b\"s, by rearranging and editing\ncommits, and squashing multiple commits into one. Start it with the last commit you want to retain as-is: git rebase -i <after-this-commit> An editor will be fired up with all the commits in your current branch\n(ignoring merge commits), which come after the given commit. You can\nreorder the commits in this list to your heart’s content, and you can\nremove them. The list looks more or less like this: pick deadbee The oneline of this commit\npick fa1afe1 The oneline of the next commit\n... The oneline descriptions are purely for your pleasure; git rebase will\nnot look at them but at the commit names (\"deadbee\" and \"fa1afe1\" in this\nexample), so do not delete or edit the names. By replacing the command \"pick\" with the command \"edit\", you can tell git rebase to stop after applying that commit, so that you can edit\nthe files and/or the commit message, amend the commit, and continue\nrebasing. To interrupt the rebase (just like an \"edit\" command would do, but without\ncherry-picking any commit first), use the \"break\" command. If you just want to edit the commit message for a commit, replace the\ncommand \"pick\" with the command \"reword\". To drop a commit, replace the command \"pick\" with \"drop\", or just\ndelete the matching line. If you want to fold two or more commits into one, replace the command\n\"pick\" for the second and subsequent commits with \"squash\" or \"fixup\".\nIf the commits had different authors, the folded commit will be\nattributed to the author of the first commit. The suggested commit\nmessage for the folded commit is the concatenation of the first\ncommit’s message with those identified by \"squash\" commands, omitting the\nmessages of commits identified by \"fixup\" commands, unless \"fixup -c\"\nis used. In that case the suggested commit message is only the message\nof the \"fixup -c\" commit, and an editor is opened allowing you to edit\nthe message. The contents (patch) of the \"fixup -c\" commit are still\nincorporated into the folded commit. If there is more than one \"fixup -c\"\ncommit, the message from the final one is used. You can also use\n\"fixup -C\" to get the same behavior as \"fixup -c\" except without opening\nan editor. git rebase will stop when \"pick\" has been replaced with \"edit\" or\nwhen a command fails due to merge errors. When you are done editing\nand/or resolving conflicts you can continue with git rebase --continue . For example, if you want to reorder the last 5 commits, such that what\nwas HEAD~4 becomes the new HEAD . To achieve that, you would call git rebase like this: $ git rebase -i HEAD~5 And move the first patch to the end of the list. You might want to recreate merge commits, e.g. if you have a history\nlike this: X\n \\\n A---M---B\n /\n---o---O---P---Q Suppose you want to rebase the side branch starting at \"A\" to \"Q\". Make\nsure that the current HEAD is \"B\", and call $ git rebase -i -r --onto Q O Reordering and editing commits usually creates untested intermediate\nsteps. You may want to check that your history editing did not break\nanything by running a test, or at least recompiling at intermediate\npoints in history by using the \"exec\" command (shortcut \"x\"). You may\ndo so by creating a todo list like this one: pick deadbee Implement feature XXX\nfixup f1a5c00 Fix to feature XXX\nexec make\npick c0ffeee The oneline of the next commit\nedit deadbab The oneline of the commit after\nexec cd subdir; make test\n... The interactive rebase will stop when a command fails (i.e. exits with\nnon-0 status) to give you an opportunity to fix the problem. You can\ncontinue with git rebase --continue . The \"exec\" command launches the command in a shell (the default one, usually\n/bin/sh), so you can use shell features (like \"cd\", \">\", \";\" …​). The command\nis run from the root of the working tree. $ git rebase -i --exec \"make test\" This command lets you check that intermediate commits are compilable.\nThe todo list becomes like that: pick 5928aea one\nexec make test\npick 04d0fda two\nexec make test\npick ba46169 three\nexec make test\npick f4593f9 four\nexec make test" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options" }, { "role": "assistant", "content": "NAME git-config - Get and set repository or global options" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Set git config values for all child folders\nI know that it's possible to set per-repo configs which override the user-level config (i.e. /path/to/my/repo/.gitconfig overrides ~/.gitconfig). Is it possible to set git configs which override the user-level settings for all child folders of a given folder? I.e., I have\n|--topLevelFolder1\n|--\\\n| ---.gitconfig_override\n|--\\\n| ---childFolder1\n| \\---[...]\n|--\\\n| ---childFolder2\n| \\---[...]\n\nAnd I want the settings defined in .gitconfig_override to apply in childFolder1 and childFolder2.\nMy motivation for this is as follows: I have a work laptop which I also use in my spare time for personal projects. All my work code is nested within a single folder. When I push to work git repos, I need to do so with my work persona - work login instead of name, and work email. When I push to my own personal (github) repos, I want to do so with my real name and personal email.\nOther possible solutions I've thought of (and problems):\n\nCreate separate users for \"work\" and \"play\", set their user-level settings appropriately, and log in as the appropriate user when I switch context (hassle, plus I could easily forget to switch)\nCreate a script that searches for git repos inside \"workFolder\", and adds/updates their .gitconfig files to hold the appropriate details (if I create a repo and forget to run the script before pushing, I will push as the wrong person)\n\"hack\" git such that every time it creates a repo, it checks the filepath and, if appropriate, updates the .gitconfig file (complicated, messy, and almost certainly The Wrong Way To Do It - plus, I wouldn't have the first clue how to go about it!)\n\nI checked this question, which only seems to contain solutions for single repos, not multiple. Hopefully someone will see this question who missed that one!" }, { "role": "assistant", "content": "As mentioned by NateEag's edit, git's Conditional Includes are perfect for this. Since that answer's the one for people on git < 2.13, here's one for those who have newer versions.\nFirst, create a new config file somewhere with the settings you want to take effect in the sub-folders - using the original question's folders, let's say it's at ~/topLevelFolder1/.gitconfig_include\nIn ~/.gitconfig, add:\n[includeIf \"gitdir:~/toplevelFolder1/\"]\n path = ~/topLevelFolder1/.gitconfig_include\n\nAny subfolder of ~/topLevelFolder1 will now include the config in ~/toplevelFolder1/.gitconfig_include - there isn't a need to manually change the .git/config in each subfolder's repo. (This doesn't override whatever's in the subfolder config - it just adds to it, as \"include\" implies.)\nNotes:\n\nWithin ~/.gitconfig this setting should be located after the config you want to override because includeIf will be overridden again by any config that comes after it.\nThis setting includes the file only if you are in a repository under the given path. It's ignored if you're in any non-repository sub-path.\nThe trailing forward slash (/) in the gitdir condition is important.\ngit config --list is good for testing this. You'll see any overrides below includeIf lines in the output. You can also check specific entries with, e.g., git config --get user.email\nOn Git for Windows, specify paths relative to your user directory with ~/ and absolute paths with the Windows-style drive, like C:/ using forward slashes only. Backslashes and Unix-style mount points like /c/ don't work. Furthermore, in the includeIf part, you must specify the path with the correct case as the comparisons are case sensitive." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I discard modified files?\nThis is a Linux 2.6 kernel repository. I git clone it to my local host.\nAfter that. I didn't make any change. But when I \"git status\". I found 13 modified files. I want to discard them, but I can't.\n> luke@Macbook-Pro~/Documents/workspace/linuxkernel/linux-2.6$ git\n> status\n> # On branch master\n> # Changes not staged for commit:\n> # (use \"git add <file>...\" to update what will be committed)\n> # (use \"git checkout -- <file>...\" to discard changes in working directory)\n> #\n> # modified: include/linux/netfilter/xt_connmark.h\n> # modified: include/linux/netfilter/xt_dscp.h\n> # modified: include/linux/netfilter/xt_mark.h\n> # modified: include/linux/netfilter/xt_rateest.h\n> # modified: include/linux/netfilter/xt_tcpmss.h\n> # modified: include/linux/netfilter_ipv4/ipt_ecn.h\n> # modified: include/linux/netfilter_ipv4/ipt_ttl.h\n> # modified: include/linux/netfilter_ipv6/ip6t_hl.h\n> # modified: net/ipv4/netfilter/ipt_ecn.c\n> # modified: net/netfilter/xt_dscp.c\n> # modified: net/netfilter/xt_hl.c\n> # modified: net/netfilter/xt_rateest.c\n> # modified: net/netfilter/xt_tcpmss.c\n> #\n> # Untracked files:\n> # (use \"git add <file>...\" to include in what will be committed)\n> #\n> # samples/hidraw/ no changes added to commit (use \"git add\" and/or \"git commit -a\")\n> luke@Macbook-Pro~/Documents/workspace/linuxkernel/linux-2.6$ git\n> checkout -- include/linux/netfilter/xt_connmark. h\n> luke@Macbook-Pro~/Documents/workspace/linuxkernel/linux-2.6$ git\n> status\n> # On branch master\n> # Changes not staged for commit:\n> # (use \"git add <file>...\" to update what will be committed)\n> # (use \"git checkout -- <file>...\" to discard changes in working directory)\n> #\n> # modified: include/linux/netfilter/xt_CONNMARK.h\n> # modified: include/linux/netfilter/xt_dscp.h\n> # modified: include/linux/netfilter/xt_mark.h\n> # modified: include/linux/netfilter/xt_rateest.h\n> # modified: include/linux/netfilter/xt_tcpmss.h\n> # modified: include/linux/netfilter_ipv4/ipt_ecn.h\n> # modified: include/linux/netfilter_ipv4/ipt_ttl.h\n> # modified: include/linux/netfilter_ipv6/ip6t_hl.h\n> # modified: net/ipv4/netfilter/ipt_ecn.c\n> # modified: net/netfilter/xt_dscp.c\n> # modified: net/netfilter/xt_hl.c\n> # modified: net/netfilter/xt_rateest.c\n> # modified: net/netfilter/xt_tcpmss.c\n> #\n> # Untracked files:\n> # (use \"git add <file>...\" to include in what will be committed)\n> #\n> # samples/hidraw/ no changes added to commit (use \"git add\" and/or \"git commit -a\")\n> luke@Macbook-Pro~/Documents/workspace/linuxkernel/linux-2.6$ git\n> checkout -- include/linux/netfilter/xt_dscp.h\n> luke@Macbook-Pro~/Documents/workspace/linuxkernel/linux-2.6$ git\n> status\n> # On branch master\n> # Changes not staged for commit:\n> # (use \"git add <file>...\" to update what will be committed)\n> # (use \"git checkout -- <file>...\" to discard changes in working directory)\n> #\n> # modified: include/linux/netfilter/xt_CONNMARK.h\n> # modified: include/linux/netfilter/xt_DSCP.h\n> # modified: include/linux/netfilter/xt_mark.h\n> # modified: include/linux/netfilter/xt_rateest.h\n> # modified: include/linux/netfilter/xt_tcpmss.h\n> # modified: include/linux/netfilter_ipv4/ipt_ecn.h\n> # modified: include/linux/netfilter_ipv4/ipt_ttl.h\n> # modified: include/linux/netfilter_ipv6/ip6t_hl.h\n> # modified: net/ipv4/netfilter/ipt_ecn.c\n> # modified: net/netfilter/xt_dscp.c\n> # modified: net/netfilter/xt_hl.c\n> # modified: net/netfilter/xt_rateest.c\n> # modified: net/netfilter/xt_tcpmss.c\n> #\n> # Untracked files:\n> # (use \"git add <file>...\" to include in what will be committed)\n> #\n> # samples/hidraw/ no changes added to commit (use \"git add\" and/or \"git commit -a\")\n> luke@Macbook-Pro~/Documents/workspace/linuxkernel/linux-2.6$ \n> \n\nedited:\nluke@Macbook-Pro~/Documents/workspace/linuxkernel/linux-2.6$ git config -l\nuser.name=99999\nuser.email=99999\nalias.co=checkout\ncore.editor=mate -w\ncore.edit=mate -w\ncore.excludesfile=/Users/luke/.gitignore_global\ndifftool.sourcetree.cmd=opendiff \"$LOCAL\" \"$REMOTE\"\ndifftool.sourcetree.path=\nmergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"\nmergetool.sourcetree.trustexitcode=true\ncore.repositoryformatversion=0\ncore.filemode=true\ncore.bare=false\ncore.logallrefupdates=true\ncore.ignorecase=true\n\nedited: this is my diff file:\ndiff --git a/include/linux/netfilter/xt_CONNMARK.h b/include/linux/netfilter/xt_CONNMARK.h\nindex 2f2e48e..efc17a8 100644\n--- a/include/linux/netfilter/xt_CONNMARK.h\n+++ b/include/linux/netfilter/xt_CONNMARK.h\n@@ -1,6 +1,31 @@\n-#ifndef _XT_CONNMARK_H_target\n-#define _XT_CONNMARK_H_target\n+#ifndef _XT_CONNMARK_H\n+#define _XT_CONNMARK_H\n\n-#include <linux/netfilter/xt_connmark.h>\n+#include <linux/types.h>\n\n-#endif /*_XT_CONNMARK_H_target*/\n+/* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com>\n+ * by Henrik Nordstrom <[email protected]>\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version.\n+ */\n+\n+enum {\n+ XT_CONNMARK_SET = 0,\n+ XT_CONNMARK_SAVE,\n+ XT_CONNMARK_RESTORE\n+};\n+\n+struct xt_connmark_tginfo1 {\n+ __u32 ctmark, ctmask, nfmask;\n+ __u8 mode;\n+};\n+\n+struct xt_connmark_mtinfo1 {\n+ __u32 mark, mask;\n+ __u8 invert;\n+};\n+\n+#endif /*_XT_CONNMARK_H*/\ndiff --git a/include/linux/netfilter/xt_DSCP.h b/include/linux/netfilter/xt_DSCP.h\nindex 648e0b3..15f8932 100644\n--- a/include/linux/netfilter/xt_DSCP.h\n+++ b/include/linux/netfilter/xt_DSCP.h\n@@ -1,26 +1,31 @@\n-/* x_tables module for setting the IPv4/IPv6 DSCP field\n+/* x_tables module for matching the IPv4/IPv6 DSCP field\n *\n * (C) 2002 Harald Welte <[email protected]>\n- * based on ipt_FTOS.c (C) 2000 by Matthew G. Marsh <[email protected]>\n * This software is distributed under GNU GPL v2, 1991\n *\n * See RFC2474 for a description of the DSCP field within the IP Header.\n *\n- * xt_DSCP.h,v 1.7 2002/03/14 12:03:13 laforge Exp\n+ * xt_dscp.h,v 1.3 2002/08/05 19:00:21 laforge Exp\n */\n-#ifndef _XT_DSCP_TARGET_H\n-#define _XT_DSCP_TARGET_H\n-#include <linux/netfilter/xt_dscp.h>\n+#ifndef _XT_DSCP_H\n+#define _XT_DSCP_H\n+\n #include <linux/types.h>\n\n-/* target info */\n-struct xt_DSCP_info {\n+#define XT_DSCP_MASK 0xfc /* 11111100 */\n+#define XT_DSCP_SHIFT 2\n+#define XT_DSCP_MAX 0x3f /* 00111111 */\n+\n+/* match info */\n+struct xt_dscp_info {\n __u8 dscp;\n+ __u8 invert;\n };\n\n-struct xt_tos_target_info {\n- __u8 tos_value;\n+struct xt_tos_match_info {\n __u8 tos_mask;\n+ __u8 tos_value;\n+ __u8 invert;\n };\n\n-#endif /* _XT_DSCP_TARGET_H */\n+#endif /* _XT_DSCP_H */\ndiff --git a/include/linux/netfilter/xt_mark.h b/include/linux/netfilter/xt_mark.h\nindex ecadc40..41c456d 100644\n--- a/include/linux/netfilter/xt_mark.h\n+++ b/include/linux/netfilter/xt_mark.h\n@@ -1,15 +1,6 @@\n-#ifndef _XT_MARK_H\n-#define _XT_MARK_H\n+#ifndef _XT_MARK_H_target\n+#define _XT_MARK_H_target\n\n-#include <linux/types.h>\n+#include <linux/netfilter/xt_mark.h>\n\n-struct xt_mark_tginfo2 {\n- __u32 mark, mask;\n-};\n-\n-struct xt_mark_mtinfo1 {\n- __u32 mark, mask;\n- __u8 invert;\n-};\n-\n-#endif /*_XT_MARK_H*/\n+#endif /*_XT_MARK_H_target */\ndiff --git a/include/linux/netfilter/xt_rateest.h b/include/linux/netfilter/xt_rateest.h\nindex d40a619..6605e20 100644\n--- a/include/linux/netfilter/xt_rateest.h\n+++ b/include/linux/netfilter/xt_rateest.h\n@@ -1,37 +1,15 @@\n-#ifndef _XT_RATEEST_MATCH_H\n-#define _XT_RATEEST_MATCH_H\n+#ifndef _XT_RATEEST_TARGET_H\n+#define _XT_RATEEST_TARGET_H\n\nDue to Stack Overflow length limit. Only part of diff file can be copied here.\nstill need help" }, { "role": "assistant", "content": "A git reset --hard HEAD should solve the problem." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "giteveryday - A useful minimum set of commands for Everyday Git" }, { "role": "assistant", "content": "DESCRIPTION Git users can broadly be grouped into four categories for the purposes of\ndescribing here a small set of useful commands for everyday Git. Individual Developer (Standalone) commands are essential\nfor anybody who makes a commit, even for somebody who works alone. If you work with other people, you will need commands listed in\nthe Individual Developer (Participant) section as well. People who play the Integrator role need to learn some\nmore commands in addition to the above. Repository Administration commands are for system\nadministrators who are responsible for the care and feeding\nof Git repositories." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Undo git add --all [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do I undo 'git add' before commit?\n\n (38 answers)\n \n\nClosed 9 years ago.\n\n\n\nI made a mistake and called git add -all, now all files are added. I did not make a commit and push. How can I undo my action?" }, { "role": "assistant", "content": "It has already been answered several times:\n\nYou can use git reset. This will 'unstage' all the files you've\n added after your last commit.\nIf you want to unstage only some files, use git reset -- <file 1>\n <file 2> <file n>.\nAlso it's possible to unstage some of the changes in files by using\n git reset -p.\n\nSee\n\nHow to undo 'git add' before commit?\nHow can you undo the last git add?" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can't add git submodule when specified as a relative path\nI'm trying to add a submodule to my git repo, and I'm getting this error in return: \nremote origin does not have a url defined in .git/config\n\nany ideas about what this might be? I tried googling for it but only one vague link comes up.\nI'm doing this: \ngit submodule add ../extern/Lib1 lib \n\nI'm expecting this to create a submodule lib/Lib1\nI'm aware that this will only create a reference and that I then have to update/init (not crystal clear on this part, haven't gotten that far; I'm just learning the submodule command)." }, { "role": "assistant", "content": "Does ../extern/Lib1 refer to a Git repository?\nIf it does not, Git wouldn't know how to have the Git repo URL to its .gitmodule\nAlso, try:\n\nwith the destination lib not already existing (even empty)\nwith an absolute path instead of a relative path (you can use a relative one, but just in case, it is worth a try here)\n\nSome good sources on submodules are:\n\nchapter 8 of Git User's manual\nWiki page on Git Submodule Tutorial\nand of course\nGit submodule man page\n\n\nSince only the absolute path works here, it means the relative path need a reference to be compared against.\nThat reference is the \"remote origin\" which should be in your DirName/NewRepo_withSubmodules/.git/config file, like so:\n$ cat .git/config\n ...\n [remote \"origin\"]\n url = /path/to/DirName/NewRepo_withSubmodules/.git\n fetch = +refs/heads/*:refs/remotes/origin/*\n ...\n\nIf you do have that section in ../DirName/NewRepo_withSubmodules/.git/config file, you should be able to add ../Extern/Lib1 as a submodule using a relative path.\nAll the above is inspired from the following section of the git submodule man page:\n\n<repository> is the URL of the new submodule's origin repository.\nThis may be either an absolute URL, or (if it begins with ./ or ../), the location relative to the superproject's origin repository.\n\nSo if NewRepo_withSubmodules is a local Git repo which has just been created (and has of course no \"origin\"), an artificial \"remote origin\" ought to be defined (even if the origin points to itself), if only to allow relative URL for other submodule repositories to be used.\n\nGit 2.13 (Q2 2017) will improve the detection of the default origin of a submodule.\nSee commit d1b3b81 (25 Feb 2017) by Stefan Beller (stefanbeller).\n(Merged by Junio C Hamano -- gitster -- in commit ae900eb, 10 Mar 2017)\n\nsubmodule init: warn about falling back to a local path\n\nAs now documented:\n\n<repository> is the URL of the new submodule's origin repository.\nThis may be either an absolute URL, or (if it begins with ./ or ../), the location relative to the superproject's default remote repository\n(Please note that to specify a repository 'foo.git' which is located right next to a superproject 'bar.git', you'll have to use '../foo.git' instead of './foo.git' - as one might expect when following the rules for relative URLs - because the evaluation of relative URLs in Git is identical to that of relative directories).\nThe default remote is the remote of the remote tracking branch of the current branch.\nIf no such remote tracking branch exists or the HEAD is detached, \"origin\" is assumed to be the default remote.\nIf the superproject doesn't have a default remote configured, the superproject is its own authoritative upstream and the current.\nWorking directory is used instead.\n\n\nGit 2.20 (Q4 2018) improves local path support for submodules.\nSee commit e0a862f (16 Oct 2018) by Stefan Beller (stefanbeller).\n(Merged by Junio C Hamano -- gitster -- in commit 3fc8522, 06 Nov 2018)\n\nsubmodule helper: convert relative URL to absolute URL if needed\n\n\nThe submodule helper update_clone called by \"git submodule update\", clones submodules if needed.\nAs submodules used to have the URL indicating if they were active, the step to resolve relative URLs was done in the \"submodule init\" step. Nowadays, submodules can be configured active without calling an explicit init, e.g. via configuring submodule.active.\nWhen trying to obtain submodules that are set active this way, we'll fallback to the URL found in the .gitmodules, which may be relative to the superproject, but we do not resolve it, yet:\ngit clone https://gerrit.googlesource.com/gerrit\ncd gerrit && grep url .gitmodules\n url = ../plugins/codemirror-editor\n ...\ngit config submodule.active .\ngit submodule update\n fatal: repository '../plugins/codemirror-editor' does not exist\n fatal: clone of '../plugins/codemirror-editor' into submodule path '/tmp/gerrit/plugins/codemirror-editor' failed\n Failed to clone 'plugins/codemirror-editor'. Retry scheduled\n [...]\n fatal: clone of '../plugins/codemirror-editor' into submodule path '/tmp/gerrit/plugins/codemirror-editor' failed\n Failed to clone 'plugins/codemirror-editor' a second time, aborting\n [...]\n\nTo resolve the issue, factor out the function that resolves the relative URLs in \"git submodule init\" (in the submodule helper in the init_submodule function) and call it at the appropriate place in the update_clone helper.\n\n\n\"git submodule\"(man) code trusted the data coming from the config (and the in-tree .gitmodules file) too much without validating, leading to NULL dereference if the user mucks with a repository (e.g. when submodule.<name>.url is removed).\nThis has been corrected with Git 2.42 (Q3 2023).\nSee commit fbc806a (24 May 2023) by Taylor Blau (ttaylorr).\n(Merged by Junio C Hamano -- gitster -- in commit 9cd234e, 20 Jun 2023)\n\nbuiltin/submodule--helper.c: handle missing submodule URLs\nReported-by: Tribo Dar\nSigned-off-by: Taylor Blau\n\n\nIn e0a862f (\"submodule helper: convert relative URL to absolute URL if needed\", 2018-10-16, Git v2.20.0-rc0 -- merge listed in batch #9), prepare_to_clone_next_submodule() lost the ability to handle URL-less submodules, due to a change from:\nif (repo_get_config_string_const(the_repostiory, sb.buf, &url))\n url = sub->url;\n\nto\nif (repo_get_config_string_const(the_repostiory, sb.buf, &url)) {\n if (starts_with_dot_slash(sub->url) ||\n starts_with_dot_dot_slash(sub->url)) {\n /* ... */\n }\n}\n\n,which will segfault when sub->url is NULL, since both starts_with_dot_slash() does not guard its arguments as non-NULL.\nGuard the checks to both of the above functions by first checking whether sub->url is non-NULL.\nThere is no need to check whether sub itself is NULL, since we already perform this check earlier in prepare_to_clone_next_submodule().\nBy adding a NULL-ness check on sub->url, we'll fall into the 'else' branch, setting url to sub->url (which is NULL).\nBefore attempting to invoke git submodule--helper clone, check whether url is NULL, and die() if it is." } ]