messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-notes - Add or inspect object notes notes.rewrite.<command>" }, { "role": "assistant", "content": "When rewriting commits with <command> (currently amend or rebase ), if this variable is false , git will not copy\nnotes from the original to the rewritten commit. Defaults to true . See also \" notes.rewriteRef \" below. This setting can be overridden with the GIT_NOTES_REWRITE_REF environment variable, which must be a colon separated list of refs or\nglobs." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to migrate GIT repository from one server to a new one\nI have a server that I'm taking down. The only thing I have left to migrate is my repository. This server is listed as the origin (master) for one of my projects. What is the proper way to move the repository to keep the history." }, { "role": "assistant", "content": "Updated to use git push --mirror origin instead of git push -f origin as suggested in the comments.\n\nThis worked for me flawlessly.\ngit clone --mirror <URL to my OLD repo location>\ncd <New directory where your OLD repo was cloned>\ngit remote set-url origin <URL to my NEW repo location>\ngit push --mirror origin\n\nI have to mention though that this creates a mirror of your current repo and then pushes that to the new location. Therefore, this can take some time for large repos or slow connections.\nSee also the receipt in section \"Extra\" of How to move a git repository with history | Atlassian Git Tutorial." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options guitool.<name>.revUnmerged" }, { "role": "assistant", "content": "Show only unmerged branches in the revPrompt subdialog.\nThis is useful for tools similar to merge or rebase, but not\nfor things like checkout or reset." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-merge-index" }, { "role": "assistant", "content": "Run a merge for files needing merging" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Connecting to docker-in-docker from a GitLab CI runner\n\nI have a GitLab pipeline that I want to:\n\nBuild a Java app\nTest using docker-compose\nPush to my Docker repository\n\nThe primary issue I'm having is that this works:\nservices:\n - docker:dind\n\ndocker_test:\n stage: docker_test\n image: docker:latest\n script:\n - docker version\n\nThe output is printed as expected:\n> gitlab-ci-multi-runner exec docker --docker-privileged docker_test\n...\n$ docker version\nClient:\n Version: 17.06.0-ce\n...\nServer:\n Version: 17.06.0-ce\n...\nBuild succeeded\n\nWhile this does not (installation steps for docker-ce omitted):\nservices:\n - docker:dind\n\ndocker_test:\n stage: docker_test\n image: ubuntu:latest << note change\n script:\n - docker version\n\nIt fails with:\n$ docker version\nClient:\n Version: 17.06.0-ce\n API version: 1.30\n Go version: go1.8.3\n Git commit: 02c1d87\n Built: Fri Jun 23 21:23:31 2017\n OS/Arch: linux/amd64\nCannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?\nERROR: Build failed: exit code 1\nFATAL: exit code 1\n\nHow do I make my ubuntu image (or whatever image is going to build my project) connect to the linked Docker-in-Docker service? What is docker:latest doing that I'm not?\nI've read up on the GitLab services documentation, but it only makes sense to me from a hostname perspective. (If you have a mysql service, you can connect over mysql:3306.)\nEdit: Updating the command to echo $DOCKER_HOST, I see in the docker:latest image:\n$ echo $DOCKER_HOST\ntcp://docker:2375\n\nAnd in the ubuntu:latest image I see:\n$ echo $DOCKER_HOST\n(nothing - but SO doesn't let me add a blank code line)" }, { "role": "assistant", "content": "As the information you've added, I hope that this does work:\nservices:\n - docker:dind\n\ndocker_test:\n stage: docker_test\n image: ubuntu:latest\n variables:\n DOCKER_HOST: \"tcp://docker:2375\"\n script:\n - docker version\n\nAlternatively:\nservices:\n - docker:dind\n\ndocker_test:\n stage: docker_test\n image: ubuntu:latest \n script:\n - export DOCKER_HOST=tcp://docker:2375\n - docker version\n\nIt seems that Gitlab does not set the DOCKER_HOST variable for custom images." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-rerere" }, { "role": "assistant", "content": "Reuse recorded resolution of conflicted merges" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How does the github website work (architecture)? [closed]\n\nClosed. This question needs to be more focused. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it focuses on one problem only by editing this post.\n\n\nClosed 4 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nGithub is a truly amazing service. I'm keen to understand what their architecture is like and how they fit the different pieces together; how they store the repositories, how they access those repositories to show file contents, how they handle displaying diffs, etc. Could someone give an overview of the technologies and techniques they use, so I can study them to expand my knowledge and in turn skills?" }, { "role": "assistant", "content": "The core of Github is the open-source software git, which is a distributed version control and source code management software. Github adds many features onto git's functionality, including issue tracking, wiki, access control, etc.\nHowever, Github is proprietary software, and many of it's internals remain unknown to general public.\nIn order to find out how pieces are fit together, I suggest following the leads below:\n\nGithub's official Engineering Blog, which covers a wide range of topics of the design of the platform.\n\n\nespecially this article, an extensive overview written by Github CTO.\n\nProjects that power Github, an officially curated list of open-source projects that power Github. Here are a few highlights:\n\n\nrails - web backend\njekyll - blog engine behind Github Pages\nelasticsearch - search engine\nhubot - a chat bot for task automation\nace - browswer based code editor\nd3 - js lib for graphs and charts\nresque - background works\n\nGitLab, an open-source alternative to Github, which offers pretty much the same functionalities.\n\n\nRead the source code of GitLab and you'll get to know how GitLab (and Github as well) works under the hood.\nGitLab Architecture Overview. This article is definitely a good entry point.\n\n\nI stole a system layout diagram from Gitlab Architecture Overview. Bet you've already get a hang of how gitlab works from this diagram.\n(There surely are lots of difference between Github and GitLab. But an open-source project is always better for someone who wants to learn, isn't it?)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker gitk" }, { "role": "assistant", "content": "The Git repository browser" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do you move a commit to the staging area in git?\nIf you want to move a commit to the staging area - that is uncommit it and move all of the changes which were in it into the staging area (effectively putting the branch in the state that it would have been in prior to the commit) - how do you do it? Or is it something that you can't do?\nThe closest that I know how to do is to copy all of the files that were changed in the commit to somewhere else, reset the branch to the commit before the commit that you're trying to move into the staging area, move all of the copied files back into the repository, and then add them to the staging area. It works, but it's not exactly a nice solution. What I'd like to be able to do is just undo the commit and move its changing into the staging area. Can it be done? And if so, how?" }, { "role": "assistant", "content": "git reset --soft HEAD^\n\nThis will reset your index to HEAD^ (the previous commit) but leave your changes in the staging area.\nThere are some handy diagrams in the git-reset docs\nIf you are on Windows you might need to use this format:\ngit reset --soft HEAD~1" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-switch - Switch branches --ignore-other-worktrees" }, { "role": "assistant", "content": "git switch refuses when the wanted ref is already\nchecked out by another worktree. This option makes it check\nthe ref out anyway. In other words, the ref can be held by\nmore than one worktree." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-commit-tree" }, { "role": "assistant", "content": "Create a new commit object" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-cherry" }, { "role": "assistant", "content": "Find commits yet to be applied to upstream" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database zeroPaddedFilemode" }, { "role": "assistant", "content": "(WARN) Found a zero padded filemode in a tree." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-blame - Show what revision and author last modified each line of a file" }, { "role": "assistant", "content": "SPECIFYING RANGES Unlike git blame and git annotate in older versions of git, the extent\nof the annotation can be limited to both line ranges and revision\nranges. The -L option, which limits annotation to a range of lines, may be\nspecified multiple times. When you are interested in finding the origin for\nlines 40-60 for file foo , you can use the -L option like so\n(they mean the same thing — both ask for 21 lines starting at\nline 40): git blame -L 40,60 foo\ngit blame -L 40,+21 foo Also you can use a regular expression to specify the line range: git blame -L '/^sub hello {/,/^}$/' foo which limits the annotation to the body of the hello subroutine. When you are not interested in changes older than version\nv2.6.18, or changes older than 3 weeks, you can use revision\nrange specifiers similar to git rev-list : git blame v2.6.18.. -- foo\ngit blame --since=3.weeks -- foo When revision range specifiers are used to limit the annotation,\nlines that have not changed since the range boundary (either the\ncommit v2.6.18 or the most recent commit that is more than 3\nweeks old in the above example) are blamed for that range\nboundary commit. A particularly useful way is to see if an added file has lines\ncreated by copy-and-paste from existing files. Sometimes this\nindicates that the developer was being sloppy and did not\nrefactor the code properly. You can first find the commit that\nintroduced the file with: git log --diff-filter=A --pretty=short -- foo and then annotate the change between the commit and its\nparents, using commit^! notation: git blame -C -C -f $commit^! -- foo" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-for-each-ref - Output information on each ref --format=<format>" }, { "role": "assistant", "content": "A string that interpolates %(fieldname) from a ref being shown and\nthe object it points at. In addition, the string literal %% renders as % and %xx - where xx are hex digits - renders as\nthe character with hex code xx . For example, %00 interpolates to \\0 (NUL), %09 to \\t (TAB), and %0a to \\n (LF). When unspecified, <format> defaults to %(objectname) SPC %(objecttype)\nTAB %(refname) ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I push to GitHub under a different username?\nA friend and myself are sharing my computer. I've made pushes to GitHub using the git bash shell on Windows 7. Now we're in a different project on that computer and I need her to push to her account. But it keeps trying to use my username and saying I don't have access to her repository:\n$ git push her_github_repository our_branch\nERROR: Permission to her_username/repository.git denied to my_username.\nfatal: The remote end hung up unexpectedly\nIMPORTANT: *Support for password authentication was removed on August 13, 2021.*" }, { "role": "assistant", "content": "This worked for me, it will prompt for username and password\ngit config --local credential.helper \"\"\ngit push origin master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-push - Update remote refs along with associated objects --porcelain" }, { "role": "assistant", "content": "Produce machine-readable output. The output status line for each ref\nwill be tab-separated and sent to stdout instead of stderr. The full\nsymbolic names of the refs will be given." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git commit bash script\nI'm writing a bash script to add, commit, push all files in a directory.\n#!/bin/bash \ngit add . \nread -p \"Commit description: \" desc \ngit commit -m $desc \ngit push origin master\n\nI'm getting the following error:\n$ ./togithub \nCommit description: \ntest commit script \nerror: pathspec 'commit' did not match any file(s) known to git. \nerror: pathspec 'script\"' did not match any file(s) known to git. \nEverything up-to-date\n\nI'm not sure if this is a problem with reading in the text (it echos fine) or passing it to git commit -m." }, { "role": "assistant", "content": "You have to do:\ngit commit -m \"$desc\"\n\nIn the current script, test is going as commit message and commit and script are being treated as next arguments." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to rebase local branch onto remote master\nI have a cloned project from a master branch from remote repository remote_repo. I created a new branch and I committed to that branch. Other programmers pushed to the master branch in the remote_repo.\nI now need to rebase my local branch RB onto remote_repo's master branch.\nHow to do this? What commands to type to a terminal?" }, { "role": "assistant", "content": "First fetch the new master from the upstream repository, then rebase your work branch on that:\ngit fetch origin # Updates origin/master\ngit rebase origin/master # Rebases current branch onto origin/master\n\nUpdate: Please see Paul Draper's answer for a more concise way to do the same - recent Git versions provide a simpler way to do the equivalent of the above two commands." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Meaning of Github Ahead/Behind Metrics\n\nIn plain language (hopefully with a simple example), what do the ahead/behind metrics on a Github repo's branch mean?\nAnd what are the implications for that branch and the attention it's receiving? Is being \"behind\" a bad sign for a branch?" }, { "role": "assistant", "content": "Ahead is the number of commits on this branch that do not exist on the base branch. Behind is the number of commits on the base branch that do not exist on this branch.\nAhead and behind are almost like a kind of \"age\" metric. The ahead number tells you roughly how much impact the branch will have on the base branch should it be merged. The behind number tells you how much work has happened on the base branch since this branch was started.\nI find the behind number really useful for judging whether a branch is likely to merge cleanly. When a lot of work has happened on the base branch, it's more likely that the two branches have modified the same line(s). When behind is large, it's a sign that you should probably merge the base branch into this branch to sync up. Once you merge the base branch into this branch, behind will be 0." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to deploy Python packages to Gitlab Package Registry with Poetry?\n\nI'm trying to set up Poetry to deploy packages to our internal Gitlab Package Registry. According to other sources online the repository ID should be https://gitlab.com/api/v4/projects/<project id>/packages/pypi, but no matter what I try, Poetry returns\n\n[UploadError]\nHTTP Error 404: Not Found\n\nAnyone got this working ?" }, { "role": "assistant", "content": "If you are attempting to deploy from GitLab CI, GitLab automatically creates a user and token combination that can be used to authenticate in the CI context under the user gitlab-ci-token and the password in the $CI_JOB_TOKEN variable.\nAll you need to do that is poetry specific is set the config values for poetry to know the package registry exists, then pass this for authentication. All of which can be done just in the CI config/script.\n script:\n - poetry build\n - poetry config repositories.gitlab \"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi\"\n - poetry config http-basic.gitlab gitlab-ci-token \"$CI_JOB_TOKEN\"\n - poetry publish --repository gitlab\n\nIf you are deploying from outside of GitLab CI, then you would need that access token and to provide values as used in the script above." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --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": "git-log - Show commit logs %an" }, { "role": "assistant", "content": "author name" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker gittutorial" }, { "role": "assistant", "content": "A tutorial introduction to Git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Elegant solution to prevent force push on master only\nI'm trying to figure out a good way to prevent developers from force pushing master with Git. We used GitHub to host our remote repositories so a pre-receive hook isn't an option. Any other solutions that could easily be implemented for a team of developers?\nAs a side note, I don't want to disable force pushing in general. Sometimes it is a necessary evil. But that said, force pushing on master cannot happen." }, { "role": "assistant", "content": "Update\nGithub has since introduced the concept of protected branches. It can be found under Settings -> Branches -> Protected Branches \nThis \"protection\" can be enabled for any branch, and for any user, including admins.\nMore details here - https://help.github.com/articles/defining-the-mergeability-of-pull-requests/\n\nYou cannot prevent this in Github.\nWhat you can do is have an intermediate repo on your side, run a pre-receive hook in that to prevent force push and push from this intermediate repo to github and block access for direct push to github. Yeah this is not elegant and you lose lots of features with Github, but I don't see any other way.\nEdit: Just came across this answer, which says the same and gives another workaround: GitHub - prevent collaborators from using push -f" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %ct" }, { "role": "assistant", "content": "committer date, UNIX timestamp" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs git log master --not --remotes=*/master" }, { "role": "assistant", "content": "Shows all commits that are in local master but not in any remote\nrepository master branches." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "giteveryday - A useful minimum set of commands for Everyday Git Branch off of a specific tag." }, { "role": "assistant", "content": "$ git switch -c private2.6.14 v2.6.14 (1) $ edit/compile/test; git commit -a\n$ git checkout master\n$ git cherry-pick v2.6.14..private2.6.14 (2) create a private branch based on a well known (but somewhat behind)\ntag. forward port all changes in private2.6.14 branch to master branch\nwithout a formal \"merging\". Or longhand git format-patch -k -m --stdout v2.6.14..private2.6.14 |\n git am -3 -k" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)\nerror: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)\n\nI tried 'push' while writing 'git'.\nHowever, the following message does not solve the problem." }, { "role": "assistant", "content": "You can force git using http version 1.1 \ngit config --global http.version HTTP/1.1\n\nhttps://gist.github.com/daofresh/0a95772d582cafb202142ff7871da2fc" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git repository URL - SSH syntax without absolute path\nI'm running a git repository server accessible via SSH, on a custom port (let's say 12345). I have found that in this case the repository URLs need to be specified using SSH syntax:\ngit clone ssh://[email protected]:12345/absolute/path/to/repository\n\nI'd like to setup it in such a way that it would be possible for users to clone repositories without specifying the absolute path.\ngit clone ssh://[email protected]:12345/repository.git\n\nI have researched the topic and found the following options:\n\nRemove the custom port from the URL and make the users add it to their ~/.ssh/config file (a last-resort workaround rather than a solution).\nDrop SSH and use git-daemon and specify its --base-path parameter (still a workaround...)\nUse an utility like gitosis or gitolite - but wouldn't it be an overkill to use it for this purpose only? Gitosis is discontinued, gitolite is a quite huge piece of software...\n\nAll I want is a \"prettier\" SSH URL with custom port (so I can distribute the whole git clone command and require nothing more from the remote user). Which one of the above solutions would be the most viable in my case?" }, { "role": "assistant", "content": "If you use the alternate form of ssh URLs you don't need an absolute path. For example...\ngit clone [email protected]:repos/myrepo.git\n\n...will clone repository repos/myrepo.git relative to my home directory, although this doesn't permit use of an alternate port. However, you can also use ~ in either form to indicate the user's home directory, e.g.:\ngit clone ssh://[email protected]:12345/~/repository.git\n\nIncidentally, despite being discontinued, gitosis functions quite well, and the code is both small and easy to understand. It offers a useful set of access controls and self-service management of repositories. I wouldn't discount it completely." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-reset" }, { "role": "assistant", "content": "Reset current HEAD to the specified state" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to get a branch name with a slash in Azure DevOps?\nAzure Devops offers two variables containing information about the current git branch name: $(Build.SourceBranchName) and $(Build.SourceBranch).\nWhile SourceBranch contains the full reference to the branch, SourceBranchName is expected to contain only the short branch name. \nUnfortunately, the behavior is a bit unexpected when the branch name contains a slash (/):\n+---------------------------------------------------------------------------------------------------------+\n| Situation | Git branch name | Build.SourceBranch | Build.SourceBranchName |\n|---------------------------------------------------------------------------------------------------------|\n| branch name contains no slash | mybranch | refs/heads/mybranch | mybranch |\n| branch name contains slash | release/mybranch | refs/heads/release/mybranch | mybranch |\n+---------------------------------------------------------------------------------------------------------+\n\nThe part of the branch name before the slash is not considered as part of the branch name. My colleague pointed out that this is the documented behavior of Azure Devops:\n\nGit repo branch or pull request: The last path segment in the ref. For example, in refs/heads/master this value is master. In refs/heads/feature/tools this value is tools.\n\nI am not sure if this behavior is particularly useful: I want to checkout the branch, and need the branch name to include the slash. Also, If the part before the slash is stripped off, there might well be confusion about the actual path, as the name could be ambiguous.\nI need the branch name including the slash. Is there any simple way to get it? Do I always have to work with the full ref in order to be on the safe side?" }, { "role": "assistant", "content": "You can use replace expression to remove refs/heads/ from Build.SourceBranch\n variables:\n BRANCH_NAME: $[replace(variables['Build.SourceBranch'], 'refs/heads/', '')]\n\nUse like this (edited typo)\n$(BRANCH_NAME)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I get the parents of a merge commit in Git?\nSome Git commands take the parent as a revision; others (such as git revert), as a parent number. How can I get the parents for both cases?\nI don’t want to use the graphical log command as that often requires scrolling down a long tree to find the second parent." }, { "role": "assistant", "content": "Simple git log <hash> called for a merge commit shows abbreviated hashes of its parents:\n $ git log -1 395f65d\n commit 395f65d438b13fb1fded88a330dc06c3b0951046\n Merge: 9901923 d28790d\n ...\n\ngit outputs parents according to their number: the first (leftmost) hash is for the first parent, and so on.\nIf all you want is just the hashes, the two equivalent choices are:\n$ git log --pretty=%P -n 1 <commit>\n$ git show -s --pretty=%P <commit>\n\ngit rev-list can also show the parents' hashes, though it will first list the hash for a commit:\n$ git rev-list --parents -n 1 <commit>\n\nIf you want to examine the parents, you can refer to them directly with carats as <commit>^1 and <commit>^2, e.g.:\ngit show <commit>^1\n\nThis does generalize; for an octopus merge you can refer to the nth parent as <commit>^n. You can refer to all parents with <commit>^@, though this doesn't work when a single commit is required. Additional suffixes can appear after the nth parent syntax (e.g. <commit>^2^, <commit>^2^@), whereas they cannot after ^@ (<commit>^@^ isn't valid). For more on this syntax, read the rev-parse man page." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch ours" }, { "role": "assistant", "content": "This resolves any number of heads, but the resulting tree of the\nmerge is always that of the current branch head, effectively\nignoring all changes from all other branches. It is meant to\nbe used to supersede old development history of side\nbranches. Note that this is different from the -Xours option to\nthe recursive merge strategy." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can git be installed on CENTOS 5.5?\nHow can I install git on CENTOS 5.5 machine?\nI tried to install it from yum but got following msg.\nroot@host [~]# sudo yum install git\nLoaded plugins: fastestmirror\nLoading mirror speeds from cached hostfile\n * addons: centos.mirrors.tds.net\n * base: mirror.ubiquityservers.com\n * extras: mirrors.serveraxis.net\n * updates: pubmirrors.reflected.net\naddons | 951 B 00:00\nbase | 2.1 kB 00:00\nextras | 2.1 kB 00:00\nupdates | 1.9 kB 00:00\nExcluding Packages in global exclude list\nFinished\nSetting up Install Process\nNo package git available.\nNothing to do\nroot@host [~]#" }, { "role": "assistant", "content": "If you are using CentOS the built in yum repositories don't seem to have git included and as such, you will need to add an additional repository to the system. For my servers I found that the Webtatic repository seems to be reasonably up to date and the installation for git will then be as follows:\n# Add the repository\nrpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm\n\n# Install the latest version of git\nyum install --enablerepo=webtatic git-all\n\nTo work around Missing Dependency: perl(Git) errors:\nyum install --enablerepo=webtatic --disableexcludes=main git-all" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options column.branch" }, { "role": "assistant", "content": "Specify whether to output branch listing in git branch in columns.\nSee column.ui for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-am - Apply a series of patches from a mailbox --resolvemsg=<msg>" }, { "role": "assistant", "content": "When a patch failure occurs, <msg> will be printed\nto the screen before exiting. This overrides the\nstandard message informing you to use --continue or --skip to handle the failure. This is solely\nfor internal use between git rebase and git am ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git pull while not in a git directory\nLet's say I have a directory, /X/Y, which is a git repository. Is it possible to somehow call a command like git pull from inside /X, but targeting the /X/Y directory?\nEDIT: I guess I was wondering specifically: is it possible to do this using the a git command, but without having to change directories?\nNOTE: I've accepted VonC's answer as it's much more elegant than previous options. For people running Git older than 1.8.5, please see bstpierre's answer below." }, { "role": "assistant", "content": "Starting git 1.8.5 (Q4 2013), you will be able to \"use a Git command, but without having to change directories\".\n\nJust like \"make -C <directory>\", \"git -C <directory> ...\" tells Git to go there before doing anything else.\n\nSee commit 44e1e4 by Nazri Ramliy:\n\nIt takes more keypresses to invoke Git command in a different directory without leaving the current directory:\n\n(cd ~/foo && git status)\n git --git-dir=~/foo/.git --work-tree=~/foo status\n GIT_DIR=~/foo/.git GIT_WORK_TREE=~/foo git status \n(cd ../..; git grep foo)\nfor d in d1 d2 d3; do (cd $d && git svn rebase); done\n\nThe methods shown above are acceptable for scripting but are too cumbersome for quick command line invocations.\nWith this new option, the above can be done with fewer keystrokes:\n\ngit -C ~/foo status\ngit -C ../.. grep foo\nfor d in d1 d2 d3; do git -C $d svn rebase; done\n\n\n\nSince Git 2.3.4 (March 2015), and commit 6a536e2 by Karthik Nayak (KarthikNayak), git will treat \"git -C '<path>'\" as a no-op when <path> is empty. \n\n'git -C \"\"' unhelpfully dies with error \"Cannot change to ''\", whereas the shell treats cd \"\"' as a no-op.\n Taking the shell's behavior as a precedent, teach git to treat -C \"\"' as a no-op, as well.\n\n\n4 years later, Git 2.23 (Q3 2019) documents that 'git -C \"\"' works and doesn't change directory\n\nIt's been behaving so since 6a536e2 (git: treat \"git -C '<path>'\"\n as a no-op when <path> is empty, 2015-03-06, Git v2.3.4). \n\nThat means the documentation now (finally) includes:\n\nIf '<path>' is present but empty, e.g. -C \"\", then the current working directory is left unchanged.\n\n\nYou can see git -C used with Git 2.26 (Q1 2020), as an example.\nSee commit b441717, commit 9291e63, commit 5236fce, commit 10812c2, commit 62d58cd, commit b87b02c, commit 9b92070, commit 3595d10, commit f511bc0, commit f6041ab, commit f46c243, commit 99c049b, commit 3738439, commit 7717242, commit b8afb90 (20 Dec 2019) by Denton Liu (Denton-L).\n(Merged by Junio C Hamano -- gitster -- in commit 381e8e9, 05 Feb 2020) \n\nt1507: inline full_name()\nSigned-off-by: Denton Liu\nBefore, we were running test_must_fail full_name. However, test_must_fail should only be used on git commands.\n Inline full_name() so that we can use test_must_fail on the git command directly.\nWhen full_name() was introduced in 28fb84382b (\"Introduce <branch>@{upstream} notation\", 2009-09-10, Git v1.7.0-rc0 -- merge), the git -C option wasn't available yet (since it was introduced in 44e1e4d67d (\"git: run in a directory given with -C option\", 2013-09-09, Git v1.8.5-rc0 -- merge listed in batch #5)).\n As a result, the helper function removed the need to manually cd each time. However, since git -C is available now, we can just use that instead and inline full_name()." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --ignore-cr-at-eol" }, { "role": "assistant", "content": "Ignore carriage-return at the end of line when doing a comparison." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --show-linear-break[=<barrier>]" }, { "role": "assistant", "content": "When --graph is not used, all history branches are flattened\nwhich can make it hard to see that the two consecutive commits\ndo not belong to a linear branch. This option puts a barrier\nin between them in that case. If <barrier> is specified, it\nis the string that will be shown instead of the default one." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can Gerrit work in front of Gitlab or is it meant to replace it\n\nI don't think I'm really understanding how Gerrit can fit into my group's existing workflow. Is Gerrit intended to be the central \"hub\" of code? I have been imagining it as similar to Atlassian's Crucible, which fits in with Atlassian's Stash or Bitbucker.\nMy group currently uses a very active Gitlab installation but the built-in code review facility is lacking, and I absolutely must inspect code from contractors going into the repo.\nI need a behind-the-firewall solution, and cost is a big consideration. I have heard positive things about Gerrit, but not really an explanation of how it can fit into an existing process. I also like that it seems to have pretty good eclipse integration.\nCan someone help me out?" }, { "role": "assistant", "content": "Gerrit expects to \"own\" the repositories you use it with, i.e. it expects the git directories to be present in a mounted file system. If you want it to interact with GitLab (or GitHub) you can set up one way replication from Gerrit to GitLab so that changes made in Gerrit will be pushed to GitLab within a few seconds. For GitHub there's a Gerrit GitHub plugin to help with this.\nYou can continue to use the other features of GitLab but if you don't lock down the repositories (or at least block pushes into branches that Gerrit manages) you'll end up in trouble the next time Gerrit attempts to replicate to the GitLab repository.\nSo... Gerrit does replace GitLab's repository management and code review facilities but doesn't contain an issue tracker, wiki, or similar." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is there a way in git to obtain a push date for a given commit?\n\nI am wondering if there is a way to view a push date associated with each commit in the git log. If that is not possible, is there a way to see all the commits under a certain push.\nI writing a program that needs to keep track of the commits as they are pushed. Because the git log is ordered by the commit date, not the push date, I am not able to see the most recent commits that are pushed. For example, if a user commits to his local repository 2 days before he pushes to the master, that commit will be placed behind 2 days of other commits in the master repository log." }, { "role": "assistant", "content": "It took me an insanely long time to gather scattered information and finally find the very best answer to this question, but now I know I have it. In just two lines, no code and no hooks:\n# required for a bare repo\ngit config core.logAllRefUpdates true\n\ngit reflog --date=local master\n\nSimple at last.\nWarning: you probably want to override the default values of gc.reflogExpire and gc.reflogExpireUnreachable. Check git help reflog for details and to understand how and why this works.\nThe two commands above must be run inside the clone you push to. If that is not possible then an approximation is to run in another, permanent clone:\ngit fetch origin # often and *regularly*\ngit reflog --date=local origin/master\n\nNever delete this permanent clone or you will lose the dates." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Searching in multiple Github repositories\n\nI Want to search all our codebase in our Github installation for different text strings. We have app. 90 different repositories.\nIs there such a method?\nI can only find search for file names, authors etc., not search for strings inside code. My task is to find every project which uses or refers to systems, classes, methods etc. that soon are obsolete. \nAlternately: Is there a method to download/clone all repositories in one action?\nWe use SourceTree as client software." }, { "role": "assistant", "content": "You can search directly at the top of an Organisation now. This results in the prefix org:.\ne.g. if you wanted to search all twitter repos for the word bot you would search for org:twitter bot\nhttps://github.com/search?l=&q=org%3Atwitter+bot&ref=advsearch&type=Code" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-mergetool - Run merge conflict resolution tools to resolve merge conflicts --prompt" }, { "role": "assistant", "content": "Prompt before each invocation of the merge resolution program\nto give the user a chance to skip the path." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "how to set http as the project default url in gitlab\n\nwhen opening a project in gitlab, you will see SSH and HTTP(or HTTPS) url on the top of project home page, the SSH url is as default, but I want to set HTTP(or HTTPS) as default, so how should I do? Thanks" }, { "role": "assistant", "content": "infact, you have to modify 2 other lines above the default_clone_protocol.\ndef default_url_to_repo(project = nil)\n project = project || @project\n current_user ? project.http_url_to_repo : project.url_to_repo\nend\n\ndef default_clone_protocol\n current_user ? \"http\" : \"ssh\"\nend" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Force \"git status\" to output color on the terminal (inside a script)\nEDIT:\nI would like to make a recommendation that parsing colors is a generally ill-conceived idea.\nPart of why i wanted it was so I can both parse it and pass it along in my own script output. This is... okay, but it would probably be saner to use porcelain or some such and re-build the colored parts myself!\nOriginal question follows.\n\nI like to see color because my scripting is robust enough (so far) to handle the color codes. It does seem like I'm going against the grain here, but I honestly don't see what the big deal is about having to parse stuff like escape codes in scripts. If colors help for interactive use, why wouldn't they help in script use where I might be aggregating data and crunching even more data than I would manually? Wouldn't colors be even more important?\nAnyway, I have a neat little shell script I wrote that munges git status output, and i'm just looking to make this script keep the colors intact. My global git config is set so that the lists of changed and untracked files show up in color in the git status. Unfortunately unlike git diff there is no option for forcing color for git status that I can find. \nTo be abundantly clear, this is the issue: \n$ git status\n\nproduces perfect output, but (excerpt from my script follows)\ngit status | sed \"s/^#/\\x1b[34m#[0m/\"\n\nproduces no colored git status output, and you can even see here that I'm explicitly converting the leading hash-characters to blue because it helps highlight the different regions of output from my script. \nDoes anyone know how to get it to put out the colors? Is there maybe a standard program I can use that can be used as a \"fake terminal\" STDIN/STDOUT pipe? I am in fact also working on a pty pseudoterminal tool so I could certainly make use of that for this purpose, but it's a rather heavy-handed solution (and not ready for use yet as I haven't finished building it)." }, { "role": "assistant", "content": "To avoid changing your git config, you can enable colour just for the current command by passing a config variable with -c.\nFor older git versions (< 2.20.1) the status variable is color.status:\n git -c color.status=always status | less -REX\n\nIn modern git versions, and for diff, show, log and grep commands, the variable is color.ui:\n git -c color.ui=always diff | less -REX\n\nNotes:\n\nAssuming you are >2.20.1, color.ui=always is preferable because it's consistent across subcommands.\n\nthat -c must come before the status or diff argument, and not after.\n\nAlternatively, for diff, show, log and grep commands, you can use --color=always after the command:\n git diff --color=always | less -REX\n\n\n\n\nNote: As Steven said, if you are trying to extract meaningful data, then instead of parsing colours to extract meaning, you can use --porcelain to get more parser-friendly output.\n git status --porcelain | awk ...\n\nThen if you wanted, you could reintroduce colours later.\nTo get the user's configured colours, you can use git config --get-colour:\n reset_color=\"$(tput sgr0)\"\n remote_branch_color=\"$(git config --get-color color.branch.remote white)\"\n\n echo \"Pushing to ${remote_branch_color}${branch_name}${reset_color}\"\n\nSome more examples here." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker --work-tree=<path>" }, { "role": "assistant", "content": "Set the path to the working tree. It can be an absolute path\nor a path relative to the current working directory.\nThis can also be controlled by setting the GIT_WORK_TREE\nenvironment variable and the core.worktree configuration\nvariable (see core.worktree in git-config for a\nmore detailed discussion)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-difftool - Show changes using common diff tools -g --[no-]gui" }, { "role": "assistant", "content": "When git-difftool is invoked with the -g or --gui option\nthe default diff tool will be read from the configured diff.guitool variable instead of diff.tool . This may be\nselected automatically using the configuration variable difftool.guiDefault . The --no-gui option can be used to\noverride these settings. If diff.guitool is not set, we will\nfallback in the order of merge.guitool , diff.tool , merge.tool until a tool is found." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-remote - Manage set of tracked repositories" }, { "role": "assistant", "content": "DESCRIPTION Manage the set of repositories (\"remotes\") whose branches you track." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options forceDeleteBranch" }, { "role": "assistant", "content": "Shown when the user tries to delete a not fully merged\nbranch without the force option set." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-submodule - Initialize, update or inspect submodules init [--] [<path>…​]" }, { "role": "assistant", "content": "Initialize the submodules recorded in the index (which were\nadded and committed elsewhere) by setting submodule.$name.url in .git/config , using the same setting from .gitmodules as\na template. If the URL is relative, it will be resolved using\nthe default remote. If there is no default remote, the current\nrepository will be assumed to be upstream. Optional <path> arguments limit which submodules will be initialized.\nIf no path is specified and submodule.active has been configured, submodules\nconfigured to be active will be initialized, otherwise all submodules are\ninitialized. It will also copy the value of submodule.$name.update , if present in\nthe .gitmodules file, to .git/config , but (1) this command does not\nalter existing information in .git/config , and (2) submodule.$name.update that is set to a custom command is not copied for security reasons. You can then customize the submodule clone URLs in .git/config for your local setup and proceed to git submodule update ;\nyou can also just use git submodule update --init without\nthe explicit init step if you do not intend to customize\nany submodule locations. See the add subcommand for the definition of default remote." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --stdin" }, { "role": "assistant", "content": "In addition to getting arguments from the command line, read\nthem from standard input as well. This accepts commits and\npseudo-options like --all and --glob= . When a -- separator\nis seen, the following input is treated as paths and used to\nlimit the result. Flags like --not which are read via standard input\nare only respected for arguments passed in the same way and will not\ninfluence any subsequent command line arguments." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options submodule.<name>.url" }, { "role": "assistant", "content": "The URL for a submodule. This variable is copied from the .gitmodules\nfile to the git config via git submodule init . The user can change\nthe configured URL before obtaining the submodule via git submodule\nupdate . If neither submodule.<name>.active nor submodule.active are\nset, the presence of this variable is used as a fallback to indicate\nwhether the submodule is of interest to git commands.\nSee git-submodule and gitmodules for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %ae" }, { "role": "assistant", "content": "author email" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub: make fork an \"own project\"\n\nI have found a nice GitHub project which I extended a lot. I believe my changes are good, because they are working. But it seems the original author hasn't got the time to review these changes and include them. In fact, it is even possible that the features I need and implemented are not in the vision of the original author and we simply aim at different goals. I don't know as I never got responses from him.\nThat said I saw my contributions are not counted in my commit-map. This is the case as long as the original repository doesn't accept my contributions. Furthermore my work is only recognized as work and doesn't attract any other people with the same vision as I have. This is the bigger problem for me, because I see a lot of people asking for these features.\nI am still offering my contributions to the original project, but I see it is unlikely they are ever accepted. Now I would like to make my fork a \"real project\". While I plan to sync with the original project at some points of time, I want to rename it and motivate people to contribute to my project as well. In addition, I would love if GitHub would show that this project is actively maintained (speaking of the commit map). And finally, I would love to make proper releases of it.\nHow can I get this done and well, make my fork a full-fledged project?" }, { "role": "assistant", "content": "To detach the fork and turn it into a standalone repository on GitHub, contact GitHub support.\n\nhttps://help.github.com/articles/why-are-my-contributions-not-showing-up-on-my-profile/#commit-was-made-in-a-fork" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-shortlog - Summarize git log output --tags[=<pattern>]" }, { "role": "assistant", "content": "Pretend as if all the refs in refs/tags are listed\non the command line as <commit> . If <pattern> is given, limit\ntags to ones matching given shell glob. If pattern lacks ? , * ,\nor [ , /* at the end is implied." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options uploadpack.allowRefInWant" }, { "role": "assistant", "content": "If this option is set, upload-pack will support the ref-in-want feature of the protocol version 2 fetch command. This feature\nis intended for the benefit of load-balanced servers which may\nnot have the same view of what OIDs their refs point to due to\nreplication delay." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Bash bash: open: command not found\nI'm new to Git Bash, just freshly downloaded this for use in my class today, on the first class module it ask me to cd in to different directory and ls the content which works perfectly fine in Git Bash, then it ask me to open a README.md file in a folder with the command:\nopen README.md\nthen this error message show up:\nbash: open: command not found\nI know I cd in to the correct folder, and ls does shows the the README.md file, this is a freshly installed and most updated Git Bash, can't imagine there would be a missing link or altered in this program... what can I do? please help thank you! \nI'm using Windows 8 with Git for windows" }, { "role": "assistant", "content": "bash: open: command not found\n\nThis error message is trying to tell you that there is no such command called \"open\". There's nothing wrong with the README.md.\n\nOSX - open is a universal opener in OSX\nLinux - has xdg-open\nWindows - use start\n\nBut you don't need to take the instructions literally. It's not really important how you open the readme file. You can open it with the less command to view the content inside the terminal, or you can open it with notepad for editing in a text editor." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "ssh-keygen' is not recognized as an internal or external command\nI am trying to add ssh keys for usage on github but on my xp on command prompt ssh-keygen does not work. It gives me the following error\nssh-keygen' is not recognized as an internal or external command.\n\nIs there an alternative for generating keys on xp?" }, { "role": "assistant", "content": "Are you running msysgit, or some other form of Windows git installation? msysgit is only one possible way to run git on Windows but it's probably also the simplest one. It's also the way recommended by the git website at http://git-scm.org/ .\nIf you are using msysgit, then you need to run the command in Git Bash, not in a standard Windows command line prompt. Git Bash is a prompt that is installed for you by msysgit, and is basically the most common Linux command line shell (bash) packaged for Windows to facilitate command line usage of git. msysgit should also install the ssh-keygen program in a place where it is accessible from Git Bash, but not necessarily from your usual Windows command line prompt." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rebase - Reapply commits on top of another base tip --apply" }, { "role": "assistant", "content": "Use applying strategies to rebase (calling git-am internally). This option may become a no-op in the future\nonce the merge backend handles everything the apply one does. See also INCOMPATIBLE OPTIONS below." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is a patch in Git version control?\nI am new to both Git and version control so I am trying to figure out what a patch is and how is it different from the rest of activities I do in Git?\nWhen do I apply a patch? Does it happen every time I commit?" }, { "role": "assistant", "content": "You can see in this blog post how you can create a patch (collection of changes you want to communicate and apply to another repo)\n\n(picture from the 2008 blog post \"Bioruby with git: how would that work?\", published by Jan AERTS)\nSee also Contributing to Rails with Git as another concrete example.\nNowadays, the GitHub pull request makes it really easy to apply patches on GitHub repos, which is useful when you aren't a direct contributor (ie you have no right to directly push to a repo).\nActually, fairly recently GitHub introduced \"Better Pull Request Emails\" to improve the notification of new patches." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to cancel a pull request on github?\nHow can a pull request on github be cancelled?" }, { "role": "assistant", "content": "GitHub now supports closing a pull request\nBasically, you need to do the following steps:\n\nVisit the pull request page\nClick on the pull request\nClick the \"close pull request\" button\n\nExample (button on the very bottom):\n\nThis way the pull request gets closed (and ignored), without merging it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_DEFAULT_HASH" }, { "role": "assistant", "content": "If this variable is set, the default hash algorithm for new\nrepositories will be set to this value. This value is\nignored when cloning and the setting of the remote repository\nis always used. The default is \"sha1\".\nSee --object-format in git-init ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Do you ignore a git submodule in your .gitignore or commit it to your repo?\nI've added a submodule to my project in project_dir/vendor/submodule_one now each time I run git status I get modified: vendor/submodule_one (new commits).\nMy question is whats the best way to deal with this? Do I add the vendor/submodule_one-folder to my .gitignore as my main project shouldn't need to know about the specifics of my submodule?\nOr when I'm changing and commiting changes to my submodule do I need to make commits in my main project also?\nJust getting started with submodules and couldn't seem to find much info beyond setting them up." }, { "role": "assistant", "content": "No, you don't need to add your submodule to your .gitignore: what the parent will see from your submodule is a gitlink (a special entry, mode 160000).\nThat means: any change directly made in a submodule needs to be followed by a commit in the parent directory.\nThat way, the parent directory will record the right commit for the state of the submodule: That commit is the \"gitlink\" mentioned above;\nYou can read more about that policy in \"git submodule update (true nature of submodules)\".\nThe main idea behind submodules is a component-based approach, where you reference other repos at specific commits. But if you change anything in those submodules, you need to update those references in the parent repo as well.\n\nNote that with Git 2.13 (Q2 2017), while not ignoring the gitlink, you can still ignore the submodule with:\ngit config submodule.<name>.active false\n\nSee more at \"Ignore new commits for git submodule\".\n\nNote: with Git 2.15.x/2.16 (Q1 2018), ignoring a submodule is more precise.\n\"git status --ignored --untracked\" did not stop at a working tree of a separate project that is embedded in an ignored directory and listed files in that other project, instead of just showing the directory itself as ignored.\nSee commit fadb482 (25 Oct 2017) by Johannes Schindelin (dscho).\n(Merged by Junio C Hamano -- gitster -- in commit da7996a, 06 Nov 2017) \n\nstatus: do not get confused by submodules in excluded directories\nWe meticulously pass the exclude flag to the treat_directory() function so that we can indicate that files in it are excluded rather than untracked when recursing.\nBut we did not yet treat submodules the same way.\nBecause of that, git status --ignored --untracked with a submodule\n submodule in a gitignored tracked/ would show the submodule in the\n \"Untracked files\" section, e.g.\n\nOn branch master\nUntracked files:\n (use \"git add <file>...\" to include in what will be committed)\n\n tracked/submodule/\n\nIgnored files:\n (use \"git add -f <file>...\" to include in what will be committed)\n\n tracked/submodule/initial.t\n\n\nInstead, we would want it to show the submodule in the \"Ignored files\"\n section:\n\nOn branch master\nIgnored files:\n (use \"git add -f <file>...\" to include in what will be committed)\n\n tracked/submodule/" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I ignore a whole git repository in Visual Studio Code?\nIt’s not about using .gitignore to ignore certain files, it’s about completely excluding that particular repository from file watcher of VS Code.\nIt complains that there’s more than 5000 files are opened and then just hanged my laptop. This repository has insane amount of files, and it’s located in my home folder as my configs are stored in git, in .gitignore I’ve added all files to ignore, and when I need to stash the files I’m using git add -f <file>.\nAs you can see on the picture, the repository \"holms\" is always opened, and it's causing me issues. This is parent repo, which is in my home folder. How can I ignore it completely? If I close that repo, it appears again after like 3 minutes of working in a editor" }, { "role": "assistant", "content": "Had the same problem, try adding option: \n\"git.autoRepositoryDetection\": false\nand close repo from your parent (home) folder. It shouldn't appear again.\nUpdate:\nThere's now an option to watch only repositories for opened files:\n\"git.autoRepositoryDetection\": \"openEditors\"\nThis way, if you open any file in a specific repository, vscode will only watch it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git - remove commits with empty changeset using filter-branch\nHow do I remove commits which have no changeset using git filter-branch?\nI rewrote my git history using:\ngit filter-branch --tree-filter 'rm -r -f my_folder' -f HEAD\n\nthis worked out well but now I have lots of commits with empty changesets. I would like to remove those commits. Preferably in msysgit.\nRebasing is not really an option because I have over 4000 commits and half of them must be removed." }, { "role": "assistant", "content": "Just add on the --prune-empty option:\ngit filter-branch --tree-filter 'rm -rf my_folder' --prune-empty -f HEAD\n\n(And of course, if you have other refs, you might want to rewrite everything with -- --all instead of just HEAD.)\nNote that this isn't compatible with --commit-filter; in that case, Charles Bailey has your answer." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Using Source Tree, rebase with conflict, rebase doesn't work after conflict resovled\nI'm using SourceTree as my git tool on Windows.\nI have a main branch and a feature branch and I can't get SourceTree to perform a rebase when I have a conflict.\nmain looks like:\n\nc1 -> c2 -> c4 -> c5\n\nfeature looks like:\n\nc1-> c2 -> c3\n\nI want to rebase feature so it will be:\n\nc1 -> c2-> c4-> c5-> c3\n\nThere is a conflict between c3 and c5. I can resolve the conflict, but when I commit the changes I get a HEAD tag and looking at my graph I can see that feature branch wasn't rebased. \nHow can I get the rebase to work?" }, { "role": "assistant", "content": "Unfortunately the UX path for the resolving conflicts during a rebase is quite poor in atlassian-sourcetree. \nAfter you have resolved the conflict and have all of your changes in the staging area, instead of clicking commit, go to Actions-> Continue Rebase:" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to have 'git log' show filenames like 'svn log -v'\nSVN's log has a \"-v\" mode that outputs filenames of files changed in each commit, like so:\njes5199$ svn log -v\n------------------------------------------------------------------------\nr1 | jes5199 | 2007-01-03 14:39:41 -0800 (Wed, 03 Jan 2007) | 1 line\nChanged paths:\n A /AUTHORS\n A /COPYING\n A /ChangeLog\n A /EVOLUTION\n A /INSTALL\n A /MacOSX\n\nIs there a quick way to get a list of changed files in each commit in Git?" }, { "role": "assistant", "content": "For full path names of changed files:\ngit log --name-only\n\nFor full path names and status of changed files:\ngit log --name-status\n\nFor abbreviated pathnames and a diffstat of changed files:\ngit log --stat\n\nThere are a lot more options. Check out the documentation." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-worktree - Manage multiple working trees" }, { "role": "assistant", "content": "DETAILS Each linked worktree has a private sub-directory in the repository’s $GIT_DIR/worktrees directory. The private sub-directory’s name is usually\nthe base name of the linked worktree’s path, possibly appended with a\nnumber to make it unique. For example, when $GIT_DIR=/path/main/.git the\ncommand git worktree add /path/other/test-next next creates the linked\nworktree in /path/other/test-next and also creates a $GIT_DIR/worktrees/test-next directory (or $GIT_DIR/worktrees/test-next1 if test-next is already taken). Within a linked worktree, $GIT_DIR is set to point to this private\ndirectory (e.g. /path/main/.git/worktrees/test-next in the example) and $GIT_COMMON_DIR is set to point back to the main worktree’s $GIT_DIR (e.g. /path/main/.git ). These settings are made in a .git file located at\nthe top directory of the linked worktree. Path resolution via git rev-parse --git-path uses either $GIT_DIR or $GIT_COMMON_DIR depending on the path. For example, in the\nlinked worktree git rev-parse --git-path HEAD returns /path/main/.git/worktrees/test-next/HEAD (not /path/other/test-next/.git/HEAD or /path/main/.git/HEAD ) while git\nrev-parse --git-path refs/heads/master uses $GIT_COMMON_DIR and returns /path/main/.git/refs/heads/master ,\nsince refs are shared across all worktrees, except refs/bisect , refs/worktree and refs/rewritten . See gitrepository-layout for more information. The rule of\nthumb is do not make any assumption about whether a path belongs to $GIT_DIR or $GIT_COMMON_DIR when you need to directly access something\ninside $GIT_DIR . Use git rev-parse --git-path to get the final path. If you manually move a linked worktree, you need to update the gitdir file\nin the entry’s directory. For example, if a linked worktree is moved\nto /newpath/test-next and its .git file points to /path/main/.git/worktrees/test-next , then update /path/main/.git/worktrees/test-next/gitdir to reference /newpath/test-next instead. Better yet, run git worktree repair to reestablish the connection\nautomatically. To prevent a $GIT_DIR/worktrees entry from being pruned (which\ncan be useful in some situations, such as when the\nentry’s worktree is stored on a portable device), use the git worktree lock command, which adds a file named locked to the entry’s directory. The file contains the reason in\nplain text. For example, if a linked worktree’s .git file points\nto /path/main/.git/worktrees/test-next then a file named /path/main/.git/worktrees/test-next/locked will prevent the test-next entry from being pruned. See gitrepository-layout for details. When extensions.worktreeConfig is enabled, the config file .git/worktrees/<id>/config.worktree is read after .git/config is." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc minimal" }, { "role": "assistant", "content": "Spend extra time to make sure the smallest possible diff is\nproduced." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "error: src refspec master does not match any\nI have tried to follow the solutions suggested in this post but it didnt work and I am still getting: src refspec master does not match any. \nHere is what I did: \nFollowed this solution\n// adding the file I created\n$ git add .\n$ git commit -m 'initial commit'\n$ git push origin master\nerror: src refspec master does not match any.\n\nWhen doing:\n$ git push origin HEAD:master\nb40ffdf..a0d1423 HEAD -> master // looks promising\n\n// adding a remote\n$ git remote add devstage -f <another git>\n$ git merge devstage/master -s recursive -X ours\n$ git push -u devstage master\nerror: src refspec master does not match any.\n\nMore information:\n$ git branch \n* origin\n\n$ git show-ref\nrefs/heads/origin\nrefs/remotes/devstage/master\nrefs/remotes/origin/HEAD\nrefs/remotes/origin/devstage\nrefs/remotes/origin/master\nrefs/remotes/origin/origin\n\nSo I am definitely missing refs/heads/master but dont know how to create it. \nThanks" }, { "role": "assistant", "content": "This should help you\ngit init\ngit add .\ngit commit -m 'Initial Commit'\ngit push -u origin master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to get the name of the current git branch into a variable in a shell script? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow to programmatically determine the current checked out Git branch [duplicate]\n\n (20 answers)\n \n\nClosed 10 years ago.\n\n\n\nI am new to shell scripting and can't figure this out. If you are unfamiliar, the command git branch returns something like\n* develop\n master\n\n, where the asterisk marks the currently checked out branch. When I run the following in the terminal:\ngit branch | grep \"*\"\n\nI get:\n* develop\n\nas expected.\nHowever, when I run \ntest=$(git branch | grep \"*\")\n\nor\ntest=`git branch | grep \"*\"`\n\nAnd then\necho $test\n\n, the result is just a list of files in the directory. How do we make the value of test=\"* develop\"?\nThen the next step (once we get \"* develop\" into a variable called test), is to get the substring. Would that just be the following?\ncurrentBranch=${test:2} \n\nI was playing around with that substring function and I got \"bad substitution\" errors a lot and don't know why." }, { "role": "assistant", "content": "Expanding on Noufal Ibrahim's answer, use the --short flag with git-symbolic-ref, no need to fuss with sed.\nI've been using something like this in hooks and it works well:\n#!/bin/bash\n\nbranch=$(git symbolic-ref --short HEAD)\n\necho\necho \"**** Running post-commit hook from branch $branch\"\necho\n\nThat outputs \"**** Running post-commit hook from branch master\"\nNote that git-symbolic-ref only works if you're in a repository. Luckily .git/HEAD, as a leftover from Git's early days, contains the same symbolic ref. If you want to get the active branch of several git repositories, without traversing directories, you could use a bash one-liner like this:\nfor repo in */.git; do branch=$(cat $repo/HEAD); echo ${repo%/.git} : ${branch##*/}; done\n\nWhich outputs something like:\nrepo1 : master \nrepo2 : dev \nrepo3 : issue12\n\nIf you want to go further, the full ref contained in .git/HEAD is also a relative path to a file containing the SHA-1 hash of the branch's last commit." } ]
[ { "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 can I email someone a git repository?\nI have tried:\ngit archive HEAD --format=zip > archive.zip\n\n:and then I email archive.zip and at the other end they unzip archive.zip into a folder. But when they try any git commands they find out that this does not produce a valid git repository" }, { "role": "assistant", "content": "You could use git bundle and email one single file\nSee \"backing up project which uses git\"\n\nA git bundle is just one file which can be very easily created and again imported as it can be treated like another remote.\n\nOnce received, you can clone it or fetch from that file.\nAs mentioned in \"Backup of github repo\", you will probably want for the first email to make your bundle with all branches:\n$ git bundle create /tmp/foo-all --all\n\nAs Andreas mentions in the comments, Scott Chacon recently (March 2010) wrote a \"cute\" article on this topic in the ProGit book:\nGit's Little Bundle of Joy" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-notes - Add or inspect object notes GIT_NOTES_REWRITE_REF" }, { "role": "assistant", "content": "When rewriting commits, which notes to copy from the original\nto the rewritten commit. Must be a colon-delimited list of\nrefs or globs. If not set in the environment, the list of notes to copy depends\non the notes.rewrite.<command> and notes.rewriteRef settings." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options pack.islandCore" }, { "role": "assistant", "content": "Specify an island name which gets to have its objects be\npacked first. This creates a kind of pseudo-pack at the front\nof one pack, so that the objects from the specified island are\nhopefully faster to copy into any pack that should be served\nto a user requesting these objects. In practice this means\nthat the island specified should likely correspond to what is\nthe most commonly cloned in the repo. See also \"DELTA ISLANDS\"\nin git-pack-objects ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-shortlog - Summarize git log output --merge" }, { "role": "assistant", "content": "Show commits touching conflicted paths in the range HEAD...<other> ,\nwhere <other> is the first existing pseudoref in MERGE_HEAD , CHERRY_PICK_HEAD , REVERT_HEAD or REBASE_HEAD . Only works\nwhen the index has unmerged entries. This option can be used to show\nrelevant commits when resolving conflicts from a 3-way merge." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --relative[=<path>] --no-relative" }, { "role": "assistant", "content": "When run from a subdirectory of the project, it can be\ntold to exclude changes outside the directory and show\npathnames relative to it with this option. When you are\nnot in a subdirectory (e.g. in a bare repository), you\ncan name which subdirectory to make the output relative\nto by giving a <path> as an argument. --no-relative can be used to countermand both diff.relative config\noption and previous --relative ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to use GitHub V3 API to get commit count for a repo?\n\nI am trying to count commits for many large github repos using the API, so I would like to avoid getting the entire list of commits (this way as an example: api.github.com/repos/jasonrudolph/keyboard/commits ) and counting them.\nIf I had the hash of the first (initial) commit , I could use this technique to compare the first commit to the latest and it happily reports the total_commits in between (so I'd need to add one) that way. Unfortunately, I cannot see how to elegantly get the first commit using the API.\nThe base repo URL does give me the created_at (this url is an example: api.github.com/repos/jasonrudolph/keyboard ), so I could get a reduced commit set by limiting the commits to be until the create date (this url is an example: api.github.com/repos/jasonrudolph/keyboard/commits?until=2013-03-30T16:01:43Z) and using the earliest one (always listed last?) or maybe the one with an empty parent (not sure about if forked projects have initial parent commits).\nAny better way to get the first commit hash for a repo?\nBetter yet, this whole thing seems convoluted for a simple statistic, and I wonder if I'm missing something. Any better ideas for using the API to get the repo commit count?\nEdit: This somewhat similar question is trying to filter by certain files (\" and within them to specific files.\"), so has a different answer." }, { "role": "assistant", "content": "Make a request on https://api.github.com/repos/{username}/{repo}/commits?sha={branch}&per_page=1&page=1\nNow just take the Link parameter of the response header and grab out the page count situated just before rel=\"last\"\nThis page count is equal to the total number of commits in that branch!\nThe trick was to use &per_page=1&page=1. It distributed 1 commit in 1 page. So, the total number of commits will be equal to the total number of pages." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission default , myers" }, { "role": "assistant", "content": "The basic greedy diff algorithm. Currently, this is the default." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "go back to a specific commit then go back to the present\nI'd like to see the file from a specific commit in the past, I'm thinking of git reset --hard but I won't be able to see the commits beyond that commit. How do I go back to a commit (together with the state of the files), have a look at the files, the go to the present again?" }, { "role": "assistant", "content": "Suppose your current branch is master and the old commit is a1b2c3, then you can change all the files in your working tree back to the old commit with:\ngit checkout a1b2c3\n\n... and return to master with:\ngit checkout master\n\nThis way of hopping about in your git history (i.e. checking out a commit with its object name, also known as its hash or SHA1sum) is very useful for finding a previous good commit for git bisect, for example, since it won't move your branches.\nOne thing to bear in mind is that you'll get a possibly confusing warning when doing this: if you check out a commit from its object name (a1b2c3) that will put you into a state known as \"detached HEAD\", where HEAD, which usually represents your current branch, instead points directly to a particular commit. This isn't something to worry about - it's very useful for moving about in your history - but it does mean that if you create new commits when HEAD is detached, they won't move a branch forward.\n\nfork0 points out in the comment below the potentially useful shortcut git checkout -, which will checkout the previous branch or commit that HEAD pointed at." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Add Github remote to GitKraken\nI'm using GitKraken (v. 1.4.1) as my Git managing tool. And now I want to use Github as a remote to back up my repos. But when I click on add remote and try to add a Github repo, it just says 'no match'\n\nDoes anybody know why this happens? (BTW: I'm using Windows 10, just in case that's relevant)" }, { "role": "assistant", "content": "Here's how it seems to work. If you have a local repo and want to connect it to github, you would use the \"URL\" option and put in the github address to set that as the remote repo for your local repo. The first time you do a pull or push on a local branch, it will ask which remote branch you want to use and that becomes the remote location to which you will pushing and pulling changes.\nThe GitHub.com option only comes into play after you have set the remote repo using the \"URL\" option. If there are multiple collaborators on a project and someone has created one or more forks of the project, then instead of \"No Match\" under the GitHub.com, you would see a list of all the forks of the project on which you are a collaborator.\nYou could then add the forked repos as the 2nd, 3rd, etc. remotes, and any activity on those forks would be displayed to you on the commit graph. This allows people to see what's going on in the forks, and you can drag and drop from the forked parts of the graph to create pull requests to the repo you first set up using \"URL\".\nIt's a nice feature, but the remote dialog could be labelled more clearly so that people would know the GitHub.com option was for adding forked repos to the commit graph display.\nYou must always use the \"URL\" option to add the 1st remote, and then the GitHub.com option only becomes available after that if there are forks to which you have access." } ]
[ { "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\"\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": "Git: How do I pull a tagged revision into my fork?\n\nI have a fork of a project on github where the main trunk was recently tagged. I want to pull the code from the tagged revision into my fork. How would I do that?" }, { "role": "assistant", "content": "Once you have the tag in local repository you can do something like\n\ngit merge tags/yourtag\n\nIf you don't have the \"trunk\" tags locally, you can fetch it using\n\ngit fetch remote-url \"refs/tags/*:refs/tags/*\"\n\nOr by setting up the remote\n\ngit remote add upstream remote-url\n\nand fetching the stuff using\n\ngit fetch -t upstream\n\nI think, though, using\n\ngit remote update\n\nwill have similar effect." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why are connections to GitHub over SSH throwing an error \"Warning: Remote Host Identification Has Changed\"?\n\nJust sometime ago I started getting this warning when pushing to GitHub.\nWARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!\n\nIT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!\nSomeone could be eavesdropping on you right now (man-in-the-middle attack)!\nIt is also possible that a host key has just been changed.\n\nIs this normal and how do I resolve it?" }, { "role": "assistant", "content": "This happened because on the 24th of March 2023, GitHub updated their RSA SSH host key used to secure Git operations for GitHub.com because the private key was briefly exposed in a public GitHub repository. You will get that message if you had remembered GitHub’s previous key fingerprint in your SSH client before that date.\nAs per per the linked blog post, the solution is to remove the old key by running this command:\n$ ssh-keygen -R github.com\n\nNow the next git connection (pull, push or clone) should ask if you trust the new SSH key. Before entering yes, ensure the shown new key is valid, using the list:\nhttps://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints\nRefer to the blog post for other ways to fix the issue." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git's famous \"ERROR: Permission to .git denied to user\"\n\nI have tried googling and read through https://help.github.com/en/articles/connecting-to-github-with-ssh and various, various guides. I am unable to git push -u origin master or git push origin master ( the same command ).\nI've had my git account for at least 2 or so years. I've successfully been able to create repos and push -u origin master fine on my laptop but on this desktop I'm having issues.\nHere's what I tried:\n1. I have setup my git user name\n2. I have setup my git user email\n3. I have uploaded the contents of my /home/meder/.ssh/id_rsa.pub to github's account page. I have verified I did not paste any whitespace\n4. I have created a ~/.ssh/config with these contents:\n Host github.com\n User git\n Hostname github.com\n PreferredAuthentications publickey\n IdentityFile ~/.ssh/id_rsa\n\nI have chmodded the .ssh to 700, id_rsa 600\n5. I have added the proper remote origin without making typos : git remote add origin [email protected]:medero/cho.git\n6. To confirm #5, here is my .git/config. The directory is correct and not another directory:\n[remote \"origin\"]\n fetch = +refs/heads/*:refs/remotes/origin/*\n url = [email protected]:medero/cho.git\n\n7. ssh [email protected] -v gives me a successful Authentication\n8. One weird thing is, the username which it greets me with has t appended to it. My github username is medero, not medert.\n\nHi mederot! You've successfully\n authenticated, but GitHub does not\n provide shell access.\n\n9. I am not behind a proxy or firewall\n10. The key is offered, heres the output from -v:\n\ndebug1: Host 'github.com' is known and matches the RSA host key.\ndebug1: Found key in /home/meder/.ssh/known_hosts:58\ndebug1: ssh_rsa_verify: signature correct\ndebug1: SSH2_MSG_NEWKEYS sent\ndebug1: expecting SSH2_MSG_NEWKEYS\ndebug1: SSH2_MSG_NEWKEYS received\ndebug1: SSH2_MSG_SERVICE_REQUEST sent\ndebug1: SSH2_MSG_SERVICE_ACCEPT received\ndebug1: Authentications that can continue: publickey\ndebug1: Next authentication method: publickey\ndebug1: Offering public key: /home/meder/.ssh/id_rsa\ndebug1: Remote: Forced command: gerve mederot\ndebug1: Remote: Port forwarding disabled.\ndebug1: Remote: X11 forwarding disabled.\ndebug1: Remote: Agent forwarding disabled.\ndebug1: Remote: Pty allocation disabled.\ndebug1: Server accepts key: { some stuff, dont know if i should share it\n\ndebug1: Remote: Forced command: gerve mederot\ndebug1: Remote: Port forwarding disabled.\ndebug1: Remote: X11 forwarding disabled.\ndebug1: Remote: Agent forwarding disabled.\ndebug1: Remote: Pty allocation disabled.\ndebug1: Authentication succeeded (publickey).\n\n\n11. Here are the commands I used\nmkdir cho\ngit init\ntouch README\ngit add README\ngit commit -m 'test'\ngit remote add origin [email protected]:medero/cho.git\ngit push -u origin master\n\n12. I don't want to create a new SSH key.\n13. If I git clone using ssh and make an edit, commit, and git push, I get the same exact thing.\n14. Here's the actual error:\n$ git push\nERROR: Permission to medero/cho.git denied to mederot.\nfatal: The remote end hung up unexpectedly\n\n15. I have setup my github username and github token:\n$ git config --global github.user medero\n$ git config --global github.token 0123456789yourf0123456789tokenSets the GitHub token for all git instances on the system\n16. I have confirmed my github username is NOT mederot and my github token IS CORRECT per my account page ( validated first 2 chars and last 2 chars ).\n17. To confirm #16, ~/.gitconfig contains\n[github]\n token = mytoken...\n user = medero\n\n18. I did ssh-key add ~/.ssh/id_rsa if that's even necessary...\n\nTHEORIES:\nI suspect there's something fishy because when I get ssh authenticated, the user greeting is mederot and not medero, which is my acct. Could something in my github account possibly be incorrectly cached?\nI also suspect some local ssh caching weirdness because if i mv ~/.ssh/id_rsa KAKA and mv ~/.ssh/id_rsa.pub POOPOO, and do ssh [email protected] -v, it still Authenticates me and says it serves my /home/meder/.ssh/id_rsa when I renamed it?! It has to be cached?!" }, { "role": "assistant", "content": "After Googling for few days, I found this is the only question similar to my situation.\nHowever, I just solved the problem! So I am putting my answer here to help anyone else searching for this issue.\nHere is what I did:\n\nOpen \"Keychain Access.app\" (You can find it in Spotlight or LaunchPad)\nSelect \"All items\" in Category\nSearch \"git\"\nDelete every old & strange item\nTry to Push again and it just WORKED" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git command to checkout any branch and overwrite local changes\nIs there a Git command (or a short sequence of commands) that will safely and surely do the following?\n\nGet rid of any local changes.\nFetch the given branch from origin if necessary\nCheckout the given branch?\n\nCurrently I'm stuck with:\ngit fetch -p\ngit stash\ngit stash drop\ngit checkout $branch\ngit pull\n\nbut it's bothering me because I'm asked for password two times (by fetch and pull). Generally I would be happy with any solution as long as the password is needed only once.\nA couple of notes:\n\nIt's a part of homebrewed deployment script for an application (the code is hosted on GitHub).\nThere should be no difference if the branch was already fetched from origin or not (i.e. the first deployment of a new branch shouldn't ideally require any additional steps).\nThe script is located on a remote machine that can be accessed by several people, hence no credentials are stored and user/password must be entered (but only once if possible).\nI don't care about any local changes; I always want a pristine copy of the given branch (the further part of deployment script produces local changes).\nI can't clone or export a fresh repository each time; it takes too much time." }, { "role": "assistant", "content": "You could follow a solution similar to \"How do I force “git pull” to overwrite local files?\":\ngit fetch --all\ngit reset --hard origin/abranch\ngit checkout abranch \n\nThat would involve only one fetch.\nWith Git 2.23+, git checkout is replaced here with git switch (presented here) (still experimental).\ngit switch -f $branch\n\n(with -f being an alias for --discard-changes, as noted in Jan's answer)\n\nProceed even if the index or the working tree differs from HEAD.\nBoth the index and working tree are restored to match the switching target.\n\n\nIf you do not want to switch branch, but only restore a folder from another branch, then git restore is the other command which replaces the old obsolete and confusing git checkout.\nI presented git restore here.\ngit restore --source=anotherBranch --staged] [--worktree -- aFolder\n# or, shorter:\ngit restore -s anotherBranch -SW -- aFolder" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I check if an image:tag exists in gitlab container registry\n\nI know that this can be done with dockerhub. I want to know if there is something similar available for gitlab registry. \nThe use case is that, I have written a fabric script to revert a deployment to a particular tag provided by the user. Before actually pulling in the images, I want to know whether an image with the specified tag exists in the registry and warn the user accordingly.\nI've searched in their documentation, but couldn't find anything.\nNote: User here is the person who is deploying the code." }, { "role": "assistant", "content": "Hint: Also have a look at @filiprafaj's answer using crane.\nOk, here is a solution I came up with using the docker:stable image by enabling the experimental client features.\nmkdir -p ~/.docker\n\"echo '{\\\"experimental\\\": \\\"enabled\\\"}' > ~/.docker/config.json\"\ndocker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY\ndocker manifest inspect $IMGNAME:$IMGTAG > /dev/null && exit || true\n\nThe exit terminates the build script in case that tag already exists. Also you should be aware that ~/.docker/config.json is overwritten. That is also why the login must happen afterwards.\nUpdate: Instead of writing to the config one can also set the DOCKER_CLI_EXPERIMENTAL environment variable to enabled. Thus the first two lines can be replaced with export DOCKER_CLI_EXPERIMENTAL=enabled" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --reverse" }, { "role": "assistant", "content": "Output the commits chosen to be shown (see Commit Limiting\nsection above) in reverse order. Cannot be combined with --walk-reflogs ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Are multiple `.gitignore`s frowned on?\nUnless a repo consisted of several independent projects, it seems it would be simplest to just have one .gitignore file at the root of the repo than various ones throughout. Is there a standard best practice on this or some analysis online of when one approach is better than the other?" }, { "role": "assistant", "content": "I can think of at least two situations where you would want to have multiple .gitignore files in different (sub)directories.\n\nDifferent directories have different types of file to ignore. For example the .gitignore in the top directory of your project ignores generated programs, while Documentation/.gitignore ignores generated documentation.\nIgnore given files only in given (sub)directory (you can use /sub/foo in .gitignore, though).\n\nPlease remember that patterns in .gitignore file apply recursively to the (sub)directory the file is in and all its subdirectories, unless pattern contains '/' (so e.g. pattern name applies to any file named name in given directory and all its subdirectories, while /name applies to file with this name only in given directory)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do you resolve Git conflicts in yarn.lock\nWhen multiple Git branches modify the dependencies in a project that uses Yarn, it is likely to introduce a conflict in the yarn.lock file. It is not a good idea to delete and regenerate the yarn.lock file because this will probably cause several packages to be unintentionally upgraded. What is the best way to quickly resolve conflicts in this file?" }, { "role": "assistant", "content": "Since Yarn 1.0 it's easy because it has built in support for this scenario.\nFirst solve the conflict in package.json manually, then just run this:\n$ yarn install\n\nyarn install v1.0.1\ninfo Merge conflict detected in yarn.lock and successfully merged.\n[1/4] Resolving packages...\n\nAnd then the conflict will be resolved and you can commit that or continue rebasing if that was what you were doing." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options diff.suppressBlankEmpty" }, { "role": "assistant", "content": "A boolean to inhibit the standard behavior of printing a space\nbefore each empty output line. Defaults to false." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-shortlog - Summarize git log output --sparse" }, { "role": "assistant", "content": "All commits that are walked are included. Note that without --full-history , this still simplifies merges: if\none of the parents is TREESAME, we follow only that one, so the other\nsides of the merge are never walked." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.algorithm" }, { "role": "assistant", "content": "Choose a diff algorithm. The variants are as follows: default , myers The basic greedy diff algorithm. Currently, this is the default. minimal Spend extra time to make sure the smallest possible diff is\nproduced. patience Use \"patience diff\" algorithm when generating patches. histogram This algorithm extends the patience algorithm to \"support\nlow-occurrence common elements\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitattributes - Defining attributes per path" }, { "role": "assistant", "content": "USING MACRO ATTRIBUTES You do not want any end-of-line conversions applied to, nor textual diffs\nproduced for, any binary file you track. You would need to specify e.g. *.jpg -text -diff but that may become cumbersome, when you have many attributes. Using\nmacro attributes, you can define an attribute that, when set, also\nsets or unsets a number of other attributes at the same time. The\nsystem knows a built-in macro attribute, binary : *.jpg binary Setting the \"binary\" attribute also unsets the \"text\" and \"diff\"\nattributes as above. Note that macro attributes can only be \"Set\",\nthough setting one might have the effect of setting or unsetting other\nattributes or even returning other attributes to the \"Unspecified\"\nstate." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I tell if a file will be uploaded to git lfs correctly?\n\nI'm trying to add everything under MyProject/Frameworks/ to git-lfs (large file storage). I'm not sure what the proper format for matching all files and folders recursively under the Frameworks folder is. This answer says the proper format is git lfs track \"MyProject/Frameworks/**\", but Atlassian's help document says I should use git lfs track \"MyProject/Frameworks/\". I tried both and they didn't use git lfs for storage. It tried uploading files directly.\nSure, I'd love to know the proper format, but more importantly, before I attempt to push my changes to github, I'd like to verify that the match and files do indeed work correctly. This'll allow me to iterate and try new things.\nI see two related commands that might help: git lfs status and git lfs ls-files. It's not clear which one I should be using and what output I should be looking for. For example, when I ran git lfs status, it showed me a ton of files under Git LFS objects to be committed, making me think they would be added to Git LFS. However, after attempting to push to GitHub.com, I realized that it was clearly not the case. If it helps, the output for these files always had something like (Git: edee1ad) after each file name.\nWhen I attempt to use git lfs ls-files I'm not sure if I need to run it after git adding the files, after committing them, or after pushing them. Most of the time it's just showing me blank output.\nEssentially the question is: If I configured git lfs correctly, what tool (e.g. git lfs status) should I use, and what output should I look for before I attempt to commit/push?\nNote: Please don't answer the question with only how to match all recursive files as that will help me once (this specific case), rather than allowing me to iterate and try new things (any case)." }, { "role": "assistant", "content": "TL;DR\nIf everything is set up correctly, you can verify that git LFS is going to work properly by:\n\ngit add the file(s) in question.\nDo one of the following:\n\n\nRun git lfs status and ensure the file(s) in question appear under Git LFS objects to be committed, and that they have the LFS value in parenthesis; or\nRun git lfs ls-files and ensure the file(s) in question appear in this output.\n\n\n\n⚠️ Important: After running git lfs track, you must run git add to refresh the state of files before calling git lfs status or git lfs ls-files. Otherwise you'll see irrelevant output from those commands.\n\nAlso, for the record, looks like git lfs track \"MyProject/Frameworks/**\" is the correct one for recursive matching.\n\nSet up and testing methodology:\n\ngit lfs track \"*.lfs\". This generates .gitattributes. Leave it unstaged.\nCreate a file in the root directory, Test.lfs. Leave it unstaged.\nTest:\n\ngit lfs status: no filenames output\n$ git lfs status\nOn branch master\nGit LFS objects to be pushed to origin/master:\n\n\nGit LFS objects to be committed:\n\n\nGit LFS objects not staged for commit:\n\n\n$\n\ngit lfs ls-files: no output\n$ git lfs ls-files\n$\n\n\nAdd git add Test.lfs.\nTest:\n\ngit lfs status: Test.lfs will now be listed with an LFS suffix.\n$ git lfs status\nOn branch master\nGit LFS objects to be pushed to origin/master:\n\n\nGit LFS objects to be committed:\n\n Test.lfs (LFS: 2ab9f1e)\n\nGit LFS objects not staged for commit:\n\n\n$\n\ngit lfs ls-files: Test.lfs will now be listed. \n$ git lfs ls-files\n2ab9f1e447 * Test.lfs\n$\n\n\nCommit changes.\nTest:\n\ngit lfs status: Test.lfs will move to the \"to be pushed\" section. It will have a suffix such with a bunch of numbers/letters.\n$ git lfs status\nOn branch master\nGit LFS objects to be pushed to origin/master:\n\n Test.lfs (2ab9f1e44720efb7a26553e06b667a270320efb3e906553b3f9e0702538a2b3f)\n\nGit LFS objects to be committed:\n\n\nGit LFS objects not staged for commit:\n\n\n$\n\ngit lfs ls-files: Test.lfs will continue to be listed. \n$ git lfs ls-files\n2ab9f1e447 * Test.lfs\n$\n\n\nPush changes. Including adding/committing/pushing .gitattributes.\nTest:\n\ngit lfs status: no filenames output anymore\n$ git lfs status\nOn branch master\nGit LFS objects to be pushed to origin/master:\n\n\nGit LFS objects to be committed:\n\n\nGit LFS objects not staged for commit:\n\n\n$\n\ngit lfs ls-files: Continues to output the tracked file\n$ git lfs ls-files\n2ab9f1e447 * Test.lfs\n$\n\n\n\nConclusions:\n\nThe Git LFS objects not staged for commit section seems misleading as it never displayed any files, even those that should have been tracked by LFS.\nIf you attempt to do the previous experiment with a non git-lfs tracked file, you'll also notice that it appears under the Git LFS objects to be committed incorrectly. It is not a Git LFS object. The way you can tell that it's not actually a Git LFS object though is to look at how it ends. If it ends with (Git: 111111111) it won't be committed to LFS.\nTo avoid the above confusions, you may want to favor git lfs ls-files over git lfs status to determine if something is going to be part of git-lfs or not.\nAnother gotcha: Some applications such as Xcode will git add files in a weird way causing what should have been clear matches to not be considered for Git LFS. The solution is to unstage the files and then re-stage them." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I create a GitLab webhook?\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-rev-parse - Pick out and massage parameters The .. (two-dot) Range Notation" }, { "role": "assistant", "content": "The ^r1 r2 set operation appears so often that there is a shorthand\nfor it. When you have two commits r1 and r2 (named according\nto the syntax explained in SPECIFYING REVISIONS above), you can ask\nfor commits that are reachable from r2 excluding those that are reachable\nfrom r1 by ^r1 r2 and it can be written as r1..r2 ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to abort a cherry-pick?\nI ran git cherry-pick <hash> and had merge conflicts. I don't want to resolve the conflicts, I just want to abort the cherry-pick. When doing an actual merge (with git merge) there's the handy git merge --abort. What's the equivalent of cherry-picking?" }, { "role": "assistant", "content": "You can do the following\ngit cherry-pick --abort\n\nFrom the git cherry-pick docs\n\n--abort \n\nCancel the operation and return to the pre-sequence state." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Where can I see the commit history on the gitHub website?\n\nI am looking for the history button on gitHub for all the past git commits.\nThese are buttons on the gitHub page.\nCode\nIssues\nPull requests\nActions\nProjects\nWiki\nSecurity\nInsights\nSettings\n1 branch\n0 tags" }, { "role": "assistant", "content": "On the repository page there is commits button below the Big Green Pull-Down Code button to see all commits. Clicking on it will open all the history" } ]