{"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-status - Show the working tree status"}, {"role": "assistant", "content": "SYNOPSIS git status [] [--] […​]"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I see the commit differences between branches in git?\nI'm on branch-X and have added a couple more commits on top of it. I want to see all the differences between MASTER and the branch that I am on in terms of commits. I could just do a \ngit checkout master\ngit log\n\nand then a \ngit checkout branch-X\ngit log\n\nand visually diff these, but I'm hoping for an easier, less error-prone method."}, {"role": "assistant", "content": "You can easily do that with\ngit log master..branch-X\n\nThat will show you commits that branch-X has but master doesn't."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options blame.date"}, {"role": "assistant", "content": "Specifies the format used to output dates in git-blame .\nIf unset the iso format is used. For supported values,\nsee the discussion of the --date option at git-log ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database --tags"}, {"role": "assistant", "content": "Report tags."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is there a better way to find out if a local git branch exists?\nI am using the following command to find out if a local git branch with branch-name exists in my repository. Is this correct? Is there a better way?\nPlease note that I am doing this inside a script. For this reason I'd like to use plumbing commands if possible. \ngit show-ref --verify --quiet refs/heads/\n# $? == 0 means local branch with exists."}, {"role": "assistant", "content": "When I search for 'git check if branch exists' on a search engine, this page is the first one I see.\nI get what I want, but I'd like to provide a updated answer since the original post was from 2011.\ngit rev-parse --verify \n\nThis is essentially the same as the accepted answer, but you don't need type in \"refs/heads/\"\nSo from a shell script, this would be\nif [ `git rev-parse --verify main 2>/dev/null` ]\nthen\n ...\nfi"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git: push a single commit\nSay I made several commits and wish to cherry pick which ones I push to the remote repository. How can I do that (in ascii: C1->C2->C3->C4 and I want to push C2 and C4). Will reordering with rebase, resetting, pushing and then resetting work? (C1->C2->C3->C4 => C2->C4->C1->C3 => reset C4 => push => reset C3). Is there a nicer way?"}, {"role": "assistant", "content": "You may be looking for:\ngit push origin $commit:$branch\n\nCredit: http://blog.dennisrobinson.name/push-only-one-commit-with-git/\nExplanatory notes:\n\nPushing a commit pushes all commits before it (as Amber said). The\nkey is to reorder your commits first (git rebase -i), so they are\nin the order you want to push them.\n$commit doesn't have to be a sha1. For example,\n\"HEAD~N\" would push everything before the last N commits.\n$branch (typically \"master\" or \"main\") is the branch you push to – the remote branch. It does not have to be the same as a local branch.\nIf you need to get some commits out of the way locally, you can use the cherry-pick method (suggested by midtiby) to move them onto a separate local branch first. But as shown here, it's not necessary to create a local branch for the purpose of pushing to a remote branch. You can work on multiple branches at once if you are careful about which commits you push where.\n\n\nIf the remote branch does not exist yet, and you want to create it, it must be prefixed with refs/heads/ (to disambiguate branch from tag):\ngit push origin $commit:refs/heads/$branch\n\nAnd as a variation of this theme, deleting a remote branch can be thought of as pushing no commit to it:\ngit push origin :$branch\n\n\nPro tip: git-revise is a tool for massaging your commit stack into shape before pushing. It has a similar interface to git rebase. This tool is irreplaceable (correct me if I'm wrong) for sufficiently hard commit untangling jobs, though its interface is in dire need of replacement."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "In a git hook is the current working directory guaranteed to be within the git repository?\nExperimentally it seems that git hooks get run with the current directory set to be the root of the repository. However, I can't see any guarantee about that in the git documentation. Should I rely on the current working directory to locate the git repository, or is there a better way to work out the git repository associated with the hook?"}, {"role": "assistant", "content": "The current answers appear to be outdated. As of 2.9.0, the docs state the following:\n\nBefore Git invokes a hook, it changes its working directory to either\n the root of the working tree in a non-bare repository, or to the\n $GIT_DIR in a bare repository.\n\nhttps://git-scm.com/docs/githooks/2.9.0"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to find a deleted file in the project commit history?\n\nOnce upon a time, there was a file in my project that I would now like to be able to get.\nThe problem is: I have no idea of when have I deleted it and on which path it was.\nHow can I locate the commits of this file when it existed?"}, {"role": "assistant", "content": "If you do not know the exact path you may use\ngit log --all --full-history -- \"**/thefile.*\"\n\nIf you know the path the file was at, you can do this:\ngit log --all --full-history -- \n\nThis should show a list of commits in all branches which touched that file. Then, you can find the version of the file you want, and display it with...\ngit show -- \n\nOr restore it into your working copy with:\ngit checkout ^ -- \nNote the caret symbol (^), which gets the checkout prior to the one identified, because at the moment of commit the file is deleted, we need to look at the previous commit to get the deleted file's contents"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-gc - Cleanup unnecessary files and optimize the local repository --prune="}, {"role": "assistant", "content": "Prune loose objects older than date (default is 2 weeks ago,\noverridable by the config variable gc.pruneExpire ).\n--prune=now prunes loose objects regardless of their age and\nincreases the risk of corruption if another process is writing to\nthe repository concurrently; see \"NOTES\" below. --prune is on by\ndefault."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to cancel a pull request on github?\n\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."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options core.notesRef"}, {"role": "assistant", "content": "When showing commit messages, also show notes which are stored in\nthe given ref. The ref must be fully qualified. If the given\nref does not exist, it is not an error but means that no\nnotes should be printed. This setting defaults to \"refs/notes/commits\", and it can be overridden by\nthe GIT_NOTES_REF environment variable. See git-notes ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-apply - Apply a patch to files and/or to the index"}, {"role": "assistant", "content": "NAME git-apply - Apply a patch to files and/or to the index"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs i18n.logOutputEncoding"}, {"role": "assistant", "content": "Encoding to use when displaying logs. (See Discussion above.)\nDefaults to the value of i18n.commitEncoding if set, and UTF-8\notherwise."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -w --ignore-all-space"}, {"role": "assistant", "content": "Ignore whitespace when comparing lines. This ignores\ndifferences even if one line has whitespace where the other\nline has none."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-cvsimport"}, {"role": "assistant", "content": "Salvage your data out of another SCM people love to hate"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I get a git submodule's associated commit ID from a past commit in the parent clone?\nIs there a way, short of actually checking out the parent commit, to determine a submodule's SHA-1 commit ID based on a commit ID in the parent clone? I know I can find the currently associated SHA-1 with git submodule.\nHere's an example: \n\nI have a clone with a single submodule foo that has changed several times in the last month. \nI have a tag in the parent clone that is a few weeks old called released-1.2.3. I want to find out what the associated SHA-1 of foo was for this tagged commit. \nI could simply check out released-1.2.3 and use git submodule to see, but I'm wondering if there's a way to do this without affecting the working tree, as I want to script it.\n\nI want to do this because I want to construct a script to do a 'diff' on all changes within a submodule between two commits within the parent repository - i.e. \"tell me what files changed within the submodule foo between these two commits in the parent.\""}, {"role": "assistant", "content": "You may use git-ls-tree to see what the SHA-1 id of a given path was during a given commit:\n$ git ls-tree released-1.2.3 foo\n160000 commit c0f065504bb0e8cfa2b107e975bb9dc5a34b0398 foo\n\n(My first thought was git show released-1.2.3 foo, but that fails with \"fatal: bad object\".)\nSince you are scripting the output, you will probably want to get just the SHA-1 id by itself, e.g.:\n$ git ls-tree released-1.2.3 foo | awk '{print $3}'\nc0f065504bb0e8cfa2b107e975bb9dc5a34b0398\n\nAlso: When writing scripts around git, try to stick to the plumbing commands, as described in the manual. They have a more stable interface, while the more familiar “porcelain” commands will possibly change in incompatible ways."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Stuck at \"A merge operation in progress\"\nSteps\n\nIn Visual Studio\nPulled from remote repo\n1 merge conflict\nMerged manually, clicked 'Accept merge'\n\nResult\n\nMessage: \"A merge operation is in progress in the ... repository. Commit your changes to complete the merge operation.\"\nHowever, there is nothing to commit: There are 0 pending changes, no actions apart from Abort seem to be possible.\n\nScreenshot: https://pbs.twimg.com/media/DBOeRIiXsAEbnLP.jpg\nContext\n\nRemote git repo is hosted in Visual Studio Team Services\nVisual Studio 2017 with all updates"}, {"role": "assistant", "content": "I had a very similar problem with one of my projects which gave me the same TFS message in Visual Studio 2017. I was also using git. In my case I needed to manually add a comment to the commit before posting the merge. Since I had to manually merge the conflicts, a comment was needed rather than the auto-populated message that takes place on a merge without conflicts. \nI'm well aware that commits need comments but if I recall correctly, VS 2015 would auto-populate the comment on a merge, even if you manually fixed any merge issues. Regardless, in VS 2017 you will need to add a commit comment when there are resolved conflicts."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-merge - Join two or more development histories together subtree"}, {"role": "assistant", "content": "This is a modified ort strategy. When merging trees A and\nB, if B corresponds to a subtree of A, B is first adjusted to\nmatch the tree structure of A, instead of reading the trees at\nthe same level. This adjustment is also done to the common\nancestor tree."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Unfork a GitHub fork without deleting\nI would like to \"unfork\" a GitHub fork without deleting + recreating it. Is this possible?\nMy reason is that my project now has a completely different use to the source of the fork, and makes no sense to be showing number of commits ahead, or the pull request button (or at least, with such prominence). With hindsight, I think I would have just git cloned the original, rather than made a fork.\nI would like to not delete my fork in order to keep the issues + history of pull requests made.\nI am happy to keep the history of commits, it's just the removal of the fork status that I'm after."}, {"role": "assistant", "content": "Note: The following does not migrate GitHub specific metadata (issues, pull requests, wikis, releases, etc).\nUndoubtedly, there's no way but make a bare copy of all of the codes. However, the copy procedure can be done by GitHub itself. So, no pain of mirroring the code with our own bandwidth.\nStep by step:\n\nClick the \"+\" on top right corner, select \"Import repository\"\nPaste the old repo url (like https://github.com/user/repo) and enter a new name.\nClick \"Begin import\"\n\nDone. GitHub will even give you an email notification when copy'n'paste is done.\n\nUpdates on Jan, 2023.\nGithub support now provide \"unfork\" operation upon request. Just open a support ticket at https://support.github.com/contact?tags=rr-forks"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What does it mean when Git says 'rewrite' or 'rename' in a commit message?\nRunning a git commit leads to the following output:\n[manu@host] git: git commit -a -m \"StreamIt instrumentation\"\n[master 263410f] StreamIt instrumentation\n62 files changed, 6117 insertions(+), 5748 deletions(-)\nrewrite Code/ALCHEMY/streamit-src-2.1.1/src/at/dms/kjc/cluster/ClusterBackend.java (91%)\nrewrite Code/ALCHEMY/streamit-src-2.1.1/src/at/dms/kjc/cluster/ClusterCodeGenerator.java (95%)\nrewrite Code/ALCHEMY/streamit-src-2.1.1/src/at/dms/kjc/cluster/code/FlatIRToCluster.java (94%)\nrewrite Code/ALCHEMY/streamit-src-2.1.1/src/at/dms/kjc/common/ToCCommon.java (92%)\nrewrite Code/ALCHEMY/streamit-src-2.1.1/src/at/dms/kjc/flatgraph/ScheduledStaticStreamGraph.java (93%)\nrename Code/ALCHEMY/streamit-src-2.1.1/src/at/dms/kjc/sir/lowering/fission/{StatelessDuplicate.java => HorizontalFission.java} (98%)\nrewrite Code/ALCHEMY/streamit-src-2.1.1/src/at/dms/kjc/sir/lowering/partition/dynamicprog/DynamicProgPartitioner.java (93%)\n\n\nWhat does git mean when it reports a file as 'rewrite'? \nWhat is the meaning of the associated percentage?\nWhy is a percentage only associated with these lines among the 62 changed in this commit?"}, {"role": "assistant", "content": "Git uses heuristics to determine if a change was a renaming or copying of a file, and also if it is a \"rewriting\" of the file. Roughly speaking, if the diff between the old and new version is bigger than the new version itself, it's a \"rewrite\".\nThis is tuned for git's original use case of changing source files, most often making localised changes: since it is based on a line-by-line diff, things like reindenting a source file can trigger it. Also, since it is determined on-the-fly, diff options like \"-b\" and \"-w\" can change the evaluation of whether a change is a rewrite (or a copy, or a rename).\nThe percentage is git's \"dissimilarity index\" (as opposed to the percentage \"similarity index\" for a rename or copy). Probably something like the percentage of lines in the file that have changed."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to update git commit author, but keep original date when amending?\nIf the commits are already made and pushed to the repository, and if want to change an author for some particular commit I can do it like this:\ngit commit --amend --reset-author\n\nBut, that will change the original committed date.\nHow can I reset author, but keep the original committer date?"}, {"role": "assistant", "content": "Here's how to do it with rebase and keep both the commit date and the author date:\ngit -c rebase.instructionFormat='%s%nexec GIT_COMMITTER_DATE=\"%cD\" GIT_AUTHOR_DATE=\"%aD\" git commit --amend --no-edit --reset-author' rebase -f \n\nBased off this Reddit thread."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --word-diff[=]"}, {"role": "assistant", "content": "Show a word diff, using the to delimit changed words.\nBy default, words are delimited by whitespace; see --word-diff-regex below. The defaults to plain , and\nmust be one of: color Highlight changed words using only colors. Implies --color . plain Show words as [-removed-] and {+added+} . Makes no\nattempts to escape the delimiters if they appear in the input,\nso the output may be ambiguous. porcelain Use a special line-based format intended for script\nconsumption. Added/removed/unchanged runs are printed in the\nusual unified diff format, starting with a + / - /` `\ncharacter at the beginning of the line and extending to the\nend of the line. Newlines in the input are represented by a\ntilde ~ on a line of its own. none Disable word diff again. Note that despite the name of the first mode, color is used to\nhighlight the changed parts in all modes if enabled."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-stash - Stash the changes in a dirty working directory away …​"}, {"role": "assistant", "content": "This option is only valid for push command. The new stash entry records the modified states only for the files\nthat match the pathspec. The index entries and working tree files\nare then rolled back to the state in HEAD only for these files,\ntoo, leaving files that do not match the pathspec intact. For more details, see the pathspec entry in gitglossary ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Github Pages site not detecting index.html [closed]\n\nClosed. This question needs details or clarity. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Add details and clarify the problem by editing this post.\n\n\nClosed 3 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI created a GitHub pages repository. For some reason when I name it\nhttps://[username].github.io, it doesn't work, but it works when I name it https://[username].github.io/index.html.\nWhy?"}, {"role": "assistant", "content": "It got fixed automatically. I just had to wait for a while for the settings to take effect."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitHub - fatal: could not read Username for 'https://github.com': No such file or directory\n\nI have the following problem when I try to pull code using git Bash on Windows:\nfatal: could not read Username for 'https://github.com': No such file or directory\n\nI already tried to implement the accepted solution provided here:\n\nError when push commits with Github: fatal: could not read Username\n\nHowever the problem still persists.\nAfter adding/removing origin I still get the same error.\nCould advise on this issue?\nThanks!"}, {"role": "assistant", "content": "Follow the steps to setup SSH keys here: https://help.github.com/articles/generating-ssh-keys\nOR\ngit remote add origin https://{username}:{password}@github.com/{username}/project.git\n\nUpdate: If you get \"fatal: remote origin already exists.\" then you have to use set-url:\ngit remote set-url origin https://{username}:{password}@github.com/{username}/project.git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I push a specific commit to a remote, and not previous commits?\nI have made several commits on different files, but so far I would like to push to my remote repository only a specific commit.\nIs that possible?"}, {"role": "assistant", "content": "To push up through a given commit, you can write:\ngit push :\n\nprovided already exists on the remote. (If it doesn't, you can use git push :refs/heads/ to autocreate it.)\nIf you want to push a commit without pushing previous commits, you should first use git rebase -i to re-order the commits."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can I push/pull directly from my google drive online?\nThere are methods to sync my local git repository over to my google drive via google drive sync windows application, but I was wondering whether I could bypass its need altogether. \nFro eg. \n$ git remote add origin https://drive.google.com//.git\n$ git push github master"}, {"role": "assistant", "content": "No, you can't. There's no git running on Google drive.\nI would also suggest against Google drive/Dropbox based solutions, and go for a git hosting solution instead. For example Bitbucket which offers some free private repositories. You can find some comparison information about different git hosting sites here.\nAs people have pointed out (and as OP already knows), you can put the bare repository inside your local Google Drive/Dropbox folder and work with that, however, there are caveats. The cloud services have their own systems for merging conflicts, and that doesn't really work with git. Consider the scenario:\n\nYou work with device A offline, push some commits to the bare repository in Google Drive folder, but because you are offline, those changes do not sync to the cloud.\nYou then forget about it, work with device B online, push commits to Google Drive folder, and those changes do get synced.\nDevice A becomes online - you now have a conflict in Google Drive.\n\nThis is, of course, recoverable, but inconvenient. I therefore recommend to use a solution that is designed precisely for git hosting."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I avoid the specification of the username and password at every git push?\nI git push my work to a remote Git repository.\nEvery push will prompt me to input username and password. I would like to avoid it for every push, but how to configure to avoid it?"}, {"role": "assistant", "content": "1. Generate an SSH key\nLinux/Mac\nOpen terminal to create ssh keys:\ncd ~ #Your home directory\nssh-keygen -t rsa #Press enter for all values\n\nFor Windows\n(Only works if the commit program is capable of using certificates/private & public ssh keys)\n\nUse Putty Gen to generate a key\nExport the key as an open SSH key\n\nHere is a walkthrough on putty gen for the above steps\n2. Associate the SSH key with the remote repository\nThis step varies, depending on how your remote is set up.\n\nIf it is a GitHub repository and you have administrative privileges, go to settings and click 'add SSH key'. Copy the contents of your ~/.ssh/id_rsa.pub into the field labeled 'Key'.\nIf your repository is administered by somebody else, give the administrator your id_rsa.pub.\nIf your remote repository is administered by your, you can use this command for example: \nscp ~/.ssh/id_rsa.pub YOUR_USER@YOUR_IP:~/.ssh/authorized_keys/id_rsa.pub\n\n3. Set your remote URL to a form that supports SSH 1\nIf you have done the steps above and are still getting the password prompt, make sure your repo URL is in the form\ngit+ssh://[email protected]/username/reponame.git\n\nas opposed to\nhttps://github.com/username/reponame.git\n\nTo see your repo URL, run:\ngit remote show origin\n\nYou can change the URL with:\ngit remote set-url origin git+ssh://[email protected]/username/reponame.git\n\n[1] This section incorporates the answer from Eric P"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitfaq - Frequently asked questions about using Git What should I put in user.name ?"}, {"role": "assistant", "content": "You should put your personal name, generally a form using a given name\nand family name. For example, the current maintainer of Git uses \"Junio\nC Hamano\". This will be the name portion that is stored in every commit\nyou make. This configuration doesn’t have any effect on authenticating to remote services;\nfor that, see credential.username in git-config ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git checkout error: cannot create directory: Permission denied\n\nI am facing issues with the git checkout command. Please help.\nHere is what I did.\n\nCreated a local directory. Created some files. Initiated a git repo locally.\nCreated a repo in bitbucket & pushed my local repo to bitbucket\nCreated a new branch locally, b01\nAdded new files to b01, committed them and successfully pushed the branch to bitbucket\nNow I am trying to merge b01 with master and that is where I am facing issues. I am not able to checkout master.\n\nLists of commands used and the error details:\ngit clone [my repo]\ngit checkout -b b01\n\nHereafter I made multiple changes, including creating new files and directories, committed those changes and successfully pushed the changes on that branch to the repo. like:\ngit push -u origin b01\n\nNow I am done with the changes and want to merge it to the master branch. So I do a:\ngit checkout master\n\nHere is the error it throws:\nfatal: cannot create directory at 'workfolder': Permission denied\n\nGit keeps me in b01, but deletes ALL the files I had created in the branch. \nSo if I now do a \ngit status\n\nit shows me: \nOn branch b01\nYour branch is upto date with 'orgin/b01'\nChanges not staged for commit:\n(use \"git add/rm .....)\n deleted: new file1\n deleted: new file2\n\n\nI am having to run a \ngit checkout -- . \n\nto restore the files.\nPlease help."}, {"role": "assistant", "content": "I had a similar situation. Though it was due to me having the solution open in visual studio. Closing visual studio and doing a git reset put me into a good spot.\nI.e. check to see if any processes are locking the folder/files."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-symbolic-ref - Read, modify and delete symbolic refs -m"}, {"role": "assistant", "content": "Update the reflog for with . This is valid only\nwhen creating or updating a symbolic ref."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitsubmodules - Mounting one repository inside another"}, {"role": "assistant", "content": "NAME gitsubmodules - Mounting one repository inside another"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options credential.username"}, {"role": "assistant", "content": "If no username is set for a network authentication, use this username\nby default. See credential..* below, and gitcredentials ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to access multiple repositories in CI build?\n\nWe have a project that is composed of multiple (non-public) repositories. \nTo build the whole project, the build system needs to have the files of all repositories (master branches).\nIs there a way I can configure GitLab CI to provide the repositories I need?\nI guess I could do a git fetch or similar during the CI build, but how to deal with authentication then?"}, {"role": "assistant", "content": "If you are running GitLab version 8.12 or later, the permissions model was reworked. Along with this new permission model comes the CI environment variable CI_JOB_TOKEN. The premium version of GitLab uses this environment variable for triggers, but you can use it to clone repos.\ndummy_stage:\n script:\n - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.instance/group/project.git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-merge-base - Find as good common ancestors as possible for a merge -a --all"}, {"role": "assistant", "content": "Output all merge bases for the commits, instead of just one."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-shortlog - Summarize git log output --dense"}, {"role": "assistant", "content": "Commits that are walked are included if they are not TREESAME\nto any parent."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why does git merge a branch into itself?\nI awoke this morning and looked at the commit history of one of my dev team's private repositories on BitBucket. I saw this:\n\nAnonymous committed fcde879 MERGE\nMerge branch 'develop' of https://bitbucket.org/abc/xyz into develop\n\nThis is, uh, somewhat unusual. My guess was that this was pushed from a new machine that didn't have git configured properly. Still, I was not sure why it was doing this. On BitBucket, it shows two separate hashes as the commit parents, but it does not have the \"view raw commit\" option of other commits.\nI checked out that branch, pulled, and looked at the log manually.\nsidious@DS-1:/path/to/repo$ git log -1 --format=raw\ntree 2931d14f48e61eaf0bbe0660af5b5dd76c07f063\nparent 6bb38dee681df7620ffa42b6790641a7873166f2\nparent f59c82e19e3e79310a53e273bab78139c49ff063\nauthor root 1437069530 +0000\ncommitter root 1437069530 +0000\n\nMerge branch 'develop' of https://bitbucket.org/abc/xyz into develop\n\nAs far as I can tell, the 6bb parent is on the develop branch and the f59 parent appears to be from a different branch. It is kinda hard to tell what is going on.\nI searched but could not find an answer, and I need to get back to the grind, thus I posit my query here: why is git merging a branch into itself? Or, rather, why is this nomenclature being used as the commit message?"}, {"role": "assistant", "content": "This scenario is not unusual.\nThe key here is that the branches being merged are different: it's the remote repository's develop branch being merged into the developer's local (working) develop branch.\nIn the developer's local repository there are two distinct branches:\n\ndevelop = The branch he/she is currently working on. The new commits go here.\norigin/develop = This is essentially a snapshot that the current repository holds about the state of the develop branch on the remote server. It gets updated with the remote changes when you do fetch or pull, and with the local changes after a successful push.\n\nNow, when you do git pull, two things happen. This is because git pull is essentially an alias for other two git operations: fetch and merge:\n\nfetch - brings all new commits (if any) from the remote repository to the local origin/develop branch.\nmerge - takes the new commits and applies them to the local working develop branch. This can happen in one of two ways:\n\n\nif the local working branch does not contain divergent history (new commits that the remote does not know about), then it simply advances the develop branch pointer ahead, so that it points to the latest commit in origin/develop. This is known as a fast-forward merge.\nif the developer has some new commits of his own that are not present in the remote repo, and, therefore not in the origin/develop branch, then a regular merge is done, meaning that there's a new commit, containing the changes from both branches. By default, git assigns messages like these to such commits: Merge branch 'develop' of https://bitbucket.org/abc/xyz into develop.\n\n\nSo, the scenario is a pretty common one.\nNow, if this happens very often and you don't like to see very complex commit history graphs containing commits like the one we're talking about, try looking into using rebase instead of merge.\nYou can do this two ways (when getting the changes from the remote server):\n\ngit fetch; git rebase\ngit pull --rebase"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects"}, {"role": "assistant", "content": "DISCUSSION Git is to some extent character encoding agnostic. The contents of the blob objects are uninterpreted sequences\nof bytes. There is no encoding translation at the core\nlevel. Path names are encoded in UTF-8 normalization form C. This\napplies to tree objects, the index file, ref names, as well as\npath names in command line arguments, environment variables\nand config files ( .git/config (see git-config ), gitignore , gitattributes and gitmodules ). Note that Git at the core level treats path names simply as\nsequences of non-NUL bytes, there are no path name encoding\nconversions (except on Mac and Windows). Therefore, using\nnon-ASCII path names will mostly work even on platforms and file\nsystems that use legacy extended ASCII encodings. However,\nrepositories created on such systems will not work properly on\nUTF-8-based systems (e.g. Linux, Mac, Windows) and vice versa.\nAdditionally, many Git-based tools simply assume path names to\nbe UTF-8 and will fail to display other encodings correctly. Commit log messages are typically encoded in UTF-8, but other\nextended ASCII encodings are also supported. This includes\nISO-8859-x, CP125x and many others, but not UTF-16/32,\nEBCDIC and CJK multi-byte encodings (GBK, Shift-JIS, Big5,\nEUC-x, CP9xx etc.). Although we encourage that the commit log messages are encoded\nin UTF-8, both the core and Git Porcelain are designed not to\nforce UTF-8 on projects. If all participants of a particular\nproject find it more convenient to use legacy encodings, Git\ndoes not forbid it. However, there are a few things to keep in\nmind. git commit and git commit-tree issue\na warning if the commit log message given to it does not look\nlike a valid UTF-8 string, unless you explicitly say your\nproject uses a legacy encoding. The way to say this is to\nhave i18n.commitEncoding in .git/config file, like this: [i18n]\n\tcommitEncoding = ISO-8859-1 Commit objects created with the above setting record the value\nof i18n.commitEncoding in their encoding header. This is to\nhelp other people who look at them later. Lack of this header\nimplies that the commit log message is encoded in UTF-8. git log , git show , git blame and friends look at the encoding header of a commit object, and try to re-code the\nlog message into UTF-8 unless otherwise specified. You can\nspecify the desired output encoding with i18n.logOutputEncoding in .git/config file, like this: [i18n]\n\tlogOutputEncoding = ISO-8859-1 If you do not have this configuration variable, the value of i18n.commitEncoding is used instead. Note that we deliberately chose not to re-code the commit log\nmessage when a commit is made to force UTF-8 at the commit\nobject level, because re-coding to UTF-8 is not necessarily a\nreversible operation."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "When do I need to do \"git pull\", before or after \"git add, git commit\"?\nWhat is the right way?\ngit add foo.js\ngit commit foo.js -m \"commit\"\ngit pull\ngit push\n\nOr\ngit pull\ngit add foo.js\ngit commit foo.js -m \"commit\"\ngit push\n\nOr\ngit add foo.js\ngit pull\ngit commit foo.js -m \"commit\"\ngit push\n\nUPD:\nI forgot to mention that in this case I use git add to stage a tracked and modified file. Not to include a brand new file to repository. Does this changes an order of commands?"}, {"role": "assistant", "content": "I think that the best way to do this is:\nStash your local changes:\ngit stash\n\nUpdate the branch to the latest code\ngit pull\n\nMerge your local changes into the latest code:\ngit stash apply\n\nAdd, commit and push your changes\ngit add\ngit commit\ngit push\n\nIn my experience this is the path to least resistance with Git (on the command line anyway)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to push Git TAGs from IntelliJ without using the console?\nIs there a way to push git tags from IntelliJ without bringing up the console and typing git push origin master --tags?"}, {"role": "assistant", "content": "You can create a tag in VCS -> Git -> Tag... menu.\nThen open the push dialog with VCS -> Git -> Push and activate the checkbox \"Push Tags\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "VS 2022: \"Error encountered while pushing to the remote repository: Git failed with a fatal error...\"\n\nMy company uses GitLab, and when I try to push to my remote feature branch using the Git UI in Visual Studio 2022, I get the following error in the Output window:\nGit failed with a fatal error.\nunable to access '': \n schannel: CertGetCertificateChain trust error CERT_TRUST_IS_UNTRUSTED_ROOT\"\n\nI tried the following command that I saw in another solution git config --global http.\".sslCAInfo C:/path/to/cert.pem but it gives me the same error. The certificate used in the command I downloaded it from the GitLab server for the repo by clicking the padlock icon 🔏 and View Certificate.\nThis happens each time I push or pull from the UI. The error doesn't occur when I use a separate terminal like Git Bash or PowerShell."}, {"role": "assistant", "content": "After much gnashing of teeth and searching (and placing a bounty on this question) I was able to determine a workaround myself: Switch the Cryptographic network provider from OpenSSL to Secure Channel.\n\nUnder Tools > Options > Source Control > Git Global Settings\nI don't know why OpenSSL gave me an error; perhaps there's a better solution that works with OpenSSL. But just using the Windows SSL implementation resolved it for me when connecting to my company's Azure DevOps repository."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options local"}, {"role": "assistant", "content": "$GIT_DIR/config"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-check-ignore - Debug gitignore / exclude files -v, --verbose"}, {"role": "assistant", "content": "Instead of printing the paths that are excluded, for each path\nthat matches an exclude pattern, print the exclude pattern\ntogether with the path. (Matching an exclude pattern usually\nmeans the path is excluded, but if the pattern begins with \" ! \"\nthen it is a negated pattern and matching it means the path is\nNOT excluded.) For precedence rules within and between exclude sources, see gitignore ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-check-ignore - Debug gitignore / exclude files 128"}, {"role": "assistant", "content": "A fatal error was encountered."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-status - Show the working tree status --porcelain[=]"}, {"role": "assistant", "content": "Give the output in an easy-to-parse format for scripts.\nThis is similar to the short output, but will remain stable\nacross Git versions and regardless of user configuration. See\nbelow for details. The version parameter is used to specify the format version.\nThis is optional and defaults to the original version v1 format."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-filter-branch - Rewrite branches --tree-filter "}, {"role": "assistant", "content": "This is the filter for rewriting the tree and its contents.\nThe argument is evaluated in shell with the working\ndirectory set to the root of the checked out tree. The new tree\nis then used as-is (new files are auto-added, disappeared files\nare auto-removed - neither .gitignore files nor any other ignore\nrules HAVE ANY EFFECT !)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git's local repository and remote repository -- confusing concepts\nIf I understand correctly, Git has two sorts of repositories: one called local, another called remote. My questions are extremely naive ones about the two types of repositories.\nIs that correct to say\n\nGit local repository is the one on which we will make local changes, typically this local repository is on our computer.\n\nGit remote repository is the one of the server, typically a machine situated at 42 miles away.\n\n\nAnother question: some tutorial shows me this workflow\n\nmkdir myproject\ncd myproject\ngit init\ntouch README\ngit add README\ngit commit -a -m \"\n\nI see that git init creates myproject a local repository. What I don't understand is the\ngit commit command. If I have not yet set a remote repository, how can Git know where to commit my README file??\nI hope I was clear.\n[EDIT] The way I am using Git might be different from others:\nI use a private Git repository to backup my code. So I think I do need a remote repository. The local repository should be nonsense in this case. Am I right? Thanks for your clarification. These are the most naive questions that I cannot find replies anywhere else..."}, {"role": "assistant", "content": "Git is a distributed version control system and it makes Git awesome. Your local repository has exactly the same features and functionality as any other Git repository. So a Git repo on a server is the same as a Git repo on GitHub (granted GitHub adds additional features, but at its core, you're dealing with Git repositories) which is the same as your coworker's local repo.\nSo why is that awesome? Because there is no central repo you have to have access to do your work. You can commit, branch, and party on your own repo on your local machine even without internet access. Then, when you have a connection again, you can push your changes to any other Git repo you have access to. So while most people treat a particular repo as the central repo (repository), that's a process choice, not a Git requirement.\nThe point of all that was to state (as others have) that you're committing your README to your local repo. Then, whenever you choose, you can push changes from your local repo to any other repo. It's pretty nifty!"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-apply - Apply a patch to files and/or to the index --no-add"}, {"role": "assistant", "content": "When applying a patch, ignore additions made by the\npatch. This can be used to extract the common part between\ntwo files by first running diff on them and applying\nthe result with this option, which would apply the\ndeletion part but not the addition part."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is it possible to have one Git repo placed on Github and Gitlab?\n\nIs it possible to have one git repo placed on both github and gitlab?\nSo that if you push to a remote repo that its both on Github and Gitlab."}, {"role": "assistant", "content": "You have misunderstood how Git works. Or how content hosting works.\nFirst of all, your repo is not on GitHub nor GitLab. Your repo is on your hard disk, right there where you cloned or created it. This is a repository. Local one. This is where you do the work *)\nOn GitHub and on GitLab you can setup remote copy of your repository. Then, after you did some work on your local repo, you can instruct your local repo to send those new bits of work to that remote copy. Or to another remote copy. Or to 50 remote copies held in different places.\nSecond fact is, GitHub and GitLab are separate. In fact, there is one GitHub, but there is no single GitLab. There are many GitLabs out there, you can even buy a server and host your own GitLab. This only emphasises that they are all separate. Whatever you send to GitHub will NOT magically show up on GitLab1, nor GitLab2, nor (..)\nThird fact, they are all separate, but they all allow you to host copies of your git repo. Since you can instruct your local repo to send things to multiple remotes, you can have them all in sync.\nHowever, pasting all the URLs to all servers each time you want to do a push would be cumbersome, so your local git repo can be taught to know the remote locations and remember them for you. This called remotes and you probably saw it already in form:\ngit push origin master\n \\ \\\n \\ branch to be pushed\n name of the remote\n\norigin is the typical name for the-single-remote-server you work with. But if you want to have many, you probably want to set some meaningful names, like:\ngit remote add remote-github (url-to-repo-on-github)\ngit remote add remote-gitlab1 (url-to-repo-on-gitlab1)\ngit remote add remote-gitlab2 (url-to-repo-on-gitlab2)\n...\n\nThis sets up 3+ remotes with different names. Now you can:\ngit push remote-github master\ngit push remote-gitlab1 master\n\nand so on. That will work - basically, do code changes, commit, push them to 3+ servers, and you have \"same things on GitHub and GitLab\". Keep in mind that if you are not alone and if you let someone work on your code on GitHub/GitLab separately, everyone would need to push to all remotes at the same time and in the same order, or else it can diverge quickly.\nManually pushing to 2+ remotes can be somewhat cumbersome too, even if they are remembered by their names. That's why recent Git versions allow to set multiple push URLs under single name of a remote.\nAlso, Git repositories, and some Git hostings, support \"triggers\" or \"hooks\". These things allow you to set a script that will be executed every time something happens. Something like a commit or push. Using that you could instruct your hosting to, for example, at every received push do a push to the other remote repo. But I won't cover it, here&now, I think you already have enough keywords to search for!\n*) well, except for some semi-automated things like PRs/MRs/Reviews/Issues/etc - but that's specific to your workflow and support for it on the hosting site. Obviously, since sites are separate, and since support for features may differ, PRs/MRs/Reviews/../etc performed on one site will not magically transfer to other sites. If the specific feature is implemented via branches, then you can sync that via some hooks&scripting. Otherwise, you'd need to find a proper plugin for the site. Or, well, write it yourself. IIRC, at least GitLab has an API for that."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to re-authorize the OAuth Application 'Git Credential Manager'\n\nI am part of an organization that uses SSO in Github. I don't have problem to access the repository through the web, it redirects me to SSO login and that's all.\nThe problem started when I logged-in first to my personal repository on GitHub through Git-Bash, I did some changes and then I wanted to do changes in a repository from my organization. When I run the below command, it wrote me that I need to re-authorize the OAuth Application, but I don't understand how:\n$ git push --delete origin v0.1.3\nremote: The `' organization has enabled or enforced SAML SSO. To access\nremote: this repository, you must re-authorize the OAuth Application `Git Credential Manager`.\nfatal: unable to access 'https://github.com//myproj.git/': The requested URL returned error: 403\n\nHow can I re-authorize the login?\nI tried to re-open Git-Bash but it wrote me the same error."}, {"role": "assistant", "content": "My company just enabled SSO for my Github Org overnight so was getting the same error running git pull. I fixed this with the following steps.\n\nOpen Credential Manager in Windows and delete the existing credential for github.com\nRe-initialise the cred manager in git bash: git config --global credential.helper manager-core\nRe-run git pull and follow the pop-up instructions to authenticate in a browser (which happened automatically for me with SSO).\n\nAfter those steps git commands worked for me again."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --merges"}, {"role": "assistant", "content": "Print only merge commits. This is exactly the same as --min-parents=2 ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options --show-origin"}, {"role": "assistant", "content": "Augment the output of all queried config options with the\norigin type (file, standard input, blob, command line) and\nthe actual origin (config file path, ref, or blob id if\napplicable)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Make an existing Git branch track a remote branch?\nI know how to make a new branch that tracks remote branches, but how do I make an existing branch track a remote branch?\nI know I can just edit the .git/config file, but it seems there should be an easier way."}, {"role": "assistant", "content": "Given a branch foo and a remote upstream:\nAs of Git 1.8.0:\ngit branch -u upstream/foo\n\nOr, if local branch foo is not the current branch:\ngit branch -u upstream/foo foo\n\nOr, if you like to type longer commands, these are equivalent to the above two:\ngit branch --set-upstream-to=upstream/foo\n\ngit branch --set-upstream-to=upstream/foo foo\n\nAs of Git 1.7.0 (before 1.8.0):\ngit branch --set-upstream foo upstream/foo\n\nNotes:\n\nAll of the above commands will cause local branch foo to track remote branch foo from remote upstream.\nThe old (1.7.x) syntax is deprecated in favor of the new (1.8+) syntax. The new syntax is intended to be more intuitive and easier to remember.\nDefining an upstream branch will fail when run against newly-created remotes that have not already been fetched. In that case, run git fetch upstream beforehand.\n\n\nSee also: Why do I need to do `--set-upstream` all the time?"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Code coverage report using gitlab-ci.yml file\n\nI need to see code coverage report for a java maven project in Gitlab.\nAccording to this, this and some other sources:\n\nI added jacoco to the list of plugins in pom.xml.\nAdded pages job to my .gitlab-ci.yml file.\nAdded Total.*?([0-9]{1,3})% to code coverage parsing in project setting.\n\nbut there isn't any coverage report or at least I can't see it. There is no coverage percentage or coverage report page.\nContent of .gitlab-ci.yml file:\nimage: maven:latest\n\nvariables:\n MAVEN_CLI_OPTS: \"--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true\"\n MAVEN_OPTS: \"-Dmaven.repo.local=.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true\"\n\ncache:\n paths:\n - .m2/repository/\n\nbuild:\n stage: build\n script:\n - mvn $MAVEN_CLI_OPTS compile\n\ntest:\n stage: test\n script:\n - mvn $MAVEN_CLI_OPTS test\n artifacts:\n paths:\n - target/site/jacoco/\npages:\n stage: deploy\n dependencies:\n - test\n script:\n - mkdir public\n - mv target/site/jacoco/index.html public\n artifacts:\n paths:\n - public\n\ndeploy:\n stage: deploy\n script:\n - mvn $MAVEN_CLI_OPTS verify\n only:\n - master\n\njacoco plugin in pom.xml:\n\n org.jacoco\n jacoco-maven-plugin\n 0.7.5.201505241946\n \n \n pre-unit-test\n \n prepare-agent\n \n \n \n post-unit-test\n test\n \n report\n \n \n \n\n\nMy Project is a private project on gitlab.com.\nPipeline and its all 4 jobs passed successfully.\nHow can I see the coverage reports?"}, {"role": "assistant", "content": "It seems you forgot to add the calls to cat in your .gitlab-ci.yml file.\nYou should have something like that:\nscript:\n - mvn $MAVEN_CLI_OPTS test\n - cat target/site/jacoco/index.html\n\nThat being said, I don't think this is the best way of doing this, as you need to pollute your output with raw HTML in order to retreive the desired coverage value.\nI would recommend using the method described in this pull request instead: https://github.com/jacoco/jacoco/pull/488\n\nKeep the jacoco parts in your build.xml\nUse this awk instruction to print the correct code coverage total:\nawk -F\",\" '{ instructions += $4 + $5; covered += $5 } END { print covered, \"/\", \ninstructions, \"instructions covered\"; print 100*covered/instructions, \"% \ncovered\" }' target/site/jacoco/jacoco.csv\n\nReplace the Gitlab CI regexp with what the instruction returns: \\d+.\\d+ \\% covered\n\nEdit:\nAs of Gitlab 8.17, you can define the regexp directly inside the .gitlab-ci.yml file, as stated in the documentation.\nIt may seem superfluous, but if this regexp is now part of your repository history, you can change it alongside the other tools used to compute it."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git: name and email address configuration\nOnce in a while I get the message shown below from Git. My questions regarding this are:\n\nWhy does this happen?\nHow can I prevent this from happening again?\nHow does this affect my commits or any other Git actions I may take?\n\nI realize similar questions have been posted to Stack Overflow, but I don't believe they address this message in particular.\n\nYour name and email address were configured automatically based\non your username and hostname. Please check that they are accurate.\nYou can suppress this message by setting them explicitly:\ngit config --global user.name \"Your Name\"\ngit config --global user.email [email protected]\n\nAfter doing this, you may fix the identity used for this commit with:\ngit commit --amend --reset-author"}, {"role": "assistant", "content": "Git simply detects you don't have the following section in your config files:\n[user]\n name = \n email = \n\n\n/.git/config for the project specific config file.\n~/.gitconfig the global config file\n\nWhen you do:\ngit config --global user.name \"Your Name\"\ngit config --global user.email [email protected]\n\nGit writes that information into the configuration file (--global means in the global config file).\nTo have a the correct Author section in a commit like the following example commit:\ncommit 79eeaa9f22321580a0e5bee6e237331691cd3b68\nAuthor: Sandro Munda <[email protected]>\nDate: Thu Jun 8 10:40:05 2012 +0200\n\n My first commit\n\nYou need to reset the commit information with the command:\ngit commit --amend --reset-author"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git branch: gh-pages\nI have a repo on GitHub. Recently I have discovered GitHub's pages and I want to use them.\nI would like to create this new branch and then, when I need to, either commit on master branch or on gh-pages branch. \nHow can I do this? Do I have to create another folder inside my repo?"}, {"role": "assistant", "content": "More recent versions of git have an alternative to the git symbolic-ref method that Chandru explained. This avoids having to use the lower level commands.\ngit checkout --orphan gh-pages\ngit rm -rf ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-daemon - A really simple server for Git repositories --port="}, {"role": "assistant", "content": "Listen on an alternative port. Incompatible with --inetd option."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why do some repository URLs end in .git while others don't?\nWhen I clone a repository, is there any difference between these two URLs?\n\nWithout .git extension:\ngit clone http://foo/repo\n\nWith .git extension:\ngit clone http://foo/repo.git"}, {"role": "assistant", "content": "The convention is that the .git extension should be used for bare repositories, and left off of directories with a working tree. Git doesn't really care, but has a few convenience methods that make this fairly transparent.\nFor example, if you have a repository named /tmp/foo.git and you call git clone file:///tmp/foo, Git will first try to find /tmp/foo. If it doesn't exist, it will try /tmp/foo.git instead.\nThis does not work the other way around. If your directory is named /tmp/foo and you try to clone from /tmp/foo.git you will be told:\n\nfatal: '/tmp/foo.git' does not appear to be a git repository\n\nMost of the HTTP/HTTPS functionality is from your web server, not Git. Even if you're using Smart HTTP transport, I suspect most of the magic happens in a server-side LocationMatch directive. Theory aside, some quick tests against GitHub show that it works the same way as the SSH and Git procotols in that respect, but your mileage may vary on other web servers."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options bundle..uri"}, {"role": "assistant", "content": "This string value defines the URI by which Git can reach the contents\nof this . This URI may be a bundle file or another bundle list."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to copy contents of one branch to other branch?\nI have 'develop' and 'InitialPomChanges' branches. I want to copy all the contents of develop branch to InitialPomChanges branch."}, {"role": "assistant", "content": "Assuming you want to overwrite all the contents of InitialPomChanges with what is in develop (i.e. you want the contents of InitialPomChanges to exactly match develop), do the following:\ngit checkout InitialPomChanges\ngit checkout develop . #copies the contents of develop into the working directory\ngit commit -am \"Making InitialPomChanges match develop\"\n\nThis will make the last commit in InitialPomChanges match the last commit in develop. To make future merges between the two branches easier, it would be a good idea to now do a git merge develop. \nAlternatively, if you want to change the contents of InitialPomChanges and do the merge in one single commit, you can do:\ngit checkout InitialPomChanges\ngit merge -s theirs develop"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Error while pull from git - insufficient permission for adding an object to repository database .git/objects\nI have git error: \"insufficient permission for adding an object to repository database .git/objects\" every time I make \"git pull origin develop\".\n remote: Counting objects: 70, done.\n remote: Compressing objects: 100% (7/7), done.\n remote: Total 42 (delta 35), reused 42 (delta 35)\n error: insufficient permission for adding an object to repository database .git/objects\n\n fatal: failed to write object\n fatal: unpack-objects failed"}, {"role": "assistant", "content": "Assuming @ChrisHayes is right about an accidental sudo, this should fix it. From inside your repository:\nsudo chown -R $USER:$USER \"$(git rev-parse --show-toplevel)/.git\"\n\nUpdate: for those of you getting the illegal group name error, try this instead:\nsudo chown -R $(id -u):$(id -g) \"$(git rev-parse --show-toplevel)/.git\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-verify-pack - Validate packed Git archive files"}, {"role": "assistant", "content": "OUTPUT FORMAT When specifying the -v option the format used is: SHA-1 type size size-in-packfile offset-in-packfile for objects that are not deltified in the pack, and SHA-1 type size size-in-packfile offset-in-packfile depth base-SHA-1 for objects that are deltified."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is there a way to show a progressbar on Github Wiki?\n\nI want to show the progress of the current iteration of my project on Github Wiki. However I couldn't find a way to do this. \nI am looking for something similar to the Bootstrap progress bars without any interaction. Is there a simple way to do this?"}, {"role": "assistant", "content": "Use this link as an image:\nhttps://progress-bar.dev/\nExample: ![50%](https://progress-bar.dev/50) \nIf you want to add a title like shields.io:\nhttps://progress-bar.dev/?title= \nMore documentation can be found here."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git mkdirs"}, {"role": "assistant", "content": "Attempts to recreate empty directories that core Git cannot track\nbased on information in $GIT_DIR/svn/<refname>/unhandled.log files.\nEmpty directories are automatically recreated when using\n\"git svn clone\" and \"git svn rebase\", so \"mkdirs\" is intended\nfor use after commands like \"git checkout\" or \"git reset\".\n(See the svn-remote.<name>.automkdirs config file option for\nmore information.)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I connect my python spyder with github?\n\nIs there any way to connect python spyder with github?\nI manage my R scripts via github, because R provides with\ninterfaces that enables users to commit, pull and push,\nbut I wonder if there is same(or similar) system in python(x,y) spyder.\nI want to manage my python scripts with github, not just locally\nediting my code and manually write change logs on my hand every time."}, {"role": "assistant", "content": "A command line git has been integrated into Spyder.\nhttps://github.com/spyder-ide/spyder/issues/6105\n\nFirst right click the tab corresponding to any file in your repository and click \"set console working directory.\"\nThen go to the Ipython window in Spyder and simply type your git commands (assuming Git is installed and its paths are configured properly) but append a \"!\" to the beginning of your command:\n!git add \"file.py\"\n!git commit -m \"My commit\"\n!git push origin master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Download Github pull request as unified diff\n\nHow can I download the changes contained in a Github pull request as a unified diff?"}, {"role": "assistant", "content": "To view a commit as a diff/patch file, just add .diff or .patch to the end of the URL, for example:\n\nhttps://github.com/weppos/whois/pull/90\nhttps://github.com/weppos/whois/pull/90.diff\nhttps://github.com/weppos/whois/pull/90.patch"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker --config-env=<name>=<envvar>"}, {"role": "assistant", "content": "Like -c <name>=<value> , give configuration variable <name> a value, where <envvar> is the name of an\nenvironment variable from which to retrieve the value. Unlike -c there is no shortcut for directly setting the value to an\nempty string, instead the environment variable itself must be\nset to the empty string. It is an error if the <envvar> does not exist\nin the environment. <envvar> may not contain an equals sign\nto avoid ambiguity with <name> containing one. This is useful for cases where you want to pass transitory\nconfiguration options to git, but are doing so on operating systems\nwhere other processes might be able to read your command line\n(e.g. /proc/self/cmdline ), but not your environment\n(e.g. /proc/self/environ ). That behavior is the default on\nLinux, but may not be on your system. Note that this might add security for variables such as http.extraHeader where the sensitive information is part of\nthe value, but not e.g. url.<base>.insteadOf where the\nsensitive information can be part of the key."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-tag - Create, list, delete or verify a tag object signed with GPG"}, {"role": "assistant", "content": "NAME git-tag - Create, list, delete or verify a tag object signed with GPG"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git error: src refspec master does not match any error: failed to push some refs [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nMessage 'src refspec master does not match any' when pushing commits in Git\n\n (142 answers)\n \n\nClosed 10 years ago.\n\n\n\nI am trying to add a file to my repository on BitBucket and I am having trouble.\nI am using GIT and this is what I type in \n$ cd lis4368/assignments\n$ git remote\n$ git remote -v\n$ git remote rm origin\n\nand then I type this in (this is what BitBucket tells me to enter)\n$ git remote add origin https://[email protected]/cpb09e/cpb09e.git\n$ git push -u origin master\n\nAnd I keep getting this error message: \nerror: src refspec master does not match any.\nerror: failed to push some refs to 'https://[email protected]/cpb09e/cpb09e.git'\n\nCan someone pleas help me out? I have tried everything from git commit to rm -rf * and I cannot get anything to work at all."}, {"role": "assistant", "content": "One classic root cause for this message is:\n\nwhen the repo has been initialized (git init lis4368/assignments),\nbut no commit has ever been made\n\nIe, if you don't have added and committed at least once, there won't be a local master branch to push to.\nTry first to create a commit:\n\neither by adding (git add .) then git commit -m \"first commit\"\n(assuming you have the right files in place to add to the index)\nor by create a first empty commit: git commit --allow-empty -m \"Initial empty commit\"\n\nAnd then try git push -u origin master again.\nSee \"Why do I need to explicitly push a new branch?\" for more."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --no-binary"}, {"role": "assistant", "content": "Do not output contents of changes in binary files, instead\ndisplay a notice that those files changed. Patches generated\nusing this option cannot be applied properly, but they are\nstill useful for code review."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git --shared[=(false|true|umask|group|all|world|everybody)] --template=<template-directory>"}, {"role": "assistant", "content": "Only used with the init command.\nThese are passed directly to git init ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to see changes to a file before commit?\nI have tried git commit -v\nubuntu@ip:~/agile$ git commit -v\n# On branch master\n# Changes not staged for commit:\n# (use \"git add <file>...\" to update what will be committed)\n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n# modified: .htaccess\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\nubuntu@ip:~/agile$ \n\nBut it is just showing me that .htaccess has changed, but not what has changed. How do I achieve this?\nUpdate: \nIn Aptana Studio it is possible to see the changes before you commit anything. So back to my question, there must be a way to see the difference to the original state, before you actually commit. Maybe there is a different command for that."}, {"role": "assistant", "content": "To see all the diff in tracked files but not staged:\ngit diff\n\nor\ngit diff path/to/a/given/file\n\nto see the diff only for a file. You can also see the diff in a given sub-directory of your project:\ngit diff path/to/a/dir/\n\nIf you have already staged the changes with git add, you can see what patch you have staged with\ngit diff --staged\n\nYou can also specify a path with --staged."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I show statistics for author's contributions in git?\nI'm working with a team on a git project and I would like to see the contribution of each author in terms of lines written or lines edited etc... how can I show statistics for the authors?"}, {"role": "assistant", "content": "As simple as:\ngit shortlog -s -n"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gerrit - git (pull vs checkout vs cherrypick) which is for what?\nIn Android's gerrit ex: link, to download the patch, I see 4 options.\n\nrepo download\ncheckout\npull\ncherry-pick\n\nWhat is the difference between them?\nHere is what I think of them. Please clarify\n\nrepo download --> Downloads full source code(of all git repos in the project) till this commit\ncheckout --> Not sure what it is.\npull --> Not sure what it does?\ncherry-pick --> It tries to download only this change and merge it into the source code.\n\nI know that pull and checkout are different from cherry-pick. But how are they different?"}, {"role": "assistant", "content": "You are right about the first one. Here are the rest of them:\n\nCheckout: Fetches the latest changes. You should already have this repo downloaded. It does not merge those new changes but makes your working directory reflect them. And a name-less commit is created to include these changes in your working directory. And a detached HEAD pointing to it. You can merge them at your leisure later.\n\nPull: Fetches the changes AND merges them into the local branch of the same name.\n\nCherry-pick: Fetches the commit and plays it on top of the current local branch, thus creating an entirely new commit which happens to have same changes as the one it fetched.\n\n\nThey are a little different than what they actually mean in git. checkout and cherry-pick don't automatically fetch the changes. checkout just takes HEAD to a commit you specify, thus making working directory exactly as it was at that commit. Likewise, cherry-pick is used to replay commits which you already have local access to."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git stash and git pull\nI am new to Git and I am using EGit eclipse plugin to commit.\nI modified few files and I stashed the changes, then I did git pull in command line which pulled up all the latest commits. Then I did Apply stashed changes from EGit. Now it applied my changes and the changes which pulled from last commit of stashed files went out. I am not sure why it didn't ask me about merge conflicts and overwrote my changes and lost previous commits changes. \nHow to get those changes?"}, {"role": "assistant", "content": "When you have changes on your working copy, from command line do:\ngit stash \n\nThis will stash your changes and clear your status report\ngit pull\n\nThis will pull changes from upstream branch. Make sure it says fast-forward in the report. If it doesn't, you are probably doing an unintended merge\ngit stash pop\n\nThis will apply stashed changes back to working copy and remove the changes from stash unless you have conflicts. In the case of conflict, they will stay in stash so you can start over if needed.\nif you need to see what is in your stash\ngit stash list"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Difference between HEAD and master (or main)\n\nWhat is the difference between the HEAD and master in Git?\nI did a clone of a project on GitHub and want to push my changes to the remote. But to which one should I push?"}, {"role": "assistant", "content": "master is a reference to the end of a branch. By convention this is usually the main integration branch, but it doesn't have to be. (As of git v2.28.0, released in July 2020, the default name changed from master to main)\nHEAD is actually a special type of reference that points to another reference. It may point to master/main or it may not (it will point to whichever branch is currently checked out). If you know you want to be committing to the master/main branch then push to this.\nHere is a visual example:\n\nOn your own repository you can check where the HEAD is pointing to by running this:\n$ git symbolic-ref HEAD\nrefs/heads/master\n\nHowever, finding out where the remotes/origin/HEAD is pointing to is more tricky because it is on the remote machine.\nThere is a great little tutorial on git references here"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs git log -L '/int main/',/^}/:main.c"}, {"role": "assistant", "content": "Shows how the function main() in the file main.c evolved\nover time."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is the internal format of a Git tree object?\nWhat is the format of a Git tree object's content?\nThe content of a blob object is blob [size of string] NUL [string], but what is it for a tree object?"}, {"role": "assistant", "content": "The format of a tree object:\ntree [content size]\\0[Entries having references to other trees and blobs]\n\nThe format of each entry having references to other trees and blobs:\n[mode] [file/folder name]\\0[SHA-1 of referencing blob or tree]\n\nI wrote a script deflating tree objects. It outputs as follows:\ntree 192\\0\n40000 octopus-admin\\0 a84943494657751ce187be401d6bf59ef7a2583c\n40000 octopus-deployment\\0 14f589a30cf4bd0ce2d7103aa7186abe0167427f\n40000 octopus-product\\0 ec559319a263bc7b476e5f01dd2578f255d734fd\n100644 pom.xml\\0 97e5b6b292d248869780d7b0c65834bfb645e32a\n40000 src\\0 6e63db37acba41266493ba8fb68c76f83f1bc9dd\n\nThe number 1 as the first character of a mode shows that is reference to a blob/file. The example above, pom.xml is a blob and the others are trees.\nNote that I added new lines and spaces after \\0 for the sake of pretty printing. Normally all the content has no new lines. Also I converted 20 bytes (i.e. the SHA-1 of referencing blobs and trees) into hex string to visualize better."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to connect Bitbucket to Jenkins properly\nSince about 1 week now, Bitbucket doesn't (?) send a request to my Jenkins server.\nI've set it all up like this: \nEndpoint http://username:apitoken@jenkinshost/\nusername = username in Jenkins\napitoken = apitoken connected to the username in Jenkins\njenkinshost = my host where I run Jenkins \nProject name is a project\nToken: The token I can setup in the per-project configuration.\nI've done this according to this website: http://felixleong.com/blog/2012/02/hooking-bitbucket-up-with-jenkins.\nIt did work, but it doesn't anymore. Did Bitbucket change something? How can I fix this?"}, {"role": "assistant", "content": "In order to build your repo after new commits, use Bitbucket Plugin.\nThere is just one thing to notice:\nWhen creating a POST Hook (notice that it is POST hook, not Jenkins hook), the URL works when it has a \"/\" in the end. Like:\nURL: JENKINS_URL/bitbucket-hook/\ne.g. someAddress:8080/bitbucket-hook/\n\nDo not forget to check \"Build when a change is pushed to Bitbucket\" in your job configuration."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git Copy a folder from master branch to another branch\n\nI have folder name utils I want to copy this folder from master branch to work branch. How do I do that ?"}, {"role": "assistant", "content": "To copy the folder over:\n$ git checkout work\nSwitched to branch 'work'\n$ git checkout master -- utils\n$ git add utils\n$ git commit -m \"Adding 'utils' directory from 'master' branch.\"\n[work 9fcd968] Adding 'utils' directory from 'master' branch.\n 1 file changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 utils/file\n\nIf you want to delete it on master after that:\n$ git checkout master\nSwitched to branch 'master'\n$ git rm -r utils\nrm 'utils/file'\n$ git commit -m \"Removing 'utils' directory.\"\n[master c786f95] Removing 'utils' directory.\n 1 file changed, 0 insertions(+), 0 deletions(-)\n delete mode 100644 utils/file\n\nThen you can just git push as necessary. Git's output in your project may be different; I just made a simple test repo here with only one file in the utils directory."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git merge hotfix branch into feature branch\nLet’s say we have the following situation in Git:\n\nA created repository:\nmkdir GitTest2\ncd GitTest2\ngit init\n\nSome modifications in the master take place and get committed:\necho \"On Master\" > file\ngit commit -a -m \"Initial commit\"\n\nFeature1 branched off master and some work is done:\ngit branch feature1\ngit checkout feature1\necho \"Feature1\" > featureFile\ngit commit -a -m \"Commit for feature1\"\n\nMeanwhile, a bug is discovered in the master-code and a hotfix-branch is established:\ngit checkout master\ngit branch hotfix1\ngit checkout hotfix1\n\nThe bug is fixed in the hotfix branch and merged back into the master (perhaps after a pull request/code review):\necho \"Bugfix\" > bugfixFile\ngit commit -a -m \"Bugfix Commit\"\ngit checkout master\ngit merge --no-ff hotfix1\n\nDevelopment on feature1 continues:\ngit checkout feature1\n\n\nSay I need the hotfix in my feature branch, maybe because the bug also occurs there. How can I achieve this without duplicating the commits into my feature branch?\nI want to prevent to get two new commits on my feature branch which have no relation to the feature implementation. This especially seems important for me if I use pull requests: All these commits will also be included in the pull request and have to be reviewed although this has already been done (as the hotfix is already in the master).\nI can not do a git merge master --ff-only: \"fatal: Not possible to fast-forward, aborting.\", but I am not sure if this helped me."}, {"role": "assistant", "content": "How do we merge the master branch into the feature branch? Easy:\ngit checkout feature1\ngit merge master\n\nThere is no point in forcing a fast forward merge here, as it cannot be done. You committed both into the feature branch and the master branch. Fast forward is impossible now.\nHave a look at GitFlow. It is a branching model for git that can be followed, and you unconsciously already did. It also is an extension to Git which adds some commands for the new workflow steps that do things automatically which you would otherwise need to do manually.\nSo what did you do right in your workflow? You have two branches to work with, your feature1 branch is basically the \"develop\" branch in the GitFlow model.\nYou created a hotfix branch from master and merged it back. And now you are stuck.\nThe GitFlow model asks you to merge the hotfix also to the development branch, which is \"feature1\" in your case.\nSo the real answer would be:\ngit checkout feature1\ngit merge --no-ff hotfix1\n\nThis adds all the changes that were made inside the hotfix to the feature branch, but only those changes. They might conflict with other development changes in the branch, but they will not conflict with the master branch should you merge the feature branch back to master eventually.\nBe very careful with rebasing. Only rebase if the changes you did stayed local to your repository, e.g. you did not push any branches to some other repository. Rebasing is a great tool for you to arrange your local commits into a useful order before pushing it out into the world, but rebasing afterwards will mess up things for the git beginners like you."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What are valid fields for the --format option of git for-each-ref?\nI am trying to find the first branch that was created on a repository. To do so I used:\ngit for-each-ref --sort=commiterdate --format='%(commiterdate:short) %(refname:short)' --count=1\n\nHowever I want more information on this branch. I.e how long this branch lived, when was it merged back to the master trunk etc. \nIs there a list of field options available somewhere? I tried googling a lot but couldn't find anything."}, {"role": "assistant", "content": "I've found a field list on git repository, file builtin/for-each-ref.c:\n} valid_atom[] = {\n { \"refname\" },\n { \"objecttype\" },\n { \"objectsize\", FIELD_ULONG },\n { \"objectname\" },\n { \"tree\" },\n { \"parent\" },\n { \"numparent\", FIELD_ULONG },\n { \"object\" },\n { \"type\" },\n { \"tag\" },\n { \"author\" },\n { \"authorname\" },\n { \"authoremail\" },\n { \"authordate\", FIELD_TIME },\n { \"committer\" },\n { \"committername\" },\n { \"committeremail\" },\n { \"committerdate\", FIELD_TIME },\n { \"tagger\" },\n { \"taggername\" },\n { \"taggeremail\" },\n { \"taggerdate\", FIELD_TIME },\n { \"creator\" },\n { \"creatordate\", FIELD_TIME },\n { \"subject\" },\n { \"body\" },\n { \"contents\" },\n { \"contents:subject\" },\n { \"contents:body\" },\n { \"contents:signature\" },\n { \"upstream\" },\n { \"symref\" },\n { \"flag\" },\n { \"HEAD\" },\n { \"color\" },\n};"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git error on git pull (unable to update local ref)\nI only have a master branch and I'm getting this error every time I try to git pull:\nerror: Couldn't set refs/remotes/origin/master\nFrom /var/lib/git/xxx/project\n ! a0f80ea..49177a3 master -> origin/master (unable to update local ref)\n\nAnd when I run git pull origin master I get:\nerror: Couldn't set ORIG_HEAD\nfatal: Cannot update the ref 'ORIG_HEAD'.\n\nI have been searching but can't find why."}, {"role": "assistant", "content": "My team and I ran into this error, unable to update local ref, when doing a pull in SourceTree.\n\nUpdate 2020: Per @Edward Yang's answer below, @bryan's comment on this answer, and this question/answer you may need to run both git gc --prune=now and git remote prune origin. Running only the former has always worked for me but based on ppl's responses I think both are necessary to address different causes of the error.\n\nWe used:\ngit gc --prune=now\n\nThis removes any duplicate reference objects which should fix the issue.\nHere are a few links where you can learn more about git references and pruning :\ngit tip of the week\ngit-prune documentation\ngit references"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.ignoreSubmodules"}, {"role": "assistant", "content": "Sets the default value of --ignore-submodules. Note that this\naffects only git diff Porcelain, and not lower level diff commands such as git diff-files . git checkout and git switch also honor\nthis setting when reporting uncommitted changes. Setting it to all disables the submodule summary normally shown by git commit and git status when status.submoduleSummary is set unless it is\noverridden by using the --ignore-submodules command-line option.\nThe git submodule commands are not affected by this setting.\nBy default this is set to untracked so that any untracked\nsubmodules are ignored."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-switch - Switch branches --recurse-submodules --no-recurse-submodules"}, {"role": "assistant", "content": "Using --recurse-submodules will update the content of all\nactive submodules according to the commit recorded in the\nsuperproject. If nothing (or --no-recurse-submodules ) is\nused, submodules working trees will not be updated. Just\nlike git-submodule , this will detach HEAD of the\nsubmodules."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker <commit-ish>"}, {"role": "assistant", "content": "Indicates a commit or tag object name. A\ncommand that takes a <commit-ish> argument ultimately wants to\noperate on a <commit> object but automatically dereferences\n<tag> objects that point at a <commit>."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_AUTHOR_DATE"}, {"role": "assistant", "content": "The date used for the author identity when creating commit or tag objects, or\nwhen writing reflogs. See git-commit for valid formats."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why does my 'git branch' have no master?\nI'm a git newbie and I keep reading about a \"master\" branch. Is \"master\" just a conventional name that people used or does it have special meaning like HEAD?\nWhen I do git branch on the clone that I have, I only see 1 single branch - the one I'm on. No \"master\" at all. If I type git checkout master (as I see in alot of tutorials or guides), I get\nerror: pathspec 'master' did not match any file(s) known to git.\n\nI'm just confused as to why my clone doesn't have a master that everyone seems to imply that it always exists."}, {"role": "assistant", "content": "Most Git repositories use master as the main (and default) branch - if you initialize a new Git repo via git init, it will have master checked out by default.\nHowever, if you clone a repository, the default branch you have is whatever the remote's HEAD points to (HEAD is actually a symbolic ref that points to a branch name). So if the repository you cloned had a HEAD pointed to, say, foo, then your clone will just have a foo branch.\nThe remote you cloned from might still have a master branch (you could check with git ls-remote origin master), but you wouldn't have created a local version of that branch by default, because git clone only checks out the remote's HEAD."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-ls-files - Show information about files in the index and the working tree --debug"}, {"role": "assistant", "content": "After each line that describes a file, add more data about its\ncache entry. This is intended to show as much information as\npossible for manual inspection; the exact format may change at\nany time."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Resolve Git merge conflicts in favor of their changes during a pull\nHow do I resolve a git merge conflict in favor of pulled changes?\nI want to remove all conflicting changes from a working tree without having to go through all of the conflicts with git mergetool, while keeping all conflict-free changes. Preferably, I want to do this while pulling, not afterwards."}, {"role": "assistant", "content": "git pull -s recursive -X theirs <remoterepo or other repo>\n\nOr, simply, for the default repository:\ngit pull -X theirs\n\nIf you're already in conflicted state...\ngit checkout --ours path/to/file\n\n\nNote that during git rebase and git pull --rebase, ours and theirs may appear swapped; --ours gives the version from the branch the changes are rebased onto, while --theirs gives the version from the branch that holds your work that is being rebased.\ngit checkout docs"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options addEmbeddedRepo"}, {"role": "assistant", "content": "Shown when the user accidentally adds one\ngit repo inside of another."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-shortlog - Summarize git log output --full-history with parent rewriting"}, {"role": "assistant", "content": "Ordinary commits are only included if they are !TREESAME\n(though this can be changed, see --sparse below). Merges are always included. However, their parent list is rewritten:\nAlong each parent, prune away commits that are not included\nthemselves. This results in .-A---M---N---O---P---Q\n\t / / / / /\n\tI B / D /\n\t \\ / / / /\n\t `-------------' Compare to --full-history without rewriting above. Note that E was pruned away because it is TREESAME, but the parent list of P was\nrewritten to contain E 's parent I . The same happened for C and N , and X , Y and Q ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Rename a git submodule\nIs there some easy way to rename a git submodule directory (other than going through the entire motion of deleting it and re-adding it with a new destination name). \nAnd while we are at it, why is it that I simply cannot do the following in the parent directory: git mv old-submodule-name new-submodule-name"}, {"role": "assistant", "content": "Git1.8.5 (October 2013) should simplify the process. Simply do a:\ngit mv A B\n\n\n\"git mv A B\", when moving a submodule A has been taught to relocate its working tree and to adjust the paths in the .gitmodules file.\n\n\nSee more in commit 0656781fadca1:\n\nCurrently using \"git mv\" on a submodule moves the submodule's work tree in that of the superproject. But the submodule's path setting in .gitmodules is left untouched, which is now inconsistent with the work tree and makes git commands that rely on the proper path -> name mapping (like status and diff) behave strangely.\nLet \"git mv\" help here by not only moving the submodule's work tree but also updating the \"submodule.<submodule name>.path\" setting from the .gitmodules file and stage both.\n This doesn't happen when no .gitmodules file is found and only issues a warning when it doesn't have a section for this submodule. This is because the user might just use plain gitlinks without the .gitmodules file or has already updated the path setting by hand before issuing the \"git mv\" command (in which case the warning reminds him that mv would have done that for him).\n Only when .gitmodules is found and contains merge conflicts the mv command will fail and tell the user to resolve the conflict before trying again.\n\n\ngit 2.9 (June 2016) will improve git mv for submodule:\nSee commit a127331 (19 Apr 2016) by Stefan Beller (stefanbeller).\n(Merged by Junio C Hamano -- gitster -- in commit 9cb50a3, 29 Apr 2016) \n\nmv: allow moving nested submodules\n\"git mv old new\" did not adjust the path for a submodule that lives as a subdirectory inside old/ directory correctly.\nsubmodules however need to update their link to the git directory as\n well as updates to the .gitmodules file."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git flow - create feature branch off another feature branch\nI having been using git flow for a while now. I am curious to learn about a specific use case. \nFor one of my projects I have a ticket for a new website feature. This ticket depends on many sub-tasks. I would like to create a feature branch for the main ticket, and then for each sub-task create a feature branch off of the parent feature branch.\nLet's assume I have a ticket PROJ-500 and I create a feature branch for it\ngit flow feature start PROJ-500\n\nThen I want to integrate tickets PROJ-501 through PROJ-515 into PROJ-500 before integrating the whole thing into develop. Is there a way for me to do something like\ngit flow feature start PROJ-511 -b PROJ-500\n\nThen over time these sub-tasks get completed and when their feature is finished, the branch is merged into PROJ-500. \ngit flow feature finish PROJ-511\n\nThe above command would merge PROJ-511 into PROJ-500\nAnd once all sub-tasks are completed then PROJ-500 will be finished and merged into develop.\nThis way the new website feature is integrate into develop as a single unit rather than piecemeal."}, {"role": "assistant", "content": "You can create a sub-feature branch via\ngit flow feature start PROJ-511 feature/PROJ-500\n\nBut you cannot use the GitFlow tool to merge the branch back into the main feature branch because if you do\ngit flow feature finish PROJ-511\n\nthe feature will be merged into develop. Ergo sub-features are not supported, you need to do it manually.\nAlternatives: The requirement is not new, though. There is an open issue as well as a fork project claiming to support finishing features into branches other than develop. I also found a pull request with an implementation of that feature. You might want to try that modification and see if you are happy with it.\n\nUpdate 2019-12-13: As user Matěj Kříž just mentioned in his comment, user Tony Chemit has written an answer here a few months after mine, pointing to gitflow-avh as an alternative to the original gitflow product. It supports sub-features out of the box with the syntax shown above. Some years have passed by and nowadays the AVH edition is part of the normal installation of Git for Windows, I just verified this on my local box and tested the sub-feature option. I.e. for Windows users it just works right after Git installation."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-commit"}, {"role": "assistant", "content": "Record changes to the repository"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-daemon - A really simple server for Git repositories"}, {"role": "assistant", "content": "ENVIRONMENT git daemon will set REMOTE_ADDR to the IP address of the client\nthat connected to it, if the IP address is available. REMOTE_ADDR will\nbe available in the environment of hooks called when\nservices are performed."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git error \"unable to locate xcodebuild\" after a fresh OS X Mavericks upgrade\nWhen I try to run previously working git commands, I get this:\ndyld: Symbol not found: _sqlite3_intarray_bind\n Referenced from: /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData\n Expected in: /opt/local/lib/libsqlite3.dylib\n in /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData\ngit: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!\ngit: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch\n\nHow can I fix this?"}, {"role": "assistant", "content": "This works for me sudo xcode-select --switch /Library/Developer/CommandLineTools/"}]} {"messages": [{"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": "NAME git-blame - Show what revision and author last modified each line of a file"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I rename a git remote?\nI currently have a git remote called heroku and I'd like to rename it to production.\n$ git remote -v\nheroku https://git.heroku.com/example.git (fetch)\nheroku https://git.heroku.com/example.git (push)"}, {"role": "assistant", "content": "$ git remote rename <old-name> <new-name>\n\nSo, for this example:\n$ git remote rename heroku production\n\nUseful docs here: https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories#renaming-a-remote-repository"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-http-fetch"}, {"role": "assistant", "content": "Download from a remote Git repository via HTTP"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git rebase --continue no changes\nI have two branches with two features: banch_1 and branch_2.\nbranch_2 uses feature from branch_1.\nI've made changes in the branch_1 and want to rebase branch_2 on branch_1 to get changes from branch_1 into branch_2.\nSo, I'm checking out on branch_2:\ngit checkout branch_2\n\nAnd trying to rebase on branch_1:\ngit rebase branch_1\n\nAfter that I get 'Merge conflict' for two files. So I run\ngit mergetool -t meld\n\nand resolving that conflicts, choosing changes from branch_1. \nI'm saving files and going to terminal, typing \ngit status and see that there is no changes in git index. Next I run git rebase --continue and getting \nNo changes - did you forget to use 'git add'? \n\nerror. But there is nothing to add!\nI type git log and see commit from branch_1 but there is no commit from branch_2.\nWhat I'm doing wrong?"}, {"role": "assistant", "content": "If I understand correctly, when you're getting the merge conflict, you're accepting all the changes from branch_1, meaning that that particular commit from branch_2 is irrelevant - any changes in that commit are identical to the incoming changes from branch_1.\nWhen git is saying\n\nNo changes - did you forget to use 'git add'?\n\nit's telling you that the commit you're trying to apply doesn't make any changes to the repo, and therefore there's no reason for it to exist.\nThe simple solution to that is git rebase --skip, which just says \"ignore this commit and move on\" as suggested in @C-Otto's comment. This will skip the commit you're currently dealing with, and move on to subsequent ones.\nYou might also find it easier to use interactive rebasing (git rebase -i), which first presents you with a list of the commits it will apply, and gives you various options for what to do with each individual commit. In this case, if you identify a commit that is no longer relevant, you can skip it up-front, so you'll never see the conflict in the first place."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-worktree"}, {"role": "assistant", "content": "Manage multiple working trees"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Change Github account in Android Studio\n\nI have used one Github account to push an android project to Github from Android Studio. Now I have created another account on Github and want to push my another android project to this new account. But I am not able to find any option to change the Github account in Android Studio. It keeps pushing from the previous account and hence results in this error:\n\nremote: Permission to new_username/repository_name.git denied to old_username.\nfatal: unable to access 'https://github.com/new_username/repository_name.git/': The requested URL returned error: 403\n\nI am using Android Studio 1.2.2 on Windows OS."}, {"role": "assistant", "content": "Go to: \nSetting --> Version Control --> GitHub --> Change you username."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "In Git, what is the difference between origin/master vs origin master?\nI know, origin is a term for the remote repository and master is the branch there.\nI am purposely omitting the \"context\" here and I am hoping that the answer should not depend upon the context. So in git command lines, what is the difference between origin/master and origin master. Is there a non-ambiguous way to understand when to use origin/master and when I should use origin master?"}, {"role": "assistant", "content": "(Note: When this question was originally posted, \"master\" was the default name for branches in Git. Since \"main\" is now the default name, this answer has been updated to use \"main\", in the hope that this will be more natural for people new to Git.)\nThere are actually three things here: origin main is two separate things, and origin/main is one thing. Three things total.\nTwo branches:\n\nmain is a local branch\norigin/main is a remote tracking branch (which is a local copy of the branch named \"main\" on the remote named \"origin\")\n\nOne remote:\n\norigin is a remote\n\nIs origin/main remote?\nThe origin/main branch is local! Any time you fetch from origin, origin/main will get updated. However, origin/main can be out of date, and it's even possible that main no longer exists on origin. You can use the --prune option (-p) with git fetch to automatically delete remote tracking branches if the branch they track is deleted.\nThe origin/main branch is not a reference or pointer to the main branch on origin. It is a local copy.\nExample: pull in two steps\nSince origin/main is a branch, you can merge it. Here's a pull in two steps:\nStep one, fetch main from the remote origin. The main branch on origin will be fetched and the local copy will be named origin/main.\ngit fetch origin main\n\nThen you merge origin/main into main.\ngit merge origin/main\n\nThen you can push your new changes in main back to origin:\ngit push origin main\n\nMore examples\nYou can fetch multiple branches by name...\ngit fetch origin main stable oldstable\n\nYou can merge multiple branches...\ngit merge origin/main hotfix-2275 hotfix-2276 hotfix-2290\n\nCan you use a different name?\nMy local branch doesn't have to be named main if I don't want to. It doesn't have to have the same name as the remote branch! Let's say I want to name my branch alice, but still have it track origin/main:\nI can do that easily enough:\ngit checkout -b alice --track origin/main\n\nYou can see that the local branch is named alice, but the remote branch is named main, and the local copy is origin/main. This is totally OK! It might be a bit confusing, but maybe you already have a different branch named main, and you need to switch to a different branch to work on a different change."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I copy the content of a branch to a new local branch?\nI have worked on a local branch and also pushed the changes to remote.\nI want to revert the changes on that branch and do something else on it, but I don't want to lose the work completely. I was thinking of something like create a new branch locally and copy the old branch there, then I can revert the changes and continue working on the old branch.\nIs there a better way than this maybe?"}, {"role": "assistant", "content": "git checkout old_branch\ngit branch new_branch\n\nThis will give you a new branch \"new_branch\" with the same state as \"old_branch\".\nThis command can be combined to the following:\ngit checkout -b new_branch old_branch"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to push code to Github hiding the API keys?\n\nI want to push some codes to my GitHub Repository. These codes are in different languages like Javascript, Java, Python etc. Some of those codes contain some private API key that I don't want to publish.\nIs there any way to hide the keys automatically.? Should I remove it from my code manually.? \nThere are many projects that I want to push to GitHub. So, manual removal is not a good option."}, {"role": "assistant", "content": "You should consider using .env files and read the keys from the environmental variables. How to do so depends on the language and tools you use (for node.js, php, etc.).\nYou can exclude .env file from commits by adding .env to the .gitignore. You can also upload an example configuration .env.example with dummy data or blanks to show the schema your application requires."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Visual Studio Code cannot detect installed Git\nVisual Studio Code reports \"It look like git is not installed on your system.\" when I try to switch to the git view. I know I have git installed and used by other Git clients. I guess if I reinstall Git following Visual Studio Code's instruction (\"install it with Chocolatey or download it from git-scm.com\"), it probably can fix the problem, but I don't want to mess up the existing Git clients on my system. Is there a reliable way to configure Visual Studio Code so it can find existing git installation?"}, {"role": "assistant", "content": "Now you can configure Visual Studio Code (version 0.10.2, check for older versions) to use an existing Git installation.\nJust add the path to the Git executable in your Visual Studio Code settings (menu File → Preferences → Settings) like this:\n{\n // Is Git enabled\n \"git.enabled\": true,\n\n // Path to the Git executable\n \"git.path\": \"C:\\\\path\\\\to\\\\git.exe\"\n\n // Other settings\n}"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git rebase after previous git merge\nI have the following situation:\n\nI created a clone(Y) from a main repository(X), because there were many people working on Y we didn't do any rebase but only merges. When we want to deliver(push) Y to X we would like to do a rebase in order to have things nice and clean\n\nThe problem is that when doing rebase we are asked to do all the merges that we already did in the previous merge steps. Is there a solution to this, beside the one that means actually re-doing the merges? \nI expected it to be pretty straightforward since we already solved the conflicting merges."}, {"role": "assistant", "content": "git merge --squash is now my preferred way of rebasing after a large amount of work and many merges (see this answer). If the branch you're working on is called my-branch and you want to rebase from main then just do the following:\ngit checkout my-branch\ngit branch -m my-branch-old # rename from my-branch to my-brand-old\ngit checkout main\ngit checkout -b my-branch # make new my-branch branch\ngit merge --squash my-branch-old # squash and merge changes from old branch \ngit commit"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitworkflows - An overview of recommended workflows with Git"}, {"role": "assistant", "content": "SEPARATE CHANGES As a general rule, you should try to split your changes into small\nlogical steps, and commit each of them. They should be consistent,\nworking independently of any later commits, pass the test suite, etc.\nThis makes the review process much easier, and the history much more\nuseful for later inspection and analysis, for example with git-blame and git-bisect . To achieve this, try to split your work into small steps from the very\nbeginning. It is always easier to squash a few commits together than\nto split one big commit into several. Don’t be afraid of making too\nsmall or imperfect steps along the way. You can always go back later\nand edit the commits with git rebase --interactive before you\npublish them. You can use git stash push --keep-index to run the\ntest suite independent of other uncommitted changes; see the EXAMPLES\nsection of git-stash ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-pack-objects"}, {"role": "assistant", "content": "Create a packed archive of objects"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-add - Add file contents to the index --pathspec-from-file=<file>"}, {"role": "assistant", "content": "Pathspec is passed in <file> instead of commandline args. If <file> is exactly - then standard input is used. Pathspec\nelements are separated by LF or CR/LF. Pathspec elements can be\nquoted as explained for the configuration variable core.quotePath (see git-config ). See also --pathspec-file-nul and\nglobal --literal-pathspecs ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Does Bitbucket and GitHub have Work In Progress [WIP] pull requests feature?\n\nI know there is a Work In Progress (WIP) merge requests feature on GitLab. \nI find it very useful when you already want to show the code to your peers and want to prevent 'Accept' button to be pressed. Is there a similar feature on Bitbucket? Tried to use [WIP] prefix on Pull Request name in Bitbucket, but it did not work out. \nI am also curious if GitHub has a similar feature too or you still need a plugin for your browser?"}, {"role": "assistant", "content": "Bitbucket does not provide WIP PR status yet, but the enhancement is WIP 😊. You can vote here for this feature: https://bitbucket.org/site/master/issues/12503/add-additional-pull-request-states"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %Cred"}, {"role": "assistant", "content": "switch color to red"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-push - Update remote refs along with associated objects flag"}, {"role": "assistant", "content": "A single character indicating the status of the ref: (space) for a successfully pushed fast-forward; + for a successful forced update; - for a successfully deleted ref; * for a successfully pushed new ref; ! for a ref that was rejected or failed to push; and = for a ref that was up to date and did not need pushing."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can I store the .git folder outside the files I want tracked?\nI have an unusual idea to use git as a backup system. So let's say I have a directory ./backup/myfiles and I want to back that up using git. To keep things clean I don't want to have a .git directory in the myfiles folder, so I thought I could create ./backup/git_repos/myfiles. From looking at the git docs, I've tried doing this:\n$ cd backup/myfiles\n$ mkdir ../git_repos/myfiles\n$ git --git-dir=../git_repos/myfiles init\nInitialized empty Git repository in backup/git_repos/myfiles/\n$ git --git-dir=\"../git_repos/myfiles/\" add foo\nfatal: pathspec 'foo' did not match any files\n\nYou can see the error message I get there. What am I doing wrong?"}, {"role": "assistant", "content": "You just need to ensure that the repository knows where the work tree is and vice versa.\nTo let the repository know where the work tree is, set the configuration value core.worktree. To let the work tree know where it's git directory is, add a file named .git (not a folder!) and add a line like\ngitdir: /path/to/repo.git\n\nSince git 1.7.5 the init command learned an extra option for this.\nYou can initialize a new separate repository with\ngit init --separate-git-dir /path/to/repo.git\n\nThis will initialize the git repository in the separate directory and add the .git file in the current directory, which is the working directory of the new repository.\nPreviously to 1.7.5 you had to use slightly different parameters and add the .git file yourself.\nTo initialize a separate repository the following command links the work-tree with the repository:\ngit --git-dir=/path/to/repo.git --work-tree=. init && echo \"gitdir: /path/to/repo.git\" > .git\n\nYour current directory will be the working tree and git will use the repository at /path/to/repo.git. The init command will automatically set the core.worktree value as specified with the --git-dir parameter.\nYou could even add an alias for this:\n[alias]\n initexternal = !\"f() { git --work-tree=. --git-dir=\\\"$1\\\" init && echo \\\"gitdir: $1\\\" >> .git; }; f\"\n\nUse git version control on a read-only working directory\nWith the knowledge above, you can even set up git version control for an working directory without having write permissions. If you either use --git-dir on every git command or execute every command from within the repository (instead of the working directory), you can leave out the .git file and therefore do not need to create any files within the working directory. See also Leos answer"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-merge - Join two or more development histories together -S[<keyid>] --gpg-sign[=<keyid>] --no-gpg-sign"}, {"role": "assistant", "content": "GPG-sign the resulting merge commit. The keyid argument is\noptional and defaults to the committer identity; if specified,\nit must be stuck to the option without a space. --no-gpg-sign is useful to countermand both commit.gpgSign configuration variable,\nand earlier --gpg-sign ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Prevent local changes getting pushed in Git\nI have cloned a repository and the master branch in my repo is tracking origin/master. I created a work branch and changed some config files specific to my dev machine to make the app work.\nMy normal workflow will be to switch to master branch, merge changes made in work branch and push those changes upstream. The problem is that i don't want my specific chnages to get pushed. When i merge my work branch into master those changes are merged also. \nThe only solution I've found so far is not to commit those changes in work but that's not a satisfactory solution."}, {"role": "assistant", "content": "If you want to prevent committing (therefore also pushing) these local config files, you could use git update-index --assume-unchanged. Files marked with this flag will be assumed to never change (until you reset the flag with --no-assume-unchanged)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Automatically access git submodules via ssh or https\nQuestion:\nIs there a way to automatically checkout git submodules via the same method (ssh or https) as the main repository?\nBackground:\nWe have a non-public gitlab repository (main) that has a submodule (utils) which is also hosted as a non-public gitlab repository on the same server. Those repositories can be accessed either via ssh or https:\n\n[email protected]:my/path/repo.git\nhttps://gitlabserver.com/my/path/repo.git\n\nBoth variants obviously require different forms of authentication and depending on the client computer and the user, one or the other is preferred. \nFor the top level repository (main) that is not an issue, as anyone can choose the method he or she prefers, but for the sub module this depends on the .gitmodules file and hence is (initially) the same for all.\nNow instead of everyone having to adapt the .gitmodules file to whatever they prefer and make sure they don't accidentally commit those changes, it would be nice, if there was a way to just specify the server and repo path and git chooses either the same method that is used for the main repo, or something that can be set in gitconfig."}, {"role": "assistant", "content": "I finally solved this problem by specifying the submodules url as a relative path:\nSo lets say your main git repository can be reached \n\neither via https://gitlabserver.com/my/path/main.git\nor via [email protected]:my/path/main.git\n\nAnd the .gitmodules file looks like this:\n[submodule \"utils\"] \n path = libs/utils \n url = https://gitlabserver.com/my/path/utils.git\n\nThat would mean that even when you check out the main application via ssh, the submodule utils would still be accessed via https.\nHowever, you can replace the absolute path with a relative one like this: \n[submodule \"utils\"] \n path = libs/utils \n url = ../utils.git\n\nand from now on use \n\neither git clone --recursive https://gitlabserver.com/my/path/main.git\nor git clone --recursive [email protected]:my/path/main.git\n\nto get the whole repository structure which ever way you want. Obviously that doesn't work for cases where the relative ssh and the https paths are not the same, but at least for gitlab hosted repositories this is the case.\nThis is also handy if you (for whatever reason) mirror your repository structure at two different remote sites."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-branch - List, create, or delete branches -D"}, {"role": "assistant", "content": "Shortcut for --delete --force ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I log in using the Git terminal?\nI am trying to sign in using the Git command line, so that I can push my changes to a repository I have. I usually use a different account to the one I'm trying to use right now, and pushing works fine on there. The terminal is the one integrated into Visual Studio Code, and it is Git Bash.\nWhat I want to do is sign into this different account and then push from that account. I remember at one point there was a popup with a login box on it. How would I get this to show up again?\nSo far, I have tried using the commands:\ngit config user.name my-name\ngit config user.email my-email\nWhich don't appear to have asked for any credentials. Upon Googling (just now) it appears that they are used just to set my commit username.\nSo how do I log in from the Git command line? I've been stuck on this for ages and I feel like there's probably a really simple solution.\nAny help would be greatly appreciated."}, {"role": "assistant", "content": "Just entering your user in the command line won't work for newer versions of git. To sign in to GitHub, you'll need to download GitHub CLI, then do gh auth login"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options core.precomposeUnicode"}, {"role": "assistant", "content": "This option is only used by Mac OS implementation of Git.\nWhen core.precomposeUnicode=true, Git reverts the unicode decomposition\nof filenames done by Mac OS. This is useful when sharing a repository\nbetween Mac OS and Linux or Windows.\n(Git for Windows 1.7.10 or higher is needed, or Git under cygwin 1.7).\nWhen false, file names are handled fully transparent by Git,\nwhich is backward compatible with older versions of Git."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-unpack-objects"}, {"role": "assistant", "content": "Unpack objects from a packed archive"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Find size of Git repository\nWhat's a simple way to find the size of my Git repository?\nAnd I don't mean du -h on the root directory of my repository. I have a lot of ignored files, so that size would be different from my total repository size. I essentially want to know how much data would be transferred upon cloning my repository."}, {"role": "assistant", "content": "Note that, since git 1.8.3 (April, 22d 2013):\n\n\"git count-objects\" learned \"--human-readable\" aka \"-H\" option to show various large numbers in Ki/Mi/GiB scaled as necessary.\n\nThat could be combined with the -v option mentioned by Jack Morrison in his answer.\ngit gc\ngit count-objects -vH\n\n(git gc is important, as mentioned by A-B-B's answer)\nPlus (still git 1.8.3), the output is more complete:\n\n\"git count-objects -v\" learned to report leftover temporary packfiles and other garbage in the object store."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-add - Add file contents to the index patch"}, {"role": "assistant", "content": "This lets you choose one path out of a status like selection.\nAfter choosing the path, it presents the diff between the index\nand the working tree file and asks you if you want to stage\nthe change of each hunk. You can select one of the following\noptions and type return: y - stage this hunk\nn - do not stage this hunk\nq - quit; do not stage this hunk or any of the remaining ones\na - stage this hunk and all later hunks in the file\nd - do not stage this hunk or any of the later hunks in the file\ng - select a hunk to go to\n/ - search for a hunk matching the given regex\nj - leave this hunk undecided, see next undecided hunk\nJ - leave this hunk undecided, see next hunk\nk - leave this hunk undecided, see previous undecided hunk\nK - leave this hunk undecided, see previous hunk\ns - split the current hunk into smaller hunks\ne - manually edit the current hunk\np - print the current hunk\n? - print help After deciding the fate for all hunks, if there is any hunk\nthat was chosen, the index is updated with the selected hunks. You can omit having to type return here, by setting the configuration\nvariable interactive.singleKey to true ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-hash-object - Compute object ID and optionally create an object from a file --no-filters"}, {"role": "assistant", "content": "Hash the contents as is, ignoring any input filter that would\nhave been chosen by the attributes mechanism, including the end-of-line\nconversion. If the file is read from standard input then this\nis always implied, unless the --path option is given."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can I run HTML files directly from GitHub, instead of just viewing their source?\n\nIf I have a .html file in a GitHub repository, e.g. for running a a set of JavaScript tests, is there any way I can view that page directly—thus running the tests?\nFor example, could I somehow actually see the test results that would be produced by the jQuery test suite, without downloading or cloning the repo to my local drive and running them there?\nI know this would basically put GitHub in the static content hosting business, but then again, they just have to change their mime-type from text/plain to text/html."}, {"role": "assistant", "content": "You might want to use raw.githack.com. It supports GitHub, Bitbucket, Gitlab and GitHub gists.\nGitHub\nBefore:\nhttps://raw.githubusercontent.com/[user]/[repository]/[branch]/[filename.ext]\nIn your case .html extension\nAfter:\nDevelopment (throttled)\nhttps://raw.githack.com/[user]/[repository]/[branch]/[filename.ext]\nProduction (CDN)\nhttps://rawcdn.githack.com/[user]/[repository]/[branch]/[filename.ext]\nIn your case .html extension\n\nraw.githack.com also supports other services:\nBitbucket\nBefore:\nhttps://bitbucket.org/[user]/[repository]/raw/[branch]/[filename.ext]\nAfter:\nDevelopment (throttled)\nhttps://bb.githack.com/[user]/[repository]/raw/[branch]/[filename.ext]\nProduction (CDN)\nhttps://bbcdn.githack.com/[user]/[repository]/raw/[branch]/[filename.ext]\nGitLab\nBefore:\nhttps://gitlab.com/[user]/[repository]/raw/[branch]/[filename.ext]\nAfter:\nDevelopment (throttled)\nhttps://gl.githack.com/[user]/[repository]/raw/[branch]/[filename.ext]\nProduction (CDN)\nhttps://glcdn.githack.com/[user]/[repository]/raw/[branch]/[filename.ext]\nGitHub gists\nBefore:\nhttps://gist.githubusercontent.com/[user]/[gist]/raw/[revision]/[filename.ext]\nAfter:\nDevelopment (throttled)\nhttps://gist.githack.com/[user]/[gist]/raw/[revision]/[filename.ext]\nProduction (CDN)\nhttps://gistcdn.githack.com/[user]/[gist]/raw/[revision]/[filename.ext]\n\nUpdate: rawgit was discontinued"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git push from Visual Studio Code: \"No anonymous write access. Authentication failed\"\nI was following a tutorial from GitHub itself. I am following the one that teaches you to work from Visual Studio Code.\nI was trying to push something from Visual Studio Code and after quite some time I get the following error:\nremote: No anonymous write access.\nfatal: Authentication failed for ....\n\nNow I am pushing something to my personal account. I tried to google (but again I am new to this so I don't fully understand all the terminology) and what I could find are issues with two-factor authentication (but that is off in my case) and Windows credentials (but I checked and I do not have any Git in my Windows credentials).\nSo I am at a loss. What else I could try or check?"}, {"role": "assistant", "content": "A simpler method is to use personal access tokens at GitHub. This feature can be set up by going to your GitHub account → Settings → Developer settings → Personal access tokens → Generate a personal access token. Make your access control selections, generate, then copy and save your new token. After this, go to your Git project directory and this enter in the terminal:\ngit remote set-url origin https://[email protected]/your_user/your_project.git\nFrom now on you can easily do git push from the terminal or Visual Studio Code."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options status.displayCommentPrefix"}, {"role": "assistant", "content": "If set to true, git-status will insert a comment\nprefix before each output line (starting with core.commentChar , i.e. # by default). This was the\nbehavior of git-status in Git 1.8.4 and previous.\nDefaults to false."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options merge.renames"}, {"role": "assistant", "content": "Whether Git detects renames. If set to \"false\", rename detection\nis disabled. If set to \"true\", basic rename detection is enabled.\nDefaults to the value of diff.renames."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options pager.<cmd>"}, {"role": "assistant", "content": "If the value is boolean, turns on or off pagination of the\noutput of a particular Git subcommand when writing to a tty.\nOtherwise, turns on pagination for the subcommand using the\npager specified by the value of pager.<cmd> . If --paginate or --no-pager is specified on the command line, it takes\nprecedence over this option. To disable pagination for all\ncommands, set core.pager or GIT_PAGER to cat ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is git-rerere and how does it work?\nAs I understood, it is useful for the synchronization of projects through the saving of conflict resolution information, but it is not entirely clear to me how to use and configure it.\nI want to configure for my continuous integration (CI) environment. Is it recommended do this?\nPlease don't mark a duplicate with this other question: Are there any downsides to enabling git rerere?. Because my doubt isn't related to \"So is there any downside to enabling rerere?. What potential problems can it cause that would not otherwise occur?\""}, {"role": "assistant", "content": "What is git rerere?\nAs the documentation notes, rerere stands for reuse recorded resolution.\nThat doesn't really explain what it is, though. It's worth adding first, here, that git rerere itself—the command—is not something you have to run. It has just six subcommands: clear, forget, diff, status, remaining, and gc. None of these record or reuse a resolution—in fact, git rerere clear and git rerere forget <path> just discard some recorded resolutions. The gc command is similar, but refers to ones that are old, rather than current ones.\nMost of the work happens from the setting of rerere.enabled (which makes Git run git rerere, with no subcommand, for you, at the appropriate times). You can run git rerere with no subcommands yourself, but this doesn't really do anything important since Git will do that on its own.\ngit config rerere.enabled true\nOnce you have set rerere.enabled, when Git does a merge—any merge, including those from git am and git rebase and git cherry-pick and so on, not just those from git merge itself—and hits a conflict, Git will:\n\nrecord (once the merge-as-a-verb hits them) the conflicting diff hunks;\nwait for you to resolve them manually;\nrecord (at git commit time) what you did to resolve them.\n\nThere's a step missing here, which is why this is numbered starting at 2. Step 1 is:\n\ncheck for previous recorded resolutions for these conflicts: if they exist, use them to resolve those conflicts automatically.\n\nIf the recorded resolutions completely resolve the conflicts, steps 2-4 become redundant. Git may still run them all (I'm not sure that it does) to update the timestamps on the recorded resolutions.\nSummary\nOnce you set rerere.enabled, it's the act of merging itself that both creates the conflicts and (because it automatically runs git rerere with no arguments) records them and then tries to re-use any existing recorded resolutions. It's the act of committing itself that records the final resolutions (because Git automatically runs git rerere again for you). So it is all automatic—you just need to make sure, by running your own git diff commands, that your previous re-used resolutions are correct. If not, just fix them files, add, and commit as usual, and Git will replace the recorded resolutions with the new ones.\nNote that you must still git add and git commit! You should always inspect the merge results (and/or run tests)—though you should do this always, regardless of your rerere.enabled setting.\nAs VonC points out in a comment, if you have existing merge conflict resolutions you did not record earlier, you can \"train\" the rerere database on those resolutions. There is a contributed script in the Git source to do this; it's also available on-line."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git-flow and master with multiple parallel release-branches\nWe are trying to adopt the successful Git branching model implemented by git-flow. Now, we are working on at least two release-branches, one for the latest stable release and one for the next (\"preview\") release. What I don't understand is why all releases seems to \"linearized\" to the master and tagged there. Why not tag the releases in their release branches? Why the master at all? Or why a develop branch and not use master for it?"}, {"role": "assistant", "content": "In the git-flow model, your \"latest released\" version actually maps to the master, while your \"preview release\" maps to a git-flow release branch. It is forked from develop and finally merged into master when the actual release happens. Then this will become your \"latest release\" and you will usually fix only bugs for that release, using git-flow hotfixbranches. In this way, your master always represents the most stable state of your latest released version.\nIf you want to fix bugs for older releases or do any other develop there, you will fork a support branch from the appropriate commit in master (you will have all versions ever created there). support branches are still experimental (according to the docs) and are not well documented. But as you can see from the command line help:\nusage: git flow support [list] [-v]\n git flow support start [-F] <version> <base>\n\nthese branches are just started and not intended to be merged back to master nor develop. This is usually fine, as fixes to \"ancient\" releases or features requested by customers to be implemented in \"ancient\" releases can't or should not go back into master. If you still think, you want to port a fix to your main development line (represented by master and develop), just start a hotfix, cherry-pick your changes and finish the hotfix."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I export a Git log to a text file?\nI want to export the log of all commits in a repository to a text file. Is there a way to do this?"}, {"role": "assistant", "content": "You'll just need to disable the pager.\ngit --no-pager log > log.txt\n\nIf you want to format it to look nicer, you can use parameters of git log."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme:\nI understand this is an xcode warning/error, however, it happens when I try to run gitk --all from the command line.\nYuFei-Zhus-MacBook-Pro:test phil88530$ gitk --all\n2012-08-02 21:14:49.246 Wish[33464:707] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: \n2012-08-02 21:14:49.252 Wish[33464:707] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: \n2012-08-02 21:14:49.293 Wish[33464:707] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: \n2012-08-02 21:14:49.295 Wish[33464:707] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: \n2012-08-02 21:14:49.474 Wish[33464:707] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: \n2012-08-02 21:14:49.476 Wish[33464:707] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: \n2012-08-02 21:14:50.731 Wish[33464:707] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: \n2012-08-02 21:14:50.734 Wish[33464:707] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: \nYuFei-Zhus-MacBook-Pro:test phil88530$ \n\nI just replaced a new disk and did a fresh install of osx and updated to mountain lion, installed x11 and xcode. Any suggestions why this happens?"}, {"role": "assistant", "content": "$ alias gitk='gitk 2>/dev/null'\n\nI have same problem here. This is quick tip until someone answers this solution."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Adding private git repo via cPanel\n\nI'm trying to add a private git repo onto cPanel but have ran into permission issues and not sure where I'm going wrong\nI have generated the SSH keys in cPanel at the 'SSH Access' section. I then added the key onto the private repo in git at the 'Deploy keys' section.\nBut when I try to clone the repo on cPanel I get the error:\n\nError: “/usr/local/cpanel/3rdparty/bin/git” reported error code “128”\n when it ended: Permission denied (publickey). fatal: Could not read\n from remote repository. Please make sure you have the correct access\n rights and the repository exists.\n\nI'm trying to clone with SSH [email protected]:myusername/myrepo.git\nHave I done something wrong or missed a step?"}, {"role": "assistant", "content": "CLONE GITHUB REPOSITORY TO CPANEL STEPS\nsteps 1. Cpanel -> SSH Access -> Generate New Key(without enter pasword)->after generated key go to under public key-> manage-> authorize (make authoize) -> back, now view/download-> copy key\nStep 2. Go Github-> https://github.com// -> Settings(repository setting) ->Deploy Keys (rights side)-> add deploy key (give title,and add key)-> done\nStep 3. Go to Cpanel -> Git™ Version Control -> clone url : [email protected]:/<private_repository_name>.git\n [email protected]:<user_name>/<repository_name>.git\n\n-> give_repository_path \n-> give_ repository_name\n-> create\nStep 4. manage repository from list-> Manage -> pull or deploy from Github -> Click on Update from Remote: works perfectly(any files edit or delete you fetch/pull from GitHub now)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "/bin/sh: eval: line 98: bash: not found\n\ni got this\n/bin/sh: eval: line 98: bash: not found \n\nmessage by executing the gitlabb .yml file.\nI added in the before script section the line\n- apk update && apk add openssh\n\nwhich was not helpful.\nbefore_script:\n - apk update && apk add openssh\n - bash docker_install.sh > /dev/null\n\nstages:\n - build\n - deploy\n - loadtest-local\n\nbuild:\n stage: build\n script:\n - echo \"building my application in ubuntu container...\"\n\ndeploy:\n stage: deploy\n image: php:7.4\n script: \n - phpunit Unittest.php\n \n\nloadtest-local:\n image: \n name: loadimpact/k6:latest\n entrypoint: [\"\"]\n stage: loadtest-local\n script:\n - k6 run ./loadtests/performance-test.js\n - k6 run ./loadtests/inttest.js\n\nHow can I resolve this issue?"}, {"role": "assistant", "content": "That means one of the images used in your pipeline doesn't have bash installed.\nTry changing the line on before_script to ./docker_install.sh > /dev/null (make sure the docker_install.sh has execution permissions set beforehand)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitLab runner unable to clone repository via http\n\nI have the latest docker image of GitLab running in a test environment and I'm running into an issue with the GitLab runner. It's unable to clone via the HTTP link, yielding the following message:\nRunning on runner-bd27e50b-project-1-concurrent-0 via machine...\nCloning repository...\nCloning into '/builds/my/awesome-project'...\nfatal: unable to access 'http://gitlab-ci-token:[email protected]/my/awesome-project.git/': \n Failed to connect to 127.0.0.1 port 80: Connection refused\n\nERROR: Build failed with: exit code 1\n\nI ran gitlab-runner with the --debug flag and used the exact address it was trying (with the token in-tact) and I could clone the repository just fine. I'm at a loss as to why the service is unable to clone the repository. The runner executor is configured as 'docker' as well. Maybe there is some port mapping issue into that container?"}, {"role": "assistant", "content": "I hypothesized the issue might have something to do with registering the runner as a docker container causing the localhost address not to resolve to the right machine (where I'm starting the runner); in this case it probably resolves to the container instead. Using the host's IP on the docker proxy interface (172.17.0.1 for me) or using the host's real address instead of \"localhost\" when registering the runner fixes the problem.\nEdit: Here is a bit more detail on the problem as I understand it and a solution. The docker instance that's loaded up is like a (very) lightweight virtual machine. Docker configures a virtual network interface which you'll see if you run ifconfig from your host machine:\nuser@pc:~> ifconfig\ndocker0 Link encap:Ethernet HWaddr XXXX\n inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0\n ...\n\nThis is the IP address of the host machine on that interface. So, if you want the runner to be able to connect to the service that's running on that host machine, you can't point it to localhost/127.0.0.1 because, coming from inside the runner's instance, that will route to the runner's \"VM\", but GitLab is not running inside that runner \"VM\", it's on the host, so the runner is unable to communicate with GitLab.\nThe solution is to register the runner to point to the host's virtual address on the docker interface (http://172.17.0.1/ci for me), or to use the host's public IP or a domain name if you have one and it's accessible publicly. Just don't send it to localhost or 127.0.0.1 because, to the runner, that points to its \"VM\", not your GitLab instance."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options GIT_CONFIG_NOSYSTEM"}, {"role": "assistant", "content": "Whether to skip reading settings from the system-wide\n$(prefix)/etc/gitconfig file. See git for details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Gitlab with non-standard SSH port (on VM with Iptable forwarding)\n\nMy gitlab is on a virtual machine on a host server. I reach the VM with a non-standard SSH port (i.e. 766) which an iptable rule then forward from host:766 to vm:22.\nSo when I create a new repo, the instruction to add a remote provide a mal-formed URL (as it doesn't use the 766 port. For instance, the web interface give me this:\nMalformed\n\ngit remote add origin [email protected]:group/project.git\n\nInstead of an URL containing :766/ before the group.\nWellformed\n\ngit remote add origin [email protected]:766/group/project.git \n\nSo it time I create a repo, I have to do the modification manually, same for my collaborator. \nHow can I fix that ?"}, {"role": "assistant", "content": "In Omnibus-packaged versions you can modify that property in the /etc/gitlab/gitlab.rb file:\ngitlab_rails['gitlab_shell_ssh_port'] = 766\n\nThen, you'll need to reconfigure GitLab:\n# gitlab-ctl reconfigure\n\nYour URIs will then be correctly displayed as ssh://[email protected]:766/group/project.git in the web interface."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": ".gitignore does not work - file is still being tracked [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nIgnore files that have already been committed to a Git repository [duplicate]\n\n (21 answers)\n \n\nClosed 10 years ago.\n\n\n\nI've a .gitignore file at the root of my repo. The .gitignore file has the following pattern to exclude the compiled Python files and that is the only line in the file.\n*.pyc\n\nNow when i do the following at the root of the repo.\ngit init\ngit add . \ngit status \n\nIt shows that it still tracks the .pyc file and tries to add it as new file. See output below.\nSystem info: Windows 7, cygwin \nNote: This issue is CLEARLY not about the ignored file being already tracked. I also tried both DOS- and Unix-style line endings on the .gitignore file. \ngit status gives:\n# On branch master\n#\n# Initial commit\n#\n# Changes to be committed:\n# (use \"git rm --cached <file>...\" to unstage)\n#\n# new file: .gitignore\n# new file: feedapp/__init__.py\n# new file: feedapp/appconfig.py\n# new file: feedapp/appconfig.pyc\n\nHow do I troubleshoot this further?"}, {"role": "assistant", "content": ".gitignore only applies to untracked files. If you are tracking a .pyc then .gitignore won't apply. Remove the .pyc with git rm and next time you do a git status it (and any others) won't show up in the list of untracked file and nor will it be automatically added.\n\nOtherwise if you need to ignore a file already under version control, update the index to ignore changes to files already under version control:\ngit update-index --assume-unchanged <files>\n\nFor more information please see git-update-index(1) Manual Page, the related answer to .gitignore file not ignoring and the related answer to question (GIT: Ignoring Version-Controlled Files)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Are pull requests part of Git, or a feature of tools like GitHub, Gerrit and Atlassian Stash?\n\nPull requests seem to be the common way to do code review with Git. However, it is not clear whether this term means the same when using the built-in git request-pull, or a different tool.\nAre pull requests an intrinsic function of Git, or is it a common term for tools like GitHub, Gerrit or Atlassian Stash?\nIs the discussion and \"result\" of the code review stored in the Git commit history or in a separate database?"}, {"role": "assistant", "content": "Pull requests are a simple concept that originated when Git was created but has been taken to different levels since.\nThe essence is that you do not have push rights to the repository you want to contribute on, so instead you fork the repository, making your private copy (a clone already does this btw.) and you contribute to that one instead. And then you ask a maintainer of the original repository to pull in your changes. So you are essentially submitting a patch.\nNow as I said, there are different ways to do this, but it all boils down to requesting a maintainer to pull in your changes, hence the name. The original purpose Git was created for is the Linux kernel, and they have been developing using mailing lists forever. So for them, a pull request is actually sending a patch per email; those patches are actually commit objects prepended by some normal email communication stuff—Git has tools to generate this.\ngit request-pull is a similar tool to generate a message asking for a pull request. But in this case, it’s closer to the pull idea. While patches can just be applied, requests created by request-pull actually tell the maintainer to pull the changes from a different remote repository.\nThe Git book has this example:\n$ git request-pull origin/master myfork\nThe following changes since commit 1edee6b1d61823a2de3b09c160d7080b8d1b3a40:\n John Smith (1):\n added a new function\n\nare available in the git repository at:\n\n git://githost/simplegit.git featureA\n\nJessica Smith (2):\n add limit to log function\n change log output to 30 from 25\n\n lib/simplegit.rb | 10 +++++++++-\n 1 files changed, 9 insertions(+), 1 deletions(-)\n\nSo it’s really just a utility to generate messages to execute the underlying concept.\nOther source code hosters like GitHub do this similarly as well. When you create a pull request on GitHub, you just create an issue which contains further information where the commits are the maintainer can pull. Of course, it all being on a single website, they can interlink everything a bit more and provide those one-click merge buttons for example.\nBut the basic concept is still the same: Requesting a maintainer to pull in some changes you have made. The only difference is the way this request is communicated with."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch ignore-space-change ignore-all-space ignore-space-at-eol ignore-cr-at-eol"}, {"role": "assistant", "content": "Treats lines with the indicated type of whitespace change as\nunchanged for the sake of a three-way merge. Whitespace\nchanges mixed with other changes to a line are not ignored.\nSee also git-diff -b , -w , --ignore-space-at-eol , and --ignore-cr-at-eol . If their version only introduces whitespace changes to a line, our version is used; If our version introduces whitespace changes but their version includes a substantial change, their version is used; Otherwise, the merge proceeds in the usual way."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-submodule - Initialize, update or inspect submodules --[no-]recommend-shallow"}, {"role": "assistant", "content": "This option is only valid for the update command.\nThe initial clone of a submodule will use the recommended submodule.<name>.shallow as provided by the .gitmodules file\nby default. To ignore the suggestions use --no-recommend-shallow ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Cleanup git master branch and move some commit to new branch?\nI have a clone of a repo on Github in which I created a new feature for upstream. The problem is, I did that in my master branch which also contains other stuff I pulled in from other clones. That totally broke my ability to create a reasonable pull request.\nSo I want to do the following:\n\nRestore my master branch to be exactly the same as upstream master.\nCreate a new branch.\nMove some of my old commits to the new branch.\nCreate a pull request off the branch.\n\nAnd, in the future, I will do all my work in branches and create pull requests off them while leaving my master branch alone and just merging down whatever comes in from upstream.\nMy questions are:\n\nIs this a reasonable approach?\nHow would I actually do steps 1 and 3?"}, {"role": "assistant", "content": "Make a new branch to hold stuff\n$ git branch old_master\n\nSend to remote for backup (just incase)\n$ git checkout old_master\n$ git push origin old_master\n\nReset local master to the commit before you started modifying stuff\n$ git checkout master\n$ git reset --hard 037hadh527bn\n\nMerge in changes from upstream master\n$ git pull upstream master\n\nNow DELETE master on remote repo\nOn github this won't work without first going into the admin section for the fork and setting the default branch to something other than master temporarily as they try and protect you from blowing stuff away.\n$ git push origin :master\n\nAnd recreate it\n$ git push origin master\n\nOn github you should now set the default branch back to master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "install gitlab on Windows with Docker\n\nI searched a lot and found that GitLab Community Edition is not installed on Windows so now I want to install it with the help of Docker. I do not know that is it possible and how I can do it ?"}, {"role": "assistant", "content": "You need to install Docker for Windows.\n\nShare drive for Docker (in Docker's settings > shared drives). For example, drive E:\n\n\n\n\nThen, you need to create 3 directories on drive E: (e:\\gitlab\\config, e:\\gitlab\\logs, e:\\gitlab\\data)\n\nFrom the Command Prompt, run:\ndocker run --detach --hostname gitlab.yourdomain.ru \n--publish 443:443 --publish 80:80 --publish 22:22 --name gitlab \n--restart always --volume e:\\gitlab\\config:/etc/gitlab \n--volume e:\\gitlab\\logs:/var/log/gitlab \n--volume e:\\gitlab\\data:/var/opt/gitlab gitlab/gitlab-ce:latest\n\n\n\nThat's it! You have now successfully run GitLab image."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs -C[<n>] --find-copies[=<n>]"}, {"role": "assistant", "content": "Detect copies as well as renames. See also --find-copies-harder .\nIf n is specified, it has the same meaning as for -M<n> ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git, don't show me *.pyc in the list of untracked files!\nWhen doing:\n>git status\n\nIt shows a big list of .pyc files under \"untracked files\". I don't want it to show these, as it adds noise.\nIn other words, how do I make git ignore .pyc files all the time and for all projects?\nEDIT\nI'm not asking for a way to spread my ignored files to other people, I really just mean \"for all projects\", meaning I don't want to configure each new project to ignore .pyc files.\nUPDATE\nI should add that I'm working on windows, and my git is msysgit\n\nPatterns which a user wants git to ignore in all situations (e.g., backup or temporary files generated by the user's editor of choice) generally go into a file specified by core.excludesfile in the user's ~/.gitconfig.\n\nIs .gitconfig a file or a folder? I don't have such a thing in my home directory (C:\\users\\<myusername>\\)\nUPDATE2\nThanks everybody for the responses, \nI solved the issues by using:\n>git config --global core.excludesfile c:\\git\\ignore_files.txt\n\nand putting *.pyc in c:\\git\\ignore_files.txt"}, {"role": "assistant", "content": "As mentioned in gitignore, git has 3 ignore files:\n\n\nPatterns which should be version-controlled and distributed to other repositories via clone (i.e., files that all developers will want to ignore) should go into a .gitignore file. \n\n\n(that takes care of all time: if one clones your repo, it will get the .gitignore file)\n\n\nPatterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user's workflow) should go into the $GIT_DIR/info/exclude file. \n\n\n(not interesting in your case)\n\n\nPatterns which a user wants git to ignore in all situations (e.g., backup or temporary files generated by the user's editor of choice) generally go into a file specified by core.excludesfile in the user's ~/.gitconfig.\n\n\n(takes cares of all projects, but not all time since it is not replicated when one clones your repo.)\n\"All time for all projects\" would means for instance a custom shell for creating new git projects, with a custom .gitignore as first file part of the first commit..."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitHub - List commits by author\n\nIs there any way on GitHub to list all commits made by a single author, in the browser (neither locally, e.g. via git log, nor via the API)?\nClicking on a user name in the list of commits (Commit History) simply leads to that user's profile page. Examining the GitHub UI and searching (Google, StackOverflow) does not reveal a way to do this."}, {"role": "assistant", "content": "If the author has a GitHub account, just click the author's username from anywhere in the commit history, and the commits you can see will be filtered down to those by that author:\n\nYou can also click the 'n commits' link below their name on the repo's \"contributors\" page:\n\nAlternatively, you can directly append ?author=<theusername> or ?author=<emailaddress> to the URL. For example, https://github.com/jquery/jquery/commits/master?author=dmethvin or https://github.com/jquery/jquery/commits/[email protected] both give me:\n\nFor authors without a GitHub account, only filtering by email address will work, and you will need to manually add ?author=<emailaddress> to the URL - the author's name will not be clickable from the commits list.\n\nYou can also get the list of commits by a particular author from the command line using\ngit log --author=[your git name]\n\nExample:\ngit log --author=Prem"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --word-diff[=<mode>]"}, {"role": "assistant", "content": "Show a word diff, using the <mode> to delimit changed words.\nBy default, words are delimited by whitespace; see --word-diff-regex below. The <mode> defaults to plain , and\nmust be one of: color Highlight changed words using only colors. Implies --color . plain Show words as [-removed-] and {+added+} . Makes no\nattempts to escape the delimiters if they appear in the input,\nso the output may be ambiguous. porcelain Use a special line-based format intended for script\nconsumption. Added/removed/unchanged runs are printed in the\nusual unified diff format, starting with a + / - /` `\ncharacter at the beginning of the line and extending to the\nend of the line. Newlines in the input are represented by a\ntilde ~ on a line of its own. none Disable word diff again. Note that despite the name of the first mode, color is used to\nhighlight the changed parts in all modes if enabled."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Where does Git store files?\nI just ran the following commands on my Ruby on Rails project:\ngit init\ngit add .\ngit commit -a -m 'Initial'\n\nWhere does Git actually store this repository? (It's on my local machine, but where?)"}, {"role": "assistant", "content": "It will create your repository in the .git folder in the current directory."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Cannot push to gitlab from xcode 7\n\nOne unhappy side effect of upgrading to Xcode 7 is that I can no longer push to my Gitlab repo. I have been pushing and pulling from my project without problem for the last two years, so I suspect Xcode 7 is doing something different. I have verified my u/p for Gitlab by logging into and out of it via the web interface. When I go to Xcode > Preferences > Accounts, select the gitlab project, I see that the username and password are in there (just like they have been for 2 years) and I verify that they are correct.\nIt is worth noting that I can successfully post from Terminal, however, I do not wish to use Terminal to push my code to Gitlab on a regular basis. Has anyone else encountered this problem since upgrading? Any suggestions as to a fix?\nThe specific error I am getting is \"Authentication failed because the user name or password was incorrect.\" This error appears in the Accounts dialog, as well as after trying to perform a push to the gitlab repo."}, {"role": "assistant", "content": "So this one was quite a bear to wrestle, and to be honest, I am not sure what the root cause of this error was, but the way I resolved it was this:\n\nRemoved my old ssh key from GitLab\nCreated a new ssh key on the command line, then added it to GitLab\nRemoved the GitLab repo from Xcode > Preferences > Accounts\nRe-added the GitLab account, using the SSH Keys Option (which it was before as well, this is not new)\nClosed Xcode\nBlew away the working directory of the project\nOpened Xcode, then chose Source Control > Checkout\nProvided the SSH address (which you can get from GitLab within your project folder)\nMade a minor change to the project for the purposes of testing the ability to Push\nPushed to GitLab via Xcode Source Control > Push\n\nVoila! Worked. This was definitely the nuclear option but it got me working again. I firmly believe that upgrading Xcode to 7 screwed something up. If anyone else has this problem I hope this resolves it!"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-add - Add file contents to the index --"}, {"role": "assistant", "content": "This option can be used to separate command-line options from\nthe list of files, (useful when filenames might be mistaken\nfor command-line options)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-interpret-trailers"}, {"role": "assistant", "content": "Add or parse structured information in commit messages"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-gc - Cleanup unnecessary files and optimize the local repository gc.recentObjectsHook"}, {"role": "assistant", "content": "When considering whether or not to remove an object (either when\ngenerating a cruft pack or storing unreachable objects as\nloose), use the shell to execute the specified command(s).\nInterpret their output as object IDs which Git will consider as\n\"recent\", regardless of their age. By treating their mtimes as\n\"now\", any objects (and their descendants) mentioned in the\noutput will be kept regardless of their true age. Output must contain exactly one hex object ID per line, and nothing\nelse. Objects which cannot be found in the repository are ignored.\nMultiple hooks are supported, but all must exit successfully, else the\noperation (either generating a cruft pack or unpacking unreachable\nobjects) will be halted."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I see incoming commits in git? [duplicate]\nThis question already has answers here:\n \n \n\n\n\nClosed 11 years ago.\n\n\n\n\nPossible Duplicate:\nUsing Git how do I find modified files between local and remote \n\nHow can I see incoming commits in git? Or even better, see what I just git fetch/git pulled?\nEdit: To clarify the question: someone tells me that, to get some fixes, I should pull from their repository. My goal is to see what their changes are before I accept them. git pull automatically merges, which is not what I want. git fetch will grab them without merging, but I'm unsure how to view what exactly I just pulled in. The reason for the original phrasing is that I normally use Mercurial, where the command would be hg incoming <repo name here>—a command for which git seems to lack an analog."}, {"role": "assistant", "content": "incoming isn't quite a direct mapping in git because you can (and I often do) have multiple repos you're pulling from, and each repo has multiple branches.\nIf there were an equivalent of hg's incoming command, it'd probably be this:\ngit fetch && git log ..origin/master\n\nThat is, \"go grab all of the stuff from the upstream, and then compare my current branch against the upstream master branch.\"\nSimilarly, outgoing would be this:\ngit fetch && git log origin/master..\n\nIn practice, I just type those manually (even though I created an alias for one of them) because it's easy to have lots of local branches tracking and being tracked by lots of remote branches and have no trouble keeping it together."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order --count"}, {"role": "assistant", "content": "Print a number stating how many commits would have been\nlisted, and suppress all other output. When used together\nwith --left-right , instead print the counts for left and\nright commits, separated by a tab. When used together with --cherry-mark , omit patch equivalent commits from these\ncounts and print the count for equivalent commits separated\nby a tab."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options status.submoduleSummary"}, {"role": "assistant", "content": "Defaults to false.\nIf this is set to a non-zero number or true (identical to -1 or an\nunlimited number), the submodule summary will be enabled and a\nsummary of commits for modified submodules will be shown (see\n--summary-limit option of git-submodule ). Please note\nthat the summary output command will be suppressed for all\nsubmodules when diff.ignoreSubmodules is set to all or only\nfor those submodules where submodule.<name>.ignore=all . The only\nexception to that rule is that status and commit will show staged\nsubmodule changes. To\nalso view the summary for ignored submodules you can either use\nthe --ignore-submodules=dirty command-line option or the git\nsubmodule summary command, which shows a similar output but does\nnot honor these settings."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-ls-files - Show information about files in the index and the working tree objectmode"}, {"role": "assistant", "content": "The mode of the file which is recorded in the index."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is it possible to get a list of merges into a branch from the Github website OR API?\n\nIn our workflow, no \"direct\" commits are made into the master branch. The master branch only receives merges from Pull Requests.\nWe can think of each merge then as a new feature added to the master branch.\nSo I'd like to get a list of merges into master, as a way to visualize the blocks of features added into the product over time.\nDoes git or the Github API expose this query, or do I have to parse raw commits?"}, {"role": "assistant", "content": "I use the following script:\ngit log main --first-parent --merges \\\n --pretty=format:\"%h %<(10,trunc)%aN %C(white)%<(15)%ar%Creset %C(red bold)%<(15)%D%Creset %s\"\n\nExplaining each argument:\n\nmain: the name of your main branch. Can be omitted, in which case the current branch will be used.\n--first-parent: skips commits from merged branches. This removes the entries where someone merged master into their branches.\n--merges: shows only \"merge commits\" (commits with more than 1 parent). Omit this argument if you want to see direct commits to your main branch.\n--pretty-format: applies the following formatting:\n\n%h: the commit short hash;\n%<(10,trunc)%aN: author name, truncated at 10 chars;\n%<(15)%ar: the relative commit time, padded to 15 chars;\n%<(15)%D: the tag names, also padded to 15 chars;\n%s: first line of the commit message.\n\n\n\nThe result is pretty satisfying:"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Clone contents of a GitHub repository (without the folder itself)\nI'd like to git clone the contents of a repository I have on GitHub. When I git clone (git@github:me/name.git...) I get a folder called name/ and inside name I have my contents... How do I get JUST the contents?"}, {"role": "assistant", "content": "If the current directory is empty, you can do that with:\ngit clone [email protected]:me/name.git .\n\n(Note the . at the end to specify the current directory.) Of course, this also creates the .git directory in your current folder, not just the source code from your project.\nThis optional [directory] parameter is documented in the git clone manual page, which points out that cloning into an existing directory is only allowed if that directory is empty."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is there a standard naming convention for git tags? [closed]\nClosed. This question is opinion-based. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it can be answered with facts and citations by editing this post.\n\n\nClosed 9 years ago.\n\n\nThe community reviewed whether to reopen this question 10 months ago and left it closed:\n\nOriginal close reason(s) were not resolved\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI've seen a lot of projects using v1.2.3 as the naming convention for tags in git. I've also seen some use 1.2.3. Is there an officially endorsed style, or are there any good arguments for using either?"}, {"role": "assistant", "content": "Version 1.0.0 of Semantic Versioning, by Tom Preston-Werner of GitHub fame, had a sub-specification addressing this:\n\nTagging Specification (SemVerTag)\nThis sub-specification SHOULD be used if you use a version control system (Git, Mercurial,\nSVN, etc) to store your code. Using this system allows automated tools to inspect your\npackage and determine SemVer compliance and released versions.\n\nWhen tagging releases in a version control system, the tag for a version MUST be\n\"vX.Y.Z\" e.g. \"v3.1.0\".\n\n\nHowever, after discussion this was removed, and is no longer present in the latest version of the SemVer spec (2.0.0 at the time of writing). A later discussion thread in the same place went into greater depth, and resulted in a new Is \"v1.2.3\" a semantic version? being added to the FAQ in SemVer's master branch, although at the time of writing (over 2 years later) this change is still not present in the officially released spec."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker"}, {"role": "assistant", "content": "SYNOPSIS git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\n [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n [-p|--paginate|-P|--no-pager] [--no-replace-objects] [--bare]\n [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n [--config-env=<name>=<envvar>] <command> [<args>]"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to reset to my last commit in Android Studio\nI commit changes to git from Android Studio, after that I have made some changes in my project that gives me errors, and now I want to get back that commited version that has no errors.\nHow can I do that?"}, {"role": "assistant", "content": "To undo your latest changes and reset to the most recent commit:\nGo to VCS -> Git -> Reset HEAD..\nChange Reset type to hard to remove those changes.\nIt will look like this. You can validate the reset before you do it if you want.\n\n\nWhat happens if you click Validate?\nA screen will pop up that shows the changes that were made in the commit you are about to reset to. You can view diffs per file that show what the commit changed in that file. It's more or less equal to what $ git show in a terminal would do.\nContrary to what I assumed before, it does not show what files will be affected when you perform the reset."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "TortoiseGit vs Git Extensions\nWhat are the benefits and disadvantage of using either Git Extensions or TortoiseGit on a Windows Based OS?"}, {"role": "assistant", "content": "I don't know GitExtensions, but I can share my experience with TortoiseGit (alluded to by marc_s's comment):\nPros:\n\nExcellent integration with Windows (it's a shell extension)\nNearly the same UI as TortoiseSVN (if you already used TortoiseSVN, you know what to expect).\n\nCons:\n\nYou will have a hard time understanding how to use git.\n\nThe problem with TortoiseGit is that people who worked with TortoiseSVN will think everything will (or should) work exactly like in SVN... and end up never really understanding how to work with git. As a personal experience, the company I work migrated from SVN to git after 2 years, and every single developer that used TortoiseGit ended up not really knowing what they are doing and sometimes screwing up their local repositories. In the end, they dropped TortoiseGit and spend time learning git \"the hard way\" (shell, msysGit on Windows) and everyone has been happy since then.\nConclusion: Just use msysGit directly and properly learn git. You will avoid many headaches in the future."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to upload projects on gitlab by user?\n\nWe are using Gitlab (7.5.3).\nI created a Repository, but I want to upload my project to it.\nI've looked on the repository page for an upload button of some kind but I haven't seen anything of the sort.\nI've looked at the links provided so far but I'm still getting nowhere. They mention command line, is that Windows command line ?\nI am able to upload through Git GUI, how to upload without Git GUI?\nAnd when I login to user account through putty ,it shows\nlogin as: root\n[email protected]'s password:\nLast login: Tue May 26 12:20:10 2015 from 192.168.1.12\n![grep: write error]\n\nDoes anyone knows how we can solve these issue?"}, {"role": "assistant", "content": "If you have Git GUI, you probably also have Git Bash which provide command line support for git inside Windows. \nYou can use this Git Bash to upload your project. For this, you just need some git command, and you don't have to log in the Gitlab's server (I supposed it's why you tried). This command are provided by Gitlab when you create a new project and want to upload it.\nFirst open Git Bash. Then : \ncd c:\\Users\\Me\\..\\my_project\\ # Go to your project directory in Windows\ngit init # Initialize this directory as a git repo\ngit remote add origin git@your_gitlab_server_ip:your_username/your_project_name.git\ngit push -u origin master` # Send your code to your Gitlab instance\n\nIt's also a good idead to provide to git some info about you. This infos will be displayed by Gitlab : \ngit config --global user.name \"Your Name\"\ngit config --global user.email \"your_name@your_mail.com\"\n\nRemember that with Gitlab the only interaction between your git's repo and Gitlab should happend through the git command, and not with login to this server."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitLab git user password\n\nI have just installed GitLab.\nI created a project called project-x.\nI have created few users and assigned it to the project.\nNow I tried to clone:\n git clone [email protected]:project-x.git\n\nIt prompted me for a password.\nWhat password should I use?"}, {"role": "assistant", "content": "Not strictly related to the current scenario. Sometimes when you are prompted for password, it is because you added the wrong* origin format (HTTPS instead of SSH)\nHTTP(S) protocol is commonly used for public repos with strong username+pass\nSSH authentication is more common for internal projects where you can authenticate with a ssh-key-file and simple pass-phrase\nGitLab users are more likely to use the SSH protocol\nView your remote info with \ngit remote -v\n\nIf you see HTTP(S) address, this is the command to change it to SSH:\ngit remote set-url origin [email protected]_domain.com/example-project.git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-ls-tree - List the contents of a tree object objecttype"}, {"role": "assistant", "content": "The type of the object ( commit , blob or tree )."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to set up a code review using Gitlab?\n\nHow does one set up a code review using Gitlab? I see it listed as a feature on the Gitlab website, but I can't seem to find instructions on how to set one up (For that matter, any link to a Gitlab user manual would be most appreciated). \nSome of my searching has indicated that 'Merge Requests' are the way to go... but I'm finding them limiting. An issued merge request shows all of the commits between one branch and the other. I seem to only be able to view diffs generated for each individual commit. For example, let's say I have a file I want to review. It is a new file but I've submitted changes to it over 10 commits on a dev branch. If I issue a merge request for that dev branch from integration I see 10 commits each of which show the incremental changes made to the file... I want to review the entire thing. It is new! \nAm I barking up the wrong tree here? Is there an actual code-review tool I can use in GitLab, or are merge requests the way to go, and if they are am I using them incorrectly? what's the best way to set up a proper code review here?"}, {"role": "assistant", "content": "Note: since GitLab 6.4, side-by-side diff view is available: see \"pull request 5308\".\n(July 2013)There is no possibility yet to comment on each line though, only at the file level.\nDaniel Sokolowski mentions in the comments that Per line comments are now supported (09/2014):\n\nYour team members can comment on the merge request in general or on specific lines with line comments.\n\nThat still can help for code review activity.\n\n\n6 years later, for GitLab 13.1 (June 2020):\n\nMerge Request Reviews moved to Core\n\n\nOriginally introduced in GitLab 11.4 as a GitLab Premium feature, Merge Request Reviews allow merge request reviewers to:\n\nsubmit multiple comments at once,\ncutting down on notification noise for the merge request author, and\nallowing for a more cohesive and streamlined review process.\n\n\n\n\nSince its introduction, we’ve re-evaluated its place in our buyer-based pricing model and as part of 13.1 we’re excited to announce this feature has now moved to GitLab Core.\n\nSee Documentation and Issue\n\nWith GitLab 13.9 (February 2021), you also have:\n\nRequest a follow-up review from a Reviewer\nMerge request authors receive feedback from reviewers. Often, this feedback needs to be re-reviewed to make sure all issues have been appropriately addressed. As the author of the contribution, you need to communicate the need for a follow-up to your reviewer.\nFor reviewers who have already reviewed a merge request, you can now request a re-review. This request triggers a To-Do item and email notification to alert the user that you need a follow-up review of your contribution.\n\nSee Documentation and Issue.\n\n\nWith GitLab 13.11 (April 2021)\n\nAdd standalone comments to merge request reviews\nWhen you’re reviewing changes, you may want to summarize your feedback, or comment on something unrelated to the specific changes. Reviews in GitLab only allowed commenting on the changes or replying to existing comments, which meant that other kinds of comments had to be made after submitting the review.\nAs part of your review process, you can now submit a general comment along with your replies or change-specific comments. General comments make it simple to provide feedback to the author and use quick actions to update items across the merge request.\nThanks to Lee Tickett for the contribution!\n\nSee Documentation and Issue."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What are the big differences between TFVC (TFS Version Control) and Git for source control when using Visual Studio 2013?\nThere are tons of questions and answers about Git versus TFVC Source Control, but no current answers cover the integration of Git into Team Foundation Server/Service that I can find.\nI'm starting green pasture development using a wide variety of languages (C#, C++, PHP, Javascript, MySSQL) using Visual Studio 2013. In the future, there will be some iOS development. I'm very familiar with SVN, VSS and TFVC for source control. However, I have never used Git. I prefer TFS for process management/agile development... It's not perfect, but it integrates well into Visual Studio.\nSo, to help me decide between these two systems...\nWhat are the big differences between TFVC and Git for source control when using Visual Studio 2013?\n\nIs the only benefit in my case a local repository (not saying that it's insignificant) and iOS development support?\nIs the only drawback to Git the command line interface (some would argue that's not a drawback ;-P).\nHave you experienced in the Visual Studio 2013 GUI for Git? Is that enough to support basic branching/merging without the command line interface?\nIs there a detailed start-up guide for Git that shows Git being used with Visual Studio 2013? Microsoft has a video for integrating an existing Git repository into Visual Studio 2013, but I'm looking for a start from scratch with Git and VS 2013.\n\nI am not looking for a book here, but just a few bullet points and maybe some relevant links from folks that have used both TFVC and Git."}, {"role": "assistant", "content": "Update\nSince 2013 a lot has happened:\n\nMicrosoft has added ssh support to Team Foundation Server, Azure DevOps Server and Azure DevOps.\nVisual studio 2019 16.8+ ships with a completely revamped git client.\nMicrosoft has moved its own internal products off of TFVC. Windows and Office sources now live in Git in Azure DevOps.\nMicrosoft has bought GitHub which is now the main focus for DevOps related offerings, many people who contributed to Azure DevOps have moved to GitHub as a consequence.\nVirtual File System for Git & Git Large File System have resolved many of the reasons why people stayed on TFVC.\nAzure DevOps has a built-in migration tool which can convert (part of) your TFVC history into a git repo.\n\nIn all this time very little happened for TFVC:\n\nYAML pipelines have yet to receive TFVC support 2 years after their introduction (I'm not expecting these at all).\nTeam Explorer is now called \"Legacy\" in Visual Studio\nTFVC has been declared feature complete\nTFVC support for Eclipse and Visual Studio Code and Linux/Mac are officially deprecated/end-of-life.\n\nIt's pretty clear who has won: Git.\n\n\nWhat are the big differences between TFS and Git for source control when using VS 2013?\n\nMSDN has a very extensive page on all the features and differences between Team Foundation Version Control and Git.\n\nIs the only benefit in my case a local repository (not saying that's insignificant) and IoS development support?\n\nNo, there's lot more, but they're often advanced scenario's of Git. Local Repo, offline support and full local fidelity on history is incredibly powerful, you get that out of the box with Visual Studio. There's a few other features that are great too! The ability to branch and merge from one repository to another is very powerful. I recommend you look up the Pro Git book for those. Git in TFS is just another git server, it has pretty much all features that the standard Git has.\nThe ability to rewrite history before merging allows you to remove or combine a number of smaller change sets, so that the history is cleaner and easier to read as a human.\n\nIs the only drawback to Git the command line interface (some would argue that's not a drawback ;-P).\n\nTFVC has a command line too, people just don't use it. For people that want to use Git and never do much more than TFVC does, they probably won't really need to leave the UI, they won't get a lot of the cool features though...\nThere might be a few other drawbacks, mostly due to the fact that it's different than what people are used to. It's not too hard to shoot yourself in the foot if you don't take the time to learn what git does when you do things. Things like Rebase and Squash are really powerful and create a very clean history, but it can leave people with the problem that they can't merge anymore if used incorrectly. TFS has the ability to put some security settings to take away the rights to make very stupid decisions on a git repository.\nA very cool add-on for Git users on Windows is PoSHGit. it provides command autocompletion on the Powershell commandline.\n\nHave you experienced in the VS 2013 GUI for Git? Is that enough to support basic branching/merging without the command line interface?\n\nIt has all you need for basic operations. But you do need to be able to visualize the different branches to know what's going on. Since the Git server and local repo are just Git, any git client can help you out here. SourceTree is an option here. The Git for Windows client is another.\nFor standard operations, check-in, check-out, merge, branch (or push, pull, fetch, commit, merge) the UI works just fine.\n\nIs there a detailed start-up guide for Git that shows Git being used with VS 2013? MS has a video for integrating an existing Git repo into VS 2013, but I'm looking for a start from scratch with Git and VS 2013?\n\nStarting with Git is available in a number of places... These are a few options:\n\nMSDN Docs: Use Visual Studio with Git\nMSDN Blog: Getting started with Git\nThere's a Hands-on lab for the Brian Keller VM.\nMicrosoft Virtual Academy: Using Git with Visual Studio 2013 Jump Start\nPluralsight: Git for Visual Studio Developers\n\nOther good reads:\n\nMSDN Docs: Git vs TFVC Summary\nSyncfusion: Git succinctly\nSetting the Visual Studio Merge tool as default for Git\nusing PoshGit from within Visual Studio\nApress: Pro Git\nALM Ranger Git for TFVC users guidance.\n\nAnd a few tools worth installing:\n\nPoshGit\nSourceTree\nGit Diff Margin"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-apply - Apply a patch to files and/or to the index --index"}, {"role": "assistant", "content": "Apply the patch to both the index and the working tree (or\nmerely check that it would apply cleanly to both if --check is\nin effect). Note that --index expects index entries and\nworking tree copies for relevant paths to be identical (their\ncontents and metadata such as file mode must match), and will\nraise an error if they are not, even if the patch would apply\ncleanly to both the index and the working tree in isolation."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Moving a git repository\nThis question may be dumb, but I've been wondering it for a while. It's about git repositories, but I assume it's the same for local repositories for other DVCS'.\nLets say my project is like this when it starts:\n\nProject\n\n.git\nall the other folders in the project\n\n\nSo that's how it would work when you set it up right?\nLets say I move the Project folder somewhere else, would I have to change anything? Or is all the repository stuff in the .git folder relative only to the Project folder ignoring the whole file tree above Project.\nI'm pretty sure moving Project wouldn't matter but I just wanted to make sure."}, {"role": "assistant", "content": "I've found that submodules are not relative in git.\nSo, if you want to move a project that contains submodules, you have to edit the .git file in the submodule, as well as the \"worktree\" attribute in the submodule config file, which is stored in the parent's .git/modules/MODULENAME/config file."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-mktag"}, {"role": "assistant", "content": "Creates a tag object with extra validation"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is the difference between 'git format-patch and 'git diff'?\nI don't see a difference between the output of 'git format-patch' and 'git diff', is there any? And won't I be able to use 'git diff' to produce a patch and then apply it using git apply?\nMy problem is that I have changes added to the index, but apparently git format-patch only accepts commits, so if I can use the output of diff, then I can use this command to produce a patch for the changes in the index:\ngit diff --cached > index.patch"}, {"role": "assistant", "content": "A patch created with git format-patch will also include some meta-information about the commit (committer, date, commit message, ...) and will contains diff of binary data. Everything will be formatted as a mail, so that it can be easily sent. The person that receive it can then recreate the corresponding commit with git am and all meta-data will be intact. It can also be applied with git apply as it is a super-set of a simple diff.\nA patch crated with git diff will be a simple diff with context (think diff -u). It can also be applied with git apply but the meta-data will not be recreated (as they are not present).\nIn summary, git format-patch is useful to transmit a commit, while git diff is useful to get a diff between two trees."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Add another user to project owners in Github\n\nHow can I add another user to project such that the project shows under his name in his Github account too? I don't want a fork. Two users should host same project in their accounts and this should allow both users to collaborate in the project."}, {"role": "assistant", "content": "You can only add collaborators to your repository. It cannot be \"co-owned\".\nBut when someone is added as collaborator to a repo, that repo will be listed in the Your Repositories section ( but the username will be the owner username only)\nThe only way for doing what you want is to fork the repo and collaborate through pull requests.\nNote that you can create an organization ( https://github.com/account/organizations/new ) and achieve a bit of what you want."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_PROGRESS_DELAY"}, {"role": "assistant", "content": "A number controlling how many seconds to delay before showing\noptional progress indicators. Defaults to 2."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options merge.verifySignatures"}, {"role": "assistant", "content": "If true, this is equivalent to the --verify-signatures command\nline option. See git-merge for details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-archive - Create an archive of files from a named tree git archive --format=tar --prefix=git-1.4.0/ v1.4.0^{tree} | gzip >git-1.4.0.tar.gz"}, {"role": "assistant", "content": "Create a compressed tarball for v1.4.0 release, but without a\nglobal extended pax header."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options i18n.commitEncoding"}, {"role": "assistant", "content": "Character encoding the commit messages are stored in; Git itself\ndoes not care per se, but this information is necessary e.g. when\nimporting commits from emails or in the gitk graphical history\nbrowser (and possibly in other places in the future or in other\nporcelains). See e.g. git-mailinfo . Defaults to utf-8 ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_REDIRECT_STDIN GIT_REDIRECT_STDOUT GIT_REDIRECT_STDERR"}, {"role": "assistant", "content": "Windows-only: allow redirecting the standard input/output/error\nhandles to paths specified by the environment variables. This is\nparticularly useful in multi-threaded applications where the\ncanonical way to pass standard handles via CreateProcess() is\nnot an option because it would require the handles to be marked\ninheritable (and consequently every spawned process would\ninherit them, possibly blocking regular Git operations). The\nprimary intended use case is to use named pipes for communication\n(e.g. \\\\.\\pipe\\my-git-stdin-123 ). Two special values are supported: off will simply close the\ncorresponding standard handle, and if GIT_REDIRECT_STDERR is 2>&1 , standard error will be redirected to the same handle as\nstandard output."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options context"}, {"role": "assistant", "content": "non-matching text in context lines (when using -A , -B , or -C )"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to embed code from repo in github markdown?\n\nIs there a way of embedding the content of a file (from the projects repo) in Githubs markdown?\nI have a code sample and want to embed it in the projects readme."}, {"role": "assistant", "content": "@Petros's answer is (still) correct, however I got annoyed enough with this that I've created a tool to automate the copying and keep your readme synchronised with the source - https://github.com/zakhenry/embedme\nExample usage from the accepted answer\nInsert a comment into the code fence\n```rb\n# path/to/your/file.rb\n```\n\nRun npx embedme README.md (this assumes you have Nodejs installed)\nThe README will be written in-place, with the content of the file following your comment\n```rb\n# path/to/your/file.rb\nclass MyClass\nend\n```\n\nNote that as the comment is still there, you can happily re-run npx embedme README.md again and it won't make any change.\nIf you have CI, you can also run npx embedme --verify README.md which will return 1 if it detects a diff (this would mean that the source was updated without the readme being updated)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "why should I delete feature branches when merged to master\nMost of the git workflows I've seen suggest to delete a branch after it's been merged into master. For example, this gitflow suggests the following:\n# Incorporating a finished feature on develop \n$ git checkout develop\nSwitched to branch 'develop'\n$ git merge --no-ff myfeature\nUpdating ea1b82a..05e9557\n(Summary of changes)\n$ git branch -d myfeature\nDeleted branch myfeature (was 05e9557).\n$ git push origin develop\n\nWhy should I delete the branch? I'm also curious what to do when later a bug is discovered that was introduced by the feature - should I create the branch with the same name again, fix bug there, merge into master and again delete the branch?"}, {"role": "assistant", "content": "Something important to realize is Git branches are nothing more than a label pointing to a commit. Branching in Git is literally branching. Here's what a repository looks like if feature branched off master when master was a commit B.\nA - B - C - F - H [master]\n \\\n D - E - G - I[feature]\n\nSee? Actual branch. When you git merge feature into master, you get this.\nA - B - C - F - H - J [master]\n \\ /\n D - E - G - I [feature]\n\nAnd once you git branch -d feature the branch history remains!\nA - B - C - F - H - J [master]\n \\ /\n D - E - G - I\n\nJ has the parents H and I. J cannot exist without them, it's baked into how Git works. I cannot exist without G. G cannot exist without E. And so on. The branch must remain\nJ is a merge commit which will typically contain the name of the branch being merged. Its like any other commit, so you can even add more information to it, like a link back to your issue tracker.\ngit merge --no-ff is used to prevent Git from doing a \"fast forward\" and losing the branch history. This happens if no work has been done on master since the branch was created. A fast-forward looks like this.\nA - B[master]- D - E - G - I [feature]\n\ngit checkout master\ngit merge feature\n\nA - B - D - E - G - I [feature] [master]\n\nSince master is a direct ancestor of feature, no merge is required. Git can just move the master label. Your branch history is lost, it looks like D, E, G and I were all done as individual commits on master. git merge --no-ff tells Git to never do this, to always perform a merge.\nIn the future, when it's noticed a bug was introduced in G, anyone browsing the repository can see it was done as part of the branch, look ahead to find the merge commit, and get information about the branch from there.\nEven so, why delete the branch? Two reasons. First, it will clutter up your list of branches with dead branches.\nSecond, and more important, it prevents you from reusing the branch. Branching and merging are complicated. Single use, short lived feature branches simplify the process by ensuring you only ever merge the branch back into master once. This eliminates many technical and management problems. When you merge a branch, it is done. If you need to fix a problem introduced in that branch, just treat it as a bug in master and make a new branch to fix it.\nUnfortunately, git log lies to the user and presents a linear representation of history that is not linear. To fix this, use git log --graph --decorate. This will draw lines as in my examples above, and show you any branches and tags on each commit. You'll get a much truer view of the repository.\nIf you're on a Mac, GitX will visualize the repository for you. gitk is the generic version."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-format-patch - Prepare patches for e-mail submission -w --ignore-all-space"}, {"role": "assistant", "content": "Ignore whitespace when comparing lines. This ignores\ndifferences even if one line has whitespace where the other\nline has none."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Error \"'git' is not recognized as an internal or external command\"\nI have an installation of Git for Windows, but when I try to use the git command in Command Prompt, I get the following error:\n'git' is not recognized as an internal or external command,\noperable program or batch file. \n\nHow do I fix this problem?"}, {"role": "assistant", "content": "You may not have set your PATH correctly to point at your Git installation.\nYou need to add the following paths to PATH:\n\nC:\\Program Files\\Git\\bin\\\nC:\\Program Files\\Git\\cmd\\\n\nAnd check that these paths are correct. You may have Git installed on a different drive, or under Program Files (x86). Correct the paths if necessary.\n\nModifying PATH on Windows 10:\n\nIn the Start Menu or taskbar search, search for \"environment variable\".\nSelect \"Edit the system environment variables\".\nClick the \"Environment Variables\" button at the bottom.\nDouble-click the \"Path\" entry under \"System variables\".\nWith the \"New\" button in the PATH editor, add C:\\Program Files\\Git\\bin\\ and C:\\Program Files\\Git\\cmd\\ to the end of the list.\nClose and re-open your console.\n\nModifying PATH on Windows 7:\n\nRight-click \"Computer\" on the Desktop or Start Menu.\nSelect \"Properties\".\nOn the very far left, click the \"Advanced system settings\" link.\nClick the \"Environment Variables\" button at the bottom.\nDouble-click the \"Path\" entry under \"System variables\".\nAt the end of \"Variable value\", insert a ; if there is not already one, and then C:\\Program Files\\Git\\bin\\;C:\\Program Files\\Git\\cmd\\. Do not put a space between ; and the entry.\nClose and re-open your console.\n\nIf these instructions weren't helpful, feel free to look at some others:\n\nHow to set the path and environment variables in Windows (Computer Hope)\nHow to edit your system PATH for easy command line access in Windows (How-To Geek)\nHow to set Path environment variables in Windows 10 (Addictive Tips)\nWhat are PATH and other environment variables, and how can I set or use them? (Super User)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Rebase a single Git commit\nIs there a way to rebase a single commit from a branch onto another branch? \nI have this branch structure:\n-- -- -- -- -- (Master)\n \\\n -- -- -- -- -- XX (Feature-branch)\n\nAll I want to do is to rebase the last commit of Feature-branch onto master and rollback Feature-branch one commit. \n-- -- -- -- -- XX (Master)\n \\\n -- -- -- -- -- (Feature-branch)\n\nHow do I do that?"}, {"role": "assistant", "content": "You can cherry-pick XX to master.\ngit checkout master\ngit cherry-pick <commit ID of XX>\n\nAnd remove the last commit from the feature branch with git reset.\ngit checkout Feature-branch\ngit reset --hard HEAD^"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-remote - Manage set of tracked repositories set-branches"}, {"role": "assistant", "content": "Changes the list of branches tracked by the named remote.\nThis can be used to track a subset of the available remote branches\nafter the initial setup for a remote. The named branches will be interpreted as if specified with the -t option on the git remote add command line. With --add , instead of replacing the list of currently tracked\nbranches, adds to that list."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-apply - Apply a patch to files and/or to the index --check"}, {"role": "assistant", "content": "Instead of applying the patch, see if the patch is\napplicable to the current working tree and/or the index\nfile and detects errors. Turns off \"apply\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git (SSH) in Visual Studio 2015\nSo with Visual Studio 2015 just being released there is a much more integrated tie-in with git. \nHowever the feature that seems to be lacking is git over SSH. There are various plugins for 2013 that allow this functionality (i.e GitExtensions) but I can't see any with 2015. \nGitHub plugin only appears to work with GitHub and not generic git repos. \nI'm not looking for an opinion of which is better, only some examples or articles to see if anyone has got Git+SSH on Visual Studio 2015 working."}, {"role": "assistant", "content": "No. Visual Studio 2015 (RTM) does not support SSH for Git remotes. This is true even with GitHub repositories using the GitHub plug-in (which - at present - uses the same connection mechanism for Git repositories as any other Git repository using Team Explorer.)\nThis is regrettable, but there are a handful of reasons why this is not available yet: the short answer is that in our opinion, providing SSH poorly or insecurely is worse than not providing SSH at all, and we would like to be very confident that any SSH implementation we provide is of high-quality.\nThat said, we are working on it, and making progress. Microsoft is going to begin including OpenSSH in Windows (and is a sponsor of that very fine project). However I cannot make any predictions as to when support might be available.\nThe GitHub extension is open source, so it's possible that it may be able to use a different connection mechanism and begin supporting SSH before the core Git support in Team Explorer."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How secure would github hosting be for private repositories? [closed]\nClosed. This question is opinion-based. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it can be answered with facts and citations by editing this post.\n\n\nClosed 10 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI have read this thread but I'm wondering how secure such a solution would be? I know that github offers ssh/ssl support and am familiar but could someone give me a breakdown of what sort of internal security they would use to make sure my committed conf/credential files don't get hacked?\nEDIT: I've read http://help.github.com/security/ but I would like an answer from someone who has worked with multiple repository hosts and has real-world experience with this."}, {"role": "assistant", "content": "We tried out github recently.\nCompared with our previous git hosting (which was on our own linux virtual server), I'm not overly impressed with the security. We did decide to use it, but only for projects where keeping the code private wasn't a huge concern.\nNamely:\n\nThere's no company control at all over the user accounts. We control which users have access to our repository, but there's no password policies, the users pick their own email addresses, etc.\nThere's no way to limit access by IP address\nPasswords can only be reset by the user\nCompromising the users email account (which we're unable to see what account they've set it to) also results in a compromise of their github account, as they use an email challenge to reset forgotten passwords.\nThere's no access logs (there is an audit trail for most or possibly all changes, but no logging at all for access)\nAccess to the web front end is only password protected, so is vulnerable to password reuse from other sites and to some extent to brute forcing (github's statement about what they do for failed logins is pretty unclear).\n\nOne or two of these we could live, but in combination they basically make github completely unsuitable.\nThey have added 2 factor authentication recently, and there is an API so that organisations can at least check if users with access to their repositories have two factor authentication enabled. Whilst I don't feel this is really the best solution, it probably just about moves github into being secure enough that it can be considered for private repos.\nAs mt3 notes, you can run an enterprise install instead, which presumably significantly improves security - but the cost difference between that and a standard github company account is staggering, and it would probably mean you miss out on all the third party tools that integrate with github.\nOn a non-security note, they do at least now support annual billing properly, which helps reduce the paperwork overhead.\nGitHub have recently announced new business plans with extra features - this could solve '1'/'4'/'5'. (Though the 'uptime guarantee' that's part of it is pretty laughable - not even \"four 9s\", and excludes scheduled maintenance and anything they deem 'outside their reasonable control' - and it's not an actual guarantee, it's just a small credit against your next bill which is capped to be no more than a third of your bill. Basically very carefully worded marketing weasel words instead of any kind of commitment from them.)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to push changes to github after jenkins build completes?\nI have a jenkins job that clones the repository from github, then runs the powershell script that increments the version number in the file. I'm now trying to publish that update file back to the original repository on github, so when developer pulls the changes he gets the latest version number.\nI tried using Git Publisher in the post build events, and I can publish tags with no issues, but it doesn't seem to publish any files."}, {"role": "assistant", "content": "The git checkout master of the answer by Woland isn't needed. Instead use the \"Checkout to specific local branch\" in the \"Additional Behaviors\" section to set the \"Branch name\" to master.\nThe git commit -am \"blah\" is still needed.\nNow you can use the \"Git Publisher\" under \"Post-build Actions\" to push the changes. Be sure to specify the \"Branches\" to push (\"Branch to push\" = master, \"Target remote name\" = origin).\n\"Merge Results\" isn't needed."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-grep - Print lines matching a pattern -v --invert-match"}, {"role": "assistant", "content": "Select non-matching lines."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fetch - Download objects and refs from another repository --deepen=<depth>"}, {"role": "assistant", "content": "Similar to --depth, except it specifies the number of commits\nfrom the current shallow boundary instead of from the tip of\neach remote branch history."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-verify-pack - Validate packed Git archive files"}, {"role": "assistant", "content": "DESCRIPTION Reads given idx file for packed Git archive created with the git pack-objects command and verifies the idx file and the\ncorresponding pack file."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git push to existing remote branch\nHow do I push changes from a local git branch to an existing non-master remote branch? If I do a \"git push\", it tries to push changes in all local branches to the remotes they are tracking."}, {"role": "assistant", "content": "To do this you use a refspec, as explained in the git push documentation. For example:\ngit push origin local_branch_name:remote_branch_name"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options uploadpack.keepAlive"}, {"role": "assistant", "content": "When upload-pack has started pack-objects , there may be a\nquiet period while pack-objects prepares the pack. Normally\nit would output progress information, but if --quiet was used\nfor the fetch, pack-objects will output nothing at all until\nthe pack data begins. Some clients and networks may consider\nthe server to be hung and give up. Setting this option instructs upload-pack to send an empty keepalive packet every uploadpack.keepAlive seconds. Setting this option to 0\ndisables keepalive packets entirely. The default is 5 seconds."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rm - Remove files from the working tree and from the index -r"}, {"role": "assistant", "content": "Allow recursive removal when a leading directory name is\ngiven."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git branching strategy integated with testing/QA process\nOur development team has been using the GitFlow branching strategy and it has been great !\nRecently we recruited a couple testers to improve our software quality. The idea is that every feature should be tested/QA by a tester.\nIn the past, developers work on features on separate feature branches and merge them back to the develop branch when done. The developer will test his work himself on that feature branch. Now with testers, we start asking this Question\n\nOn which branch should the tester test new features ?\n\nObviously, there are two options: \n\non the individual feature branch\non the develop branch\n\nTesting On Develop Branch\nInitially, we believed this is the sure way to go because:\n\nThe feature is tested with all other features merged to the develop branch since it's development started. \nAny conflicts can be detected earlier than later\nIt makes the tester's job easy, he is only dealing with one branch (develop) at all time. He doesn't need to ask the developer about which branch is for which feature ( feature branches are personal branches managed exclusively and freely by relevant developers )\n\nThe biggest problems with this is:\n\nThe develop branch is polluted with bugs. \nWhen the tester finds bugs or conflicts, he reports them back to the developer, who fixes the issue on the develop branch (the feature branch were abandoned once merged ), and there could be more fixes required afterward. Multiple subsequence commits or merges (if a branch is recreated off develop branch again for fixing the bugs) makes rolling back the feature from the develop branch very difficult if possible. There are multiple features merging to and being fixed on the develop branch at different times. This creates a big issue when we want to create a release with just some of the features in the develop branch \n\nTesting On Feature Branch\nSo we thought again and decided we should test features on the feature branches. Before we test, we merge the changes from the develop branch to the feature branch ( catch up with the develop branch ). This is good:\n\nYou still test the feature with other features in the mainstream\nFurther development ( e.g. bug fix, resolving conflict ) will not pollute the develop branch;\nYou can easily decide not to release the feature until it is fully tested and approved;\n\nHowever, there are some drawbacks\n\nThe tester has to do the merging of the code, and if there's any conflict (very likely), he has to ask the developer for help. Our testers specialize in test and are not capable of coding.\na feature could be tested without the existence of another new feature. e.g. Feature A and B are both under test at the same time, the two features are unaware of each other because neither of them has been merged to the develop branch. These means you will have to test against the develop branch again when both of the features are merged to the develop branch anyway. And you have to remember to test this in the future.\nIf Feature A and B are both tested and approved, but when merged a conflict is identified, both of the developers for both features believe it is not his own fault/job because his feature branch past the test. There is an extra overhead in communication, and sometimes whoever resolving the conflict is frustrated. \n\n\nAbove is our story. With limited resource, I would like to avoid testing everything everywhere. We are still looking for a better way to cope with this. I would love to hear how other teams handle this kind of situations."}, {"role": "assistant", "content": "The way we do it is the following:\nWe test on the feature branches after we merge the latest develop branch code on them. The main reason is that we do not want to \"pollute\" the develop branch code before a feature is accepted. In case a feature would not be accepted after testing but we would like to release other features already merged on develop that would be hell. Develop is a branch from which a release is made and thus should better be in a releasable state. The long version is that we test in many phases. More analytically:\n\nDeveloper creates a feature branch for every new feature.\nThe feature branch is (automatically) deployed on our TEST environment with every commit for the developer to test.\nWhen the developer is done with the implementation and the feature is ready to be tested they reabse the develop branch on the feature branch and deploy the feature branch that contains all the latest develop changes on TEST.\nThe tester tests on TEST. When they are done they \"accept\" the story and merge the feature branch on develop. Since the developer had previously rebased the develop branch on the feature one we don't expect too many conflicts. However, if that's the case the developer can help. This is a tricky step, I think the best way to avoid it is to keep features as small/specific as possible. Different features have to be eventually merged, one way or another. Of course the size of the team plays a role on this step's complexity.\nThe develop branch is also (automatically) deployed on TEST. We have a policy that even though the features branch builds can fail the develop branch should never fail.\nOnce we have reached a feature freeze we create a release from develop. This is automatically deployed on STAGING. Extensive end to end tests take place on there before the production deployment. (ok maybe I exaggerate a bit they are not very extensive but I think they should be). Ideally beta testers/colleagues i.e. real users should test there.\n\nWhat do you think of this approach?"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --no-decorate --decorate[=short|full|auto|no]"}, {"role": "assistant", "content": "Print out the ref names of any commits that are shown. If short is\nspecified, the ref name prefixes refs/heads/ , refs/tags/ and refs/remotes/ will not be printed. If full is specified, the\nfull ref name (including prefix) will be printed. If auto is\nspecified, then if the output is going to a terminal, the ref names\nare shown as if short were given, otherwise no ref names are\nshown. The option --decorate is short-hand for --decorate=short .\nDefault to configuration value of log.decorate if configured,\notherwise, auto ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I resolve merge conflicts in a Git repository?\nHow do I resolve merge conflicts in my Git repository?"}, {"role": "assistant", "content": "Try:\ngit mergetool\n\nIt opens a GUI that steps you through each conflict, and you get to choose how to merge. Sometimes it requires a bit of hand editing afterwards, but usually it's enough by itself. It is much better than doing the whole thing by hand certainly.\n\nAs per Josh Glover's comment:\n\n[This command]\ndoesn't necessarily open a GUI unless you install one. Running git mergetool for me resulted in vimdiff being used. You can install\none of the following tools to use it instead: meld, opendiff,\nkdiff3, tkdiff, xxdiff, tortoisemerge, gvimdiff, diffuse,\necmerge, p4merge, araxis, vimdiff, emerge.\n\n\nBelow is a sample procedure using vimdiff to resolve merge conflicts, based on this link.\n\nRun the following commands in your terminal\ngit config merge.tool vimdiff\ngit config merge.conflictstyle diff3\ngit config mergetool.prompt false\n\nThis will set vimdiff as the default merge tool.\n\nRun the following command in your terminal\ngit mergetool\n\n\nYou will see a vimdiff display in the following format:\n ╔═══════╦══════╦════════╗\n ║ ║ ║ ║\n ║ LOCAL ║ BASE ║ REMOTE ║\n ║ ║ ║ ║\n ╠═══════╩══════╩════════╣\n ║ ║\n ║ MERGED ║\n ║ ║\n ╚═══════════════════════╝\n\nThese 4 views are\n\nLOCAL: this is the file from the current branch\nBASE: the common ancestor, how this file looked before both changes\nREMOTE: the file you are merging into your branch\nMERGED: the merge result; this is what gets saved in the merge commit and used in the future\n\nYou can navigate among these views using ctrl+w. You can directly reach the MERGED view using ctrl+w followed by j.\nMore information about vimdiff navigation is here and here.\n\nYou can edit the MERGED view like this:\n\nIf you want to get changes from REMOTE\n:diffg RE\n\n\nIf you want to get changes from BASE\n:diffg BA\n\n\nIf you want to get changes from LOCAL\n:diffg LO\n\n\n\n\nSave, Exit, Commit, and Clean up\n:wqa save and exit from vi\ngit commit -m \"message\"\ngit clean Remove extra files (e.g. *.orig). Warning: It will remove all untracked files, if you won't pass any arguments."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Warning on \"diff.renamelimit variable\" when doing git push\nI'm pushing the local commit to the remote git server and got the following warning messages:\nremote: warning: only found copies from modified paths due to too many files.\nremote: warning: you may want to set your diff.renamelimit variable to at least 19824 and retry the command.\n\nBut actually I've already set the diff.renamelimit to 0 (I think zero means unlimited, right?).\n$ git config --list\n...\ndiff.renamelimit=0\n\nSo what shall I do to avoid this warning? Thanks."}, {"role": "assistant", "content": "git config merge.renameLimit 999999\n\nWhat does merge.renameLimit mean\n\nThe number of files to consider when performing rename detection during a merge; if not specified, defaults to the value of diff.renameLimit.\n\nsource: https://git-scm.com/docs/git-merge"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-multi-pack-index"}, {"role": "assistant", "content": "Write and verify multi-pack-indexes"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-push - Update remote refs along with associated objects --prune"}, {"role": "assistant", "content": "Remove remote branches that don’t have a local counterpart. For example\na remote branch tmp will be removed if a local branch with the same\nname doesn’t exist any more. This also respects refspecs, e.g. git push --prune remote refs/heads/*:refs/tmp/* would\nmake sure that remote refs/tmp/foo will be removed if refs/heads/foo doesn’t exist."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-branch - List, create, or delete branches -v -vv --verbose"}, {"role": "assistant", "content": "When in list mode,\nshow sha1 and commit subject line for each head, along with\nrelationship to upstream branch (if any). If given twice, print\nthe path of the linked worktree (if any) and the name of the upstream\nbranch, as well (see also git remote show <remote> ). Note that the\ncurrent worktree’s HEAD will not have its path printed (it will always\nbe your current directory)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git branch is not showing all the branches\n/opt/lampp/htdocs/drupal-8.4.0$ git branch\n\nI have installed drupal in my system ,I want to switch to other branch but when used git branch is not showing other branches !"}, {"role": "assistant", "content": "Execute git branch -av to show all remote and local branches."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git merge develop into feature branch outputs \"Already up-to-date\" while it's not\nI checked out a feature branch from develop called branch-x. After a while other people pushed changes to the develop branch. \nI want to merge those changes into my branch-x. However if I do \ngit merge develop \n\nit says \"Already up-to-date\" and doesn't allow me to merge. \ngit diff develop shows that there are differences between branch-x and develop.\nHow do I merge develop into branch-x?"}, {"role": "assistant", "content": "You should first pull the changes from the develop branch and only then merge them to your branch:\ngit checkout develop \ngit pull \ngit checkout branch-x\ngit rebase develop\n\nOr, when on branch-x:\ngit fetch && git rebase origin/develop\n\n\nI have an alias that saves me a lot of time. Add to your ~/.gitconfig:\n[alias]\n fr = \"!f() { git fetch && git rebase origin/\"$1\"; }; f\"\n\nNow, all that you have to do is:\ngit fr develop"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker gitsubmodules"}, {"role": "assistant", "content": "Mounting one repository inside another"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git mergetool with Meld on Windows\nIn Linux, my favorite merge tool is Meld, and I've had no problems using or configuring it to work with Git. However, in Windows it has been a different story.\nFirst, I installed Meld from a bundle I found here: https://code.google.com/p/meld-installer/\nThen, I configured my .gitconfig like so to support Meld as the default mergetool\n[merge] \n tool = meld \n\n[mergetool \"meld\"] \n path = C:\\\\Program Files (x86)\\\\Meld\\\\meld\\\\meld.exe\n keepBackup = false \n trustExitCode = false\n\nSo, when I have a conflict, I do git difftool and Meld does in fact open. However, the paths to the files that Git writes to pass to the diff tool is incorrect. For example, even though Git generates the BASE, LOCAL, and REMOTE files in the repository directory (the location I called git mergetool from), Meld tries to open each of those files in the directory of the executable. \nInstead of opening C:\\repo\\roses.txt.LOCAL.2760.txt, Meld tries to open C:\\Program Files (x86)\\Meld\\meld\\roses.txt.LOCAL.2760.txt.\nHas anyone ran into this before or know how to configure Git / Meld to work correctly in Windows?"}, {"role": "assistant", "content": "Why do you not use git bash for Windows?\nAfter install meld simply:\ngit config --global merge.tool meld\ngit config --global mergetool.meld.path \"C:\\Program Files (x86)\\Meld\\Meld.exe\" <- path to meld here\n\nThats all!"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What does \"@@ -1 +1 @@\" mean in Git's diff output?\nI've been collecting data from the information returned from\ngit diff <commitId>..<commitId>\n\nand I ran into @@ -1 +1 @@\nI can't figure out what that's telling me. I've searched a bit on Google but to no avail."}, {"role": "assistant", "content": "Simple example analysis\nThe format is basically the same the diff -u unified diff.\nFor instance consider:\ndiff -u <(seq -w 16) <(seq -w 16 | grep -Ev '^(02|03|14|15)$')\n\nwhere:\n\nthe first file contains 01, 02 through 16\nthe second file contains the same but with lines 02, 03, 14 and 15 removed\n\nDiff output:\n@@ -1,6 +1,4 @@\n 01\n-02\n-03\n 04\n 05\n 06\n@@ -11,6 +9,4 @@\n 11\n 12\n 13\n-14\n-15\n 16\n\n@@ -1,6 +1,4 @@ means:\n\n-1,6 means that this piece of the first file starts at line 1 and shows a total of 6 lines. Therefore it shows lines 1 to 6.\n1\n2\n3\n4\n5\n6\n\n- means \"old\", as we usually invoke it as diff -u old new.\n\n+1,4 means that this piece of the second file starts at line 1 and shows a total of 4 lines. Therefore it shows lines 1 to 4.\n+ means \"new\".\nWe only have 4 lines instead of 6 because 2 lines were removed! The new hunk is just:\n01\n04\n05\n06\n\n\n\n@@ -11,6 +9,4 @@ for the second hunk is analogous:\n\non the old file, we have 6 lines, starting at line 11 of the old file:\n11\n12\n13\n14\n15\n16\n\n\non the new file, we have 4 lines, starting at line 9 of the new file:\n11\n12\n13\n16\n\nNote that line 11 is the 9th line of the new file because we have already removed 2 lines on the previous hunk: 2 and 3.\n\n\nHunk header\nDepending on your git version and configuration, you can also get a code line next to the @@ line, e.g. the func1() { in:\n@@ -4,7 +4,6 @@ func1() {\n\nThis can also be obtained with the -p flag of plain diff.\nExample: old file:\nfunc1() {\n 1;\n 2;\n 3;\n 4;\n 5;\n 6;\n 7;\n 8;\n 9;\n}\n\nIf we remove line 6, the diff shows:\n@@ -4,7 +4,6 @@ func1() {\n 3;\n 4;\n 5;\n- 6;\n 7;\n 8;\n 9;\n\nNote that this is not the correct line for func1: it skipped lines 1 and 2.\nThis awesome feature often tells exactly to which function or class each hunk belongs, which is very useful to interpret the diff.\nHow the algorithm to choose the header works exactly is discussed at: Where does the excerpt in the git diff hunk header come from?\nOne line hunk summarized notation\nThis is very rare, but consider:\ndiff -U0 <(seq -w 16) <(seq -w 16 | sed 's/10/hack/')\n\nwhere:\n\n-U0: use 0 lines of context\nsecond file replaces 10 with hack\n\nThe diff output in that case is:\n@@ -10 +10 @@\n-10\n+hack\n\nSo we understand that when there's a single line change, the notation gets summarized to showing just one number instead of the m,n pair.\nThis behavior is documented in the documentation quoted by Todd's answer:\n\nIf a hunk contains just one line, only its start line number appears. Otherwise its line numbers look like start,count. An empty hunk is considered to start at the line that follows the hunk.\n\nAnd single line hunk addition and removal look like this, removal:\ndiff -U0 <(seq -w 16) <(seq -w 16 | grep -Ev '^(10)$')\n\noutput:\n@@ -10 +9,0 @@\n-10\n\naddition:\n$ diff -U0 <(seq -w 16 | grep -Ev '^(10)$') <(seq -w 16)\n\noutput:\n@@ -9,0 +10 @@\n+10\n\nTested on diff 3.8, Ubuntu 22.10."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "In git how is fetch different than pull and how is merge different than rebase?\nI just cant understand this. I been reading a lot on the web and books and something is just not staying in my head. Can someone please give me the dummy version of the following:\n\ngit fetch vs pull\ngit merge vs rebase"}, {"role": "assistant", "content": "fetch vs pull\nfetch will download any changes from the remote* branch, updating your repository data, but leaving your local* branch unchanged.\npull will perform a fetch and additionally merge the changes into your local branch.\nWhat's the difference? pull updates you local branch with changes from the pulled branch. A fetch does not advance your local branch.\nmerge vs rebase\nGiven the following history:\n\n C---D---E local\n /\n A---B---F---G remote\n\nmerge joins two development histories together. It does this by replaying the changes that occurred on your local branch after it diverged on top of the remote branch, and record the result in a new commit. This operation preserves the ancestry of each commit.\nThe effect of a merge will be:\n\n C---D---E local\n / \\\n A---B---F---G---H remote\n\nrebase will take commits that exist in your local branch and re-apply them on top of the remote branch. This operation re-writes the ancestors of your local commits.\nThe effect of a rebase will be:\n\n C'--D'--E' local\n /\n A---B---F---G remote\n\nWhat's the difference? A merge does not change the ancestry of commits. A rebase\nrewrites the ancestry of your local commits.\n* This explanation assumes that the current branch is a local branch, and that the branch specified as the argument to fetch, pull, merge, or rebase is a remote branch. This is the usual case. pull, for example, will download any changes from the specified branch, update your repository and merge the changes into the current branch."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options trace2.maxFiles"}, {"role": "assistant", "content": "Integer. When writing trace files to a target directory, do not\nwrite additional traces if doing so would exceed this many files. Instead,\nwrite a sentinel file that will block further tracing to this\ndirectory. Defaults to 0, which disables this check."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git: Show content of file as it will look like after committing\nAfter reading Git pre-commit hook : changed/added files, the following question arose:\nGiven I have a file with both staged and unstaged changes, how can I display a preview of the file's contents after staging?\nExample:\necho \"foo\" >> file\ngit add file\necho \"bar\" >> file\n\nWanted output:\n[previous contents of file]\nfoo"}, {"role": "assistant", "content": "Use the : prefix to access objects in the current index (staged but not yet commited).\ngit show :file\n\nSee gitrevisions (which uses the term 'stage 0' for the \"normal\" index contents):\n\n:[<n>:]<path>, e.g. :0:README, :README\n\nA colon, optionally followed by a stage number (0 to 3) and a colon, followed by a path, names a blob object in the index at the given path. A missing stage number (and the colon that follows it) names a stage 0 entry. During a merge, stage 1 is the common ancestor, stage 2 is the target branch’s version (typically the current branch), and stage 3 is the version from the branch which is being merged."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_NO_REPLACE_OBJECTS"}, {"role": "assistant", "content": "Setting and exporting this environment variable tells Git to\nignore replacement refs and do not replace Git objects."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I move my local Git repository to a remote Git repository\nI have various Git projects that are on my local machine. I have a server that I would like to use as my remote Git Repository. How do I move my local Git Repositories (Projects) to my server while keeping the history intact?\nThanks!\nEDIT:\nThanks for all the great answers. The response I choose makes sense to my limited GIT knowledge.\nEDIT #2:\nI noticed my original answer selection did not copy my tags. git push --mirror <path> does copy tags."}, {"role": "assistant", "content": "First, create a git repo on your server\ngit init --bare /path/to/repo\n\nThen add the remote repo to your local one (ssh:// or https://)\ngit remote add origin ssh://server/path/to/repo\n\nAnd, push files/commits\ngit push origin master\n\nAnd finally, push tags\ngit push origin --tags"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I fix \"remote: fatal error in commit_refs\" errors trying to push with Git?\n\nWhen I try to push to master branch that is hosted on https://github.com I get:\n\nremote: fatal error in commit_refs\n\nHow can I solve this?"}, {"role": "assistant", "content": "In my case, GitHub was down by the time I was trying to push.\nJust check https://www.githubstatus.com to know about GitHub site status.\nWhen it's up you'll be able to push."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git: How do I recursively add all files in a directory subtree that match a glob pattern?\nI have several .screen files inside /xxx/documentation and its subdirectories that are already tracked by Git.\nAfter modifying many of these screen files, I run git add documentation/\\\\*.screen—as indicated by the first example in git-add's documentation—to stage these files, but the command fails:\nfatal: pathspec 'documentation/\\*.screen' did not match any files\nIs my command bad, or does git have a bug?"}, {"role": "assistant", "content": "It's a bug in the documentation. Quote the asterisk with\n$ git add documentation/\\*.screen\nor\n$ git add 'documentation/*.screen'\nto get the behavior you want.\nIf instead you want to add files in the current directory only, use\n$ git add *.screen\nUPDATE: I submitted a patch that corrects the issue, now fixed as of version 1.6.6.2."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git error: \"Please make sure you have the correct access rights and the repository exists\"\n\nI am using TortoiseGit on Windows. When I am trying to Clone from the context menu of the standard Windows Explorer, I get this error:\n\nPlease make sure you have the correct access rights and the repository exists\n\nMore precisely, the snapshot of terminal is the following:\n\ngit.exe clone --progress -v \"git@arobotdev:\\git\\AlfaRobot.git\" \"C:\\Work\\AlfaRobot\"\n\n Cloning into 'C:\\Work\\AlfaRobot'...\n Permission denied, please try again.\n Permission denied, please try again.\n Permission denied (publickey,password).\n fatal: Could not read from remote repository.\n\n Please make sure you have the correct access rights\n and the repository exists.\n\n git did not exit cleanly (exit code 128) (21450 ms @ 19.09.2014 10:36:58)\n\nWhat should I do to make git work properly ?"}, {"role": "assistant", "content": "Your git URL might have changed. Change the URL in the local directory by using the following command:\nfor https protocol\ngit remote set-url origin https://github.com/username/repository.git\n\nfor ssh protocol\ngit remote set-url origin [email protected]:username/repository.git\n\nThere might be multiple causes for the issue:\n\nIf the issue is with your ssh identity, see onkar-m18's answer here\nIf ssh key is not added to hosting server, see lovekush-vishwakarma's answer here"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Project management to go with GitHub [closed]\nClosed. This question is seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. It does not meet Stack Overflow guidelines. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\n We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.\n\n\nClosed 9 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\n(EDIT: This question is now outdated for my particular issue, as Google Code supports git now and I've converted Protocol Buffers to Mercurial anyway. However, it's still of general interest, IMO.)\nMy C# Protocol Buffers Port uses github for its source control, and I'm beginning to really enjoy using git. However, as far as I can tell, github doesn't provide any project management tools: defect and feature tracking, discussions, feature requests, docs etc. Given my affiliations, Google Code would be a natural choice, but it would seem odd to create a project there but host the source on github.\nThis question about Fogbugz/Assembla seems to mostly focus on the defect tracking. I was wondering what experiences others have had when it comes to a more \"complete\" project management solution. Does Fogbugz actually do everything I need? (Using a wiki for docs has its advantages, although I also want to be able to distribute documentation with the code.) Beyond the explicit features mentioned in the first paragraph, are there other project aspects I should be considering which I may have missed?\nThis will definitely stay an open source project, and although I'd rather not pay I don't mind if a small fee is required. Currently I'm the only developer, but that may change and there may very well be lots of people filing bugs and feature requests. (In other words, I hope and expect it to be popular, but with me doing most of the work.)\nPreviously I've contributed to various open source projects, but haven't done much in the way of running a very visible and active one. (MiscUtil is currently still \"hosted\" on my website, with occasional releases - the actual source control is on my local NAS.)\nAnyone care to share their experiences?\nEDIT: Another option I'm now considering is a Google Code project (I really would like to be loyal to my employer) and an occasional merge from git to svn (at the very least, every time I do a release). This would allow non-git users to get hold of the source easily too."}, {"role": "assistant", "content": "If you're thinking that you'll really be the only developer, Fogbugz will help you keep your sanity. Fogbugz is a great product, It builds focused communications and can turn anything into a case (issue). It does all that as well as any system I've seen. \nBut its orientation is commercial -- efficient communication between users and tech support, improve reliability of schedules, focus & prioritize what's being worked on, separate internal & external discussions, some good reporting to track that things are getting handled. (About the only criticism I can think of is it doesn't do case blocking and dependency tracking, which is really useful for those bugs buried deep.) \nLittle of this feature set will help you build an active open source project, with open lively communication and the need build a community and have users evolve into developers as the project grows. So if that's where you want to end up, you may really want the less focused communication channels of one of these lightweight tracking systems. \nI haven't used Google Code on a project yet, but in terms of transparent & open communication, it looks like a good support for an active open source project. Plus you already know it. If you want to grow the involvement in your project, Google code looks like the way to go."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-add - Add file contents to the index removing untouched content"}, {"role": "assistant", "content": "Content which does not differ between the index and working tree may be\nshown on context lines, beginning with a \" \" (space). You can stage\ncontext lines for removal by converting the space to a \"-\". The\nresulting working tree file will appear to re-add the content."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I see what has changed in a file before committing to git?\nI've noticed that while working on one or two tickets, if I step away, I'm not sure what I worked on, what changed, etcetera.\nIs there a way to see the changes made for a given file before git add and then git commit?"}, {"role": "assistant", "content": "You're looking for\ngit diff --staged\nDepending on your exact situation, there are three useful ways to use git diff:\n\nShow differences between index and working tree; that is, changes you haven't staged to commit:\n\ngit diff [filename]\n\n\nShow differences between current commit and index; that is, what you're about to commit (--staged does exactly the same thing, use what you like):\n\ngit diff --cached [filename]\n\n\nShow differences between current commit and working tree:\n\ngit diff HEAD [filename]\n\ngit diff works recursively on directories, and if no paths are given, it shows all changes."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do you deal with configuration files in source control?\nLet's say you have a typical web app and with a file configuration.whatever. Every developer working on the project will have one version for their dev boxes, there will be a dev, prod and stage versions. How do you deal with this in source control? Not check in this file at all, check it with different names or do something fancy altogether?"}, {"role": "assistant", "content": "What I've done in the past is to have a default config file which is checked in to source control. Then, each developer has their own override config file which is excluded from source control. The app first loads the default, and then if the override file is present, loads that and uses any settings from the override in preference to the default file.\nIn general, the smaller the override file the better, but it can always contain more settings for a developer with a very non-standard environment."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Difference between subprojects and submodules in Git?\nIn Git, is there a difference between a \"submodule\" (as created and managed by the git submodule command) and a \"subproject\" (literally just one Git repository that you put inside another Git repository), and if so, what is it?\nAll the documentation I've been able to find about this is rather ambiguous (and in some cases, contradictory). My suspicion is that there is no difference, but I figure I ought to confirm that and leave a question for Git newbies to find."}, {"role": "assistant", "content": "A subproject is a generic term for one of three types of nesting:\n\nSubmodules provide semi-fixed references from the superproject into subprojects and are integrated into git. It is best used when the subproject:\n\n\nis developed by someone else, is not under the administrative control of the superproject and follows a different release cycle.\ncontains code shared between superprojects (especially when the intention is to propagate bugfixes and new features back to other superprojects).\nseparates huge and/or many files that would hurt performance of everyday git commands. \n\nSubtrees causes the subproject repository to be imported into the superproject's repository to be a native part of the repository with full history, typically in a specific subdirectory of the superproject. \nWrappers, which provide multi-repository management functionality to a superproject with associated subprojects.\n\nReference documentation"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I copy a version of a single file from one Git branch to another?\nI've got two branches that are fully merged together.\nHowever, after the merge is done, I realise that one file has been messed up by the merge (someone else did an auto-format, gah), and it would just be easier to change to the new version in the other branch, and then reinsert my one line change after bringing it over into my branch.\nSo what's the easiest way in Git to do this?"}, {"role": "assistant", "content": "Run this from the branch where you want the file to end up:\ngit checkout otherbranch myfile.txt\n\nGeneral formulas:\ngit checkout <commit_hash> <relative_path_to_file_or_dir>\ngit checkout <remote_name>/<branch_name> <file_or_dir>\n\nSome notes (from comments):\n\nUsing the commit hash, you can pull files from any commit\nThis works for files and directories\nOverwrites the file myfile.txt and mydir\nWildcards don't work, but relative paths do\nMultiple paths can be specified\n\nAn alternative:\ngit show commit_id:path/to/file > path/to/file"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to connect local folder to Git repository and start making changes on branches?\n\nI'm new to source control; in the past, I've manually backed up copies of files and made changes on clones then transferred changes manually to master files once debugged. I realize this is similar to how branches work with Git repositories, however I've never used one.\nI downloaded Git and made an account on GitLab, and started a new project. My site is hosted on a local server and my files are saved locally. How do I connect these files to a Git repository and continue developing with branches?"}, {"role": "assistant", "content": "To register a project as a local Git repository the first thing you need to do is perform the following command at your project root:\ngit init\n\nThis will create a .git folder at your project root and will allow you to start using Git in that repository.\n\nIf you want to \"push\" your local Git repository to a remote Git server (in your case, to GitLab), you'll need to perform the following command first:\ngit remote add origin <Repository_Location>\n\nYou can call origin whatever you like, really, but origin is the standard name for Git remote repositories. <Repository_Location> is the URL to your remote repository. For example, if I had a new project called MyNewProject that I wanted to push to GitLab, I'd perform:\ngit remote add origin https://gitlab.com/Harmelodic/MyNewProject.git\n\nYou can then \"push\" your changes from your local machine to your remote repo using the following command:\ngit push origin <branch_name>\n\nwhere branch name is the name of the branch you want to push, e.g. master.\n\nYou can find a good beginners guide to Git here."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git checkout with dot\nWhat is the difference between the following git commands:\ngit checkout branch\ngit checkout branch .\ngit checkout . #<-- used at the branch\n\nWhy when I checkout different branches into different folders with first one I missed some files.\nBut when I am using the second command, everything is ok?"}, {"role": "assistant", "content": "git checkout(1) does very different things whether given path specifier or not.\n\nWith branch specifier only (git checkout branch) it will switch current working directory to specified branch, keeping local changes if possible and failing otherwise. If you already are on branch, it will do nothing at all. It only modifies files in the working directory that differ between HEAD and branch and fails if any of them has local modifications (indexed or not).\nWith path specifier it will overwrite the all matching files (all files match .) with specified content:\n\nWith path specifier only (git checkout .) it writes content from index. That is, it undoes unstaged local modification. To undo staged modifications, use git reset with path specifier.\nWith both branch and path specifiers (git checkout branch .) it writes content in specified revision. It will not modify where HEAD points, so if branch is different from HEAD, there will be unstaged changes afterwards.\n\n\n\nNote, that the man page distinguishes additional cases for use of the -b/--branch option and -p/--patch option, but those are mostly straightforward extensions of the above cases."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why does git fail to fetch specific valid submodule for a given commit and how to fix it?\nI have a git repo which has another one as a submodule dependency. In the root of my project (where the .git, .gitsubmodules etc. are) I called\ngit submodule update\n\nThis failed with the following message:\n\nFetched in submodule path 'src/framework', but it did not contain cc8c38e9d853491c672452d8dbced4666fc73ec8. Direct fetching of that commit failed.\n\nwhere src/framework is a sub-directory of my project (PROJECT_ROOT/src/framework) and should be where the third-party repo lands. The given commit hash is a valid one as in I can use to access that commit through the web interface.\nI have also tried git clone --recursive <my-repo> but it fails too.\nThe contents of my .gitmodules is\n[submodule \"src/framework\"]\n path = src/framework\n url = [email protected]:gh/framework.git\n\nIn addition to that I have to note the following important fact: due to recent updates in the framework repo my code breaks hence I really need to retrieve that specific version of it where things were working fine."}, {"role": "assistant", "content": "Running this command after cloning (and receiving the error) solved my problem:\ngit submodule update --force --recursive --init --remote\n\nOf course this is not a good solution. It is better to find and solve the underlying problem, but if anyone is in hurry, this was worked for me."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git push fatal: unable to create thread: Resource temporarily unavailable\nI'm new to git.\nI'm want to push a large commit to a remote server but the problem is\nwhen I use\ngit push origin master\n\nit return the error\nCounting objects: 5009, done.\nDelta compression using up to 16 threads.\nfatal: unable to create thread: Resource temporarily unavailable\nerror: pack-objects died with strange error\n\nSo is there anyway I can set the max thread use for Delta Compression.\nThanks for help,\nYuan Chen"}, {"role": "assistant", "content": "The error: \"fatal: unable to create thread: Resource temporarily unavailable\" strongly suggests you've run out of memory on the server, which can happen if you have a repository with lots of large files, which can cause re-packing to take a lot of memory, or limited virtual memory - either in general, or just for that account due to the ulimit setting.\nAnyways, here's the commands you can run to limit the amount of memory that packing may take by logging into the remote system (as the user that git runs as) and typing these commands:\ngit config --global pack.windowMemory \"100m\"\ngit config --global pack.packSizeLimit \"100m\"\ngit config --global pack.threads \"1\"\n\nHope this works."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fast-import - Backend for fast Git data importers --[no-]relative-marks"}, {"role": "assistant", "content": "After specifying --relative-marks the paths specified\nwith --import-marks= and --export-marks= are relative\nto an internal directory in the current repository.\nIn git-fast-import this means that the paths are relative\nto the .git/info/fast-import directory. However, other\nimporters may use a different location. Relative and non-relative marks may be combined by interweaving\n--(no-)-relative-marks with the --(import|export)-marks= options."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects remerge, r"}, {"role": "assistant", "content": "Remerge two-parent merge commits to create a temporary tree\nobject—​potentially containing files with conflict markers\nand such. A diff is then shown between that temporary tree\nand the actual merge commit. The output emitted when this option is used is subject to change, and\nso is its interaction with other options (unless explicitly\ndocumented)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Gitlab pages and Jekyll - issue with set up TLS Lets Encrypted\n\nI try to add SSL/TLS on my static web site. I use Gitlab static pages, and Jekyll is for content.\nI follow this instructions to set up TLS - Gitlab tutorial.\nI am stack on this part - I got 404 error from Gitlab pages\n\nOnce the build finishes, test again if everything is working well:\n# Note that we're using the actual domain, not localhost anymore\n$ curl http://YOURDOMAIN.org/.well-known/acme-challenge/5TBu788fW0tQ5EOwZMdu1Gv3e9C33gxjV58hVtWTbDM\n\n\nThe problem is next\nI am successfully generated certificate with command ./letsencrypt-auto certonly -a manual -d example.com\nI created custom page letsencrypt-setup.html in root directory whit appropriate content. \nI run jekyll build command and it created _site/.well-known/acme-challenge/5TBu788fW0tQ5EOwZMdu1Gv3e9C33gxjV58hVtWTbDM.html page.\nWhen I run curl command to this page it worked with and without .html extension - both commands work, and return appropriate value\ncurl http://localhost:4000/.well-known/acme-challenge/5TBu788fW0tQ5EOwZMdu1Gv3e9C33gxjV58hVtWTbDM\ncurl http://localhost:4000/.well-known/acme-challenge/5TBu788fW0tQ5EOwZMdu1Gv3e9C33gxjV58hVtWTbDM.html\n\nWhen I commit changes and push to Gitlab after build and deploy I can fetch appropriate content only with second command \ncurl http://example.com/.well-known/acme-challenge/5TBu788fW0tQ5EOwZMdu1Gv3e9C33gxjV58hVtWTbDM.html\n\nWhen I ran \ncurl http://example.com/.well-known/acme-challenge/5TBu788fW0tQ5EOwZMdu1Gv3e9C33gxjV58hVtWTbDM\n\nI got 404 error. \nIf I press continue in ./letsencrypte script I also got 404 error. This tool try against URL without .html extension.\nI read comments in the tutorial and try this workaround but it didn't work for me. \nI have no clue what to try next - I have no lot experience with Jekyll/SSL"}, {"role": "assistant", "content": "Another solution (as suggested by Marthym) is simply to add a slash to the end of the permalink line:\npermalink: /.well-known/acme-challenge/5TBu788fW0tQ5EOwZMdu1Gv3e9C33gxjV58hVtWTbDM/\n\nIn this way, visiting YOURDOMAIN.org/.well-known/acme-challenge/... will redirect you to YOURDOMAIN.org/.well-known/acme-challenge/.../ (note the extra slash) which will have the correct data. It worked flawlessly for me, and I didn't need to update the .gitlab-ci.yml when I switched to a different domain."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to avoid git rebase killing merge commits?\nGiven the following git history:\n C-I origin/master\n /\nA-B-F-G-H master\n \\ /\n D-E branch-b\n\nI want to rebase my local master branch on top of origin/master, but I want to preserve the merge commit G. When I tried simply doing a git rebase origin/master while at master it squashed D..E as G and committed that with the commit message of E, so the history that there was a merge was lost. Is there some way of preserving this merge while still getting the rebase? For clarity, my intended result is:\nA-B-C-I-F-G-H master\n \\ /\n D-----E branch-b"}, {"role": "assistant", "content": "Add --preserve-merges to your rebase command. In case there were conflict resolutions in your merge, add 'recursive theirs' strategy as a parameter as well. \nEDIT: --preserve-merges is now deprecated, use --rebase-merges instead"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %>>( <N> ) , %>>|( <M> )"}, {"role": "assistant", "content": "similar to %>( <N> ) , %>|( <M> ) respectively, except that if the next\nplaceholder takes more spaces than given and\nthere are spaces on its left, use those\nspaces"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I remove Tag in GitLab repository\nI am using GitLab 7.7.2 and tried to remove Tag in a repository in GitLab.\nI could remove tag in a local repository but cannot remove tag in origin.\nHow do I remove tag in GitLab repository?\n$ git tag -d Tag_AAA\nDeleted tag 'Tag_AAA' (was d10bff2)\n\n$ git push --delete origin Tag_AAA\nremote: GitLab: You don't have permission\nTo [email protected]:root/Repository.git\n ! [remote rejected] Tag_AAA (pre-receive hook declined)\nerror: failed to push some refs to '[email protected]:root/Repository.git'"}, {"role": "assistant", "content": "# delete locally:\ngit tag -d <tag>\n\n# delete remotely:\ngit push origin :refs/tags/<tag>\n\n# another way to delete remotely:\ngit push --delete origin <tag>"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -R"}, {"role": "assistant", "content": "Swap two inputs; that is, show differences from index or\non-disk file to tree contents."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Easier way to keep a git feature branch up to date\nI was wondering if anyone would have a better suggestion for keeping a feature branch in sync with it's parent branch. \nWe typically have multiple feature branches that are being worked on at a time, each derived from our develop branch. It's fairly common for feature branches to be merged into develop a couple times a day. \nIn order to stay on top of changes (i.e. resolve conflicts) I find I need to keep the feature branches I'm actively working on up to date with develop.\nTo do this I run these commands a couple times a day:\ngit checkout develop\ngit pull\ngit checkout feature/foo \ngit merge develop \ngit push\n\nThe last git push I usually only do if I'm working with someone else on the feature branch.\nIs there a better or more convenient way to do this?"}, {"role": "assistant", "content": "Well, git is really set up for wrapping things you do frequently into a script and then calling the script instead. There isn't a huge number of variations on the above. They all will require pulling the upstream branch, and then integrating your changes with the upstream's. Some things that may shorten it for you might be:\ngit checkout feature/foo\ngit fetch --all\ngit merge --into-name=develop origin/develop\ngit rebase develop\n\nThat way you can simply pull all the upstream branches in one shot without switching to the other branch. And rebasing is possibly an operation you may prefer over merging, but that's frequently a personal choice depending on how you want the history to look."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options --add"}, {"role": "assistant", "content": "Adds a new line to the option without altering any existing\nvalues. This is the same as providing ^$ as the value-pattern in --replace-all ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is the purpose of \"workflow:rules\" in Gitlab-ci pipelines?\n\nI am a bit confused between Gitlab CI pipeline workflow:rules and job:rules\nworkflow:\n rules:\n - if: '$CI_PIPELINE_SOURCE == \"push\"'\n - if: '$CI_PIPELINE_SOURCE != \"schedule\"'\n\n\nand\ntest:\n stage: test\n image: image\n script:\n - echo \"Hello world!\"\n rules:\n - if: $CI_PIPELINE_SOURCE == \"schedule\"\n\nWhat happens if both of them were used in the same GitLab-ci YAML file."}, {"role": "assistant", "content": "With workflow you configure when a pipeline is created while with rules you configure when a job is created.\nSo in your example pipelines are created for pushes but cannot be scheduled while your test job will only run when scheduled.\nBut as workflow rules take precedence over job rules, no pipeline will be created in your example as your rules for workflow and job are mutually exclusive."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitHub - error: failed to push some refs to '[email protected]:myrepo.git'\nI ran these commands below:\ngit add .\n\ngit commit -m 't'\n\nThen, when running the command below:\ngit push origin development\n\nI got the error below:\nTo [email protected]:myrepo.git\n ! [rejected] development -> development (non-fast-forward)\nerror: failed to push some refs to '[email protected]:myrepo.git'\nTo prevent you from losing history, non-fast-forward updates were rejected\nMerge the remote changes (e.g. 'git pull') before pushing again. See the\n'Note about fast-forwards' section of 'git push --help' for details.\n\nAre there any ways to solve the error above?"}, {"role": "assistant", "content": "Your origin repository is ahead of your local repository. You'll need to pull down changes from the origin repository as follows before you can push. This can be executed between your commit and push.\ngit pull origin development\n\ndevelopment refers to the branch you want to pull from.\nIf you want to pull from master branch then type this one.\ngit pull origin master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %as"}, {"role": "assistant", "content": "author date, short format ( YYYY-MM-DD )"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_COMMIT_GRAPH_PARANOIA"}, {"role": "assistant", "content": "When loading a commit object from the commit-graph, Git performs an\nexistence check on the object in the object database. This is done to\navoid issues with stale commit-graphs that contain references to\nalready-deleted commits, but comes with a performance penalty. The default is \"false\", which disables the aforementioned behavior.\nSetting this to \"true\" enables the existence check so that stale commits\nwill never be returned from the commit-graph at the cost of performance."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I test what my readme.md file will look like before committing to GitHub?\n\nI am writing a readme for my GitHub project in the .md format. Is there a way can I test what my readme.md file will look like before committing to GitHub?"}, {"role": "assistant", "content": "Many ways: If you're on a Mac, use Mou.\nIf you want to test in a browser, you could try StackEdit, as pointed out by @Aaron or Dillinger since Notepag seems to be down now. Personally I use Dillinger since it just works and saves all my documents in my browser's local database."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git branch command behaves like 'less'\nWhen I use the git branch command to list all branches, I see the output of git branch | less.\nThe command git branch is supposed to show a list of branches, like ls does for files.\nThis is the output I get:\n\nHow do I get the default behaviour of git branch? What causes the paged output?\nMy .gitconfig looks like this:\n[user]\n email = [email protected]\n name = Dennis H.\n[push]\n default = simple\n[merge]\n tool = vimdiff\n[core]\n editor = nvim\n excludesfile = /Users/dennish/.gitignore_global\n[color]\n ui = true\n[alias]\n br = branch\n ci = commit -v\n cam = commit -am\n co = checkout\n df = diff\n st = status\n sa = stash\n mt = mergetool\n cp = cherry-pick\n pl = pull --rebase\n[difftool \"sourcetree\"]\n cmd = opendiff \\\"$LOCAL\\\" \\\"$REMOTE\\\"\n[mergetool \"sourcetree\"]\n cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \n \\\"$LOCAL\\\" \\\"$REMOTE\\\" -ancestor \\\"$BASE\\\" -merge \\\"$MERGED\\\"\n trustExitCode = true"}, {"role": "assistant", "content": "As mentioned in comments to Mark Adelsberger's answer, this was a default behavior change introduced in Git 2.16.\nYou can turn paged output for git branch back off by default with the pager.branch config setting:\ngit config --global pager.branch false"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…​]"}, {"role": "assistant", "content": "compares the trees named by the two arguments."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitglossary - A Git Glossary merge"}, {"role": "assistant", "content": "As a verb: To bring the contents of another branch (possibly from an external repository ) into the current branch. In the\ncase where the merged-in branch is from a different repository,\nthis is done by first fetching the remote branch\nand then merging the result into the current branch. This\ncombination of fetch and merge operations is called a pull . Merging is performed by an automatic process\nthat identifies changes made since the branches diverged, and\nthen applies all those changes together. In cases where changes\nconflict, manual intervention may be required to complete the\nmerge. As a noun: unless it is a fast-forward , a\nsuccessful merge results in the creation of a new commit representing the result of the merge, and having as parents the tips of the merged branches .\nThis commit is referred to as a \"merge commit\", or sometimes just a\n\"merge\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-for-each-ref - Output information on each ref --no-merged[=<object>]"}, {"role": "assistant", "content": "Only list refs whose tips are not reachable from the\nspecified commit (HEAD if not specified)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hidden markdown text on GitHub\n\nIs there anything in markdown syntax specifically on GitHub to support hidden text?\nI just want to put some to-do notes in README.md for myself, not to be visible.\n\nEXTRAS\nAs a tribute to the great answer by Tamas, and what's also asked a lot of times, below is an example of how to write foldable sections within MD files:\n<details>\n<summary><b>My section header in bold</b></summary>\n\nAny folded content here. It requires an empty line just above it.\n\n</details>"}, {"role": "assistant", "content": "Just use standard HTML comments:\n<!-- This is commented out. -->"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-archive - Create an archive of files from a named tree -<digit>"}, {"role": "assistant", "content": "Specify compression level. Larger values allow the command\nto spend more time to compress to smaller size. Supported\nvalues are from -0 (store-only) to -9 (best ratio).\nDefault is -6 if not given."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_TRACE"}, {"role": "assistant", "content": "Enables general trace messages, e.g. alias expansion, built-in\ncommand execution and external command execution. If this variable is set to \"1\", \"2\" or \"true\" (comparison\nis case insensitive), trace messages will be printed to\nstderr. If the variable is set to an integer value greater than 2\nand lower than 10 (strictly) then Git will interpret this\nvalue as an open file descriptor and will try to write the\ntrace messages into this file descriptor. Alternatively, if the variable is set to an absolute path\n(starting with a / character), Git will interpret this\nas a file path and will try to append the trace messages\nto it. Unsetting the variable, or setting it to empty, \"0\" or\n\"false\" (case insensitive) disables trace messages."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-show"}, {"role": "assistant", "content": "Show various types of objects"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %B"}, {"role": "assistant", "content": "raw body (unwrapped subject and body)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Thin web server: `start_tcp_server': no acceptor (RuntimeError) after git branch checkout\nA Rails 3.2.0 app, working fine with Thin web server, both locally and on Heroku cedar stack.\nAfter:\n$ git branch work\n$ git checkout work\n$ rails server\n\nI get:\n=> Booting Thin\n=> Rails 3.2.0 application starting in development on http://0.0.0.0:3000\n=> Call with -d to detach\n=> Ctrl-C to shutdown server\n>> Thin web server (v1.3.1 codename Triple Espresso)\n>> Maximum connections set to 1024\n>> Listening on 0.0.0.0:3000, CTRL+C to stop\nExiting\n/Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/eventmachine-0.12.10/lib/eventmachine.rb:572:in `start_tcp_server': no acceptor (RuntimeError)\nfrom /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/eventmachine-0.12.10/lib/eventmachine.rb:572:in `start_server'\nfrom /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/thin-1.3.1/lib/thin/backends/tcp_server.rb:16:in `connect'\nfrom /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/thin-1.3.1/lib/thin/backends/base.rb:53:in `block in start'\nfrom /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `call'\nfrom /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'\nfrom /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'\nfrom /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/thin-1.3.1/lib/thin/backends/base.rb:61:in `start'\nfrom /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/thin-1.3.1/lib/thin/server.rb:159:in `start'\nfrom /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/handler/thin.rb:13:in `run'\nfrom /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/server.rb:265:in `start'\nfrom /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.0/lib/rails/commands/server.rb:70:in `start'\nfrom /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.0/lib/rails/commands.rb:55:in `block in <top (required)>'\nfrom /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.0/lib/rails/commands.rb:50:in `tap'\nfrom /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.0/lib/rails/commands.rb:50:in `<top (required)>'\nfrom script/rails:6:in `require'\nfrom script/rails:6:in `<main>'\n\nAlso, when I do:\nsudo bundle exec rails server thin -p 3000\n\nI get:\n/Users/peter/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)\nfrom /Users/peter/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'\nfrom /Users/peter/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems.rb:1210:in `gem'\nfrom /Users/peter/.rvm/gems/ruby-1.9.3-p125/bin/bundle:18:in `<main>'\n\nI have bundler 1.0.22 installed. Updated and installed it. Nothing seems to work. Any ideas?"}, {"role": "assistant", "content": "This works for me. Find (zombie?) server (can happen when quitting terminal with server running):\n$ ps ax | grep rails\n\nIf it returns something like:\n33467 s002 S+ 0:00.00 grep rails\n33240 s003 S+ 0:15.05 /Users/Arta/.rbenv/versions/1.9.2-p290/bin/ruby script/rails s -p 3000\n\nkill it, and run anew:\n$ kill -9 33240\n$ rails s"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "how to restore deleted file [duplicate]\nThis question already has answers here:\n \n \n\n\n\nClosed 12 years ago.\n\n\n\n\nPossible Duplicate:\nRestore a deleted file in a Git repo \n\nHow do I restore a file I accidentally removed from my git repository? I know this is a trivial question, but I haven't found the answer in the documentation."}, {"role": "assistant", "content": "git checkout <commit> <path>\nCommits may be specified directly by SHA1, or via a branch or tag. Make sure that the represents the state of the repository when the deleted file was still present. If the commit argument is omitted, the currently checked out commit (HEAD) will be used."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I selectively merge or pick changes from another branch in Git?\nI'm using Git on a new project that has two parallel -- but currently experimental -- development branches:\n\nmaster: import of existing codebase plus a few modifications that I'm generally sure of\nexp1: experimental branch #1\nexp2: experimental branch #2\n\nexp1 and exp2 represent two very different architectural approaches. Until I get further along I have no way of knowing which one (if either) will work. As I make progress in one branch I sometimes have edits that would be useful in the other branch and would like to merge just those.\nWhat is the best way to merge selective changes from one development branch to another while leaving behind everything else?\nApproaches I've considered:\n\ngit merge --no-commit followed by manual unstaging of a large number of edits that I don't want to make common between the branches.\n\nManual copying of common files into a temporary directory followed by git checkout to move to the other branch and then more manual copying out of the temporary directory into the working tree.\n\nA variation on the above. Abandon the exp branches for now and use two additional local repositories for experimentation. This makes the manual copying of files much more straightforward.\n\n\nAll three of these approaches seem tedious and error-prone. I'm hoping there is a better approach; something akin to a filter path parameter that would make git-merge more selective."}, {"role": "assistant", "content": "tl;dr\ngit checkout source_branch -- path/to/file\n# resolve conflicts if any\ngit commit -am '...'\n\n\nI had the exact same problem as mentioned by you above. But I found this clearer in explaining the answer.\nSummary:\n\nCheck out the path(s) from the branch you want to merge,\n $ git checkout source_branch -- <paths>...\n\nHint: It also works without `--` like seen in the linked post.\n\n\nor to selectively merge hunks\n $ git checkout -p source_branch -- <paths>...\n\n\n\nAlternatively, use reset and then add with the option -p,\n $ git reset <paths>...\n $ git add -p <paths>...\n\n\nFinally commit\n $ git commit -m \"'Merge' these changes\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc lines"}, {"role": "assistant", "content": "Compute the dirstat numbers by doing the regular line-based diff\nanalysis, and summing the removed/added line counts. (For binary\nfiles, count 64-byte chunks instead, since binary files have no\nnatural concept of lines). This is a more expensive --dirstat behavior than the changes behavior, but it does count rearranged\nlines within a file as much as other changes. The resulting output\nis consistent with what you get from the other --*stat options."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Github: how to checkout my own repository\n\nI am very new to GitHub.\nI have created a GitHub repository and pushed it from my computer.\nNow I need to work on it from another computer.\nHow can I checkout my own repository? Should I fork it as for other people's repositories?\nIt seems to me a bit silly to fork my own repository, though."}, {"role": "assistant", "content": "On the project page (http://github.com/you/project) there will be a link on the right at the bottom of project tools list with a path to a .git repo \n\nOpen a terminal and type: \ngit clone [link to repo here]\n\nThat will create a local clone of the repo you can work on, then if you follow the instructions on GitHub to add a remote server you can push your changes back.\nSyncing files back and forwards is just as easy;\nComputer A (Had the original git repo)\nComputer B (Has the cloned repo)\nMake some changes on Computer A, then run\ngit push origin master\n\nGo to computer B, then run\ngit pull origin master\n\nTo sync your new changes, make some changes on computer B then push back\ngit push origin master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git apply skips patches\nI'm trying to apply a patch that includes binary files with git apply but only the files are added. I tried running git apply failing.patch -v and it prints something like:\n\nSkipped patch 'file.txt'.\n Checking patch file.bin...\n Applied patch file.bin cleanly.\n\nHow can I find out what's the reason of the skip? As the current message is not very enlightening."}, {"role": "assistant", "content": "I found out the problem by running patch -p1 < failing.patch which printed:\n\ncan't find file to patch at input line 5\n\nand reminded me that I was not in the root directory.\nI can't understand why no one had asked this before and why is the verbose message not verbose.\nAlso, not even the official documentation mentions skipping and possible causes."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker gitweb"}, {"role": "assistant", "content": "Git web interface (web frontend to Git repositories)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to check the version of GitLab?\n\nHow to check which version of GitLab is installed on the server? \nI am about version specified in GitLab changelog:\nhttps://gitlab.com/gitlab-org/gitlab-foss/blob/master/CHANGELOG.md\nFor example: \"6.5.0\", \"6.4.3\", etc.\nСan this be done only through the terminal?\nIs there a way to do that remotely (with browser instead of terminal)?"}, {"role": "assistant", "content": "I have updated my server to GitLab 6.6.4 and finally found the way to get version of GitLab remotely without SSH access to server.\nYou should be logged in to access the following page:\nhttps://your.domain.name/help\nIt shows something similar to:\n\nGitLab 6.6.4 42e34ae\nGitLab is open source software to collaborate on code.\n...\netc."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-submodule - Initialize, update or inspect submodules --recursive"}, {"role": "assistant", "content": "This option is only valid for foreach, update, status and sync commands.\nTraverse submodules recursively. The operation is performed not\nonly in the submodules of the current repo, but also\nin any nested submodules inside those submodules (and so on)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Cloning a Gitlab project to a Google Colab instance using SSH or HTTPS\n\nMy issue is that I would like to connect a Google Colab instance with a Gitlab project, but neither SSH nor HTTPS seem to work. From the error messages, I suspect setting-related issues in Colab. Maybe I have to allow Colab to connect to Gitlab and put it on a whitelist somewhere?\nRunning the following shell commands from a Notebook in Colab while being in the '/content' directory\ngit config --global user.name \"mr_bla\"\ngit config --global user.email \"[email protected]\"\ngit clone https://gitlab.com/mr_bla/mr_blas_project.git\n\nresults in the following error messages:\nCloning into 'mr_blas_project'...\nfatal: could not read Username for 'https://gitlab.com': No such device or address\n\nI have generated SSH keys as I'm used to, but the SSH check\nssh -vvvT [email protected]:mr_bla/mr_blas_project.git\n\nfails, leading to the following error:\nOpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017\ndebug1: Reading configuration data /etc/ssh/ssh_config\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\ndebug2: resolving \"gitlab.com:mr_bla/mr_blas_project.git\" port 22\nssh: Could not resolve hostname gitlab.com:mr_bla/mr_blas_project.git: Name or service not known\n\nTrying the SSH-way to clone a project doesn't work either:\ngit clone [email protected]:mr_bla/mr_blas_project.git\n\nresults in:\nCloning into 'mr_blas_project'...\nHost key verification failed.\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\nThe Google Colab instance is running the following OS:\ncat /etc/os-release\nNAME=\"Ubuntu\"\nVERSION=\"18.04.3 LTS (Bionic Beaver)\"\nID=ubuntu\nID_LIKE=debian\nPRETTY_NAME=\"Ubuntu 18.04.3 LTS\"\nVERSION_ID=\"18.04\"\nHOME_URL=\"https://www.ubuntu.com/\"\nSUPPORT_URL=\"https://help.ubuntu.com/\"\nBUG_REPORT_URL=\"https://bugs.launchpad.net/ubuntu/\"\nPRIVACY_POLICY_URL=\"https://www.ubuntu.com/legal/terms-and-policies/privacy-policy\"\nVERSION_CODENAME=bionic\nUBUNTU_CODENAME=bionic\n\nI've checked, among many others, the following questions without success:\n\nssh: Could not resolve hostname git: Name or service not known fatal: Could not read from remote repository\nfatal: could not read Username for 'https://github.com': No such file or directory"}, {"role": "assistant", "content": "Here is the workflow I follow to persistently version control with GitLab my Google Colab notebooks (with GitHub I guess it would be quite similar).\nI use Personal Access Tokens from GitLab in order to be able to use them in private repositories\nWorkFlow\n\nCreate a Personal Access Token in GitLab\n\nFrom Edit Profile/User Settings go to Access Tokens\n\nThen enter a name (you will have to use it later) for the token and and optional expiry date\nSelect desired scopes:\n\nread_repository: Read-only (pull) for the repository through git clone\nwrite_repository: Read-write (pull, push) for the repository.\n\n\nPress Create personal access token\nSave the personal access token somewhere safe. After you leave the page, you no longer have access to the token.\n\n\n\n\nThen in order to Colab to interact with GitLab you have to store the .git folder of the repository in a Google Drive Folder so it is persistent between Colab sessions\n\nLet's say that you have a folder in Gdrive with some files you want to version control with Git:\n\n/RootGDrive/Folder1/Folder2\n\n\nMount GoogleDrive in the GColab container file system. Let's say you mount it on /content/myfiles within the Colab container File System. You have to execute in a notebook this lines (this outputs an URL you have to go to give OAuth2 access to your Google Drive to the Colab instance).In a cell just run:\nfrom google.colab import drive \ndrive.mount(/content/myfiles)\n\n\nThis mounts on the container File System the root folder of your Google Drive in /content/myfiles/MyDrive\n\n\nOnce mounted change directory executing a magic command with %cd (with !cd will not work, each shell command is executed in a temporary subshell so it is not persistent)\n%cd \"/content/myfiles/MyDrive/Folder1/Folder2\"\n!pwd\n\n\nOnce there you initialize the git repository (this is just the first time, due to the fact that all this is done in your Google Drive means that it is a repository that will persist between sessions, if not once you leave the Google Colab session it would be removed).\n !git init\n\n\nThis creates the .git folder within your Google Drive folder\n\n\nNow you have to configure typical git parameters locally (so it is stored on the .git folder) needed when pushing/pulling (again this has to be done just the first time):\n!git config --local user.email your_gitlab_mail@your_domain.com \n!git config --local user.name your_gitlab_name\n\n\nNow add the remote using the PAT created before (again this is done just the first time):\n\nKey Point: The remote URL format (it has to be over HTTPs) depends on weather the Gitlab project (repo) is under a group/subgroups or not:\n\nUnder a group (there could be /group/subgroup1/subgroup2/.../project.git or just /group/projec.git)\n!git remote add origin https://<pat_name>:pat_code>@gitlab.com/group_name/subgroup1/project_name.git\n\n\nNOT Under a group\n!git remote add origin https://<pat_name>:pat_code>@gitlab.com/your_gitlab_username/project_name.git\n\n\n\n\n\n\nNow the git repository is configured within the Google Drive Folder not just in the File System Container so you can pull/push besides all the usual git commands\n!git add .\n!git commit -m\"First commit\"\n!git push -u origin master\n\n\n\n\n\nAfter this is done the first time now in order to keep \"version controlling\" with Git and GitLab (again I guess it is very similar with GitHub for the Groups feature of GitLab for me is quite valuable) the files in the MyDrive/Folder1/Folder2 you should create a notebook that mounts the Google Drive and the git commands you want while you edit the other files in the folder.\nI would say the best way is to have a parametrized notebook that checks if this is the first time to do the git initialization and so on and if not to just add/commit/push to the GitLab repository.\nCloning\nFor just cloning into the Container FS (or into Google Drive if it is already mounted) it is just use the same remote explained above with git clone:\n\nUnder a group\n !git clone https://<pat_name>:<pat_code>@gitlab.com/group_name/project_name.git\n\n\nNOT Under a group\n !git clone https://<pat_name>:<pat_code>@gitlab.com/gitlab_user_name/project_name.git\n\n\n\nEdit: I am adding the notebook I have created so you can use it to interact between Colab and GitLab called Gitlab_Colab_Interaction.ipynb so you can use it directly from Colab:\nImports\nimport os\nfrom pathlib import Path\n\nParameters\n# Paths\ncontainer_folder_abspath = Path('/content/myfiles')\ngdrive_subfolder_relpath = Path('MyDrive/Colab Notebooks/PathTo/FolderYouWant') # No need to scape the space with pathlib Paths\ngitlab_project_relpath = Path('/group_name/subgroup1/YourProject.git')\n# Personal Access Token\nPAT_name = 'my_pat_name'\nPAT_code = 'XXXX_PAT_CODE_XXXXX'\n\nMount Drive\nfrom google.colab import drive\ndrive.mount(str(container_folder_abspath))\n\n\nfullpath = container_folder_abspath / gdrive_subfolder_relpath # Path objects with the operator /\n%cd $fullpath\n!pwd\n\nInitialization (or not)\ninitialization = True\nfor element in fullpath.iterdir():\n if element.is_dir():\n if element.name == '.git':\n initialization = False\n print('Folder already initialized as a git repository!')\n \n\ngitlab_url = 'https://' + PAT_name + ':' + PAT_code + '@gitlab.com/' + str(gitlab_project_relpath)\nif initialization:\n !git init\n !git config --local user.email [email protected]\n !git config --local user.name your_gitlab_user\n !git remote add origin $gitlab_url # Check that PATs are still valid\n !echo \"GitLab_Colab_Interaction.ipynb\" >> \".gitignore\" # To ignore this file itself if it is included in the folder\n\nelse:\n print(\"### Current Status ###\")\n !git status\n print(\"\\n\\n### Git log ###\")\n !git log\n\nGit Commands\n# Git Add\n!git add *.ipynb # For example to add just the modified notebooks\n\n# Git Commit\n!git commit -m \"My commit message\"\n\n# Git Push\n!git push -u origin master # As of now Gitlab keeps using the name master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to draw (visualise) git workflows [closed]\nClosed. This question is seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. It does not meet Stack Overflow guidelines. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\n We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.\n\n\nClosed 2 years ago.\n\n\nThe community reviewed whether to reopen this question 2 years ago and left it closed:\n\nOriginal close reason(s) were not resolved\n\n\n\n\n\n\n Improve this question\n \n\n\n\nYou sure know those nice git timeline charts, visualising a git branching strategy and workflow.\nI created a git workflow based upon the specific needs of a customer. To hand over my work, I´d prefer not to scan my drawings, nor to fiddle with photoshop. Are there any free tools to create those? (i.e. sure they are - but are any of these especcially well suited for the task?) Ideally theye are web-based, or at least easy to learn for such a one-time-occasion. (No, LaTeX isn´t :) )\nThanks!"}, {"role": "assistant", "content": "You can describe your flow using JS code. Here is GitGraph.js\n\n- a simple JavaScript library which is meant to help you visually presenting git branching stuff like a git workflow, a tricky git command or whatever git tree you'd have in mind."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How does git log --since count?\nI have a simple test repository with just several commits and want to see the date&time filtered log:\n\n$ git log --author=\"automatix\" --since=\"2013-01-30\" --pretty -- test\ncommit ea0719bef142659fa561c9d040b2120012ed0184\nDate: Thu Jan 31 02:03:12 2013 +0100\n\ncommit ab4a8387bc4d9bdb4f67212df77eb1fc3d8b6304\nDate: Thu Jan 31 01:59:11 2013 +0100\n\ncommit a0b027beba2cd03571bb9475b9db9542f8efe990\nDate: Thu Jan 31 01:50:38 2013 +0100\n\ncommit add77c8fe2ba9254c11b98e14facede3420dc51c\nDate: Thu Jan 31 01:48:34 2013 +0100\n\ncommit e6e323c05d37c74fcabeb9186b95c0d49b862e6f\nDate: Thu Jan 31 01:46:27 2013 +0100\n\ncommit 8c286391e54d3fc1e210950b1320fd6f013a8f84\nDate: Thu Jan 31 01:41:27 2013 +0100\n\ncommit 9c880595e57f717383796fa2940f41f0f42f7e2a\nDate: Thu Jan 31 01:38:17 2013 +0100\n\ncommit a95527f36a533e1ecba1aadceea31a9dcbe1a8db\nDate: Thu Jan 31 01:30:00 2013 +0100\n\nThe first selected commit is a95527f36a533e1ecba1aadceea31a9dcbe1a8db from 2013-01-30 01:30:00. 8 commits are selected:\n\n$ git log --author=\"automatix\" --since=\"2013-01-30\" --format=oneline -- test | wc\n 8 34 498\n\nOK. Now I select since 2013-01-31:\n\n$ git log --author=\"automatix\" --since=\"2013-01-31\" --format=oneline -- test | wc\n 0 0 0\n\nWhat? Ok, that should mean, that the since rule excludes the commits of the startdate. Right?\nBut let's go on:\n$ git log --author=\"automatix\" --since=\"2013-01-31 01:30:00\" --pretty -- test\ncommit ea0719bef142659fa561c9d040b2120012ed0184\nDate: Thu Jan 31 02:03:12 2013 +0100\n\ncommit ab4a8387bc4d9bdb4f67212df77eb1fc3d8b6304\nDate: Thu Jan 31 01:59:11 2013 +0100\n\ncommit a0b027beba2cd03571bb9475b9db9542f8efe990\nDate: Thu Jan 31 01:50:38 2013 +0100\n\ncommit add77c8fe2ba9254c11b98e14facede3420dc51c\nDate: Thu Jan 31 01:48:34 2013 +0100\n\ncommit e6e323c05d37c74fcabeb9186b95c0d49b862e6f\nDate: Thu Jan 31 01:46:27 2013 +0100\n\ncommit 8c286391e54d3fc1e210950b1320fd6f013a8f84\nDate: Thu Jan 31 01:41:27 2013 +0100\n\ncommit 9c880595e57f717383796fa2940f41f0f42f7e2a\nDate: Thu Jan 31 01:38:17 2013 +0100\n\ncommit a95527f36a533e1ecba1aadceea31a9dcbe1a8db\nDate: Thu Jan 31 01:30:00 2013 +0100\n\n$ git log --author=\"automatix\" --since=\"2013-01-31 01:30:00\" --format=oneline -- test | wc\n 8 34 498\n\nNow, when I'm writing the starttime as well, the commits of the starttime are included .\nI don't understand the logic. Can anybody explain, why it works so strange?\nThanks"}, {"role": "assistant", "content": "In case it helps someone else who lands here like I did, after a bit of researching I found out that using ISO8601 format also works:\ngit log --since=\"2014-02-12T16:36:00-07:00\"\n\nThis will give you precision down to the second. Note: you can also use:\ngit log --after=\"2014-02-12T16:36:00-07:00\"\ngit log --before=\"2014-02-12T16:36:00-07:00\"\ngit log --since=\"1 month ago\"\ngit log --since=\"2 weeks 3 days 2 hours 30 minutes 59 seconds ago\"\n\netc.\nOf course, this doesn't \"explain why it works so strange.\" However, it certainly solved the problem for me.\n\nEDIT:\nAfter a bit more research, I found out \"why it works so strangely\":\nIt turns out that when you don't specify a date format, git log defaults to either the author's timezone or commit dates, meaning for consistent behavior, it's useful to explicitly declare your date format with something like:\ngit log --date=local\n\nLastly, when you don't specify a time, it defaults to your local time when you ran the command.\nLong story short, being specific should solve the problem:\ngit log --date=local --after=\"2014-02-12T16:36:00-07:00\"\n\nAlso, you can set the default date format permanently with the following command:\ngit config log.date local\n\nyou can use any one of these values: (relative|local|default|iso|rfc|short|raw)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What to do about \"PTY allocation request failed on channel 0\"\n\nI can't see to wrap my head creating an ssh key for GitHub. I had it working quite awhile back but I can't figure out what has changed. I've since removed the previous SSH keys from my GitHub account. After following the instructions several times for generating an SSH key (http://help.github.com/mac-key-setup) and testing \"ssh [email protected]\" I get the following; \n\nPTY allocation request failed on\n channel 0 ERROR: Hi...successfully\n authenticated...GitHub does not\n provide shell access...Connection to\n github.com closed.\n\nI reviewed the troubleshooting guide and noticed that my ssh directory didn't have a config file. After creating it I'm unsure of what or how to enter the local path on the IdentityFile line. I'm not even sure whether this is necessary in my case? \n\nIf your github authentication\n information is different from your\n machine account information, you’ll\n need to modify your ssh configuration\n file.\nCreate or open the file at\n ~/.ssh/config Add the following lines:\n\nHost github.com\n User git\n Hostname github.com\n PreferredAuthentications publickey\n IdentityFile [local path to private key half of github public key you provided]\n\n\nYou may also need to update the\n permissions on your .ssh folder and\n its contents. The SSH application will\n ignore secret files that are too\n permissive.\n\n$ chmod 700 ~/.ssh\n$ chmod 600 ~/.ssh/*\n\nI also ran ssh -v [email protected] the results of which can be seen here http://gist.github.com/607283 nothing different from what I can tell.\nAny idea what I'm doing wrong?"}, {"role": "assistant", "content": "As described in the comments on the question, the “PTY allocation request failed” is a red herring with respect to GitHub authentication (it is the result of trying to interactively login to GitHub when the only SSH service they offer is non-interactive Git-over-SSH; the authentication is working, they just do not provide interactive, “shell” service).\n\nThe person who asked the question wrote this in a comment: \n\nI guess the related problem is that when I try to create a new repository and \"git push origin master\" I return the following \"Error: Permission to [email protected]/myapp denied to myusername. Fatal: the remote end hung up unexpectedly\"\n\nThis seems more likely to be the actual problem. This seems to indicate that the remote named origin not configured to correctly point to a GitHub repository.\nCheck the output of git remote show -n origin. Probably the “Fetch URL” and the “Push URL” are the same. They should both look like this:\n[email protected]:git-user-name/repository-name\n\nWhen logging into GitHub on the web you can use either your account’s username or its associated email address. When pushing to repositories (or fetching from private repositories) you have to use your actual username (an email address will not work). It looks you are using your email address in there instead of just your GitHub username. To fix this, reconfigure the remote’s URL:\ngit remote set-url origin [email protected]:github-username/repository-name\n\nYour username is displayed in many places on the GitHub web pages once you are logged in. The easiest place to find it is between your gravatar and the “Dashboard” link on the page header (you will see a silhouette icon if you do not have a gravatar configured). That same location links to your public profile page; this page’s URL should also end in your username."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I generate a new ssh-key for my new gitlab account?\n\nI have two Gitlab accounts. On my old account I added an ssh-key that is located in ~/.ssh/id_rsa.pub on my computer. \nNow I want to add another ssh-key for my new Gitlab account. How do I do this without having the ssh-keys conflict?"}, {"role": "assistant", "content": "I would recommend a second key, for now without passphrase:\nssh-keygen -t rsa -C \"[email protected]\" -P \"\" -q -f ~/.ssh/gitlab_rsa\n\nThat will create (without any prompt) ~/.ssh/gitlab_rsa (private key) and ~/.ssh/gitlab_rsa.pub (public key)\nYou need to register that second gitlab_rsa.pub public key to your second GitLab account.\n\nNavigate to the 'SSH Keys' tab in your 'Profile Settings'. Paste your key in the 'Key' section and give it a relevant 'Title'. \n\nThen add a ~/.ssh/config file with:\nHost gitlab_rsa\n HostName gitlab.com\n User git\n PreferredAuthentications publickey\n IdentityFile /home/<you>/.ssh/gitlab_rsa\n\nFinally, you can clone any GitLab repo as your second identity with:\ngit clone gitlab_rsa:<yourSecondAccount>/<yourRepo.git>\n\nThat will be replaced automatically with [email protected]:<yourSecondACcount>/<yourRepo.git> and will use your second key."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options blame.showEmail"}, {"role": "assistant", "content": "Show the author email instead of author name in git-blame .\nThis option defaults to false."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What \"Hack\" means in the languages bar on gitlab\n\nI've noticed, on the languages bar, that 1.3% of the languages used on my project are \"Hack\".\nI was just wondering what this \"hack\" actually means ?"}, {"role": "assistant", "content": "As explained in this issue: https://github.com/github/linguist/issues/4229#issuecomment-412846757\nA php file is considered a hack file by Gitlab and Github when there is only HTML code in it."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What happens to git commits created in a detached HEAD state?\nThis is what happened:\nI have a branch A. On branch A I committed a bunch of changes. I was not happy with the code, so I checked out the previous commit in branch A. I then made a bunch more changes and committed them on branch A. Now I can not find this commit anywhere. Did I lose this code?"}, {"role": "assistant", "content": "The old commit is still in the reflog.\ngit reflog\n\nThis will show a list of commits, and the \"lost\" commit should be in there. You can make it into a new branch. For example, if the SHA-1 is ba5a739, then you can make a new branch named \"new-branch\" at the old commit with:\ngit branch new-branch ba5a739\n\nNote that \"lost\" commits will get deleted when the database is pruned."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-archive - Create an archive of files from a named tree git archive -o latest.tar --prefix=build/ --add-file=configure --prefix= HEAD"}, {"role": "assistant", "content": "Creates a tar archive that contains the contents of the latest\ncommit on the current branch with no prefix and the untracked\nfile configure with the prefix build/ ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff-index - Compare a tree to the working tree or index -W --function-context"}, {"role": "assistant", "content": "Show whole function as context lines for each change.\nThe function names are determined in the same way as git diff works out patch hunk headers (see Defining a\ncustom hunk-header in gitattributes )."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to migrate code from SVN to GIT without losing commits history? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do I migrate an SVN repository with history to a new Git repository?\n\n (34 answers)\n \n\nClosed 9 years ago.\n\n\n\nI would like to know the recommended way to move our code from a SVN repository to a GIT repository, so that we transition our developers team & start using GIT.\nCan we do the transition and keep all the commits done in the SVN repository ?\nAlso, our team is happy with SVN currently, but, they don't know that branching in GIT is much easier than SVN, where can I find a practical example that proves power of GIT in branching ?"}, {"role": "assistant", "content": "Eric Raymond (esr) has created reposurgeon, “a command interpreter for performing tricky editing operations on version-control histories.” The tool includes scripts for various purposes, including cleaning up the results of VCS conversions. Check it out from https://gitlab.com/esr/reposurgeon.\nAs of version 2.0 it includes support for reading SVN dumpfiles for complete and idiomatic translation to Git, Mercurial, etc.; see http://esr.ibiblio.org/?p=4071 for details. Reposurgeon has been used to convert several large projects to Git, including Emacs whose repository, ESR says, “is large, complex in branch structure, and old enough to have begun life as a CVS repo. That last part matters because some of the ugliest translation problems lurking in the back history of Subversion projects are strange Subversion operation sequences (including combinations of branch copy operations) generated by cvs2svn.”\n(The git-svn tool included with Git will handle many Subversion repositories, including branches. It’s pretty commonly used, especially by teams that are in the process of doing a conversion, since it allows Git to behave as a Subversion client. But see ESR’s Don’t do svn-to-git repository conversions with git-svn!, where he discusses the drawbacks to git-svn as a conversion tool.)\nRegarding your second question, it isn’t branching where the power of Git is so helpful (though Git is at least as powerful as Subversion in this regard); it’s when it comes to merging those branches that Git shines. Read through the Git Community Book, especially the section in chapter 3 titled “Basic Branching and Merging” and the section in chapter 7 titled “Advanced Merging”."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I list all the files in a commit?\nHow can I print a plain list of all files that were part of a given commit?\nAlthough the following lists the files, it also includes unwanted diff information for each:\ngit show a303aa90779efdd2f6b9d90693e2cbbbe4613c1d"}, {"role": "assistant", "content": "Preferred Way (because it's a plumbing command; meant to be programmatic):\n$ git diff-tree --no-commit-id --name-only bd61ad98 -r\nindex.html\njavascript/application.js\njavascript/ie6.js\n\nAnother Way (less preferred for scripts, because it's a porcelain command; meant to be user-facing)\n$ git show --pretty=\"\" --name-only bd61ad98 \nindex.html\njavascript/application.js\njavascript/ie6.js\n\n\n\nThe --no-commit-id suppresses the commit ID output.\nThe --pretty argument specifies an empty format string to avoid the cruft at the beginning.\nThe --name-only argument shows only the file names that were affected (Thanks Hank). Use --name-status instead, if you want to see what happened to each file (Deleted, Modified, Added)\nThe -r argument is to recurse into sub-trees"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git Example:"}, {"role": "assistant", "content": "Assume you have local changes in \"master\", but you need to refetch \"r2\". r1---r2---r3 remotes/git-svn\n \\\n A---B master Fix the ignore-paths or SVN permissions problem that caused \"r2\" to\nbe incomplete in the first place. Then: git svn reset -r2 -p\ngit svn fetch r1---r2'--r3' remotes/git-svn\n \\\n r2---r3---A---B master Then fixup \"master\" with git rebase .\nDo NOT use git merge or your history will not be compatible with a\nfuture dcommit ! git rebase --onto remotes/git-svn A^ master r1---r2'--r3' remotes/git-svn\n \\\n A'--B' master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-mergetool - Run merge conflict resolution tools to resolve merge conflicts mergetool.prompt"}, {"role": "assistant", "content": "Prompt before each invocation of the merge resolution program."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Failed to install gitlab-runner: Init already exists\n\nI installed gitlab-runner via sudo apt install gitlab-runner, configured it according to the tutorial and it worked well. \nNow I want to change the user of the gitlab-runner. So I stop the service with service gitlab-runner stop and try to change the user via \nsudo gitlab-runner install --user=my-user --working-directory=/home/my-user \n\nI get following error message:\n\nFATAL: Failed to install gitlab-runner: Init already exists: /etc/systemd/system/gitlab-runner.service\n\nHow to proceed?"}, {"role": "assistant", "content": "Rename the init file with \nsudo mv /etc/systemd/system/gitlab-runner.service /etc/systemd/system/gitlab-runner.service.bak\n\nand execute again\nsudo gitlab-runner install --user=my-user --working-directory=/home/my-user\n\ncleanup the backup file\nsudo rm /etc/systemd/system/gitlab-runner.service.bak\n\n\nFinally you can start the runner again with service gitlab-runner start."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to do Git Log see only merges to master branch?\nIn my work process I need to provide a list of files to my server admin.\nThe list comes from the merge of my working branch (Branch A) into Master branch.\nSo I merge branch A into branch Master and then deploy Master.\nRight now the best I could do with git log is the following but this list contains other commit as well ( not only the merge I'm looking for ):\ngit log -m --name-only --author=[NAME]\nSo basically I need to retrieve the files list for the merge of Branch A into Master Branch\nIs it possible with cli command ?"}, {"role": "assistant", "content": "Narrow it down using git log --merges --author to figure out the commit you want and then try \ngit diff --name-only ${MERGE_SHA}^1..${MERGE_SHA}"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs dense-combined, cc"}, {"role": "assistant", "content": "Further compress output produced by --diff-merges=combined by omitting uninteresting hunks whose contents in the parents\nhave only two variants and the merge result picks one of them\nwithout modification."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %cL"}, {"role": "assistant", "content": "committer local-part (see %cl ) respecting .mailmap, see git-shortlog or git-blame )"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --no-color-moved"}, {"role": "assistant", "content": "Turn off move detection. This can be used to override configuration\nsettings. It is the same as --color-moved=no ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Proper Way To Use Git/GitHub - PHP System with Dev/Testing/Production servers\nI apologize if this is obvious or easy, I have looked at a good number of git/github tutorials and read other articles, but I want to make sure what I'm doing is right.\nI want to incorporate VC (for obvious reasons) into my development team and process.\nCurrent development process (using Dreamweaver):\n * Receive a ticket (or work order)\n * Download file on Development server\n * Make changes to the file\n * Upload file back to development server\n * Changes tested/verified\n * Send to production server \n\nI'm trying to figure out how to make our new development process with using Git.\nI am switching over to PHPStorm (which is an actual PHP IDE with direct integration with Git).\nWould it be something like\n\nReceive a ticket (or work order) \nCheckout/Update/Download file(s) \nChange Files \nUpload file (which I assume is also the current working directory...?) \nAt the end of the day, do a commit \nHave build script send data to testing server (nightly build) \n\nOr would it be better to do something like \n\nReceive a ticket (or work order) \nCheckout/Update/Download file(s) \nChange Files \nUpload file/commit\nHave build script send data to testing server (nightly build) \n\nOr is there another way? Having a bit of trouble understanding what would be the optimal flow?\nAny help would be greatly appreciated.\n\nEdit\nI'm trying see if it is best to have a version of the server locally (every developer), and if so, how does that work if you have 7 or so branches?\nIf not, how do you deal with 7 or so branches with them on the web? Do you FTP files up or use Git Hooks to make them auto update?\nUpdate 07/26/2012 \nAfter working successfully with Git for quite a while now I've been following this branching model with great success:\nA Successful Git Branching Model\nThe answer to the above was yes -- should definitely have a local version of the server."}, {"role": "assistant", "content": "Assuming you have a live server and a development server I would do something along these lines.\nBefore even starting with a development cycle I would at least have two branches:\n\nMaster - the development server runs on this branch\nStable - the live server runs on this branch.\n\nSo if a developer gets a ticket or a work order he/she will perform the following actions:\n\ngit pull origin master\ngit branch featureBranch (named as the ticket id or as a good description for the work order)\ngit checkout featureBranch\nMake changes which will accomplish the desired change. Commit as often as is necessary. Do this because you will create valuable history. For instance you can try an approach to a problem and if it doesn't work, abandon it. If a day later you see the light and want to re-apply the solution, it is in your history!\nWhen the feature is fully developed and tested locally, checkout master.\ngit merge featureBranch\ngit push origin master\nTest the pushed changes on your development server. This is the moment to run every test you can think of.\nIf all is working out, merge the feature or fix into the stable branch. Now the change is live for your customers.\n\nGetting the code on the server\nThe updating of servers shouldn't be a problem. Basically I would set them up as users just like you're developers are. At my company we've setup the servers as read-only users. Basically that means the servers can never push anything but can always pull. Setting this up isn't trivial though, so you could just as well build a simple webinterface which simply only allows a git pull. If you can keep your developers from doing stuff on live implementations you're safe :)\n[EDIT]\nIn response to the last questions asked in the comments of this reaction:\nI don't know if I understand your question correctly, but basically (simplified a bit) this is how I would do this, were I in you shoes.\n\nThe testing machine (or the webroot which acts as testing implementation) has it source code based in a git repository with the master branch checked out. While creating this repository you could even remove all other references to all other branches so you'll be sure no can checkout a wrong branch in this repository. So basically the testing machine has a Git repository with only a master branch which is checked out.\nFor the live servers I would do exactly the same, but this time with the stable branch checked out. Developer should have a local repository cloned in which all branches exist. And a local implementation of the software you guys build. This software gets its source from a the local git repository. In other words: from the currently checked out branch in this repository.\nActual coding\nWhen a new feature is wanted, a local feature branch can be made based on the current master. When the branch is checked out the changes can be made and checked locally by the developer (since the software is now running on the source of the feature branch).\nIf everything seems to be in order, the changes get merged from feature branch to master and pushed to your \"git machine\". \"your github\" so to speak. Testing can now pull the changes in so every test necessary can be done by QA. If they decide everything is ok, the developer can merge the changes from master to stable and push again.\nAll thats left now is pulling form your live machines."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-branch - List, create, or delete branches --points-at <object>"}, {"role": "assistant", "content": "Only list branches of the given object."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do you change the capitalization of filenames in Git?\nI am trying to rename a file to have different capitalization from what it had before:\ngit mv src/collision/b2AABB.js src/collision/B2AABB.js\nfatal: destination exists, source=src/collision/b2AABB.js, destination=src/collision/B2AABB.js\n\nAs you can see, Git throws a fit over this. I tried renaming using just the plain old mv command as well, but Git doesn't pick up the rename (as a rename or as a new untracked file).\nHow can I change a file to have a different capitalization of the same name? I am on Mac OS X v10.7.3 (Lion) with Git 1.7.9.1 using Z shell (zsh) 4.3.15."}, {"role": "assistant", "content": "Starting Git 2.0.1 (June 25th, 2014), a git mv will just work on a case-insensitive OS.\nSee commit baa37bf by David Turner (dturner-tw).\nmv: allow renaming to fix case on case-insensitive filesystems\n\"git mv hello.txt Hello.txt\" on a case-insensitive filesystem always triggers \"destination already exists\" error, because these two names refer to the same path from the filesystem's point of view and requires the user to give \"--force\" when correcting the case of the path recorded in the index and in the next commit.\n\nDetect this case and allow it without requiring \"--force\".\n\ngit mv hello.txt Hello.txt just works (no --force required anymore).\n\nThe other alternative is:\ngit config --global core.ignorecase false\n\nAnd rename the file directly; git add and commit.\nIt does work in a CMD. It might fail in a git bash (on Windows) session (see Louis-Caron's answer)\nAs noted by jaquinocode in the comments, if your local repository itself has that setting:\ngit config --local core.ignorecase false"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database --verbose"}, {"role": "assistant", "content": "Be chatty."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-index-pack"}, {"role": "assistant", "content": "Build pack index file for an existing packed archive"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-reset - Reset current HEAD to the specified state Undo a merge or pull inside a dirty working tree"}, {"role": "assistant", "content": "$ git pull (1) Auto-merging nitfol\nMerge made by recursive.\n nitfol | 20 +++++----\n ...\n$ git reset --merge ORIG_HEAD (2) Even if you may have local modifications in your\nworking tree, you can safely say git pull when you know\nthat the change in the other branch does not overlap with\nthem. After inspecting the result of the merge, you may find\nthat the change in the other branch is unsatisfactory. Running git reset --hard ORIG_HEAD will let you go back to where you\nwere, but it will discard your local changes, which you do not\nwant. git reset --merge keeps your local changes."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Best Practices for using Git with Intellij Idea\nIn a nutshell: what are best practices for using Intellij Idea (9) and Git?\nContext\nWe recently upgraded to Intellij idea version 9 and have started to use Git for a new feature on existing project. \nWe largely use git command line to learn the tool better. But we thought we'd pick the hive-mind to find out what are best practices for git with idea.\nThe Idea UI is similar for both CVS and Git, yet the underlying implementations differ a bit.\nExample Questions\nFor example:\n-With CVS, when we had multiple release of a product, each of us would have a local copy of the 1-0, 2-0, 3-0, etc. branches , each with its own Intellij files (i.e. .ipr, .iws, etc.). The \"git way\" seems to have one project and use 'git branch' to switch branches. This is fine, but it creates huge overhead for idea (as it has to reload each changed file, including checked-in jars) when you change branches. So: do you still have a separate project (with .git) for each \"major release\" or have one project and use \"git branch\"?\n-Is it a good idea to use Autostash?\n-Do you automatically add each modification to your git commit? or use \"git add\" later?\n-Do you rebase?\n-Best way to merge?\n-Any other hints/tips/what-works-for-you,etc.\nFinal Comments\nWe still \"think in cvs\" so part of this is getting used to git; part is getting used to Idea's Ui for git. \nThese are fairly rudimentary questions as we still use the comand line primarily. Also I've heard idea 10 has better/stronger/faster git integration tools\nThanks"}, {"role": "assistant", "content": "Here's what we've found after several weeks of Git/Idea. I've made this a community wiki. Please throw in your 2 kronor/centimos/pfennings/cents. \nNote: I'm answering my own question because I sought those easy-use bullet points.\nPresupposition\nIdea is great tool. No one here is complaining. Just observing.\nBest Practices\n\nAt this point (9.0.3) Git with Idea is just plain harder to use than SVN with Idea. Part stems from the complexity of Git (vs SVN), partly because Idea's tools don't do everything in the git world.\nThus you will need to use the command line\nIdea's merge tool works much better than command line merging or even using mergetool (using meld or mergetool). The reason: you have much more freedeom to work in the 'idea environment' rather than fixe one lint at a time.\nRemember to synchronize in Idea (ctrl-alt-y) when you update the working tree from the command line\nWatching the Git Console to learn idea's git tricks; idea executes git commands there.( Version Control view, Console tab):\n\nexample:\n13:30:58.234: git log -M --follow --name-only --pretty=format:%H%x00%ct%x00%an%x20%x3C%ae%x3E%x00%cn%x20%x3C%ce%x3E%x00%s%n%n%b%x00 --encoding=UTF-8 -- src/jsp/workspaces/include/edit.jsp\n13:31:02.437: cd J:\\projects\\PE-GIT\\pe\n13:31:02.437: git annotate -p -l -t -M HEAD -- src/jsp/workspaces/include/edit.jsp\n\n\nUnfortunately Idea does not have good tools for \"merging conflicts in upstream commits\" in 9.0.3\n\nExample:\n\nAlice does work, commits (locally)\nfile A, commits file B, commits file\nC \nBob does work, commits file C, commits file D, commits file E \nAlice pushes her changes \nBob Pulls his changes\n\nComing from CVS/SVN, I expected Ideas handy diffing tool to pop up. No. Instead git/idea throw up a red flag, I usually end up using \"git mergetool\" (meld od on linux, tortoiesmerge on windows).\nNote: Perhaps Idea provides a better way. Please set me straight.\nNote to the motivated: can you set up .gitconfig to use Idea's diffing tool?\nStashing\n\nIdeas \"Shelve\" functionality duplicates \"Git Stash\". Both seem similar. Both use patches. You probably want to use one or the other. I haven't figured out the advantage of one or the other\n\nBig Old Projects\n\nIf you're working on a decade old project recently migrated to Git, with jar files checked into the scm (i.e. previously checked into CVS/SVN, where log4j-1.0.jar is in BRANCH-2-0 and the mainline has log4j-9.0.jar ), PROCEED WITH CAUTION if you want to checkout \"version 2.0\" of your project. Idea needs to unload all the \"head\" jars and reload the jars-checked-in-at-2.0. This takes for-ever. \n\nOther little stuff\n\nThe idea menus/UI still shows \"git init...\" even though you've already initialized Git. It's confusing, but ignore it.\nYou cannot have the same working tree in both Git and CVS/SVN (though the UI may seem to imply so). I/we tried this during an initial \"let's try git and still use CVS as a backup plan\" phase. It didn't work"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is it possible to pull from one repo and push to other one?\nI have one repo in github which is public, there I have an Open source application i'm working on that is for making product catalogs, and small cms content.\nI also have a private repository (not hosted in github) which is an application developed under the open source application hosted in github.\nSince I'm currently working on both applications, adding features in the open source one and also making changes in the private one like changing the template and also pulling the code from the open source one.\nI was wondering if there is any way in which I could pull the new stuff from the open source one but also pushing the code of the new application to the other repo."}, {"role": "assistant", "content": "Set a push URL for the remote that is different from the pull URL:\ngit remote set-url --push origin [email protected]:repo.git\nThis changes the remote.name.pushurl configuration setting. Then git pull will pull from the original clone URL but git push will push to the other.\n\nIn old Git versions, git remote set-url did not have the --push switch. Without it, you have to do this by changing the configuration setting manually:\ngit config remote.origin.pushurl [email protected]:repo.git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-shortlog - Summarize git log output"}, {"role": "assistant", "content": "MAPPING AUTHORS See gitmailmap . Note that if git shortlog is run outside of a repository (to process\nlog contents on standard input), it will look for a .mailmap file in\nthe current directory."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I pull from remote Git repository and override the changes in my local repository? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nReset local repository branch to be just like remote repository HEAD\n\n (27 answers)\n \n\nClosed 9 years ago.\n\n\n\nI need to throw away all the changes in my local repository and pull all the code from the remote repository. What is the Git command to do this?"}, {"role": "assistant", "content": "Provided that the remote repository is origin, and that you're interested in master:\ngit fetch origin\ngit reset --hard origin/master\n\nThis tells it to fetch the commits from the remote repository, and position your working copy to the tip of its master branch. \nAll your local commits not common to the remote will be gone."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc default"}, {"role": "assistant", "content": "Is a synonym for zebra . This may change to a more sensible mode\nin the future."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-show-ref"}, {"role": "assistant", "content": "List references in a local repository"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-shortlog - Summarize git log output --cherry-pick"}, {"role": "assistant", "content": "Omit any commit that introduces the same change as\nanother commit on the “other side” when the set of\ncommits are limited with symmetric difference. For example, if you have two branches, A and B , a usual way\nto list all commits on only one side of them is with --left-right (see the example below in the description of\nthe --left-right option). However, it shows the commits that were\ncherry-picked from the other branch (for example, “3rd on b” may be\ncherry-picked from branch A). With this option, such pairs of commits are\nexcluded from the output."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Github Comparison View for 2 branches is incorrect?\nWhen I do a Github comparison view between master and another branch A, Github seems to be comparing the HEAD version of A with an older, non head version of master.\nI looked into it, and from what I can tell it sounds like Github is comparing branch A against a common ancestor of master. It's not actually comparing it to what's currently at the HEAD of master.\nIs there a way to diff the HEAD of master against the HEAD of Branch A in Github?\nIf not, why not? This seems like a feature every developer would want to be able to do. Or is there some process that should be done that I'm perhaps missing? I'd like to be able to create a Pull Request directly from one of these diffs.\nEDIT: Here's an example repo that shows the problem\nhttps://github.com/bradparks/test_github_diff_view\n\nI created a new repo that contains a single file, README.md\nI set this file to contain a single line v100.\nI then branched master into a new branch A, and changed the line to `v200'\nI then changed the value in the master branch to 'v300', and then compared the 2 branches using the compare link\nhttps://github.com/bradparks/test_github_diff_view/compare/A\nand I see the following unexpected result. Why isn't it diffing against v300 instead of v100?"}, {"role": "assistant", "content": "Is there a way to diff the HEAD of master against the HEAD of Branch A in Github?\n\nSept 2018: yes: GitHub now explicitly supports \"Three-dot and two-dot Git diff comparisons\". See an example here.\nkeisuke mentions in the comments a similar initiative on Bitbucket.\nOriginal answer 2015:\nNo: as mentioned in \"GitHub compare view for current versions of branches\", GitHub only supports the triple dots (...) range shortcut specification.\nThat is:\n\nThis form is to view the changes on the branch containing and up to the second , starting at a common ancestor of both.\n\"git diff A...B\" is equivalent to \"git diff $(git-merge-base A B) B\".\nYou can omit any one of , which has the same effect as using HEAD instead.\n\nThe official GitHub help mentions this feature as:\n\nThe most common use of Compare is to compare branches, such as when you're starting a new Pull Request.\n\nIn that scenario, the PR branch starts from master (or should be rebased on top of master anyway), which means master HEAD is the base between master and the PR branch.\nBut when the two branches have forked, the comparison is no longer between HEADs, but between one common ancestor and one HEAD: git diff $(git-merge-base master B) B.\nNote: even if you were to specify two SHA1 directly, as it is clearly documented in \"Comparing commits\", that would still do a git diff $(git-merge-base A B) B.\nThat would not do a diff directly between the two commits."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitHub - HTTPS access\n\nI am unable to clone my repository via HTTPS:\ngit clone https://github.com/walterjwhite/project.configuration.git\n\nOutput:\nInitialized empty Git repository in ./project.configuration/.git/\nerror: Failed connect to github.com:443; Connection refused while accessing https://github.com/walterjwhite/project.configuration.git/info/refs\nfatal: HTTP request failed\n\nI have configured the .netrc file with my login and password as well as the machine or server I am connecting to."}, {"role": "assistant", "content": "As you did saw yourself in GitHub support, Scott Schacon himself suggested:\n\nSo I guess your .netrc is incorrect or something?\n Try removing the info from your .netrc and cloning first (since it's a public repo).\n\nIf it isn't a GitHub server issue, it could be your firewall.\nAnd/or your proxy (git config --global http.proxy http://user:password@proxy:xxx)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git pull and resolve conflicts\nI am learning git and I have a scenario:\n\nMy coworker makes changes and pushes the changes to the master.\nI make changes locally to my master.\n\nSo far from my understanding, at this point I can either:\n\nPull the master that my coworker worked on and fix the merge conflicts that I will end up having. \nCreate a back up of my local, clone a new copy of the master, and then merge my changes to the master. \n\nI want to know if there is any better way of doing this."}, {"role": "assistant", "content": "If there are different changes on both the remote and the local branch, instead of just pulling the master by git pull, I rather would do:\ngit pull --rebase\n\nI even have it in my default config so that it will always will do a rebase if required on git pull:\ngit config --global pull.rebase true\n\nA rebase avoids a merge commit and keeps your changes on top of the current remote branch.\nYet you still have to resolve any occurring merge conflicts when different people are working on the same branch, which is a bad practice especially because it leads to conflicts.\n(Also be aware that in the scope of a rebase, the meaning of theirs and ours is switched.)\nIn cases with minor changes, yours are just applied on the top.\nYou are changing the history, yet only your local one, not the remote's.\nYou won't need to git push --force. You just git push it as you are used to it.\nIn general, you should be working on feature branches and merge those back to the master branch.\nWhen working on feature branches one can also keep the feature branch close to the master by:\ngit checkout feature-branch\ngit fetch && git rebase origin/master\n\nYet here one would need to git push --force the feature-branch, so one should be careful not to use this strategy if more than one person is working on the same feature-branch.\nIf one wants to use rebase and push forcing, consider using git push --force-with-lease over git push --force as it prevents accidentally deleting other's commits on the remote."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git Bash: Could not open a connection to your authentication agent [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nCould not open a connection to your authentication agent\n\n (43 answers)\n \n\nClosed 4 years ago.\n\n\n\nI'm new to Github and Generating SSH Keys look a neccessity. And was informed by my boss about this, so I need to comply.\nI successfully created SSH Key but when I'm going to add it to the ssh-agent\nthis is what happens\nWhat seems to be the problem?"}, {"role": "assistant", "content": "It seems you need to run ssh-agent before using it:\neval `ssh-agent -s`\n\nThat question was answered in this topic: Could not open a connection to your authentication agent"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git diff against a stash\nHow can I see the changes un-stashing will make to the current working tree? I would like to know what changes will be made before applying them!"}, {"role": "assistant", "content": "See the most recent stash:\ngit stash show -p\n\nSee an arbitrary stash:\ngit stash show -p stash@{1}\n\nFrom the git stash manpages:\n\nBy default, the command shows the diffstat, but it will accept any\n format known to git diff (e.g., git stash show -p stash@{1} to view\n the second most recent stash in patch form)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-read-tree - Reads tree information into the index -m"}, {"role": "assistant", "content": "Perform a merge, not just a read. The command will\nrefuse to run if your index file has unmerged entries,\nindicating that you have not finished a previous merge you\nstarted."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %b"}, {"role": "assistant", "content": "body"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "unable to remove file that really exists - fatal: pathspec ... did not match any files\nunable to remove file that really exists - fatal: pathspec ... did not match any files\n\nI have a file under git control that simply will not be deleted. The failing command is:\n$ git rm .idea/workspace.xml\nfatal: pathspec '.idea/workspace.xml' did not match any files\n\nBelow I list the directory contents, branches, etc. So far I've tried rm from within the directory, and escaping just in case there are funny characters, and I'm really stumped. I searched the web and SO but couldn't find this specifically.\n$ git branch -a\n* dot-output\n master\n remotes/origin/HEAD -> origin/master\n remotes/origin/master\n remotes/origin/modelspace\n$ \n\n$ git status\n# On branch dot-output\n# Untracked files:\n# ...\n\n$ ls .idea/\nant.xml encodings.xml modules.xml workspace.xml\ncompiler.xml inspectionProfiles scopes\ncopyright libraries testrunner.xml\ndictionaries misc.xml vcs.xml\n\n$ ls -al\ntotal 56\ndrwxr-xr-x 16 matt staff 544 Apr 10 11:33 .\ndrwxr-xr-x@ 33 matt staff 1122 Apr 10 09:40 ..\n-rw-r--r--@ 1 matt staff 12292 Apr 10 11:19 .DS_Store\ndrwxr-xr-x 18 matt staff 612 Apr 10 11:39 .git\n-rw-r--r-- 1 matt staff 98 Mar 6 13:40 .gitignore\ndrwxr-xr-x 16 matt staff 544 Apr 10 11:34 .idea\n-rw-r--r-- 1 matt staff 1113 Feb 25 11:07 README\n...\n\n$ head -n 2 .idea/workspace.xml\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n\n$ git rm .idea/workspace.xml\nfatal: pathspec '.idea/workspace.xml' did not match any files\n\nUpdate\nAnswers from @Nevik and @Boris helped a lot. I realized that I was confused by a number of things going on, some of which were exacerbated by IntelliJ IDEA (a tool I generally love, BTW). First, the 'fatal: pathspec' message from git rm is both unhelpful and misleading.\nSecond, I had the file in .gitignore, but had removed it before asking my question. However, it was also included in IDEA's Ignored Files feature independently of git, and showed as such in the project viewer (instead of untracked, as git status showed). Finally, I had IDEA running while I was experimenting, and it looks like it was recreating the file immediately after my rm.\nMy takeaway is that if I'm getting confusing Git behavior, make sure to quit IDEA and work solely in the command line (and gitk) while debugging."}, {"role": "assistant", "content": "Your file .idea/workspace.xml is not under git version control. You have either not added it yet (check git status/Untracked files) or ignored it (using .gitignore or .git/info/exclude files)\nYou can verify it using following git command, that lists all ignored files:\ngit ls-files --others -i --exclude-standard"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-daemon - A really simple server for Git repositories --log-destination=<destination>"}, {"role": "assistant", "content": "Send log messages to the specified destination.\nNote that this option does not imply --verbose,\nthus by default only error conditions will be logged.\nThe <destination> must be one of: stderr Write to standard error.\nNote that if --detach is specified,\nthe process disconnects from the real standard error,\nmaking this destination effectively equivalent to none . syslog Write to syslog, using the git-daemon identifier. none Disable all logging. The default destination is syslog if --inetd or --detach is specified,\notherwise stderr ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why Git is not allowing me to commit even after configuration?\nThis question seems like a duplicate but it's really not. Just a slight difference that keeps on repeating. git keeps on telling me: \"please tell me who you are\", even after setting it up. when I run git commit, this is what I get....\n$ git commit\n\n*** Please tell me who you are.\n\nRun\n\ngit config --global user.email \"[email protected]\"\n\ngit config --global user.name \"Your Name\"\n\nto set your account's default identity.\nOmit --global to set the identity only in this repository.\n\nfatal: unable to auto-detect email address (got 'Obby@ObbyWorkstation.(none)')\n\nBut when I run git config --global -l, it gives me all my details...\n$ git config --global -l\nuser.name=myname\n[email protected]\nhttp.proxy=proxy.XX.XX.XX:XXXX\n\nI have changed my name, email and proxy but they are appearing fine when I run the command, even in the .gitconfig file I can see the values are set. what could be the missing thing, because I cannot commit at all. Every time it keeps asking me who I am ?\n@sheu told me something that i changed, but still the same problem. when i set --local, still git commit asks me the same question. this is the output\n$ git config --local -l\ncore.repositoryformatversion=0\ncore.filemode=false\ncore.bare=false\ncore.logallrefupdates=true\ncore.symlinks=false\ncore.ignorecase=true\ncore.hidedotfiles=dotGitOnly\nuser.name=myname\n[email protected]"}, {"role": "assistant", "content": "That’s a typo. You’ve accidently set user.mail with no e in email. Fix it by setting user.email in the global configuration with\ngit config --global user.email \"[email protected]\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-worktree - Manage multiple working trees"}, {"role": "assistant", "content": "LIST OUTPUT FORMAT The worktree list command has two output formats. The default format shows the\ndetails on a single line with columns. For example: $ git worktree list\n/path/to/bare-source (bare)\n/path/to/linked-worktree abcd1234 [master]\n/path/to/other-linked-worktree 1234abc (detached HEAD) The command also shows annotations for each worktree, according to its state.\nThese annotations are: locked , if the worktree is locked. prunable , if the worktree can be pruned via git worktree prune . $ git worktree list\n/path/to/linked-worktree abcd1234 [master]\n/path/to/locked-worktree acbd5678 (brancha) locked\n/path/to/prunable-worktree 5678abc (detached HEAD) prunable For these annotations, a reason might also be available and this can be\nseen using the verbose mode. The annotation is then moved to the next line\nindented followed by the additional information. $ git worktree list --verbose\n/path/to/linked-worktree abcd1234 [master]\n/path/to/locked-worktree-no-reason abcd5678 (detached HEAD) locked\n/path/to/locked-worktree-with-reason 1234abcd (brancha)\n\tlocked: worktree path is mounted on a portable device\n/path/to/prunable-worktree 5678abc1 (detached HEAD)\n\tprunable: gitdir file points to non-existent location Note that the annotation is moved to the next line if the additional\ninformation is available, otherwise it stays on the same line as the\nworktree itself. Porcelain Format The porcelain format has a line per attribute. If -z is given then the lines\nare terminated with NUL rather than a newline. Attributes are listed with a\nlabel and value separated by a single space. Boolean attributes (like bare and detached ) are listed as a label only, and are present only\nif the value is true. Some attributes (like locked ) can be listed as a label\nonly or with a value depending upon whether a reason is available. The first\nattribute of a worktree is always worktree , an empty line indicates the\nend of the record. For example: $ git worktree list --porcelain\nworktree /path/to/bare-source\nbare\n\nworktree /path/to/linked-worktree\nHEAD abcd1234abcd1234abcd1234abcd1234abcd1234\nbranch refs/heads/master\n\nworktree /path/to/other-linked-worktree\nHEAD 1234abc1234abc1234abc1234abc1234abc1234a\ndetached\n\nworktree /path/to/linked-worktree-locked-no-reason\nHEAD 5678abc5678abc5678abc5678abc5678abc5678c\nbranch refs/heads/locked-no-reason\nlocked\n\nworktree /path/to/linked-worktree-locked-with-reason\nHEAD 3456def3456def3456def3456def3456def3456b\nbranch refs/heads/locked-with-reason\nlocked reason why is locked\n\nworktree /path/to/linked-worktree-prunable\nHEAD 1233def1234def1234def1234def1234def1234b\ndetached\nprunable gitdir file points to non-existent location Unless -z is used any \"unusual\" characters in the lock reason such as newlines\nare escaped and the entire reason is quoted as explained for the\nconfiguration variable core.quotePath (see git-config ).\nFor Example: $ git worktree list --porcelain\n...\nlocked \"reason\\nwhy is locked\"\n..."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "fatal: Unable to create temporary file '/home/username/git/myrepo.git/./objects/pack/tmp_pack_XXXXXX': Permission denied\nI have been having trouble with this error message and I don't understand the proper solution to fix it or go about debugging it. I have googled the error in various forms but no real solution has presented itself. I am assuming it's an issue with permissions but I don't really know how to check or what I should check for.\nI have a server running Ubuntu 11.10 and I'm basically trying to make the initial commit to my git repo from my development machine. I'm running as root. Should I be running as the user?\nRepo creation on server:\n$ cd /home/username/git\n$ mkdir myrepo.git\n$ cd myrepo.git/\n$ git --bare init\n\nRepo creation on development machine:\nGoto rails project directory first\n$ git init\n$ git add .\n$ git commit -m \"initial commit\"\n$ bundle pack\n$ git add Gemfile.lock vendor/cache\n$ git commit -m \"bundle gems\"\n$ git remote add origin ssh://[email protected]/home/username/git/myrepo.git\n$ git push origin master\n\nError:\nfatal: Unable to create temporary file '/home/username/git/myrepo.git/./objects/pack/tmp_pack_XXXXXX': Permission denied\nerror: pack-objects died of signal 13\nerror: failed to push some refs to 'ssh://[email protected]/home/username/git/myrepo.git'\n\nMy .git/config file:\n[core]\n repositoryformatversion = 0\n filemode = true\n bare = false\n logallrefupdates = true\n ignorecase = true\n[remote \"origin\"]\n url = ssh://[email protected]/home/username/git/myrepo.git\n fetch = +refs/heads/*:refs/remotes/origin/*\n\nSimilar question:\nHow do I do an initial push to a remote repository with Git?"}, {"role": "assistant", "content": "It sounds like you have file in the git repo owned by root. Since you're ssh'ing in as 'username' to do the push, the files must be writable by username. The easiest thing is probably to create the repo as the user, and use the same user to do your pushes. Another option is to create a group, make everything writable by the group, and make your user a member of that group."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rebase - Reapply commits on top of another base tip rebase.maxLabelLength"}, {"role": "assistant", "content": "When generating label names from commit subjects, truncate the names to\nthis length. By default, the names are truncated to a little less than NAME_MAX (to allow e.g. .lock files to be written for the\ncorresponding loose refs)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.srcPrefix"}, {"role": "assistant", "content": "If set, git diff uses this source prefix. Defaults to \"a/\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I add images to a PyPI readme (that works on GitHub)?\n\nIn my readme on GitHub I have several images that are present there in my project's source tree which I reference successfully with directives like\n.. image:: ./doc/source/_static/figs/moon_probe.png\n\nI would also like to have these images appear when this same readme is generated in PyPi.\nHow do I (a) ensure that images are present on PyPi for the readme to access and (b) formulate the .. image:: directive to access them?"}, {"role": "assistant", "content": "PyPI will not read your package distributions for the image. You have to use the image's external link, for example:\n.. image:: https://raw.githubusercontent.com/greyli/flask-share/master/images/demo.png\n\nIf you are using Markdown description, use this:\n![](https://raw.githubusercontent.com/greyli/flask-share/master/images/demo.png)\n\nBe sure to replace the URL in the above examples with your image URL, here I use the image hosted by GitHub, the real demo is on PyPI.\nP.S. To get the image's raw link on GitHub, right-click the image and choose Copy image address."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options credentialCache.ignoreSIGHUP"}, {"role": "assistant", "content": "Tell git-credential-cache—​daemon to ignore SIGHUP, instead of quitting."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git octopus merge order of multiple branches\nI had an interesting thing happen using git, wondering if anyone could explain it to me so I can understand better. \nWhen doing a merge of multiple branches (A,B), \ngit merge A B\n\nfails as non-fast-forward, while \ngit merge B A\n\nworked well. Why would that be?"}, {"role": "assistant", "content": "Let's assume that A is a strict, direct child of the current branch. Then assume that B is a strict, direct child of A.\nThe octopus merge, which processes heads given as arguments from left to right, incrementally with respect to the tree, but independently with respect to the index succeeds without conflict if it tries to apply B and then A, but encounters a conflict if it does the converse.\nAs per the git-merge manual, section MERGE STRATEGIES:\noctopus\n This resolves cases with more than two heads, but refuses to do a\n complex merge that needs manual resolution.\n\nFor instance:\n ~ $ git init testdir && cd testdir && echo \"This is C\" > myfile\n Initialized empty Git repository in /home/huitseeker/testdir/.git/\n\n ~/testdir $ git add myfile && git commit -m \"C\" \n [master (root-commit) f0c8c82] C\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 myfile\n\n ~/testdir(master) $ git checkout -b \"A\" && echo \"This is A1\" > myfile\n Switched to a new branch 'A'\n ~/testdir(A) $ git commit -m \"A1\" myfile\n [A ac5b51c] A1\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\n ~/testdir(A) $ git checkout -b \"B\" && echo \"This is B1\" >> myfile\n Switched to a new branch 'B'\n ~/testdir(B) $ git commit -m \"B1\" myfile\n [B 5bc838c] B1\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\n ~/testdir(B) $ git checkout master\n Switched to branch 'master'\n ~/testdir(master) $ git merge B A\n Fast-forwarding to: B\n Already up-to-date with A\n Merge made by octopus.\n myfile | 3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\n ~/testdir(master) $ git reset --hard HEAD^^^\n HEAD is now at f0c8c82 C\n ~/testdir(master) $ git merge A B\n Fast-forwarding to: A\n Fast-forwarding to: B\n error: Entry 'myfile' would be overwritten by merge. Cannot merge.\n Merge with strategy octopus failed.\n\n ~/testdir(master) $ cat myfile\n This is A1\n\nIndeed, when fast-forwarding to A, the label of master has not been pushed forward, though the tree has.\n ~/testdir(master) $ git status\n # On branch master\n # Changes to be committed:\n # (use \"git reset HEAD <file>...\" to unstage)\n #\n # modified: myfile\n #\n\nIf, looking at the code of what the octopus merge does, I perform this manually (look above for hashes):\n ~/testdir(master) $ git reset --hard f0c8c82\n HEAD is now at f0c8c82 C \n ~/testdir(master) $ git read-tree -u -m f0c8c82 ac5b51c\n ~/testdir(master) $ git read-tree -u -m f0c8c82 5bc838c\n error: Entry 'myfile' would be overwritten by merge. Cannot merge.\n\nIn the other direction (merge B A), now, if you look again at the code of merge-octopus, it tries to detect the branch we are trying to add is already in the tree (second case of the for loop). Indeed, at the merge of A, it sees ac5b51c (a.k.a. A's head) is the common ancestor of A and B, and aborts without doing the second read-tree.\nThis behavior is consistent with the fresh version of git : though I've pointed to v.1.3.1, this is still happening with my version.\n ~/testdir(master) $ git --version\n git version 1.7.5.4\n\ntl;dr : you want your octopus merge branches to touch distinct files"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options blame.coloring"}, {"role": "assistant", "content": "This determines the coloring scheme to be applied to blame\noutput. It can be repeatedLines , highlightRecent ,\nor none which is the default."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --cumulative"}, {"role": "assistant", "content": "Synonym for --dirstat=cumulative"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "avoid rebuilding node_modules in elastic beanstalk\nWe have a fairly simple node.js app, but due to AWS Elastic Beanstalk deployment mechanism, it takes about 5 minutes to roll-out a new version (via git aws.push) even after a single file commit.\nI.e. the commit itself (and upload) is fast (only 1 file to push), but then Elastic Beanstalk fetches whole package from S3, unzips it and runs npm install, which causes node-gyp to compile some modules. Upon installation/building completion, Elastic Beanstalk wipes /var/app/current and replaces it with the new app version.\nNeedless to say, constant node_modules rebuilding is not necessary, and rebuilding that takes 30 seconds on my old Macbook Air, takes >5 mins on a ec2.micro instance, not fun.\nI see two approaches here:\n\ntweak /opt/containerfiles/ebnode.py and play with node_modules location to avoid its removal and rebuilding upon deployment. \nset up a git repo on Elastic Beanstalk EC2 instance and basically re-write deployment procedure ourselves, so /var/app/current receives pushes and runs npm install only when necessary (which makes Elastic Beanstalk to look like OpsWorks..)\n\nBoth options lack grace and are prone to issues when Amazon updates their Elastic Beanstalk hooks and architecture.\nMaybe somebody has a better idea how to avoid constant rebuilding of node_modules that are already present in the app dir? Thank you."}, {"role": "assistant", "content": "Thanks Kirill, it was really helpful !\nI'm just sharing my config file for people who just look the simple solution to the npm install. This file needs to be placed in the .ebextensions folder of the project, it is lighter since it doesn't include last version of node installation, and ready to use.\nIt also dynamically checks the node version installed, so no need for it to be included in the env.vars file.\n.ebextensions/00_deploy_npm.config\nfiles:\n \"/opt/elasticbeanstalk/env.vars\" :\n mode: \"000775\"\n owner: root\n group: users\n content: |\n export NPM_CONFIG_LOGLEVEL=error\n export NODE_PATH=`ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin\n \"/opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh\" :\n mode: \"000775\"\n owner: root\n group: users\n content: |\n #!/bin/bash\n . /opt/elasticbeanstalk/env.vars\n function error_exit\n {\n eventHelper.py --msg \"$1\" --severity ERROR\n exit $2\n }\n\n #install not-installed yet app node_modules\n if [ ! -d \"/var/node_modules\" ]; then\n mkdir /var/node_modules ;\n fi\n if [ -d /tmp/deployment/application ]; then\n ln -s /var/node_modules /tmp/deployment/application/\n fi\n\n OUT=$([ -d \"/tmp/deployment/application\" ] && cd /tmp/deployment/application && $NODE_PATH/npm install 2>&1) || error_exit \"Failed to run npm install. $OUT\" $?\n echo $OUT\n \"/opt/elasticbeanstalk/hooks/configdeploy/pre/50npm.sh\" :\n mode: \"000666\"\n owner: root\n group: users\n content: |\n #no need to run npm install during configdeploy"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects dimmed-zebra"}, {"role": "assistant", "content": "Similar to zebra , but additional dimming of uninteresting parts\nof moved code is performed. The bordering lines of two adjacent\nblocks are considered interesting, the rest is uninteresting. dimmed_zebra is a deprecated synonym."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rebase - Reapply commits on top of another base tip recursive"}, {"role": "assistant", "content": "This can only resolve two heads using a 3-way merge\nalgorithm. When there is more than one common\nancestor that can be used for 3-way merge, it creates a\nmerged tree of the common ancestors and uses that as\nthe reference tree for the 3-way merge. This has been\nreported to result in fewer merge conflicts without\ncausing mismerges by tests done on actual merge commits\ntaken from Linux 2.6 kernel development history.\nAdditionally this can detect and handle merges involving\nrenames. It does not make use of detected copies. This was\nthe default strategy for resolving two heads from Git v0.99.9k\nuntil v2.33.0. The recursive strategy takes the same options as ort . However,\nthere are three additional options that ort ignores (not documented\nabove) that are potentially useful with the recursive strategy: patience Deprecated synonym for diff-algorithm=patience . diff-algorithm=[patience|minimal|histogram|myers] Use a different diff algorithm while merging, which can help\navoid mismerges that occur due to unimportant matching lines\n(such as braces from distinct functions). See also git-diff --diff-algorithm . Note that ort specifically uses diff-algorithm=histogram , while recursive defaults to the diff.algorithm config setting. no-renames Turn off rename detection. This overrides the merge.renames configuration variable.\nSee also git-diff --no-renames ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Include an SVG (hosted on GitHub) in MarkDown\n\nI know that an image can be placed in an MD with the MD syntax of either ![Alt text](/path/to/img.jpg) or ![Alt text](/path/to/img.jpg \"Optional title\"), but I am having difficulty placing an SVG in MD where the code is hosted on GitHub.\nUltimately using rails3, and changing the model frequently right now, so I am using RailRoady to generate an SVG of the schema diagram of the models. I would like for that SVG to then be placed in the ReadMe.md, and be displayed. When I open the SVG file locally, it does work, so how do I get the browser to render the SVG in the MD file? Given that the code will be dynamic until it is finalized (seemingly never), hosting the SVG in a separate place seems overkill and that I am missing an approach to accomplish this.\nThe SVG I am trying to include is here on GitHub: https://github.com/specialorange/FDXCM/blob/master/Rails/fdxcm/doc/models_brief.svg\nI have tried the following, with an actual image as well to verify the syntax is working, just that the SVG code isn't being rendered:\n![Overview][1]\n[1]: https://github.com/specialorange/FDXCM/blob/master/doc/controllers_brief.svg \"Overview\"\n\n<img src=\"https://raw.github.com/specialorange/FDXCM/master/doc/controllers_brief.svg\">\n\n![Alt text](https://raw.github.com/specialorange/FDXCM/master/doc/controllers_brief.svg)\n\n[Google Doc](https://docs.google.com/drawings/d/1B95ajItJTAImL2WXISX0fkBLYk3nldea4Vm9eo-VyE4/edit) :\n\n<img src=\"https://docs.google.com/drawings/pub?id=117XsJ1kDyaY-n8AdPS3_8jTgMyITqaoT3-ah_BSc9YQ&w=960&h=720\">\n\n<img src=\"https://raw.github.com/specialorange/FDXCM/master/doc/controllers_brief.svg\">\n\n<img src=\"https://docs.google.com/drawings/d/1B95ajItJTAImL2WXISX0fkBLYk3nldea4Vm9eo-VyE4/edit\">\n\nto get the results of:\n\n1: https://github.com/specialorange/FDXCM/blob/master/Rails/fdxcm/doc/controllers_brief.svg \"Overview\"\n\n\n\nGoogle Doc :"}, {"role": "assistant", "content": "The purpose of raw.github.com is to allow users to view the contents of a file, so for text based files this means (for certain content types) you can get the wrong headers and things break in the browser.\nWhen this question was asked (in 2012) SVGs didn't work. Since then Github has implemented various improvements. Now (at least for SVG), the correct Content-Type headers are sent.\nThe easiest way to add SVG is to use the upload assets feature. To quote the manual:\n\nYou can upload assets like images by dragging and dropping, selecting from a file browser, or pasting. You can upload assets to issues, pull requests, comments, and .md files in your repository.\n\nSince 2022, \"images\" also includes SVG:\n\n\nSome comments regarding changes that happened along the way:\n\nGithub has implemented a feature which makes it possible for SVG's to be used with the Markdown image syntax. The SVG image will be sanitized and displayed with the correct HTTP header. Certain tags (like <script>) are removed.\nTo view the sanitized SVG or to achieve this effect from other places (i.e. from markdown files not hosted in repos on http://github.com/) simply append ?sanitize=true to the SVG's raw URL.\n\nAs stated by AdamKatz in the comments, using a source other than github.io can introduce potentially privacy and security risks. See the answer by CiroSantilli and the answer by DavidChambers for more details.\n\nThe issue to resolve this was opened on Github on October 13th 2015 and was resolved on August 31th 2017\n\nSupport for SVG drag-and-drop file upload was announced January 21 2022\n\n\nExamples\nAll of the ways stated below will work.\nI copied the SVG image from the question to a repo on github in order to create the examples below\nLinking to files using relative paths (Works, but obviously only on github.com / github.io)\nCode\n![Alt text](./controllers_brief.svg)\n<img src=\"./controllers_brief.svg\">\n\nResult\nSee the working example on github.com.\nLinking to RAW files\nCode\n![Alt text](https://raw.github.com/potherca-blog/StackOverflow/master/question.13808020.include-an-svg-hosted-on-github-in-markdown/controllers_brief.svg)\n<img src=\"https://raw.github.com/potherca-blog/StackOverflow/master/question.13808020.include-an-svg-hosted-on-github-in-markdown/controllers_brief.svg\">\n\nResult\n\n\nLinking to RAW files using ?sanitize=true\nCode\n![Alt text](https://raw.github.com/potherca-blog/StackOverflow/master/question.13808020.include-an-svg-hosted-on-github-in-markdown/controllers_brief.svg?sanitize=true)\n<img src=\"https://raw.github.com/potherca-blog/StackOverflow/master/question.13808020.include-an-svg-hosted-on-github-in-markdown/controllers_brief.svg?sanitize=true\">\n\nResult\n\n\nLinking to files hosted on github.io\nCode\n![Alt text](https://potherca-blog.github.io/StackOverflow/question.13808020.include-an-svg-hosted-on-github-in-markdown/controllers_brief.svg)\n<img src=\"https://potherca-blog.github.io/StackOverflow/question.13808020.include-an-svg-hosted-on-github-in-markdown/controllers_brief.svg\">\n\nResult"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Runner is not healthy and will be disabled\n\nI hosts my repository with gitlab.com and I install runner in the DigitalOcean. It ran fine until today 16March2019 14:24 Thailand time.\n# gitlab-runner status\nRuntime platform arch=amd64 os=linux pid=16937 revision=4745a6f3 version=11.8.0\ngitlab-runner: Service is running!\n# gitlab-runner unregister --all-runners\nRuntime platform arch=amd64 os=linux pid=16299 revision=4745a6f3 version=11.8.0\nRunning in system-mode.\n\nWARNING: Unregistering all runners\nERROR: Unregistering runner from GitLab forbidden runner=2bcd7af4\nERROR: Failed to unregister runner HerrRunner\n# gitlab-runner list\nRuntime platform arch=amd64 os=linux pid=16346 revision=4745a6f3 version=11.8.0\nListing configured runners ConfigFile=/etc/gitlab-runner/config.toml\nHerrRunner Executor=shell Token=2bcd7af455f866ede7991992a68780 URL=https://gitlab.com/\n# gitlab-runner --debug run\nRuntime platform arch=amd64 os=linux pid=16395 revision=4745a6f3 version=11.8.0\nStarting multi-runner from /etc/gitlab-runner/config.toml ... builds=0\nChecking runtime mode GOOS=linux uid=0\nRunning in system-mode.\n\nConfiguration loaded builds=0\nlistenaddress: \"\"\nsessionserver:\n listenaddress: \"\"\n advertiseaddress: \"\"\n sessiontimeout: 1800\nmetricsserveraddress: \"\"\nconcurrent: 1\ncheckinterval: 0\nloglevel: null\nlogformat: null\nuser: \"\"\nrunners:\n- name: HerrRunner\n limit: 0\n outputlimit: 0\n requestconcurrency: 0\n runnercredentials:\n url: https://gitlab.com/\n token: 2bcd7af455f866ede7991992a68780\n tlscafile: \"\"\n tlscertfile: \"\"\n tlskeyfile: \"\"\n runnersettings:\n executor: shell\n buildsdir: \"\"\n cachedir: \"\"\n cloneurl: \"\"\n environment: []\n preclonescript: \"\"\n prebuildscript: \"\"\n postbuildscript: \"\"\n shell: \"\"\n ssh: null\n docker: null\n parallels: null\n virtualbox: null\n cache:\n type: \"\"\n path: \"\"\n shared: false\n s3: null\n gcs: null\n s3cachepath: \"\"\n cacheshared: false\n serveraddress: \"\"\n accesskey: \"\"\n secretkey: \"\"\n bucketname: \"\"\n bucketlocation: \"\"\n insecure: false\n machine: null\n kubernetes: null\nsentrydsn: null\nmodtime: 2018-08-12T18:07:07.963445119Z\nloaded: true\n builds=0\nWaiting for stop signal builds=0\nListen address not defined, metrics server disabled builds=0\nListen address not defined, session server disabled builds=0\nStarting worker builds=0 worker=0\nFeeding runners to channel builds=0\nDialing: tcp gitlab.com:443 ...\nERROR: Checking for jobs... forbidden runner=2bcd7af4\nFeeding runners to channel builds=0\nERROR: Checking for jobs... forbidden runner=2bcd7af4\nFeeding runners to channel builds=0\nERROR: Checking for jobs... forbidden runner=2bcd7af4\nERROR: Runner https://gitlab.com/2bcd7af455f866ede7991992a68780 is not healthy and will be disabled!\nFeeding runners to channel builds=0\nFeeding runners to channel builds=0\nFeeding runners to channel builds=0\n^CWARNING: Requested service stop: interrupt builds=0\nAll workers stopped. Can exit now builds=0\n\nUltimate Goal\nGet my runner up and run again\nQuestion:\n\nWhat does not healthy means?\nI can't unregister my runner. How to fix this?"}, {"role": "assistant", "content": "I was integrating my runner for the first time, and anyone familiar with gitlab will know this was never going to be a walk in the park. I spent many hours chasing down this error message only to find I was completely looking in the wrong direction.\nERROR: Checking for jobs... forbidden runner=s3xBVnW8\nERROR: Checking for jobs... forbidden runner=s3xBVnW8\nERROR: Checking for jobs... forbidden runner=s3xBVnW8\nERROR: Runner https://gitlab.com/s3xBVnW8JZPTaocALN3i is not healthy and will be disabled!\n\nI now believe my runner was telling me that the \"runner\" at gitlab.com is not healthy and has been rejected (by my runner). When I left it running and put a pipeline job in, it processed fine, there was no issue at my end, I had spent hours looking for nothing!"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-revert - Revert some existing commits --continue"}, {"role": "assistant", "content": "Continue the operation in progress using the information in .git/sequencer . Can be used to continue after resolving\nconflicts in a failed cherry-pick or revert."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-cat-file - Provide contents or details of repository objects --allow-unknown-type"}, {"role": "assistant", "content": "Allow -s or -t to query broken/corrupt objects of unknown type."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects --word-diff-regex=<regex>"}, {"role": "assistant", "content": "Use <regex> to decide what a word is, instead of considering\nruns of non-whitespace to be a word. Also implies --word-diff unless it was already enabled. Every non-overlapping match of the\n<regex> is considered a word. Anything between these matches is\nconsidered whitespace and ignored(!) for the purposes of finding\ndifferences. You may want to append |[^[:space:]] to your regular\nexpression to make sure that it matches all non-whitespace characters.\nA match that contains a newline is silently truncated(!) at the\nnewline. For example, --word-diff-regex=. will treat each character as a word\nand, correspondingly, show differences character by character. The regex can also be set via a diff driver or configuration option, see gitattributes or git-config . Giving it explicitly\noverrides any diff driver or configuration setting. Diff drivers\noverride configuration settings."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-status"}, {"role": "assistant", "content": "Show the working tree status"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Does running git init twice initialize a repository or reinitialize an existing repo?\nWhat happens to an existing git repository when you issue git init again?\nI created a repository with git init. Created a file, add, commit. Check the status (nothing to commit). Then created another file, check the status and I can see it's untracked as expected. \nThen, say by mistake, I run git init again and I get Reinitialise existing Git repository message. \nTried git status, but it shows the same. So what really happens? \nCan reinitialising an existing git repository this way be harmful or helpful? Why can we git init inside an existing repository?"}, {"role": "assistant", "content": "From the git docs:\n\nRunning git init in an existing repository is safe. It will not overwrite things that are already there. The primary reason for rerunning git init is to pick up newly added templates."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-commit - Record changes to the repository --date=<date>"}, {"role": "assistant", "content": "Override the author date used in the commit."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitglossary - A Git Glossary repository"}, {"role": "assistant", "content": "A collection of refs together with an object database containing all objects\nwhich are reachable from the refs, possibly\naccompanied by meta data from one or more porcelains . A\nrepository can share an object database with other repositories\nvia alternates mechanism ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Squash to only one \"proper\" commit for github pull request\nI have a repo on github which someone else (Bob, for the sake of argument) has issued a pull request for. His code's not perfect, so we go through a few rounds of markups. As I understand it, he commits and pushes to his pull-request for each set of marked up changes.\nSo my repository now looks like this:\nmaster: ---o A (Chowlett\n |\n |\npull-req: o---o---o---o\n B C D (all Bob)\n\nCommit SHAs and msgs are as follows:\nA:\n123456 Good commit <chowlett>\n\nB:\n777ccc Fix the widget bug <bob>\n\nC:\n888ddd Review markups <bob>\n\nD:\n999eee Further markups <bob>\n\nI'm now happy to accept this pull request; but I'd rather the pre-markup versions weren't in my repo. Can I achieve all of the following; and how?\n\nMerge B, C & D into my repo as a single commit\nGenerate the \"Merge pull request #99 into ...\" commit as well\nHave github automatically close the pull request"}, {"role": "assistant", "content": "Note that Bob doesn't have to squash his commits when he is making a GitHub PR.\nSince March 2016, you can leave that operation to the maintainer (you) accepting your PR.\nSee \"Squash your commits\" and its new documentation\n\nThis is a new option which lets you force commit squashing on all pull requests merged via the merge button."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-restore - Restore working tree files -q --quiet"}, {"role": "assistant", "content": "Quiet, suppress feedback messages. Implies --no-progress ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs -<number> -n <number> --max-count=<number>"}, {"role": "assistant", "content": "Limit the number of commits to output."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options format.signOff"}, {"role": "assistant", "content": "A boolean value which lets you enable the -s/--signoff option of\nformat-patch by default. Note: Adding the Signed-off-by trailer to a\npatch should be a conscious act and means that you certify you have\nthe rights to submit this work under the same open source license.\nPlease see the SubmittingPatches document for further discussion."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.colorMoved"}, {"role": "assistant", "content": "If set to either a valid <mode> or a true value, moved lines\nin a diff are colored differently, for details of valid modes\nsee --color-moved in git-diff . If simply set to\ntrue the default color mode will be used. When set to false,\nmoved lines are not colored."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to stash only staged changes in Git?\nIs there a way I can stash just my staged changes? The scenario I'm having issues with is when I've worked on several bugs at a given time, and have several unstaged changes. I'd like to be able to stage these files individually, create my .patch files, and stash them away until the code is approved. This way, when it's approved I can stash my entire (current) session, pop that bug and push the code.\nAm I going about this the wrong way? Am I misunderstanding how git can work in other ways to simplify my process?"}, {"role": "assistant", "content": "Yes, It's possible with DOUBLE STASH\n\nStage all your files that you need to stash.\nRun git stash --keep-index. This command will create a stash with ALL of your changes (staged and unstaged), but will leave the staged changes in your working directory (still in state staged).\nRun git stash push -m \"good stash\" (add the -u flag to include new files in the stash)\nNow your \"good stash\" has ONLY staged files.\n\nNow if you need unstaged files before stash, simply apply first stash (the one created with --keep-index) and now you can remove files you stashed to \"good stash\".\nEnjoy"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to make \"spoiler\" text in github wiki pages?\n\nI'm trying to make text which is either invisible until moused over, or, has a \"show\" / \"hide\" button, or some other thing, so that it is not visible until the user interacts with it in some way.\nI'm trying to do this on a github wiki page. (Specifically it's for a short self-quiz.)\nBasically I want to get a similar effect to what SO achieves with the >! markup:\n\n Hoho! Spoiler text!\n\nas described in these meta posts.\nThe same markup doesn't work in github, I guess that it's an SO extension?\nI saw this issue about using spoiler text in comments on github, which was closed, but I thought there might be a different answer for the wiki pages, or a different solution based on HTML or something?\nDoes anyone know if there's a way to do this, or if it is definitely unfortunately impossible?"}, {"role": "assistant", "content": "GFM supports a subset of HTML. For now, you can wrap your question in a <summary> and your answer in any standard HTML tag like <p> and wrap the whole thing in the <details> tag.\nSo if you do this\n<details> \n <summary>Q1: What is the best Language in the World? </summary>\n A1: JavaScript \n</details>\n\nYou get this -> https://github.com/gaurav21r/Spoon-Knife/wiki/Read-More-Test\nBrowser support is an Issue.\nThe thing with GitHUB wiki is that it allows you write text in other formats like AsciiDoc, RST etc. Probabaly there's solution in those too. These are 2 formats that are far more feature rich than Markdown."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to revert a Git Submodule pointer to the commit stored in the containing repository?\nI have a git submodule in my main git repo. As I understand it, the main repo stores a SHA value (somewhere...), pointing to the specific commit of the submodule that it is \"linked to\". \nI went in to my submodule and typed git checkout some_other_branch. I have no idea which commit I came from.\nI would like to revert that pointer so that the main repo and the submodule are in sync again.\nMy first (probably naive) instinct was to say git reset --hard - that seems to work for everything else. To my surprise, it did not work for this scenario.\nSo I've figured out that I can type git diff, note the SHA ID that the submodule pointer used to have, and then head into the submodule and git checkout [SHA ID]... but surely there must be an easier way?\nAs I'm still learning about git submodules, please feel free to correct my terminology if there are words for concepts that I don't know."}, {"role": "assistant", "content": "You want to update your submodule so it is in sync with what the parent repository believes it should be. This is what the update command is for:\nFrom the submodule manpage:\n\nUpdate the registered submodules, i.e. clone missing submodules and\ncheckout the commit specified in the index of the containing\nrepository. This will make the submodules HEAD be detached unless\n--rebase or --merge is specified or the key submodule.$name.update\nis set to rebase or merge.\n\nRun this and all should be well:\ngit submodule update --init\n\nYou can add the --recursive flag as well to recurse through all submodules."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs git log --branches --not --remotes=origin"}, {"role": "assistant", "content": "Shows all commits that are in any of local branches but not in\nany of remote-tracking branches for origin (what you have that\norigin doesn’t)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is it possible to \"lock\" group of jobs across multiple gitlab pipelines\n\nI have multiple jobs working with a single external resource (Server). The first job deploys the app to the environment, the second execute tests at this environment, third execute integration tests at this environment.\nI know there is Resource group option. But it locks only jobs. If two pipelines run concurrently I need to execute job1, job2, job3 from the first pipeline, and only when the first pipeline release resource - the second pipeline can launch jobs1-3. Is there a way to achieve this? There are other jobs in the pipeline - they should work concurrently."}, {"role": "assistant", "content": "This should be possible in 13.9 by using resource_group with process mode = oldest_first. Details available at: https://docs.gitlab.com/ee/ci/resource_groups/index.html#pipeline-level-concurrency-control-with-cross-projectparent-child-pipelines"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git mergetool generates unwanted .orig files\nWhen I do a merge conflict resolution with Kdiff3 (and other merge tool I tried) I noticed that on resolution a *.orig file is created. Is there a way for it to not create that extra file?"}, {"role": "assistant", "content": "A possible solution from git config:\ngit config --global mergetool.keepBackup false\n\n\nAfter performing a merge, the original file with conflict markers can be saved as a file with a .orig extension.\n If this variable is set to false then this file is not preserved.\n Defaults to true (i.e. keep the backup files).\n\nThe alternative being not adding or ignoring those files, as suggested in this gitguru article, \n\ngit mergetool saves the merge-conflict version of the file with a “.orig” suffix.\n Make sure to delete it before adding and committing the merge or add *.orig to your .gitignore.\n\nBerik suggests in the comments to use:\nfind . -name \\*.orig \nfind . -name \\*.orig -delete\n\nCharles Bailey advises in his answer to be aware of internal diff tool settings which could also generate those backup files, no matter what git settings are.\n\nkdiff3 has its own settings (see \"Directory merge\" in its manual). \nother tools like WinMerge can have their own backup file extension (WinMerge: .bak, as mentioned in its manual).\n\nSo you need to reset those settings as well."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -C[<n>] --find-copies[=<n>]"}, {"role": "assistant", "content": "Detect copies as well as renames. See also --find-copies-harder .\nIf n is specified, it has the same meaning as for -M<n> ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can i see output of .rmd in github?\n\nI am practicing data analysis using R programming. I want my files to be on github. I am unable to figure out why github is not showing the output of .rmd files. \nHere is the link to the file in my github repository Data Analysis Practice\nI want the output including plots to be shown on github."}, {"role": "assistant", "content": "Instead of:\noutput: html_document\n\nmake it:\noutput: rmarkdown::github_document\n\n(assuming you have the latest rmarkdown installed which you should if you're using RStudio — which I suspect you are — and keep it updated or update packages regularly).\nIt will create Exploring_one_variable.md and render the images as files. \nWhen you browse to that markdown file, the images will render.\nAn alternative is to use:\noutput: \n html_document:\n keep_md: true\n\nand it will render to both Exploring_one_variable.md and Exploring_one_variable.html so you'll have the best of both worlds without the local github-esque preview that the former provides.\nYou can get fancier and put something like the following as the first code section in the Rmd:\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n fig.path = \"README_figs/README-\"\n)\n```\n\nwhich will put the figures in a directory of your choosing.\nYou can see this in action here as the README.md was generated with knitr from the README.Rmd in the same directory."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Using git commit -a with vim\nI'm new with git, so I decided to learn git using the tutorials of github. The third chapter said: \n\n\"For this first example we’ll modify the README file to add ourselves as an author on the project. So we simply edit the file. Now we want to commit that change, so we run the git commit -a command.\"\n\nWhen I use the git commit -a command, the console opens a vim and I wrote my message, but I don't know how to close this vim editor from the console. How do I save the message and close vim?"}, {"role": "assistant", "content": "In vim, you save a file with :wEnter while in the normal mode (you get to the normal mode by pressing Esc).\nYou close your file with :q while in the normal mode.\n\nYou can combine both these actions and do Esc:wqEnter to save the commit and quit vim.\nAs an alternate to the above, you can also press ZZ while in the normal mode, which will save the file and exit vim. This is also easier for some people as it's the same key pressed twice."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How is Gitlab's \"project workspace\" defined and propagated between jobs?\n\nGitlab's documentation often mentions a \"project workspace\" without actually defining its construction and functionality. One example is from the chapter about Git strategy which just plain tells the user \"Using git fetch which is faster as it re-uses the project workspace (falling back to clone if it doesn't exist).\" and doesn't define the way of reusage in any way.\nI would like to understand how it's created, how it's tranferred between jobs and how this impacts jobs running in a Docker executor. Is there some kind of information about this apart from the source code? Have I missed some crucial part of the documentation?"}, {"role": "assistant", "content": "There is no concept of a GitLab-specific workspace as far as I know. Perhaps it might be worth suggesting a change in that documentation page (everyone can submit a merge request using the links at the bottom of each docs page).\nI would say workspace in that concepts simply refers to either the parent directory under which you clone a Git repository, or the repository's own directory. This other document provides some more context."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why doesn't `git checkout` automatically do `git submodule update --recursive`? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nWhy is git submodule not updated automatically on git checkout?\n\n (3 answers)\n \n\nClosed 5 years ago.\n\n\n\nSomeone please help me understand submodules in git. I know they are getting a lot of bashing around the internet but since I assume the git developers are smart people there must a reason for the current behavior - and maybe a way to work around my problem.\nSo, I have a project and some submodules. The project have different branches, like:\n\nMyApp_version2\nMyApp_version3\nMyApp_version4\nMyApp_liteversion\nMyApp_development\n\nMy submodules doesn't update that often (maybe once a week) so I'm fine with them not being attached to the head of the submodule repository automatically.\nHowever, when I check out an old branch - because I need to fix a bug in an old version of the software - I also need to update the submodules.\nWhy do I need to do this?\nI would expect git to work like svn. When I commit my work in my main repo I would expect git to think something along these lines: \"OK, he wants to commit his work now. I can see the submodules are currently at revision abc so when he at some point in the future get's back to this commit he probably wants the submodules at the same revision again.\"\nI can not see a single case where you would want the submodules to stay at the current revision while you go back 3 years in your main repository. However, there must be a reason for this implementation, right?\nI would really like to hear if any of you know the thoughts behind this, but in any case I would really like a solution. Is there a way to tell git: \"I want to commit this work with these submodules. If I at some point go back to this state I want the submodules to be checked out at the correct version as well.\"\nExample for clarification\nMy main repository is an application which needs to use SSL, and I find a SSL library (libSSL) I add as a submodule.\nOn Oct. 31 2010 I create a commit in my main repository (2fd4e1) while the submodule points to libSSL version 3 (c67a2d).\nTime passes, libSSl gets updated to version 34, I adapt my code, life it good.\nOn May 14 2013 I create a new commit (28fced) and submodule points to the most recent version of libSSL (849ee1).\nHowever, if I check out 2fd4e1 my submodule will stay at 849ee1 even though the original commit was created with c67a2d. Git knows I made the original commit with c67a2d and I don't see how you could possibly want a another submodule than the one the original commit was created with."}, {"role": "assistant", "content": "It sounds like what you want to do can be achieved from git v2.13 on with the new --recurse-submodules option of git checkout. From the git-checkout manual page:\n\n--[no-]recurse-submodules\nUsing --recurse-submodules will update the content of all initialized submodules according to the commit recorded in the superproject. If local modifications in a submodule would be overwritten the checkout will fail unless -f is used. If nothing (or --no-recurse-submodules) is used, the work trees of submodules will not be updated.\n\nSee also this relevant git mailing list message about that new option."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-reflog"}, {"role": "assistant", "content": "Manage reflog information"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to limit a job in gitlab ci to a tag matching a pattern?\n\nI want to be able to trigger a deployment to a special server every time a tag matching a pattern is pushed.\nI use the following job definition:\n# ...\ndeploy to stage:\n image: ruby:2.2\n stage: deploy\n environment:\n name: foo-bar\n script:\n - apt-get update -yq\n - apt-get install -y ruby-dev\n - gem install dpl\n# - ...\n only:\n - tags\n\nNow my question: how can I limit this to tags that have a certain name, for example starting with \"V\", so that I can push a tag \"V1.0.0\" and have a certain job running?"}, {"role": "assistant", "content": "Only accepts regex patterns so for your use case it would be:\nonly:\n - /^V.*$/\nexcept:\n - branches\n - triggers"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Remove folder and its contents from git/GitHub's history\nI was working on a repository on my GitHub account and this is a problem I stumbled upon.\n\nNode.js project with a folder with a few npm packages installed\nThe packages were in node_modules folder\nAdded that folder to git repository and pushed the code to github (wasn't thinking about the npm part at that time)\nRealized that you don't really need that folder to be a part of the code\nDeleted that folder, pushed it \n\nAt that instance, the size of the total git repo was around 6MB where the actual code (all except that folder) was only around 300 KB. \nNow what I am looking for in the end is a way to get rid of details of that package folder from git's history so if someone clones it, they don't have to download 6mb worth of history where the only actual files they will be getting as of the last commit would be 300KB.\nI looked up possible solutions for this and tried these 2 methods\n\nRemove file from git repository (history)\nhttp://help.github.com/remove-sensitive-data/\nhttps://gist.github.com/1588371\n\nThe Gist seemed like it worked where after running the script, it showed that it got rid of that folder and after that it showed that 50 different commits were modified. But it didn't let me push that code. When I tried to push it, it said Branch up to date but showed 50 commits were modified upon a git status. The other 2 methods didn't help either.\nNow even though it showed that it got rid of that folder's history, when I checked the size of that repo on my localhost, it was still around 6MB. (I also deleted the refs/originalfolder but didn't see the change in the size of the repo).\nWhat I am looking to clarify is, if there's a way to get rid of not only the commit history (which is the only thing I think happened) but also those files git is keeping assuming one wants to rollback.\nLets say a solution is presented for this and is applied on my localhost but cant be reproduced to that GitHub repo, is it possible to clone that repo, rollback to the first commit perform the trick and push it (or does that mean that git will still have a history of all those commits? - aka. 6MB). \nMy end goal here is to basically find the best way to get rid of the folder contents from git so that a user doesn't have to download 6MB worth of stuff and still possibly have the other commits that never touched the modules folder (that's pretty much all of them) in git's history.\nHow can I do this?"}, {"role": "assistant", "content": "WARNING: git filter-branch is no longer officially recommended. The official recommendation is to use git-filter-repo; see André Anjos' answer for details.\n\nIf you are here to copy-paste code:\nThis is an example which removes node_modules from history\ngit filter-branch --tree-filter \"rm -rf node_modules\" --prune-empty HEAD\ngit for-each-ref --format=\"%(refname)\" refs/original/ | xargs -n 1 git update-ref -d\necho node_modules/ >> .gitignore\ngit add .gitignore\ngit commit -m 'Removing node_modules from git history'\ngit gc\ngit push origin main --force\n\nWhat git actually does:\nThe first line iterates through all references on the same tree (--tree-filter) as HEAD (your current branch), running the command rm -rf node_modules. This command deletes the node_modules folder (-r, without -r, rm won't delete folders), with no prompt given to the user (-f). The added --prune-empty deletes useless (not changing anything) commits recursively.\nThe second line deletes the reference to that old branch.\nThe rest of the commands are relatively straightforward."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Count the number of commits on a Git branch\nI found this answer already: Number of commits on branch in git\nbut that assumes that the branch was created from master.\nHow can I count the number of commits along a branch without relying on that assumption?\nIn SVN this is trivial, but for some reason is really difficult to figure out in git."}, {"role": "assistant", "content": "To count the commits for the branch you are on:\ngit rev-list --count HEAD\n\nfor a branch\ngit rev-list --count <branch-name>\n\nIf you want to count the commits on a branch that are made since you created the branch\ngit rev-list --count HEAD ^<branch-name>\n\nThis will count all commits ever made that are not on the branch-name as well.\nExamples\ngit checkout master\ngit checkout -b test\n<We do 3 commits>\ngit rev-list --count HEAD ^master\n\nResult: 3\nIf your branch comes of a branch called develop:\ngit checkout develop\ngit checkout -b test\n<We do 3 commits>\ngit rev-list --count HEAD ^develop\n\nResult: 3\nIgnoring Merges\nIf you merge another branch into the current branch without fast forward and you do the above, the merge is also counted. This is because for git a merge is a commit.\nIf you don't want to count these commits add --no-merges:\ngit rev-list --no-merges --count HEAD ^develop"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git: Set up a fetch-only remote?\nWhen I run git remote -v in one of my Git repositories that has a remote(s) configured, I see that each remote has both fetch and push specs:\n$ git remote -v\n<remote-name> ssh://host/path/to/repo (fetch)\n<remote-name> ssh://host/path/to/repo (push)\n\nFor remotes that point to peer developers there's no need to push, and Git will refuse to push to a non-bare repository anyway. Is there any way to configure these remotes as \"fetch-only\" with no push address or capabilities?"}, {"role": "assistant", "content": "I don't think you can remove the push URL, you can only override it to be something other than the pull URL. So I think the closest you'll get is something like this:\n$ git remote set-url --push origin no-pushing\n$ git push\nfatal: 'no-pushing' does not appear to be a git repository\nfatal: The remote end hung up unexpectedly\n\nYou are setting the push URL to no-pushing, which, as long as you don't have a folder of the same name in your working directory, git will not be able to locate. You are essentially forcing git to use a location that does not exist."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-unpack-objects"}, {"role": "assistant", "content": "Unpack objects from a packed archive"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What user will Ansible run my commands as?\nBackground\nMy question seems simple, but it gets more complex really fast.\nBasically, I got really tired of maintaining my servers manually (screams in background) and I decided it was time to find a way to make being a server admin much more liveable. That's when I found Ansible. Great huh? Sure beats making bash scripts (louder scream) for everything I wanted to automate.\nWhat's the problem?\nI'm having a lot of trouble figuring out what user my Ansible playbook will run certain things as. I also need the ability to specify what user certain tasks will run as. Here are some specific use cases:\nCloning a repo as another user:\nMy purpose with this is it run my node.js webapp from another user, who we'll call bill (that can only use sudo to run a script that I made that starts the node server, as opposed to root or my user that can use sudo for all commands). To do this, I need the ability to have Ansible's git module clone my git repo as bill. How would I do that?\nKnowing how Ansible will gain root:\nAs far as I understand, you can set what user Ansible will connect to the server you're maintaining by defining 'user' and the beginning of the playbook file. Here's what I don't understand: if I tell it to connect via my username, joe, and ask it to update a package via the apt module, how will it gain root? Sudo usually prompts me for my password, and I'd prefer keeping it that way (for security).\nFinal request\nI've scoured the Ansible docs, done some (what I thought was thorough) Googling, and generally just tried to figure it out on my own, but this information continues to elude me.\nI am very new to Ansible, and while it's mostly straight-forwards, I would benefit greatly if I could understand exactly how Ansible runs, on which users it runs, and how/where I can specify what user to use at different times.\nThank you tons in advance"}, {"role": "assistant", "content": "You may find it useful to read the Hosts and Users section on Ansible's documentation site:\nhttp://docs.ansible.com/playbooks_intro.html#hosts-and-users\nIn summary, ansible will run all commands in a playbook as the user specified in the remote_user variable (assuming you're using ansible >= 1.4, user before that). You can specify this variable on a per-task basis as well, in case a task needs to run as a certain user.\nUse sudo: true in any playbook/task to use sudo to run it. Use the sudo_user variable to specify a user to sudo to if you don't want to use root.\nIn practice, I've found it easiest to run my playbook as a deploy user that has sudo privileges. I set up my SSH keys so I can SSH into any host as deploy without using a password. This means that I can run my playbook without using a password and even use sudo if I need to.\nI use this same user to do things like cloning git repos and starting/stopping services. If a service needs to run as a lower-privileged user, I let the init script take care of that. A quick Google search for a node.js init.d script revealed this one for CentOS:\nhttps://gist.github.com/nariyu/1211413\nDoing things this way helps to keep it simple, which I like.\nHope that helps."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is the reason for the /a /b prefixes of git diff\nI've been using Git for some years now and always wondered why git diff prefixes the names of modified files with a/ and b/. I expected to eventually stumble upon a use-case where it is useful, but until now it was always annoying and never helpful.\nWhat is it good for? Why is this enabled by default? In which situations is it useful?"}, {"role": "assistant", "content": "As mentioned in the diff man page, a/ and b/ represent the prefix to differentiate source and destination.\nActually, you have the options:\n\n--no-prefix\n\nDo not show any source or destination prefix.\n--src-prefix=<prefix>\n\nShow the given source prefix instead of \"a/\".\n--dst-prefix=<prefix>\n\nShow the given destination prefix instead of \"b/\"\n\n\nGringo Suave adds in the comments:\n\nWent with:\ngit diff --src-prefix=\"SRC \" --dst-prefix=\"DST \" \n\nto make double-click select and paste work.\n\n\nBy the way, it does not have to always be a/ and b/:\nWith Git 2.45 (Q2 2024), batch 12, \"git diff\"(man) and friends learned two extra configuration variables, diff.srcPrefix and diff.dstPrefix.\nSee commit 178401d (15 Mar 2024) by Junio C Hamano (gitster).\nSee commit 7fdc265 (15 Mar 2024) by Peter Hutterer (whot).\n(Merged by Junio C Hamano -- gitster -- in commit 396430b, 28 Mar 2024)\n\ndiff: add diff.srcPrefix and diff.dstPrefix configuration variables\nSigned-off-by: Peter Hutterer\n\n\nAllow the default prefixes \"a/\" and \"b/\" to be tweaked by the diff.srcPrefix and diff.dstPrefix configuration variables.\n\ngit config now includes in its man page:\n\ndiff.srcPrefix\nIf set, 'git diff' uses this source prefix. Defaults to \"a/\".\ndiff.dstPrefix\nIf set, 'git diff' uses this destination prefix. Defaults to \"b/\".\n\ndiff-options now includes in its man page:\n\n--default-prefix\nUse the default source and destination prefixes (\"a/\" and \"b/\").\nThis overrides configuration variables such as diff.noprefix,\ndiff.srcPrefix, diff.dstPrefix, and diff.mnemonicPrefix."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --find-copies-harder"}, {"role": "assistant", "content": "For performance reasons, by default, -C option finds copies only\nif the original file of the copy was modified in the same\nchangeset. This flag makes the command\ninspect unmodified files as candidates for the source of\ncopy. This is a very expensive operation for large\nprojects, so use it with caution. Giving more than one -C option has the same effect."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Remove old git commits\nI'm very new to git, and was wondering if something like this is possible?\n>git log --pretty=oneline --abbrev-commit\n2f05aba Added new feature\n3371cec Fixed screw up <-- I want to remove this\ndaed25c Screw up <-- and remove this.\ne2b2a84 First. So it's like they never happend.\n\nIs this possible?"}, {"role": "assistant", "content": "If you truly wish to delete them (wiping them from history, never to be seen any more), you can\nrun rebase:\ngit rebase -i HEAD~4\n\nand then, just delete (or comment out) the lines corresponding to the commits you wish to delete, like so:\npick 2f05aba ... #will be preserved\n#pick 3371cec ... #will be deleted\n#pick daed25c ... #will be deleted\npick e2b2a84 ... #will be preserved"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-submodule - Initialize, update or inspect submodules --dissociate"}, {"role": "assistant", "content": "This option is only valid for add and update commands. These\ncommands sometimes need to clone a remote repository. In this case,\nthis option will be passed to the git-clone command. NOTE : see the NOTE for the --reference option."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker --html-path"}, {"role": "assistant", "content": "Print the path, without trailing slash, where Git’s HTML\ndocumentation is installed and exit."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to delete a file tracked by git-lfs and release the storage quota?\n\nHow to delete a never-use-again file and release the storage back to the github lfs quota?\nDoes deleting the reference point of the file in git history work in this situation?"}, {"role": "assistant", "content": "There doesn't currently appear to be a great way of removing large assets from git-lfs. GitHub's current suggestion is to use a tool called The BFG to completely strip all existence of the file from your repo.\nPresumably it'll then be removed from the lfs storage when git's garbage collection is next run by GitHub.\nFor more info see https://help.github.com/en/github/managing-large-files/removing-files-from-git-large-file-storage\nEdit 2019-11-20\nGitHub has updated their documentation on this explicitly stating there is no way to free up your git-lfs storage without deleting your repository. https://help.github.com/en/github/managing-large-files/removing-files-from-git-large-file-storage\nTheir only recommendation is to still use the BFG tool to strip the file from your repository, which will reduce the size of your repository when cloning, but will still count towards your git-lfs quota until you delete the repository.\nGitLab again suggests using the BFG tool and will automatically clean the lfs storage of any files which aren't referenced in any commits, although currently this doesn't seem to be working correctly. This issue has been open since 2017 with no resolution.\nBitBucket has a section in the repository settings which you can clean up lfs files. https://www.atlassian.com/git/tutorials/git-lfs#deleting-remote-files"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options fetch.output"}, {"role": "assistant", "content": "Control how ref update status is printed. Valid values are full and compact . Default value is full . See the\nOUTPUT section in git-fetch for details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git produces Gtk-WARNING: cannot open display\nI've been working on my project remotely through the command line on a machine to which I don't have admin rights and after running git push origin master I get the following error message:\n(gnome-ssh-askpass:29241): Gtk-WARNING **: cannot open display:\n\nMy .git/config file has the following contents:\n\n [core]\n repositoryformatversion = 0\n filemode = true\n bare = false\n logallrefupdates = true \n [remote \"origin\"]\n fetch = +refs/heads/*:refs/remotes/origin/*\n url = https://[email protected]/username/repository.git \n [branch \"master\"]\n remote = origin\n merge = refs/heads/master\n\n\nI was getting the 403 error earlier. Following the comment here, I put my username before the @ sign in the remote url and since then, I've been getting the Gtk error.\nWhen I login to the machine using ssh -X and try to push, I get the following error:\nX11 connection rejected because of wrong authentication.\n(gnome-ssh-askpass:31922): Gtk-WARNING **: cannot open display:localhost:10.0\n\nIf I change the url of the remote to [email protected]:username/repository.git, then the error is:\nssh: connect to host github.com port 22: Connection timed out\nfatal: The remote end hung up unexpectedly\n\nDo you know how to fix this?"}, {"role": "assistant", "content": "I have finally discovered a solution to the problem. As it was described here, I ran the following command in the terminal:\n unset SSH_ASKPASS\n\nand then running git push origin master works the way it should. You can also add the line to your .bashrc file."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -R"}, {"role": "assistant", "content": "Swap two inputs; that is, show differences from index or\non-disk file to tree contents."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Maximum commit message size\nIs there any size limit to the Git commit message? I searched through the web but cannot find any relevant mention about this except this one.\nHowever, that one does not answer my question."}, {"role": "assistant", "content": "Empirically, I think the answer is no. This worked (that's a ~100MB commit message):\nyes | head -c 100000000 | git commit -F - > /dev/null\n\nCommand parts explanation:\n\nyes repeats \"y\\n\" forever\nhead -c 100000000 takes only the first 100,000,000 bytes (~100MB)\ngit commit -F - commits with the passed-in commit message (this won’t work if you haven’t staged any changes to commit)\n> /dev/null hides the output from the command, which includes Git repeating back the very long commit message"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -l<num>"}, {"role": "assistant", "content": "The -M and -C options involve some preliminary steps that\ncan detect subsets of renames/copies cheaply, followed by an\nexhaustive fallback portion that compares all remaining\nunpaired destinations to all relevant sources. (For renames,\nonly remaining unpaired sources are relevant; for copies, all\noriginal sources are relevant.) For N sources and\ndestinations, this exhaustive check is O(N^2). This option\nprevents the exhaustive portion of rename/copy detection from\nrunning if the number of source/destination files involved\nexceeds the specified number. Defaults to diff.renameLimit.\nNote that a value of 0 is treated as unlimited."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Revert to a commit by a SHA hash in Git? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do I revert a Git repository to a previous commit?\n\n (41 answers)\n \n\nClosed 9 years ago.\n\n\n\nI'm not clear on how git revert works. For example, I want to revert to a commit six commits behind the head, reverting all the changes in the intermediary commits in between.\nSay its SHA hash is 56e05fced214c44a37759efa2dfc25a65d8ae98d. Then why can't I just do something like:\ngit revert 56e05fced214c44a37759efa2dfc25a65d8ae98d"}, {"role": "assistant", "content": "If you want to commit on top of the current HEAD with the exact state at a different commit, undoing all the intermediate commits, then you can use reset to create the correct state of the index to make the commit.\n# Reset the index and working tree to the desired tree\n# Ensure you have no uncommitted changes that you want to keep\ngit reset --hard 56e05fced\n\n# Move the branch pointer back to the previous HEAD\ngit reset --soft \"HEAD@{1}\"\n\ngit commit -m \"Revert to 56e05fced\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-diff-tree"}, {"role": "assistant", "content": "Compares the content and mode of blobs found via two tree objects"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I move all git content one-level up in the folder hierarchy?\nI have a git repository whose structure looks like:\n+--repo.git\n|\n+----+bootstrap.py\n+----+buildout.cfg\n+----+.gitignore\n+----+webapp\n|\n+---------+manage.py\n+---------+modules\n+---------+templates\n+---------+static\n+---------+...\n+---------+...\n\nI would like to move the contents of the webapp folder one level up. My resulting repo should look like:\n+--repo.git\n|\n+----+bootstrap.py\n+----+buildout.cfg\n+----+.gitignore\n+----+manage.py\n+----+modules\n+----+templates\n+----+static\n+----+...\n+----+...\n\nCan I do this by simply moving all the files of the webapp directory one level up, deleting the empty webapp directory and then committing the changes? Would this preserve the commit history of the files under the webapp directory?\nAlthough a very simple question for many of you, I'd like to be sure. The last thing I'd want is a git soup.\n\nI tried moving the files but I lost the commit history as git doesn't really handle a move or a rename. I do know that even though it shows up as a new file in the logs, it is still possible to view the commit history for the file using some options in git log.\nFrom what I've read, the best way to accomplish this would be using git-filter. I'm not very good with shell or git so could someone tell me what I'd need to execute to do the aforementioned."}, {"role": "assistant", "content": "The right way to do this is:\ngit mv repo.git/webapp/* repo.git/.\ngit rm repo.git/webapp\ngit add * \ngit commit -m \"Folders moved out of webapp directory :-)\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs"}, {"role": "assistant", "content": "NAME git-log - Show commit logs"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git rebase merge conflict cannot continue\nI'm trying to rebase 'dev' to catch up to 'master' branch. \n$ git checkout dev \n$ git rebase master \nFirst, rewinding head to replay your work on top of it...\nApplying: Corrected compilation problems that came from conversion from SVN.\nUsing index info to reconstruct a base tree...\nM src/com/....\n<stdin>:125: trailing whitespace.\n/**\n<stdin>:126: trailing whitespace.\n *\n<stdin>:127: trailing whitespace.\n */\n<stdin>:128: trailing whitespace.\npackage com....\n<stdin>:129: trailing whitespace.\n\nwarning: squelched 117 whitespace errors\nwarning: 122 lines add whitespace errors.\nFalling back to patching base and 3-way merge...\nAuto-merging src/com/....\nCONFLICT (content): Merge conflict in src/com/...\nFailed to merge in the changes.\nPatch failed at 0001 Corrected compilation problems that came from conversion from SVN.\n\nWhen you have resolved this problem run \"git rebase --continue\".\nIf you would prefer to skip this patch, instead run \"git rebase --skip\".\nTo check out the original branch and stop rebasing run \"git rebase --abort\".\n\n$ vi src/com/..... { fixed the merge issue on one file } \n$ git add -A . \n$ git rebase --continue \nsrc/com/....: needs merge\nYou must edit all merge conflicts and then\nmark them as resolved using git add\n$ vi src/com.... { verified, no >>> or <<< left, no merge markers } \n$ git rebase --continue \nApplying: Corrected compilation problems that came from conversion from SVN.\nNo changes - did you forget to use 'git add'?\nIf there is nothing left to stage, chances are that something else\nalready introduced the same changes; you might want to skip this patch.\n\nWhen you have resolved this problem run \"git rebase --continue\".\nIf you would prefer to skip this patch, instead run \"git rebase --skip\".\nTo check out the original branch and stop rebasing run \"git rebase --abort\".\n\nAny ideas?"}, {"role": "assistant", "content": "There are a couple situations where I've seen rebase get stuck. One is if the changes become null (a commit has changes that were already made previously in the rebase) in which case you may have to use git rebase --skip.\nIt's pretty easy to tell. If you do git status it should show no changes. If so just skip it. If that isn't the case please post a copy of git status and I can try to help further."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff-index - Compare a tree to the working tree or index"}, {"role": "assistant", "content": "NON-CACHED MODE The \"non-cached\" mode takes a different approach, and is potentially\nthe more useful of the two in that what it does can’t be emulated with\na git write-tree + git diff-tree . Thus that’s the default mode.\nThe non-cached version asks the question: show me the differences between HEAD and the currently checked out\ntree - index contents _and_ files that aren't up to date which is obviously a very useful question too, since that tells you what\nyou could commit. Again, the output matches the git diff-tree -r output to a tee, but with a twist. The twist is that if some file doesn’t match the index, we don’t have\na backing store thing for it, and we use the magic \"all-zero\" sha1 to\nshow that. So let’s say that you have edited kernel/sched.c , but\nhave not actually done a git update-index on it yet - there is no\n\"object\" associated with the new state, and you get: torvalds@ppc970:~/v2.6/linux> git diff-index --abbrev HEAD\n:100644 100644 7476bb5ba 000000000 M\tkernel/sched.c i.e., it shows that the tree has changed, and that kernel/sched.c is\nnot up to date and may contain new stuff. The all-zero sha1 means that to\nget the real diff, you need to look at the object in the working directory\ndirectly rather than do an object-to-object diff. Note As with other commands of this type, git diff-index does not\nactually look at the contents of the file at all. So maybe kernel/sched.c hasn’t actually changed, and it’s just that you\ntouched it. In either case, it’s a note that you need to git update-index it to make the index be in sync. Note You can have a mixture of files show up as \"has been updated\"\nand \"is still dirty in the working directory\" together. You can always\ntell which file is in which state, since the \"has been updated\" ones\nshow a valid sha1, and the \"not in sync with the index\" ones will\nalways have the special all-zero sha1."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to merge branch to master?\n\nI do have a local branch with some changes, and I want to merge it to remote master. When I run: git merge master I get: \n\nAlready up-to-date\n\nbut I still can see that the master doesn't contain the new changes. \nI checked the following issue Git merge reports “Already up-to-date” though there is a difference Ask, but it seems in one hand to be outdated, and on the other hand, none of the hints there were helpful.\nAny idea or hint?"}, {"role": "assistant", "content": "If you want to merge your branch to master on remote, follow the below steps:\n\npush your branch say 'br-1' to remote using git push origin br-1.\nswitch to master branch on your local repository using git checkout master.\nupdate local master with remote master using git pull origin master.\nmerge br-1 into local master using git merge br-1. This may give you conflicts which need to be resolved and changes committed before moving further.\nOnce merge of br-1 to master on local is committed, push local master to remote master using git push origin master."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-send-email - Send a collection of patches as emails"}, {"role": "assistant", "content": "NAME git-send-email - Send a collection of patches as emails"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.<driver>.xfuncname"}, {"role": "assistant", "content": "The regular expression that the diff driver should use to\nrecognize the hunk header. A built-in pattern may also be used.\nSee gitattributes for details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --inter-hunk-context=<lines>"}, {"role": "assistant", "content": "Show the context between diff hunks, up to the specified number\nof lines, thereby fusing hunks that are close to each other.\nDefaults to diff.interHunkContext or 0 if the config option\nis unset."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why am I getting \"Commit failed with error: pathspec ... did not match any file(s)\"?\nI am having some issues with Git.\nI have a repository where I can commit any file to without problem. However, there is a single file 'Funder.php' which, when I try committing, tells me there is an error as:\nCommit failed with error:\npathspec 'application/libraries/Funder.php' did not match any file(s) known to git.\n\nI am quite new to this, so was wondering if anybody could please help?"}, {"role": "assistant", "content": "The reason why this error happens is pointed in this post: https://stackoverflow.com/a/29485441/2769415\n\nWindows’ file system is mostly case-insensitive, so you cannot rename\n a file by just changing its capitalization. Instead, you will have to\n use a temporary name in between.\n\nSolution:\nRename the file back to the original one, then rename it to a different name, then back to the one with the correct capitalization. Git will not throw the bug anymore.\nExample:\nCreated FOOBar class.\nRenamed it to FooBar and then got the error.\nRename it back to FOOBar.\nRename to FooBarTest.\nRename to FooBar.\nGit works now."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order --full-history without parent rewriting"}, {"role": "assistant", "content": "This mode differs from the default in one point: always follow\nall parents of a merge, even if it is TREESAME to one of them.\nEven if more than one side of the merge has commits that are\nincluded, this does not imply that the merge itself is! In\nthe example, we get I A B N D O P Q M was excluded because it is TREESAME to both parents. E , C and B were all walked, but only B was !TREESAME, so the others\ndo not appear. Note that without parent rewriting, it is not really possible to talk\nabout the parent/child relationships between the commits, so we show\nthem disconnected."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Enabling Git syntax highlighting for Mac's terminal\nI miss the Git syntax highlighting I had on Windows for every \"git .*\" command like green staged filenames, some bolding, etc.\nHow do I enable Git syntax highlighting for Mac's terminal?"}, {"role": "assistant", "content": "git config --global color.ui auto"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Error \"Waiting for a runner to pick up this job\" using GitHub Actions\n\nWhen I use GitHub Actions with my config, there is a long waiting and it shows \"Waiting for a runner to pick up this job\".\nWhat does 'runner' mean? And how can I resolve the problem?"}, {"role": "assistant", "content": "One potential reason might be that GitHub does not support anymore the operating system you're requesting.\nFor example, the following would not work:\nruns-on: ubuntu-18.04\n\nbecause GitHub stopped supporting Ubuntu 18.04 on April 1, 2023, see:\nhttps://github.com/actions/runner-images/issues/6002\nThe solution is to use a supported operating system, for example:\nruns-on: ubuntu-latest\n\nFor a list of supported operating systems, see:\nhttps://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -I<regex> --ignore-matching-lines=<regex>"}, {"role": "assistant", "content": "Ignore changes whose all lines match <regex>. This option may\nbe specified more than once."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker gitcredentials"}, {"role": "assistant", "content": "Providing usernames and passwords to Git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %aE"}, {"role": "assistant", "content": "author email (respecting .mailmap, see git-shortlog or git-blame )"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --dirstat-by-file[=<param1,param2>…​]"}, {"role": "assistant", "content": "Synonym for --dirstat=files,<param1>,<param2>…​"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitglossary - A Git Glossary rewind"}, {"role": "assistant", "content": "To throw away part of the development, i.e. to assign the head to an earlier revision ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-switch - Switch branches --guess --no-guess"}, {"role": "assistant", "content": "If <branch> is not found but there does exist a tracking\nbranch in exactly one remote (call it <remote> ) with a\nmatching name, treat as equivalent to $ git switch -c <branch> --track <remote>/<branch> If the branch exists in multiple remotes and one of them is named by\nthe checkout.defaultRemote configuration variable, we’ll use that\none for the purposes of disambiguation, even if the <branch> isn’t\nunique across all remotes. Set it to e.g. checkout.defaultRemote=origin to always checkout remote branches from there if <branch> is\nambiguous but exists on the origin remote. See also checkout.defaultRemote in git-config . --guess is the default behavior. Use --no-guess to disable it. The default behavior can be set via the checkout.guess configuration\nvariable."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Resolving a 'both added' merge conflict in git?\nI'm rebasing in git, and one conflict I get is 'both added' - that is, exactly the same filename has been added independently in my branch, and in the branch I'm rebasing on. git status tells me:\n# Unmerged paths:\n# (use \"git reset HEAD <file>...\" to unstage)\n# (use \"git add/rm <file>...\" as appropriate to mark resolution)\n#\n# both added: src/MyFile.cs\n\nWhat are my options to resolve this either by a merge tool or from the commandline?\nIf I were to use git rm src/MyFile.cs, how would it know which file version I wanted to remove or keep?"}, {"role": "assistant", "content": "If you use git rm git will remove all versions of that path from the index so your resolve action will leave you without either version.\nYou can use git checkout --ours src/MyFile.cs to choose the version from the branch onto which you are rebasing or git checkout --theirs src/MyFile.cs to choose the version from the branch which you are rebasing.\nIf you want a blend you need to use a merge tool or edit it manually."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker gitdiffcore"}, {"role": "assistant", "content": "Tweaking diff output"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is the difference between \"Revert Commit\" and \"Undo Commit\" in IntelliJ IDEA?\nIn IntelliJ Ultimate IDEA 2019.3 (not sure when it was introduced) we have \"Revert Commit\" and \"Undo Commit\" options in the Version Control -> Log Tab.\n\nWhat is the difference between those two options?"}, {"role": "assistant", "content": "Undo the last commit\n\nIntelliJ IDEA allows you to undo the last commit in the current branch (for example, HEAD).\nNote: You cannot undo a commit if it was pushed to a protected branch, that is a branch to which force --push is not allowed (configure protected branches in the Settings/Preferences dialog Ctrl+Alt+S under Version Control | Git).\n\nOpen the Version Control window Alt+9 and switch to the Log tab.\nSelect the last commit in the current branch and choose Undo Commit from the context menu.\nIn the dialog that opens, select a changelist where the changes you are going to discard will be moved. You can either select an existing changelist from the Name list, or specify the name of a new changelist (the commit message is used by default).\nSelect the Set active option if you want to make the changelist with the changes you are about to discard the active changelist.\nSelect the Track context option if you want IntelliJ IDEA to remember your context and reload currently opened files in the editor when this changelist becomes active.\n\n\nRevert a pushed commit\n\nIf you notice an error in a specific commit that has already been pushed, you can revert that commit. This operation results in a new commit that reverses the effect of the commit you want to undo. Thus, project history is preserved, as the original commit remains intact.\n\nLocate the commit you want to revert in the Log tab of the Version Control window Alt+9, right-click it and select Revert Commit from the context menu. This option is also available from the context menu of a commit in the File History view. The Commit Changes dialog will open with an automatically generated commit message.\nIf the selected commit contains several files, and you only need to revert some of them, deselect the files you do not want to touch.\nClick Commit to commit a changeset that reverts changes to the selected files in this particular commit.\n\nFor more information please refer here"}]} {"messages": [{"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\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I clone a private GitLab repository?\n\nWhen I do this:\ngit clone https://example.com/root/test.git\n\nI am getting this error:\n\nfatal: HTTP request failed\n\nWhen I use SSH:\ngit clone username [email protected]:root/test.git\n\nI am getting this error:\n\nInitialized empty Git repository in /server/user/[email protected]:root/test.git/.git/ \n fatal: 'user' does not appear to be a git repository \n fatal: The remote end hung up unexpectedly\n\nIt's a private repository, and I have added my SSH keys."}, {"role": "assistant", "content": "It looks like there's not a straightforward solution for HTTPS-based cloning regarding GitLab. Therefore if you want a SSH-based cloning, you should take account these three forthcoming steps:\n\nCreate properly an SSH key using your email used to sign up. I would use the default filename to key for Windows. Don't forget to introduce a password! (tip: you can skip this step if you already have one ssh key here)\n $ ssh-keygen -t rsa -C \"[email protected]\" -b 4096\n\n Generating public/private rsa key pair.\n Enter file in which to save the key ($PWD/.ssh/id_rsa): [\\n]\n Enter passphrase (empty for no passphrase):[your password]\n Enter same passphrase again: [your password]\n Your identification has been saved in $PWD/.ssh/id_rsa.\n Your public key has been saved in $PWD/.ssh/id_rsa.pub.\n\n\nCopy and paste all content from the recently id_rsa.pub generated into Setting>SSH keys>Key from your GitLab profile.\n # Copy to clipboard\n pbcopy < ~/.ssh/id_rsa.pub\n\n\nGet locally connected:\n $ ssh -i $PWD/.ssh/id_rsa [email protected]\n\n Enter passphrase for key \"$PWD/.ssh/id_rsa\": [your password]\n PTY allocation request failed on channel 0\n Welcome to GitLab, you!\n Connection to gitlab.com closed.\n\n\n\nFinally, clone any private or internal GitLab repository!\n$ git clone https://git.metabarcoding.org/obitools/ROBIBarcodes.git\n\nCloning into 'ROBIBarcodes'...\nremote: Counting objects: 69, done.\nremote: Compressing objects: 100% (65/65), done.\nremote: Total 69 (delta 14), reused 0 (delta 0)\nUnpacking objects: 100% (69/69), done."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Visual Studio 2013 git, only Master branch listed\nI'm using Visual Studio 2013's Git support to work on a private GitHub repository. I have permission to commit to it. I want to switch branches, but when I go to the Branches view, the only branch in any of the lists (branch drop-down, published branches, merge tool) is master. Other branches show up in GitHub, GitHub for Windows, and TortoiseGit. So I know they're there and I have access.\nAny ideas why I can't see other branches in Visual Studio?\n\nI'm running Visual Studio 2013 Update 2."}, {"role": "assistant", "content": "The branch dropdown will only show local branches, it will not show remote branches. You should create a new local branch to track that remote branch. Simply click the New Branch dropdown, and you will see all the remote branches:\n\nOnce you've done that, this will appear as a \"published branch\" allowing you to push and pull to it."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --notes[=<ref>]"}, {"role": "assistant", "content": "Show the notes (see git-notes ) that annotate the\ncommit, when showing the commit log message. This is the default\nfor git log , git show and git whatchanged commands when\nthere is no --pretty , --format , or --oneline option given\non the command line. By default, the notes shown are from the notes refs listed in the core.notesRef and notes.displayRef variables (or corresponding\nenvironment overrides). See git-config for more details. With an optional <ref> argument, use the ref to find the notes\nto display. The ref can specify the full refname when it begins\nwith refs/notes/ ; when it begins with notes/ , refs/ and otherwise refs/notes/ is prefixed to form the full name of the ref. Multiple --notes options can be combined to control which notes are\nbeing displayed. Examples: \"--notes=foo\" will show only notes from\n\"refs/notes/foo\"; \"--notes=foo --notes\" will show both notes from\n\"refs/notes/foo\" and from the default notes ref(s)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git and hard links\nConsidering that Git does not recognize symbolic links that point outside of the repository, is there any problem using hard links? \nCould Git break them?\nCan you please point me to detailed information?"}, {"role": "assistant", "content": "The 'tree' object, representing directories in Git, stores file name and (subset of) permissions. It doesn't store inode number (or other kind of file id). Therefore hard links cannot be represented in git, at least not without third party tools such as metastore or git-cache-meta (and I am not sure if it is possible even with those tools).\nGit tries to not touch files that it doesn't need to update, but you have to take into account that git doesn't try to preserve hardlinks, so they can be broken by git.\n\nAbout symbolic links pointing outside repository: git has no problems with them and should preserve contents of symbolic links... but utility of such links is dubious to me, as whether those symlinks would be broken or not depends on the filesystem layout outside git repository, and not under control of git."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Case sensitivity in Git\nI've run into a problem with git. Basically I set to false core.ignorecase because I wanted to change the case of the names of some folders (since I'm under OSX with a case-insensitive filesystem, the changes weren't shown otherwise). When I pulled my data, I've noticed that now every renamed folder appears twice on the repository, with both the old and the new name. I don't know what to do to remove the old folders since they don't appear locally (I've try to set core.ignorecase to true again but it isn't helping)."}, {"role": "assistant", "content": "May be a workaround similar to this comment in an msysgit issue (for another case-insensitive OS: Windows) could help?\n\nI've encountered this same issue. Refactored a package name in Eclipse and switching to a previous build broke due to the folder name not reverting. I'm using Windows 7, Git 1.7.0.2.msysgit.0\nMy folder was renamed in Windows to \"folder\" but was displayed as \"Folder\" in Git.\nI fixed the issue by renaming it to \"Folder\" in Windows and then running:\n\ngit mv \"Folder\" \"Folder2\"\ngit mv \"Folder2\" \"folder\"\n\n\nNote that since git 2.0.1 (June 2014), git mv Folder folder should just work!\nSee \"Git: Changing capitalization of filenames\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.<driver>.command"}, {"role": "assistant", "content": "The custom diff driver command. See gitattributes for details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-push - Update remote refs along with associated objects remote rejected"}, {"role": "assistant", "content": "The remote end refused the update. Usually caused by a hook\non the remote side, or because the remote repository has one\nof the following safety options in effect: receive.denyCurrentBranch (for pushes to the checked out\nbranch), receive.denyNonFastForwards (for forced\nnon-fast-forward updates), receive.denyDeletes or receive.denyDeleteCurrent . See git-config ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --anchored=<text>"}, {"role": "assistant", "content": "Generate a diff using the \"anchored diff\" algorithm. This option may be specified more than once. If a line exists in both the source and destination, exists only once,\nand starts with this text, this algorithm attempts to prevent it from\nappearing as a deletion or addition in the output. It uses the \"patience\ndiff\" algorithm internally."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitkraken - How to compare 2 branches\nIs there any way to compare 2 branches (branch1 and branch2) with gitkraken?\nI want a list of files that have changes"}, {"role": "assistant", "content": "If you want to find out difference between branch A and B\nFirst checkout on branch A then click on branch B and select commits it then you can find changes on right panel.\n\nand can select multiple commit rows in the graph using Shift Click to show its merged diff"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects -p -u --patch"}, {"role": "assistant", "content": "Generate patch (see Generating patch text with -p )."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Does Git Add have a verbose switch\n\nI am in the process of moving all my private an public repo's over to github. One of the decisions I have made is to only use the console as it means a smaller tooling footprint if I ever need to change PCs, etc.\nI would be a huge user of console applications and being new to git I decided to purchase Tekpub's Mastering Git series since it shows you how to intergrate git bash as a toolbar.\nEverything is working fine except for the add all command which is:\ngit add .\n\nIt seems to be working but I don't get any indication of it working or not. Is there a verbose switch (I think that is what it would be called) that would say what files were tracked after the command is launched?\nI am using Visual Studio 2010 with the standard install of git (Not Git extensions)"}, {"role": "assistant", "content": "For some git-commands you can specify --verbose,\ngit 'command' --verbose\n\nor\ngit 'command' -v\n\nMake sure the switch is after the actual git command. Otherwise - it won't work!\nAlso useful:\ngit 'command' --dry-run"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git recover deleted file where no commit was made after the delete\nI deleted some files. \nI did NOT commit yet. \nI want to reset my workspace to recover the files. \nI did a git checkout ..\nBut the deleted files are still missing.\nAnd git status shows:\n# On branch master\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# deleted: cc.properties\n# deleted: store/README\n# deleted: store/cc.properties\n#\n\nWhy doesn't git checkout . reset the workspace to HEAD?"}, {"role": "assistant", "content": "The output tells you what you need to do. git reset HEAD cc.properties etc. \nThis will unstage the rm operation. After that, running a git status again will tell you that you need to do a git checkout -- cc.properties to get the file back. \nUpdate:\nI have this in my config file\n$ git config alias.unstage\nreset HEAD\n\nwhich I usually use to unstage stuff."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How Do I Upload Eclipse Projects to GitHub?\n\nI have code in Eclipse that I'd like to upload to GitHub but so far I can't figure out how. It says \"create a repository\" but that looks more like a folder that holds your projects and I'm not sure how to upload my code to it. Apologies for the seemingly dumb question. Also, how does one delete repositories? Didn't see a way to do that either."}, {"role": "assistant", "content": "While the EGit plugin for Eclipse is a good option, an even better one would be to learn to use git bash -- i.e., git from the command line. It isn't terribly difficult to learn the very basics of git, and it is often very beneficial to understand some basic operations before relying on a GUI to do it for you. But to answer your question:\nFirst things first, download git from http://git-scm.com/. Then go to http://github.com/ and create an account and repository.\nOn your machine, first you will need to navigate to the project folder using git bash. When you get there you do:\ngit init\n\nwhich initiates a new git repository in that directory.\nWhen you've done that, you need to register that new repo with a remote (where you'll upload -- push -- your files to), which in this case will be github. This assumes you have already created a github repository. You'll get the correct URL from your repo in GitHub.\ngit remote add origin https://github.com/[username]/[reponame].git\n\nYou need to add you existing files to your local commit:\ngit add . # this adds all the files\n\nThen you need to make an initial commit, so you do:\ngit commit -a -m \"Initial commit\" # this stages your files locally for commit. \n # they haven't actually been pushed yet\n\nNow you've created a commit in your local repo, but not in the remote one. To put it on the remote, you do the second line you posted:\ngit push -u origin --all"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "github actions: how to check if current push has new tag (is new release)?\nname: test-publish\n\non: [push]\n\njobs:\n test:\n strategy:\n ...\n steps:\n ...\n\n publish:\n needs: test\n if: github.event_name == 'push' && github.ref???\n steps:\n ... # eg: publish package to PyPI\n\nWhat should I put in jobs.publish.if in order to check that this commit is new release?\nIs this okay: contains(github.ref, '/tags/')?\nWhat will happen if I push code and tag at the same time?"}, {"role": "assistant", "content": "You could do this to check if the current push event is for a tag starting with v.\n publish:\n needs: test\n if: startsWith(github.ref, 'refs/tags/v')\n\nAs you pointed out though, I don't think you can guarantee that this is a new release. My suggestion would be to use on: release instead of on: push. This will only trigger on a newly tagged release.\nSee the docs for on: release here:\nhttps://docs.github.com/en/actions/reference/events-that-trigger-workflows#release"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What are the differences between double-dot \"..\" and triple-dot \"...\" in Git commit ranges?\nSome Git commands take commit ranges and one valid syntax is to separate two commit names with two dots .., and another syntax uses three dots ....\nWhat are the differences between the two?"}, {"role": "assistant", "content": "Using Commit Ranges with Git Log\nWhen you're using commit ranges like .. and ... with git log, the difference between them is that, for branches A and B,\ngit log A..B\n\nwill show you all of the commits that B has that A doesn't have, while\ngit log A...B\n\nwill show you both the commits that A has and that B doesn't have, and the commits that B has that A doesn't have, or in other words, it will filter out all of the commits that both A and B share, thus only showing the commits that they don't both share.\nVisualization with Venn Diagrams & Commit Trees\nHere is a visual representation of git log A..B. The commits that branch B contains that don't exist in A is what is returned by the commit range, and is highlighted in red in the Venn diagram, and circled in blue in the commit tree:\n \nThese are the diagrams for git log A...B. Notice that the commits that are shared by both branches are not returned by the command:\n \nMaking the Triple-Dot Commit Range ... More Useful\nYou can make the triple-dot commit range ... more useful in a log command by using the --left-right option to show which commits belong to which branch:\n$ git log --oneline --decorate --left-right --graph master...origin/master\n< 1794bee (HEAD, master) Derp some more\n> 6e6ce69 (origin/master, origin/HEAD) Add hello.txt\n\nIn the above output, you'll see the commits that belong to master are prefixed with <, while commits that belong to origin/master are prefixed with >.\nUsing Commit Ranges with Git Diff\nSomeday I might add my own explanation for how the commit ranges work with git diff, but for now, you might want to check out What are the differences between double-dot \"..\" and triple-dot \"...\" in Git diff commit ranges?.\nSee Also\n\nPro Git § 6.1 Git Tools - Revision Selection - Commit Ranges"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options color.blame.highlightRecent"}, {"role": "assistant", "content": "Specify the line annotation color for git blame --color-by-age depending upon the age of the line. This setting should be set to a comma-separated list of color and\ndate settings, starting and ending with a color, the dates should be\nset from oldest to newest. The metadata will be colored with the\nspecified colors if the line was introduced before the given\ntimestamp, overwriting older timestamped colors. Instead of an absolute timestamp relative timestamps work as well,\ne.g. 2.weeks.ago is valid to address anything older than 2 weeks. It defaults to blue,12 month ago,white,1 month ago,red , which\ncolors everything older than one year blue, recent changes between\none month and one year old are kept white, and lines introduced\nwithin the last month are colored red."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "\"Warning: the ECDSA host key for 'github.com' differs from the key for the IP address\" issue\n\nI don't know what happened, but one day when I got up and git push my changes it gave:\nWarning: the ECDSA host key for 'github.com' differs from the key for the IP address '140.82.112.4'\nOffending key for IP in /Users/joyliu/.ssh/known_hosts:13\nMatching host key in /Users/joyliu/.ssh/known_hosts:16\n\nIt seems like I'm not able to connect to Github. I Googled the fix and did sed -i '13d' ~/.ssh/known_hosts to delete line 13 but then it shows the same error with a different line number.\nIt also happened when I did git pull.\nCan anyone help me? Thank you in advance!\n======== Update ========\nAfter ssh-keygen -R github.com and ssh-keyscan github.com >> ~/.ssh/known_hosts, it still doesn't work somehow... It gave:\n(base) ➜ liuzz10.github.io git:(master) ssh-keygen -R github.com\n# Host github.com found: line 17\n# Host github.com found: line 18\n# Host github.com found: line 19\n# Host github.com found: line 20\n/Users/joyliu/.ssh/known_hosts updated.\nOriginal contents retained as /Users/joyliu/.ssh/known_hosts.old\n(base) ➜ liuzz10.github.io git:(master) ssh-keyscan github.com >> ~/.ssh/known_hosts\n# github.com:22 SSH-2.0-babeld-4b034cc8\n# github.com:22 SSH-2.0-babeld-4b034cc8\n# github.com:22 SSH-2.0-babeld-4b034cc8\n(base) ➜ liuzz10.github.io git:(master) git pull\nWarning: the ECDSA host key for 'github.com' differs from the key for the IP address '140.82.112.4'\nOffending key for IP in /Users/joyliu/.ssh/known_hosts:13\nMatching host key in /Users/joyliu/.ssh/known_hosts:18\nAre you sure you want to continue connecting (yes/no)? yes\nfatal: refusing to merge unrelated histories\n(base) ➜ liuzz10.github.io git:(master) git push\nWarning: the ECDSA host key for 'github.com' differs from the key for the IP address '140.82.112.4'\nOffending key for IP in /Users/joyliu/.ssh/known_hosts:13\nMatching host key in /Users/joyliu/.ssh/known_hosts:18\nAre you sure you want to continue connecting (yes/no)? yes\nTo github.com:liuzz10/liuzz10.github.io.git\n ! [rejected] master -> master (non-fast-forward)\nerror: failed to push some refs to 'github.com:liuzz10/liuzz10.github.io.git'\nhint: Updates were rejected because the tip of your current branch is behind\nhint: its remote counterpart. Integrate the remote changes (e.g.\nhint: 'git pull ...') before pushing again.\nhint: See the 'Note about fast-forwards' in 'git push --help' for details."}, {"role": "assistant", "content": "If you are getting the following error:\nWarning: the ECDSA host key for 'github.com' differs from the key for the IP address 'IP_ADDRESS'\n\nI would recommend to do the following:\n$ ssh-keygen -R github.com\n\nIf that does not work then remove the IP itself from known-host:\n$ ssh-keygen -R IP_ADDRESS\n\nThis should would fix your issue."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git, fatal: The remote end hung up unexpectedly\nWhen I tried to run\ngit push origin master --force\n\nI just got\nCounting objects: 2649, done.\nDelta compression uses up to 2 threads.\nCompressing objects: 100% (1280/1280), done.\nerror: RPC failed; result=22, HTTP code = 413 | 116 KiB/s \nfatal: The remote end hung up unexpectedly\nWriting objects: 100% (2504/2504), 449.61 MiB | 4.19 MiB/s, done.\nTotal 2504 (delta 1309), reused 2242 (delta 1216)\nfatal: The remote end hung up unexpectedly\nEverything up-to-date\n\nIs it something to do with not being secure? I tried creating a public key as the answer for Fatal: The remote end hung up unexpectedly and rerunning it, but it still doesn't work. Am I not actually using the key? If so, how do I use it?"}, {"role": "assistant", "content": "This is due to git/https buffer settings.\nRun this (taken from Git fails when pushing commit to github):\ngit config http.postBuffer 524288000\n\nThen, run your original command again."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git -r <n> --revision=<n>"}, {"role": "assistant", "content": "Specify the most recent revision to keep. All later revisions\nare discarded."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-mergetool - Run merge conflict resolution tools to resolve merge conflicts"}, {"role": "assistant", "content": "NAME git-mergetool - Run merge conflict resolution tools to resolve merge conflicts"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-reset - Reset current HEAD to the specified state Reset a single file in the index"}, {"role": "assistant", "content": "Suppose you have added a file to your index, but later decide you do not\nwant to add it to your commit. You can remove the file from the index\nwhile keeping your changes with git reset. $ git reset -- frotz.c (1) $ git commit -m \"Commit files in index\" (2) $ git add frotz.c (3) This removes the file from the index while keeping it in the working\ndirectory. This commits all other changes in the index. Adds the file to the index again."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Update my github repo which is forked out from another project [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\n\nPull new updates from original GitHub repository into forked GitHub repository\n\n (8 answers)\n \n\nClosed 8 years ago.\n\n\n\nI have forked out a Parent: project to Child: this. Now, I want to update my child with parents current updates. Can I do that, if yes how?\nWhen I update my github repo, then I can do a \"git pull\" to update my local repo."}, {"role": "assistant", "content": "In your local clone of Child, pull from Parent, adding it as a remote if you like:\ncd child\ngit remote add parent <parent-url>\ngit pull parent\n\nThe url of the parent could be the public github repo, or your local clone of it - the local clone will of course be faster. If you want to pull a branch other than the current HEAD of the parent repo, just add an argument (e.g. git pull parent topic-branch). If this is a one-time thing, you can just skip adding the remote: git pull <parent-url> [branch].\nPulling is a combination of fetching and merging, so once you've done that, you've got a new merge commit you'll presumably want to push back to your public repo at some point.\nThe key point here, in case it's not clear, is that pulling from the parent (upstream) repository is not different from pulling from your public clone of child, your current repository. Either way, you're fetching from a repository with some common history, and merging that into your current branch. And of course, since you're merging, a work tree is required - so this is something that must be done in your local repo. The repo hosted on github is essentially a way of publishing what you've done locally. All you can really do with it is push/pull, and browse what's there."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options merge.<driver>.name"}, {"role": "assistant", "content": "Defines a human-readable name for a custom low-level\nmerge driver. See gitattributes for details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why is git AuthorDate different from CommitDate?\nI looked in my git logs and found that the AuthorDate and CommitDate is slightly different for some of my commits. From the git log --pretty=fuller output:\ncommit 3a5912f90dc5227f308e99f95152fbee2301c59a\nAuthor: <hidden>\nAuthorDate: Fri Jun 15 10:57:22 2012 +0800\nCommit: <hidden>\nCommitDate: Fri Jun 15 11:14:37 2012 +0800\n\nThe Author and Commit is the same (me).\nHow does this happen? I have been puzzled for days.\nThere are more - it happened in 17 out of 341 commits:\n+------------------------------+-------------------------------+\n| from_unixtime(authored_date) | from_unixtime(committed_date) |\n+------------------------------+-------------------------------+\n| 2012-06-15 10:57:22 | 2012-06-15 11:14:37 |\n| 2012-06-15 14:39:54 | 2012-06-15 14:48:57 |\n| 2012-06-19 12:28:21 | 2012-06-19 12:29:41 |\n| 2012-06-21 18:16:25 | 2012-06-21 18:28:48 |\n| 2012-06-26 17:30:54 | 2012-06-26 17:33:55 |\n| 2012-07-13 11:41:43 | 2012-07-13 11:42:17 |\n| 2012-07-13 11:56:02 | 2012-07-13 12:13:22 |\n| 2012-07-13 12:05:09 | 2012-07-13 12:12:24 |\n| 2012-07-12 18:38:49 | 2012-07-13 12:26:35 |\n| 2012-07-13 11:00:47 | 2012-07-13 12:25:15 |\n| 2012-07-16 14:10:54 | 2012-07-16 14:15:01 |\n| 2012-07-13 12:56:51 | 2012-07-16 13:49:48 |\n| 2012-07-16 14:10:54 | 2012-07-16 14:19:46 |\n| 2012-07-24 16:05:05 | 2012-07-24 16:05:48 |\n| 2012-07-24 17:42:58 | 2012-07-24 17:43:33 |\n| 2012-07-24 17:42:58 | 2012-07-24 17:45:18 |\n| 2012-07-26 16:55:40 | 2012-07-26 16:55:53 |\n+------------------------------+-------------------------------+"}, {"role": "assistant", "content": "The author date notes when this commit was originally made (i.e. when you finished the git commit). According to the docs of git commit, the author date could be overridden using the --date switch.\nThe commit date gets changed every time the commit is being modified, for example when rebasing the branch where the commit is in on another branch (more).\nSame could happen if you make your commit and send your patch to another one in order to apply the patch in another repo: the author date will be the date of your git commit, the commit date will be set to that date when the patch is applied in the other repo.\nIf you send the patch to two colleagues, there will be one author date but two different commit dates.\nThis is also mentioned in the Git Book:\n\nYou may be wondering what the difference is between author and committer. The author is the person who originally wrote the patch, whereas the committer is the person who last applied the patch. So, if you send in a patch to a project and one of the core members applies the patch, both of you get credit — you as the author and the core member as the committer"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options extensions.compatObjectFormat"}, {"role": "assistant", "content": "Specify a compatitbility hash algorithm to use. The acceptable values\nare sha1 and sha256 . The value specified must be different from the\nvalue of extensions.objectFormat. This allows client level\ninteroperability between git repositories whose objectFormat matches\nthis compatObjectFormat. In particular when fully implemented the\npushes and pulls from a repository in whose objectFormat matches\ncompatObjectFormat. As well as being able to use oids encoded in\ncompatObjectFormat in addition to oids encoded with objectFormat to\nlocally specify objects."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Automatically remove *.pyc files and otherwise-empty directories when I check out a new branch\nSo here's an interesting situation when using git and python, and I'm sure it happens for other situations as well.\nLet's say I make a git repo with a folder /foo/. In that folder I put /foo/program.py. I run program.py and program.pyc is created. I have *.pyc in the .gitignore file, so git doesn't track it. \nNow let's say I make another branch, dev. In this dev branch, I remove the /foo/ folder entirely.\nNow I switch back to the master branch, and /foo/ reappears. I run the program.py and the program.pyc file reappears. All is well.\nI switch back to my dev branch. The /foo/ directory should disappear. It only exists in the master branch, not the dev branch. However, it is still there. Why? Because the ignored program.pyc file prevents the folder from being deleted when switching branches.\nThe solution to this problem is to recursively delete all *.pyc files before switching branches. I can do that easily with this command.\nfind . -name \"*.pyc\" -exec rm '{}' ';'\n\nThe problem is that it is annoying to have to remember to do this almost every time I change branches. I could make an alias for this command, but then I still have to remember to type it every time I change branches. I could also make an alias for git-branch, but that's no good either. The git branch command does other things besides just change branches, and I don't want to delete all pyc files every time I use it. Heck, I might even use it in a non-python repo, then what?\nIs there a way to set a git hook that only executes when I change branches? Or is there some other way to set all *.pyc files to get erased whenever I switch branches?"}, {"role": "assistant", "content": "There is a post-checkout hook, to be placed in .git/hooks/post-checkout. There's probably a sample there, possibly named .sample or possibly not executable, depending on your git version. Short description: it gets three parameters, the previous HEAD, the new HEAD, and a flag which is 1 if the branch changed and 0 if it was merely a file checkout. See man githooks for more information! You should be able to write a shell script to do what you need and put it there.\nEdit: I realize you're looking to do this pre-checkout, so that the checkout automatically cleans up directories which become empty. There's no pre-checkout hook, though, so you'll have to use your script to remove the directories too.\nAnother note:\nAliases are part of gitconfig, which can be local to a repository (in .git/config, not ~/.gitconfig). If you choose to do this with aliases (for git-checkout, not git-branch) you can easily put them only in python-related repositories. Also in this case, I'd make an alias specifically for this purpose (e.g. cc for checkout clean). You can still use checkout (or another aliased form of it) if you don't want to clean up pyc files."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options merge.tool"}, {"role": "assistant", "content": "Controls which merge tool is used by git-mergetool .\nThe list below shows the valid built-in values.\nAny other value is treated as a custom merge tool and requires\nthat a corresponding mergetool.<tool>.cmd variable is defined."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is there a way to get download/clone statistics of a git repository?\n\nIs there any way to get how many times a git repository has been cloned or downloaded from github?\nI was just curious as I found other statistics such as commit times lines of code can be generated using: http://gitstats.sourceforge.net/ but I did not find how to check for clone/download count."}, {"role": "assistant", "content": "Its super easy now!\nGo \"REPO -> Insights -> Traffic\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Pod install is staying on \"Setting up CocoaPods Master repo\"\nI'm cloning a project from a git repo, but when I execute pod install the first line I see is \"Setting up CocoaPods Master repo\" and after that I can't see anything more, the console stops there.\nI don't know what is happening. Anyone knows what's happening here? Why Does CocoaPods stop there?"}, {"role": "assistant", "content": "You could try running in verbose mode:\npod install --verbose\n\nThat'll show you what cocoa pods are up to:\nSetting up CocoaPods master repo\n\nCloning spec repo `master` from `https://github.com/CocoaPods/Specs.git` (branch `master`)\n $ /usr/bin/git clone 'https://github.com/CocoaPods/Specs.git' master\n Cloning into 'master'...\n\n(as suggested here)\nFor me the above step took quite a long time as the repo (Dec 2016) is now 1.1 GB"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-notes - Add or inspect object notes -f --force"}, {"role": "assistant", "content": "When adding notes to an object that already has notes,\noverwrite the existing notes (instead of aborting)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to unstash only certain files?\nI stashed my changes. Now I want to unstash only some files from the stash. How can I do this?"}, {"role": "assistant", "content": "As mentioned below, and detailed in \"How would I extract a single file (or changes to a file) from a git stash?\", you can apply use git checkout or git show to restore a specific file.\ngit checkout stash@{0} -- <filename>\n\nWith Git 2.23+ (August 2019), use git restore, which replaces the confusing git checkout command:\ngit restore --source=stash@{0} -- <filename>\n\nThat does overwrite filename: make sure you didn't have local modifications, or you might want to merge the stashed file instead.\n(As commented by Jaime M., for certain shell like tcsh where you need to escape the special characters, the syntax would be: git checkout 'stash@{0}' -- <filename>)\n\nor to save it under another filename:\n\ngit show stash@{0}:<full filename> > <newfile>\n\n\n(note that here <full filename> is full pathname of a file relative to top directory of a project (think: relative to stash@{0})).\n\nyucer suggests in the comments:\n\nIf you want to select manually which changes you want to apply from that file:\n\ngit difftool stash@{0}..HEAD -- <filename>\n# or\ngit checkout -p stash@{0} -- <filename>\n\nVivek adds in the comments:\n\nLooks like \"git checkout stash@{0} -- <filename>\" restores the version of the file as of the time when the stash was performed -- it does NOT apply (just) the stashed changes for that file.\nTo do the latter:\n\ngit diff stash@{0}^1 stash@{0} -- <filename> | git apply\n\n(as commented by peterflynn, you might need | git apply -p1 in some cases, removing one (p1) leading slash from traditional diff paths)\n\nAs commented: \"unstash\" (git stash pop), then:\n\nadd what you want to keep to the index (git add)\nstash the rest: git stash --keep-index\n\nThe last point is what allows you to keep some file while stashing others.\nIt is illustrated in \"How to stash only one file out of multiple files that have changed\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Committing Machine Specific Configuration Files\nA common scenario when I develop is that the codebase will have several config files which require machine specific settings. These files will be checked into Git and other developers will always accidentally check them back in and break someone else's configuration.\nA simple solution to this would be to just not check them in to Git, or even to additionally add a .gitignore entry for them. However, I find that it is much more elegant to have some sensible defaults in the file which the developer can modify to suit his needs.\nIs there an elegant way to make Git play nicely with such files? I would like to be able to modify a machine-specific configuration file and then be able to run \"git commit -a\" without checking that file in."}, {"role": "assistant", "content": "Have your program read a pair of configuration files for its settings. First, it should read a config.defaults file that would be included in the repository. Then, it should read a config.local file that should be listed in .gitignore\nWith this arrangement, new settings appear in the defaults file and take effect as soon as it's updated. They will only vary on particular systems if they're overridden.\nAs a variation on this, you could have just a general config file that you ship in version control, and have it do something like include config.local to bring in the machine-specific values. This introduces a more general mechanism (versus policy) in you code, and consequently enables more complicated configurations (if that's desirable for your application). The popular extension from this, seen in many large-scale open-source software, is to include conf.d, which reads configuration from all the files in a directory.\nAlso see my answer to a similar question."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to wrap git commit comments?\nIs there a way to wrap git commit comments (when viewed via git log), so they are not cut off at the end of the line? It seems like there should be a pretty simple solution, but I haven't been able to find one.\nThanks."}, {"role": "assistant", "content": "Or you can change your pager to use less -R\n$ git config --global core.pager 'less -R'\n\nThis will tell less to stop trying to control how the screen is formatted (you can normally scroll right and left during a git log using arrow keys). And as the less manual says \"Thus, various display problems may result, such as long lines being split in the wrong place.\" Which is what you want, you want the line ending to appear at the right of your screen (the wrong place) instead of where the comment author put it.\nAlso to note, pressing the right arrow key without modifying your pager, will let you see more of the code. Which is my preferred method."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitlab - Push to a repository using access_token\nI implemented the oauth2 web flow in order to get access_token from users of my app. With the access_token, I would like to do the following actions: \n\nGet user informations \nCreate a repo for this user \nPush code to this repo (using git push )\n\nI already successfully get the user information(1) and create a repo(2)\nThe problem is I can't push code (3), I got \"Unauthorized\" error. \nThe command I run:\ngit remote add origin https://gitlab-ci-token<mytoken>@gitlab.com/myuser/myrepo.git \ngit push origin master"}, {"role": "assistant", "content": "You should do\ngit remote add origin https://<access-token-name>:<access-token>@gitlab.com/myuser/myrepo.git\n\nNote that this stores the access token as plain text in the .git\\config file. To avoid this you can use the git credential system, providing the access token name for \"username\" and the access token for \"password\". This should store the credentials in the git credential system in a more secure way."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --show-signature"}, {"role": "assistant", "content": "Check the validity of a signed commit object by passing the signature\nto gpg --verify and show the output."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options pushUnqualifiedRefname"}, {"role": "assistant", "content": "Shown when git-push gives up trying to\nguess based on the source and destination refs what\nremote ref namespace the source belongs in, but where\nwe can still suggest that the user push to either refs/heads/* or refs/tags/* based on the type of the\nsource object."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Query git reflog for all commits to a specific file\nIs it possible to check the git reflog for all commits to a specific file.\nI made a commit to file foo.txt and now it no longer shows in the git history via\ngit log foo.txt\n\nI want to search the reflog to find all commits to this file so I can find my \"lost\" commit."}, {"role": "assistant", "content": "Came across this while searching for an answer, which is simple: git reflog -- $PATH, which will include amends and other actions that will not be visible otherwise (though beware, reflog will be pruned by gc)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do you squash commits into one patch with git format-patch?\nI've got eight commits on a branch that I'd like to email to some people who aren't git enlightened, yet. So far, everything I do either gives me 8 patch files, or starts giving me patch files for every commit in the branch's history, since the beginning of time. I used git rebase --interactive to squash the commits, but now everything I try gives me zillions of patches from the beginning of time. What am I doing wrong?\ngit format-patch master HEAD # yields zillions of patches, even though there's \n # only one commit since master"}, {"role": "assistant", "content": "I'd recommend doing this on a throwaway branch as follows. If your commits are in the \"newlines\" branch and you have switched back to your \"master\" branch already, this should do the trick:\n[adam@mbp2600 example (master)]$ git checkout -b tmpsquash\nSwitched to a new branch \"tmpsquash\"\n\n[adam@mbp2600 example (tmpsquash)]$ git merge --squash newlines\nUpdating 4d2de39..b6768b2\nFast forward\nSquash commit -- not updating HEAD\n test.txt | 2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\n[adam@mbp2600 example (tmpsquash)]$ git commit -a -m \"My squashed commits\"\n[tmpsquash]: created 75b0a89: \"My squashed commits\"\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\n[adam@mbp2600 example (tmpsquash)]$ git format-patch master\n0001-My-squashed-commits.patch"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Pulling changes from fork parent in Git\n\nHow do you pull changes from the parent of a fork in Git, specifically in a github configured project?\nFor example, say I forked http://github.com/originaluser/originalproject into http://github.com/myuser/myproject. I don't plan on myproject on being a permanent fork, as I only want to maintain a \"dev\" branch to test some experimental features, and then eventually merge it back into the original project.\nAs such, whenever commits are made to originalproject, I want to be able to pull them down and merge them with myproject. However, I also want to be able to push changes up into myproject, but not yet immediately create a pull request to get them merged into originalproject until my branch is complete and tested. What's the best way to do this?\nEdit: By default, when I create a local checkout/fork of my github fork for local development, and then push/pull changes up, these changes only effect my personal fork. I never get changes from the original project. How do I fix that?\nSorry for any incorrect git terminology."}, {"role": "assistant", "content": "Expanding on other answers, these are the steps I took on a fork I had of tsc-watch:\ngit remote add upstream https://github.com/gilamran/tsc-watch.git\ngit fetch upstream\ngit merge upstream/master\ngit push\n\nExplained:\n\nadding the remote server as upstream (alias)\nfetch all changes from the upstream remote\nmerge changes from upstream/master branch into my current branch\npush all changes to GitHub"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitglossary - A Git Glossary stash entry"}, {"role": "assistant", "content": "An object used to temporarily store the contents of a dirty working directory and the index for future reuse."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git: How do I get rid of \"warning: CRLF will be replaced by LF\" without disabling safecrlf?\nI'm new to git, and I've read a lot about line endings and\nhow git treats them. I'm on Windows by the way. I have made\na .gitattributes file and set for example *.txt to text.\nWhen I commit a .txt file, I get the warning:\n\nwarning: CRLF will be replaced by LF in whatever.txt\n\nBut I know that. I don't need that warning. Replacing line\nendings in text files is what I want. \nNow, setting safecrlf to false makes the warning\ndisappear, but the manual for safecrlf reads:\n\nIf true, makes git check if converting CRLF is reversible\n when end-of-line conversion is active. Git will verify if\n a command modifies a file in the work tree either directly\n or indirectly. For example, committing a file followed by\n checking out the same file should yield the original file\n in the work tree. If this is not the case for the current\n setting of core.autocrlf, git will reject the file.\n\nFrom that, safecrlf seems like a good idea to have.\nHowever, I don't understand why setting safecrlf to true\ngives me warnings about my text files; it seems to me that\nthose are different issues -- the warning on text files and\nthe checking if reversible. Indeed, git does not reject my\nfile.\nCan I get rid of the warnings for text files, and still have\nsafecrlf set? Or am I misunderstanding something?"}, {"role": "assistant", "content": "As far as I can tell, setting core.safecrlf to false is the only way to turn off that warning.\nsafecrlf is generally not necessary if your attributes are set correctly. The point of safecrlf is to prevent normalization in a file that is supposed to have mixed (or non-LF) line endings in the repository. It's really only useful in combination with core.autocrlf (to make sure that its automatic guesses can't destroy anything), and if you're setting your own attributes via .gitattributes it should be okay to turn all that off."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "In git, how do I create a single patch for the last 2+ revisions?\nI would like to create a patch for the last 2 revisions.\ngit format-patch -2\n\ngives me 2 patch files, one for each revision\ngit format-patch HEAD~2..HEAD\n\ngives the same thing.\ngit format-patch -1 HEAD~2..HEAD\n\ngives a single file, but only contains changes for the last revision.\nIs there any way to do this in git?"}, {"role": "assistant", "content": "git diff HEAD~2..HEAD > my-patch.diff\n\nIt won't have any of format-patch's per-commit metadata, though."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Ignoring directories in Git repositories on Windows\nHow can I ignore directories or folders in Git using msysgit on Windows?"}, {"role": "assistant", "content": "Create a file named .gitignore in your project's directory. Ignore directories by entering the directory name into the file (with a slash appended):\ndir_to_ignore/\n\nMore information is here."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_INDEX_FILE"}, {"role": "assistant", "content": "This environment variable specifies an alternate\nindex file. If not specified, the default of $GIT_DIR/index is used."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "getting \"fatal: not a git repository: '.'\" when using post-update hook to execute 'git pull' on another repo\nI'm new to git so I apologize (and please correct me) if I misuse terminology here, but I'll do my best.\nI'm trying to set up a bare git repo (hub) and a development site working copy (prime) on a web server. I've tried to pattern it after this article. I want the development working copy to be updated whenever the hub repo is pushed to. I'm under the impression that the proper hook for this is post-update, which I have created like so:\n#!/bin/sh\nwhoami\ncd /path/to/working-copy/\nRET=`git pull`\necho $RET\n\nUpdate\nWhen I push changes from my local repo to the bare hub I get the following output from the post-update script:\nremote: sites\nremote: fatal: Not a git repository: '.'\n\nHowever if I SSH into the server as user 'sites' and execute this script manually it works great Any ideas as to what might be going wrong with this hook or script?"}, {"role": "assistant", "content": "Here is the script that ultimately worked. I think the bit I was originally missing that prevented it from working remotely was the unset GIT_DIR\n#!/bin/sh\ncd /path/to/working-copy/ || exit\nunset GIT_DIR\ngit pull repo branch\n\nexec git-update-server-info"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I generate a git diff of what's changed since the last time I pulled?\nI'd like to script, preferably in rake, the following actions into a single command:\n\nGet the version of my local git repository.\nGit pull the latest code.\nGit diff from the version I extracted in step #1 to what is now in my local repository.\n\nIn other words, I want to get the latest code form the central repository and immediately generate a diff of what's changed since the last time I pulled."}, {"role": "assistant", "content": "You could do this fairly simply with refspecs.\ngit pull origin\ngit diff @{1}..\n\nThat will give you a diff of the current branch as it existed before and after the pull. Note that if the pull doesn't actually update the current branch, the diff will give you the wrong results. Another option is to explicitly record the current version:\ncurrent=`git rev-parse HEAD`\ngit pull origin\ngit diff $current..\n\nI personally use an alias that simply shows me a log, in reverse order (i.e. oldest to newest), sans merges, of all the commits since my last pull. I run this every time my pull updates the branch:\ngit config --global alias.lcrev 'log --reverse --no-merges --stat @{1}.."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitattributes - Defining attributes per path Set to string value \"crlf\""}, {"role": "assistant", "content": "This setting converts the file’s line endings in the working\ndirectory to CRLF when the file is checked out."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-parse - Pick out and massage parameters <rev1>...<rev2>"}, {"role": "assistant", "content": "Include commits that are reachable from either <rev1> or\n<rev2> but exclude those that are reachable from both. When\neither <rev1> or <rev2> is omitted, it defaults to HEAD ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Which is the best git hosting sw? - Gitolite vs. Gitlab vs. Gitorius [closed]\nClosed. This question is opinion-based. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it can be answered with facts and citations by editing this post.\n\n\nClosed 10 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI am looking for a git hosting environment for several users. Therefore i've searched for comparisons between Gitolite, Gitlab and Gitorius. But i get nothing what could be useful.\nIs there anybody, who has experiences with different hosting tools and could provide an advice?"}, {"role": "assistant", "content": "Gitolite is not a git hosting environment: it is an authorization layer, which grants or denies access to a git repo.\nIt is the https or ssh layer which allows the authentication of a user, and the git repo hosting itself.\nSee \"How do programs like gitolite work?\"\nGitLab and Gitorious both provide git hosting, with (to my opinion) an easier installation process and more features for GitLab.\n\nWhen comparing GitLab features and Gitorious features, the issue tracker is more complete, the fork and authorization levels are present, GitLab has teams and groups, webhooks, and API.\nThe development is more active (one release every month) on GitLab. \nUpdate: GitLab has acquired Gitorious"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs"}, {"role": "assistant", "content": "SYNOPSIS git log [<options>] [<revision-range>] [[--] <path>…​]"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options diff.mnemonicPrefix"}, {"role": "assistant", "content": "If set, git diff uses a prefix pair that is different from the\nstandard \"a/\" and \"b/\" depending on what is being compared. When\nthis configuration is in effect, reverse diff output also swaps\nthe order of the prefixes: git diff compares the (i)ndex and the (w)ork tree; git diff HEAD compares a (c)ommit and the (w)ork tree; git diff --cached compares a (c)ommit and the (i)ndex; git diff HEAD:file1 file2 compares an (o)bject and a (w)ork tree entity; git diff --no-index a b compares two non-git things (1) and (2)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-update-server-info - Update auxiliary info file to help dumb servers"}, {"role": "assistant", "content": "DESCRIPTION A dumb server that does not do on-the-fly pack generations must\nhave some auxiliary information files in $GIT_DIR/info and\n$GIT_OBJECT_DIRECTORY/info directories to help clients discover\nwhat references and packs the server has. This command\ngenerates such auxiliary files."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -S<string>"}, {"role": "assistant", "content": "Look for differences that change the number of occurrences of\nthe specified string (i.e. addition/deletion) in a file.\nIntended for the scripter’s use. It is useful when you’re looking for an exact block of code (like a\nstruct), and want to know the history of that block since it first\ncame into being: use the feature iteratively to feed the interesting\nblock in the preimage back into -S , and keep going until you get the\nvery first version of the block. Binary files are searched as well."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-clone - Clone a repository into a new directory -- [ no- ] reject-shallow"}, {"role": "assistant", "content": "Fail if the source repository is a shallow repository.\nThe clone.rejectShallow configuration variable can be used to\nspecify the default."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-citool"}, {"role": "assistant", "content": "Graphical alternative to git-commit"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Microservices: How to store source code of many microservices?\nCurrently, I have 20 microservices for one project. And every microservice stored in separate GIT reposotiry. \nSubsequently, the number of services will increase to 200 (or more).\nEvery service has unit tests and integration tests. Every service has build in TeamCity (Continuous integration server). \nQuestion: How to store source code of 200 microservices for one project? In one repository or in separate repositories?"}, {"role": "assistant", "content": "Unless those micro-services are tightly coupled (meaning it wouldn't make sense to download only some of them, and you would only work with all of them), keeping them each in a separate Git repo is recommended.\nBut you can still reference them as submodule in a parent repo in order to keep track of their state at any given time."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why do some repository URLs end in .git while others don't?\n\nWhen I clone a repository, is there any difference between these two URLs?\n\nWithout .git extension:\ngit clone http://foo/repo\n\nWith .git extension:\ngit clone http://foo/repo.git"}, {"role": "assistant", "content": "The convention is that the .git extension should be used for bare repositories, and left off of directories with a working tree. Git doesn't really care, but has a few convenience methods that make this fairly transparent.\nFor example, if you have a repository named /tmp/foo.git and you call git clone file:///tmp/foo, Git will first try to find /tmp/foo. If it doesn't exist, it will try /tmp/foo.git instead.\nThis does not work the other way around. If your directory is named /tmp/foo and you try to clone from /tmp/foo.git you will be told:\n\nfatal: '/tmp/foo.git' does not appear to be a git repository\n\nMost of the HTTP/HTTPS functionality is from your web server, not Git. Even if you're using Smart HTTP transport, I suspect most of the magic happens in a server-side LocationMatch directive. Theory aside, some quick tests against GitHub show that it works the same way as the SSH and Git procotols in that respect, but your mileage may vary on other web servers."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Convert a Git folder to a submodule retrospectively?\nQuite often it is the case that you're writing a project of some kind, and after a while it becomes clear that some component of the project is actually useful as a standalone component (a library, perhaps). If you've had that idea from early on, then there's a fair chance that most of that code is in its own folder.\nIs there a way to convert one of the sub directories in a Git project to a submodule?\nIdeally this would happen such that all of the code in that directory is removed from the parent project, and the submodule project is added in its place, with all the appropriate history, and such that all the parent project commits point to the correct submodule commits."}, {"role": "assistant", "content": "To isolate a subdirectory into its own repository, use filter-branch on a clone of the original repository:\ngit clone <your_project> <your_submodule>\ncd <your_submodule>\ngit filter-branch --subdirectory-filter 'path/to/your/submodule' --prune-empty -- --all\n\nIt's then nothing more than deleting your original directory and adding the submodule to your parent project."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is it possible to exclude specific commits when doing a git merge?\nLet's say that I want to merge from a release branch to the master branch and there are some commits in the release branch that I don't want to include in the master branch. Is there a way to do the merge so that one or more of those commits will not be merged?\nMy strategy so far is to do the following (in master):\ngit merge --no-commit release-branch\n# Resolve conflicts and apply reverse patch of the commits that I don't want included\ngit commit # Edit commit message so that it lists the commits that have been reverse-patched\n\nIs there a better way to do this?"}, {"role": "assistant", "content": "I've found a solution that works for me in the Pro Git book.\nLet's say you want to exclude the file config.php.\nOn branch A:\n\nCreate a file named .gitattributes in the same dir, with this line: config.php merge=ours. This tells git what strategy to use when merging the file. In this case it always keep your version, ie. the version on the branch you are merging into.\nAdd the .gitattributes file and commit\n\nOn branch B: repeat steps 1-2\nTry merging now. Your file should be left untouched."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What does colon in job name means when using Gitlab CI pipeline?\n\nUsing the following CI pipeline running on GitLab:\nstages:\n - build\n - website\n\ndefault:\n retry: 1\n timeout: 15 minutes\n\nbuild:website:\n stage: build\n ...\n ...\n ...\n ...\n\nwebsite:dev:\n stage: website\n ...\n ...\n ...\n\nWhat does the first colon in job name in build:website: and in website:dev: exactly mean?\nIs it like we pass the second part after the stage name as a variable to the stage?"}, {"role": "assistant", "content": "Naming of jobs does not really change the behavior of the pipeline in this case. It's just the job name.\nHowever, if you use the same prefix before the : for multiple jobs, it will cause jobs to be grouped in the UI. It still doesn't affect the material function of the pipeline, but it will change how they show up in the UI:\n\nIt's a purely cosmetic feature.\nJobs can also be grouped using / as the separator or a space."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why has Git allowed me to create two branches with the same name?\nI'm still relatively new to Git and I have made a bit of a mess of my repository. I'm hoping there is a way to fix it without re-cloning. \nI have a repository which I have cloned from Github. The repository has several branches. I worked on the master branch for a while but then needed to switch to one of the other branches.\nSo, I had:\n$ git branch --all\n* master\n remotes/origin/abc\n remotes/origin/def\n remotes/origin/HEAD -> origin/master\n remotes/origin/ghi\n\nProblem: I wanted to switch to the 'abc' branch but instead of doing git checkout remotes/origin/abc I accidentally did git branch remotes/origin/abc which leaves me with the following:\n$ git branch --all\n* master\n remotes/origin/abc\n remotes/origin/abc\n remotes/origin/def\n remotes/origin/HEAD -> origin/master\n remotes/origin/ghi\n\nMy questions are:\n\nWhy on Earth does Git allow you to create two branches with the same\nname? \nHow do I identify which is the real remotes/origin/abc branch?\nHow do I remove the unwanted remotes/origin/abc that I created by\naccident?\n\nAny help much appreciated."}, {"role": "assistant", "content": "You can't create two local branches or two distant branches with the same name.\n\nHere you have a local branch named remotes/origin/abc and a distant branch named abc on the remote origin. They have not the same name, but it seems to when you use the git branch --all command.\nTo identify which branch is which, you can show local branches with git branch, or show remote branches with git branch --remote. You could also easily differentiate them even while using git branch --all with the branch syntax coloration (git config --global color.branch auto).\nTo remove the accidentally created local branch abc, you have to do git branch -d abc (or git branch -D abc to force deletion, see man git-branch)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-range-diff - Compare two commit ranges (e.g. two versions of a branch)"}, {"role": "assistant", "content": "SYNOPSIS git range-diff [--color=[<when>]] [--no-color] [<diff-options>]\n\t[--no-dual-color] [--creation-factor=<factor>]\n\t[--left-only | --right-only]\n\t( <range1> <range2> | <rev1>…​<rev2> | <base> <rev1> <rev2> )\n\t[[--] <path>…​]"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why is git prompting me for a post-pull merge commit message?\nRecently, following any git pull, git has started spawning my text editor, and asking for a merge commit message. A commit message is already pre-filled, and I just have to save and close the window to complete the pull.\nIn the past, it would do the merge silently, with a standard commit message (along the lines of Merge branch 'dev' of remote.com:/repo into dev).\nI recently updated git to version 1.7.11.3 (via homebrew), but can't think of anything else I might have done to change this behavior. Is this a setting, or is there otherwise some way of getting back to the way it was?"}, {"role": "assistant", "content": "In git 1.7.10, the git developers decided merge commits could be made too easily. As explained in this blog post, forcing the interactive commit message behavior should make those commit messages more detailed and could reduce the overall frequency of unnecessary merges.\nYou can use the --no-edit flag to avoid this behavior, but, well, don't. Merge commits, like any commits to history, should be well constructed. Your history should be nothing but useful."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I completely empty the master branch in Git?\nI would like to completely empty the master branch in Git. For now, I would also like to keep all other branches which have been branched from master.\nIs this possible and how?"}, {"role": "assistant", "content": "That's actually called \"delete old master branch and create new from scratch\"\nThis will create a new master branch pointing to initial commit:\ngit branch -D master\ngit checkout -b master <initial commit hash>\n\nThis will create a totally new master branch unrelated to whatever you had:\ngit branch -D master\ngit checkout --orphan master\ngit rm -rf *\n\nBut actually you can simply save current repository to some other place and create a new repository instead."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --patch-with-stat"}, {"role": "assistant", "content": "Synonym for -p --stat ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git and Trac (or similar)\nIn the past I have really enjoyed using Trac with subversion repositories hosted on some of my own servers. The integrated ticketing and online code browsing is very convenient.\nI have used github for some of my public projects but I don't have the money to shell out for an extra service, espcially when I am already paying for remote VPS hosting.\nDoes anyone know of or have any experience setting up something like Trac with git version control? Specifically, I can already push to a remote server but I would like some web interface that allows me (and people working with me) to see that commits and current state of the codebase online without making the project public. I am aware of GitPlugin but have not been able to get it up and running successfully. Any other suggestions?\nIntegrated ticketing (and wiki) is desired but not an absolute necessity.\nEdit:\nAfter playing around with GitPlugin and Trac a bit more I have been able to get it up and running. The main problem was that I needed to explicitly enable the plugin for the trac environment by doing something like this in trac.ini:\n[components]\n# for version 0.10\ngitplugin.* = enabled\n# for version 0.11\ntracext.git.* = enabled \n\nI may also try out Redmine and CGit as this seem like other pieces of software that do what I am looking for. Any other suggestions are welcome."}, {"role": "assistant", "content": "You should take a look at Redmine (http://www.redmine.org/). It has all of the features you mention and more. You can host it on your own vps (I do)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to pull remote branch from somebody else's repo\n\nI've got a project hosted on GitHub which somebody has forked. On their fork, they've created a new branch \"foo\" and made some changes. How do I pull their \"foo\" into a new branch also named \"foo\" in my repo?\nI understand they could submit a pull request to me, but I'd like to initiate this process myself.\nAssume the following:\n\nBecause they forked my project, both our repos share the same 'history'\nAlthough GitHub shows their project was forked from mine, my local repository doesn't have any references to this person's project. Do I need to add theirs as a remote?\nI don't have a branch called \"foo\" yet - I don't know if I need to manually create this first.\nI definitely want this pulled into a separate branch and not my master."}, {"role": "assistant", "content": "git remote add coworker git://path/to/coworkers/repo.git\ngit fetch coworker\ngit checkout --track coworker/foo\n\nThis will setup a local branch foo, tracking the remote branch coworker/foo. So when your co-worker has made some changes, you can easily pull them:\ngit checkout foo\ngit pull\n\n\nResponse to comments:\n\nCool :) And if I'd like to make my own\n changes to that branch, should I\n create a second local branch \"bar\"\n from \"foo\" and work there instead of\n directly on my \"foo\"?\n\nYou don't need to create a new branch, even though I recommend it. You might as well commit directly to foo and have your co-worker pull your branch. But that branch already exists and your branch foo need to be setup as an upstream branch to it:\ngit branch --set-upstream foo colin/foo\n\nassuming colin is your repository (a remote to your co-workers repository) defined in similar way:\ngit remote add colin git://path/to/colins/repo.git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why is Gitlab CI re-uploading cache when key is still valid\n\nin gitlab CI file for an angular project; I define the global cache with the checksum of the package-lock.json file as key. so that the cache is only invalidated when the package-lock.json file changes.\ncache:\n key:\n files:\n - package-lock.json\n paths:\n - node_modules/\n - .npm\n\nPROBLEM: cache is still uploaded even when the cache-key is still valid. (see the picture the cache name did not change)\n\nI want the cache to be uploaded only when it is invalidated, is there anyway to achieve this? or any other remarks recommendations?"}, {"role": "assistant", "content": "By default, the cache is always uploaded on success (push-pull policy).\nYou can change this behavior by configuring the cache policy. If you want a job to only download the cache, but never upload it, set the cache policy to pull. However, you need to make sure at least one previous job populates the cache with either a push or push-pull policy.\nFor example:\nstages:\n - one\n - two\n\ncreate_cache:\n stage: one\n cache:\n key:\n files:\n - package-lock.json\n paths:\n - node_modules/\n - .npm\n policy: \"push-pull\" # default cache behavior\n script:\n - echo \"this job is responsible for creating/updating the cache as needed\"\n\nother_jobs:\n stage: two\n cache:\n key:\n files:\n - package-lock.json\n paths:\n - node_modules/\n - .npm\n policy: \"pull\" # only download cache, do not upload\n script:\n - echo \"this will rely on cache being created in previous stage\" \n\nUnfortunately, there is no configuration to say \"push cache if old-cache is invalidated\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to solve \"Unable to find git in your PATH\" on Flutter?\nI've just tried to install Flutter on Linux and when I try to run a flutter command (flutter doctor), I'm getting\nError: Unable to find git in your PATH.\n\nHow can I solve this?"}, {"role": "assistant", "content": "Here is my solution for Windows 11 64bit, flutter 3.7.3, installed via chocolatey. It has simply to do with enforced git security settings which can detect dubious ownship for the flutter repository. Just add the flutter base directory to the git directory exception list:\ngit config --global --add safe.directory C:/tools/flutter-base-dir\n\nor change the ownership of the flutter base directory with fix unsafe git repository"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do you push a Git tag to a branch using a refspec?\nI want to force push, for example, my tag 1.0.0 to my remote master branch.\nI'm now doing the following:\ngit push production +1.0.0:master\n\nI want to force the push, because all I care about is that the code inside the 1.0.0 tag is pushed to the master branch on the remote repository.\nWhat am I doing wrong?\nUpdate #1\nWhen I SSH into my server where my Git repository is and execute git branch -l, I don't see the master branch listed either.\nUpdate #2\nAfter running git tag -l from inside the remote Git repository, I see that master is listed, meaning that when I ran the following:\ngit push production 1.0.0:master\n\nIt actually pushed the tag and created a tag named master rather than a new branch.\nI want to basically push the contents of the tag 1.0.0 into the master branch of the remote Git repository."}, {"role": "assistant", "content": "git push --tags production"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-send-email - Send a collection of patches as emails --smtp-server=<host>"}, {"role": "assistant", "content": "If set, specifies the outgoing SMTP server to use (e.g. smtp.example.com or a raw IP address). If unspecified, and if --sendmail-cmd is also unspecified, the default is to search\nfor sendmail in /usr/sbin , /usr/lib and $PATH if such a\nprogram is available, falling back to localhost otherwise. For backward compatibility, this option can also specify a full pathname\nof a sendmail-like program instead; the program must support the -i option. This method does not support passing arguments or using plain\ncommand names. For those use cases, consider using --sendmail-cmd instead."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-commit"}, {"role": "assistant", "content": "Record changes to the repository"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-diagnose"}, {"role": "assistant", "content": "Generate a zip archive of diagnostic information"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-commit - Record changes to the repository --short"}, {"role": "assistant", "content": "When doing a dry-run, give the output in the short-format. See git-status for details. Implies --dry-run ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to split a git branch into two branches?\nI'm trying to help out a coworker who accidentally created one feature branch from another feature branch, rather than creating the second one from master. Here is essentially what we have now…\nMaster ---A---B---C\n \\\n Foo E---F---F---H\n \\\n Bar J---K---L---M\n\nAnd here is what we'd like to have…\nMaster ---A---B---C\n |\\\n Foo | E---F---F---H\n |\n Bar J---K---L---M\n\nOne way I thought of would be to create FooV2 and BarV2 branches, and cherry-pick the individual commits into the appropriate V2 branches. But I'm curious, is there a better way to handle this situation?"}, {"role": "assistant", "content": "For a more general answer that will help us understand things a bit better than just \"run this command\", we need a larger example. So, let's pretend you're actually in this situation:\n---A---B---C <= Master\n \\\n E---F---F---H <= Foo\n \\\n J---K---L---M <= Bar\n \\\n N---O---P---Q <= Baz\n\nAnd here is what we'd like to have…\n---A---B---C <= Master\n |\\\n | E---F---F---H <= Foo\n |\\\n | J---K---L---M <= Bar\n \\\n N---O---P---Q <= Baz\n\nThankfully, Git has a solution for us in the options to the rebase command!\ngit rebase --onto [newParent] [oldParent] [branchToMove]\n\nWhat this means can be broken down into parts:\n\nrebase - Change the parents of something\n--onto - This is the flag that tells git to use this alternate rebase syntax\nnewParent - This is the branch that the branch you are rebasing will have as it's parent\noldParent - This is the branch that the branch you are rebasing currently has as it's parent\nbranchToMove - This is the branch that you are moving (rebasing)\n\nThe bit about \"old parent branch\" can be a little confusing, but what it's really doing is it's saying \"ignore the changes from my old parent when doing the rebase\". The oldParent is how you define where the branch you are moving (ie. branchToMove) starts.\nSo, what are the commands to execute in our situation?\ngit rebase --onto Master Bar Baz\ngit rebase --onto Master Foo Bar\n\nNote that the order of these commands matter because we need to pull each branch off of the end of the \"branch chain\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-shortlog - Summarize git log output -s --summary"}, {"role": "assistant", "content": "Suppress commit description and provide a commit count summary only."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --cumulative"}, {"role": "assistant", "content": "Synonym for --dirstat=cumulative"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitLens extension disappeared\nI'm work on Linux Mint:\nScreenshot of mint version\nI have latest version of Visual Studio code:\nScreenshot of vs code version\nAfter new reload of OS extension GitLens disappeared: Screenshot of problem\nI can't see any information in my source code, that provide this extension. Reinstallation this extension or vs code didn't apply any effect. How can i fix it?"}, {"role": "assistant", "content": "For me the problem was for VS Code 1.51.1 and GitLens 11 they have made the Source Control Layout as default and requires the selection of view in order to make it work as before i.e., in the VS Code sidebar (using Mac OS Catalina 10.15.2).\nAfter update:\n\nPress cmd+shift+p (ctrl+shift+p on Windows) and type > Gitlens: Show Welcome View and hit enter. This will bring back the GitLens on sidebar. Then click on GitLens icon in sidebar and you will be shown a welcome page similar to screenshot below:\n\n\n\nClick on Welcome (Quick Setup), this will open the below screen:\n\n\n\nScroll to the bottom and then select the view named GITLENS LAYOUT among the two options given:\n\n\n\nNow click on Close button in GitLens menu that is opened next to VS Code sidebar:\n\n\nAnd your GitLens is back!"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Editing the git commit message in GitHub\n\nIs there any way of online editing the commit message in GitHub.com, after submission?\nFrom the command line, one can do\ngit commit --amend -m \"New commit message\"\n\nas correctly suggested in the following question:\n\nHow to modify existing, unpushed commit messages?\n\nTrying git pull and then git push has worked (without any other commit having interfered in the mean time).\nBut can it be done via the GitHub website?"}, {"role": "assistant", "content": "GitHub's instructions for doing this:\n\nOn the command line, navigate to the repository that contains the commit you want to amend.\nType git commit --amend and press Enter.\nIn your text editor, edit the commit message and save the commit.\nUse the git push --force origin example-branch command to force push over the old commit.\n\nSource: https://help.github.com/articles/changing-a-commit-message/"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to add a GitHub personal access token to Visual Studio Code\nI received an email saying GitHub will require token authentication after August 13 2021. I want to ensure I don't have an interruption of service (push/pull) after this date.\nSo I logged into GitHub and created a token for my single repository.\nNow I want to use the token to push/pull my repository from GitHub, in Visual Studio Code, which uses Git and the command line, which I have installed on my Mac.\nWhat do I do to add/replace the password from GitHub with the generated token I just created to push/pull from my repository? Can I do it from Visual Studio Code or does it get added from the terminal command line?"}, {"role": "assistant", "content": "Follow these simple steps to set up GitHub authentication with a personal access token:\n\nOpen a command line window on your PC or Terminal on Mac\n\nSet the current directory to your project root\ncd C:\\Users\\Giddy\\source\\repo\\MySampleProject\n\n\nRun the command to set remote access via a token\ngit remote set-url origin https://username:[email protected]/username/repository.git\n\nExample:\ngit remote set-url origin https://sampleuser:a7b19929***[email protected]/sampleuser/sampleproject.git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git : fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists\n\nI am getting this error - \nD:\\Projects\\wamp\\www\\REPO [master]> git pull origin master\nWarning: Permanently added 'github.com,192.30.252.128' (RSA) to the list of known hosts.\nERROR: Repository not found.\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\nThe output of git remote -v\nD:\\Projects\\wamp\\www\\REPO [master]> git remote -v\norigin [email protected]:username/repo.git (fetch)\norigin [email protected]:username/repo.git (push)\n\nFinal message of ssh -Tv [email protected] command - \nHi [My Username]! You've successfully authenticated, but GitHub does not provide shell access.\n\nHow can I solve it?"}, {"role": "assistant", "content": "change your ssh url by an http url for your remote 'origin', use:\n> git remote set-url origin https://github.com/<user_name>/<repo_name>.git\n\nIt will ask for your GitHub password on the git push."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I merge a specific commit from one branch into another in Git?\n\nI have BranchA which is 113 commits ahead of BranchB.\nBut I only want the last 10 or so commits from BranchA merged into BranchB.\nIs there a way to do this?"}, {"role": "assistant", "content": "The git cherry-pick <commit> command allows you to take a single commit (from whatever branch) and, essentially, rebase it in your working branch.\nChapter 5 of the Pro Git book explains it better than I can, complete with diagrams and such. (The chapter on Rebasing is also good reading.)\nLastly, there are some good comments on the cherry-picking vs merging vs rebasing in another SO question."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "fatal: A branch named 'gh-pages' already exists\nI made a template sale website (gatsby / react). I cloned my template GitHub repo and changed the remote origin to a new private repo, pushing to which works fine.\nI deploy to gh-pages with npm srcipt \"deploy\": \"gatsby build --prefix-paths && gh-pages -d public\"\nThe first time I ran this command it seemed to stall so I control c'd out of it. Now, when I try to deploy I get the error \"fatal: A branch named 'gh-pages' already exists.\"\ngit branch -a shows:\nremotes/origin/HEAD -> origin/master\nremotes/origin/gh-pages\nremotes/origin/master \nBut there is not a gh-pages branch on gitHub.\nI tried rm -rf node_modules/gh-pages/.cache didn't work.\nAlso, git push origin --delete gh-pages which gave\n\"error: unable to delete 'gh-pages': remote ref does not exist\".\nI uninstalled and reinstalled gh-pages."}, {"role": "assistant", "content": "I had to manually remove the folder node_modules/.cache/gh-pages to get the deployment to work.\nPrior to this I had tried git fetch --prune, which removed remotes/origin/gh-page. I don't know if pruning the branches was a necessary step or not."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Delete forked repo from GitHub\n\nI'm starting with git and GitHub and there's a project I'm watching on GitHub. I unintentionally clicked to fork it. Now it appears as a new project to me.\nI have some doubts about it:\n\nI know if commit or do another thing to my forked repo, it will be updated, but the updated code will take effect only after the project's author request the pull. Right?\nIf I go to admin panel on GitHub there's a delete option. If I delete it as the option above, will it make any effect in the original one or not?\n\nI'd like to delete it. By now I'm just studying the code and don't really need the fork."}, {"role": "assistant", "content": "By far the easiest way is to log in GitHub account:\n\nClick to your repository for example yourUsername/yourRepository for example mbaric/zpropertyz.\nThen in the main toolbar of GitHub click on Settings\nScroll to the bottom of the page to the section called Danger Zone and you will find Delete this repository button\nWhen you click it another pop up will appear here you need to type in your Github username and the name of your repository in this format gitHubUsername/nameOfTheRepository and click on the button below which says: I understand the consequences, delete the repository\nIf you are having trouble doing it, below are the images that can be checked…\n\n2020-01-15 - Here are images. Enjoy."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What happens if you force push to a branch with an existing pull request?\nI am working on a git branch that is currently part of a closed pull request on github. Subsequently to the initial pull request, I made some additional commits, pushed those commits to github, and then reverted those commits and recommitted them because I need to revise the commits. \nNow if I want to push those commits to github, I'll need to issue a force push: git push --force. But I have the strong feeling that this might cause mayhem with the existing pull request, even though the changed commits occurred after the commits that existed prior to me making the pull request.\nCan anyone describe to me how best to handle this situation? I think I may need to just create an entirely new branch and then issue a pull request on that branch instead. But if there's a way to link this to the existing pull request that would be preferable."}, {"role": "assistant", "content": "If my memory serves me correctly, then if you force push or update the branch in question in any way, GitHub will automatically update the pull request. If doing the force push would result in the pull request not being possible, then GitHub will tell you this.\nYou do not need to worry about updating the pull request as GitHub will take care of this for you.\nThis being said, doing a git push --force on any remote branch can cause mayhem for your coworkers who are also currently working on this branch. So you are correct to be shying away from doing a force push, but fortunately a GitHub pull request is not your biggest problem."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitglossary - A Git Glossary pull"}, {"role": "assistant", "content": "Pulling a branch means to fetch it and merge it. See also git-pull ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I merge a specific file from one branch into another branch in Git\nI have 2 branches in a git repo, lets call them, dev and test. I have changes in a single file, somecode.js. Both branches have changes to somecode.js. The 2 branches have diverged significantly (but manageably) so a straight \"merge\" is insufficient.\nI have tried http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/ but it doesn't merge the contents of both files. You basically just write over the file instead of actually merging the contents of the file.\nI have also tried:\ngit checkout -b newbranch\ngit checkout test somecode.js\ngit commit -m \"somecode changes from newbranch\"\ngit checkout dev\ngit merge newbranch\n\nAnd\ngit checkout -m test somecode.js\n\n(I was really hopeful with the -m for merge, but it didn't appear to work for me...)\nI thought I was close to what I needed, but then I realized that it just fast-forwarded the commit meaning it didn't merge, it wrote over the original file in test.\nSo, to reiterate, how can I merge a specific file from one branch into another branch without just writing over the file in the branch I am merging into using git."}, {"role": "assistant", "content": "I think you like to use\ngit checkout -p\n\nIn your case\ngit checkout dev\ngit checkout -p test somecode.js\n\nAnd you can interactively apply the diffs."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "equivalence of: git log --exclude-author?\nAt work we have a git repo where the majority of all commits are automated commits by a bot user. There are times when I prefer to view a git log from that repo, but without seeing the auto commits. I guess it could be described as an inverted \"git log --author\" or a \"git log --exclude-author=botuser\", if such as option had existed.\nCurrently I do the following, shortcuted to a bash alias.\ngit log --format=\"%H %aE\" | grep -v -F botuser@domain | while read hash email; do git log -1 $hash; echo; done | less\n\nMy question is if there is a less hackish solution to what I want to accomplish?"}, {"role": "assistant", "content": "From https://coderwall.com/p/tzdzwa :\ngit log --perl-regexp --author='^((?!excluded-author-regex).*)$'\n\nThis worked for me.\nIf you don't want to specify --perl-regexp every time you can do:\ngit config --global grep.patternType perl"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker gittutorial-2"}, {"role": "assistant", "content": "A tutorial introduction to Git: part two"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Look up commit log for commit ID in Git\nI want to look at a commit by ID. For instance, I want to know the code that got committed for that ID, something like: \ngit log <commit_id>\n\nAnd this would display the committed code and commit message that corresponds to this ID."}, {"role": "assistant", "content": "git show <commit_id>\n\nis the droid you are looking for, probably."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Update Git submodule to latest commit on origin\nI have a project with a Git submodule. It is from an ssh://... URL, and is on commit A. Commit B has been pushed to that URL, and I want the submodule to retrieve the commit, and change to it.\nNow, my understanding is that git submodule update should do this, but it doesn't. It doesn't do anything (no output, success exit code). Here's an example:\n$ mkdir foo\n$ cd foo\n$ git init .\nInitialized empty Git repository in /.../foo/.git/\n$ git submodule add ssh://user@host/git/mod mod\nCloning into mod...\nuser@host's password: hunter2\nremote: Counting objects: 131, done.\nremote: Compressing objects: 100% (115/115), done.\nremote: Total 131 (delta 54), reused 0 (delta 0)\nReceiving objects: 100% (131/131), 16.16 KiB, done.\nResolving deltas: 100% (54/54), done.\n$ git commit -m \"Hello world.\"\n[master (root-commit) 565b235] Hello world.\n 2 files changed, 4 insertions(+), 0 deletions(-)\n create mode 100644 .gitmodules\n create mode 160000 mod\n# At this point, ssh://user@host/git/mod changes; submodule needs to change too.\n$ git submodule init\nSubmodule 'mod' (ssh://user@host/git/mod) registered for path 'mod'\n$ git submodule update\n$ git submodule sync\nSynchronizing submodule url for 'mod'\n$ git submodule update\n$ man git-submodule \n$ git submodule update --rebase\n$ git submodule update\n$ echo $?\n0\n$ git status\n# On branch master\nnothing to commit (working directory clean)\n$ git submodule update mod\n$ ...\n\nI've also tried git fetch mod, which appears to do a fetch (but can't possibly, because it's not prompting for a password!), but git log and git show deny the existence of new commits. Thus far I've just been rm-ing the module and re-adding it, but this is both wrong in principle and tedious in practice."}, {"role": "assistant", "content": "The git submodule update command actually tells Git that you want your submodules to each check out the commit already specified in the index of the superproject. If you want to update your submodules to the latest commit available from their remote, you will need to do this directly in the submodules.\nSo in summary:\n# Get the submodule initially\ngit submodule add ssh://bla submodule_dir\ngit submodule init\n\n# Time passes, submodule upstream is updated\n# and you now want to update\n\n# Change to the submodule directory\ncd submodule_dir\n\n# Checkout desired branch\ngit checkout master\n\n# Update\ngit pull\n\n# Get back to your project root\ncd ..\n\n# Now the submodules are in the state you want, so\ngit commit -am \"Pulled down update to submodule_dir\"\n\nOr, if you're a busy person:\ngit submodule foreach git pull origin master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options global"}, {"role": "assistant", "content": "$XDG_CONFIG_HOME/git/config ~/.gitconfig"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitHub: searching through older versions of files\nI know that using GitHub I can search through all the current versions of my files in a repo. However, I would also like to search through the older versions of my repo files. For example, say, I used to have a function called get_info() in my code, but deleted it several versions ago, is it possible to search for get_info and find the code. If it is not possible using GitHub, is it possible from the git command line?\nEDIT\nThanks to @Mark Longair for showing how this can be done from the git command line. If it's not possible in GitHub it would be a great feature to have."}, {"role": "assistant", "content": "Currently, I don't believe it's possible to search within the complete history of a repository's code on the github website - the closest is just searching within the current code of a repository with the \"code search\" option on this page.\nHowever, from the command line, you can find any commits that introduced or removed lines mentioning get_info with the -S option to git log. e.g.:\ngit log -Sget_info -p\n\n(n.b. there should be no space between -S and the search term)\n(also note: to search for more than one word, surround in '):\ngit log -S'get info' -p\n\nSo, at a minimum that should find the commit where the function was first introduced and the one that removed it. I added the -p so you can also see the patches - if lots of commits introduced changes that mentioned the function that may be helpful. If the function was only on another branch it might also be useful to use --all to search all branches.\nJefromi points out in a comment below that git 1.7.4 will introduce the -G option as an alternative - this change is summarized in a recent blog post from Junio Hamano (git maintainer): http://gitster.livejournal.com/48191.html"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-clone"}, {"role": "assistant", "content": "Clone a repository into a new directory"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Cannot push to GitHub - keeps saying need merge\nI met some issue when I was trying to push my code to GitHub.\nPushing to [email protected]:519ebayproject/519ebayproject.git\nTo [email protected]:519ebayproject/519ebayproject.git\n ! [rejected] master -> master (non-fast-forward)\nerror: failed to push some refs to '[email protected]:519ebayproject/519ebayproject.git'\nhint: Updates were rejected because the tip of your current branch is behind\nhint: its remote counterpart. Merge the remote changes (e.g. 'git pull')\nhint: before pushing again.\nhint: See the 'Note about fast-forwards' in 'git push --help' for details.\n\nI have not pushed anything in the repository yet, so why do I need to pull something?"}, {"role": "assistant", "content": "This can cause the remote repository to lose commits; use it with care.\n\nIf you do not wish to merge the remote branch into your local branch (see differences with git diff), and want to do a force push, use the push command with -f\ngit push -f origin <branch>\n\nwhere origin is the name of your remote repo.\n\nUsually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. This flag disables the check. This can cause the remote repository to lose commits; use it with care."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git: show all files changed between two commits\nA riff on git: show all changed files between two commits: I want a listing of all files that have been changed between two commits, even if they are now the same (ie, changed and then changed back)."}, {"role": "assistant", "content": "This is the best I could come up with:\ngit log --name-only --pretty=oneline --full-index HEAD^^..HEAD | grep -vE '^[0-9a-f]{40} ' | sort | uniq\n\nReplace HEAD^^ and HEAD with the commits you want to compare.\nMy attempt uses git log with --name-only to list all files of each commit between the specified ones. --pretty=oneline makes the part above the file listing consist only of the commit SHA and message title. --full-index makes the SHA be the full 40 characters. grep filters out anything looking like a SHA followed by a space. Unless you have files beginning with a SHA followed by a space, the result should be accurate."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --[no-]base[=<commit>]"}, {"role": "assistant", "content": "Record the base tree information to identify the state the\npatch series applies to. See the BASE TREE INFORMATION section\nbelow for details. If <commit> is \"auto\", a base commit is\nautomatically chosen. The --no-base option overrides a format.useAutoBase configuration."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --[no-]rename-empty"}, {"role": "assistant", "content": "Whether to use empty blobs as rename source."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Automatically Build NPM Module On Install From Github\n\nGiven that a project's lib/ dir shouldn't be checked into Git because the files it contains are derived files (from the build process). When installing a package from the project's github (during development for example) the lib/ dir will not exist, so if the package's package.json's main field points to (for example) lib/index.js, the package cannot be compiled when imported because these files do not exist within the repository and therefore within the package installed into node_modules. This means the package needs to built (just as it would be before release), only this time locally so that the lib directory (or whatever other files are generated during the build process) are added to the module's directory.\nAssuming there is a build script within the package.json file's scripts field, can the package be configured to run this automatically in the situation where it is installed from github only? If not, what is the the best approach to ensuring it is built when installed from github? \nThere are now prepublish, prepublishOnly and prepare lifecycle hooks, but none provide an answer to this problem because they don't allow any way to differentiate between the source of the install. In short, yes they allow you to build on install, but they don't allow you to build on install from github only. There is not only no reason to force a build when people install from npm, but more importantly, development dependencies will not be installed (for example babel which is critical to the build).\nI am aware of one strategy to deal with this problem:\n\nFork / branch the repo\nbuild locally\nremove the lib/ dir from .gitignore and check it in.\ninstall module from your fork/branch\nWhen you are ready for a PR / rebase add lib/ dir to .gitignore and remove dir from git.\n\nBut that is far from ideal. I guess this could be automated with a githook though. So every you push to master the project also builds and pushes to a separate branch.\nThere is a closed issue on NPM's Github with no resolution - just lots of people who want a solution. From this issue it is clear that using prepare is not the answer. \nMy usecase is that I am developing a module that is used in a number of other projects. I want to consume the latest version of the module without having to push out a release to NPM whenever I update the codebase - I would rather push out fewer releases when I am ready, but I still need to consume whatever the latest version of the lib is on Github. \nNote: I also reached out to NPM's support regarding this issue and I'll add their response if I receive one."}, {"role": "assistant", "content": "prepare is the correct way, but might seem broken\nIf you have a repository with source files but a \"build\" step is necessary to use it,\nprepare does exactly what you want in all cases (as of npm 4).\n\nprepare: Run both BEFORE the package is packed and published, on local npm install without any arguments, and when installing git dependencies.\n\nYou can even put your build dependencies into devDependencies and they will be installed before prepare is executed.\nHere is an example of a package of mine that uses this method.\n\nProblems with .gitignore - prepare will seem broken\nThere is one issue with this option that gets many people.\nWhen preparing a dependency, Npm and Yarn will keep only the files that are listed in the files section of package.json.\nOne might see that files defaults to all files being included and think they're done.\nWhat is easily missed is that:\n\n.npmignore mostly overrides the files directive and,\nif .npmignore does not exist, .gitignore is used instead.\n\nSo, if you have your built files listed in .gitignore, like a sane person, and don't do anything else, prepare will seem broken.\nIf you fix files to only include the built files or add an empty .npmignore, you're all set.\nMy recommendation is to set files (or, by inversion, .npmignore) such that the only files actually published are those needed by users of the published package. Imho, there is no need to include uncompiled sources in published packages."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Pulling from Git fails and gives me following error: client_global_hostkeys_private_confirm: server gave bad signature for RSA key 0\nI am working on a project with my teammates. Some weeks ago, I pulled the project from git successfully. But today when I wanted to pull the updated project via the command \"git pull origin <my_branch>\", it gave me the following error:\nclient_global_hostkeys_private_confirm: server gave bad signature for RSA key 0\nI have generated the public key using the command ssh-keygen and then pasted the content of the new generated file id_rsa.pub in the \"Add an SSH key\" section of Git, But the pull command did not work. Could somebody help me?"}, {"role": "assistant", "content": "The message \"client_global_hostkeys_private_confirm: server gave bad signature for RSA key 0\" is not an error, it is a warning, and it is related to some ssh versioning issue. It used to be very common to receive from GitLab.\nIf you want it to go away, you can make sure that your ~/.ssh/config contains the following:\nHost gitlab.com\n UpdateHostKeys no\n\nHowever, if you are in fact being prevented from pulling, then this bad signature warning is probably not the reason. Once you make the warning go away, you will still have to find the real problem that you have, about which we know nothing, as the question stands right now."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to update a git shallow clone?\nBackground\n(for tl;dr, see #questions below)\nI have multiple git repository shallow clones. I'm using shallow clones because it's a lot smaller compared to a deep clone. Each is cloned doing about git clone --single-branch --depth 1 <git-repo-url> <dir-name>.\nThis works fine, except I don't see how to update it.\nWhen I'm cloning by a tag, update is not meaningful, as a tag is frozen point in time (as I understand it). In this case, if I want to update, this means I want to clone by another tag, so I just rm -rf <dir-name> and clone again.\nThings get more complicated when I’ve cloned the HEAD of a master branch then later want to update it.\nI tried git pull --depth 1 but although I'm not to push anything to the remote repository, it complains it don’t know who I am.\nI tried git fetch --depth 1, but although it seems to update something, I checked it is not up to date (some files on the remote repository have a different content than the ones on my clone).\nAfter https://stackoverflow.com/a/20508591/279335 , I tried git fetch --depth 1; git reset --hard origin/master, but two things: first I don't understand why git reset is needed, second, although the files seems to be up to date, some old files remains, and git clean -df does not delete these files.\nQuestions\nLet a clone created with git clone --single-branch --depth 1 <git-repo-url> <dir-name>. How to update it to achieve the same result as rm -rf <dir-name>; git clone --single-branch --depth 1 <git-repo-url> <dir-name>? Or is rm -rf <dir-name> and clone again the only way?\nNote\nThis is not a duplicate of How to update a shallow cloned submodule without increasing main repo size , as the answer does not fulfil my expectations and I'm using simple repositories, not sub‑modules (which I don't know about)."}, {"role": "assistant", "content": "TL;DR\nGiven that you have an existing --depth 1 repository cloned from branch B and you'd like Git to act as if you removed and re-cloned, you can use this sequence of commands:\ngit fetch --depth 1\ngit reset --hard origin/B\ngit clean -dfx\n\n(e.g., git reset --hard origin/master—I cannot put italics in the code-literal section above). You should be able to do the git clean step at any point before or after the other two commands, but the git reset must come after the git fetch.\nLong\n\n[slightly reworded and formatted] Given a clone created with git clone --single-branch --depth 1 url directory, how can I update it to achieve the same result as rm -rf directory; git clone --single-branch --depth 1 url directory?\n\nNote that --single-branch is the default when using --depth 1. The (single) branch is the one you give with -b. There's a long aside that goes here about using -b with tags but I will leave that for later. If you don't use -b, your Git asks the \"upstream\" Git—the Git at url—which branch it has checked-out, and pretends you used -b thatbranch. This means that it is important to be careful when using --single-branch without -b to make sure that this upstream repository's current branch is sensible, and of course, when you do use -b, to make sure that the branch argument you give really does name a branch, not a tag.\nThe simple answer is basically this one, with two slight changes:\n\nAfter https://stackoverflow.com/a/20508591/279335, I tried git fetch --depth 1; git reset --hard origin/master, but two things: first I don't understand why git reset is needed, second, although the files seems to be up to date, some old files remains, and git clean -df does not delete these files.\n\nThe two slight changes are: make sure you use origin/branchname instead, and add -x (git clean -d -f -x or git clean -dfx) to the git clean step. As for why, that gets a bit more complicated.\nWhat's going on\nWithout --depth 1, the git fetch step calls up the other Git and gets from it a list of branch names and corresponding commit hash IDs. That is, it finds a list of all the upstream's branches and their current commits. Then, because you have a --single-branch repository, your Git throws out all but the single branch, and brings over everything Git needs to connect that current commit back to the commit(s) you already have in your repository.\nWith --depth 1, your Git doesn't bother connecting the new commit to older historical commits at all. Instead, it obtains just the one commit and the other Git objects needed to complete that one commit. It then writes an additional \"shallow graft\" entry to mark that one commit as a new pseudo-root commit.\nRegular (non-shallow) clone and fetch\nThese are all related to how Git behaves when you're using a normal (non-shallow, non-single-branch) clone: git fetch calls up the upstream Git, gets a list of everything, and then brings over whatever you don't already have. This is why an initial clone is so slow, and a fetch-to-update is usually so fast: once you get a full clone, the updates rarely have very much to bring over: maybe a few commits, maybe a few hundred, and most of those commits don't need much else either.\nThe history of a repository is formed from the commits. Each commit names its parent commit (or for merges, parent commits, plural), in a chain that goes backwards from \"the latest commit\", to the previous commit, to some more-ancestral commit, and so on. The chain eventually stops when it reaches a commit that has no parent, such as the first commit ever made in the repository. This kind of commit is a root commit.\nThat is, we can draw a graph of commits. In a really simple repository the graph is just a straight line, with all the arrows pointing backwards:\no <- o <- o <- o <-- master\n\nThe name master points to the fourth and latest commit, which points back to the third, which points back to the second, which points back to the first.\nEach commit carries with it a complete snapshot of all the files that go in that commit. Files that are not at all changed are shared across these commits: the fourth commit just \"borrows\" the unchanged version from the third commit, which \"borrows\" it from the second, and so on. Hence, each commit names all the \"Git objects\" that it needs, and Git either finds those objects locally—because it already has them—or uses the fetch protocol to bring them over from the other, upstream Git. There's a compression format called \"packing\", and a special variant for network transfer called \"thin packs\", that allows Git to do this even better / fancier, but the principle is simple: Git needs all, and only, those objects that go with the new commits it's picking up. Your Git decides whether it has those objects, and if not, obtains them from their Git.\nA more-complicated, more-complete graph generally has several points where it branches, some where it merges, and multiple branch names pointing to different branch tips:\n o--o <-- feature/tall\n /\no--o--o---o <-- master\n \\ /\n o--o <-- bug/short\n\nHere branch bug/short is merged back into master, while branch feature/tall is still undergoing development. The name bug/short can (probably) now be deleted entirely: we don't need it anymore if we are done making commits on it. The commit at the tip of master names two previous commits, including the commit at the tip of bug/short, so by fetching master we will fetch the bug/short commits.\nNote that both the simple and slightly-more-complicated graph each have just one root commit. That's pretty typical: all repositories that have commits have at least one root commit, since the very first commit is always a root commit; but most repositories have only one root commit as well. You can, however, have different root commits, as with this graph:\n o--o\n \\\no--o--o <-- master\n\nor this one:\n o--o <-- orphan\n\no--o <-- master\n\nIn fact, the one with just the one master was probably made by merging orphan into master, then deleting the name orphan.\nGrafts and replacements\nGit has for a long time had (possibly shaky) support for grafts, which was replaced with (much better, actually-solid) support for generic replacements. To grasp them concretely we need to add, to the above, the notion that each commit has its own unique ID. These IDs are the big ugly 40-character SHA-1 hashes, face0ff... and so on. In fact, every Git object has a unique ID, though for graph purposes, all we care about are the commits.\nFor drawing graphs, those big hash IDs are too painful to use, so we can use one-letter names A through Z instead. Let's use this graph again but put in one-letter names:\n E--H <-- feature/tall\n /\nA--B--D---G <-- master\n \\ /\n C--F <-- bug/short\n\nCommit H refers back to commit E (E is H's parent). Commit G, which is a merge commit—meaning it has at least two parents—refers back to both D and F, and so on.\nNote that the branch names, feature/tall, master, and bug/short, each point to one single commit. The name bug/short points to commit F. This is why commit F is on branch bug/short ... but so is commit C. Commit C is on bug/short because it is reachable from the name. The name gets us to F, and F gets us to C, so C is on branch bug/short.\nNote, however, that commit G, the tip of master, gets us to commit F. This means that commit F is also on branch master. This is a key concept in Git: commits may be on one, many, or even no branches. A branch name is merely a way to get started within a commit graph. There are other ways, such as tag names, refs/stash (which gets you to the current stash: each stash is actually a couple of commits), and the reflogs (which are normally hidden from view as they are normally just clutter).\nThis also, however, gets us to grafts and replacements. A graft is just a limited kind of replacement, and shallow repositories use a limited form of graft.1 I won't describe replacements fully here as they are a bit more complicated, but in general, what Git does for all of these is to use the graft or replacement as an \"instead-of\". For the specific case of commits, what we want here is to be able to change—or at least, pretend to change—the parent ID or IDs of any commit ... and for shallow repositories, we want to be able to pretend that the commit in question has no parents.\n\n1The way shallow repositories use the graft code is not shaky. For the more general case, I recommended using git replace instead, as that also was and is not shaky. The only recommended use for grafts is—or at least was, years ago—to put them in place just long enough to run git filter-branch to copy an altered—grafted—history, after which you should just discard the grafted history entirely. You can use git replace for this purpose as well, but unlike grafts, you can use git replace permanently or semi-permanently, without needing git filter-branch.\n\nMaking a shallow clone\nTo make a depth-1 shallow clone of the current state of the upstream repository, we will pick one of the three branch names—feature/tall, master, or bug/short—and translate it to a commit ID. Then we will write a special graft entry that says: \"When you see that commit, pretend that it has no parent commits, i.e., is a root commit.\"\nLet's say we pick master. The name master points to commit G, so to make a shallow clone of commit G, we obtain commit G from the upstream Git as usual, but then write a special graft entry that claims commit G has no parents. We put that into our repository, and now our graph looks like this:\nG <-- master, origin/master\n\nThose parent IDs are still actually inside G; it's just that every time we have Git use or show us the history, it immediately \"grafts\" nothing-at-all on, so that G seems to be a root commit, for history tracking purposes.\nUpdating a shallow clone we made earlier\nBut what if we already have a (depth-1 shallow) clone, and we want to update it? Well, that's not really a problem. Let's say we made a shallow clone of the upstream back when master pointed to commit B, before the new branches and the bug fix. That means we currently have this:\nB <-- master, origin/master\n\nWhile B's real parent is A, we have a shallow-clone graft entry saying \"pretend B is a root commit\". Now we git fetch --depth 1, which looks up the upstream's master—the thing we call origin/master—and sees commit G. We grab commit G from the upstream, along with its objects, but deliberately don't grab commits D and F. We then update our shallow-clone graft entries to say \"pretend G is a root commit too\":\nB <-- master\n\nG <-- origin/master\n\nOur repository now has two root commits: The name master (still) points to commit B, whose parents we (still) pretend are non-existent, and the name origin/master points to G, whose parents we pretend are non-existent.\nThis is why you need git reset\nIn a normal repository, you might use git pull, which really is git fetch followed by git merge. But git merge requires history, and we have none: we have faked Git out with pretend root commits, and they have no history behind them. So we must use git reset instead.\nWhat git reset does is a bit complicated, because it can affect up to three different things: a branch name, the index, and the work-tree. We have already seen what the branch names are: they simply point to a (one, specific) commit, which we call the tip of the branch. That leaves the index and work-tree.\nThe work-tree is easy to explain: it's where all your files are. That's it: no more and no less. It's there so that you can actually use Git: Git is all about storing every commit ever made, forever, so that they can all be retrieved. But they're in a format useless to mere mortals. To be used, a file—or more typically, a whole commit's worth of files—has to be extracted into its normal format. The work-tree is where that happens, and then you can work on it and make new commits using it too.\nThe index is a bit harder to explain. It's something peculiar to Git: other version control systems don't have one, or if they have something like it, they don't expose it. Git does. Git's index is essentially where you keep the next commit to make, but that means that it starts out holding the current commit that you have extracted into the work-tree, and Git uses that to make Git fast. We'll say more about this in a bit.\nWhat git reset --hard does is to affect all three: branch name, index, and work-tree. It moves the branch name so that it points to a (probably different) commit. Then it updates the index to match that commit, and updates the work-tree to match the new index.\nHence:\ngit reset --hard origin/master\n\ntells Git to look up origin/master. Since we ran our git fetch, that now points to commit G. Git then makes our master—our current (and only) branch—also point to commit G, and then updates our index and work-tree. Our graph now looks like this:\nB [abandoned - but see below]\n\nG <-- master, origin/master\n\nNow master and origin/master both name commit G, and commit G is the one checked-out into the work-tree.\nWhy you need git clean -dfx\nThe answer here is a bit complicated, but usually it's \"you don't\" (need to git clean).\nWhen you do need git clean, it is because you—or something you ran—added files to your work-tree that you have not told Git about. These are untracked and/or ignored files. Using git clean -df will remove untracked files (and empty directories); adding -x will also remove the ignored files.\nFor more about the difference between \"untracked\" and \"ignored\", see this answer.\nWhy you don't need git clean: the index\nI mentioned above that you usually don't need to run git clean. This is because of the index. As I said earlier, Git's index is mainly \"the next commit to make\". If you never add your own files—if you are just using git checkout to check out various existing commits that you have had all along, or that you have added with git fetch; or if you are using git reset --hard to move a branch name and also switch the index and work-tree to another commit—then whatever is in the index right now is there because an earlier git checkout (or git reset) put it in the index, and also into the work-tree.\nIn other words, the index has a short—and fast for Git to access—summary or manifest describing the current work-tree. Git uses that to know what is in the work-tree now. When you ask Git to switch to another commit, via git checkout or git reset --hard, Git can quickly compare the existing index to the new commit. Any files that have changed, Git must extract from the new commit (and update the index). Any files that are newly added, Git must also extract (and update the index). Any files that are gone—that are in the existing index, but not in the new commit—Git must remove ... and that's what Git does. Git updates, adds, and removes those files in the work-tree, as directed by the comparison between the current index, and the new commit.\nWhat this means is that if you do need git clean, you must have done something outside Git that added files. These added files are not in the index, so by definition, they are untracked and/or ignored. If they are merely untracked, git clean -f would remove them, but if they are ignored, only git clean -fx will remove them. (You want -d just to remove directories that are or become empty during the cleaning.)\nAbandoned commits and garbage collection\nI mentioned, and drew in the updated shallow graph, that when we git fetch --depth 1 and then git reset --hard, we wind up abandoning the previous depth-1 shallow graph commit. (In the graph I drew, this was commit B.) However, in Git, abandoned commits are rarely truly abandoned—at least, not right away. Instead, some special names like ORIG_HEAD hang on to them for a while, and each reference—branches and tags are forms of reference—carries with it a log of \"previous values\".\nYou can display each reflog with git reflog refname. For instance, git reflog master shows you not only which commit master names now, but also which commits it has named in the past. There is also a reflog for HEAD itself, which is what git reflog shows by default.\nReflog entries eventually expire. Their exact duration varies, but by default they are eligible for expiration after 30 days in some cases and 90 days in others. Once they do expire, those reflog entries no longer protect abandoned commits (or, for annotated tag references, the annotated tag object—tags are not supposed to move, so this case is not supposed to occur, but if it does—if you force Git to move a tag—it's just handled in the same way as all other references).\nOnce any Git object—commit, annotated tag, \"tree\", or \"blob\" (file)—is really unreferenced, Git is allowed to remove it for real.2 It's only at this point that the underlying repository data for the commits and files goes away. Even then, it only happens when something runs git gc. Thus, a shallow repository updated with git fetch --depth 1 is not quite the same as a fresh clone with --depth 1: the shallow repository probably has some lingering names for the original commits, and won't remove the extra repository objects until those names expire or are otherwise cleared-out.\n\n2Besides the reference check, objects get a minimum time before they expire as well. The default is two weeks. This prevents git gc from deleting temporary objects that Git is creating, but has yet to establish a reference to. For instance, when making a new commit, Git first turns the index into a series of tree objects which refer to each other but have no top-level reference. Then it creates a new commit object that refers to the top-level tree, but nothing yet refers to the commit. Last, it updates the current branch name. Until that last step finishes, the trees and new commit are unreachable!\n\nSpecial considerations for --single-branch and/or shallow clones\nI noted above that the name you give to git clone -b can refer to a tag. For normal (non-shallow or non-single-branch) clones, this works just as one would expect: you get a regular clone, and then Git does a git checkout by the tag name. The result is the usual detached HEAD, in a perfectly ordinary clone.\nWith shallow or single-branch clones, however, there are several unusual consequences. These are all, to some extent, a result of Git letting the implementation show through.\nFirst, if you use --single-branch, Git alters the normal fetch configuration in the new repository. The normal fetch configuration depends on the name you choose for the remote, but the default is origin so I will just use origin here. It reads:\nfetch = +refs/heads/*:refs/remotes/origin/*\n\nAgain, this is the normal configuration for a normal (not single-branch) clone. This configuration tells git fetch what to fetch, which is \"all branches\". When you use --single-branch, though, you get instead a fetch line that refers to only the one branch:\nfetch = +refs/heads/zorg:refs/remotes/origin/zorg\n\nif you're cloning the zorg branch.\nWhichever branch you clone, that's the one that goes into the fetch line. Each future git fetch will obey this line,3 so you won't fetch any other branches. If you do want to fetch other branches later, you will have to alter this line, or add more lines.\nSecond, if you use --single-branch and what you clone is a tag, Git will put in a rather odd fetch line. For instance, with git clone --single-branch -b v2.1 ... I get:\nfetch = +refs/tags/v2.1:refs/tags/v2.1\n\nThis means you will get no branches, and unless someone has moved the tag,4 git fetch will do nothing!\nThird, the default tag behavior is a bit weird due to the way git clone and git fetch obtain tags. Remember that tags are simply a reference to one particular commit, just like branches and all other references. There are two key differences between branches and tags, though: branches are expected to move (and tags are not), and branches get renamed (and tags don't).\nRemember that all throughout the above, we keep finding that the other (upstream) Git's master becomes our origin/master, and so on. This is an example of the renaming process. We also saw, briefly, precisely how that renaming works, through the fetch = line: our Git takes their refs/heads/master and changes it to our refs/remotes/origin/master. This name is not only different-looking (origin/master), but literally can't be the same as any of our branches. If we create a branch named origin/master,5 this branch's \"full name\" is actually refs/heads/origin/master which is different from the other full name refs/remotes/origin/master. It's only when Git uses the shorter name that we have one (regular, local) branch named origin/master and another different (remote-tracking) branch named origin/master. (It's a lot like being at a group where everyone is named Bruce.)\nTags don't go through all this. The tag v2.1 is just named refs/tags/v2.1. This means there's no way to separate \"their\" tag from \"your\" tag. You can have either your tag, or their tag. As long as no one ever moves a tag, this doesn't matter: if you both have the tag, it must point to the same object. (If someone starts moving tags, things get ugly.)\nIn any case, Git implements the \"normal\" fetching of tags by a simple rule:6 when Git already has a commit, if some tag names that commit, Git copies the tag too. With ordinary clones, the first clone gets all the tags, and then subsequent git fetch operations get the new tags. A shallow clone, however, by definition omits some commit(s), namely everything below any graft-point in the graph. Those commits won't pick up the tags. They can't: to have the tags, you would need to have the commits. Git is not allowed (except through the shallow grafts) to have the ID of a commit without actually having the commit.\n\n3You can give git fetch some refspec(s) on the command line, and those will override the default. This applies only to a default fetch. You may also use multiple fetch = lines in the configuration, e.g., to fetch just a specific set of branches, although the normal way to \"de-restrict\" an initially-single-branch clone is to put back the usual +refs/heads/*:refs/remotes/origin/* fetch line.\n4Since tags are not supposed to move, we could just say \"this does nothing\". If they do move, though, the + in the refspec represents the force flag, so the tag winds up moving.\n5Don't do this. It's confusing. Git will handle it just fine—the local branch is in the local name space, and the remote-tracking branch is in the remote-tracking name space—but it's really confusing.\n6This rule does not match the documentation. I tested against Git version 2.10.1; older Gits might use a different method. Git since 2.26 may also use different rules now that there is a newer, fancier protocol for git fetch and git push to use. If you care about the precise behavior with tags, you may need to test it on your particular Git version."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to get rid of \"You are currently editing a commit\"?\nSuddenly appeared:\nMacBook-Pro: $ git status\nOn branch dev\nYour branch is up-to-date with 'dropbox/dev'.\nYou are currently editing a commit while rebasing branch 'Releases' on '72ca998'.\n (use \"git commit --amend\" to amend the current commit)\n (use \"git rebase --continue\" once you are satisfied with your changes)\n\nnothing to commit, working directory clean\n\nNo changed in the branch. Everything is up to date."}, {"role": "assistant", "content": "git rebase --abort should abort the rebase operation and return to the previous state. But to be sure, what commands did you enter before?\nedit: the output of git reflog can show you where the rebase started, it would look something like\n7d0b010 HEAD@{0}: rebase finished: returning to refs/heads/bran\n7d0b010 HEAD@{1}: rebase: adding file in branch\na7e6693 HEAD@{2}: rebase: checkout master\na7e6693 HEAD@{3}: commit: adding file in master\n4c00dd7 HEAD@{4}: checkout: moving from bran to master\n3cb192a HEAD@{5}: commit: adding file in branch"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What's the difference between 'git switch' and 'git checkout' <branch>?\nGit 2.23 introduces a new command git switch. After reading the documentation, it seems pretty much the same as git checkout <branchname>. What is the difference or use case?\n\nTwo new commands \"git switch\" and \"git restore\" are introduced to\nsplit \"checking out a branch to work on advancing its history\" and\n\"checking out paths out of the index and/or a tree-ish to work on\nadvancing the current history\" out of the single \"git checkout\"\ncommand."}, {"role": "assistant", "content": "Well, according to the documentation you link to, its sole purpose is to split and clarify the two different uses of git checkout:\n\ngit switch can now be used to change branches, as git checkout <branchname> does\ngit restore can be used to reset files to certain revisions, as git checkout -- <path_to_file> does\n\nPeople are confused by these different ways to use git checkout, as you can see from the many questions regarding git checkout here on Stack Overflow. Git developers seem to have taken this into account."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Prevent git from asking for the GnuPG password during signing a commit\n\nGit always asks me to enter a passphrase to unlock my secret key while signing a commit using.\ngit commit -S -m 'message'\n\nHow can I store in cache the password so that I don't have to enter it each and every time while signing the commit"}, {"role": "assistant", "content": "Git never gets hold of the GnuPG passphrase. You must rely on GnuPG's capabilities of caching passphrases, which happens through gpg-agent which are easily set up by editing ~/.gnupg/gpg-agent.conf (hidden somewhere in your AppData folder in Windows).\nSet default-cache-ttl to the number of seconds the passphrase is cached after each invocation of GnuPG. maximum-cache-ttl sets the time after the passphrase was initially entered at which the cache is wiped. Make sure ignore-cache-for-signing is not set -- otherwise GnuPG will ignore the cache for signing operations.\nIf you want to sign commits without any user interaction, you can prefill the cache through gpg-preset-passphrase, often hidden somewhere in a location like /usr/lib/gnupg2/gpg-preset-passphrase; or by running an arbitrary decryption or signing operation. You might also configure git to use an option like --passphrase [your passphrase] to be passed to gpg, but read up on the restrictions and security implications of this approach (it involves your passphrase being stored in plaintext somewhere).\nFull list of options is here."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Gitlab Pages: Failed to verify domain ownership\n\nThis morning I got emails for each of my Gitlab Pages that are hosted on custom domains, saying that the domain verification failed.\nThat's fine, because I don't think I ever verified them in the first place - good on Gitlab for getting this going.\nWhen I head on over the the Settings>Pages>Domain_Details on each repo, I see the instructions to create the following record:\n_gitlab-pages-verification-code.blog.ollyfg.com TXT gitlab-pages-verification-code={32_digit_long_code}\n\nOn creating this record, and clicking the \"Verify Ownership\" button, I get the message \"Failed to verify domain ownership\".\nI have ensured that the record is set, and calling\ndig -t txt +short _gitlab-pages-verification-code.blog.ollyfg.com\n\nReturns:\n\"gitlab-pages-verification-code={same_32_digit_long_code}\"\n\nIs this a bug in Gitlab? Am I doing something wrong?\nThanks!"}, {"role": "assistant", "content": "The docs (and the verification page) were a little confusing for me. Here's what worked for me, on GoDaddy:\n\nA Record:\nName: @\nValue: 35.185.44.232\nCNAME:\nName: example.com\nValue: username.gitlab.io\nTXT Record:\nName: @\nValue: gitlab-pages-verification-code=00112233445566778899aabbccddeeff\n\nVerified with Gitlab, and also:\ndig -t txt +short example.com"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options clone.defaultRemoteName"}, {"role": "assistant", "content": "The name of the remote to create when cloning a repository. Defaults to origin .\nIt can be overridden by passing the --origin command-line\noption to git-clone ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Gitlab Trigger API returns 404\n\nI created a trigger (using settings/ci_cd page). The instructions below the trigger tell me to call it using version 3 API (of course, I set the token variable to the token stated under the trigger section):\ncurl -X POST \\\n -F token=${TOKEN} \\\n -F ref=master \\\n https://gitlab.com/api/v3/projects/2313008/trigger/builds\n\nWhich only returns:\n\n{\"error\":\"404 Not Found\"}\n\nI also tried to follow the API v4 documentation:\ncurl --request POST \\\n --form token=${TOKEN} \\\n --form ref=master \\\n https://gitlab.com/api/v4/projects/2313008/trigger/pipeline\n\nwhich returns the same error.\nAre there any additional settings required?"}, {"role": "assistant", "content": "I had the same issue, but I was using Personal Access Token instead of Pipeline trigger token!!\nYou can generate this token inside your project repo CI/CD settings."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Diffing between two entire directories/projects in hg or git?\nI inherited a project originally stored in CVS with all the revisions. I made quite a few edits, and I'm trying to compare all the changes I made in the original directory, in regards to new files added versus the old ones.\nIs there some sort of utility for hg/git where I can do a tree diff, or something of that nature? So that say, there's a mark between newly added files, deleted files, am I asking for too much?"}, {"role": "assistant", "content": "To simply create a diff patch in git's diff format from two arbitrary files or directories, without any fancy repository stuff or version control:\ngit diff --no-index some/path other/path > some_filename\n\nJakub Narębski's comment on knittl's answer hinted at the answer... For simplicity's sake, that's the full command.\nThe > part creates a file and redirects the output to it. If you don't want a file and just want the output printed in your console so you can copy it, just remove the > some_filename part.\n\nFor convenient copying and pasting, if you've already cded to a directory containing the original directory/file named a and the modified directory b, it'll be:\ngit diff --no-index a b > patch"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options sendemail.<identity>.*"}, {"role": "assistant", "content": "Identity-specific versions of the sendemail.* parameters\nfound below, taking precedence over those when this\nidentity is selected, through either the command-line or sendemail.identity ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options detachedHead"}, {"role": "assistant", "content": "Shown when the user uses git-switch or git-checkout to move to the detached HEAD state, to tell the user how\nto create a local branch after the fact."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "pip connection failure: cannot fetch index base URL http://pypi.python.org/simple/\nI run sudo pip install git-review, and get the following messages:\nDownloading/unpacking git-review\n Cannot fetch index base URL http://pypi.python.org/simple/\n Could not find any downloads that satisfy the requirement git-review\nNo distributions at all found for git-review\nStoring complete log in /home/sai/.pip/pip.log\n\nDoes anyone has any idea about this?"}, {"role": "assistant", "content": "I know this is an old thread, but I encountered this issue today and wanted to share my solution to the problem because I haven't seen this solution elsewhere on SO.\nMy environment: Python 2.7.12/2.7.14 on Ubuntu 12.04.5 LTS in a virtualenv, pip version 1.1.\nMy Errors:\npip install nose\n\nin console:\nCannot fetch index base URL http://pypi.python.org/simple/\n\nin ~/.pip/pip.log:\nCould not fetch URL http://pypi.python.org/simple/: HTTP Error 403: SSL is required\n\nCurious for me because I had been running these same commands in a script without issue for about a year.\nthis fixed it:\npip install --index-url=https://pypi.python.org/simple/ nose\n\n(note the https)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-help - Display help information about Git -a --all"}, {"role": "assistant", "content": "Print all the available commands on the standard output."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to rebase many branches (with the same base commit) at once?\nI have a master branch in my project, that I use to pull changes from other people. From that, I usually have several topic branches on which I'm currently working.\nMy question is: Is there a way for me to pull new changes into my master and then rebase ALL of my topic branches onto that at once?\nThis is the situation:\n D--E topic1\n /\nA--B--C master\n \\\n F--G topic2\n\nAnd I want to accomplish this with one single command (H came from upstream) :\n\n D'--E' topic1\n /\n A--B--C--H master\n \\\n F'--G' topic2\n\nNow, I know I can accomplish this by rebasing topic1 and topic2 onto master, and I could even write a script to automate this. But what if I have several other branches, create new ones and delete others frequently and I receive upstream changes all the time?\nThis operation (several rebases), when done by hand, is both tiring and error-prone.\nIs there an easier way?"}, {"role": "assistant", "content": "I'm fairly sure that there isn't a way to automatically do this. Remember that \"git rebase master\" can also drop you back to the shell needing you to resolve merge conflicts, so if you want to write a script to automate all this you need to take that into account.\nYou can fairly easily track which branches need updating, though. Hmm, for any branch, \"git rev-list branch..master\" will produce output if the branch is not up-to-date wrt (i.e. just commits on top of) master. So you need to loop through all the local heads except master to produce a report (nb \"git show-branch\" will approximately do this):\ngit for-each-ref 'refs/heads/*' | \\\n while read rev type ref; do\n branch=$(expr \"$ref\" : 'refs/heads/\\(.*\\)' )\n revs=$(git rev-list $rev..master)\n if [ -n \"$revs\" ]; then\n echo $branch needs update\n git diff --summary --shortstat -M -C -C $rev master\n fi\n done\n\nSo if you were feeling brave, you could replace that \"git diff\" with something like \"git checkout $branch && git rebase master\" (or maybe just \"git pull --rebase\" if you've set that up). I think you'd then have to check for the existence of a \".git/rebase-apply\" directory or check the index for unmerged files (\"git ls-files -u\") to test if we've been left waiting to do a merge.\nOf course, if there are no conflicts, then it's easy... it's producing something that also works when it's not easy that's the problem :p\nAnd this doesn't necessarily address what happens if one of your branches is based on something else... that's why I mentioned using \"git pull --rebase\" instead, because that would rebase according to the branch configuration, not blindly from master. Although the detection isn't based on the branch configuration... maybe it would be easiest just to check out each branch and do \"git pull\" and let the branch configuration handle everything, including whether to rebase or merge?"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git: merge two branches: what direction?\nWe have the following situation:\n A --- B --- C --- ... --- iphone\n /\n ... --- last-working --- ... --- master\n\nBetween last-working and iPhone, 32 commits were made. Between last-working and master, a lot of commits were made.\nWhat I want now is a new branch where I have iphone and current master merged together. And at some later time, this should be merged into the master.\nFirst, I planned to do:\ngit checkout iphone -b iphone31\ngit merge master\n\nBut then I thought, if it would be better to do:\ngit checkout master -b iphone31\ngit merge iphone\n\nNow I am wondering. What would be the difference in the result? Would the merge behave different?\nI already tried both and as I have expected, I got many conflicts because iphone is really old compared to master. Now I wonder about the easiest way to merge them.\nMaybe even starting with master and merging each single commit of iphone into it would be easier? Like doing this:\ngit checkout master -b iphone31\ngit merge A\ngit merge B\ngit merge C\n...\ngit merge iphone\n\n\nAt the very end, when this merge is done (i.e. all conflicts are resolved and it is working), I want to do this:\ngit checkout master\ngit merge iphone31"}, {"role": "assistant", "content": "Regarding the alternatives\ngit checkout iphone -b iphone31\ngit merge master\n\nand\ngit checkout master -b iphone31\ngit merge iphone\n\nthey will have identical ease or difficulty, it is like arguing whether a glass is half full or half empty.\nVersion tree perception\nHow we look at version trees are in some way just our arbitrary perception.\nLet's say that we have a version tree like the following:\n A----------+\n | |\n | |\n \\_/ \\_/\n B X\n | |\n | |\n \\_/ \\_/\n C Y\n |\n |\n \\_/\n D\n |\n |\n \\_/\n E\n\nAnd let's say that we want to make a new version Z checked out from Y\nbased on the changes from C to E but not including the changes made from\nA to C.\n\"Oh, that will be difficult because there is no common starting point.\"\nWell not really. If we just place the objects a little differently\nin the graphical layout like this\n /\n C+---------+\n | \\ |\n | |\n \\_/ |\n D B\n | / \\\n | |\n \\_/ |\n E A\n |\n |\n \\_/\n X\n |\n |\n \\_/\n Y\n\nnow things are starting to look promising. Notice that I have not\nchanged any relation ships here, the arrows all point the same way as\nin the previous picture and version A is still the common base.\nOnly the layout is changed.\nBut it now trivial to imagine a different tree\n C'---------+\n | |\n | |\n \\_/ \\_/\n D B'\n | |\n | |\n \\_/ \\_/\n E A\n |\n |\n \\_/\n X\n |\n |\n \\_/\n Y\n\nwhere the task would just be to merge version E normally.\nSo you can merge anything you want, the only thing that influence\nthe ease or difficulty is the aggregate of changes done between where\nyou select as a starting point or common base and where you merge to.\nYou are not limited to using the natural starting point the your\nversioning tool suggest.\nThis might not be simple with some version control systems/tools,\nbut if all else fails there\nis nothing that stops you from doing this manually by\nchecking out version C and save the file as file1,\nchecking out version E and save the file as file2,\nchecking out version Y and save the file as file3,\nand run kdiff3 -o merge_result file1 file2 file3.\nAnswer\nNow for your specific situation it is difficult to say exactly what\nstrategy that will produce the least amount of problems, but\nif there are many changes that create some kind of conflict it\nprobably is easier to split up and merge smaller parts.\nMy suggestion would be that\nsince there are 32 commits between last-working and iphone,\nyou could for instance start by branching of master and then\nmerge in the first 16 commits. If that turns out to\nbe too much trouble, revert and try to merge the 8 first commits.\nAnd so on. In worst case you end up merging each of the 32 commits one by one,\nbut it would probably be easier than having to handle all the\naccumulated conflicts in one single merge operation (and\nin that case you are working with a really diverging code base).\nTips:\nDraw on paper a version tree and note with arrows what you want to\nmerge. Cross off things as they are done if you split up the process\nin several steps. This will give you a clearer picture of what you want\nto achieve, what you have done so far and what is left.\nI can really recommend KDiff3, it is an excellent diff/merge tool."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options index.recordOffsetTable"}, {"role": "assistant", "content": "Specifies whether the index file should include an \"Index Entry\nOffset Table\" section. This reduces index load time on\nmultiprocessor machines but produces a message \"ignoring IEOT\nextension\" when reading the index using Git versions before 2.20.\nDefaults to true if index.threads has been explicitly enabled, false otherwise."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects %cl"}, {"role": "assistant", "content": "committer email local-part (the part before the @ sign)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker --bare"}, {"role": "assistant", "content": "Treat the repository as a bare repository. If GIT_DIR\nenvironment is not set, it is set to the current working\ndirectory."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to modify a pull request on GitHub to change target branch to merge into?\nI have a pull request that is requesting a merge into master from my branch, but the owner wants me to change the request to merge into a different branch from my branch.\nIs this possible? What are the possible solutions?"}, {"role": "assistant", "content": "Update August 2016: Change the base branch of a Pull Request finally allows for changing that branch.\n(And this closes issue 18, which was 3 years old and had 1500+ comments)\n\nAfter you’ve created a pull request, you can modify the base branch so that the changes in the pull request are compared against a different branch.\n\n\nAs noted in the comments byspazm:\n\nIt is (and was) working.\nChanging target branch is not enabled while the PR is closed.\nSolution was to \"reopen\" the PR (meaning by using the option in the UI) and then change the target branch\n\n\nOriginal answer:\nSince a PR cannot be edited in term of branch (see below), the easiest way would be to:\n\ncreate a local new branch on top of your current branch\npush that new branch\nmake a new PR with the right destination.\nclose the previous PR\nreference the \"old\" pull request from the new one; eg. Supersedes #123 (as commented below by Rivera)\n\n\n(original answer, valid only when creating the PR)\nYou could try and chose another base branch, as in \"Changing the branch range and destination repository\" (Clicking on the Edit button at the top of a PR page)\n\n\nThe easiest way of thinking about the branch range is this:\n\nthe base branch is where you think changes should be applied,\nthe head branch is what you would like to be applied.\n\nChanging the base repository changes who is notified of the pull request.\nEveryone that can push to the base repository will receive an email notification and see the new pull request in their dashboard the next time they sign in.\n\nIf you select as a base branch the one that the original maintainer (the owner) wants, your PR should merge from your branch (unchanged) to the new base branch."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs notes.displayRef"}, {"role": "assistant", "content": "Which ref (or refs, if a glob or specified more than once), in\naddition to the default set by core.notesRef or GIT_NOTES_REF , to read notes from when showing commit\nmessages with the git log family of commands. This setting can be overridden with the GIT_NOTES_DISPLAY_REF environment variable, which must be a colon separated list of refs or\nglobs. A warning will be issued for refs that do not exist,\nbut a glob that does not match any refs is silently ignored. This setting can be disabled by the --no-notes option to the git\nlog family of commands, or by the --notes=<ref> option accepted by\nthose commands. The effective value of \"core.notesRef\" (possibly overridden by\nGIT_NOTES_REF) is also implicitly added to the list of refs to be\ndisplayed."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-stash - Stash the changes in a dirty working directory away stash.showStat"}, {"role": "assistant", "content": "If this is set to true, the git stash show command without an\noption will show a diffstat of the stash entry. Defaults to true.\nSee the description of the show command in git-stash ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options uploadpack.allowTipSHA1InWant"}, {"role": "assistant", "content": "When uploadpack.hideRefs is in effect, allow upload-pack to accept a fetch request that asks for an object at the tip\nof a hidden ref (by default, such a request is rejected).\nSee also uploadpack.hideRefs . Even if this is false, a client\nmay be able to steal objects via the techniques described in the\n\"SECURITY\" section of the gitnamespaces man page; it’s\nbest to keep private data in a separate repository."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Workflow is not shown so I cannot run it manually (Github Actions)\n\nI created the workflow Test but there is no Run workflow button to run it manually.\n\nThis is my test.yml file. Is there anything missing?\nname: Test\n\non:\n release:\n types: [created]\n \njobs:\n build:\n runs-on: ubuntu-latest\n\n steps:\n - uses: actions/checkout@v2\n\n - name: Run a one-line script\n run: echo Hello, world!"}, {"role": "assistant", "content": "Some workflows, such as those, based on workflow_dispatch event, the workflow will not even show until the code is on the main (or default branch).\nThe good news is, once you do merge your feature to main, you may keep on working on the feature branch. From then on, you will have the option to choose which branch you want to run the workflow on , like in the picture."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Deploy every build to a server using Gitlab CI\n\nI've set up my own Gitlab server with one project and a Gitlab runner configured for it. I'm new to continuous integration server and therefore don't know how to accomplish the following.\nEvery time I commit to the master branch of my project I would like to deploy the repository to another server and run two shell-commands there (npm installand forever restartall)\nHow would I do this? Do I need a runner on the machine which the project is deployed to as well?"}, {"role": "assistant", "content": "You could use gitlab-ci and gitlab-runner [runners.ssh] to deploy to single or mutiple servers.\nthe flow: \n(git_project with yml file) --> (gitlab && gitlab-ci) --> (gitlabrunner) ---runners.ssh---> (deployed_server,[deploye_server2])\n\n\nyou need register gitlab-runner to gitlab-ci and set the tag to delpoyServer on gitlab web .\n/etc/gitlab-runner/config.toml:\n [[runners]]\n url = \"http://your.gitlab.server/ci\"\n token = \"1ba879596cf3ff778ee744e6decedd\"\n name = \"deployServer1\"\n limit = 1\n executor = \"ssh\"\n builds_dir = \"/data/git_build\"\n [runners.ssh]\n user = \"you_user_name\"\n host = \"${the_destionation_of_deployServer_IP1}\"\n port = \"22\"\n identity_file = \"/home/you_user_name/.ssh/id_rsa\"\n\n\n[[runners]]\n url = \"http://your.gitlab.server/ci\"\n token = \"1ba879596cf3ff778ee744e6decedd\"\n name = \"deployServer2\"\n limit = 1\n executor = \"ssh\"\n builds_dir = \"/data/git_build\"\n [runners.ssh]\n user = \"you_user_name\"\n host = \"${the_destionation_of_deployServer_IP2}\"\n port = \"22\"\n identity_file = \"/home/you_user_name/.ssh/id_rsa\"\n\n\nthe runner.ssh means, the runner will login into ${the_destionation_of_deployServer_IP1} and ${the_destionation_of_deployServer_IP2}, then clone the project to builds_dir.\n\nwrite the yml file\nfor example:\n.gitlab-ci.yml\njob_deploy:\n stage: deploy\n tags: delpoyServer1\n script:\n - npm install && forever restartall\njob_deploy:\n stage: deploy\n tags: delpoyServer2\n script:\n - npm install && forever restartall\n\nset the your gitlab-runner to delpoyServer1 and delpoyServer2tags in 'http://your.gitlab.server/ci/admin/runners'\n\nwhen you push you code to gitlab\nthe gitlab-ci server will parser your .gitlab-ci.yml file in your project, choose a runner with the tags: deployServer1 or deployServer2; \nthe gitlab-runnerwith the deployServer1 tag will login into ${the_destionation_of_deployServer_IP1} and ${the_destionation_of_deployServer_IP2} with ssh , clone the project to builds_dir, then execute you script: npm install && forever restartall.\n\n\nlink: \n\ngitlab-runner register\nrunners.ssh"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Generating a GPG key for git tagging\nI'm trying to create signed tags in GitHub using the git command line. I generated a GPG key with a (sample) username Full Name (skytreader) <[email protected]>. Having done that, I try to create a signed tag. However I get the following error:\ngpg: skipped \"full <[email protected]>\": secret key not available\ngpg: signing failed: secret key not available\nerror: gpg failed to sign the data\nerror: unable to sign the tag\n\nI figure that I just need to create another key with the indicated username. But then, entering the name \"full\", gpg complains that my name should be at least 5 characters long.\nHow do I use this key with git?\nDo I change the username git uses for signing my tags with GPG so that I get a real name at least 5 chars long?"}, {"role": "assistant", "content": "First you need check if there is a gpg key for your ID.\n$ gpg --list-key\n\nIf you have should appear something like this:\n\n\npub 2048R/6AB3587A 2013-05-23\nuid xxx (gpg for xxx) \nsub 2048R/64CB327A 2013-05-23\n\n\nIf there is no gpg key. You should create\n$ gpg --gen-key\n\nNext you have this output:\n\ngpg (GnuPG) 2.0.14; Copyright (C) 2009 Free Software Foundation, Inc.\n This is free software: you are free to change and redistribute it.\n There is NO WARRANTY, to the extent permitted by law.\nPlease select what kind of key you want:\n\n(1) RSA and RSA (default) \n(2) DSA and Elgamal\n(3) DSA (sign only)\n(4) RSA (sign only)\n\nYour selection? RSA keys may be between 1024 and 4096 bits long. What keysize do you want? (2048)\n Requested keysize is 2048 bits\n Please\n specify how long the key should be valid.\n 0 = key does not expire\n <n> = key expires in n days\n <n>w = key expires in n weeks\n <n>m = key expires in n months\n <n>y = key expires in n years\n\nKey is valid for? (0)\n Key does not expire at all\n Is this correct? (y/N) y \nGnuPG needs to construct a user ID to identify your key.\n\nReal name: xxx\nEmail address: [email protected]\nComment: gpg for xxx\n\nYou selected this USER-ID:\n \"xxx(gpg for xxx) <[email protected]>\"\n\nChange (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O\nYou need a Passphrase to protect your secret key.\n\ncan't connect to `/xxx/.gnupg/S.gpg-agent': No such file or directory\nWe need to generate a lot of random bytes. It is a good idea to perform\nsome other action (type on the keyboard, move the mouse, utilize the\ndisks) during the prime generation; this gives the random number\ngenerator a better chance to gain enough entropy."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Rebase feature branch onto another feature branch\nI have two (private) feature branches that I'm working on.\na -- b -- c <-- Master\n \\ \\\n \\ d -- e <-- Branch1\n \\\n f -- g <-- Branch2\n\nAfter working on these branches a little while I've discovered that I need the changes from Branch2 in Branch1. I'd like to rebase the changes in Branch2 onto Branch1. I'd like to end up with the following:\na -- b -- c <-- Master\n \\\n d -- e -- f -- g <-- Branch1\n\nI'm pretty sure I need to rebase the second branch onto the first, but I'm not entirely sure about the correct syntax and which branch I should have checked out.\nWill this command produce the desired result?\n(Branch1)$ git rebase --onto Branch1 Branch2"}, {"role": "assistant", "content": "Switch to Branch2\ngit checkout Branch2\n\nApply the current (Branch2) changes on top of the Branch1 changes, staying \nin Branch2:\ngit rebase Branch1\n\n\nWhich would leave you with the desired result in Branch2: \na -- b -- c <-- Master\n \\\n d -- e <-- Branch1\n \\\n d -- e -- f' -- g' <-- Branch2\n\nYou can delete Branch1."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to exclude git branch from building in Jenkins\nHere is my current Jenkins setup for a project: \n\none job runs all development branches\none job runs all pull requests\none job runs only the master branch\none job makes the automated release only when master passes\n\nThis setup allows me to have continuous automated delivery as well as constant feedback during development. The first 3 jobs also run all tests and coverage reports. \nThe problem is that I could not find a way to exclude the master branch from the \"all development branches\" job. It unnecessarily builds master twice every time I merge a pull-request.\nDoes anybody know how to exclude one branch from the job in Jenkins ?\nps: I am using the Git and the Github plugins. My project is stored on Github."}, {"role": "assistant", "content": "You can choose \"Inverse\" strategy for targeting branches to build.\nCheck out Jenkins job configuration,\n\n\"Source Code Management\" section (choose \"Git\")\nAdditional Behaviours\nclick \"Add\" button\nchoose \"Strategy for choosing what to build\"\nselect \"Inverse\" strategy in combo box.\n\n(Don't forget to fill in \"Branches to build\" text field by \"master\")\nSee also attachment screenshot image:"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why is Github asking for username/password when following the instructions on screen and pushing a new repo?\nI'm the owner of an organization on github and just created a repo and tried pushing but I'm running into an issue where it's asking me for my username even though I can SSH just fine:\n$ ssh -T [email protected]\nHi Celc! You've successfully authenticated, but GitHub does not provide shell access.\n$ git add .\n$ git commit -m 'first commit'\n[master (root-commit) 3f1b963] first commit\n 6 files changed, 59 insertions(+)\n create mode 100644 .gitignore\n create mode 100644 main.js\n create mode 100644 package.json\n create mode 100644 readme.markdown\n create mode 100644 views/index.ejs\n create mode 100644 views/layout.ejs\n$ git remote add origin https://github.com/WEMP/project-slideshow.git\n$ git push -u origin master\nUsername for 'https://github.com':\n\nWhat am I doing wrong? This has never happened to me before but I recently also upgraded to git 1.7.10.3."}, {"role": "assistant", "content": "Don't use HTTP use SSH instead\nchange \nhttps://github.com/WEMP/project-slideshow.git \n\nto \n[email protected]:WEMP/project-slideshow.git\n\nyou can do it in .git/config file"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_TRACE_CURL"}, {"role": "assistant", "content": "Enables a curl full trace dump of all incoming and outgoing data,\nincluding descriptive information, of the git transport protocol.\nThis is similar to doing curl --trace-ascii on the command line.\nSee GIT_TRACE for available trace output options."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to merge the current branch into another branch\nI have two branches, master and dev. I always work on dev and only check code into the master branch once it's been approved for production use. When I do so, I have to do the following:\ngit checkout master\ngit merge dev\ngit checkout dev\n\nThat's awfully verbose, and since I do it frequently, I'd like to minimize it. Is there any one git command I can use to merge from my current branch dev to the other branch master without having to checkout the master branch first? Something maybe like:\ngit merge dev to master\n\nwould be awesome. I looked through the git documentation and didn't see anything."}, {"role": "assistant", "content": "1. Add a remote alias for your local repository, ex:\ngit remote add self file:///path/to/your/repository\n\n(Or on windows git remote add self C:\\path\\to\\your\\repository)\n2. Push to the self remote, ex:\ngit push self dev:master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch patience"}, {"role": "assistant", "content": "Deprecated synonym for diff-algorithm=patience ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Broken branch in git, fatal: your current branch appears to be broken\nHere is my case:\n\nI was working on one branch.\nPushed new commits to the remote.\nSwitched back to the master branch. \n\nBut suddenly after typing git checkout master command my computer encountered blue screen of death and an unexpected force shut down happened. After starting back my computer I have checked the status of my current branch and as a result I got each and every file as marked new files.\nNow, I am stuck at this point and after git log command I am getting error \n$ git log\nfatal: your current branch appears to be broken\n\nHow to solve this problem and recover my branch?.\nI am working with windows 7 and git bash latest version\n\nEdit: I don't want to delete this branch."}, {"role": "assistant", "content": "I meet similar issue on Windows 7. In my case,the current branch file (refer by ./git/HEAD) under \\.git\\refs\\heads was broken. \nI found the hash code of broken current branch on .git\\logs\\refs\\heads with same branch name. \nAnd I fixed the issue by opening that file (.git\\logs\\refs\\heads\\xxx) via notepad and copy the 4th number (the hash code) to (.git\\refs\\heads\\xxx)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-apply - Apply a patch to files and/or to the index -R --reverse"}, {"role": "assistant", "content": "Apply the patch in reverse."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "diff returning entire file for identical files\nI've got a website that has a git repo. I cloned the repo so that I could develop in one directory and then push to the repo, and then pull in the live/prod directory (would be interested in suggestions for a better way to do this if there is one, but that's outside the scope of this question).\nI did the following in the live directory to push all my latest changes:\ngit add .\ngit commit -a // added a message\ngit push\n\nI then did the following in the dev directory:\ngit clone [email protected]:user/repo.git\n\nI then opened two files, prod/root/test.php and dev/root/test.php, and they looked identical. However, when I did the following diff command, it outputted the entire file:\ndiff prod/root/test.php dev/root/test.php\n\nI am so confused as to why diff would output the entire file if they're identical... I also tried googling this and can't find anyone else with this problem. Maybe it's a line endings issue or a character encoding issue where they look the same but they are actually different and git/bitbucket converts it when you push to their repo? That's the only thing I can think of... Either that or I'm missing something really obvious.\nHere's the output:\n1,3c1,3\n< <?\n< echo '<p>Hello world!</p>';\n< ?>\n---\n> <?\n> echo '<p>Hello world!</p>';\n> ?>"}, {"role": "assistant", "content": "This seems like a whitespace issue, in order to avoid them in the future, you can setup Git to normalize them.\nWindows and UNIX system don't use same line-ending, to prevent conflict from happening based on these, you should setup you git config this way:\n\nWindows : git config --global core.autocrlf true\nUnix : git config --global core.autocrlf input\n\nNext, to make sure we only commit with ideal whitespace rules, you can set this config option:\ngit config --global core.whitespace trailing-space,space-before-tab,indent-with-non-tab"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options $GIT_DIR/config"}, {"role": "assistant", "content": "Repository specific configuration file."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-cat-file - Provide contents or details of repository objects"}, {"role": "assistant", "content": "CAVEATS Note that the sizes of objects on disk are reported accurately, but care\nshould be taken in drawing conclusions about which refs or objects are\nresponsible for disk usage. The size of a packed non-delta object may be\nmuch larger than the size of objects which delta against it, but the\nchoice of which object is the base and which is the delta is arbitrary\nand is subject to change during a repack. Note also that multiple copies of an object may be present in the object\ndatabase; in this case, it is undefined which copy’s size or delta base\nwill be reported."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git master branch has no upstream branch\nI'm trying to push one of my projects to github, and I keep getting this error:\nfatal: The current branch master has no upstream branch.\n\nI've never seen this before. I re-initialized my git, re-added my origin, deleted and re-made the repo, and recreated my SSH key."}, {"role": "assistant", "content": "Instead of creating a new repository on Github, cloning that, or reinitializing your local repository, the following command would have been sufficient:\ngit push -u origin master\n\norigin stands for the remote name (default is origin),\nmaster is the branch you want to push, in your case it's master, otherwise you would have to change that in the command.\n-u means, that your local branch will be setup to track the new created master branch on the origin repository (the master on the origin will be the upstream branch of your local branch). If the branch master doesn't exist on the remote repository, it will be created, otherwise it will be updated (the -u works no matter if it exists or not)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Change a Git remote HEAD to point to something besides master\nHow do I set a Git remote's HEAD reference to point to something besides \"master\"?\nMy project has a policy not to use a \"master\" branch (all branches are to have meaningful names). Furthermore, the canonical master repository is only accessible via ssh://, with no shell access (like GitHub or Unfuddle).\nMy problem is that the remote repository still has a HEAD reference to refs/heads/master, but I need it to point to a different branch. This is causing two problems:\n\nWhen cloning the repo, there this, \n\nwarning: remote HEAD refers to nonexistent ref, unable to checkout.\n\nThat's confusing and inconvenient.\nThe web-based code browser depends on HEAD as a basis for browsing the tree. I need HEAD to point to a valid branch, then."}, {"role": "assistant", "content": "There was almost the same question on GitHub a year ago.\nThe idea was to rename the master branch:\ngit branch -m master development\ngit branch -m published master\ngit push -f origin master \n\n\nMaking master have what you want people to use, and do all other work in branches.\n\n(a \"git-symbolic-ref HEAD refs/head/published\" would not be propagated to the remote repo)\nThis is similar to \"How do I delete origin/master in Git\".\n\nAs said in this thread: (emphasis mine)\n\n\"git clone\" creates only a single local branch.\nTo do that, it looks at the HEAD ref of the remote repo, and creates a local branch with the same name as the remote branch referenced by it.\nSo to wrap that up, you have repo A and clone it:\n\nHEAD references refs/heads/master and that exists\n-> you get a local branch called master, starting from origin/master\n\nHEAD references refs/heads/anotherBranch and that exists\n-> you get a local branch called anotherBranch, starting from origin/anotherBranch\n\nHEAD references refs/heads/master and that doesn't exist\n-> \"git clone\" complains\n\n\nNot sure if there's any way to directly modify the HEAD ref in a repo.\n\n(which is all besides the point of your question, I know ;) )\n\nMaybe the only way would be a \"publication for the poor\", where you:\n $ git-symbolic-ref HEAD refs/head/published\n $ git-update-server-info\n $ rsync -az .git/* server:/local_path_to/git/myRepo.git/\n\nBut that would involve write access to the server, which is not always possible.\n\nAs I explain in \"Git: Correct way to change Active Branch in a bare repository?\", git remote set-head wouldn't change anything on the remote repo.\nIt would only change the remote tracking branch stored locally in your local repo, in remotes/<name>/HEAD.\n\nWith Git 2.29 (Q4 2020), \"git remote set-head(man)\" that failed still said something that hints the operation went through, which was misleading.\nSee commit 5a07c6c (17 Sep 2020) by Christian Schlack (cschlack).\n(Merged by Junio C Hamano -- gitster -- in commit 39149df, 22 Sep 2020)\n\nremote: don't show success message when set-head fails\nSigned-off-by: Christian Schlack\n\n\nSuppress the message 'origin/HEAD set to master' in case of an error.\n$ git remote set-head origin -a\nerror: Not a valid ref: refs/remotes/origin/master\norigin/HEAD set to master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc plain"}, {"role": "assistant", "content": "Any line that is added in one location and was removed\nin another location will be colored with color.diff.newMoved .\nSimilarly color.diff.oldMoved will be used for removed lines\nthat are added somewhere else in the diff. This mode picks up any\nmoved line, but it is not very useful in a review to determine\nif a block of code was moved without permutation."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-add - Add file contents to the index -n --dry-run"}, {"role": "assistant", "content": "Don’t actually add the file(s), just show if they exist and/or will\nbe ignored."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc cumulative"}, {"role": "assistant", "content": "Count changes in a child directory for the parent directory as well.\nNote that when using cumulative , the sum of the percentages\nreported may exceed 100%. The default (non-cumulative) behavior can\nbe specified with the noncumulative parameter."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs git log v2.6.12.. include/scsi drivers/scsi"}, {"role": "assistant", "content": "Show all commits since version v2.6.12 that changed any file\nin the include/scsi or drivers/scsi subdirectories"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-merge - Join two or more development histories together --overwrite-ignore --no-overwrite-ignore"}, {"role": "assistant", "content": "Silently overwrite ignored files from the merge result. This\nis the default behavior. Use --no-overwrite-ignore to abort."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Trigger a GitHub Action when another repository creates a new release\n\nI'm trying to build a GitHub workflow that will be triggered when another repository creates a new release.\nIn the documentation, there is the paragraph: on.event_name.types where event_name will be release.\nThe question is: Is there any way to refer to the release event of another repository?"}, {"role": "assistant", "content": "Is there any way to refer to the release event of another repository?\n\nFairly sure this feature does not exist.\nIf you have have access to the repository creating the release then you could call a webhook event to trigger an on: repository_dispatch workflow to run in another repository. repository-dispatch action can help in this case.\nIf you don't have access to the repository creating the release (which I assume is the case here) then this would be my suggestion. First, create the following workflow that periodically checks the release version tag of the repository you want to track. If it differs from the release version you currently have saved in your repository then the new version will be committed.\nNote that you must prepare the destination file first (e.g. release-versions/swagger-ui-latest.txt) for the the modified files check to work.\nFurther, you must use a repo scoped token instead of the default GITHUB_TOKEN. For more detail about that see Push to origin from GitHub action\nname: Get latest release version\non:\n schedule:\n - cron: '0 10 * * *'\njobs:\n get-version:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v2\n with:\n token: ${{ secrets.REPO_SCOPED_TOKEN }}\n - name: Fetch release version\n run: |\n curl -sL https://api.github.com/repos/swagger-api/swagger-ui/releases/latest | \\\n jq -r \".tag_name\" > release-versions/swagger-ui-latest.txt\n - name: Check for modified files\n id: git-check\n run: echo ::set-output name=modified::$([ -z \"`git status --porcelain`\" ] && echo \"false\" || echo \"true\")\n - name: Commit latest release version\n if: steps.git-check.outputs.modified == 'true'\n run: |\n git config --global user.name 'Your Name'\n git config --global user.email '[email protected]'\n git commit -am \"New release version\"\n git push\n\nThen you can create a second workflow that only runs when it sees any changes to the directory release-versions.\non:\n push:\n paths:\n - 'release-versions/*'\n\nIn this workflow you can use the saved version to fetch the assets you need and do whatever processing you need to.\nHere is a similar example that raises a pull request instead of committing immediately."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fast-import - Backend for fast Git data importers --active-branches=<n>"}, {"role": "assistant", "content": "Maximum number of branches to maintain active at once.\nSee “Memory Utilization” below for details. Default is 5."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects --no-prefix"}, {"role": "assistant", "content": "Do not show any source or destination prefix."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --find-copies-harder"}, {"role": "assistant", "content": "For performance reasons, by default, -C option finds copies only\nif the original file of the copy was modified in the same\nchangeset. This flag makes the command\ninspect unmodified files as candidates for the source of\ncopy. This is a very expensive operation for large\nprojects, so use it with caution. Giving more than one -C option has the same effect."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "fatal: unable to access 'https://github.com/xxx': OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\n\nGetting Git to work with a proxy server - fails with \"Request timed out\"\n\n (22 answers)\n \n\nClosed 2 years ago.\n\n\n\nWhen l try to use git push, an error reports: \n\nFatal: fatal: unable to access 'https://github.com/xxx': OpenSSL\n SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443\n\nMy git version is 2.16.2 for windows\nIt worked well before this day, and reinstalling git seems to not work.\nCan anyone help me with that? Thanks in advance!"}, {"role": "assistant", "content": "If you are behind a proxy, try the following:\ngit config --global --add remote.origin.proxy \"\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-for-each-ref - Output information on each ref signature"}, {"role": "assistant", "content": "The GPG signature of a commit."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I restart bundle nginx in gitlab separately?\n\nI have installed Gitlab CE version. I can find nginx bundled in Gitlab. However I cannot find a way to restart nginx separately. I have tried sudo service nginx restart but it gives:\n* Restarting nginx nginx [fail] \n\nI have checked all the document but cannot find a solution. I am trying to add vhost to the bundled nginx according to this tutorial. But I stuck at that step. Is there other way to add vhost to bundled nginx with Gitlab? Or How can I check whether my nginx conf work?\nEdit: 502 error I have solved.\nI try to use NON-bundle nginx according to this doc , But after I modify gitlab.rb and run sudo gitlab-ctl reconfigure , I got 502 Whoops, GitLab is taking too much time to respond. error. \nHere is my gitlab.conf for nginx.\nupstream gitlab {\n server unix://var/opt/gitlab/gitlab-git-http-server/sockets/gitlab.socket fail_timeout=0;\n #\n}\n\nserver {\n listen *:80;\n server_name blcu.tk;\n server_tokens off;\n root /opt/gitlab/embedded/service/gitlab-rails/public;\n\n client_max_body_size 250m;\n\n access_log /var/log/gitlab/nginx/gitlab_access.log;\n error_log /var/log/gitlab/nginx/gitlab_error.log;\n\n\n# Ensure Passenger uses the bundled Ruby version\npassenger_ruby /opt/gitlab/embedded/bin/ruby;\n\n# Correct the $PATH variable to included packaged executables\npassenger_env_var PATH \"/opt/gitlab/bin:/opt/gitlab/embedded/bin:/usr/local/bin:/usr/bin:/bin\";\n\n# Make sure Passenger runs as the correct user and group to\n# prevent permission issues\npassenger_user git;\npassenger_group git;\n\n# Enable Passenger & keep at least one instance running at all times\npassenger_enabled on;\npassenger_min_instances 1;\n\nlocation / {\n try_files $uri $uri/index.html $uri.html @gitlab;\n}\n\n location @gitlab {\n # If you use https make sure you disable gzip compression \n # to be safe against BREACH attack\n\n proxy_read_timeout 300; # Some requests take more than 30 seconds.\n proxy_connect_timeout 300; # Some requests take more than 30 seconds.\n proxy_redirect off;\n\n proxy_set_header X-Forwarded-Proto $scheme;\n proxy_set_header Host $http_host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Frame-Options SAMEORIGIN;\n\n proxy_pass http://gitlab;\n }\n location ~ ^/(assets)/ {\n root /opt/gitlab/embedded/service/gitlab-rails/public;\n # gzip_static on; # to serve pre-gzipped version\n expires max;\n add_header Cache-Control public;\n }\n\n\n error_page 502 /502.html;\n}"}, {"role": "assistant", "content": "To restart only one component of GitLab Omnibus you can execute sudo gitlab-ctl restart <component>. Therefore, to restart Nginx:\nsudo gitlab-ctl restart nginx\nAs a further note, this same concept is possible with nearly all of the gitlab-ctl commands. For example, sudo gitlab-ctl tail allows you to see all GitLab logs. Applying this concept, sudo gitlab-ctl tail nginx will tail only Nginx logs."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff-index - Compare a tree to the working tree or index blocks"}, {"role": "assistant", "content": "Blocks of moved text of at least 20 alphanumeric characters\nare detected greedily. The detected blocks are\npainted using either the color.diff.{old,new}Moved color.\nAdjacent blocks cannot be told apart."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git gc --aggressive vs git repack\n\nI want to reduce the size of a Git repository. I have discovered:\n\ngit gc --aggressive. But some people discourage its use. Why? What's wrong with it?\n\ngit repack -a -d --depth=250 --window=250. Some say to use this instead. Why? How does this reduce the size of a repository? What are --depth and --window for?\n\n\nWhat should I choose: gc or repack?"}, {"role": "assistant", "content": "Nowadays there is no difference: git gc --aggressive operates according to the suggestion Linus made in 2007; see below. As of version 2.11 (Q4 2016), git defaults to a depth of 50. A window of size 250 is good because it scans a larger section of each object, but depth at 250 is bad because it makes every chain refer to very deep old objects, which slows down all future git operations for marginally lower disk usage.\n\nHistorical Background\nLinus suggested (see below for the full mailing list post) using git gc --aggressive only when you have, in his words, “a really bad pack” or “really horribly bad deltas,” however “almost always, in other cases, it’s actually a really bad thing to do.” The result may even leave your repository in worse condition than when you started!\nThe command he suggests for doing this properly after having imported “a long and involved history” is\ngit repack -a -d -f --depth=250 --window=250\n\nBut this assumes you have already removed unwanted gunk from your repository history and that you have followed the checklist for shrinking a repository found in the git filter-branch documentation.\n\ngit-filter-branch can be used to get rid of a subset of files, usually with some combination of --index-filter and --subdirectory-filter. People expect the resulting repository to be smaller than the original, but you need a few more steps to actually make it smaller, because Git tries hard not to lose your objects until you tell it to. First make sure that:\n\nYou really removed all variants of a filename, if a blob was moved over its lifetime. git log --name-only --follow --all -- filename can help you find renames.\nYou really filtered all refs: use --tag-name-filter cat -- --all when calling git filter-branch.\n\nThen there are two ways to get a smaller repository. A safer way is to clone, that keeps your original intact.\n\nClone it with git clone file:///path/to/repo. The clone will not have the removed objects. See git-clone. (Note that cloning with a plain path just hardlinks everything!)\n\nIf you really don’t want to clone it, for whatever reasons, check the following points instead (in this order). This is a very destructive approach, so make a backup or go back to cloning it. You have been warned.\n\nRemove the original refs backed up by git-filter-branch: say\ngit for-each-ref --format=\"%(refname)\" refs/original/ |\n xargs -n 1 git update-ref -d\n\nExpire all reflogs with git reflog expire --expire=now --all.\nGarbage collect all unreferenced objects with git gc --prune=now (or if your git gc is not new enough to support arguments to --prune, use git repack -ad; git prune instead).\n\n\n\n\nDate: Wed, 5 Dec 2007 22:09:12 -0800 (PST)\nFrom: Linus Torvalds <torvalds at linux-foundation dot org>\nTo: Daniel Berlin <dberlin at dberlin dot org>\ncc: David Miller <davem at davemloft dot net>,\n ismail at pardus dot org dot tr,\n gcc at gcc dot gnu dot org,\n git at vger dot kernel dot org\nSubject: Re: Git and GCC\nIn-Reply-To: <[email protected]>\nMessage-ID: <[email protected]>\nReferences: <[email protected]>\n <[email protected]>\n <[email protected]>\n <[email protected]>\n <[email protected]>\n\nOn Thu, 6 Dec 2007, Daniel Berlin wrote:\n\nActually, it turns out that git-gc --aggressive does this dumb thing\n to pack files sometimes regardless of whether you converted from an\n SVN repo or not.\n\nAbsolutely. git --aggressive is mostly dumb. It’s really only useful for\n the case of “I know I have a really bad pack, and I want to throw away\n all the bad packing decisions I have done.”\nTo explain this, it’s worth explaining (you are probably aware of it, but\n let me go through the basics anyway) how git delta-chains work, and how\n they are so different from most other systems.\nIn other SCMs, a delta-chain is generally fixed. It might be “forwards”\n or “backwards,” and it might evolve a bit as you work with the repository,\n but generally it’s a chain of changes to a single file represented as some\n kind of single SCM entity. In CVS, it’s obviously the *,v file, and a lot\n of other systems do rather similar things.\nGit also does delta-chains, but it does them a lot more “loosely.” There\n is no fixed entity. Deltas are generated against any random other version\n that git deems to be a good delta candidate (with various fairly\n successful heuristics), and there are absolutely no hard grouping rules.\nThis is generally a very good thing. It’s good for various conceptual\n reasons (i.e., git internally never really even needs to care about the whole\n revision chain — it doesn’t really think in terms of deltas at all), but\n it’s also great because getting rid of the inflexible delta rules means\n that git doesn’t have any problems at all with merging two files together,\n for example — there simply are no arbitrary *,v “revision files” that have\n some hidden meaning.\nIt also means that the choice of deltas is a much more open-ended\n question. If you limit the delta chain to just one file, you really don’t\n have a lot of choices on what to do about deltas, but in git, it really\n can be a totally different issue.\nAnd this is where the really badly named --aggressive comes in. While\n git generally tries to re-use delta information (because it’s a good idea,\n and it doesn’t waste CPU time re-finding all the good deltas we found\n earlier), sometimes you want to say “let’s start all over, with a blank\n slate, and ignore all the previous delta information, and try to generate\n a new set of deltas.”\nSo --aggressive is not really about being aggressive, but about wasting\n CPU time re-doing a decision we already did earlier!\nSometimes that is a good thing. Some import tools in particular could\n generate really horribly bad deltas. Anything that uses git fast-import,\n for example, likely doesn’t have much of a great delta layout, so it might\n be worth saying “I want to start from a clean slate.”\nBut almost always, in other cases, it’s actually a really bad thing to do.\n It’s going to waste CPU time, and especially if you had actually done a\n good job at deltaing earlier, the end result isn’t going to re-use all\n those good deltas you already found, so you’ll actually end up with a\n much worse end result too!\nI’ll send a patch to Junio to just remove the git gc --aggressive\n documentation. It can be useful, but it generally is useful only when you\n really understand at a very deep level what it’s doing, and that\n documentation doesn’t help you do that.\nGenerally, doing incremental git gc is the right approach, and better\n than doing git gc --aggressive. It’s going to re-use old deltas, and\n when those old deltas can’t be found (the reason for doing incremental GC\n in the first place!) it’s going to create new ones.\nOn the other hand, it’s definitely true that an “initial import of a long\n and involved history” is a point where it can be worth spending a lot of\n time finding the really good deltas. Then, every user ever after (as\n long as they don’t use git gc --aggressive to undo it!) will get the\n advantage of that one-time event. So especially for big projects with a\n long history, it’s probably worth doing some extra work, telling the delta\n finding code to go wild.\nSo the equivalent of git gc --aggressive — but done properly — is to\n do (overnight) something like\ngit repack -a -d --depth=250 --window=250\n\nwhere that depth thing is just about how deep the delta chains can be\n (make them longer for old history — it’s worth the space overhead), and\n the window thing is about how big an object window we want each delta\n candidate to scan.\nAnd here, you might well want to add the -f flag (which is the “drop all\n old deltas,” since you now are actually trying to make sure that this one\n actually finds good candidates.\nAnd then it’s going to take forever and a day (i.e., a “do it overnight”\n thing). But the end result is that everybody downstream from that\n repository will get much better packs, without having to spend any effort\n on it themselves.\n Linus"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-check-ignore - Debug gitignore / exclude files -n, --non-matching"}, {"role": "assistant", "content": "Show given paths which don’t match any pattern. This only\nmakes sense when --verbose is enabled, otherwise it would\nnot be possible to distinguish between paths which match a\npattern and those which don’t."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "restoring git repository from bundle backup\ni created backups of my git repository like in How to backup a local Git repository? proposed\nwith\ngit bundle create /tmp/foo-all --all\n\nI can see all refs are in there, including a remote ref created by git-svn.\nNow I can't figure out how to restore this bundle to a local repository again.\nI am quite quite sure i've done it already once. I tried git-clone but that gives me a just a repository with my backup bundle as remote repo. \nI also tried\ngit init\ngit bundle unbundle /tmp/foo --all \n\nbut this just lists all references...\nVerifying the bundle gives:\n$ git bundle verify $somewhere/foo.bundle \nThe bundle contains 12 refs\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/master\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/remotes/git-svn\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx HEAD\nThe bundle requires these 0 ref\n$somewhere/foo.bundle is okay"}, {"role": "assistant", "content": "Short answer:\n$ git bundle verify $somewhere/foo.bundle\n$ git clone $somewhere/foo.bundle\nCloning into 'foo'...\nReceiving objects: 100% (10133/10133), 82.03 MiB | 74.25 MiB/s, done.\nResolving deltas: 100% (5436/5436), done.\n$ cd foo\n$ git status\n...\n\nLazy Badger said this, but it's in the last paragraph. :)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "fatal: does not appear to be a git repository\nWhy am I getting this error when my Git repository URL is correct?\nfatal: '[email protected]/gittest.git' does not appear to be a git repository\nfatal: The remote end hung up unexpectedly\n\nSee it in context below, or as a screenshot.\njitendra@JITENDRA-PC /c/mySite (master)\n$ git push beanstalk master\nfatal: '[email protected]/gittest.git' does not appear to be a git repository\nfatal: The remote end hung up unexpectedly\n\njitendra@JITENDRA-PC /c/mySite (master)\n$ git clone git://github.com/jquery/jquery.git\nCloning into jquery...\nRemote: Counting objects: 19803, done.\nRemote: Compressing objects: 100% (5196/5196), done.\nRemote: Total 19803 (delta 14204), reused 19549 (delta 14052)\nReceiving objects: 100% (19803/19803), 12.80 MiB | 591 KiB/s, done.\nResolving deltas: 100% (14204/14204), done.\n\njitendra@JITENDRA-PC /c/mySite (master)\n$ gitk --all\n\njitendra@JITENDRA-PC /c/mySite (master)\n$ gitk -all\n\njitendra@JITENDRA-PC /c/mySite (master)\n$ git remote add origin [email protected]/gittest.git\n\njitendra@JITENDRA-PC /c/mySite (master)\n$ git push origin master\nfatal: '[email protected]/gittest.git' does not appear to be a git repository\nfatal: The remote end hung up unexpectedly\n\njitendra@JITENDRA-PC /c/mySite (master)"}, {"role": "assistant", "content": "You've got the syntax for the scp-style way of specifying a repository slightly wrong - it has to be:\n[user@]host.xz:path/to/repo.git/\n\n... as you can see in the git clone documentation. You should use instead the URL:\n[email protected]:/gittest.git\n\ni.e. in the URL you're using, you missed out the : (colon)\nTo update the URL for origin you could do:\ngit remote set-url origin [email protected]:/gittest.git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-parse - Pick out and massage parameters <rev1>..<rev2>"}, {"role": "assistant", "content": "Include commits that are reachable from <rev2> but exclude\nthose that are reachable from <rev1>. When either <rev1> or\n<rev2> is omitted, it defaults to HEAD ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options merge.branchdesc"}, {"role": "assistant", "content": "In addition to branch names, populate the log message with\nthe branch description text associated with them. Defaults\nto false."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Move git repo with git clone --mirror and git push --mirror\n\nI have to move a couple of repos from Gitlab to Bitbucket and discovered that the easiest way to do it seems to be:\n\nCreate new empty repository in Bitbucket\ngit clone --mirror [email protected]:path/to/repo.git\ncd repo.git\ngit remote set-url origin [email protected]:path/to/repo.git\ngit push --mirror\n\nThis seems to copy the entire repo including tags, all branches etc. and I haven't discovered any disadvantages of this method yet. However, as I haven't seen this method anywhere on the internet, I'm afraid I'm missing something.\nCan I safely use this method and remove the old repositories afterwards?"}, {"role": "assistant", "content": "From a repo-only standpoint, it should be safe. All refs (branches, tags) are copied as-is.\nAs torek mentioned in the comments, other things might be left out: configuration, hosting-specific settings, hooks."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I recover a dropped stash in Git?\nI frequently use git stash and git stash pop to save and restore changes in my working tree. Yesterday, I had some changes in my working tree that I had stashed and popped, and then I made more changes to my working tree. I'd like to go back and review yesterday's stashed changes, but git stash pop appears to remove all references to the associated commit.\nI know that if I use git stash then .git/refs/stash contains the reference of the commit used to create the stash. And .git/logs/refs/stash contains the whole stash. But those references are gone after git stash pop. I know that the commit is still in my repository somewhere, but I don't know what it was.\nIs there an easy way to recover yesterday's stash commit reference?"}, {"role": "assistant", "content": "Once you know the hash of the stash commit you dropped, you can apply it as a stash:\ngit stash apply $stash_hash\n\nOr, you can create a separate branch for it with\ngit branch recovered $stash_hash\n\nAfter that, you can do whatever you want with all the normal tools. When you’re done, just blow the branch away.\nFinding the hash\nIf you have only just popped it and the terminal is still open, you will still have the hash value printed by git stash pop on screen (thanks, Dolda).\nOtherwise, you can find it using this for Linux, Unix or Git Bash for Windows:\ngit fsck --no-reflog | awk '/dangling commit/ {print $3}'\n\n...or using PowerShell for Windows:\ngit fsck --no-reflog | select-string 'dangling commit' | foreach { $_.ToString().Split(\" \")[2] }\n\nThis will show you all the commits at the tips of your commit graph which are no longer referenced from any branch or tag – every lost commit, including every stash commit you’ve ever created, will be somewhere in that graph.\nThe easiest way to find the stash commit you want is probably to pass that list to gitk:\ngitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )\n\n...or see the answer from emragins if using PowerShell for Windows.\nThis will launch a repository browser showing you every single commit in the repository ever, regardless of whether it is reachable or not.\nYou can replace gitk there with something like git log --graph --oneline --decorate if you prefer a nice graph on the console over a separate GUI app.\nTo spot stash commits, look for commit messages of this form:\n        WIP on somebranch: commithash Some old commit message\nNote: The commit message will only be in this form (starting with \"WIP on\") if you did not supply a message when you did git stash."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-range-diff - Compare two commit ranges (e.g. two versions of a branch) --left-only"}, {"role": "assistant", "content": "Suppress commits that are missing from the first specified range\n(or the \"left range\" when using the <rev1>...<rev2> format)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to make git diff show the same result as github's pull request diff?\n\nAfter branches are merged, and GitHub no longer show difference when I try to make a pull request, but git diff will still show differences.\nFor example:\n\nI have branch D\nCreated hotfix on branch H\nMerged H to D\nCreated more stuff on D\n\nNow GitHub pull request from H to D shows no difference but git diff H D show differences.\nWhat I am trying to do is to create a command-line tool to see which old branches (there can be a lot) don't have code differences to develop. right now I have to go to GitHub, do a pull request and select each branch to see if there are difference."}, {"role": "assistant", "content": "You probably want the \"triple-dot\" syntax:\ngit diff D...H\n\nSee also What are the differences between double-dot \"..\" and triple-dot \"...\" in Git diff commit ranges?"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is github 'compare & pull request'\n\nI am working on a MeteorIntegration (feature) branch that is published. I did a git push assuming the push was going to the checked-out branch MeteorIntegration: \nAnd now I see the following on both master and MeteorIntegration branches. \n\nI read github documentation: Closing a pull request and Tidying up Pull Requests but that didn't help, possibly because I am not dealing with a pull request here?\nHow do I get rid of this compare & pull request?"}, {"role": "assistant", "content": "You don't actually have a pull request; GitHub just sees that you've pushed a branch, and is offering to create a pull request for it if you want.\nIf you don't care about that, just ignore it. It's completely harmless and will go away as soon as GitHub doesn't think the branch is \"recent\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options grep.column"}, {"role": "assistant", "content": "If set to true, enable the --column option by default."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fast-import - Backend for fast Git data importers"}, {"role": "assistant", "content": "DEVELOPMENT COST A typical frontend for fast-import tends to weigh in at approximately 200\nlines of Perl/Python/Ruby code. Most developers have been able to\ncreate working importers in just a couple of hours, even though it\nis their first exposure to fast-import, and sometimes even to Git. This is\nan ideal situation, given that most conversion tools are throw-away\n(use once, and never look back)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git rebase - what's the difference between 'edit' and 'reword'\nWhat's the difference between edit and reword when you do a git rebase?\nI'm going through some docs which say this:\nReplace pick with:\n- edit to mark a commit for amending.\n- reword to change the log message."}, {"role": "assistant", "content": "\"reword\" allows you to change ONLY the commit message, NOT the commit contents\n\"edit\" allows you to change BOTH commit contents AND commit message (the mechanism by which git allows you to edit the commit contents is by \"pausing\" the rebase; so you can amend the commit)\n\nreference :\nThe git-rebase documentation says this:\n\nedit : By replacing the command \"pick\" with the command \"edit\", you can tell git rebase to stop after applying that commit, so that you can edit the files and/or the commit message, amend the commit, and continue rebasing.\nreword : If you just want to edit the commit message for a commit, replace the command \"pick\" with the command \"reword\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to overwrite local tags with git fetch?\nHow to overwrite local tags with git fetch?\nI want to replace local tags with remote tags."}, {"role": "assistant", "content": "As of Git 2.20 you need to explicitly specify the force flag:\ngit fetch origin --tags --force\n\nUntil Git version 2.20, and unlike when pushing with git-push[1], any updates to refs/tags/* would be accepted without + in the refspec (or --force). When fetching, we promiscuously considered all tag updates from a remote to be forced fetches. Since Git version 2.20, fetching to update refs/tags/* works the same way as when pushing. I.e. any updates will be rejected without + in the refspec (or --force).\nhttps://git-scm.com/docs/git-fetch"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "github changes not staged for commit\nI have a very basic github setup with a readme, a directory, and another directory inside it with an html file. On github I can only view the readme and the first folder but none of its contents, and I am getting this message\ntc349 ryntc3$ git add *\ntc349 ryntc3$ git status\nOn branch master\nChanges not staged for commit:\n(use \"git add <file>...\" to update what will be committed)\n(use \"git checkout -- <file>...\" to discard changes in working directory)\n(commit or discard the untracked or modified content in submodules) \n\nmodified: week1 (modified content)\n\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nI feel like if I am adding all to be staged that it should not be an issue. Any help?"}, {"role": "assistant", "content": "Have you tried\ngit add .\n\nThis recurses into sub-directories, whereas I don't think * does.\nSee here"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why do I have to resolve the same \"git rebase\" conflict over and over?\nWhen I do git rebase branch1 in my branch1-local I get conflicts. I solve the conflict, do git add <conflicted-add> and then do git rebase --continue as git asks me to do. After that a new commit is applied. A new conflict shows up. But is the same conflict again in the same file. I do it again, git add, the git rebase --continue, and then it all repeats again until I repeat this for each commit being rebased on.\nWhy rebase is having me redo the same conflict resolution over and over again?"}, {"role": "assistant", "content": "What you want is git rerere which records conflict resolutions for you. The best introduction to this I have seen is now part of the Git Book, Tools chapter. In practice when you perform a rebase, you will end up stopping as before but you only have to check the merge conflict remains resolved then git add it and continue."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker <type>"}, {"role": "assistant", "content": "Indicates that an object type is required.\nCurrently one of: blob , tree , commit , or tag ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-cherry-pick - Apply the changes introduced by some existing commits --continue"}, {"role": "assistant", "content": "Continue the operation in progress using the information in .git/sequencer . Can be used to continue after resolving\nconflicts in a failed cherry-pick or revert."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Pull Request, ignore some file changes\nWhen I do a Pull Request on GitHub (against master branch), can we ignore some file changes, like\n\nwe have one file named 'fileA' in branch 'release', and we have the same file in 'master', but we do some changes in 'fileA' in branch 'release'\nwhen we do a Pull Request, is there any way we can ignore the changes in 'fileA', do not let that merge into 'master'."}, {"role": "assistant", "content": "You can't ignore some files from a pull request selectively.\nTwo workarounds for this can be -\nFirst -\n\nCreate a new branch from 'release'\nReplace the non-required files from 'master'\nCreate pull request from this new branch\n\nSecond -\n\nCreate a new branch from 'master'\nPut changes of required files from 'release'\nCreate pull request from this new branch\n\nAny of this method will work. Which will be easier depends upon how many files are to be included / excluded."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to connect to a target server via SSH with a key from a GitLab pipeline?\n\nI want to connect to a server via SSH with a public key when GitLab pipeline succeeds.\nAs I see, I need to generate a key with ssh-keygen on GitLab side and add it to server where I want to connect.\nI can generate a key during the pipeline but as the public key is not added to the target server, it makes no sense.\nI suppose it's a common scenario to connect from a CI build to a remote SSH with a key.\nHow can I make it work?"}, {"role": "assistant", "content": "You can run ssh-keygen from wherever you want as long as you use the appropriate keys on the appropriate server.\nHere is what you need:\n\nGenerate a key pair\nCopy the private key to a gitlab CI variable (let's call it SSH_PRIVATE_KEY)\nCopy the public key to the server gitlab will connect to and add it to your ~/.ssh/authorized_keys file\nTell your CI pipeline to use the private key that is stored in the Gitlab CI variable\n\nIn order to do that last step, just add the following to your .gitlab-ci.yml in the script or before_script section of the job of interest: \n- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'\n# Run ssh-agent (inside the build environment)\n- eval $(ssh-agent -s)\n# Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store\n- ssh-add <(echo \"$SSH_PRIVATE_KEY\")\n- mkdir -p ~/.ssh\n- '[[ -f /.dockerenv ]] && echo -e \"Host *\\n\\tStrictHostKeyChecking no\\n\\n\" > ~/.ssh/config'\n\nThen do your SSH connections and voilà !\nEDIT: I couldn't remember where I had found this info the first time but here it is : https://docs.gitlab.com/ee/ci/ssh_keys/README.html"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Error when using Git credential helper with gnome-keyring as Sudo\nI was looking for a way to store credentials securely while connecting to our Git server which uses SSL. I came across this suggestion by @james-ward (only edit I made was I updated our \"system\" config instead of our \"global\" config for Git (https://stackoverflow.com/a/14528360/6195194)\nsudo apt-get install libgnome-keyring-dev\ncd /usr/share/doc/git/contrib/credential/gnome-keyring\nsudo make\ngit config --system credential.helper /usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring\n\nI then can run\ngit clone https://ipaddress/git/repo.git\n\nand the credential helper will store my credentials, however when I run the following:\nsudo git clone https://ipaddress/git/repo.git testfolder\n\nit give me the following error\n** (process:3713): CRITICAL **: Error communicating with gnome-keyring-daemon\n\nI sometimes need to run sudo git clone since sometimes the directory where I need to make a clone requires it. Any help would be appreciated.\nVersions I am using:\n - git version 1.9.1\n - Ubuntu Server 14.0.4\nThank you in advance!\n-Richard O."}, {"role": "assistant", "content": "Beside the use of sudo, note that in 2016, libgnome-keyring is specific to GNOME and is now deprecated (since January 2014, actually).\n2022 option: git-credential-manager\nMicrosoft provides a cross-platform credential helper named GCM (Git Credential Manager), which you can install (no need to build it) and configure:\ngit-credential-manager-core configure\n\nYou will need Git 2.27+ to use it.\nQ4 2022: GCM is now Git Credential Manager (no more -core)\ngit-credential-manager configure\n\nYou will need Git 2.38.1+ to use it.\n\n2016 option: git-credential-libsecret\nGit 2.11+ (Q4 2016) included a new credential helper using libsecret.\nSee commit 87d1353 (09 Oct 2016) by Mantas Mikulėnas (grawity).\n(Merged by Junio C Hamano -- gitster -- in commit bfe800c, 26 Oct 2016)\n\nA new credential helper that talks via \"libsecret\" with implementations of XDG Secret Service API has been added to contrib/credential/.\nit uses libsecret which can support other implementations of XDG Secret\nService API.\n\nBut in 2022, this is no longer needed. See above\n\nAs noted by mati865 in the comments:\n\nIt should be noted that some distros like Arch and Fedora provide helpers available as both binary and source.\n\nLibsecret binary on Arch: /usr/lib/git-core/git-credential-libsecret, and\nLibsecret binary on Fedora: /usr/libexec/git-core/git-credential-libsecret.\n\n\nNote: As @rugk adds in the comments, for Fedora and Git v2.25.2-1 or higher, you need to install an extra package with that binary, because it has been split from the main git package:\ndnf install git-credential-libsecret\n\n\nGit 2.41 (Q2 2023) clarifies:\nSee commit 0a3a972, commit 64f1e65, commit de2fb99, commit 048b673, commit 5747c80, commit 71201ab, commit 16b305c (01 May 2023) by Taylor Blau (ttaylorr).\n(Merged by Junio C Hamano -- gitster -- in commit fbbf60a, 10 May 2023)\n\ncontrib/credential: remove 'gnome-keyring' credential helper\nCo-authored-by: Jeff King\nSigned-off-by: Jeff King\nSigned-off-by: Taylor Blau\n\n\nlibgnome-keyring was deprecated in 2014 (in favor of libsecret), more than nine years ago.\nThe credential helper implemented using libgnome-keyring has had a small handful of commits since 2013, none of which implemented or changed any functionality.\nThe last commit to do substantial work in this area was 15f7221 (\"contrib/git-credential-gnome-keyring.c: support really ancient gnome-keyring\", 2013-09-23, Git v1.8.5-rc0 -- merge), just shy of nine years ago.\nThis credential helper suffers from the same fgets()-related injection attack (using the new \"wwwauth[]\" feature) as in the previous commit.\nInstead of patching it, let's remove this helper as deprecated."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I squash two non-consecutive commits?\nI'm a bit new to the whole rebasing feature within git. Let's say that I made the following commits:\nA -> B -> C -> D\n\nAfterwards, I realize that D contains a fix which depends on some new code added in A, and that these commits belong together. How do I squash A & D together and leave B & C alone?"}, {"role": "assistant", "content": "You can run git rebase --interactive and reorder D before B and squash D into A.\nGit will open an editor, and you see a file like this, ex: git rebase --interactive HEAD~4\npick aaaaaaa Commit A\npick bbbbbbb Commit B\npick ccccccc Commit C\npick ddddddd Commit D\n\n# Rebase aaaaaaa..ddddddd onto 1234567 (4 command(s))\n#\n# Commands:\n# p, pick = use commit\n# r, reword = use commit, but edit the commit message\n# e, edit = use commit, but stop for amending\n# s, squash = use commit, but meld into previous commit\n# f, fixup = like \"squash\", but discard this commit's log message\n# x, exec = run command (the rest of the line) using shell\n#\n# These lines can be re-ordered; they are executed from top to bottom.\n#\n# If you remove a line here THAT COMMIT WILL BE LOST.\n#\n# However, if you remove everything, the rebase will be aborted.\n#\n# Note that empty commits are commented out\n\nNow you change the file that it looks like this:\npick aaaaaaa Commit A\nsquash ddddddd Commit D\npick bbbbbbb Commit B\npick ccccccc Commit C\n\nAnd git will now meld the changes of A and D together into one commit, and put B and C afterwards. When you don't want to keep the commit message of D, instead of squash, you would use the fixup keyword. For more on fixup, you can consult the git rebase docs, or check out this question which has some good answers."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I delete a Git branch with TortoiseGit\nIs there an option to delete a branch with TortoiseGit?\nI found a solution for the commandline. Is there an implementation in TortoiseGit?"}, {"role": "assistant", "content": "You should read this article: Remote branches with TortoiseGit\nAccording to this blog post:\n...remove the local branch by first opening up the Checkout/Switch dialog to get at the Browse refs dialog.\n\nIn the Browse refs dialog we can right click on the local branch and choose to delete it.\n\nTo delete a remote branch we can do the same thing, but instead of right clicking on our local branch we expand the remotes tree in the left part of the dialog and then locate the remote branch."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitglossary - A Git Glossary attr"}, {"role": "assistant", "content": "After attr: comes a space separated list of \"attribute\nrequirements\", all of which must be met in order for the\npath to be considered a match; this is in addition to the\nusual non-magic pathspec pattern matching.\nSee gitattributes . Each of the attribute requirements for the path takes one of\nthese forms: \" ATTR \" requires that the attribute ATTR be set. \" -ATTR \" requires that the attribute ATTR be unset. \" ATTR=VALUE \" requires that the attribute ATTR be\nset to the string VALUE . \" !ATTR \" requires that the attribute ATTR be\nunspecified. Note that when matching against a tree object, attributes are still\nobtained from working tree, not from the given tree object."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git pull/push error: RPC failed; result=22, HTTP code = 408\n\nI am new to GIT. I am using Git version 1.7.9.5.\nI am working on project hosted on github. While pushing and pulling the code from github sometime it works fine and some time it gives me error.\n\nerror: RPC failed; result=22, HTTP code = 408\nfatal: The remote end hung up unexpectedly\n\nI don't what is going wrong. If anyone can suggest me something what could possibly be the issue."}, {"role": "assistant", "content": "The problem is due to git/https buffer settings. In order to solve it run this below command:-\ngit config http.postBuffer 524288000\n\nAnd try git push again"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-clean - Remove untracked files from the working tree -f --force"}, {"role": "assistant", "content": "If the Git configuration variable clean.requireForce is not set\nto false, git clean will refuse to delete files or directories\nunless given -f. Git will refuse to modify untracked\nnested git repositories (directories with a .git subdirectory)\nunless a second -f is given."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_DISCOVERY_ACROSS_FILESYSTEM"}, {"role": "assistant", "content": "When run in a directory that does not have \".git\" repository\ndirectory, Git tries to find such a directory in the parent\ndirectories to find the top of the working tree, but by default it\ndoes not cross filesystem boundaries. This Boolean environment variable\ncan be set to true to tell Git not to stop at filesystem\nboundaries. Like GIT_CEILING_DIRECTORIES , this will not affect\nan explicit repository directory set via GIT_DIR or on the\ncommand line."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Reapply a commit that was undone by conflict?\n\nI have this commit that was undone by someone who doesn't know how to deal with conflicts. Is there an easy way to try auto merging the commit back in? I tried using \"merge to master\" but it just says up to date. I am using tortoisegit."}, {"role": "assistant", "content": "That's what git cherry-pick is for. It lets you apply changes by using already existing commits.\nThe basic syntax is:\ngit cherry-pick <commit> ..."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Where did git put a clone\n\nI'm pretty new to git. For a class the teacher posted a link to clone a project file it said\ngit clone git://github.com/foo\n\nI typed the command and it seemed to work. Problem is I don't know where the file is! If I type the command again it says destination path already exists and is not an empty directory.\nAny help really appreciated =S"}, {"role": "assistant", "content": "The repository should have been cloned into a directory named \"foo\" located in whichever directory you ran the git clone command from."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is proprietary code legally safe on bitbucket or github? [closed]\n\nClosed. This question is off-topic. 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's on-topic for Stack Overflow.\n\n\nClosed 11 years ago.\n\n\nThe community reviewed whether to reopen this question 10 months ago and left it closed:\n\nOriginal close reason(s) were not resolved\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI know this slightly in the legal realm but its unclear who owns the code if you put proprietary code on github or bitbucket in a private repository.\nFrom Bitbucket we have:\n\nBy submitting public (non-private)\n Content to Avantlumiere for inclusion\n on your Website, you grant\n Avantlumiere a world-wide,\n royalty-free, and non-exclusive\n license to reproduce, modify, adapt\n and publish the Content solely for the\n purpose of displaying and promoting\n your account or repository. If a\n repository is marked as private, these\n terms do not apply.\n\nThe question of course is what terms do apply to private accounts. \nIn theory the code should be safe if a license header with copyright information is on every file... right?\nI am not asking for legal advice and will not hold any one responsible."}, {"role": "assistant", "content": "From GitHub:\n\nWe claim no intellectual property rights over the material you provide to the Service. Your profile and materials uploaded remain yours. However, by setting your pages to be viewed publicly, you agree to allow others to view your Content. By setting your repositories to be viewed publicly, you agree to allow others to view and fork your repositories.\n\nAs noted in the BitBucket TOS you linked, BitBucket's parent company similarly has no claims to code that you upload into private repos."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to convert a normal Git repository to a bare one?\nHow can I convert a 'normal' Git repository to a bare one?\nThe main difference seems to be:\n\nin the normal Git repository, you have a .git folder inside the repository containing all relevant data and all other files making up your working copy\nin a bare Git repository, there is no working copy and the folder (let's call it repo.git) contains the actual repository data"}, {"role": "assistant", "content": "In short: replace the contents of repo with the contents of repo/.git, then tell the repository that it is now a bare repository.\nTo do this, execute the following commands:\ncd repo\nmv .git ../repo.git # renaming just for clarity\ncd ..\nrm -fr repo\ncd repo.git\ngit config --bool core.bare true\n\nNote that this is different from doing a git clone --bare /path/to/repo to a new location (as described here).\nConsider this scenario\n\nYour origin had 100 branches\n\nYou have only checked out 10 of them locally\nYour bare repo will only have the 10\n\n\nYou send the bare repo somewhere\n\nIt would be missing 90 branches\n\n\n\nIf that's your intention, that's fine. If you needed a mirror of the remote/origin, this is not the way."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Remove commit from history\nI entered a curseword in my code and I pushed the code on the master branch. I pushed a few more times after that so people do not pull the bad stuff, but I can still find the curseword in the commits history.\nI don't want to add the file to .gitignore because we need that file.\nIs there a way to delete the commit from history?"}, {"role": "assistant", "content": "Once you push to the repo, you really don't want to go about changing history. However, if you are absolutely sure that nobody has pulled/fetched from the repo since your offending commit, you have 2 options.\nIf you want to remove the \"bad\" commit altogether (and every commit that came after that), do a git reset --hard ABC (assuming ABC is the hash of the \"bad\" commit's elder sibling — the one you want to see as the new head commit of that branch). Then do a git push --force (or git push -f).\nIf you just want to edit that commit, and preserve the commits that came after it, do a git rebase -i ABC~. This will launch your editor, showing the list of your commits, starting with the offending one. Change the flag from \"pick\" to \"e\", save the file and close the editor. Then make the necessary changes to the files, and do a git commit -a --amend, then do git rebase --continue. Follow it all up with a git push -f.\nI want to repeat, these options are only available to you if nobody has done a pull or fetch that contains your offending commit. If they have, doing these steps will just make matters worse."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git - Won't add files?\nI'm having issues where I can't add files to my repository.\nI'm using GIT on windows, in Aptana Studio for some Ruby development.\nI've managed to push a few files up to GitHub, but then after this, everything's stopped working. I have for example a new sub-folder in my master directory, with 2 ruby files inside. If I call \"git add .\", and then \"git status\" and it keeps saying \"working directory clean\" and has nothing to commit.\nI've tried \"git add folder/myfile.rb\" and still nothing.\nAnyone any idea's what I can try?"}, {"role": "assistant", "content": "I found myself in a similar situation as the poster:\n\nIf I call \"git add .\", and then \"git status\" and it keeps saying\n\"working directory clean\" and has nothing to commit.\n\nBut I had a different solution than what's here. Since I came to this first, I hope to save others some time.\nFrom the above answers and what I've seen elsewhere, the usual fixes to this problem are:\n\nEnsure there are actually saved changes on the file in question\nEnsure the file doesn't meet your exclude rules in .gitignore and .git/info/exclude\nEnsure you're not trying to add an empty folder. Git won't track those. Standard solution is to place a blank file named .gitkeep as a placeholder so git will track the folder.\n\nIn my case, I had originally tried to create a git repo around an existing repo (not knowing it was there). I had removed the .git folder from this sub repo a while ago, but I didn't realize that it was too late, and git was already tracking it as a submodule. You can read more about how these behave and how to remove them here, but\n\nthe solution for me was to simply run git rm --cached path_to_submodule."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options mergetool.guiDefault"}, {"role": "assistant", "content": "Set true to use the merge.guitool by default (equivalent to\nspecifying the --gui argument), or auto to select merge.guitool or merge.tool depending on the presence of a DISPLAY environment\nvariable value. The default is false , where the --gui argument\nmust be provided explicitly for the merge.guitool to be used."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Change from master to a new default branch git\n\nHere is a scenerio:\nWe have a default branch master and we work off from this, creating branches and pushing up etc...\nWe have now created a develop branch off master and set this as a default development branch.\nWhat I would like to know is, how do I now know if my git pull command is requesting changes from the default branch via the command line? or point to this new default branch?\nWhat I have done:\n\nSince creating a new default branch git pull into master from origin/master\n\nAlso, any new branch, will it be from master or develop?\nAs you can see\nOn branch master\nYour branch is up to date with 'origin/master'.\n\nnothing to commit, working tree clean\nPS C:\\Users\\dir\\Documents\\GitHub\\repo> git log\ncommit 867cxx\n\nfd956f73dc91d0022b (HEAD -> master, origin/master, origin/develop, origin/HEAD)\n\nupdate:\nthis change of default branch occurred after cloning the repo."}, {"role": "assistant", "content": "With git 2.28 you can set a global config with this command\ngit config --global init.defaultBranch {branchName}\nReplace {branchName} with the default branch name\nand now whenever you create a new git repo, the default branch will be this.\nMore details in my video here: https://www.youtube.com/watch?v=YccHk6QlRss"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitglossary - A Git Glossary working tree"}, {"role": "assistant", "content": "The tree of actual checked out files. The working tree normally\ncontains the contents of the HEAD commit’s tree,\nplus any local changes that you have made but not yet committed."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git: checkout files from another branch into current branch (don't switch HEAD to the other branch)\nI want to load a different version of the files that exist in another branch into my current branch.\ngit help checkout says:\nDESCRIPTION\n Updates files in the working tree to match the version in the index or\n the specified tree. If no paths are given, git checkout will also\n update HEAD to set the specified branch as the current branch.\n\nIs there a way to checkout all those files, but not update HEAD?"}, {"role": "assistant", "content": "checkout by providing the current path, .:\ngit checkout other-branch-name -- .\nThis operation is similar to switching HEAD to another branch without checking out files, but just from the \"other direction\".\nAs @김민준 mentions, this overwrites any uncommitted changes. Remember to either stash or commit them somewhere first if needed."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_SSH GIT_SSH_COMMAND"}, {"role": "assistant", "content": "If either of these environment variables is set then git fetch and git push will use the specified command instead of ssh when they need to connect to a remote system.\nThe command-line parameters passed to the configured command are\ndetermined by the ssh variant. See ssh.variant option in git-config for details. $GIT_SSH_COMMAND takes precedence over $GIT_SSH , and is interpreted\nby the shell, which allows additional arguments to be included. $GIT_SSH on the other hand must be just the path to a program\n(which can be a wrapper shell script, if additional arguments are\nneeded). Usually it is easier to configure any desired options through your\npersonal .ssh/config file. Please consult your ssh documentation\nfor further details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-merge - Join two or more development histories together --stat -n --no-stat"}, {"role": "assistant", "content": "Show a diffstat at the end of the merge. The diffstat is also\ncontrolled by the configuration option merge.stat. With -n or --no-stat do not show a diffstat at the end of the\nmerge."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-checkout - Switch branches or restore working tree files -B <new-branch>"}, {"role": "assistant", "content": "Creates the branch <new-branch> , start it at <start-point> ;\nif it already exists, then reset it to <start-point> . And then\ncheck the resulting branch out. This is equivalent to running\n\"git branch\" with \"-f\" followed by \"git checkout\" of that branch;\nsee git-branch for details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitfaq - Frequently asked questions about using Git I’ve made a mistake in the last commit. How do I change it?"}, {"role": "assistant", "content": "You can make the appropriate change to your working tree, run git add\n<file> or git rm <file> , as appropriate, to stage it, and then git\ncommit --amend . Your change will be included in the commit, and you’ll\nbe prompted to edit the commit message again; if you wish to use the\noriginal message verbatim, you can use the --no-edit option to git\ncommit in addition, or just save and quit when your editor opens."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to use Git and Dropbox together? [closed]\nClosed. This question needs details or clarity. It is not currently accepting answers.\n \n \n\n\n\nClosed 3 years ago.\n\n\n\n\n\n\n\n\n\n\n\nLocked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.\n \n \n\n\n\n\n\n\nIs it possible to use Git and Dropbox together?"}, {"role": "assistant", "content": "I think that Git on Dropbox is great. I use it all the time. I have multiple computers (two at home and one at work) on which I use Dropbox as a central bare repository. Since I don’t want to host it on a public service, and I don’t have access to a server that I can always SSH to, Dropbox takes care of this by syncing in the background (very doing so quickly).\nSetup is something like this:\n~/project $ git init\n~/project $ git add .\n~/project $ git commit -m \"first commit\"\n~/project $ cd ~/Dropbox/git\n\n~/Dropbox/git $ git init --bare project.git\n~/Dropbox/git $ cd ~/project\n\n~/project $ git remote add origin ~/Dropbox/git/project.git\n~/project $ git push -u origin master\n\nFrom there, you can just clone that ~/Dropbox/git/project.git directory (regardless of whether it belongs to your Dropbox account or is shared across multiple accounts) and do all the normal Git operations—they will be synchronized to all your other machines automatically.\nI wrote a blog post “On Version Control” in which I cover the reasoning behind my environment setup. It’s based on my Ruby on Rails development experience, but it can be applied to anything, really."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is there a way to lock a branch in GIT\nI have an idea of locking a repository from users pushing files into it by having a lock script in the GIT update hook since the push can only recognize the userid as arguments and not the branches. So i can lock the entire repo which is just locking a directory.\nIs there a way to lock a specific branch in GIT?\nOr is there a way an Update Hook can identify from which branch the user is pushing and to which branch the code is pushed?"}, {"role": "assistant", "content": "The branch being pushed to is the first parameter to the update hook. If you want to lock the branch myfeature for pushing, this code (placed in hooks/update) will do it:\n#!/bin/sh\n# lock the myfeature branch for pushing\nrefname=\"$1\"\n\nif [[ $refname == \"refs/heads/myfeature\" ]]\nthen\n echo \"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"\n echo \"You cannot push to myfeature! It's locked\"\n echo \"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"\n exit 1\nfi\nexit 0"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-grep - Print lines matching a pattern -n --line-number"}, {"role": "assistant", "content": "Prefix the line number to matching lines."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker --icase-pathspecs"}, {"role": "assistant", "content": "Add \"icase\" magic to all pathspec. This is equivalent to setting\nthe GIT_ICASE_PATHSPECS environment variable to 1 ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git log and show on a bare repo\nI created a bare repository on a file-server in my local network at home.\nAfter this i pushed a branch of an existing repository from my desktop-pc to this new remote repository.\nPushing worked perfectly and it seems, that all data arrived (a \"git branch -va\" gives me the correct data). \nBut i cannot use git log or git show on the bare repository.\ni get an:\nfatal: bad default revision 'HEAD'\nor simply no output\nis this normal for bare repositories? Is there another possibility to visualize everything?\nEdit:\nThe fatal error is solved now, but i receive no output from \"git log\" or \"git log unstable\". Same command on the desktop-pc works perfectly"}, {"role": "assistant", "content": "Yes, this is normal for new bare (and non-bare) repositories.\nExplanation\nHEAD is what Git calls a symbolic reference—a reference to another reference.\nIn non-bare repositories, HEAD normally indicates which branch is currently checked out. A new commit will cause the branch named by HEAD to be advanced to refer to the new commit. When HEAD refers to a commit object directly instead of a branch, it's considered to be detached, meaning further commits will not cause a branch reference to be advanced to refer to the new commits (dangerous because checking out a different commit or branch will render the new commits unreachable by any existing reference, making them hard to find and subject to garbage collection).\nIn bare repositories, HEAD indicates the repository's default branch, so that in a clone of the repository git checkout origin is equivalent to git checkout origin/master if master is the default branch (see git help rev-parse for details).\nWhen Git initializes a new repository, it initializes HEAD to refer to refs/heads/master (in other words, HEAD points to the master branch by default). However, it does not create a branch named master because there are no commits in the repository for master to point to yet.\nSo until you either create a master branch or change HEAD to point to a branch that does exist, you'll get that error when you run a command that looks at HEAD (such as git log or git show without any arguments).\nYou can still use commands that don't examine HEAD. For example:\ngit log some_branch_that_exists\n\nFix\nTo get rid of the error message, you can do one of the following:\n\nChange HEAD to point to a branch that does exist:\ngit symbolic-ref HEAD refs/heads/some_other_branch\n\nPush a new master branch into the repository from somewhere else\nCreate a new master branch locally:\ngit branch master some_existing_commit\n\n\nVisualization\nTo visualize everything in the repository, I use something like this:\ngit log --graph --oneline --date-order --decorate --color --all\n\nNote that the above command will work even if HEAD is pointing to a non-existent branch."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch -v --verbose"}, {"role": "assistant", "content": "Pass --verbose to git-fetch and git-merge."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker <object>"}, {"role": "assistant", "content": "Indicates the object name for any type of object."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Merge git repo into branch of another repo\nGiven repo Foo and repo Bar. I want to merge Bar with Foo, but only into a separate branch, called baz.\ngit switch -c baz <= put the Bar repo here."}, {"role": "assistant", "content": "You can't merge a repository into a branch. You can merge a branch from another repository into a branch in your local repository.\nAssuming that you have two repositories, base-repo and other-repo, where you want to merge other-repo into base-repo:\nChange into the base-repo repository:\n$ cd base-repo\n\nAdd the other-repo repository as a remote and fetch it:\n$ git remote add other-repo [email protected]:xxx/other-repo.git # or use a path like ../foo if you have it locally on your machine\n$ git remote update\n\nCreate a new branch base-with-other in the base-repo based on whatever your current branch is:\n$ git switch -c base-with-other # choose any branch name you want and put it after -c\n\nMerge branch somebranch from the other-repo into the current branch:\n$ git merge --allow-unrelated-histories other-repo/somebranch\n\n(--allow-unrelated-histories is not required prior to git version 2.9)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options diff.tool"}, {"role": "assistant", "content": "Controls which diff tool is used by git-difftool .\nThis variable overrides the value configured in merge.tool .\nThe list below shows the valid built-in values.\nAny other value is treated as a custom diff tool and requires\nthat a corresponding difftool.<tool>.cmd variable is defined."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options rmHints"}, {"role": "assistant", "content": "Shown on failure in the output of git-rm , to\ngive directions on how to proceed from the current state."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git rebase failing\n\nI'm trying to rebase the work of a colleague.\nFirst, I get a ton of conflicts where <<<<< head seams to contain the new code. \nThen after a while I get the following error:\nfatal: update_ref failed for ref 'refs/heads/dev_504': \ncannot lock ref 'refs/heads/dev_504': ref refs/heads/dev_504 is at\n XXXXXXX \n but expected XXXXXXXX\nCould not move back to refs/heads/dev_504\n\nThen if I try to continue anyway I get the following error:\nfatal: cannot resume: .git/rebase-apply/final-commit does not exist.\n\nHow can I fix this so the rebase won't give an error?"}, {"role": "assistant", "content": "You can run git rebase --abort to completely undo the rebase. Git will return you to your branch's state as it was before git rebase was called.\nYou can run git rebase --skip to completely skip the commit. That means that none of the changes introduced by the problematic commit will be included. It is very rare that you would choose this option.\nYou can fix the conflict.\nFailing that, you should re-create your branch or you can be able to remove the .git/rebase-merge directory, which contains the rebase state."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Modify PATH for gitlab-runner\n\nI want to install a gitlab-runner (executor shaell) on my Windows 10 box. I start the job on the gitlab server and it always ends up with the message the command \"git\" cannot be found (roughly translated into english).\nAs a matter of fact git is not part of my path.\nHow can I modify my PATH variable for the shell the gitlab-runner starts?\nTo use git on the command line in windows I usually set it with the statement: PATH %PATH%C:\\Program Files\\Git\\bin.\nIs it documented somewhere, git has to be available to the runner?\nHow can I see the command line the runner invokes (i.e. the call to git)?"}, {"role": "assistant", "content": "This GitLab Runner issue answers your question.\nThe environment setting doesn't work since it gets evaluated before the variables are set, but you can use pre_build_script in the runner config to update the path.\n[[runners]]\n name = \"My Runner\"\n url = \"https://gitlab.com/\"\n token = \"Abcd1234\"\n executor = \"shell\"\n pre_build_script = \"set Path=%GIT_HOME%\\\\usr\\\\bin;%Path%\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-send-email - Send a collection of patches as emails --smtp-domain=<FQDN>"}, {"role": "assistant", "content": "Specifies the Fully Qualified Domain Name (FQDN) used in the\nHELO/EHLO command to the SMTP server. Some servers require the\nFQDN to match your IP address. If not set, git send-email attempts\nto determine your FQDN automatically. Default is the value of sendemail.smtpDomain ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-add - Add file contents to the index -p --patch"}, {"role": "assistant", "content": "Interactively choose hunks of patch between the index and the\nwork tree and add them to the index. This gives the user a chance\nto review the difference before adding modified contents to the\nindex. This effectively runs add --interactive , but bypasses the\ninitial command menu and directly jumps to the patch subcommand.\nSee “Interactive mode” for details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --find-object=<object-id>"}, {"role": "assistant", "content": "Look for differences that change the number of occurrences of\nthe specified object. Similar to -S , just the argument is different\nin that it doesn’t search for a specific string but for a specific\nobject id. The object can be a blob or a submodule commit. It implies the -t option in git-log to also find trees."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I reverse a commit in git?\n\nI'm not really familiar with how git works. I pushed a commit by mistake and want to revert it. I did a \ngit reset --hard HEAD~1\n\nBeware Fellow Googlers: This does not only revert the commit, but discards all file changes!\nand now the project is reverted on my machine, but not on github. If I try to push this code, I get the error 'Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.' How do I remove this commit from github?"}, {"role": "assistant", "content": "This article has an excellent explanation as to how to go about various scenarios (where a commit has been done as well as the push OR just a commit, before the push):\nFrom the article, the easiest command I saw to revert a previous commit by its commit id, was:\ngit revert dd61ab32"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I interactively unstage a particular hunk in git?\nIn git, if I have a couple of hunks from the same file staged in my index, how can I interactively unstage one of them?\nIs there any alternative to unstaging the entire file, and then re-staging the hunks I want to keep, or manually undoing the changes to the working copy, and then interactively adding those undone changes?"}, {"role": "assistant", "content": "Try git reset --patch filename; this should do the opposite of git add --patch, according to the documentation. The short form -p also works for both commands."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to use Go with a private GitLab repo\nGitLab is a free, open-source way to host private .git repositories but it does not seem to work with Go. When you create a project it generates a URL of the form:\n[email protected]:private-developers/project.git\n\nwhere:\n\n1.2.3.4 is the IP address of the gitlab server\nprivate-developers is a user group which has access to the private repo\n\nGolang 1.2.1 doesn't seem to understand this syntax.\ngo get [email protected]:private-developers/project.git\n\nresults in:\npackage [email protected]/project.git: unrecognized import path \"[email protected]/project.git\"\n\nIs there a way to get this to work?"}, {"role": "assistant", "content": "Run this command:\ngit config --global url.\"[email protected]:\".insteadOf \"https://1.2.3.4/\"\n\nAssuming you have the correct privileges to git clone the repository, this will make go get work for all repos on server 1.2.3.4. \nI tested this with go version 1.6.2, 1.8, and 1.9.1."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to stash only unstaged changes in Git?\nI would like to use this workflow:\n\nStage some changes.\nSave the unstaged changes to the stash.\nDo some stuff with the things in stage (build, test, etc.).\nCommit.\nRestore the unstaged changes.\n\nIs there a way to do step 2?\nExample:\ngit init\necho one >file\ngit add file\ngit commit\necho two >>file\ngit add file\necho three >>file\ngit stash push\ntest\ngit commit\ngit stash pop"}, {"role": "assistant", "content": "git stash push has an option --keep-index that does exactly what you need, so run:\ngit stash push --keep-index"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-for-each-ref - Output information on each ref --stdin"}, {"role": "assistant", "content": "If --stdin is supplied, then the list of patterns is read from\nstandard input instead of from the argument list."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --patience"}, {"role": "assistant", "content": "Generate a diff using the \"patience diff\" algorithm."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc git-diff-index <tree-ish>"}, {"role": "assistant", "content": "compares the <tree-ish> and the files on the filesystem."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Empty Git submodule folder when repo cloned\nI have one repo hosted at https://github.com/aikiframework/json. On my local copy, I added a submodule using the command:\ngit submodule add [email protected]:jcubic/json-rpc.git json-rpc\n\nThen I did a commit and push, and the changes appear on GitHub (I can click on it). But when I clone the repo:\ngit clone https://github.com/aikiframework/json.git\n\nthe submodule folder json-rpc is empty.\nWhat am I missing here? Did I forget about something? Why is that folder empty?"}, {"role": "assistant", "content": "OK I found it, needed to add --recursive when cloning the repo.\nSo the clone command ends up as:\ngit clone https://github.com/aikiframework/json.git --recursive\n\nNote that if you forgot the --recursive flag you can do (thanks to @Amber):\ngit submodule update --init\n\nNote that when submodules have other submodules you need recursive option (thanks for @cpprust):\ngit submodule update --init --recursive"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Integrate Gitlab and TravisCi\n\nIs there a way where I can integrate TravisCi with Giltab? or at least logging in TravisCi using username and password and not Github credentials?"}, {"role": "assistant", "content": "No, as of right now, Travis-CI is strictly bound to GitHub. While there are certainly talks about lessening this requirement, it's still there for still some time to come.\nAs a workaround, you could push your stuff to GitHub and from there to Travis, using GitHub only as an intermediary."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to clone a specific Git tag\nFrom git-clone(1) Manual Page\n\n--branch can also take tags and detaches the HEAD at that commit in the resulting repository.\n\nI tried \ngit clone --branch <tag_name> <repo_url>\n\nBut it does not work. It returns: \nwarning: Remote branch 2.13.0 not found in upstream origin, using HEAD instead\n\nHow to use this parameter?"}, {"role": "assistant", "content": "git clone --depth 1 --branch <tag_name> <repo_url>\n\n--depth 1 is optional but if you only need the state at that one revision, you probably want to skip downloading all the history up to that revision."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitglossary - A Git Glossary head"}, {"role": "assistant", "content": "A named reference to the commit at the tip of a branch . Heads are stored in a file in $GIT_DIR/refs/heads/ directory, except when using packed refs. (See git-pack-refs .)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Compare old and new versions of force-pushed GitHub pull request\n\nFrequently, my colleagues will make some changes to an open pull request, rebase their local branch against the base branch - often squashing their changes into previous commits as well - and force-push.\nHow can I see what changed between the old version of the PR and the new version of the PR?\nI guess I could do a git pull and git checkout $BRANCH_NAME when the PR was first raised, then git fetch and then git diff $BRANCH_NAME..origin/$BRANCH_NAME after the PR was updated - but that will also show changes that have been introduced into the base branch (typically master) and brought into the PR via a rebase. Is it possible to remove that noise and just show what has changed in the PR itself?"}, {"role": "assistant", "content": "the old version of the PR\n\nYou can do so directly on GitHub: see \"Find committer of a force push on GitHub\"\n\nClicking the “force-pushed” link will show a two dot comparison between the two commits.\n\n\nOriginal answer: 2016\nThat would be only available in the reflog of the remote repo, which would include the previous HEAD of the branch force-pushed.\nSince the remote repo is a GitHub one, you still can infer the old commit by looking at push events: see \"Does github remember commit IDs?\".\n\nhat will also show changes that have been introduced into the base branch (typically master) \n\nMore exactly, you will always have the differences against a common ancestor (which will include commits from the base branch like master)\nSee What are the differences between double-dot \"..\" and triple-dot \"...\" in Git diff commit ranges?\n\nSo in your case, your forced-pushed branch looks like this on the remote repo:\n x--x--x (old branch in reflog)\n /\n m--M0--M--M (master)\n \\\n X--X--X (new branch forced push)\n\nA diff old_HEAD..newHEAD would include the few M commits from the base branch, as they are part of the common ancestor (M0) path.\nSo you can compare a force-pushed branch (providing you are monitoring pushEvents and know of the previous HEAD of that branch).\nBut uou cannot easily compare two branches without their common ancestor path."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Continue working on a Git branch after making a pull request\n\nI've found myself in this situation a couple of times lately, and I'm not totally sure how best to handle it.\nSo I have a fork of a git repository that I'm contributing to. I keep my master branch synced with the upstream master branch.\nWhen I want to work on a new feature, bugfix, etc, I create a branch from my master and do any work. When I'm done, I merge in any changes that have been made to upstream master in the meantime, and then send a pull request from my feature/bugfix branch to the upstream master.\nNow, while I'm waiting for that pull request to be accepted, I want to work on something slightly different. However, the new feature work needs the bugfix/new feature that I just sent the pull request for. I need to build on it.\nHow do I branch/merge/handle branches in such a way that I can work on the continuation, while still being able to merge/pull request in my changes in a clean way once the first pull request is accepted into master?\nThis is all using Github, although I imagine the answer would be applicable to Git in general."}, {"role": "assistant", "content": "Create a new branch feature2 based on the last commit to feature1. feature1 will not move forward any more, and can be merged.\nfeature2 can then be merged later (some people would argue to rebase feature2 on the commit where feature1 was merged into upstream, but personally i dislike rebasing)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git and SSH, which key is used?\nSay your .ssh directory contains 30 keys (15 private and 15 public).\nWhere in Git can one check which one is used to connect to a given remote repository?"}, {"role": "assistant", "content": "The following entry in .ssh/config file solves the problem\n host git.assembla.com\n user git\n identityfile ~/.ssh/whatever\n\nWhere ~/.ssh/whatever is a path to your private key\nAdditionally, user and host can be picked up from\ngit push [email protected]:repo_name.git\n ^__ ^_______________\n user host"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git status returns fatal: Not a git repository but .git exists and HEAD has proper permissions\nWhen I run git status on my repo I get fatal: Not a git repository: /my repo/.git/modules/docs\nI've checked and .git exists and contains HEAD with the proper permissions. I can run various other commands fine. If I run git gui it opens fine and will list a couple of the changed files, but is missing a lot of them.\nI'm guessing there may be some sort of corruption in HEAD, not sure though. Any idea how to fix this without wiping out the whole repo? \nUpdate: I realized that I had changed the name of the repo's directory. The directory being referenced in the error is the old name of the directory. So my current repo is at /new dir/.git but the error is saying Not a git repository: /old dir/.git/modules/docs. So maybe git is confused?"}, {"role": "assistant", "content": "These two files contains absolute submodule path:\n{submodule}/.git\n.git/modules/{submodule}/config\n\nSo, if you moved the repo, the absolute path in these two files are not valid, and cause the 'not a git repository' error. Just fix these files manually."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options transfer.fsckObjects"}, {"role": "assistant", "content": "When fetch.fsckObjects or receive.fsckObjects are\nnot set, the value of this variable is used instead.\nDefaults to false. When set, the fetch or receive will abort in the case of a malformed\nobject or a link to a nonexistent object. In addition, various other\nissues are checked for, including legacy issues (see fsck.<msg-id> ),\nand potential security issues like the existence of a .GIT directory\nor a malicious .gitmodules file (see the release notes for v2.2.1\nand v2.17.1 for details). Other sanity and security checks may be\nadded in future releases. On the receiving side, failing fsckObjects will make those objects\nunreachable, see \"QUARANTINE ENVIRONMENT\" in git-receive-pack . On the fetch side, malformed objects will\ninstead be left unreferenced in the repository. Due to the non-quarantine nature of the fetch.fsckObjects implementation it cannot be relied upon to leave the object store\nclean like receive.fsckObjects can. As objects are unpacked they’re written to the object store, so there\ncan be cases where malicious objects get introduced even though the\n\"fetch\" failed, only to have a subsequent \"fetch\" succeed because only\nnew incoming objects are checked, not those that have already been\nwritten to the object store. That difference in behavior should not be\nrelied upon. In the future, such objects may be quarantined for\n\"fetch\" as well. For now, the paranoid need to find some way to emulate the quarantine\nenvironment if they’d like the same protection as \"push\". E.g. in the\ncase of an internal mirror do the mirroring in two steps, one to fetch\nthe untrusted objects, and then do a second \"push\" (which will use the\nquarantine) to another internal repo, and have internal clients\nconsume this pushed-to repository, or embargo internal fetches and\nonly allow them once a full \"fsck\" has run (and no new fetches have\nhappened in the meantime)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git: How to rebase to a specific commit?\nI'd like to rebase to a specific commit, not to a HEAD of the other branch:\nA --- B --- C master\n \\\n \\-- D topic\n\nto\nA --- B --- C master\n \\\n \\-- D topic\n\ninstead of \nA --- B --- C master\n \\\n \\-- D topic\n\nHow can I achieve that?"}, {"role": "assistant", "content": "You can avoid using the --onto parameter by making a temp branch on the commit you like and then use rebase in its simple form:\ngit branch temp master^\ngit checkout topic\ngit rebase temp\ngit branch -d temp"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %al"}, {"role": "assistant", "content": "author email local-part (the part before the @ sign)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects %gE"}, {"role": "assistant", "content": "reflog identity email (respecting .mailmap, see git-shortlog or git-blame )"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %m"}, {"role": "assistant", "content": "left ( < ), right ( > ) or boundary ( - ) mark"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Transfer gist repo to github\nI am working on a small project with gist and since it is growing I would like to put it on github. \nLet's suppose that:\n\nmy gist repo is at: https://gist.github.com/1234\nmy new (empty) repo is at: https://github.com/ChrisJamesC/myNewProject\n\nThe ideal solution would be one that pushes my changes on both the gist and the github repository."}, {"role": "assistant", "content": "You can add the github repository as a remote to your checked out gist repository.\ngit clone [email protected]:1234.git\ngit remote add github [email protected]:ChrisJamesC/myNewProject.git\n\nPush it to initialize the git on github\ngit push -u github master\n\n\nIf your github repo wasn't quite empty (you created it with a README, license, etc. which you don't mind losing) you will have to do a force overwrite on your push\ngit push -f -u github master\n\nIf you don't want to lose the exiting commits and files, see https://stackoverflow.com/a/40408059/117471\n\nThis will also change the upstream of the branch, so github will be default.\nYou now can rename the remote of gist:\ngit remote rename origin gist\n\nEach time you make changes (or pull changes from github/gist), you can do:\ngit push # To github\ngit push gist master # To gist\n\nThis will also push back your changes to the gist and not only the github repo."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to clone git repository from its zip\nI'm trying to clone a remote repository on github, but it is big and my connection doesn't seem to be stable enough, so I can't clone it successfully.\nBut I have successfully downloaded the .zip of the repository.\nIs there a way to use this zip as it was created by git clone, so I can push, pull etc..?"}, {"role": "assistant", "content": "A related post here provides the information needed to grab the .git directory and simplify the answer that umläute provided:\n\nGrab the .git directory by cloning a bare repository\n$ mkdir repo\n$ git clone --bare http://github/user/repo repo\n\nMake the .git directory and move the cloned files\n$ mkdir repo/.git\n$ mv repo/* repo/.git\n\nUnzip the repository\n$ unzip repo.zip\n\nRe-initialize the repository\n$ cd repo\n$ git init\n\nVerify you're sync'ed\n$ git pull\n\nReset the HEAD to clean up the status\n$ git reset HEAD\n\nHere's the log for the repo ... repo location - http://github.com/udacity/fullstack-nanodegree-vm\n$ git log\ncommit ebcbda650bc81d7f4856f5314a0689cea5b43086\nMerge: 574774b b5b787e\nAuthor: Karl Krueger <[email protected]>\nDate: Tue Apr 7 11:39:54 2015 -0700`\n\n Merge pull request #3 from pmallory/sharedDirAlert\n\n Add a login alert to explain how to access Vagrant's shared directory\n\ncommit b5b787efdb1ecec0c3c9c7f9c0fd4732f984fcb3\nAuthor: Philip Mallory <[email protected]>\nDate: Mon Apr 6 15:40:32 2015 -0700`\n\n move the alert into the motd\n\ncommit b8012f33c86b0d19fc4c2b972af092e88d00978f\nAuthor: Philip Mallory <[email protected]>\nDate: Mon Apr 6 14:32:01 2015 -0700`\n\n Add a login alert to explain how to access Vagrant's shared directory\n\ncommit 574774ba29ccd661154431d5600240f090440c37\nAuthor: Lorenzo Brown <[email protected]>\nDate: Wed Mar 11 14:08:02 2015 -0700`\n\n Update pg_config.sh\n\n Added installs for Auth&Auth\n\ncommit 88fc5537b1a0017a1d76af4587a22412473809a4\nAuthor: Lorenzo Brown <[email protected]>\nDate: Wed Mar 4 13:00:25 2015 -0800`\n\n Update and rename vagrant to vagrant/catalog/README.txt\n\ncommit f978cdc14c62b7295d8da1a95452faaa1bd108b8\nAuthor: Lorenzo Brown <[email protected]>\nDate: Wed Feb 4 11:06:03 2015 -0800`\n\n Update Vagrantfile\n\n switched to port forwarding on 8080\n\ncommit d6a3a26578ef3c6d01d28abca76d817938892c7f\nAuthor: Lorenzo Brown <[email protected]>\nDate: Tue Feb 3 14:52:34 2015 -0800`\n\n Update Vagrantfile\n\n Added:\n\n config.vm.network \"forwarded_port\", guest: 80, host: 8080\n config.vm.network \"forwarded_port\", guest: 5000, host: 5000\n\n FSF uses these two ports for lessons 2 & 3 respectively.\n\ncommit 752a79e408c7328ef7f1766d1b97bb468ffed90a\nAuthor: Mike Wales <[email protected]>\nDate: Mon Feb 2 11:21:29 2015 -0800`\n\n Removed .vagrant directory\n\ncommit 5af9d19adf9ab19b1d886f6cc78e556f864b42dd\nAuthor: Mike Wales <[email protected]>\nDate: Mon Feb 2 11:16:45 2015 -0800`\n\n Initial commit."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --exclude-hidden=[fetch|receive|uploadpack]"}, {"role": "assistant", "content": "Do not include refs that would be hidden by git-fetch , git-receive-pack or git-upload-pack by consulting the appropriate fetch.hideRefs , receive.hideRefs or uploadpack.hideRefs configuration along with transfer.hideRefs (see git-config ). This option affects the next pseudo-ref option --all or --glob and is cleared after processing them."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-parse - Pick out and massage parameters --symbolic"}, {"role": "assistant", "content": "Usually the object names are output in SHA-1 form (with\npossible ^ prefix); this option makes them output in a\nform as close to the original input as possible."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Restore a file's modification time in Git\nI understand the default Git behaviour of updating the modification time every time it changes a file, but there are times when I want to restore a file's original modification time.\nIs there a way I can tell Git to do this?\n(As an example, when working on a large project, I made some changes to configure.ac, found out that autotools doesn't work on my system, and wanted to restore configure.ac's to its original contents and modification time so that make doesn't try to update configure with my broken autotools.)"}, {"role": "assistant", "content": "Restore the modificaton time of a list of files to the author date of the their last commit with\ngitmtim(){ local f;for f;do touch -d @0`git log --pretty=%at -n1 -- \"$f\"` \"$f\"; done;}; gitmtim configure.ac\n\nIt will not change directories recursively, though.\nIf you want to change a whole working tree, e.g. after a fresh clone or checkout, you may try\ngit log --pretty=%at --name-status --reverse | perl -ane '($x,$f)=@F;next if !$x;$t=$x,next if !defined($f)||$s{$f};$s{$f}=utime($t,$t,$f),next if $x=~/[AM]/;'\n\nNB: I grepped for utime in builtin/clone.c and got no matches."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Does NPM ignore files listed in .gitignore?\nI have a file that is generated by npm install command (using preinstall task). I don't want to add it in the git repository, nor in the NPM project.\nSupposing the file name is foo.json, I added it in .gitignore file as foo.json.\nIs this enough to avoid uploading it on NPM registry?\nI know I can add .npmignore file that will surely ignore the file, but I won't add it if .gitignore already does this."}, {"role": "assistant", "content": "If a project has both .npmignore and .gitignore, npm will only use the .npmignore file.\nFrom the documentation:\n\nUse a .npmignore file to keep stuff out of your package. If there's no .npmignore file, but there is a .gitignore file, then npm will ignore the stuff matched by the .gitignore file. If you want to include something that is excluded by your .gitignore file, you can create an empty .npmignore file to override it.\n\nIn simpler terms, npm prefers the .npmignore file, but it will fall back to the .gitignore file.\nIn many cases, both Git and npm can ignore the same files, so it makes sense to just use a .gitignore file.\nIf you need npm and Git to ignore different files, then you need to maintain separate .gitignore and .npmignore files.\nMore information on what to put in .npmignore files: Should I .npmignore my tests?"}]} {"messages": [{"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"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I prevent an automerge using Git?\nI am trying to merge a local branch into the master branch without having Git to do an automerge. I would like to “hand pick” what I would like to be merged into master.\nWhen I use Git’s difftool command, I am able to diff and select what I want to be added into the master branch. But then when I do a merge, I will lose what I selected prior because Git will do an automerge. I can commit the changes into master prior to the merge, but doing so seems unnatural.\nAnd Git’s mergetool is only available when there are conflicts from a merge. But if Git does an automerge then usually there aren’t conflicts, so I am unable to run the mergetool command.\nUpdate:\nI am starting to think what I am trying to accomplish is bad practice or it’s just not possible. That is, to merge a topic branch and only have it merge what I need from diffing. And in an addition, to have this reflected in history. At any rate, the question I posted surfaced when experimenting with Git."}, {"role": "assistant", "content": "You are trying to bypass Git from getting involved in the merge process and to hand-pick each line of each modified file to be merged. This not the same as git cherry-pick. Neither will git merge --no-commit, etc. help. You will need to do:\n$ git checkout master\n$ git difftool -t kdiff3 local-branch HEAD\n\nIn the KDiff3 window, the left hand side (A) is your local-branch and the right hand side (B) is your current branch (master). \nSelect Merge | Merge Current File from the menu (or press the colorful diamond shaped icon with the same title). \nYou will then be shown a diff and conflicts (if any) for each file. And you will have the ability to pick left or right side (A or B), or both, and/or manually tweak the merged file.\nOn another note, something is telling me you have some bigger issues with your workflow."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Visual Studio Code - Connect to a remote Git repository and PUSH local files to a new remote repository\nI have created a local project with Visual Studio Code that implements a local Git repository.\nThen I have create a Git repository on Visual Studio Online and I want to push all my project files to the remote repository...\nWhat is the correct procedure to do it?\nMy .git\\config files at this moment look like this:\n[core]\n repositoryformatversion = 0\n filemode = true\n bare = false\n logallrefupdates = true\n ignorecase = true\n precomposeunicode = true"}, {"role": "assistant", "content": "I assume you started to work in a directory and didn't use Git there. The following should work with Git Bash:\ncd \"path to your repository\"\ngit init\ngit add . # If you want to commit everything. Otherwise use .gitconfig files\ngit commit -m \"initial commit\" # If you change anything, you can add and commit again...\n\nTo add a remote, just do\ngit remote add origin https://...\ngit remote show origin # If everything is ok, you will see your remote\ngit push -u origin master # Assuming you are on the master branch.\n\nThe -u sets an upstream reference and Git knows from where to fetch/pull and where to push in the future."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_COMMITTER_DATE"}, {"role": "assistant", "content": "The date used for the committer identity when creating commit or tag objects, or\nwhen writing reflogs. See git-commit for valid formats."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Listing and deleting Git commits that are under no branch (dangling?)\nI've got a Git repository with plenty of commits that are under no particular branch, I can git show them, but when I try to list branches that contain them, it reports back nothing.\nI thought this is the dangling commits/tree issue (as a result of -D branch), so I pruned the repo, but I still see the same behavior after that:\n$ git fetch origin\n\n$ git fsck --unreachable\n$ git fsck\n\nNo output, nothing dangling (right?). But the commit exists\n$ git show 793db7f272ba4bbdd1e32f14410a52a412667042\ncommit 793db7f272ba4bbdd1e32f14410a52a412667042\nAuthor: ...\n\nand it is not reachable through any branch as\n$ git branch --contains 793db7f272ba4bbdd1e32f14410a52a412667042\n\ngives no output.\nWhat exactly is the state of that commit? How can I list all commits in a similar state? How can I delete commits like those?"}, {"role": "assistant", "content": "To remove all dangling commits (including those still reachable from stashes and other reflogs) do this:\ngit reflog expire --expire-unreachable=now --all\ngit gc --prune=now\n\nBut be certain that this is what you want. I recommend you read the man pages but here is the gist:\ngit gc removes unreachable objects (commits, trees, blobs (files)). An object is unreachable if it isn't part of the history of some branch. Actually it is a bit more complicated:\nStashes are implemented using the reflog (i.e not not branches or tags). That means that they are subject to garbage collection. Or, to make it more explicit: running the above commands will delete all your stashes.\ngit gc does some other things but they are not relevant here and not dangerous.\nUnreachable objects that are younger than two weeks are not removed so we use --prune=now which means \"remove unreachable objects that were created before now\".\nObjects can also be reached through the reflog. While branches record the history of some project, reflogs record the history of these branches. If you amend, reset etc. commits are removed from the branch history but git keeps them around in case you realize that you made a mistake. Reflogs are a convenient way to find out what destructive (and other) operations were performed on a branch (or HEAD), making it easier to undo a destructive operation.\nSo we also have to remove the reflogs to actually remove everything not reachable from a branch. We do so by expiring --all reflogs. Again git keeps a bit of the reflogs to protect users so we again have to tell it not to do so: --expire-unreachable=now.\nSince I mainly use the reflog to recover from destructive operations I usually use --expire=now instead, which zaps the reflogs completely."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git diff - how to quit the diff listing [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow to exit a 'git status' list in a terminal?\n\n (17 answers)\n \n\nClosed 8 years ago.\n\n\n\nHow do you quit git diff listing?\nThere is an <END> marker at the bottom of the screen, and everything I do which appears to quit the diff listing, then shows an <END> marker at the bottom of the screen again."}, {"role": "assistant", "content": "The default pager for git is less. To quit less, hit q."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options add.ignoreErrors add.ignore-errors (deprecated)"}, {"role": "assistant", "content": "Tells git add to continue adding files when some files cannot be\nadded due to indexing errors. Equivalent to the --ignore-errors option of git-add . add.ignore-errors is deprecated,\nas it does not follow the usual naming convention for configuration\nvariables."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options transfer.hideRefs"}, {"role": "assistant", "content": "String(s) receive-pack and upload-pack use to decide which\nrefs to omit from their initial advertisements. Use more than\none definition to specify multiple prefix strings. A ref that is\nunder the hierarchies listed in the value of this variable is\nexcluded, and is hidden when responding to git push or git\nfetch . See receive.hideRefs and uploadpack.hideRefs for\nprogram-specific versions of this config. You may also include a ! in front of the ref name to negate the entry,\nexplicitly exposing it, even if an earlier entry marked it as hidden.\nIf you have multiple hideRefs values, later entries override earlier ones\n(and entries in more-specific config files override less-specific ones). If a namespace is in use, the namespace prefix is stripped from each\nreference before it is matched against transfer.hiderefs patterns. In\norder to match refs before stripping, add a ^ in front of the ref name. If\nyou combine ! and ^ , ! must be specified first. For example, if refs/heads/master is specified in transfer.hideRefs and\nthe current namespace is foo , then refs/namespaces/foo/refs/heads/master is omitted from the advertisements. If uploadpack.allowRefInWant is set, upload-pack will treat want-ref refs/heads/master in a protocol v2 fetch command as if refs/namespaces/foo/refs/heads/master did not exist. receive-pack , on the other hand, will still advertise the object id the\nref is pointing to without mentioning its name (a so-called \".have\" line). Even if you hide refs, a client may still be able to steal the target\nobjects via the techniques described in the \"SECURITY\" section of the gitnamespaces man page; it’s best to keep private data in a\nseparate repository."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Getting existing git branches to track remote branches\nMy usual workflow when working with git, is something like this:\n\ncreate a local repository\ndo some work in that repository, add/change files etc.\ndecide that I want a central remote location for the repository, and create one\npush all the commits from my local repository to this new remote repository\n\nNow, however, I want to be able to push and pull from this remote repository without having to specify where I'm pushing to or pulling from; I want my local master to track the remote master.\nThe proper way to do this isn't clear to me, and I've been unable to determine it from the documentation, even though it shouldn't really be more than one command.\nBecause it's something that's only ever done once per repository, I've generally employed one of two simple, but hacky, solutions:\n\nused git clone to make a new local repository, and deleted the old one. After git cloning, the new repository is setup to track the origin.\nmanually edited .git/config to make master track origin.\n\nI think I should be able to run a command, probably some form of git remote to setup an existing repository to have master track a remote master. Can anyone tell me what that command is?"}, {"role": "assistant", "content": "Use the set-upstream arg:\ngit branch --set-upstream local-branch-name origin/remote-branch-name\n\nRunning the above command updates your .git/config file correctly and even verifies with this output:\n\"Branch local-branch-name set up to track remote branch remote-branch-name from origin.\"\nEDIT: As martijn said: \"In version Git v1.8.0, --set-upstream is deprecated. Use --set-upstream-to instead.\"\ngit branch --set-upstream-to local-branch-name origin/remote-branch-name\n\nSee this for more information."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git: Could not resolve host github.com error while cloning remote repository in git\nWhat I did: I have created a remote repository on Github and I am trying to clone the remote repository on my local machine. While cloning I am providing the clone URL & target folder.\nBut every time I try to clone, I am getting this error:\nError: \"fatal: unable to access 'https://github.com/hyperion057/spring-repo.git/': Could not resolve host: github.com\"\nWhat do I need to do to connect to GitHub ?"}, {"role": "assistant", "content": "I got a similar error, and it's caused by incorrect proxy setting. This command saved me:\ngit config --global --unset http.proxy\n\nhttps version:\ngit config --global --unset https.proxy"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-parse - Pick out and massage parameters --not"}, {"role": "assistant", "content": "When showing object names, prefix them with ^ and\nstrip ^ prefix from the object names that already have\none."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to resume review process after updating pull request at GitHub?\nI forked GitHub repository and created pull request. Reviewer requested changes from me:\n\n\nChanges requested\n1 review requesting changes by reviewers with write access. Learn more.\n\nI've committed and pushed necessary changes in pull request branch, so they are displaying at pull request page. Now I want ask contributor to continue review my changes.\nIs there any button or action for this? Can't find this."}, {"role": "assistant", "content": "2 years and a half years later, (February 2019), do check if the new button \"Re-request review\" would help. \nAs illustrated on twitter, if your PR was already reviewed, but now it’s time for round 2: With fresh eyes and fresh code, re-request a review 🔃\n\n\nNote/caveat: (from \"Requesting a pull request review\")\n\nPull request authors can't request reviews unless they are either a repository owner or collaborator with write access to the repository.\n\nAs noted in the comments by gertvdijk:\n\nI am a contributor on the project and the owner of the PR.\n It does not make sense to me that I need to be a collaborator on the project to request a re-review? \nOh, wow, it's by design that PR authors can't use this feature?\n Damn, that's very much killing the whole feature."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Yarn can't find private Github npm registry\n\nI signed up for the Github private npm registry beta and followed their instruction: https://github.com/features/package-registry\nWorks great with npm but I'd prefer using yarn. And while npm has no issues finding the registered package, yarn can't find it at all.\nyarn add @omniphx/adminite-adminite-ui-components outputs:\nyarn add v1.19.0\ninfo No lockfile found.\nwarning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.\n[1/4] 🔍 Resolving packages...\nerror Couldn't find package \"@omniphx/adminite-ui-components\" on the \"npm\" registry.\ninfo Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.\n\nAfter reading up on private repos with yarn, I thought the trick was due to yarn having a slightly different rc format. Unfortunately, that didn't work either and yarn is still unable to find the private registry.\n.npmrc\nregistry=https://registry.npmjs.org\n@omniphx:registry=https://npm.pkg.github.com/omniphx\n\n.yarnrc\nregistry \"https://registry.npmjs.org\"\n\"@omniphx:registry\" \"https://npm.pkg.github.com/omniphx\"\n\nAlso confirmed that my github token is set too with yarn config list:\nyarn config v1.19.0\ninfo yarn config\n{\n 'version-tag-prefix': 'v',\n 'version-git-tag': true,\n 'version-commit-hooks': true,\n 'version-git-sign': false,\n 'version-git-message': 'v%s',\n 'init-version': '1.0.0',\n 'init-license': 'MIT',\n 'save-prefix': '^',\n 'bin-links': true,\n 'ignore-scripts': false,\n 'ignore-optional': false,\n registry: 'https://registry.npmjs.org',\n 'strict-ssl': true,\n 'user-agent': 'yarn/1.19.0 npm/? node/v12.11.1 darwin x64',\n email: '[email protected]',\n lastUpdateCheck: 1570679687836,\n username: 'omniphx',\n '@omniphx:registry': 'https://npm.pkg.github.com/omniphx'\n}\ninfo npm config\n{\n '//npm.pkg.github.com/:_authToken': 'fake12345',\n registry: 'https://registry.npmjs.org',\n '@omniphx:registry': 'https://npm.pkg.github.com/omniphx',\n python: '/usr/bin/python'\n}\n\nAny idea?\n\nResolved\nChanged \"@myorg:registry\" \"https://npm.pkg.github.com/myorg\"\nTo \"@myorg:registry\" \"https://npm.pkg.github.com\""}, {"role": "assistant", "content": "I've just run into a similar situation. It seemed that yarn was only looking in the main Yarn package registry for my organization's private package. I had copied the examples from GitHub's Packages documentation for constructing your .npmrc file directly to the .yarnrc file in the project that will be consuming the app, not knowing that the formats were different (I've never had to deal with .yarnrc files before). \nHowever, after updating the .yarnrc file with the correct format that you've mentioned above (which I also found in googling around), yarn successfully found the private package and installed it correctly. \nAs a heads up, my yarn version: 1.17.3\nSteps I Took\n\nStart new terminal session\ncd to the project\nnvm use (if you have a specific node version to use)\nAdd the correctly-formatted .yarnrc file to the project. See below for what it looks like. \nManually add the package and version range to the package.json for my private package\nRun npm login --registry=https://npm.pkg.github.com --scope=@MyOrg\n\nSee the note below on scope / org gotcha's\n\nRun yarn\n\nThat worked for me. \n.yarnrc\n\"@myorg:registry\" \"https://npm.pkg.github.com\"\n\nNote: See below for a note on the org / scope name gotcha's\nOther Notes\nI know that it appears that you don't have any issues with this, given your GH username / scope above, but for anyone else that comes here, the documentation on GH is a little sparse with regards to mapping your username / org name to a scope in the package name. Just remember these little gotcha's here: \n\nThe name of your package must always be scoped to your org (or username)\n\n\nE.g., name: @johndturn/my-package\n\nIf your organization has capital letters in it, like MyOrg, just replace them in the name of the package in your package.json and your .yarnrc with lowercase\n\n\nE.g., name: @myorg/my-package\nNote: When authenticating with npm login, I still have kept the uppercase letters in the --scope= argument. \n\nThe name of your package doesn't have to be the same name of the repo. \n\n\nE.g., for a repo called MyOrg/random-prefix.js-lib, you can have name: @myorg/js-lib in your package.json file for the project itself. Then, installing it in other projects will look something like @myorg/js-lib: 1.0.0."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "executing a git pull from a different directory\nI'm configuring calimoucho (a little play continuos integration server), and for it to work I need to run a command to pull a cloned git hub repository from outside it.\nto be more precise, I'll explain it with an example.\nI have the following repository\ncd /home/sas\nmkdir apps\ncd apps\nmkdir myApp\ncd myApp\ngit init\necho \"my file\" > file\ngit add .\ngit commit -m \"initial commit\"\n\nJust a silly test repository where my app is supossed to be\nNow I need to clone that repository to a checkout folder. \ncd /home/sas\nmkdir calimoucho\ncd calimoucho\nmkdir checkout\ncd checkout\ngit clone /home/sas/apps/myApp/ \n\nso I have the following directory structure\n~/apps\n myapp\n .git\n file\n~/calimoucho\n checkout\n myapp\n .git\n file\n\nThe continuos integration server will have to pull new changes from ~/apps/myapp to ~/calimoucho/checkout/myapp, running a command line sentence from ~/calimoucho\nI try with the following command\n~/calimoucho$ git --git-dir=/home/sas/apps/myApp/.git --work-tree=/home/sas/calimoucho/checkout/myApp/ pull\n\nand I get the following error\nfatal: /usr/lib/git-core/git-pull cannot be used without a working tree.\n\nif I don't specify the --work-tree option, the pull is issued, but changes are applied to ~/calimoucho folder instead of ~/calimoucho/checkout/myApp\nany idea how to update the cloned repo from the ~/calimoucho folder?\nthanks a lot"}, {"role": "assistant", "content": "I had this question, too. I found the answer in the git documentation (https://git-scm.com/docs/git).\nRun the command\ngit -C <git-working-directory> pull <git remote>\n\nThe specific command to answer this question is\ngit -C checkout/myApp/ pull\n\nNote that it is important -C <git-working-directory> comes before the pull command and any additional pull options can be specified at the end of the command. In the example above, the git clone command would have setup the default remote repository ~/apps/myapp so it is not required to specify the remote repository."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "E325: ATTENTION Found a swap file by the name \".git/.COMMIT_EDITMSG.swp\"\n\nI've been working with a team for almost a year now. It's always been easy to use github/git to pull and push changes using:\ngit pull\ngit add .\ngit commit -a -m \"my work desc\"\ngit push\n\nThat has always worked fine until recently. Now no matter what, if someone else has pushed, whenever I try to pull I get this message:\nE325: ATTENTION\nFound a swap file by the name \".git/.COMMIT_EDITMSG.swp\"\n owned by: X dated: Wed Jan 23 16:01:06 2013\n file name: ~X/Sites/mysite/.git/COMMIT_EDITMSG\n modified: no\n user name: X host name: X-2.local\n process ID: 77109\nWhile opening file \".git/COMMIT_EDITMSG\"\n dated: Thu Jan 24 16:22:48 2013\n NEWER than swap file!\n\n(1) Another program may be editing the same file.\n If this is the case, be careful not to end up with two\n different instances of the same file when making changes.\n Quit, or continue with caution.\n\n(2) An edit session for this file crashed.\n If this is the case, use \":recover\" or \"vim -r .git/COMMIT_EDITMSG\"\n to recover the changes (see \":help recovery\").\n If you did this already, delete the swap file \".git/.COMMIT_EDITMSG.swp\"\n to avoid this message.\n\nSwap file \".git/.COMMIT_EDITMSG.swp\" already exists!\n[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:\n\nThis happens every time w/o fail. I can eventually get past this by inserting a message, saving and recommitting but it's a pain. Any idea why this keeps happening and what can be done?\nThanks"}, {"role": "assistant", "content": "Unless you need .git/.COMMIT_EDITMSG.swp for some other purpose, you can use:\ngit rm .git/.COMMIT_EDITMSG.swp\n\nto remove the file from the repository."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-ls-tree - List the contents of a tree object --full-name"}, {"role": "assistant", "content": "Instead of showing the path names relative to the current working\ndirectory, show the full path names."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options pack.preferBitmapTips"}, {"role": "assistant", "content": "When selecting which commits will receive bitmaps, prefer a\ncommit at the tip of any reference that is a suffix of any value\nof this configuration over any other commits in the \"selection\nwindow\". Note that setting this configuration to refs/foo does not mean that\nthe commits at the tips of refs/foo/bar and refs/foo/baz will\nnecessarily be selected. This is because commits are selected for\nbitmaps from within a series of windows of variable length. If a commit at the tip of any reference which is a suffix of any value\nof this configuration is seen in a window, it is immediately given\npreference over any other commit in that window."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-commit-tree - Create a new commit object"}, {"role": "assistant", "content": "NAME git-commit-tree - Create a new commit object"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Project vs Repository in GitHub\n\nIn GitHub, what is the conceptual difference between a project (that can be created inside a repository) and a repository? \nI've seen several similar questions (here, here and here) in SO, but none of them explains what is a GitHub project, what is a GitHub repository and when to use each one of them. \nI would appreciate if someone can explain each term, and provide an example of when to use/create each one. For instance, if I have several prototype applications, all independent of each other, what do I create in order to manage in an organized way the source code for all of them?"}, {"role": "assistant", "content": "Fact 1: Projects and Repositories were always synonyms on GitHub.Fact 2: This is no longer the case.\nThere is a lot of confusion about Repositories and Projects. In the past both terms were used pretty much interchangeably by the users and the GitHub's very own documentation. This is reflected by some of the answers and comments here that explain the subtle differences between those terms and when the one was preferred over the other. The difference were always subtle, e.g. like the issue tracker being part of the project but not part of the repository which might be thought of as a strictly git thing etc.\nNot any more.\nCurrently repos and projects refer to a different kinds of entities that have separate APIs:\n\nhttps://developer.github.com/v3/repos/\nhttps://developer.github.com/v3/projects/\n\nSince then it is no longer correct to call the repo a project or vice versa.\nNote that it is often confused in the official documentation and it is unfortunate that a term that was already widely used has been chosen as the name of the new entity but this is the case and we have to live with that.\nThe consequence is that repos and projects are usually confused and every time you read about GitHub projects you have to wonder if it's really about the projects or about repos. Had they chosen some other name or an abbreviation like \"proj\" then we could know that what is discussed is the new type of entity, a precise object with concrete properties, or a general speaking repo-like projectish kind of thingy.\nThe term that is usually unambiguous is \"project board\".\nWhat can we learn from the API\nThe first endpoint in the documentation of the Projects API:\n\nhttps://developer.github.com/v3/projects/#list-repository-projects\n\nis described as: List repository projects. It means that a repository can have many projects. So those two cannot mean the same thing. It includes Response if projects are disabled:\n{\n \"message\": \"Projects are disabled for this repo\",\n \"documentation_url\": \"https://developer.github.com/v3\"\n}\n\nwhich means that some repos can have projects disabled. Again, those cannot be the same thing when a repo can have projects disabled.\nThere are some other interesting endpoints:\n\nCreate a repository project - POST /repos/:owner/:repo/projects\nCreate an organization project - POST /orgs/:org/projects\n\nbut there is no:\n\nCreate a user's project - POST /users/:user/projects\n\nWhich leads us to another difference:\n1. Repositories can belong to users or organizations2. Projects can belong to repositories or organizations\nor, more importantly:\n1. Projects can belong to repositories but not the other way around2. Projects can belong to organizations but not to users3. Repositories can belong to organizations and to users\nSee also:\n\nhttps://help.github.com/articles/about-project-boards/\n\nI know it's confusing. I tried to explain it as precisely as I could."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git push vs git push origin <branchname>\nI'm quite new to Git.\nI'm creating a branch and then want to push it to origin.\nI think that simply issuing git push (while standing on my branch) should be sufficient.\nIs it possible/reasonable to do that (by specifying push.default simple)?"}, {"role": "assistant", "content": "The first push should be a:\ngit push -u origin branchname\n\nThat would make sure:\n\nyour local branch has a remote tracking branch of the same name referring an upstream branch in your remote repo 'origin',\nthis is compliant with the default push policy 'simple'\n\nAny future git push will, with that default policy, only push the current branch, and only if that branch has an upstream branch with the same name.\nthat avoid pushing all matching branches (previous default policy), where tons of test branches were pushed even though they aren't ready to be visible on the upstream repo."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Handling renames: svn vs. git vs. mercurial\nHow do each of these VCS handle renames?\nI have found a lot of contradicting information stating that git tracks LOC (lines of code) instead of files, renames would therefore have no meaning for it."}, {"role": "assistant", "content": "Git doesn't track renames at all, but uses heuristic to re-discover them during merge etc.\nMercurial tracks renames (the origin version and origin file is recorded) and uses that information during merges. So you have to explicitly tell hg about renames with hg mv, or use hg addremove --similarity for auto-discovery. There has been some talk about adding heuristics during merge too.\nSvn tracks renames, but I don't know how good it deals with them during merges (never actually tested that)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git error fatal: unable to stat '*': No such file or directory\nI ran into this error, and found very little documentation on how to fix it online. I got the error by trying to run the command git add ., and received this response:\nfatal: unable to stat 'myPathToAFile': No such file or directory"}, {"role": "assistant", "content": "To solve the problem, I removed the file from git, then re-added it by doing the following:\ngit rm \"myPathToAFile\"\ngit add .\ngit commit -am 'my commit'\nHope this helps someone else!"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-range-diff - Compare two commit ranges (e.g. two versions of a branch) <base> <rev1> <rev2>"}, {"role": "assistant", "content": "Equivalent to passing <base>..<rev1> and <base>..<rev2> .\nNote that <base> does not need to be the exact branch point\nof the branches. Example: after rebasing a branch my-topic , git range-diff my-topic@{u} my-topic@{1} my-topic would\nshow the differences introduced by the rebase."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": ".gitignore for visual studio project is not working\nI am using standard Visual Studio .gitignore file, but Git for Windows still includes build files and other stuff. How to fix this?\nGit ignore file I am using: https://github.com/github/gitignore/blob/master/VisualStudio.gitignore\nVisual Studio generates the same thing automatically\nIt is named correctly, and it is in the right place\n\nWhen I enter git status command it shows build files"}, {"role": "assistant", "content": "To stop tracking the files in the gitignore file; \nOpen a command prompt and navigate to the directory that contains your solution file (.sln), then run the following commands (first two commands contains dot at last):\n\nRemove all of the items from the Git index (not from the working directory or local repository):\n\n git rm -r --cached . \n\n\nUpdate the Git index according to gitignore:\n\n git add .\n\n\nCommit changes:\n\n git commit -am \"Remove ignored files\"\n\nThen open your Visual Studio and sync your repo.\nThat seemed to do the trick for me. I found the git commands here."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Multi-user Github Pull Requests\n\nIs it possible to amend a pull request that someone else has started?\nAssume I maintain project X, and User A has sent me a pull request. There's some things I want changed before merging and can quickly do them myself. How can I do this simply and keep it all within one PR?\nIs this even possible?"}, {"role": "assistant", "content": "You can do it like this:\nIn your repo,\ngit checkout -b new-branch\n\nThen pull User A's commits into your new-branch:\ngit pull git://github.com/[User A]/[project-name].git\n\nAfter that, you can change it whatever you like in the new-branch. And when you test and satisfy with your changes, you can merge it into your master branch:\ngit checkout master\ngit merge new-branch\n\nOK, now you have your code with User A and your changes."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to apply a git patch when given a pull number\n\nI downloaded a trunk version of a codebase from git, and there are build errors. Aparently a patch is now available, and I received an email :\nsee https://github.com/JustinTulloss/zeromq.node/pull/47 for patch\nI am new to git so I'm not quite sure what to do with this 'patch' especially, since the page looks more like a discussion thread.\nDoes anyone know how I can obtain/apply this patch to my locally cloned git repository?"}, {"role": "assistant", "content": "Save the patch somewhere. If you're using linux you can use curl:\ncurl -L https://github.com/JustinTulloss/zeromq.node/pull/47.patch > /tmp/47.patch\n\nTo apply the patch use git apply. You can see if the patch will apply cleanly with the check option. Change to your git directory and run:\ngit apply --check /tmp/47.patch\n\nIf it looks like you want to apply the patch remove the check option\ngit apply /tmp/47.patch"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to solve Access denied in gitlab?\n\nWhen I run : git push, there is exist error like this : \nremote: Access denied\nfatal: unable to access 'https://gitlab.com/myname/mysystem.git/': The requested URL returned error: 403\n\nIs there any people who can help me?"}, {"role": "assistant", "content": "For Windows users, check this unbelievable easy solution, which works for me:\nGo to Windows Credential Manager (press Windows Key and type 'credential') to edit the git entry under Windows Credentials. Replace old password with the new one."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git is not detecting a file and is not in .gitignore\nI have a file called \"style.css\" and git is not detecting it. It doesn't detect it if I delete it either, but it does detect if I change the name of the file. But I need it with that name.\nThe file is not in the .gitignore file. This is driving me crazy!\nI would appreciate some help."}, {"role": "assistant", "content": "Use git check-ignore command to debug your gitignore file (exclude files).\nIn example:\n$ git check-ignore -v config.php\n.gitignore:2:src config.php\n\nThe above output details about the matching pattern (if any) for each given pathname (including line).\nSo maybe your file extension is not ignored, but the whole directory.\nThe returned format is:\n<source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname>\n\nOr use the following command to print your .gitignore in user and repo folder:\ncat ~/.gitignore $(git rev-parse --show-toplevel)/.gitignore $(git rev-parse --show-toplevel)/.git/info/exclude\n\nAlternatively use git add -f <path/file> which allows adding otherwise ignored files.\nSee: man gitignore, man git-check-ignore for more details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to push different local Git branches to Heroku/master\nHeroku has a policy of ignoring all branches but 'master'.\nWhile I'm sure Heroku's designers have excellent reasons for this policy (I'm guessing for storage and performance optimization), the consequence to me as a developer is that whatever local topic branch I may be working on, I would like an easy way to switch Heroku's master to that local topic branch and do a \"git push heroku -f\" to over-write master on Heroku.\nWhat I got from reading the \"Pushing Refspecs\" section of http://progit.org/book/ch9-5.html is\ngit push -f heroku local-topic-branch:refs/heads/master\nWhat I'd really like is a way to set this up in the configuration file so that \"git push heroku\" always does the above, replacing local-topic-branch with the name of whatever my current branch happens to be. If anyone knows how to accomplish that, please let me know!\nThe caveat for this, of course, is that this is only sensible if I am the only one who can push to that Heroku app/repository. A test or QA team might manage such a repository to try out different candidate branches, but they would have to coordinate so that they all agree on what branch they are pushing to it on any given day.\nNeedless to say, it would also be a very good idea to have a separate remote repository (like GitHub) without this restriction for backing everything up to. I'd call that one \"origin\" and use \"heroku\" for Heroku so that \"git push\" always backs up everything to origin, and \"git push heroku\" pushes whatever branch I'm currently on to Heroku's master branch, overwriting it if necessary.\nWould this work?\n\n[remote \"heroku\"]\n url = [email protected]:my-app.git\n push = +refs/heads/*:refs/heads/master\n\nI'd like to hear from someone more experienced before I begin to experiment, although I suppose I could create a dummy app on Heroku and experiment with that.\nAs for fetching, I don't really care if the Heroku repository is write-only. I still have a separate repository, like GitHub, for backup and cloning of all my work.\nFootnote: This question is similar to, but not quite the same as Good Git deployment using branches strategy with Heroku?"}, {"role": "assistant", "content": "See https://devcenter.heroku.com/articles/git#deploying-code\n$ git push heroku yourbranch:main"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I export GitHub issues to Excel?\n\nHow can I export all my issues from an Enterprise GitHub repository to an Excel file? I have tried searching many Stack Overflow answers but did not succeed. I tried this solution too (exporting Git issues to CSV and getting \"ImportError: No module named requests\" errors. Is there any tool or any easy way to export all the issues to Excel?"}, {"role": "assistant", "content": "With the official GitHub CLI you can easily export all issues into a CSV format.\nbrew install gh\n\nLog in:\ngh auth login\n\nChange directory to a repository and run this command:\ngh issue list --limit 1000 --state all | tr '\\t' ',' > issues.csv\n\nIn the European .csv files the separator is a semicolon ';', not a comma. Modify the separator as you want."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Defining parallel sequences of jobs in GitLab CI\n\nIn my gitlab-ci.yml file, I have defined 3 stages, and the 2nd and 3rd stages have 3 jobs each, resulting in the following structure:\n\nThe 1st and 2nd stage works as I intended, however, for the 3rd stage what I'd actually like to have is something like this (the image is a mockup of course), i.e. \"parallel sequences\" of jobs if you will:\n\nThat is, I want \"deploy-b\" to start if \"build-b\" is done, and not waiting for the other build tasks to complete.\nIs that possible with GitLab pipelines? (Apart from the obvious solution of defining just 2 stages, the second being \"Build-and-Deploy\", where I just \"merge\" the script steps of the current build-* and deploy-* jobs.)"}, {"role": "assistant", "content": "This feature was added in the new GitLab release (v12.2)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Cannot determine the organization name for this 'dev.azure.com' remote URL\nSo I just updated to a new Visual Studio version and I am no longer able to push/pull from/to my Azure Repo (cloning works fine). The exact error I get is\n\nCannot determine the organization name for this 'dev.azure.com' remote\nurl. ensure the credential.usehttppath configuration value is set,\nor set the organization name as the user in the remote url\n'{org}@dev.azure.com'.\n\nand only the pull command shows me this error, all the others are failing with git fatal error. I messed with my Credentials Manager cos I suspected it might be the one causing the problem but no luck."}, {"role": "assistant", "content": "What fixed the issue for me is going to Tools > Options > Source Control > Git Global Settings, there I changed all 4 dropdowns which were still selected as \"Unset\":\n\nPrune remote branches during fetch - False\nRebase local branch when pulling - False\nCryptographic network provider - OpenSSL\nCredential helper - GCM Core\n\nSource: https://learn.microsoft.com/en-us/visualstudio/ide/git-with-visual-studio?view=vs-2019#personalize-your-git-settings\nNote: These are the settings my organization requires. You might have to tweak them around according to your exact issue."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitglossary - A Git Glossary revision"}, {"role": "assistant", "content": "Synonym for commit (the noun)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to change git repository using android studio\n\nI'm using git with android studio and I already sync other repository. \nBut I hope to change a git repository like github.\nI think I need to disconnect already connected to the repository but I don't found this option.\nTo do that, How can I do?"}, {"role": "assistant", "content": "We can change the repository url. Just follow the steps.\nIn Android Studio Arctic Fox | 2020.3.1\n\nRight click on project folder\nFrom menu Choose “Git”\nThen chosse \"Manage Remotes...\"\nNow, select the existing \"origin\" and click on edit\nEnter your new URL and click OK\n\nFor Android Studio Older versions\n\nRight click on project folder\nFrom menu Choose “Git”\nChoose “Repository”\nChoose “Remotes…”\n\n\n\nNow you got the “Git Remotes” popup\n\n\n\nYou can edit the existing url or remove the old url and then add new url.\nClick “OK”. that’s it. Now you are connected with new repo. But branches are not connected. Just follow few steps to complete.\nTry to pull the changes from repo “Git > Repository > Pull…”\nNow you got the “Pull Changes” popup. Click “Refresh” button.\n\n\n\nAfter successfully reconnected with repo then you can see the branches of new repo under “Branches to merge” box.\n\n\n\nDone. Now you are connected with new repo & branches.\n\nHappy Coding :)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc plain"}, {"role": "assistant", "content": "Any line that is added in one location and was removed\nin another location will be colored with color.diff.newMoved .\nSimilarly color.diff.oldMoved will be used for removed lines\nthat are added somewhere else in the diff. This mode picks up any\nmoved line, but it is not very useful in a review to determine\nif a block of code was moved without permutation."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Repair corrupted Git repository\nMy Git repository got corrupted after a couple of hard reboots due to power supply issues and now I'm unable to fix it (I was in the middle of staging some files at the last power failure):\n$ git status\nfatal: failed to read object 3d18855708b0f127d40c13c679559d7679228b69: Invalid argument\n$ git fsck\nfatal: failed to read object 24377c609184c192f3f3c1733bac7115c1080758: Invalid argument\n$ git branch -a\n(...works, lists branches...)\n$ git checkout someotherbranch\nfatal: failed to read object 3d18855708b0f127d40c13c679559d7679228b69: Invalid argument\n$ git log\nfatal: failed to read object 3d18855708b0f127d40c13c679559d7679228b69: Invalid argument\n$ git log someotherbranch\n(...works, shows commits...)\n\nSo, as you can see, my current branch is pretty screwed up, and I don't seem to be able to fix it. What can I try to repair this?"}, {"role": "assistant", "content": "My solution for a similar situation was to replace a hash of the damaged object in .git/refs/heads/my-working-branch with a hash of previous commit (which can be found in .git/logs/HEAD)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git merge --no-commit vs git cherry-pick --no-commit\nIs there any difference between git merge --no-commit and git cherry-pick --no-commit?\nAnd is there any difference in history if I commit after these two commands?"}, {"role": "assistant", "content": "If you commit after git merge --no-commit, you'll actually get a merge commit. Whereas after a git cherry-pick --no-commit you'll get a commit with a single parent.\nHence, yes, there is a difference between those two commands.\nIn particular if you have something like\nA -- B -- C\n \\ L HEAD\n \\\n -- D -- E\n\nIf you cherry-pick commit E, you won't get modifications of commit D. Whereas if you merge, you'll get both."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Linux kernel \"historical\" git repository with full history\nI think many developers like to investigate sources with the help of git gui blame. As explained in the commit for Linux-2.6.12-rc2 (also mirrored at Github), it needs to have special historical Linux repository for this purpose.\n\nLinux-2.6.12-rc2\nInitial git repository build. I’m not bothering with the full history,\n even though we have it. We can create a separate “historical” git\n archive of that later if we want to, and in the meantime it’s about\n 3.2GB when imported into git — space that would just make the early\n git days unnecessarily complicated, when we don’t have a lot of good\n infrastructure for it.\nLet it rip!\n\nI have looked at a lot of the prepared historical repositories but I didn’t find one containing changes going back to version zero, so I gave up and am asking this question here."}, {"role": "assistant", "content": "Here is my setup.\nI have a repository with a clone of the following remotes:\n\nhttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git\nhttps://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git\nhttps://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git\nhttps://git.kernel.org/pub/scm/linux/kernel/git/davej/history.git\n\nAnd the following grafts (info/grafts):\n1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 e7e173af42dbf37b1d946f9ee00219cb3b2bea6a\n7a2deb32924142696b8174cdf9b38cd72a11fc96 379a6be1eedb84ae0d476afbc4b4070383681178\n\nWith these grafts, I have an unbroken view of the kernel history since 0.01. The first graft glues together the very first release in Linus' repository with the corresponding release of tglx/history.git. The second graft glues together tglx/history.git and davej/history.git.\nThere are a few older versions missing, and the older versions have release granularity instead of patch granularity, but this is the best setup I know of.\n\nEdit: Dave Jones pointed me to http://www.archive.org/details/git-history-of-linux, which seems to be exactly what you want."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Xcode Project file git merge conflict\nIn Xcode, what's the best way to avoid Git conflict in the project file? (I am in manual git, not using Xcode interface for git)\nI've cloned mapbox-ios-sdk from Github, hacked it, and now the remote master has changed. When I tried to pull the remote changes into my local, after merging there would be merge conflict in the project file. (Specifically, I mean the project.pbxproj in the .xcodeproj)\nI do not really think project file should be put into the ignore, since if there are any new files the project file, the .pbxproj file seems to be changed. (Or am I just plain wrong and this file should be put to ignore? But obviously it wasn't on ignored in the mapbox-ios-sdk to begin with. People need the project file after all.) But I've also ran into this conflict before in my collaboration project with another collaborator and it's keeping me from using Git altogether. \nShould I figure out how to manually resolve conflict or is there a better way to deal with this?"}, {"role": "assistant", "content": "A lot of websites simply suggest to use a .gitattributes file with: \n*.pbxproj merge=union\nWe're gonna try this approach before trying to use scripts. If we find any issues I'll be sure to update this post. Also if anyone else has comments to this approach please include."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs log.showRoot"}, {"role": "assistant", "content": "If true, the initial commit will be shown as a big creation event.\nThis is equivalent to a diff against an empty tree.\nTools like git-log or git-whatchanged , which\nnormally hide the root commit will now show it. True by default."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-help - Display help information about Git --no-aliases"}, {"role": "assistant", "content": "When used with --all , exclude the listing of configured\naliases."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git Pull vs. Pull Request\n\nI'm new to using Git, so I apologize if this is trivial. I have a private repository set up using Github and EGit.\nTo update and merge my local repository branch with the remote version (essentially a git pull), I use Team > Pull in Eclipse.\nTo merge a branch into the master branch, I have to request and subsequently approve a Pull Request on Github.\n\nWhat is the difference between calling git pull and sending a pull request? \n\nI've seen that this is related to a Fork and Pull collaborative development model and is used for code reviews. I think I understand the motivation and usefulness of a pull request, but what exactly is it?"}, {"role": "assistant", "content": "If you use git pull, you pull the changes from the remote repository into yours.\nIf you send a pull request to another repository, you ask their maintainers to pull your changes into theirs (you more or less ask them to use a git pull from your repository).\nIf you are the maintainer of that repository, it seems you're making it a bit more difficult by pretending you're playing two roles in that workflow. You might as well merge locally your development branch into your master branch and push that master branch into your GitHub repository directly.\n(As a side note, if you're new to Git, I'd suggest using git fetch and then git merge instead of git pull. git pull is effectively git fetch followed by git merge, but doing them separately gives you better control over potential conflicts.)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --shortstat"}, {"role": "assistant", "content": "Output only the last line of the --stat format containing total\nnumber of modified files, as well as number of added and deleted\nlines."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order -<number> -n <number> --max-count=<number>"}, {"role": "assistant", "content": "Limit the number of commits to output."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to import and keep updated a CVS repository in Git?\nThere is a central repository in CVS, and I would like to use it with Git locally, and then send my changes back to CVS.\nWhat can I accomplish that on a daily basis?\nThe tasks I would like to accomplish are:\n\nimporting branches,\ngetting history in GIT-like format, and \nexporting back my changes/commits to the centralized server\n\nBTW, I have also looked at Best practices for using git with CVS . But It didn't work and I couldn't figure out what I missed or did wrong."}, {"role": "assistant", "content": "What I have done in the past is:\nImport the CVS repository\nUsing:\n$ git cvsimport -C target-cvs -r cvs -k -vA authors-file.txt -d $CVSROOT module\n\nWhere:\n\ntarget-cvs is the directory to keep my local copy of the repository.\ncvs is the name to use for referencing the remote repository. So, I will have cvs/master, cvs/HEAD, etc. pointed locally by master.\nauthors-file.txt is the file that contains the matches between CVS account and Name+email, each line contains userid=User Name <useremail@hostname>\n$CVSROOT is the CVS respository server. If I use an anonymous cloning from some sourceforge repository, then I would use: :pserver:anonymous@project_name.cvs.sourceforge.net:/cvsroot/project_name\nmodule is the module inside of the repository I want to clone. If the repository has only one module, then likely will be the same as project_name.\n\nUpdate the repository\nIt is possible to repeat the command I wrote previously. In that particular example, it should be run in the parent directory of target-cvs. To make it easier in the future, you might want to configure some variables (you can read more details in the answer of \"How to export revision history from mercurial or git to cvs?\")\n$ git cvsimport\n\nThat would be enough to keep the local repository in git synchronized with the remote one in CVS.\nDaily work\nFrom now on, every change should go in a local git branch. One feature, one branch. For this, I use a work flow described in \"A successful Git branching model\". The only difference is that master points to CVS, but conceptually the same work flows can be applied here. It is just a convention.\nOnce your commit is pushed in CVS, it will be back to master in the next update (git cvsimport). Then, you can remove the local branch that implemented that feature.\nFor work in progress (in local branches), you should rebase them against master. Because you have the features separated, it should be easier to solve conflicts. The tricky part is when some branches depend on others, but still manageable. Micro commits helps a lot (as in any git work flow).\nIf every local branch is rebased and master never touched (except for updates), then git \ncvsexportcommit should just work. Remember, it works for one commit. It is a bit tedious, but it is better than nothing. Given the previous example the command should be something like:\n$ git cvsexportcommit -vc commit-id\n\nIf you only have read-only access to the remote CVS, then you can send the patches by email or make your git repository public, so the commiters can grab your patches to apply them. Nothing different from a normal work flow of CVS in this case. Again, in the next update you will see the changes in master."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I check my github settings or who I'm signed in as on my current project through the terminal?\nMy friend set up my github for me and cloned a project onto my desktop. I want to see what is my profile name on the Github account he gave me. Is there a command to do that?"}, {"role": "assistant", "content": "You can see the current configurations, including username, with git config -l.\nYou'll want to look for user.name, user.email, and github.user. \nYou can unset configurations using --unset, like git config user.name --unset. \nYou can also reset configurations using git config user.name \"Your Name\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Difference between Git and GitHub\n\nI have recently added a new project to Git using Eclipse, but do not see the project appear in my GitHub account.\nWhy do they have the same account information and different repositories?\nIsn't Git and GitHub the same thing?"}, {"role": "assistant", "content": "Git is a revision control system, a tool to manage your source code history.\nGitHub is a hosting service for Git repositories.\nSo they are not the same thing: Git is the tool, GitHub is the service for projects that use Git.\nTo get your code to GitHub, have a look here."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-checkout - Switch branches or restore working tree files --progress --no-progress"}, {"role": "assistant", "content": "Progress status is reported on the standard error stream\nby default when it is attached to a terminal, unless --quiet is specified. This flag enables progress reporting even if not\nattached to a terminal, regardless of --quiet ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -D --irreversible-delete"}, {"role": "assistant", "content": "Omit the preimage for deletes, i.e. print only the header but not\nthe diff between the preimage and /dev/null . The resulting patch\nis not meant to be applied with patch or git apply ; this is\nsolely for people who want to just concentrate on reviewing the\ntext after the change. In addition, the output obviously lacks\nenough information to apply such a patch in reverse, even manually,\nhence the name of the option. When used together with -B , omit also the preimage in the deletion part\nof a delete/create pair."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-merge - Join two or more development histories together no-renormalize"}, {"role": "assistant", "content": "Disables the renormalize option. This overrides the merge.renormalize configuration variable."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git bisect with merged commits\nI have a history that looks like this:\n* 3830e61 Add data escaping. (Bad)\n* 0f5e148 Improve function for getting page template.\n* aaf8dc5 Merge branch 'navigation'\n|\\\n| * 3e667f8 Add icons.\n| * 43a07b1 Add menu styles. (Breaks)\n| * 107ca95 Add Responsive Nav. (Good)\n* | ea3d736 Add ‘Admin’ notice.\n* | 17ca0bb Update placeholder text.\n|/\n* f52cc34 Add featured image.\n* 2abd954 Style placeholders.\n\nI am trying to learn more and git bisect, but am having trouble with this history. I know that 107ca95 is good and 3830e61 is bad. When I run a git bisect, commits 107ca95..3e667f8 are ignored. I happen to know that 43a07b1 is the commit that introduced a regression, but it is never evaluated.\nHere is roughly what I've done:\ngit checkout master\ngit bisect start\ngit bisect bad\ngit bisect good 107ca95\ngit bisect bad (multiple times)\n\nNo matter what I do, 107ca95..3e667f8 are never checked out to be tested.\nIs there any way that I can essentially \"flatten\" the history during the bisect to test those commits? I know I can use an interactive rebase to flatten the history, but I do not want to have to do that."}, {"role": "assistant", "content": "This is a very old but unanswered question. I decided to investigate, and found that I could show that the behavior of Git is different to what the question says it is. One explanation is that Git improved the algorithm for bisect, or that the questioner made a mistake in marking commits.\n\nI am trying to learn more and git bisect, but am having trouble with this history. I know that 107ca95 is good and 3830e61 is bad. When I run a git bisect, commits 107ca95..3e667f8 are ignored. I happen to know that 43a07b1 is the commit that introduced a regression, but it is never evaluated.\n\nI wrote some code to check whether it is evaluated or not. My test shows that it is evaluated. Run the code below and verify that a commit with message Add menu styles. appears.\nFurther comments:\n\n\"commits 107ca95..3e667f8 are ignored\": Please note, that the commit you marked as \"good\" will not be evaluated because git already knows it to be good.\nPlease read the section \"Bisection Algorithm\" in this article by Christian Couder. Also the section \"Checking merge bases\" might be relevant.\nAs mentioned above, the question was certainly using a different version then the one I used (Question is from 2013, Git 2.11 is from 2016).\n\nBisect run output\n\nNotice that first 'Add Admin notice' is checked (line 4) because that provides the most information. (Read \"Checking merge bases\" from article mentioned above.)\nFrom then on, it bisects the linear history as would be expected.\n\n\n# bad: [d7761d6f146eaca1d886f793ced4315539326866] Add data escaping. (Bad)\n# good: [f555d9063a25a20a6ec7c3b0c0504ffe0a997e98] Add Responsive Nav. (Good)\ngit bisect start 'd7761d6f146eaca1d886f793ced4315539326866' 'f555d9063a25a20a6ec7c3b0c0504ffe0a997e98'\n# good: [1b3b7f4952732fec0c68a37d5f313d6f4219e4ae] Add ‘Admin’ notice. (Good)\ngit bisect good 1b3b7f4952732fec0c68a37d5f313d6f4219e4ae\n# bad: [f9a65fe9e6cde4358e5b8ef7569332abfb07675e] Add icons. (Bad)\ngit bisect bad f9a65fe9e6cde4358e5b8ef7569332abfb07675e\n# bad: [165b8a6e5137c40ce8b90911e59d7ec8eec30f46] Add menu styles. (Bad)\ngit bisect bad 165b8a6e5137c40ce8b90911e59d7ec8eec30f46\n# first bad commit: [165b8a6e5137c40ce8b90911e59d7ec8eec30f46] Add menu styles. (Bad)\n\nCode\nRun in Python 3, with Git 2.11.0. \nCommand to run: python3 script.py\n\"\"\" The following code creates a git repository in '/tmp/git-repo' and populates\nit with the following commit graph. Each commit has a test.sh which can be used\nas input to a git-bisect-run.\n\nThe code then tries to find the breaking change automatically.\nAnd prints out the git bisect log.\n\nWritten in response to http://stackoverflow.com/questions/17267816/git-bisect-with-merged-commits\nto test the claim that '107ca95..3e667f8 are never checked out'.\n\nNeeds Python 3!\n\"\"\"\n\n\nfrom itertools import chain\nimport os.path\nimport os\nimport sh\n\nrepo = {\n0x3830e61: {'message': \"Add data escaping.\", 'parents': [ 0x0f5e148 ], 'test': False} , # Last: (Bad)\n0x0f5e148: {'message': \"Improve function for getting page template.\", 'parents': [ 0xaaf8dc5], 'test': False},\n0xaaf8dc5: {'message': \"Merge branch 'navigation'\", 'parents': [ 0x3e667f8, 0xea3d736], 'test': False},\n 0x3e667f8: {'message': \"Add icons.\", 'parents': [ 0x43a07b1], 'test': False},\n 0x43a07b1: {'message': \"Add menu styles.\", 'parents': [ 0x107ca95], 'test': False} , # First: (Breaks)\n 0x107ca95: {'message': \"Add Responsive Nav.\", 'parents': [ 0xf52cc34], 'test': True}, # First: (Good)\n 0xea3d736: {'message': \"Add ‘Admin’ notice.\", 'parents': [ 0x17ca0bb], 'test': True},\n 0x17ca0bb: {'message': \"Update placeholder text.\", 'parents': [ 0xf52cc34], 'test': True},\n0xf52cc34: {'message': \"Add featured image.\", 'parents': [ 0x2abd954], 'test': True},\n0x2abd954: {'message': \"Style placeholders.\", 'parents': [], 'test': True},\n}\n\nbad = 0x3830e61\ngood = 0x107ca95\n\n\ndef generate_queue(_dag, parents):\n for prev in parents:\n yield prev\n yield from generate_queue(_dag, _dag[prev]['parents'])\n\ndef make_queue(_dag, inits):\n \"\"\" Converts repo (a DAG) into a queue \"\"\"\n q = list(generate_queue(_dag, inits))\n q.reverse()\n seen = set()\n r = [x for x in q if not (x in seen or seen.add(x))]\n return r\n\nif __name__ == '__main__':\n pwd = '/tmp/git-repo'\n sh.rm('-r', pwd)\n sh.mkdir('-p', pwd)\n g = sh.git.bake(_cwd=pwd)\n g.init()\n\n parents = set(chain.from_iterable((repo[c]['parents'] for c in repo)))\n\n commits = set(repo)\n inits = list(commits - parents)\n queue = make_queue(repo, inits)\n\n assert len(queue) == len(repo), \"queue {} vs repo {}\".format(len(queue), len(repo))\n\n commit_ids = {}\n # Create commits\n for c in queue:\n # Set up repo\n parents = repo[c]['parents']\n if len(parents) > 0:\n g.checkout(commit_ids[parents[0]])\n if len(parents) > 1:\n if len(parents) > 2: raise NotImplementedError('Octopus merges not support yet.')\n g.merge('--no-commit', '-s', 'ours', commit_ids[parents[1]]) # just force to use 'ours' strategy.\n\n # Make changes\n with open(os.path.join(pwd, 'test.sh'), 'w') as f:\n f.write('exit {:d}\\n'.format(0 if repo[c]['test'] else 1))\n os.chmod(os.path.join(pwd, 'test.sh'), 0o0755)\n with open(os.path.join(pwd, 'message'), 'w') as f:\n f.write(repo[c]['message'])\n g.add('test.sh', 'message')\n g.commit('-m', '{msg} ({test})'.format(msg=repo[c]['message'], test='Good' if repo[c]['test'] else 'Bad'))\n commit_ids[c] = g('rev-parse', 'HEAD').strip()\n\n # Run git-bisect\n g.bisect('start', commit_ids[bad], commit_ids[good])\n g.bisect('run', './test.sh')\n print(g.bisect('log'))"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options log.follow"}, {"role": "assistant", "content": "If true , git log will act as if the --follow option was used when\na single <path> is given. This has the same limitations as --follow ,\ni.e. it cannot be used to follow multiple files and does not work well\non non-linear history."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-push - Update remote refs along with associated objects git push origin +dev:master"}, {"role": "assistant", "content": "Update the origin repository’s master branch with the dev branch,\nallowing non-fast-forward updates. This can leave unreferenced\ncommits dangling in the origin repository. Consider the\nfollowing situation, where a fast-forward is not possible: o---o---o---A---B origin/master\n\t\t \\\n\t\t X---Y---Z dev The above command would change the origin repository to A---B (unnamed branch)\n\t\t /\n\t o---o---o---X---Y---Z master Commits A and B would no longer belong to a branch with a symbolic name,\nand so would be unreachable. As such, these commits would be removed by\na git gc command on the origin repository."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to push new branch without history\nI have git repo with two unrelated branches, master and configs.\nI've created configs, purged all the files and then placed in configuration files only.\nNow I want to push this on remote repo, but as it were new, empty branch (without logs of all my changes and old revisions of original branch).\nHow can I purge all the history and push it?"}, {"role": "assistant", "content": "Purging all the files doesn't get rid of the history. You need to create a branch that has no history first, and the add your config files. These days git checkout has a --orphan option that makes a branch with no history. Here's the information on the --orphan option:\n\n--orphan <new_branch>\nCreate a new orphan branch, named <new_branch>, started from <start_point> and switch to it. The first commit made on this new branch will have no parents and it will be the root of a new history totally disconnected from all the other branches and commits.\nThe index and the working tree are adjusted as if you had previously run \"git checkout <start_point>\". This allows you to start a new history that records a set of paths similar to <start_point> by easily running \"git commit -a\" to make the root commit.\nThis can be useful when you want to publish the tree from a commit without exposing its full history. You might want to do this to publish an open source branch of a project whose current tree is \"clean\", but whose full history contains proprietary or otherwise encumbered bits of code.\nIf you want to start a disconnected history that records a set of paths that is totally different from the one of <start_point>, then you should clear the index and the working tree right after creating the orphan branch by running \"git rm -rf .\" from the top level of the working tree. Afterwards you will be ready to prepare your new files, repopulating the working tree, by copying them from elsewhere, extracting a tarball, etc.\n\nHere's a link to the documentation for checkout. You can also run git help checkout as well.\nOnce you've created your branch without history, then when you push it to the server, it won't have that history either. FWIW, it helps me to think of git push as \"make the remote branch look the same as my local one\". So if you have history, and push, it will have history. If you don't, then the pushed branch won't."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options core.packedRefsTimeout"}, {"role": "assistant", "content": "The length of time, in milliseconds, to retry when trying to\nlock the packed-refs file. Value 0 means not to retry at\nall; -1 means to try indefinitely. Default is 1000 (i.e.,\nretry for 1 second)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "In Git, how do I figure out what my current revision is?\nI just want to know what my current revision number is."}, {"role": "assistant", "content": "What do you mean by \"version number\"? It is quite common to tag a commit with a version number and then use\n$ git describe --tags\n\nto identify the current HEAD w.r.t. any tags. If you mean you want to know the hash of the current HEAD, you probably want:\n$ git rev-parse HEAD\n\nor for the short revision hash:\n$ git rev-parse --short HEAD\n\nIt is often sufficient to do:\n$ cat .git/refs/heads/${branch-main}\n\nbut this is not reliable as the ref may be packed."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-mergetool - Run merge conflict resolution tools to resolve merge conflicts mergetool.meld.useAutoMerge"}, {"role": "assistant", "content": "When the --auto-merge is given, meld will merge all non-conflicting\nparts automatically, highlight the conflicting parts, and wait for\nuser decision. Setting mergetool.meld.useAutoMerge to true tells\nGit to unconditionally use the --auto-merge option with meld .\nSetting this value to auto makes git detect whether --auto-merge is supported and will only use --auto-merge when available. A\nvalue of false avoids using --auto-merge altogether, and is the\ndefault value."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Browse orphaned commits in Git\nMy git repository has somehow gone wonky - I loaded up msysgit this morning and instead of the branch name being shown after the current directory, it says \"((ref: re...))\", 'git status' reports everything as a new file, 'git log' and 'git reflog' tell me \"fatal: bad default revision 'HEAD'\", and so on.\nDoing 'git reflog --all' or 'gitk --all' shows me the rest of the repository is intact, but it looks like the branch I was working on has just disappeared, which explains why HEAD doesn't seem to exist/point to anything.\nI know git keeps hold of all sorts of globs of information, and I'm assuming my commits have just been orphaned somehow, so is there some command that will show me those commits so I can reset HEAD to them?\nEDIT: Oh dear. I discovered 'git fsck', and 'git fsck --full' reports \"fatal: object 03ca4... is corrupted\". What the devil can I do about that?\nEDIT: Oh dear oh dear. I checked out another branch, then tried to re-create the original branch with the same name using 'git checkout -b lostbranchname', and git says \"error: unable to resolve reference refs/heads/lostbranchname: No error, fatal: Failed to lock ref for update: No error\". 'No error' must be a particularly nasty error. So it looks like it's still hanging around, but unable to be used and unable to be killed.\nEDIT: Super duper oh dear. I've done a bunch of unpacking and repacking and replacing of things as suggested here: How to recover Git objects damaged by hard disk failure?, but now I'm getting another hash reported as corrupt, for something as innocuous as 'git status'. I think the entire thing is hosed. Git's lovely and all, but I shouldn't have to deal with this kind of thing."}, {"role": "assistant", "content": "Rather than leave this open I think I'll give an answer to my own question. Using git reflog --all is a good way to browse orphaned commits - and using the SHA1 hashes from that you can reconstruct history.\nIn my case though, the repository was corrupted so this didn't help; git fsck can help you find and sometimes fix errors in the repository itself."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can we include git commands in docker image?\n\nI am new to docker. I would like to create an image which will run as part of my project build to check commited files.\nMy requirement is, Docker file should have these statements\n\nGet commited files from current git repo\nCOPY myapp/ /app\nCMD /app/entry.pl <git files> (as command line arg)\n\nI would like to create an image for this process.\nI should get the git commited files list from current local repo and pass those files to my application to scan those files.\nWhile building my image I just need to copy my application but while running the container I need to run git diff to find changed files and pass that to my application as arguments.\nIs it possible to run git diff by docker container?\nUPDATE:\nI tried to execute git diff on current repo from docker but it is saying not a git repository.\nI am running my docker images as part of continuous integration in gitlab yml file. \nPlease help me to achieve this requirement?"}, {"role": "assistant", "content": "Yes, you can. \nLet me recommend some things about that.\n\nDefine a git token in github associated to a generic user. I like to give only read permissions to that user.\nDeclare some ARGs related to git in your Dockerfile, so you can customize your build.\nAdd Git installation to your Dockerfile.\nDo git clone cloning only needed folders, not the whole repo.\n\nSo, your Dockerfile could be, for example for debian/ubuntu:\nFROM <your linux distribution>\nARG GIT_USER\nARG GIT_TOKEN\nARG GIT_COMMIT\nARG SW_VERSION\nRUN apt-get update\nRUN apt-get -y install git\nRUN git clone -n https://${GIT_USER}:${GIT_TOKEN}@github.com/<your git>/your_git.git --depth 1 && cd <your_git> && git checkout ${GIT_COMMIT} <dir_you_want_to_checkout>\nCOPY myapp/ /app\nCMD /app/entry.pl /<your_git>/<dir_you_want_to_checkout>/...\n\nThen, you can build as you know with: \ndocker build -t --build-arg GIT_USER=<your_user> --build-arg GIT_TOKEN=d0e4467c63... --build-arg GIT_COMMIT=a14dc9f454... <your_image_name> .\n\nGood luck."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Github windows: Commit failed: Failed to create a new commit\n\nI have: http://windows.github.com/\nMy current project has around 20k files, around 150MB (and not speaking about how slow it is and I cannot do a thing now) it doesn't even let me commit! I get this error: Commit failed: Failed to create a new commit.\nThat seems that nobody is having.\nI've already deleted the folder and cloned again, no escape. What to do?\nIf I choose to open shell, all this *** crashes!\n\nEdit:\nSince the problem I've switched to Git Extensions and I didn't look back!\nthanks for your answers"}, {"role": "assistant", "content": "This happened to me. Try opening up PowerShell and manually committing each file using the \"git add [file name]\" command. To see which files have been added, enter \"git status\" into the command line. The green files have been added, the red ones have not been added. \nOnce you've added them all, type \"git commit.\" Then go back to Github for Windows and sync it up.\nI'm not sure what causes this issue, but once I followed the above steps, Github went back to its normal, awesome behavior."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Explain clones info in Github's Traffic tab\nIn a recent question I made, one of the answers pointed to another answer in another question where a way to explore the forks and clones of a public Github repo was shared.\nI went ahead and did that with my own public repo and came up with this information in the Git clones section under the Traffic tab in the Graphs section:\n\nI'm not really sure I understand what this information means. Are there 6 clones of the repo in total with 4 of them made on the 09/08? Did only 3 unique cloners cloned it?, in which case, does that mean they cloned it more than once? Do those numbers include myself and any clones I might have made in different systems (ie: home PC, work PC, laptop, etc)? Any help is much appreciated."}, {"role": "assistant", "content": "I believe part of the confusion is that the graph shows 4 cloners (blue line), and the label is saying 3 unique cloners. Other than that, it should be interpreted as:\n\n6 clones in the past 14 days, 4 made on 9/8 ... this may not indicate the \"total\" as you ask, as this graph only ever goes back 14 days\n3 unique cloners cloned it, some of them may have cloned it more than once...\n...For example, on 9/8, it could have been cloners:clones of 1:1 and 1:3 ... it doesn't give you that level of information\nIt should include every time the git clone command was executed against the repo, so all of your different devices, yes.\nYou would be identified as a unique user or not based on if it could determine \"unique GitHub users (or anonymous IP addresses)\" + confirmation from GitHub support"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git and DiffTool problems : What do LOCAL and REMOTE point to?\nIve been working on getting tortoisemerge working as the difftool option in Git with my .gitconfig file currently showing :\n [diff]\n tool = tortoise\n\n [difftool \"tortoise\"]\n cmd = tortoisemerge.exe -mine:$LOCAL -base:$REMOTE\n\n [difftool]\n prompt = false\n\nAccording to tortoise merge docs the 'mine' command states which file will be shown on the right, in a two way diff.\nMy question is, what do the LOCAL and REMOTE variables as provided by GIT actually point to? The documentation is a little vague stating that \n\nLOCAL is set to the name of the temporary file containing the contents of the diff pre-image and REMOTE is set to the name of the temporary file containing the contents of the diff post-image.\n\nThe problem arises when I modify a file, and then enter 'git difftool' tortoisemerge is started with the working directory file on the LEFT and not the right as I assume.\nI know I can merely switch the 'mine' and 'local' commands but I was trying to figure out what the local/remote points to and the best way to resolve this issue"}, {"role": "assistant", "content": "there are 4 components to this (note that before this step, you would have already done a local-checkin.)\n\nThe local-checkin that your git tree has: LOCAL\nThe head of the remote repository (that is going to be merged): REMOTE\ncommon ancestor to both LOCAL and REMOTE: BASE\nThe file that will be written as a result: MERGED."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options tar.umask"}, {"role": "assistant", "content": "This variable can be used to restrict the permission bits of\ntar archive entries. The default is 0002, which turns off the\nworld write bit. The special value \"user\" indicates that the\narchiving user’s umask will be used instead. See umask(2) and git-archive ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git log to get commits only for a specific branch\nI want to list all commits that are only part of a specific branch.\nWith the following, it lists all the commits from the branch, but also from the parent (master)\ngit log mybranch\n\nThe other option I found, was to exclude the commits reachable by master and gives me what I want, BUT I would like to avoid the need of knowing the other branches names.\ngit log mybranch --not master\n\nI was trying to use git for-each-ref, but it is also listing mybranch so actually it is excluding all:\ngit log mybranch --not $(git for-each-ref --format '^%(refname:short)' refs/heads/)\n\nUpdate:\nI'm testing a new option that I found a while ago, and till now seems that this could be what I was looking for:\ngit log --walk-reflogs mybranch\n\nUpdate (2013-02-13T15:08):\nThe --walk-reflogs option is good, but I checked that there is an expiration for reflogs (default 90 days, gc.reflogExpire).\nI think I found the answer I was looking for:\ngit log mybranch --not $(git for-each-ref --format='%(refname)' refs/heads/ | grep -v \"refs/heads/mybranch\")\n\nI'm just removing the current branch from list of branches available and using that list to be excluded from the log. This way I only get the commits that are only reached by mybranch."}, {"role": "assistant", "content": "From what it sounds like you should be using cherry:\ngit cherry -v develop mybranch\n\nThis would show all of the commits which are contained within mybranch, but NOT in develop. If you leave off the last option (mybranch), it will compare the current branch instead.\nAs VonC pointed out, you are ALWAYS comparing your branch to another branch, so know your branches and then choose which one to compare to."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can I setup auto-complete for git on Windows via cmd.exe?\nI've recently learned that on linux, git can be setup to autocomplete commands: If you type\ngit br<TAB>\nThen it will complete it to git branch.\nCan the same auto-completion be set up on Windows?\nUpdate - I'm usually working with git via cmd.exe (I added git to my path). This question is about adding auto-completion to git on cmd, if that's possible."}, {"role": "assistant", "content": "Installing Clink seems to make this work by magic, verified in cmd, Console2, and ConEmu. \nhttp://mridgers.github.io/clink/\nUPDATE: To get ConEmu and clink to work properly with the more recent versions, it was necessary to install clink into the ConEmu folder. See https://github.com/mridgers/clink/issues/339 and https://github.com/Maximus5/ConEmu/issues/270 for more info."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Github actions share workspace/artifacts between jobs?\n\nTrying to use Github's beta actions, I have two jobs, one that builds the code and then one that will deploy code. However, I can't seem to get the build artifact in deploy job.\nMy latest attempt is to manually set a container image with the same volumes for each job, according to docs this should be solution: https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idcontainervolumes\n\nSets an array of volumes for the container to use. You can use volumes to share data between services or other steps in a job. You can specify named Docker volumes, anonymous Docker volumes, or bind mounts on the host.\n\nWorkflow\nname: CI\non:\n push:\n branches:\n - master\n paths:\n - .github/workflows/server.yml\n - server/*\njobs:\n build:\n runs-on: ubuntu-latest\n container:\n image: docker://node:10\n volumes:\n - /workspace:/github/workspace\n steps:\n - uses: actions/checkout@master\n - run: yarn install\n working-directory: server\n - run: yarn build\n working-directory: server\n - run: yarn test\n working-directory: server\n - run: ls\n working-directory: server\n deploy:\n needs: build\n runs-on: ubuntu-latest\n container:\n image: docker://google/cloud-sdk:latest\n volumes:\n - /workspace:/github/workspace\n steps:\n - uses: actions/checkout@master\n - run: ls\n working-directory: server\n - run: gcloud --version\n\nThe first job (build) has a build directory, but when the second job (deploy) runs it doesn't and only contains the source code.\nThis project is a mono repo with code I'm trying to deploy being under path server hence all the working-directory flags."}, {"role": "assistant", "content": "You can use the Github Actions upload-artifact and download-artifact to share data between jobs.\nIn job1:\nsteps:\n- uses: actions/checkout@v1\n\n- run: mkdir -p path/to/artifact\n\n- run: echo hello > path/to/artifact/world.txt\n\n- uses: actions/upload-artifact@master\n with:\n name: my-artifact\n path: path/to/artifact\n\nAnd job2:\nsteps:\n- uses: actions/checkout@master\n\n- uses: actions/download-artifact@master\n with:\n name: my-artifact\n path: path/to/artifact\n \n- run: cat path/to/artifact/world.txt\n\nhttps://github.com/actions/upload-artifact\nhttps://github.com/actions/download-artifact"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Does git store the read, write, execute permissions for files?\nI wanted to make some files in git read only. But I couldn't find any good documentation on doing this.\nDoes git store the read, write, execute permissions for files?"}, {"role": "assistant", "content": "According to kernel.org git does not store all the permissions possible for files.\n\nGit is a content tracker, where content is de facto defined as\n \"whatever is relevant to the state of a typical sourcecode tree\".\n Basically, this is just files' data and \"executable\" attribute.\n\nSo git stores only the content in the file and the execute bit.\n(This is probably a design choice. Probably driven partly by the fact that not all file systems are the same.)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is a git topic branch?\nWhat is a git topic branch? Does it differ from an ordinary branch in some way? Are there any branches that are not topic branches?"}, {"role": "assistant", "content": "Topic branches are typically lightweight branches that you create locally and that have a name that is meaningful for you. They are where you might do work for a bug fix or feature (they're also called feature branches) that is expected to take some time to complete.\nAnother type of branch is the \"remote branch\" or \"remote-tracking branch\". This type of branch follows the development of somebody else's work and is stored in your own repository. You periodically update this branch (using git fetch) to track what is happening elsewhere. When you are ready to catch up with everybody else's changes, you would use git pull to both fetch and merge.\nI have also seen another kind of branch which is essentially a completely separate tree of files in the same repository. For example, the Git repository itself contains heads named man and html that contain entirely different content from the master branch. I don't know what these types of branches are usually called."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git pull from someone else's fork\nWe are two students working on our online repository (different repo) that is forked from a common upstream repo. \nLet's say other student made Changes, Commits and Pushed to his repo on a specific branch. \n\nHow do I pull these changes into my own local repository? \nDo I need to commit and push those changes to my staged area?\n\nThank you!"}, {"role": "assistant", "content": "Add a new remote (say, other) in your own repo. Pull other/<branch> changes into your local branch (say, add-other-changes). Push to your own forked repo (origin/add-other-changes). Now, when're you done with add-other-changes branch, create a Pull request & merge it with origin/master.\n\nPull other repo's changes into your own repo:\n # go into your own repo\n $ git remote add other <other-student-repo-url> # add a new remote with other's repo URL\n\n $ git fetch other # sync/update local with other's repo\n\n $ git checkout -b add-other-changes # create a new branch named 'add-other-changes' \n $ git pull other <specific-branch-name> # pull other/<branch> changes \n\n $ git push origin HEAD # push changes to your own(origin) forked repo `add-other-changes` branch"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-bundle - Move objects and refs by archive"}, {"role": "assistant", "content": "NAME git-bundle - Move objects and refs by archive"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-add - Add file contents to the index --ignore-errors"}, {"role": "assistant", "content": "If some files could not be added because of errors indexing\nthem, do not abort the operation, but continue adding the\nothers. The command shall still exit with non-zero status.\nThe configuration variable add.ignoreErrors can be set to\ntrue to make this the default behaviour."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-daemon - A really simple server for Git repositories upload-archive"}, {"role": "assistant", "content": "This serves git archive --remote . It is disabled by\ndefault, but a repository can enable it by setting daemon.uploadarch configuration item to true ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitHub - Find the pull request associated with a commit\n\nI'm trying to find a past pull request to see which comments / actions were made on a particular issue. \nI know the file and the change, so I can get to the commit that introduced it by looking at the blame view. However I can't find a way to look at the pull request that pushed that commit to the branch for the first time. \nIs there a way to do this? Or do I have to go on a trip down memory lane and manually browse through past pull requests?"}, {"role": "assistant", "content": "You can filter your pull requests based on the commit SHA - see here\n\nIf you know the specific SHA hash of a commit, you can use it to search for pull requests that contain that SHA. Note that the SHA syntax must be at least seven characters.\n\n\nFor example:\n\n\ne1109ab\nMatches pull requests with a commit SHA that starts with e1109ab.\n\n\n0eff326d6213c is:merged\nMatches merged pull requests with a commit SHA that starts with 0eff326d6213c."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Gitlab repository mirroring\n\nIs it possible to have gitlab set up to automatically sync (mirror) a repository hosted at another location?\nAt the moment, the easiest way I know of doing this involves manually pushing to the two (gitlab and the other) repository, but this is time consuming and error prone.\nThe greatest problem is that a mirror can resynchronize if two users concurrently push changes to the two different repositories. The best method I can come up with to prevent this issue is to ensure users can only push to one of the repositories."}, {"role": "assistant", "content": "Update Dec 2016: Mirroring is suported with GitLAb EE 8.2+: see \"Repository mirroring\".\nAs commented by Xiaodong Qi:\n\nThis answer can be simplified without using any command lines (just set it up on Gitlab repo management interface)\n\n\nOriginal answer (January 2013)\nIf your remote mirror repo is a bare repo, then you can add a post-receive hook to your gitlab-managed repo, and push to your remote repo in it.\n#!/bin/bash\ngit push --mirror [email protected]:/path/to/repo.git\n\nAs Gitolite (used by Gitlab) mentions:\n\nif you want to install a hook in only a few specific repositories, do it directly on the server.\n\nwhich would be in:\n~git/repositories/yourRepo.git/hook/post-receive\n\n\nCaveat (Update Ocotober 2014)\nCiro Santilli points out in the comments:\n\nToday (Q4 2014) this will fail because GitLab automatically symlinks github.com/gitlabhq/gitlab-shell/tree/… into every repository it manages.\n So if you make this change, every repository you modify will try to push.\n Not to mention possible conflicts when upgrading gitlab-shell, and that the current script is a ruby script, not bash (and you should not remove it!). \nYou could correct this by reading the current directory name and ensuring bijection between that and the remote, but I recommend people to stay far far away from those things\n\nSee (and vote for) feeadback \"Automatic push to remote mirror repo after push to GitLab Repo\".\n\nUpdate July 2016: I see this kind of feature added for GitLab EE (Enterprise Edition): MR 249\n\nAdd ability to enter remote push URL under Mirror Repository settings\nAdd implementation code to push to remote repository\nAdd new background worker\nShow latest update date and sync errors if they exists.\nSync remote mirror every hour.\n\nNote that the recent Remote Mirror Repository (issues 17940) can be tricky:\n\nI'm currently trying to shift main development of the Open Source npm modules of my company Lossless GmbH (https://www.npmjs.com/~lossless) from GitHub.com to GitLab.com\nI'm importing all the repos from GitHub, however when I try to switch off Mirror Repository and switch on Remote Mirror Repository with the original GitHub URL I get an error saying: \n\nRemote mirrors url is already in use\n\nHere is one of the repos this fails with: https://gitlab.com/pushrocks/npmts\nEdited 2 months ago\n\nturns out, it just requires multiple steps:\n\ndisable the Mirror Repository\npress save\nremove the URl\npress save\nthen add the Remote Mirror"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I ran into a merge conflict. How do I abort the merge?\nI used git pull and had a merge conflict:\nunmerged: some_file.txt\n\nYou are in the middle of a conflicted merge.\n\nHow do I abandon my changes to the file and keep only the pulled changes?"}, {"role": "assistant", "content": "Since your pull was unsuccessful then HEAD (not HEAD^) is the last \"valid\" commit on your branch:\ngit reset --hard HEAD\n\nThe other piece you want is to let their changes over-ride your changes. \nOlder versions of git allowed you to use the \"theirs\" merge strategy:\ngit pull --strategy=theirs remote_branch\n\nBut this has since been removed, as explained in this message by Junio Hamano (the Git maintainer). As noted in the link, instead you would do this:\ngit fetch origin\ngit reset --hard origin"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "The current branch is not configured for pull No value for key branch.master.merge found in configuration\nI get this error when I try to pull from remote repository using Egit team>pull\n\nThe current branch is not configured for pull No value for key\n branch.master.merge found in configuration"}, {"role": "assistant", "content": "Your local master branch is not set up to track remote master branch.\nYou could do git pull origin master to tell git the explicit branch you want to pull or you add this to your .git/config:\n[branch \"master\"]\n remote = origin\n merge = refs/heads/master\n\nWhen you push to master for the first time, add the -u switch (git push -u origin master). This will set everything up automatically."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "View the change history of a file using github.com\nI've found this post about using the command line, but is it possible to view the file change history of a single file in a repository on github.com?\nAn in-browser solution would help me to better illustrate changes to team members while in meetings."}, {"role": "assistant", "content": "You can view the change history of a file by clicking on the history button, or by adding commits to the URL of the file. Here is what it looks like for a file at the Homebrew repository on GitHub:\nhttps://github.com/mxcl/homebrew/commits/master/SUPPORTERS.md\nTo get a line-by-line history, simply add the SHA-1 string of the commit for which you want to see the diff to the URL after the word commit, and then anchor it with the filename you are interested in. For the same file above:\nhttps://github.com/mxcl/homebrew/commit/288f001e924d5365b79c279e4478f372a04011ae#SUPPORTERS.md\nTo see all commits for a single branch use a URL like this\nhttps://github.com/mxcl/homebrew/commits/master\nTo see all commits for all branches use a URL like this\nhttps://github.com/mxcl/homebrew/commits\nThere is no button or link in the web UI for these URLs, but you can bookmark them easily."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to restore the permissions of files and directories within git if they have been modified?\nI have a git checkout. All the file permissions are different than what git thinks they should be therefore they all show up as modified.\nWithout touching the content of the files (just want to modify the permissions) how do I set all the files permissions to what git thinks they should be?"}, {"role": "assistant", "content": "Git keeps track of filepermission and exposes permission changes when creating patches using git diff -p. So all we need is:\n\ncreate a reverse patch\ninclude only the permission changes\napply the patch to our working copy\n\nAs a one-liner (run from the repository's root directory):\ngit diff -p -R --no-ext-diff --no-color --diff-filter=M \\\n | grep -E \"^(diff|(old|new) mode)\" --color=never \\\n | git apply\n\nyou can also add it as an alias to your git config...\ngit config --global --add alias.permission-reset '!git diff -p -R --no-ext-diff --no-color --diff-filter=M | grep -E \"^(diff|(old|new) mode)\" --color=never | git apply'\n\n...and you can invoke it via:\ngit permission-reset\n\nNote, if you shell is bash, make sure to use ' instead of \" quotes around the !git, otherwise it gets substituted with the last git command you ran.\nThx to @Mixologic for pointing out that by simply using -R on git diff, the cumbersome sed command is no longer required."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-annotate"}, {"role": "assistant", "content": "Annotate file lines with commit information"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can you undo the last git add?\nIs it possible to unstage the last staged (not committed) change in git? Suppose there were a lot of files in the current branch, some staged, some not. At some point, some foolish programmer accidentally executed:\ngit add -- .\n\n...instead of:\ngit checkout -- .\n\nCan this programmer now unstage his last changes with some magical git command? Or should he have committed before experimenting in the first place?"}, {"role": "assistant", "content": "You can use git reset. This will 'unstage' all the files you've added after your last commit.\nIf you want to unstage only some files, use git reset -- <file 1> <file 2> <file n>.\nAlso it's possible to unstage some of the changes in files by using git reset -p."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Merge two remote branches in a Git repository\nI have one remote repository with many branches. For example, my repository name is:\nhttp://navis.com/MyRepo.git\n\nIts branches are:\ndevelopment\nproduction (master)\ntesting\n\nI would like to merge the development branch into the production (master) branch. Can anybody share a Git command for merging two remote branches?"}, {"role": "assistant", "content": "If you have remote-tracking branches set up locally, it's as simple as:\ngit checkout production\ngit merge development\ngit push origin production\n\nIf you have not yet set up remote-tracking branches, you could do something like:\ngit fetch origin\ngit checkout production # or `git checkout -b production origin/production` if you haven't set up production branch locally\ngit merge origin/development\ngit push origin production"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "using mattermost api via gitlab oauth as an end-user with username and password (no client_secret)\n\nIn our team we use gitlab (https://git.example) and the bundled mattermost chat (https://chat.example).\nFor mattermost we'd like to have a dedicated bot-user (the web hooks have limitations wrt. private channels etc.), which actually logs in exactly like a normal user.\nWe created that user in gitlab, and can log into our chat with it via chrome (chat login redir --> gitlab oauth, type in username and pw --> redir back to chat --> authed).\nNow i searched for python libraries that can actually do this, but i can only find some which require a client_id and client_secret... From my understanding (please correct me if i'm wrong) this is not what we're searching for, as we don't want to create another application to auth via gitlab, but login to our chat (which already has an id (known) and a secret (unknown)) as a user via gitlab.\nAs we couldn't find such a lib, we also inspected the network requests in chrome and tried to re-create it in python via requests, but can't get it to work (needless to say it involves parsing html and csrf tokens)...\nTaking yet another attempt and a lot of guesswork we tried to acquire an access_token manually via\nclient_id = 'the one of mattermost in our gitlab'\nuser = 'username'\npw = 'password'\nr = requests.post(\n 'https://git.example/oauth/token',\n data={\n \"grant_type\": \"password\",\n \"username\": user,\n \"password\": pw,\n \"client_id\": client_id,\n }\n)\naccess_token = r.json()['access_token']\n\nThis seems to work (and the token looks good), but using it in the mattermost API only results in a 401:\nri = requests.get(\n 'https://chat.example/api/v1/users/me',\n headers={'Authorization': 'Bearer ' + access_token}\n)\n\nri.status_code, ri.json()\n(401,\n {u'detailed_error': u'token=...xxx...',\n u'id': u'api.context.session_expired.app_error',\n u'is_oauth': False,\n u'message': u'Invalid or expired session, please login again.',\n u'request_id': u'...yyy...',\n u'status_code': 401})\n\nSadly http://docs.mattermost.com/developer/web-service.html#oauth2 currently doesn't shed more light into this, which is why I'm asking here. Did i maybe miss something obvious to \"activate\" that access_token in mattermost?"}, {"role": "assistant", "content": "Actually i finally got this running by imitating the browser's behavior as follows, but i'd still be interested in a more generic solution that doesn't involve parsing any of the gitlab server's html...:\nimport requests\nfrom pyquery import PyQuery as pq\n\nclient_id = '...your_mattermost_client_id...'\nuser = '...username...'\npw = '...userpass...'\n\ngitlab = 'https://git.example'\nchat = 'https://chat.example'\nteam = '/your_team'\n\nr = requests.get(\n chat + team + '/login/gitlab'\n)\nq = pq(r.content)\ncsrf_token = q('#new_ldap_user input[name=\"authenticity_token\"]')[0].value # watch out, several tokens for ldap vs. normal login, inspect the page to find correct one\n\nr2 = requests.post(\n gitlab + '/users/auth/ldapmain/callback', # or whatever the browser callback for your auth-method was\n cookies=r.cookies,\n data={\n 'authenticity_token': csrf_token,\n 'username': user,\n 'password': pw,\n }\n)\n\n# print [h.url for h in r2.history] + [r2.url] # to check the redirects\n\nme = requests.get(\n chat + '/api/v1/users/me',\n cookies=r2.cookies,\n)\nprint me.json() # if everything went well you're now authorized\n\n# remember to set cookies in the follow-up requests"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --shortstat"}, {"role": "assistant", "content": "Output only the last line of the --stat format containing total\nnumber of modified files, as well as number of added and deleted\nlines."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why Git is not allowing me to commit even after configuration?\n\nThis question seems like a duplicate but it's really not. Just a slight difference that keeps on repeating. git keeps on telling me: \"please tell me who you are\", even after setting it up. when I run git commit, this is what I get....\n$ git commit\n\n*** Please tell me who you are.\n\nRun\n\ngit config --global user.email \"[email protected]\"\n\ngit config --global user.name \"Your Name\"\n\nto set your account's default identity.\nOmit --global to set the identity only in this repository.\n\nfatal: unable to auto-detect email address (got 'Obby@ObbyWorkstation.(none)')\n\nBut when I run git config --global -l, it gives me all my details...\n$ git config --global -l\nuser.name=myname\n[email protected]\nhttp.proxy=proxy.XX.XX.XX:XXXX\n\nI have changed my name, email and proxy but they are appearing fine when I run the command, even in the .gitconfig file I can see the values are set. what could be the missing thing, because I cannot commit at all. Every time it keeps asking me who I am ?\n@sheu told me something that i changed, but still the same problem. when i set --local, still git commit asks me the same question. this is the output\n$ git config --local -l\ncore.repositoryformatversion=0\ncore.filemode=false\ncore.bare=false\ncore.logallrefupdates=true\ncore.symlinks=false\ncore.ignorecase=true\ncore.hidedotfiles=dotGitOnly\nuser.name=myname\n[email protected]"}, {"role": "assistant", "content": "That’s a typo. You’ve accidently set user.mail with no e in email. Fix it by setting user.email in the global configuration with\ngit config --global user.email \"[email protected]\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Docker Gitlab change forgotten root password\n\nI'm running my Gitlab with Docker and \nI forgot my Gitlab root password. How to change it ?"}, {"role": "assistant", "content": "I found a way to make it work.\nFirst connect to your Gitlab with command line\nsearch for your Docker CONTAINER_ID\ndocker ps -all\neg\n\ndocker exec -it d0bbe0e1e3db bash <-- with your CONTAINER_ID\n$ gitlab-rails console -e production\n\nuser = User.where(id: 1).first\nuser.password = 'your secret'\nuser.password_confirmation = 'your secret'\nuser.save\nexit"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Push existing folder to GitLab\n\nIn Gitlab project from the instructions, they tell how to add an existing_folder to Git repository.\nBut after I press git commit the console open a vim.\nThen how can I go to the last one git push -u origin master and push my repository to gitlab.\ncd existing_folder\ngit init\ngit remote add origin [remote url]\ngit add .\ngit commit\ngit push -u origin master"}, {"role": "assistant", "content": "The command git commit launches your default command line text editor because a commit needs a message describing what is happening in it. There are two ways to add this message:\n\nWhen the editor (vim) is launched, write a commit message in the editor, then save and close the file. This message will now be stored with the commit. Exiting without saving the file will cancel the commit.\nUse the command git commmit -m \"Commit message here\", which allows you add a short commit message in the quotes without launching the editor.\n\nA commit message can be anything, but here is an article if you want to go in depth on what should be in a message and how to format it. Sometimes I use the full text editor to write a complex message, sometimes I just need a quick note and use the inline command with the -m flag.\nWant to change the default editor git uses for commit messages? You're in luck! Simply add it to your git config like this: git config --global core.editor \"nano\". Now commit messages will be opened in nano, or whatever editor command you put in this config command."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --cherry-pick"}, {"role": "assistant", "content": "Omit any commit that introduces the same change as\nanother commit on the “other side” when the set of\ncommits are limited with symmetric difference. For example, if you have two branches, A and B , a usual way\nto list all commits on only one side of them is with --left-right (see the example below in the description of\nthe --left-right option). However, it shows the commits that were\ncherry-picked from the other branch (for example, “3rd on b” may be\ncherry-picked from branch A). With this option, such pairs of commits are\nexcluded from the output."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database GIT_INDEX_FILE"}, {"role": "assistant", "content": "used to specify the index file of the index"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-init - Create an empty Git repository or reinitialize an existing one Start a new Git repository for an existing code base"}, {"role": "assistant", "content": "$ cd /path/to/my/codebase\n$ git init (1) $ git add . (2) $ git commit (3) Create a /path/to/my/codebase/.git directory. Add all existing files to the index. Record the pristine state as the first commit in the history."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "New file created in Xcode 9.3, <wsname>.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist should it be committed?\nI downloaded the newly released Xcode 9.3, I recompiled my workspace and I noticed it produced a new file:\n<mywsname>.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist\nwhose contents are:\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n <dict>\n <key>IDEDidComputeMac32BitWarning</key>\n <true/>\n </dict>\n</plist>\n\nI wonder if this file should be git ignored or committed. I was not able to find any documentation about it."}, {"role": "assistant", "content": "From 9.3 release notes, it sounds like you'd want to commit.\n\nXcode 9.3 adds a new IDEWorkspaceChecks.plist file to a workspace’s\n shared data, to store the state of necessary workspace checks.\n Committing this file to source control will prevent unnecessary\n rerunning of those checks for each user opening the workspace.\n\nSource"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-commit - Record changes to the repository commit.cleanup"}, {"role": "assistant", "content": "This setting overrides the default of the --cleanup option in git commit . See git-commit for details. Changing the\ndefault can be useful when you always want to keep lines that begin\nwith the comment character # in your log message, in which case you\nwould do git config commit.cleanup whitespace (note that you will\nhave to remove the help lines that begin with # in the commit log\ntemplate yourself, if you do this)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker"}, {"role": "assistant", "content": "Reporting Bugs Report bugs to the Git mailing list < git@vger.kernel.org > where the\ndevelopment and maintenance is primarily done. You do not have to be\nsubscribed to the list to send a message there. See the list archive\nat https://lore.kernel.org/git for previous bug reports and other\ndiscussions. Issues which are security relevant should be disclosed privately to\nthe Git Security mailing list < git-security@googlegroups.com >."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Where is git submodule update in SourceTree?\nHow can I update git sub modules in SourceTree?"}, {"role": "assistant", "content": "I couldn't find the answer myself, so I created a custom action. Go to Preferences, Custom Actions, and enter the following info:\n(This is on a Mac. Your path to the git executable may vary.)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Github enterprise - remote: Password authentication is not available for Git operations\nMy git was working fine, then without changing anything than the following problem started to happen,\nI have tried resetting the cache in \n\ncredentials.helper\n\nand have gone through pretty much every stackoverflow answer I could find \nremote: Password authentication is not available for Git operations.\nremote: You must use a personal access token or SSH key.\nremote: See https://github.ibm.com/settings/tokens or\n'https://github.ibm.com/WBurney/Blockchain_SDO.git/': \nThe requested URL returned error: 403\n\nThanks"}, {"role": "assistant", "content": "If you have registered a public ssh key to your GitHub enterprise account, you could side-step the issue using an ssh url\ncd /path/to/repo\ngit remote set-url origin [email protected]:WBurney/Blockchain_SDO.git\n\nThen any command like git push/git fetch/git pull/git ls-remote would use the SSH URL set by git remote set-url.\nBut regarding your original issue, try and follow \"Creating a personal access token for the command line\".\nIf you are on Mac, update your credentials from the OSX Keychain.\nYou might need to remove an old cached credential first.\n(As commented by RayLoveless)\nAs drazen Bjelovuk confirms in the comments:\n\nUpdating the password to a personal token in my OSX Keychain worked for me."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is there a way to lock individual files or directories on fork when using git?\nWe are a team of 60+ developers working on the same product and are moving from SVN to Git and GitHub. We have a process in SVN where in individual files are locked and whenever a developer wants to commit code, he needs to get it unlocked by the owner of the file. Three of us are the owners of the total 150+ files. The unlocking is preceded by a code review. \nIn Github, we are planning to use the Fork-Clone model - each project a group of dev is working on will do a fork, each developer will do a clone of the fork, write the code & commit to origin, the lead of the feature will do a pull request to upstream.\nThough this seems fine, the problem is when a big project gets delivered, it brings in lots of changes for review and hence, increases the load for the file owners. Also, this might happen in the later cycles of development and hence the project might be jeopardized.\nOne method we thought might work is to have hooks when the git push is done to the origin (fork). There can be one final review git pull to upstream. \nHowever, we could not find any github extensions or push hooks for the same. Is there a quick way (read, existing extension) to do this with Github or should we use the same hooks that we would use with git?"}, {"role": "assistant", "content": "No chance, if file is not mergeable and you need to lock it, use a centralized solution instead of GIT, i.e. SVN or ClearCase."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_SSL_NO_VERIFY"}, {"role": "assistant", "content": "Setting and exporting this environment variable to any value\ntells Git not to verify the SSL certificate when fetching or\npushing over HTTPS."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Correctly ignore all files recursively under a specific folder except for a specific file type\nI have seen similar questions (1, 2 and 3), but I don't get a proper solution from them. \nI need to ignore all files under a particular folder except for a specific file type. The folder is a subdirectory for the root path. Let me name the folder Resources. Since I don't want to complicate things, let me ignore files under all folders named Resources wherever it is.\nThis is the most common solution (in all the duplicate questions)\n# Ignore everything\n*\n\n# Don't ignore directories, so we can recurse into them\n!*/\n\n# Don't ignore .gitignore\n!.gitignore\n\n# Now exclude our type\n!*.foo\n\nThe problem with this solution is that it stops tracking newly added files (since * ignores all files). I don't want to keep excluding each and every file type. I want normal behaviour where if any new file is added, git status shows it. \nI finally got a solution here. The solution is to add another .gitignore file in Resources folder. This works correctly. \nCan I achieve the same with one ignore file? I find having many ignore files in different directories a bit clunky.\nThis is what I'm trying to achieve: \n# Ignore everything under Resources folder, not elsewhere\nResources\n\n# Don't ignore directories, so we can recurse into them\n!*Resources/\n\n# Now exclude our type\n!*.foo\n\nBut this gives the opposite output. It ignores *.foo types and tracks other files."}, {"role": "assistant", "content": "@SimonBuchan is correct.\nSince git 1.8.2, Resources/** !Resources/**/*.foo works."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Trimming Git Commits/Squashing Git History\nI check my code into a Git branch every few minutes or so, and the comments end up being things like \"Everything broken starting again\" and other absurdities.\nThen every few minutes/hours/days I do a serious commit with a real comment like, \"Fixed bug #22.55, 3rd time.\" How can I separate these two concepts? I would like to be able to remove all my frequent-commits and just leave the serious ones."}, {"role": "assistant", "content": "Edited answer with now (in the second half of this entry) the new Git1.7 fixup! action and --autosquash option for quick commit reordering and message editing.\n\nFirst, the classic squashing process, as done before Git1.7.\n(Git1.7 has the same process, only made faster by the possibility of automatic commit reordering as opposed to manual reordering, and by cleaner squashing messages)\n\nI would like to be able to remove all my frequent-checkins and just leave the serious ones.\n\nThis is called squashing commits.\nYou have some good example of \"comit cleaning\" in this Git ready article:\n(Note: the rebase interactive feature came along since September 2007, and allows for squashing or splitting or removing or reordering commits: see also the GitPro page)\n\nA word of caution: Only do this on commits that haven’t been pushed an external repository. If others have based work off of the commits that you’re going to delete, plenty of conflicts can occur. Just don’t rewrite your history if it’s been shared with others.\n\nThe last 4 commits would be much happier if they were wrapped up together\n$ git rebase -i HEAD~4\n\npick 01d1124 Adding license\npick 6340aaa Moving license into its own file\npick ebfd367 Jekyll has become self-aware.\npick 30e0ccb Changed the tagline in the binary, too.\n\n# Rebase 60709da..30e0ccb onto 60709da\n#\n# Commands:\n# p, pick = use commit\n# e, edit = use commit, but stop for amending\n# s, squash = use commit, but meld into previous commit\n#\n# If you remove a line here THAT COMMIT WILL BE LOST.\n# However, if you remove everything, the rebase will be aborted.\n#\n\nrebase using the last four commits from where the HEAD is with HEAD~4.\nWe’re just going to squash everything into one commit.\nSo, changing the first four lines of the file to this will do the trick:\npick 01d1124 Adding license\nsquash 6340aaa Moving license into its own file\nsquash ebfd367 Jekyll has become self-aware.\nsquash 30e0ccb Changed the tagline in the binary, too.\n\n\nBasically this tells Git to combine all four commits into the the first commit in the list. Once this is done and saved, another editor pops up with the following:\n# This is a combination of 4 commits.\n# The first commit's message is:\nAdding license\n\n# This is the 2nd commit message:\n\nMoving license into its own file\n\n# This is the 3rd commit message:\n\nJekyll has become self-aware.\n\n# This is the 4th commit message:\n\nChanged the tagline in the binary, too.\n\n# Please enter the commit message for your changes. Lines starting\n# with '#' will be ignored, and an empty message aborts the commit.\n# Explicit paths specified without -i nor -o; assuming --only paths...\n# Not currently on any branch.\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# new file: LICENSE\n# modified: README.textile\n# modified: Rakefile\n# modified: bin/jekyll\n#\n\n\nSince we’re combining so many commits, Git allows you to modify the new commit’s message based on the rest of the commits involved in the process. Edit the message as you see fit, then save and quit.\nOnce that’s done, your commits have been successfully squashed!\nCreated commit 0fc4eea: Creating license file, and making jekyll self-aware.\n 4 files changed, 27 insertions(+), 30 deletions(-)\n create mode 100644 LICENSE\n Successfully rebased and updated refs/heads/master.\n\nAnd if we look at the history again…\n\n\n\nNote: for \"commit squashing\" purposes, Git1.7 (February 2010) has introduced 2 new elements (as mentioned by Dustin in the comment):\n\n\n\"git rebase -i\" learned new action \"fixup\" that squashes the change but does not affect existing log message.\n\"git rebase -i\" also learned --autosquash option that is useful together with the new \"fixup\" action.\n\n\nBoth (fixup action and --autosquash option) are illustrated in this Thechnosorcery Networks blog entry. Those features have been cooking since last June 2009 and debated further last December.\nThe fixup action or directive is for squashing a commit you would have manually reordered in the commit edit list of a rebase --interactive, while ignoring the second commit message, which will make the message edition step faster (you can just save it: the squashed commit will have the first commit message only)\nThe resulting commit message will only be the first commit one.\n # s, squash = use commit, but meld into previous commit\n # f, fixup = like \"squash\", but discard this commit's log message\n\nThe --autosquash option is about making the commit reordering process automatically for you:\n\nIf you know what commit you want to squash something in to you can commit it with a message of “squash! $other_commit_subject”. Then if you run @git rebase --interactive --autosquash commitish@, the line will automatically be set as squash, and placed below the commit with the subject of $other_commit_subject.\n\n(Actually, the squash! can only use the beginning of another commit message)\n$ vim Foo.txt\n$ git commit -am \"Change all the 'Bar's to 'Foo's\"\n[topic 8374d8e] Change all the 'Bar's to 'Foo's\n 1 files changed, 2 insertions(+), 2 deletions(-)\n$ vim Bar.txt\n$ git commit -am \"Change all the 'Foo's to 'Bar's\"\n[topic 2d12ce8] Change all the 'Foo's to 'Bar's\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\n$ vim Foo.txt\n$ git commit -am \"squash! Change all the 'Bar's\"\n[topic 259a7e6] squash! Change all the 'Bar's\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\nSee? Here the third commit uses only the beginning of the first commit message.\nA rebase --interactive --autosquash will move the squashed commit below the relevant one:\npick 8374d8e Change all the 'Bar's to 'Foo's\nsquash 259a7e6 squash! Change all the 'Bar's\npick 2d12ce8 Change all the 'Foo's to 'Bar's\n\nThe message edition would be:\n# This is a combination of 2 commits.\n# The first commit's message is:\n\nChange all the 'Bar's to 'Foo's\n\n# This is the 2nd commit message:\n\nsquash! Change all the 'Bar's\n\nMeaning by default you would keep the squashing operation recorded in the commit message.\nBut with the fixup! directive, you could keep that squashing \"invisible\" in the commit message, while still benefiting from the automatic commit reordering with the --autosquash option (and the fact that your second commit message is based on the first commit you want to be squashed with).\npick 8374d8e Change all the 'Bar's to 'Foo's\nfixup cfc6e54 fixup! Change all the 'Bar's\npick 2d12ce8 Change all the 'Foo's to 'Bar's\n\nThe message by default will be:\n# This is a combination of 2 commits.\n# The first commit's message is:\n\nChange all the 'Bar's to 'Foo's\n\n# The 2nd commit message will be skipped:\n\n# fixup! Change all the 'Bar's\n\n\nNotice that the fixup! commit’s message is already commented out.\nYou can just save out the message as-is, and your original commit message will be kept.\nVery handy for including changes when you realize that you forgot to add part of an earlier commit.\n\nNow if you want to fixup or squash based on the previous commit you just did, Jacob Helwig (the author of the Technosorcery Networks blog entry) recommends the following aliases:\n[alias]\n fixup = !sh -c 'git commit -m \\\"fixup! $(git log -1 --format='\\\\''%s'\\\\'' $@)\\\"' -\n squash = !sh -c 'git commit -m \\\"squash! $(git log -1 --format='\\\\''%s'\\\\'' $@)\\\"' -\n\nAnd for doing a rebase interactive which will always benefit from the automatic reordering of commits meant to be squashed:\n[alias]\n ri = rebase --interactive --autosquash\n\n\nUpdate for Git 2.18 (Q2 2018): \"git rebase -i\" sometimes left intermediate \"# This is a combination of N commits\" message meant for the human consumption\ninside an editor in the final result in certain corner cases, which\nhas been fixed.\nSee commit 15ef693, commit dc4b5bc, commit e12a7ef, commit d5bc6f2 (27 Apr 2018) by Johannes Schindelin (dscho).\n(Merged by Junio C Hamano -- gitster -- in commit 4a3bf32, 23 May 2018)\n\nrebase --skip: clean up commit message after a failed fixup/squash\n\n\nDuring a series of fixup/squash commands, the interactive rebase builds\nup a commit message with comments. This will be presented to the user in\nthe editor if at least one of those commands was a squash.\nIn any case, the commit message will be cleaned up eventually, removing\nall those intermediate comments, in the final step of such a fixup/squash chain.\nHowever, if the last fixup/squash command in such a chain fails with\nmerge conflicts, and if the user then decides to skip it (or resolve it\nto a clean worktree and then continue the rebase), the current code\nfails to clean up the commit message.\nThis commit fixes that behavior.\nThe fix is quite a bit more involved than meets the eye because it is\nnot only about the question whether we are git rebase --skiping a\nfixup or squash. It is also about removing the skipped fixup/squash's\ncommit message from the accumulated commit message. And it is also about\nthe question whether we should let the user edit the final commit\nmessage or not (\"Was there a squash in the chain that was not\nskipped?\").\nFor example, in this case we will want to fix the commit message, but\nnot open it in an editor:\npick <- succeeds\nfixup <- succeeds\nsquash <- fails, will be skipped\n\nThis is where the newly-introduced current-fixups file comes in real\nhandy. A quick look and we can determine whether there was a non-skipped\nsquash. We only need to make sure to keep it up to date with respect to\nskipped fixup/squash commands. As a bonus, we can even avoid committing\nunnecessarily, e.g. when there was only one fixup, and it failed, and\nwas skipped.\nTo fix only the bug where the final commit message was not cleaned up\nproperly, but without fixing the rest, would have been more complicated\nthan fixing it all in one go, hence this commit lumps together more than\na single concern.\n\n\nGit 2.19 (Q3 2018) fixes a bug: When \"git rebase -i\" is told to squash two or more commits into one, it labeled the log message for each commit with its number.\nIt correctly called the first one \"1st commit\", but the next one was \"commit #1\", which was off-by-one(!).\nSee commit dd2e36e (15 Aug 2018) by Phillip Wood (phillipwood).\n(Merged by Junio C Hamano -- gitster -- in commit 36fd1e8, 20 Aug 2018)\n\nrebase -i: fix numbering in squash message\n\n\nCommit e12a7ef (\"rebase -i: Handle \"combination of <n> commits\" with\nGETTEXT_POISON\", 2018-04-27, Git 2.18) changed the way that individual commit\nmessages are labelled when squashing commits together.\nIn doing so a regression was introduced where the numbering of the messages is off by one. This commit fixes that and adds a test for the numbering.\n\n\nNote: \"git rebase -i\"(man) with a series of squash/fixup, when one of the steps stopped in conflicts and ended up getting skipped, did not handle the accumulated commit log messages, which has been corrected with Git 2.42 (Q3 2023).\nSee commit 6ce7afe (03 Aug 2023) by Phillip Wood (phillipwood).\n(Merged by Junio C Hamano -- gitster -- in commit e8c53ff, 09 Aug 2023)\n\nrebase --skip: fix commit message clean up when skipping squash\nSigned-off-by: Phillip Wood\n\n\nDuring a series of \"fixup\" and/or \"squash\" commands, the interactive rebase accumulates a commit message from all the commits that are being squashed together.\nIf one of the commits has conflicts when it is picked and the user chooses to skip that commit then we need to remove that commit's message from accumulated messages.\nTo do this 15ef693 (\"rebase --skip: clean up commit message after a failed fixup/squash\", 2018-04-27, Git v2.18.0-rc0 -- merge listed in batch #6) updated commit_staged_changes() to reset the accumulated message to the commit message of HEAD (which does not contain the message from the skipped commit) when the last command was \"fixup\" or \"squash\" and there are no staged changes.\nUnfortunately the code to do this contains two bugs.\n\nIf parse_head() fails we pass an invalid pointer to\nunuse_commit_buffer().\n\nThe reconstructed message uses the entire commit buffer from HEAD\nincluding the headers, rather than just the commit message.\n\n\nThe first issue is fixed by splitting up the \"if\" condition into several statements each with its own error handling.\nThe second issue is fixed by finding the start of the commit message within the commit buffer using find_commit_subject().\nThe existing test added by 15ef693 is modified to show the effect of this bug.\nThe bug is triggered when skipping the first command in the chain (as the test does before this commit) but the effect is hidden because opts->current_fixup_count is set to zero which leads update_squash_messages() to recreate the squash message file from scratch overwriting the bad message created by commit_staged_changes().\nThe test is also updated to explicitly check the commit messages rather than relying on grep to ensure they do not contain any stray commit headers."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_CONFIG_NOSYSTEM"}, {"role": "assistant", "content": "Whether to skip reading settings from the system-wide $(prefix)/etc/gitconfig file. This Boolean environment variable can\nbe used along with $HOME and $XDG_CONFIG_HOME to create a\npredictable environment for a picky script, or you can set it\nto true to temporarily avoid using a buggy /etc/gitconfig file while\nwaiting for someone with sufficient permissions to fix it."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "\"fatal: corrupt patch at line XX\" when staging single line\nI'm getting the following error when I'm trying to stage a single line or multiple lines using the git gui (right click -> stage lines for commit). It's not the first time it occure to me, and I've found others facing it.However I couldn't find how to solve it.\nDid any one ever encountered this problem? is there something I can do (staging all the file is not a real solution)\nUpdate:\nHere is a file which gives me the following error when I try to stage the deleted line.\n@@ -1,7 +1,6 @@\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<bitmap xmlns:android=\"http://schemas.android.com/apk/res/android\" \n android:src=\"@drawable/texture\"\n android:tileMode=\"repeat\"\n- android:dither=\"true\"\n >\n</bitmap>\n\\ No newline at end of file\n\nHere is the error message:\nfatal: corrupt patch at line 14\n\nstrangely the following fine doesn't even have 14 line!? note ending file with a new line didn't solve the problem"}, {"role": "assistant", "content": "Apparently Git GUI requires that files end with a newline when staging individual lines.\nI'm pretty sure that at at least one point in time, staging individual lines was ok even without a newline at the end of the file, but apparently that's no longer possible. Just ran into this problem myself, having newlines at the end of the file fixes it, and removing them causes it."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker"}, {"role": "assistant", "content": "NAME git - the stupid content tracker"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %f"}, {"role": "assistant", "content": "sanitized subject line, suitable for a filename"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to merge remote changes at GitHub?\n\nI'm getting following error, whn trying first Github push:\n[rejected] master -> master (non-fast forward)\nerror: failed to push some refs to '[email protected]:me/me.git'\nTo prevent you from losing history, non-fast-forward updates were rejected\nMerge the remote changes before pushing again. See the 'non-fast forward'\nsection of 'git push --help' for details.\n\nhow can I fix this and merge remote changes?"}, {"role": "assistant", "content": "See the 'non-fast forward' section of 'git push --help' for details.\n\nYou can perform \"git pull\", resolve potential conflicts, and \"git push\" the result. A \"git pull\" will create a merge commit C between commits A and B.\nAlternatively, you can rebase your change between X and B on top of A, with \"git pull --rebase\", and push the result back. The rebase will create a new commit D that builds the change between X and B on top of A."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %gd"}, {"role": "assistant", "content": "shortened reflog selector; same as %gD , but the refname\nportion is shortened for human readability (so refs/heads/master becomes just master )."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs -z"}, {"role": "assistant", "content": "Separate the commits with NULs instead of newlines. Also, when --raw or --numstat has been given, do not munge\npathnames and use NULs as output field terminators. Without this option, pathnames with \"unusual\" characters are quoted as\nexplained for the configuration variable core.quotePath (see git-config )."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_OBJECT_DIRECTORY"}, {"role": "assistant", "content": "If the object storage directory is specified via this\nenvironment variable then the sha1 directories are created\nunderneath - otherwise the default $GIT_DIR/objects directory is used."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --to=<email>"}, {"role": "assistant", "content": "Add a To: header to the email headers. This is in addition\nto any configured headers, and may be used multiple times.\nThe negated form --no-to discards all To: headers added so\nfar (from config or command line)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --line-prefix=<prefix>"}, {"role": "assistant", "content": "Prepend an additional prefix to every line of output."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why did my Git repo enter a detached HEAD state?\nI ended up with a detached head today, the same problem as described in: git push says everything up-to-date even though I have local changes\nAs far as I know I didn't do anything out of the ordinary, just commits and pushes from my local repo. \nSo how did I end up with a detached HEAD?"}, {"role": "assistant", "content": "Any checkout of a commit that is not the name of one of your branches will get you a detached HEAD. A SHA1 which represents the tip of a branch still gives a detached HEAD. Only a checkout of a local branch name avoids that mode.\nSee committing with a detached HEAD\n\nWhen HEAD is detached, commits work like normal, except no named branch gets updated. (You can think of this as an anonymous branch.)\n\n\nFor example, if you checkout a \"remote branch\" without tracking it first, you can end up with a detached HEAD.\nSee git: switch branch without detaching head\nMeaning: git checkout origin/main (or origin/master in the old days) would result in:\nNote: switching to 'origin/main'.\n\nYou are in 'detached HEAD' state. You can look around, make experimental\nchanges and commit them, and you can discard any commits you make in this\nstate without impacting any branches by switching back to a branch.\n\nIf you want to create a new branch to retain commits you create, you may\ndo so (now or later) by using -c with the switch command. Example:\n\n git switch -c <new-branch-name>\n\nOr undo this operation with:\n\n git switch -\n\nTurn off this advice by setting config variable advice.detachedHead to false\n\nHEAD is now at a1b2c3d My commit message\n\nThat is why you should not use git checkout anymore, but the new git switch command.\nWith git switch, the same attempt to \"checkout\" (switch to) a remote branch would fail immediately:\ngit switch origin/main\nfatal: a branch is expected, got remote branch 'origin/main'\n\n\nTo add more on git switch:\nWith Git 2.23 (August 2019), you don't have to use the confusing git checkout command anymore.\ngit switch can also checkout a branch, and get a detach HEAD, except:\n\nit has an explicit --detach option\n\n\nTo check out commit HEAD~3 for temporary inspection or experiment without creating a new branch:\ngit switch --detach HEAD~3\nHEAD is now at 9fc9555312 Merge branch 'cc/shared-index-permbits'\n\n\n\nit cannot detached by mistake a remote tracking branch\n\nSee:\nC:\\Users\\vonc\\arepo>git checkout origin/master\nNote: switching to 'origin/master'.\n\nYou are in 'detached HEAD' state. You can look around, make experimental\nchanges and commit them, and you can discard any commits you make in this\nstate without impacting any branches by switching back to a branch.\n\nVs. using the new git switch command:\nC:\\Users\\vonc\\arepo>git switch origin/master\nfatal: a branch is expected, got remote branch 'origin/master'\n\nIf you wanted to create a new local branch tracking a remote branch:\ngit switch <branch> \n\n\nIf <branch> is not found but there does exist a tracking branch in exactly one remote (call it <remote>) with a matching name, treat as equivalent to\ngit switch -c <branch> --track <remote>/<branch>\n\n\nNo more mistake!\nNo more unwanted detached HEAD!\nAnd if you git switch <tag> instead of git switch --detach <tag>, Git 2.36 will help you to remember the missing --detach option."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-imap-send"}, {"role": "assistant", "content": "Send a collection of patches from stdin to an IMAP folder"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --no-prefix"}, {"role": "assistant", "content": "Do not show any source or destination prefix."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -0"}, {"role": "assistant", "content": "Omit diff output for unmerged entries and just show\n\"Unmerged\". Can be used only when comparing the working tree\nwith the index."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --no-diff-merges"}, {"role": "assistant", "content": "Synonym for --diff-merges=off ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-help - Display help information about Git -m --man"}, {"role": "assistant", "content": "Display manual page for the command in the man format. This\noption may be used to override a value set in the help.format configuration variable. By default the man program will be used to display the manual page,\nbut the man.viewer configuration variable may be used to choose\nother display programs (see below)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to squash commits in git after they have been pushed?\nThis gives a good explanation of squashing multiple commits:\nhttp://git-scm.com/book/en/Git-Branching-Rebasing\nbut it does not work for commits that have already been pushed. How do I squash the most recent few commits both in my local and remote repos?\nWhen I do git rebase -i origin/master~4 master, keep the first one as pick, set the other three as squash, and then exit (via c-x c-c in emacs), I get:\n$ git rebase -i origin/master~4 master\n# Not currently on any branch.\nnothing to commit (working directory clean)\n\nCould not apply 2f40e2c... Revert \"issue 4427: bpf device permission change option added\"\n$ git rebase -i origin/master~4 master\nInteractive rebase already started\n\nwhere 2f40 is the pick commit. And now none of the 4 commits appear in git log. I expected my editor to be restarted so that I could enter a commit message. What am I doing wrong?"}, {"role": "assistant", "content": "Squash commits locally with:\ngit rebase -i origin/master~4 master\n\nwhere ~4 means the last 4 commits.\nThis will open your default editor. Here, replace pick in the second, third, and fourth lines (since you are interested in the last 4 commits) with squash. The first line (which corresponds to the newest commit) should be left with pick. Save this file.\nAfterwards, your editor will open again, showing the messages of each commit. Comment the ones you are not interested in (in other words, leave the commit message that will correspond to this squashing uncommented). Save the file and close it.\nYou will than need to push again with the -f flag.\nand then force push with :\ngit push origin +master\n\n\nDifference between --force and +\nFrom the documentation of git push:\n\nNote that --force applies to all the refs that are pushed, hence using\nit with push.default set to matching or with multiple push\ndestinations configured with remote.*.push may overwrite refs other\nthan the current branch (including local refs that are strictly behind\ntheir remote counterpart). To force a push to only one branch, use a +\nin front of the refspec to push (e.g git push origin +master to force\na push to the master branch)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to add a new project to Github using VS Code\n\nAll the tutorials i've seen till now shows to first create a repository on github, copy the link go to vscode and git clone it and from that on, you can do commits and pushes.\nIs that the right way ? can't I just start a project from vscode and then upload it to my git ?\nEDIT 2020 :\nYou can now do it right inside vscode! just follow these steps:\n1- Open your new project folder with vscode\n2- click on the source conrol menu on the sidebar (or press Ctrl+Shift+G)\n3- Click on publish to github \n4- From there just login and follow the instructions and you're good to go.\n@Debu's answer details every step, so you can jump to there"}, {"role": "assistant", "content": "Here are the detailed steps needed to achieve this.\nThe existing commands can be simply run via the CLI terminal of VS-CODE. It is understood that Git is installed in the system, configured with desired username and email Id.\n\nNavigate to the local project directory and create a local git repository:\ngit init\n\nOnce that is successful, click on the 'Source Control' icon on the left navbar in VS-Code.One should be able to see files ready to be commit-ed. Press on 'Commit' button, provide comments, stage the changes and commit the files. Alternatively you can run from CLI\ngit commit -am \"Your comment\"\n\nNow you need to visit your GitHub account and create a new Repository. Exclude creating 'README.md', '.gitIgnore' files. Also do not add any License to the repo. Sometimes these settings cause issue while pushing in.\n\nCopy the link to this newly created GitHub Repository.\n\nCome back to the terminal in VS-CODE and type these commands in succession:\ngit remote add origin <Link to GitHub Repo> //maps the remote repo link to local git repo\ngit remote -v //this is to verify the link to the remote repo\ngit push -u origin master // pushes the commit-ed changes into the remote repo\n\n\n\nNote: If it is the first time the local git account is trying to\nconnect to GitHub, you may be required to enter credentials to GitHub in a separate window.\n\n\nYou can see the success message in the Terminal. You can also verify by refreshing the GitHub repo online."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Publish to S3 using Git?\nDoes anyone know how to do this? So far I haven't been able to find anything useful via Google.\nI'd really like to setup a local repo and use git push to publish it to S3, the idea being to have local version control over assets but remote storage on S3.\nCan this be done, and if so, how?"}, {"role": "assistant", "content": "1 Use JGit via http://blog.spearce.org/2008/07/using-jgit-to-publish-on-amazon-s3.html\nDownload jgit.sh, rename it to jgit and put it in your path (for example $HOME/bin).\nSetup the .jgit config file and add the following (substituting your AWS keys):\n$vim ~/.jgit\naccesskey: aws access key\nsecretkey: aws secret access key\n\nNote, by not specifying acl: public in the .jgit file, the git files on S3 will be private (which is what we wanted). Next create an S3 bucket to store your repository in, let’s call it git-repos, and then create a git repository to upload:\ns3cmd mb s3://git-repos\nmkdir chef-recipes\ncd chef-recipes\ngit init\ntouch README\ngit add README\ngit commit README\ngit remote add origin amazon-s3://.jgit@git-repos/chef-recipes.git\n\nIn the above I’m using the s3cmd command line tool to create the bucket but you can do it via the Amazon web interface as well. Now let’s push it up to S3 (notice how we use jgit whenever we interact with S3, and standard git otherwise):\njgit push origin master\n\nNow go somewhere else (e.g. cd /tmp) and try cloning it:\njgit clone amazon-s3://.jgit@git-repos/chef-recipes.git\n\nWhen it comes time to update it (because jgit doesn’t support merge or pull) you do it in 2 steps:\ncd chef-recipes\njgit fetch\ngit merge origin/master\n\n2 Use FUSE-based file system backed by Amazon S3\n\nGet an Amazon S3 account!\nDownload, compile and install. (see InstallationNotes)\nSpecify your Security Credentials (Access Key ID & Secret Access\nKey) by one of the following methods:\n\nusing the passwd_file command line option\nsetting the AWSACCESSKEYID and AWSSECRETACCESSKEY environment variables\nusing a .passwd-s3fs file in your home directory\nusing the system-wide /etc/passwd-s3fs file\ndo this\n\n\n.\n/usr/bin/s3fs mybucket /mnt\n\nThat's it! the contents of your amazon bucket \"mybucket\" should now be accessible read/write in /mnt"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to set default remote in git?\nI have multiple remotes in my git repository. If I execute git pull, then it asks for the password of one of my colleagues.\nHow can I change the remote to black?"}, {"role": "assistant", "content": "Edit: Thanks for all the upvotes!\nIn addition to the accepted answer to this question from @axiac that describes how to set the remote repository for an existing branch in your local copy, I felt it would be worthwhile to expand on this, by noting that while a default remote cannot be setup for git pull, a default remote can be set for git checkout in your repository using the checkout.defaultRemote setting. This way, git checkout some-branch, git push, and git pull will all Just Work™ the way you intended, without specifying or thinking about the remote name at all. Read on for a full explanation.\nNote to OP: In my examples below I'm going to use the remote name origin instead of your specific remote named black because for most people, the default origin remote is the one you'd want to setup like this. For your purposes though, just replace any instance of origin with black.\nSimplify your branch checkout process:\nFirst, you'd type the following in the console:\ngit config checkout.defaultRemote origin\n\nThis command adds the following section to your repository's .git/config file:\n[checkout]\n defaultRemote = origin\n\nNow, with a default branch configured, each time you want to setup a new local copy of a remote branch that exists on the \"origin\" remote repository, you only need to type:\ngit checkout some-branch\n\nAnd git will assume you actually meant:\ngit checkout --track origin/some-branch\n\nWhich can also be shortened to:\ngit checkout -u origin/some-branch\n\nThis is an amazing lifehack. It is a much smarter alternative method of setting up a local copy than the solution mentioned above with git checkout -b some-branch and is so very useful when you actually know that the branch already exists on one or more remotes. Particularly, if you're working with multiple remotes and not using defaultRemote, you would need to type the long form git checkout --track origin/branch-name each time you checkout a branch, because git doesn't know from which remote it should track. Save yourself a headache and just set this up always. (See final thoughts below for a suggested approach).\nSimplify your git push and git pull process:\nAs hinted at above, having your local branches auto-configured to track from the defaultRemote means that when you need to do a git pull while on some branch you checked out, git already knows exactly which remote to pull from. This is very, very helpful.\nNote: if the local branch tracks one remote and you want to pull code from a different remote, or if the local branch is not setup to track a remote at all, then you can either:\n\nmanually specify the correct remote to pull from:\n git pull <remote-name>\n\nThis must be done each time you want to pull from the remote.\n\nfix the remote tracking branch permanently on a branch-by-branch basis using:\n git branch --set-upstream-to <remote-name/branch-name>\n\nOR\n git config branch.<branch-name>.remote <remote-name>\n git config branch.<branch-name>.merge refs/heads/<branch-name>\n\nThis is a one-time change; all subsequent git pull commands should now pull from the remote/branch you specified.\n\n\nCaveats and implications:\nFor git config checkout.defaultRemote origin to be of any real benefit for a git pull command scenario, this command/configuration needs to be set up when you first start working on a project with multiple remotes, or as soon as you start adding additional remotes. The reason is because this configuration will only have an effect on branches you're going to check out after having set this configuration; it doesn't have any effect on existing branches. In which case, all existing local branches that don't already track from a specific remote will need to be modified separately to add the intended remote before a simple git pull will work.\nFinal thoughts\nIf you find yourself hitting this issue often on various projects, a more comprehensive setting would be to work under the convention that the default remote should always be added as the \"origin\" remote in all your projects. You can then set this configuration globally with:\ngit config --global checkout.defaultRemote origin"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "When to use git subtree?\nWhat problem does git subtree solve?\nWhen and why should I use that feature?\nI've read that it is used for repository separation. But why would I not just create two independent repositories instead of sticking two unrelated ones into one?\nThis GitHub tutorial explains how to perform Git subtree merges.\nI kind of know how to use it, but not when (use cases) and why, and how it relates to git submodule. I'd use submodules when I have a dependency on another project or library."}, {"role": "assistant", "content": "You should be careful to note explicitly what you are talking about when you use the term 'subtree' in the context of git as there are actually two separate but related topics here: \ngit-subtree and git subtree merge strategy.\nThe TL;DR\nBoth subtree related concepts effectively allow you to manage multiple repositories in one. In contrast to git-submodule where only metadata is stored in the root repository, in the form of .gitmodules, and you must manage the external repositories separately.\nMore Details\ngit subtree merge strategy is basically the more manual method using the commands you referenced.\ngit-subtree is a wrapper shell script to facilitate a more natural syntax. This is actually still a part of contrib and not fully integrated into git with the usual man pages. The documentation is instead stored along side the script.\nHere is the usage info:\nNAME\n----\ngit-subtree - Merge subtrees together and split repository into subtrees\n\n\nSYNOPSIS\n--------\n[verse]\n'git subtree' add -P <prefix> <commit>\n'git subtree' add -P <prefix> <repository> <ref>\n'git subtree' pull -P <prefix> <repository> <ref>\n'git subtree' push -P <prefix> <repository> <ref>\n'git subtree' merge -P <prefix> <commit>\n'git subtree' split -P <prefix> [OPTIONS] [<commit>]\n\nI have come across a pretty good number of resources on the subject of subtrees, as I was planning on writing a blog post of my own. I will update this post if I do, but for now here is some relevant information to the question at hand:\nMuch of what you are seeking can be found on this Atlassian blog by Nicola Paolucci the relevant section below:\n\nWhy use subtree instead of submodule?\nThere are several reasons why\n you might find subtree better to use:\n\nManagement of a simple workflow is easy. \nOlder version of git are supported (even before v1.5.2). \nThe sub-project’s code is available right after the clone of the super project is done. \nsubtree does not require users of your repository to learn anything new, they can ignore the fact that you are using subtree to manage dependencies.\nsubtree does not add new metadata files like submodules does (i.e.\n .gitmodule). \nContents of the module can be modified without having a\n separate repository copy of the dependency somewhere else. \n\nIn my opinion the drawbacks are acceptable:\n\nYou must learn about a new merge strategy (i.e. subtree). \nContributing code back upstream for the sub-projects is slightly more complicated.\nThe responsibility of not mixing super and sub-project code in commits lies with you.\n\n\nI would agree with much of this as well. I would recommend checking out the article as it goes over some common usage.\nYou may have noticed that he has also written a follow up here where he mentions an important detail that is left off with this approach... \ngit-subtree currently fails to include the remote!\nThis short sightedness is probably due to the fact that people often add a remote manually when dealing with subtrees, but this isn't stored in git either. The author details a patch he has written to add this meta data to the commit that git-subtree already generates. Until this makes it into the official git mainline you could do something similar by modifying the commit message or storing it in another commit.\nI also find this blog post very informative as well. The author adds a third subtree method he calls git-streeto the mix. The article is worth a read as he does a pretty good job of comparing the three approaches. He gives his personal opinion of what he does and doesn't like and explains why he created the third approach.\nExtras\n\nlisting git-subtrees\nDetach Subdirectory\n\nClosing Thoughts\nThis topic shows both the power of git and the segmentation that can occur when a feature just misses the mark. \nI personally have built a distaste for git-submodule as I find it more confusing for contributors to understand. I also prefer to keep ALL of my dependencies managed within my projects to facilitate an easily reproducible environment without trying to manage multiple repositories. git-submodule, however, is much more well known currently so it is obviously good to be aware of it and depending on your audience that may sway your decision."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I reset the git master branch to the upstream branch in a forked repository?\nI've completely messed up the master branch of my forked git repo.\nI want to completely reset the master branch that was pushed to my fork with the contents of the upstream master repo. I have no interest in retaining any master branch changes or history.\nThe simplest approach would have been to delete my forked repo and refork from the upstream project. However, I have work in other pushed branches that I don't want to lose.\nThus how to I reset my pushed master branch with the upstream master?\n\ngit clone https://myrepo.git\ncd myrepo\ngit remote add upstream https://upstream.git\ngit fetch upstream\n\nWhere do I go from here to reset my local and remote master branches with the upstream master?"}, {"role": "assistant", "content": "You can reset your local master branch to the upstream version and push it to your origin repository.\nAssuming that \"upstream\" is the original repository and \"origin\" is your fork:\n# ensures current branch is master\ngit checkout master\n\n# pulls all new commits made to upstream/master\ngit pull upstream master\n\n# this will delete all your local changes to master\ngit reset --hard upstream/master\n\n# take care, this will delete all your changes on your forked master\ngit push origin master --force\n\n(You can define the original repo as \"upstream\" with git remote add upstream /url/to/original/repo.)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --show-pulls"}, {"role": "assistant", "content": "In addition to the commits shown in the default history, show\neach merge commit that is not TREESAME to its first parent but\nis TREESAME to a later parent. When a merge commit is included by --show-pulls , the merge is\ntreated as if it \"pulled\" the change from another branch. When using --show-pulls on this example (and no other options) the resulting\ngraph is: I---X---R---N Here, the merge commits R and N are included because they pulled\nthe commits X and R into the base branch, respectively. These\nmerges are the reason the commits A and B do not appear in the\ndefault history. When --show-pulls is paired with --simplify-merges , the\ngraph includes all of the necessary information: .-A---M--. N\n\t / / \\ /\n\tI B R\n\t \\ / /\n\t \\ / /\n\t `---X--' Notice that since M is reachable from R , the edge from N to M was simplified away. However, N still appears in the history as an\nimportant commit because it \"pulled\" the change R into the main\nbranch."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to back up private branches in git\nI have a local branch for day-to-day dev work in git. My workflow is:\n\nDo stuff on local_branch, commit\nFetch origin/master \nRebase local_branch to catch up with new stuff from origin/master\n\nIt all works fine, however most of the recommendations I encountered say that one should not \"push\" private branches, on which rebase is regularly performed.\nThe problem here is that in this case local branch is not backed up to a server and the only way to save the work is to merge it back to \"pushable\" branch (i.e. origin/master)\nWhat would be your recommendations on the workflow in this case? \nThanks!\nUPDATE: I realised that one of the original requirements I had (avoiding usage of external utilities) is unnecessary limiting.\nMy current solution is to store all my repositories in a cloud-synchronised folder - this way I get backup for free."}, {"role": "assistant", "content": "I use the --mirror option and push to a personal backup repository:\nAdd it as a remote:\ngit remote add bak server:/path/to/backup/repo\n\nDo the backup:\ngit push --mirror bak\n\nThis will automatically make your backup repository look like your active one -- branches will be created, deleted, updated (even forced/non-fastforwards) as needed. You can make an alias for this too:\ngit config alias.bak \"push --mirror bak\"\n\nThen, it's just a matter of running \"git bak\" when you want to do a backup. You could also throw this into a cron job."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to find a commit by its hash?\nI need to find a commit in Git by a given hash, SHA. For example, if I have the \"a2c25061\" hash, and I need to get the author and the committer of this commit. \nWhat is the command to get that?"}, {"role": "assistant", "content": "Just use the following command\ngit show a2c25061"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects porcelain"}, {"role": "assistant", "content": "Use a special line-based format intended for script\nconsumption. Added/removed/unchanged runs are printed in the\nusual unified diff format, starting with a + / - /` `\ncharacter at the beginning of the line and extending to the\nend of the line. Newlines in the input are represented by a\ntilde ~ on a line of its own."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-add - Add file contents to the index"}, {"role": "assistant", "content": "DESCRIPTION This command updates the index using the current content found in\nthe working tree, to prepare the content staged for the next commit.\nIt typically adds the current content of existing paths as a whole,\nbut with some options it can also be used to add content with\nonly part of the changes made to the working tree files applied, or\nremove paths that do not exist in the working tree anymore. The \"index\" holds a snapshot of the content of the working tree, and it\nis this snapshot that is taken as the contents of the next commit. Thus\nafter making any changes to the working tree, and before running\nthe commit command, you must use the add command to add any new or\nmodified files to the index. This command can be performed multiple times before a commit. It only\nadds the content of the specified file(s) at the time the add command is\nrun; if you want subsequent changes included in the next commit, then\nyou must run git add again to add the new content to the index. The git status command can be used to obtain a summary of which\nfiles have changes that are staged for the next commit. The git add command will not add ignored files by default. If any\nignored files were explicitly specified on the command line, git add will fail with a list of ignored files. Ignored files reached by\ndirectory recursion or filename globbing performed by Git (quote your\nglobs before the shell) will be silently ignored. The git add command can\nbe used to add ignored files with the -f (force) option. Please see git-commit for alternative ways to add content to a\ncommit."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Viewing Git history of moved files\nDespite reading lots of other posts regarding GIT and moved files I still struggle to understand how to trace the full history. Doing gitk myfile as suggested here seems to only show history until the previous move. I understand that GIT doesn't track files, only their content. So surely I should be able to view the full evolution of a file, even if it's been moved?\nCan anyone direct me to a good yet simple example/tutorial?\nI'd like to see an example where some files are moved around, changed and committed, then the history of a single file is displayed, moves and all. I've been looking at 'log' but that seems to concern checkins. Would still appreciate some advice, even if its says I'm somehow still thinking too much SVN."}, {"role": "assistant", "content": "Try using the --follow option to git log:\ngit log --follow file.txt"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can a deleted GitLab branch be restored?\n\nThere is a Git branch which was deleted by GitLab when closing a merge request. I would like to restore (undelete) that branch; however, I'm not seeing an option in the UI to do so.\nIn GitHub it is possible to restore a branch deleted by a pull request after the fact (via the \"Restore branch\" button on the pull request). I'm wondering if GitLab has an analogous feature for closed merge requests.\nI can of course do this manually through the Git command line, checking out the last commit hash for the deleted branch, and pushing it back up to the deleted branch name. However, I would rather use the UI for something like this if it exists.\nHow can I restore a branch which GitLab deleted when closing a merge request?"}, {"role": "assistant", "content": "Restoring a deleted branch is an open issue, so GitLab has not implemented this feature at the time of this writing.\nHowever, if you know the commit ID (and it hasn't been pruned), you can create a new branch from that commit:\n\nFrom the Web UI, go to Repository > Commits\nFind the commit you want and copy the SHA to your clipboard\nGo to Repository > Branches\nClick \"New Branch\"\nEnter a branch name\nClick the \"Create from\" drop-down menu and enter the commit SHA. Press enter to apply it.\nClick \"Create Branch\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What are these ^M's that keep showing up in my files in emacs?\nI think it may have to do with TextMate, but we work in a small team and are having some issues with full-file conflicts of nearly identical files in git – in one branch the files have a ^M appended to each line.\nWhat is this mysterious ^M character supposed to do, and where could it be coming from?\nOur developers use emacs on Windows/Mac, TextMate on Mac, coda on Mac, and occasionally the wp-admin text editor.\nDid anybody ever have this issue stemming from one of those?"}, {"role": "assistant", "content": "In git-config, set core.autocrlf to true to make git automatically convert line endings correctly for your platform, e.g. run this command for a global setting:\ngit config --global core.autocrlf true"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker --man-path"}, {"role": "assistant", "content": "Print the manpath (see man(1) ) for the man pages for\nthis version of Git and exit."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Installing non-public packages from Gitlab using devtools::install_git\n\nMy institution recently installed GitLab for us. I've figured out how to install R packages from the GitLab server using devtools::install_git and it works as long as the project is public.\n#* When modeltable project has Public status\ndevtools::install_git('https://mini-me2.lerner.ccf.org/nutterb/modeltable.git')\n\nHowever, if I have a package that is listed as either \"Internal\" or \"Private,\" I can't install the package without some form of authentication. As of yet, I haven't figured out how to pass authentication via the URL. Does anyone have experience with downloading packages from GitLab?\n#* After changing the 'modeltable' project to Private status\ndevtools::install_git('https://mini-me2.lerner.ccf.org/nutterb/modeltable.git')\nPreparing installation of modeltable using the Git-URL: https://mini-me2.lerner.ccf.org/nutterb/modeltable.git\n'/usr/bin/git'clone --depth 1 --no-hardlinks https://mini-me2.lerner.ccf.org/nutterb/modeltable.git /tmp/Rtmp5aj1cU/file24493dc03a32\nError: There seems to be a problem retrieving this Git-URL."}, {"role": "assistant", "content": "I'd highly recommend going the SSH route, and the below works for that. I found making the leap to SSH was easy, especially with R and RStudio. I'm using Windows in the below example. Edits from code I use in practice are in all caps.\ncreds = git2r::cred_ssh_key(\"C:\\\\Users\\\\MYSELF\\\\.ssh\\\\id_rsa.pub\",\n \"C:\\\\Users\\\\MYSELF\\\\.ssh\\\\id_rsa\")\ndevtools::install_git(\"[email protected]:GITLABGROUP/PACKAGE.git\",\n credentials = creds)\n\nTwo quick additional comments: \n\ngit2r is imported with devtools, you shouldn't need to install it separately.\nAlso I don't think this should need mentioning, but passwords in plaintext in your script is a very bad idea."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Move branch to another branch\nI have started doing some work on a branch which I have in term realised was the wrong branch. Is there a way to move a branch to a different branch.\nFor example:\nA -- B -- C -- D -- HEAD\n \\-- E -- F -- G -- H -- I -- J\n \\-- K -- L\n\nAnd I want this:\nA -- B -- C -- D -- HEAD\n \\ \\-- K -- L\n \\\n \\-- E -- F -- G -- H -- I -- J"}, {"role": "assistant", "content": "Let's say you've named your branches like so:\n A -- B -- C -- D (master)\n \\-- E -- G -- H -- I -- J (current-parent)\n \\-- K -- L (my-branch)\n\nWhat you want to do is rebase my-branch onto the B commit like so:\n git rebase current-parent my-branch --onto B"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Gitlab Shell Script Permission Denied\n\nI am running a simple shell script with Gitlab CICD and I am getting Permission denied. Kindly suggest\nWhen I do chmod +x test.sh it says operation not permitted.\nstages:\n - build \n\nbuild: \n stage: build \n script: \n - ls\n - ./test.sh\n\nShell test.sh\necho Hi\n\nError:"}, {"role": "assistant", "content": "Instead of simply running chmod on your local system, it's better to run git update-index --chmod=+x path/to/file. This adds an executable flag to a file in Git and should ensure that a script can be executed inside a GitLab pipeline.\nSee also this question."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is git's semi-secret empty tree object reliable, and why is there not a symbolic name for it?\nGit has a well-known, or at least sort-of-well-known, empty tree whose SHA1 is:\n4b825dc642cb6eb9a060e54bf8d69288fbee4904\n\n(you can see this in any repo, even a newly created one, with git cat-file -t and git cat-file -p). [Edit made in 2020: the SHA-256 empty tree hash ID is:\n6ef19b41225c5369f1c104d45d8d85efa9b057b53b14b4b9b939dd74decc5321\n\nas VonC mentions in his answer. My question was apparently about 8 years early. 😀]\nIf you work hard and are very careful you can sort of use this empty tree to store a directory that has no files (see answer to How do I add an empty directory to a git repository), although it's not really a great idea.\nIt's more useful as one argument to git diff-tree, which one of the sample hooks does.\nWhat I'm wondering is,\n\nhow reliable is this—i.e., will some future version of git not have a git object numbered 4b825dc642cb6eb9a060e54bf8d69288fbee4904?\nWhy is there no symbolic name for the empty tree (or is there one?).\n\n(A quick and dirty way to create a symbolic name is to put the SHA1 in, e.g., .git/Nulltree. Unfortunately you have to do this for every repo. Seems better to just put the magic number in scripts, etc. I just have a general aversion to magic numbers.)"}, {"role": "assistant", "content": "This thread mentions:\n\nIf you don't remember the empty tree sha1, you can always derive it with:\n\ngit hash-object -t tree /dev/null\n\nOr, as Ciro Santilli proposes in the comments:\nprintf '' | git hash-object --stdin -t tree\n\nOr, as seen here, from Colin Schimmelfing:\ngit hash-object -t tree --stdin < /dev/null\n\nSo I guess it is safer to define a variable with the result of that command as your empty sha1 tree (instead of relying of a \"well known value\").\nNote: Git 2.25.1 (Feb. 2020) proposes in commit 9c8a294:\nempty_tree=$(git mktree </dev/null)\n\n# Windows (Command Prompt):\ngit mktree <NUL\n\n# Windows (PowerShell):\n$null | git mktree\n\nAnd adds:\n\nAs a historical note, the function now known as repo_read_object_file() was taught the empty tree in 346245a1bb (\"hard-code the empty tree object\", 2008-02-13, Git v1.5.5-rc0 -- merge), and the function now known as oid_object_info() was taught the empty tree in c4d9986f5f (\"sha1_object_info: examine cached_object store too\", 2011-02-07, Git v1.7.4.1).\n\n\nNote, you will see that SHA1 pop up on some GitHub repo when the author wants its first commit to be empty (see blog post \"How I initialize my Git repositories\"):\n$ GIT_AUTHOR_DATE=\"Thu, 01 Jan 1970 00:00:00 +0000\" GIT_COMMITTER_DATE=\"Thu, 01 Jan 1970 00:00:00 +0000\" git commit --allow-empty -m 'Initial commit'\n\nWill give you:\n\n(See the tree SHA1?)\nYou can even rebase your existing history on top of that empty commit (see \"git: how to insert a commit as the first, shifting all the others?\")\nIn both cases, you don't rely on the exact SHA1 value of that empty tree.\nYou simply follow a best practice, initializing your repo with a first empty commit.\n\nTo do that:\ngit init my_new_repo\ncd my_new_repo\ngit config user.name username\ngit config user.email email@com\n\ngit commit --allow-empty -m \"initial empty commit\"\n\nThat will generate a commit with a SHA1 specific to your repo, username, email, date of creation (meaning the SHA1 of the commit itself will be different every time).\nBut the tree referenced by that commit will be 4b825dc642cb6eb9a060e54bf8d69288fbee4904, the empty tree SHA1.\ngit log --pretty=raw\n\ncommit 9ed4ff9ac204f20f826ddacc3f85ef7186d6cc14\ntree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 <====\nauthor VonC <[email protected]> 1381232247 +0200\ncommitter VonC <[email protected]> 1381232247 +0200\n\n initial empty commit\n\nTo show just the tree of a commit (display the commit tree SHA1):\ngit show --pretty=format:%T 9ed4ff9ac204f20f826ddacc3f85ef7186d6cc14\n4b825dc642cb6eb9a060e54bf8d69288fbee4904\n\nIf that commit, referencing an empty tree, is indeed your first commit, you can show that empty tree SHA1 with:\ngit log --pretty=format:%h --reverse | head -1 | xargs git show --pretty=format:%T\n4b825dc642cb6eb9a060e54bf8d69288fbee4904\n\n(and that even works on Windows, with Gnu On Windows commands)\n\nAs commented below, using git diff <commit> HEAD, this will show all your file in the current branch HEAD:\ngit diff --name-only 4b825dc642cb6eb9a060e54bf8d69288fbee4904 HEAD\n\n\nNote: that empty tree value is formally defined in cache.h.\n#define EMPTY_TREE_SHA1_HEX \\\n \"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"\n\nSince Git 2.16 (Q1 2018), it is used in a structure which is no longer tied to (only) SHA1, as seen in commit eb0ccfd:\n\nSwitch empty tree and blob lookups to use hash abstraction\n\n\nSwitch the uses of empty_tree_oid and empty_blob_oid to use the current_hash abstraction that represents the current hash algorithm in\nuse.\n\nSee more at \"Why doesn't Git use more modern SHA?\": it is SHA-2, since Git 2.19 (Q3 2018)\n\nWith Git 2.25 (Q1 2020), tests are preparing for a SHA-2 transition, and is involving the empty tree.\nSee commit fa26d5e, commit cf02be8, commit 38ee26b, commit 37ab8eb, commit 0370b35, commit 0253e12, commit 45e2ef2, commit 79b0edc, commit 840624f, commit 32a6707, commit 440bf91, commit 0b408ca, commit 2eabd38 (28 Oct 2019), and commit 1bcef51, commit ecde49b (05 Oct 2019) by brian m. carlson (bk2204).\n(Merged by Junio C Hamano -- gitster -- in commit 28014c1, 10 Nov 2019)\n\nt/oid-info: add empty tree and empty blob values\nSigned-off-by: brian m. carlson\n\n\nThe testsuite will eventually learn how to run using an algorithm other than SHA-1. In preparation for this, teach the test_oid family of functions how to look up the empty blob and empty tree values so they can be used.\n\nSo t/oid-info/hash-info now includes:\nrawsz sha1:20\nrawsz sha256:32\n\nhexsz sha1:40\nhexsz sha256:64\n\nzero sha1:0000000000000000000000000000000000000000\nzero sha256:0000000000000000000000000000000000000000000000000000000000000000\n\nalgo sha1:sha1\nalgo sha256:sha256\n\nempty_blob sha1:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391\nempty_blob sha256:473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813\n\nempty_tree sha1:4b825dc642cb6eb9a060e54bf8d69288fbee4904\nempty_tree sha256:6ef19b41225c5369f1c104d45d8d85efa9b057b53b14b4b9b939dd74decc5321\n\nThe SHA2 \"6ef19b41225c5369f1c104d45d8d85efa9b057b53b14b4b9b939dd74decc5321\" is the new SHA1 \"4b825dc642cb6eb9a060e54bf8d69288fbee4904\" empty tree."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch"}, {"role": "assistant", "content": "SYNOPSIS git pull [<options>] [<repository> [<refspec>…​]]"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Gerrit error when Change-Id in commit messages are missing\nI set up a branch in the remote repository and made some commits on that branch.\nNow I want to merge the remote branch to the remote master.\nBasically follows are my operations:\n\ncheckout branch\ncheckout master\nmerge branch and fix merging errors\ncommit\npush origin HEAD:refs/for/master\n\nBut get error messages on the 5th step:\nremote: Resolving deltas: 0% (0/12)\n\nremote: ERROR: missing Change-Id in commit message\n...\n\nremote: Change-Id: I55862204ef71f69bc88c79fe2259f7cb8365699a\n\nTo ssh://[email protected]:29418/hello_git\n ! [remote rejected] HEAD -> refs/for/master (missing Change-Id in commit message)"}, {"role": "assistant", "content": "Check if your commits have Change-Id: ... in their descriptions. Every commit should have them.\nIf no, use git rebase -i to reword the commit messages and add proper Change-Ids (usually this is a SHA1 of the first version of the reviewed commit).\nFor the future, you should install commit hook, which automatically adds the required Change-Id.\nExecute scp -p -P 29418 username@your_gerrit_address:hooks/commit-msg .git/hooks/ in the repository directory\nor download them from\nhttp://your_gerrit_address/tools/hooks/commit-msg and copy to .git/hooks\nNow git commit --amend --no-edit inserts the line."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What are the advantages of keeping linear history in Git?\nWhen I was taught using Git with central repo (project on Gitorious) I was told to always use rebase instead of merge because we want to have linear history. So, I have always been trying to work that way.\nNow when I come to think about it is it really so beneficial? Rebasing branch with many commits is much more time consuming then simple merge.\nThere are 2 advantages that come to my mind right now:\n\ngit bisect\nPossibility of submitting with history to another version control system like SVN.\n\nAre there any other benefits?"}, {"role": "assistant", "content": "As far as I am concerned, keeping a linear history is mostly for asthetics. It's a very good way for a very skilled, disciplined developer to tidy up the history and make it nice to skim through. In a perfect world, we should have a perfectly linear history that makes everything crystal clear.\nHowever, on a large team in an enterprise environment I often do not recommend artificially keeping a linear history. Keeping history linear on a team of sharp, experienced, and disciplined developers is a nice idea, but I often see this prescribed as a 'best practice' or some kind of 'must do'. I disagree with such notions, as the world is not perfect, and there are a lot of costs to keeping a linear history that people do not do a good job of disclosing. Here's the bullet list overview:\n\nRewriting history can include erasing history\nNot everybody can even rebase\nThe benefits are often overstated\n\nNow, let's dig into that. Warning: Long, anecdotal, mostly ranting\nRewriting history can include erasing history\nHere's the problem with rebasing all of your commits to keep everything nice and linear: Rebasing is not generally loss-less. There is information- real, actual things that were done by the developer - that may be compressed out of your history when you rebase. Sometimes, that's a good thing. If a developer catches their own mistake, it's nice for them to do an interactive rebase to tidy that up. Caught-and-fixed mistakes have already been handled: we don't need a history of them. But some people work with that one individual who always seems to screw up merge conflicts. I don't personally know any developers named Neal, so let's say it's a guy named Neal. Neal is working on some really tricky accounts receivable code on a feature branch. The code Neal wrote on his branch is 100% correct and works exactly the way we want it to. Neal gets his code all ready to get merged into master, only to find there are merge conflicts now. If Neal merges master into his feature branch, we have a history of what his code originally was, plus what his code looked like after resolving the merge conflicts. If Neal does a rebase, we only have his code after the rebase. If Neal makes a mistake when resolving merge conflicts, it will be a lot easier to troubleshoot the the former than it will be the latter. But worse, if Neal screws up his rebase in a sufficiently unfortunate way (maybe he did a git checkout --ours, but he forgot he had important changes in that file), we could altogether lose portions of his code forever.\nI get it, I get it. His unit tests should have caught the mistake. The code reviewer should have caught the mistake. QA should have caught the mistake. He shouldn't have messed up resolving the merge conflicts in the first place. Blah, blah, don't care. Neal is retired, the CFO is pissed because our ledger is all screwed up, and telling the CFO 'according to our development philosophy this shouldn't have happened' is going to get me punched in the face.\nNot everybody can even rebase, bro. Yes, I've heard: You work at some space age startup, and your IoT coffee table uses only the coolest and most modern, reactive, block-chain based recurrent neural network, and the tech stack is sick! Your lead developer was literally there when Go was invented, and everybody who works there has been a Linux kernel contributor since they were 11. I'd love to hear more, but I just don't have time with how often I'm being asked 'How do I exit git diff???'. Every time someone tries to rebase to resolve their conflicts with master, I get asked 'why does it say my file is their file', or 'WHY DO I ONLY SEE PART OF MY CHANGE', and yet most developers can handle merging master into their branch without incident. Maybe that shouldn't be the case, but it is. When you have junior devs and interns, busy people, and people who didn't find out what source control is until they had already been a programmer for 35 years on your team, it takes a lot of work to keep the history pristine.\nThe benefits are often overstated.\nWe've all been on that one project where you do git log --graph --pretty and suddenly your terminal has been taken over by rainbow spaghetti. But history is not hard to read because it's non-linear...It's hard to read because it's sloppy. A sloppy linear history where every commit message is \".\" is not going to be easier to read than a relatively clean non-linear history with thoughtful commit messages. Having a non-linear history does not mean you have to have branches being merged back and forth with each other several times before reaching master. It does not mean that your branches have to live for 6 months. An occasional branch on your history graph is not the end of the world.\nI also don't think doing a git bisect is that much more difficult with non-linear history. A skilled developer should be able to think of plenty of ways to get the job done. Here's one article I like with a decent example of one way to do it.\nhttps://blog.smart.ly/2015/02/03/git-bisect-debugging-with-feature-branches/\ntldr; I'm not saying rebases and linear history aren't great. I'm just saying you need to understand what you're signing up for and make an informed decision about whether or not it's right for your team. A perfectly linear history is not a necessity, and it certainly isn't free. It can definitely make life great in the right circumstances, but it will not make sense for everyone."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git error no matching host key type found. Their offer: ssh-rsa\nI get the following error when using git:\n$ git pull\nUnable to negotiate with 172.16.42.42 port 22: no matching host key type found. Their offer: ssh-rsa\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\nHow can I resolve this error?"}, {"role": "assistant", "content": "With SSH, there are several different types of keys and RSA keys (the ssh-rsa) kind can support multiple kinds of signatures. The signature type ssh-rsa refers to RSA with SHA-1, whereas the signature type rsa-sha2-256 is RSA with SHA-256 and rsa-sha2-512 is RSA with SHA-512.\nIn the case of Azure DevOps, it only supports the kind of RSA with SHA-1, and SHA-1 is considered very weak. This essentially means that there are no secure ways to connect to it over SSH, and until they fix that, you're better off using HTTPS or a different hosting service. GitHub, GitLab, and Bitbucket all support secure methods of authentication.\nIf you really need to use SSH with Azure DevOps at the moment, you can add an entry to your ~/.ssh/config file to work around this:\nHost ssh.dev.azure.com\n User git\n PubkeyAcceptedAlgorithms +ssh-rsa\n HostkeyAlgorithms +ssh-rsa\n\nHowever, be aware that this is a workaround and it's known to be insecure, so you should contact Azure DevOps about this problem and switch to HTTPS until they do, or move elsewhere."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git commit -a \"untracked files\"?\nWhen I do a git commit -a, I am seeing the following: \n # Please enter the commit message for your changes. Lines starting\n # with '#' will be ignored, and an empty message aborts the commit.\n # On branch better_tag_show\n # Changes to be committed:\n # (use \"git reset HEAD <file>...\" to unstage)\n #\n # modified: ../assets/stylesheets/application.css\n # modified: ../views/pages/home.html.erb\n # modified: ../views/tags/show.html.erb\n # modified: ../../db/seeds.rb\n #\n # Untracked files:\n # (use \"git add <file>...\" to include in what will be committed)\n #\n # ../assets/stylesheets/\n # ../views/pages/\n\nWhat does those untracked files mean? All the changes have been indeed tracked. I don't understand why git is warning me about untracked files here. \nEDIT:\nOk I see a lot of confused replies. This is what happens after I git commit -a this.\n# On branch master\nnothing to commit (working directory clean)\n\nAs you can see, there is NOTHING other than those four files that had changes applied.\nMy question should be rephrased as follows: Why is git warning me about untracked files when all of the changes in this commit has been tracked? \nIn other words, is the untracked warning in the git commit message unnecessary?"}, {"role": "assistant", "content": "For others having the same problem, try running \ngit add .\nwhich will add all files of the current directory to track (including untracked) and then use\ngit commit -a to commit all tracked files.\nAs suggested by @Pacerier, one liner that does the same thing is\ngit add -A"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Getting permission denied (public key) on gitlab\nMy problem is that I can't push or fetch from GitLab. However, I can clone (via HTTP or via SSH). I get this error when I try to push :\n\nPermission denied (publickey) fatal : Could not read from remote repository\n\nFrom all the threads I've looked, here is what I have done :\n\nSet up an SSH key on my computer and added the public key to GitLab\nDone the config --global for username and email\nCloned via SSH and via HTTP to check if it would resolve the issue\nDone the ssh -T [email protected] command\n\nIf you have any insight about how to resolve my issue, it would be greatly appreciated."}, {"role": "assistant", "content": "I found this after searching a lot. It will work perfectly fine for me.\n\nGo to \"Git Bash\" just like cmd. Right click and \"Run as Administrator\".\nType ssh-keygen\nPress enter.\nIt will ask you to save the key to the specific directory.\nPress enter. It will prompt you to type password or enter without password.\nThe public key will be created to the specific directory.\nNow go to the directory and open .ssh folder.\nYou'll see a file id_rsa.pub. Open it on notepad. Copy all text from it.\nGo to https://gitlab.com/-/profile/keys or\nPaste here in the \"key\" textfield.\nNow click on the \"Title\" below. It will automatically get filled.\nThen click \"Add key\".\n\nNow give it a shot and it will work for sure."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Mirror a git repository by pulling?\nI am wondering if there is an easy way, ie like a simple cron job, to regularly pull from a remote git repository to a local read only mirror for backup purposes?\nIdeally it would pull all branches and tags, but the master/trunk/head would be sufficient.\nI just need a way to make sure that if the master git server dies, we have a backup location that we could manually fail over to."}, {"role": "assistant", "content": "First create a mirror with \ngit clone --mirror [email protected]:repo.git\n\nthen setup a cron job like this:\n*/1 * * * * gitbackup cd /backup/repo.git && git fetch -q --tags\n\nThis will backup the changesets every minute. Maybe you want to do this less frequently."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Stopping GitLab from skipping Git submodules during CI job?\n\nI'm testing out deploying a Hexo site on GitLab Pages. I'm currently using a theme that someone has posted to GitHub, and thus have a Git submodule in the themes folder of my Hexo project such that the top-level .gitmodules file looks like:\n[submodule \"themes/Hacker\"]\n path = themes/Hacker\n url = https://github.com/CodeDaraW/Hacker.git\n\nI'm using the Hexo doc's recommended YAML file (updated for current Node) for CI settings, and the CI job seems to go smoothly except that it randomly decides to skip Git submodules setup:\nGetting source from Git repository 00:01\n$ eval \"$CI_PRE_CLONE_SCRIPT\"\nFetching changes with git depth set to 50...\nInitialized empty Git repository in /builds/jjeffrey/jjeffrey.gitlab.io/.git/\nCreated fresh repository.\nChecking out 76f8757a as master...\nSkipping Git submodules setup\nRestoring cache 00:01\nChecking cache for default...\nFATAL: file does not exist\n\nThis prevents the site from properly generating the HTML/CSS files because no theme is present:\n$ hexo generate\nINFO Validating config\nINFO Start processing\nINFO Files loaded in 100 ms\nWARN No layout: 1970/01/01/hello-world/index.html\nWARN No layout: 1970/01/01/test_new/index.html\nWARN No layout: archives/index.html\nWARN No layout: archives/1970/index.html\nWARN No layout: archives/1970/01/index.html\nWARN No layout: index.html\nINFO Generated: archives/index.html\nINFO Generated: archives/1970/index.html\nINFO Generated: archives/1970/01/index.html\nINFO Generated: index.html\nINFO Generated: 1970/01/01/hello-world/index.html\nINFO Generated: 1970/01/01/test_new/index.html\nINFO 6 files generated in 13 ms\n\n\nHow do I ensure that GitLab actually loads the Git submodule properly so that my theme loads?"}, {"role": "assistant", "content": "From gitlab documenation Using Git submodules with GitLab CI/CD:\n\nUse Git submodules in CI/CD jobs\nTo make submodules work correctly in CI/CD jobs:\n\nMake sure you use relative URLs for submodules located in the same GitLab server.\n\nYou can set the GIT_SUBMODULE_STRATEGY variable to either normal or recursive to tell the runner to fetch your submodules before the job:\nvariables:\n GIT_SUBMODULE_STRATEGY: recursive\n\n\n\n\nAlso see https://docs.gitlab.com/ee/ci/runners/configure_runners.html#git-submodule-strategy ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %GP"}, {"role": "assistant", "content": "show the fingerprint of the primary key whose subkey was used\nto sign a signed commit"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitglossary - A Git Glossary push"}, {"role": "assistant", "content": "Pushing a branch means to get the branch’s head ref from a remote repository ,\nfind out if it is an ancestor to the branch’s local\nhead ref, and in that case, putting all\nobjects, which are reachable from the local\nhead ref, and which are missing from the remote\nrepository, into the remote object database , and updating the remote\nhead ref. If the remote head is not an\nancestor to the local head, the push fails."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Remember GPG password when signing git commits\nWould it be possible for the GPG password to be saved, so that I am not prompted for the passphrase everytime I make a git commit?"}, {"role": "assistant", "content": "You can set a timeout period for gpg-agent in ~/.gnupg/gpg-agent.conf with this line:\ndefault-cache-ttl 3600\n\nThat would tell gpg-agent to store the passphrase for one hour. You wouldn't want it to be indefinite, but not constantly typing it is of benefit too."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fetch - Download objects and refs from another repository fetch.recurseSubmodules"}, {"role": "assistant", "content": "This option controls whether git fetch (and the underlying fetch\nin git pull ) will recursively fetch into populated submodules.\nThis option can be set either to a boolean value or to on-demand .\nSetting it to a boolean changes the behavior of fetch and pull to\nrecurse unconditionally into submodules when set to true or to not\nrecurse at all when set to false. When set to on-demand , fetch and\npull will only recurse into a populated submodule when its\nsuperproject retrieves a commit that updates the submodule’s\nreference.\nDefaults to on-demand , or to the value of submodule.recurse if set."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Large github commit diff not shown\n\nThis happens to me both with Compare view as well as standard commits that are large in the amount of files changed.\nThe screenshot below is from a compare between two branches with 380 files changed. The files at the beginning of the diff log have their diffs visualized but at a certain point down the page it stops visualizing the diffs. I understand you don't want massive pages but I can't seem to find a way to view a file's diff individually. Instead I have to check these both out locally and do the diff manually.\nDoes anyone have a simpler solution whether it be software driven or (preferably) a link i'm missing on github?"}, {"role": "assistant", "content": "Adding .patch to the end of the URL somewhat helps. Removes the nice UI and comment functionality, of course.\nAn example. If your pull request is: https://github.com/JustinTulloss/zeromq.node/pull/47, then the patch can be found at https://github.com/JustinTulloss/zeromq.node/pull/47.patch"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Rebasing in smartgit \"git-am is in progress\"\nI will try to explain the problem that I have. I have used the rebase option via git bash many times. Now I have SmartGit and don’t know why rebase is not correct.\nStep 1:\n\nStep 2:\n\nStep 3:\n\nThe result is that HEAD detaches."}, {"role": "assistant", "content": "The same issue i have faced, i will delete the local branch in my machine and recreate it from origin each and every time. But finally i got the solution. I ran the below command\ngit am --abort solved my problem."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "\"Git fatal: ref HEAD is not a symbolic ref\" while using maven release plugin\nI get the following error output while running the Maven release plugin prepare step i.e. mvn release:prepare --batch-mode -DreleaseVersion=1.1.2 -DdevelopmentVersion=1.2.0-SNAPSHOT -Dtag=v1.1.2 -X from an Atlassian Bamboo plan. However doing the same in the command line works fine. The full error stack is below.\nAny ideas how can this be solved?\n[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.2:prepare (default-cli) on project hpcmom: An error is occurred in the checkin process: Exception while executing SCM command. Detecting the current branch failed: fatal: ref HEAD is not a symbolic ref -> [Help 1]\n org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.2:prepare (default-cli) on project hpcmom: An error is occurred in the checkin process: Exception while executing SCM command.\n at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)\n at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)\n at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)\n at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)\n at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)\n at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)\n at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)\n at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)\n at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)\n at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)\n at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)\n at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)\n at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)\n at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n at java.lang.reflect.Method.invoke(Method.java:606)\n at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)\n at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)\n at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)\n at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)\nCaused by: org.apache.maven.plugin.MojoExecutionException: An error is occurred in the checkin process: Exception while executing SCM command.\n at org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:281)\n at org.apache.maven.plugins.release.PrepareReleaseMojo.execute(PrepareReleaseMojo.java:232)\n at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)\n at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)\n ... 19 more\nCaused by: org.apache.maven.shared.release.ReleaseExecutionException: An error is occurred in the checkin process: Exception while executing SCM command.\n at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.checkin(AbstractScmCommitPhase.java:160)\n at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.performCheckins(AbstractScmCommitPhase.java:145)\n at org.apache.maven.shared.release.phase.ScmCommitPreparationPhase.runLogic(ScmCommitPreparationPhase.java:76)\n at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.execute(AbstractScmCommitPhase.java:78)\n at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:234)\n at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:169)\n at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:146)\n at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:107)\n at org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:277)\n ... 22 more\nCaused by: org.apache.maven.scm.ScmException: Exception while executing SCM command.\n at org.apache.maven.scm.command.AbstractCommand.execute(AbstractCommand.java:63)\n at org.apache.maven.scm.provider.git.AbstractGitScmProvider.executeCommand(AbstractGitScmProvider.java:291)\n at org.apache.maven.scm.provider.git.AbstractGitScmProvider.checkin(AbstractGitScmProvider.java:217)\n at org.apache.maven.scm.provider.AbstractScmProvider.checkIn(AbstractScmProvider.java:410)\n at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.checkin(AbstractScmCommitPhase.java:156)\n ... 30 more\nCaused by: org.apache.maven.scm.ScmException: Detecting the current branch failed: fatal: ref HEAD is not a symbolic ref\n\n at org.apache.maven.scm.provider.git.gitexe.command.branch.GitBranchCommand.getCurrentBranch(GitBranchCommand.java:147)\n at org.apache.maven.scm.provider.git.gitexe.command.checkin.GitCheckInCommand.createPushCommandLine(GitCheckInCommand.java:192)\n at org.apache.maven.scm.provider.git.gitexe.command.checkin.GitCheckInCommand.executeCheckInCommand(GitCheckInCommand.java:132)\n at org.apache.maven.scm.command.checkin.AbstractCheckInCommand.executeCommand(AbstractCheckInCommand.java:54)\n at org.apache.maven.scm.command.AbstractCommand.execute(AbstractCommand.java:59)\n ... 34 more\n[ERROR] \n[ERROR] \n[ERROR] For more information about the errors and possible solutions, please read the following articles:\n[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException\nsimple 02-Dec-2013 17:18:09 Failing task since return code of [/opt/dev/apache-maven/3.0.5//bin/mvn -Djava.io.tmpdir=/opt/atlassian/bamboo/5.2.1/temp/HPCMOM-RELEASE-JOB1 release:prepare --batch-mode -DignoreSnapshots=false -DreleaseVersion=1.1.2 -DdevelopmentVersion=1.2.0-SNAPSHOT -Dtag=v1.1.2 -X] was 1 while expected 0\n\nUPDATE:\nDoing git ls-remote . on a local workspace clone produces:\nazg@olympus:~/code/hpcmom$ git ls-remote .\n7894eea08a0afecb99515d1339623be63a7539d4 HEAD\n7894eea08a0afecb99515d1339623be63a7539d4 refs/heads/master\n7894eea08a0afecb99515d1339623be63a7539d4 refs/remotes/origin/HEAD\n7894eea08a0afecb99515d1339623be63a7539d4 refs/remotes/origin/master\n6a7095b86cccdfd4b28e4dea633d0930809ae9ac refs/tags/v1.0\n1a53462b1ecf0abfea8245016304cda9c78b420d refs/tags/v1.0^{}\n5113a7cbcf35c47b680a9c36e15e5fa01ef1d2e6 refs/tags/v1.1\n79a3073ecabe65d3c8051520f8007d9e49a65a06 refs/tags/v1.1^{}\na00249209597ea1214d80ee38f228c40db7022c2 refs/tags/v1.1.0\ne892bce8d25d87368ab557fee0d30810bef7e31e refs/tags/v1.1.0^{}\nb491a312c39088533cb069e4ab1ae8a00d1f6bfe refs/tags/v1.1.2\na3f7618dada7ed60d8190426152ffd90e0e40a86 refs/tags/v1.1.2^{}\n\nDoing git ls-remote . on the Bamboo clone produces:\nazg@olympus:/var/atlassian/application-data/bamboo/xml-data/build-dir/HPCMOM-RELEASE-JOB1$ git ls-remote .\n2422ce066ac35dae3c54f1435ef8dae5008a9a14 HEAD\n57c08d581c0fd9e788049733fbdc9c22b9a6ae00 refs/heads/master\n57c08d581c0fd9e788049733fbdc9c22b9a6ae00 refs/remotes/origin/HEAD\n57c08d581c0fd9e788049733fbdc9c22b9a6ae00 refs/remotes/origin/master\n7539f9700d78a1b766fca7ed9f409914f1ea9d08 refs/tags/vnull\n6bfa8c3fdb1f8f56a385035f01b1b77b6e88da8b refs/tags/vnull^{}\n\nand this is very weird why is the local development clone output so different from the Bamboo one?"}, {"role": "assistant", "content": "I ran into the same error on Jenkins in combination with maven release plugin, we fixed it by going to Additional behaviours, Check out to specific local branch and enter 'master'\nI realise this is not a solution but it might give you some direction in where to look."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to automate git merge to not prompt to confirm the commit message?\nI'm trying to do some automation scripts using git, simple things like updating submodules, moving to proper tags etc, but one of the problems I'm now finding is that git now forces you to confirm a merge message. Is there any way to squelch this behavior from happening?"}, {"role": "assistant", "content": "You can add the --no-edit switch to git-merge and it will not ask you to confirm the merge message."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I check the date and time of the latest `git pull` that was executed?\nHow do I check the date and time of the latest git pull that was executed? I frequently need to know when the code changed on a server when something goes wrong."}, {"role": "assistant", "content": "stat -c %Y .git/FETCH_HEAD\n\nWill give you a unix timestamp of the last modification of that file.\nGit writes the FETCH_HEAD file every time you pull or fetch, even if there was nothing to pull."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Removing contributor from github.com?\nHow to remove contributor from showing in the main page of project:\n\nLink https://help.github.com/articles/removing-a-collaborator-from-a-personal-repository/ says it possible in settings, but I dont see any collaborator in there:"}, {"role": "assistant", "content": "The below method works in my case at least.\n\nIn the GitHub web interface, change a branch name (From main to main1 for example). You can do that from the url https://github.com/[user]/[repo]/branches. It will update the contributor list on the repository dashboard.\n\n\nThen change the name back (main1 to main).\n\n\nI have multiple GitHub accounts for different projects and different communities and I accidentally pushed a commit using a wrong account. I changed the author of the commit, but the wrong account was still on the contributors list in the repository dashboard.\nMy method keeps the commit history as well as the GitHub action settings and issue history. But I did not check if pull requests are kept."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why is Jenkins failing when fetching from git, while the command line isn't?\nAll of my Jenkins builds are failing at the git fetch line. \nIt's failing at git fetch --tags --progress [email protected]:ethenwilson/whentoact.git\nStarted by user anonymous\nBuilding in workspace /Users/ethen/.jenkins/workspace/Build NikNik\n > git rev-parse --is-inside-work-tree\nFetching changes from the remote Git repository\n > git config remote.origin.url [email protected]:ethenwilson/whentoact.git\nFetching upstream changes from [email protected]:ethenwilson/whentoact.git\n > git --version\nusing GIT_SSH to set credentials NikNik BitBucket SSH Key\n > git fetch --tags --progress [email protected]:ethenwilson/whentoact.git +refs/heads/*:refs/remotes/origin/*\nFATAL: Failed to fetch from [email protected]:ethenwilson/whentoact.git\nhudson.plugins.git.GitException: Failed to fetch from [email protected]:ethenwilson/whentoact.git\n at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:622)\n at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:854)\n at hudson.plugins.git.GitSCM.checkout(GitSCM.java:879)\n at hudson.model.AbstractProject.checkout(AbstractProject.java:1252)\n at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:624)\n at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)\n at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:530)\n at hudson.model.Run.execute(Run.java:1732)\n at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)\n at hudson.model.ResourceController.execute(ResourceController.java:88)\n at hudson.model.Executor.run(Executor.java:234)\nCaused by: hudson.plugins.git.GitException: Command \"git fetch --tags --progress [email protected]:ethenwilson/whentoact.git +refs/heads/*:refs/remotes/origin/*\" returned status code 128:\nstdout: \nstderr: remote: Counting objects: 2682, done.[K\nremote: Compressing objects: 0% (1/1399) [K\nremote: Compressing objects: 1% (14/1399) [K\n...\nremote: Compressing objects: 99% (1398/1399) [K\nremote: Compressing objects: 100% (1399/1399) [K\nremote: Compressing objects: 100% (1399/1399), done.[K\nReceiving objects: 0% (1/2682) \nReceiving objects: 1% (27/2682) \n... \nReceiving objects: 78% (2092/2682), 4.07 MiB | 1.59 MiB/s \nCorrupted MAC on input.\nDisconnecting: Packet corrupt\nfatal: The remote end hung up unexpectedly\nfatal: early EOF\nfatal: index-pack failed\n\n at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1325)\n at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1186)\n at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$200(CliGitAPIImpl.java:87)\n at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:257)\n at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:620)\n ... 10 more\n\nWhen I run git fetch --tags --progress [email protected]:ethenwilson/whentoact.git from the command line, it works fine, which means my SSH keys must be working.\nI'm connecting to BitBucket with Jenkins with SSH verification. Jenkins gets the key from the file it's located (the default one), so I know that Jenkins is using the same key as I am when I run from the command line.\nI'm using the latest build of the BitBucket and Git plugins for Jenkins. My installed Git on my Mac is version 1.8.5.2 (Apple Git-48).\nMy jenkins start command is nohup java -jar ~/jenkins.war --httpPort=8081 --ajp13Port=8010 > /tmp/jenkins.log 2>&1 &.\nWhat's going wrong?\nEDIT: I was wrong, I had accidentally hit an option to have the SSH Key be in the wrong place when I did that. Now, using @borrrden's suggestion, it still gives the same error. **EDIT: As @borrrden suggested, I changed my start command to nohup java -Dorg.jenkinsci.plugins.gitclient.Git.useCLI=true -jar ~/Downloads/jenkins.war --httpPort=8081 --ajp13Port=8010 > /tmp/jenkins.log 2>&1 &, and now I get a different crash:\nStarted by user anonymous\nBuilding in workspace /Users/ethen/.jenkins/workspace/Build NikNik\n > git rev-parse --is-inside-work-tree\nFetching changes from the remote Git repository\n > git config remote.origin.url [email protected]:ethenwilson/whentoact.git\nFetching upstream changes from [email protected]:ethenwilson/whentoact.git\n > git --version\nusing GIT_SSH to set credentials NikNik BitBucket SSH Key\n > git fetch --tags --progress [email protected]:ethenwilson/whentoact.git +refs/heads/*:refs/remotes/origin/*\nFATAL: Failed to fetch from [email protected]:ethenwilson/whentoact.git\nhudson.plugins.git.GitException: Failed to fetch from [email protected]:ethenwilson/whentoact.git\n at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:622)\n at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:854)\n at hudson.plugins.git.GitSCM.checkout(GitSCM.java:879)\n at hudson.model.AbstractProject.checkout(AbstractProject.java:1252)\n at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:624)\n at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)\n at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:530)\n at hudson.model.Run.execute(Run.java:1732)\n at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)\n at hudson.model.ResourceController.execute(ResourceController.java:88)\n at hudson.model.Executor.run(Executor.java:234)\nCaused by: hudson.plugins.git.GitException: Command \"git fetch --tags --progress [email protected]:ethenwilson/whentoact.git +refs/heads/*:refs/remotes/origin/*\" returned status code 128:\nstdout: \nstderr: Permission denied (publickey).\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\n at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1406)\n at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1194)\n at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$200(CliGitAPIImpl.java:87)\n at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:265)\n at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:620)\n ... 10 more"}, {"role": "assistant", "content": "1) Go to job configuration \n2) Go to the \"Source Code Management\" section\n3) Additional behaviors > add \n4) Select \"Wipe out repository and force clone\" \nThis will delete and re-clone only the workspace which is for your job. If you'd like to confirm before deleting, then I suggest echoing out the $WORKSPACE variable via a batch/bash command build step. \nAlso, this makes the build much slower, so I suggest removing it after one build."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git show all branches (but not stashes) in log\nI have a Git alias that expands to:\ngit log --graph --oneline --all --decorate\n\nAccording to man git log there are a couple of suspicious options: --not and --branches; but I can't make it work properly.\nHow should I edit that to hide the stashes?\n\nFYI: as per the accepted question and comment my .gitconfig alias now looks like this:\n[alias]\n l = log --branches --remotes --tags --graph --oneline --decorate --notes HEAD"}, {"role": "assistant", "content": "Instead of doing --all and then trying to filter out the stashes, don't ever include them in the first place:\ngit log --branches --remotes --tags --graph --oneline --decorate\n\nThe main problem that arises from trying to filter them out afterwards is that if the stash is the latest commit on that branch (because even though it's not the head of the branch, it's still the most recent descendant of it), it can actually filter out the entire branch from the log, which isn't what you want."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is there a way to use wildcards with git checkout?\nWhat I would like to do is to checkout a single file or a set of files with a common name part like this\ngit checkout myBranch */myFile.md and\ngit checkout myBranch -- */*Test* (not sure about the '--' part)\ninstead of \ngit checkout myBranch src/main/java/a/deep/package/structure/myFile.md and\ngit checkout myBranch src/test/java/a/deep/package/structure/TestOne.java\ngit checkout myBranch src/test/java/a/deep/package/structure/TestTwo.java\ngit checkout myBranch src/test/java/a/deep/package/structure/resources/TestData.sql \nI know there is some limited wildcard functionality for some git command like diff and add but have found nothing for checkout. Is there a way?\nEDIT: I am using git 1.7.9.5 on Linux. A working combination of git and shell commmands would be acceptable as well."}, {"role": "assistant", "content": "Git does deal with wildcards, using fnmatch(3). See the pathspec entry in Git glossary.\nBut to be sure that git can see the wildcards, they must be escaped otherwise your shell will expand them first. Typically, I use wildcards between single-quotes:\ngit checkout myBranch -- '*/myFile.md'\n\nThe wildcards are applied to the whole name, directories included. \nAs you can see in the documentation, the pathspec also allows magic signature which change how to interpret the pathspec. For example, you can have case-insensitive paths with icase (you can type ':(icase)*readme*' to find all your readme's).\nI quote @bambams's comment here, in case you have problems in Windows:\n\nThis is not working for me in Windows with 2.8.1.windows.1 and I'm\n utilizing Git from the cmd.exe shell so no globbing built in. There is\n however a solution if you're in such a sorry state. Combine git diff --name-only and xargs to achieve your goal: \ngit diff --name-only <COMMIT> -- <GLOB>... | xargs git checkout <COMMIT>"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is it dangerous to keep code in gitlab and github\n\nIs it dangerous to keep code in gitlab and github?\nI heard it is quite safe to commit our code to gitlab and github.\nThe reason is every code is hashed and it is nearly impossible for everyone to alter the code without using git tool.\nIs this true?"}, {"role": "assistant", "content": "As I mentioned in \"Why does Git use a cryptographic hash function?\", it is \"safe\" in term of data integrity (Linus Torvalds, 2007):\n\nWe check checksums that is considered cryptographically secure. Nobody has been able to break SHA-1, but the point is, SHA-1 as far as git is concerned, isn't even a security feature. It's purely a consistency check.\n The security parts are elsewhere.\n A lot of people assume since git uses SHA-1 and SHA-1 is used for cryptographically secure stuff, they think that it's a huge security feature. It has nothing at all to do with security, it's just the best hash you can get.\nHaving a good hash is good for being able to trust your data\n\nThis has nothing to do with:\n\nprivacy (which doesn't depend on Git itself, but on the Git hosting server, like gitHub or BitBucket)\nuser identity (to really be sure about a commit user, as Thilo comments, you can sign commits (see \"A Git Horror Story: Repository Integrity With Signed Commits\")\n\n\nThe OP add:\n\nwhat I mean is the owner of gitlab or github may steal our code\n\nThis is a question of trust: Does the git hosting server have access to your code if it is in a private repo? Technically yes.\nWill they access your private code? As mentioned in \"Can third party hosts be trusted for closed-source/private source code management?\", nothing prevents them to.\nYet, many startups have their private code on, for instance, GitHub.\nIf you have real confidentiality concern, then it is important you keep the ownership of the all codebase, including the server where it is stored (meaning having your own Git repo hosting server)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git how to checkout a commit of a branch\nHow can I check out a commit version of a branch in git? \nFor example, my branch, Dev, has a commit ad4f43af43e. How can I check out that commit? Not just a single file, but a whole branch. \nI searched online and found: git checkout <commit>, but it didn't specify branch name"}, {"role": "assistant", "content": "git checkout <hash> # non named commit\ngit checkout <branch_name> # named commit\n\nThe two lines above will place the HEAD pointer on the given commit. You should know that a branch name is a commit, except it can evolve if a new commit is added when you're on that branch.\nIf you want to place your branch Dev on the commit ad4f43af43e you can do this\ngit branch -f Dev ad4f43af43e\n\nBe careful! This is dangerous because you may lose commits."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to skip GitHub Actions job on push event?\n\nWith Travis CI, we can skip the build for a particular commit with adding a suffix to a commit. This is described at Travis CI. I find this feature practical when I only edit README.md which is not code-related and the pre-flight build doesn't need to be triggered.\n[skip ci]\n\nHow do I skip the jobs trigged on: push events using GitHub Actions?\nname: Maven Build\non: [push]\n\njobs:\n build:\n\n runs-on: ubuntu-latest\n\n steps:\n - name: Check-out project\n uses: actions/checkout@v1\n - name: Set up JDK 11.0.3\n uses: actions/setup-java@v1\n with:\n java-version: 11.0.3\n - name: Build with Maven\n run: mvn -B package --file pom.xml\n\n\nAnswers summary:\nBig thanks to all the answerers providing various ways to achieve it. I bet everybody would need something a little bit different regarding to the origin of their problem and the CI approach. Here are the answers listed for a quick navigation:\n\nSkip CI on readme.md file: https://stackoverflow.com/a/61876395/3764965\nSkip CI on [skip ci] as a new GitHub feature:\n\nhttps://stackoverflow.com/a/66156840/3764965 (answer here)\nhttps://stackoverflow.com/a/66114678/3764965 (answer in another question)\n\n\nSkip CI on [skip ci] message by parsing (customizable solution):\n\nhttps://stackoverflow.com/a/59775665/3764965\n\n\nAllow CI per specific branch: https://stackoverflow.com/a/61876395/3764965\n\nAll the answers deserve upvote! If you like my question, you should double-like the answers."}, {"role": "assistant", "content": "UPDATE: Please see Helmisek anwser, which points out that Github has the functionality built-in now.\nMy answer only makes sense, if you want to skip just some jobs/steps.\n\nYou can give the following a try:\nname: Maven Build\non: [push]\n\njobs:\n build:\n if: \"!contains(github.event.commits[0].message, '[skip ci]')\"\n runs-on: ubuntu-latest\n\n steps:\n - name: Check-out project\n uses: actions/checkout@v1\n - name: Set up JDK 11.0.3\n uses: actions/setup-java@v1\n with:\n java-version: 11.0.3\n - name: Build with Maven\n run: mvn -B package --file pom.xml"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "AWS-CDK and Gitlab returns Error: spawnSync docker ENOENT\n\nI am trying to run a Gitlab pipeline that builds an AWS-CDK project via the cdk-synth command. I have followed advice online in terms of what images I should be using in the Gitlab runner but I am running into the following error:\n\nError: spawnSync docker ENOENT\n\nI'm not sure what this error means exactly, I guess it is trying to launch docker (which is used by thecdk synth command) but failing to do so. Again what I have found online all suggests to use the setup I currently have which is:\nimage: node:16.3.0-alpine\n\nstages:\n - build\n - test\n - .post\n\ncache:\n key: ${CI_COMMIT_REF_SLUG}\n paths:\n - .npm\n - node_modules\n\nbuild:\n tags:\n - mytag\n environment: ${CI_COMMIT_BRANCH}\n stage: build\n script:\n - npm i\n - cdk synth --no-staging > template.yaml\n artifacts:\n paths:\n - cdk.out\n expire_in: 30 mins\n\nI'm really lost with this one, it may be staring me right in the face but could someone please point me in the right direction as to why i'd be getting this error when the image i'm using is itself a docker container?"}, {"role": "assistant", "content": "I was stuck on this as well, but was able to get around it by adding esbuild as to my devDependencies in package.json."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git error: Unable to append to .git/logs/refs/remotes/origin/master: Permission denied\nI am having a strange issue that I can't seem to resolve. Here is what happend:\nI had some log files in a github repository that I didn't want there. I found this script that removes files completely from git history like so:\n #!/bin/bash\nset -o errexit\n\n# Author: David Underhill\n# Script to permanently delete files/folders from your git repository. To use \n# it, cd to your repository's root and then run the script with a list of paths\n# you want to delete, e.g., git-delete-history path1 path2\n\nif [ $# -eq 0 ]; then\n exit 0are still\nfi\n\n# make sure we're at the root of git repo\nif [ ! -d .git ]; then\n echo \"Error: must run this script from the root of a git repository\"\n exit 1\nfi\n\n# remove all paths passed as arguments from the history of the repo\nfiles=$@\ngit filter-branch --index-filter \"git rm -rf --cached --ignore-unmatch $files\" HEAD\n\n# remove the temporary history git-filter-branch otherwise leaves behind for a long time\nrm -rf .git/refs/original/ && git reflog expire --all && git gc --aggressive --prune\n\nI, of course, made a backup first and then tried it. It seemed to work fine. I then did a git push -f and was greeted with the following messages:\nerror: Unable to append to .git/logs/refs/remotes/origin/master: Permission denied\nerror: Cannot update the ref 'refs/remotes/origin/master'.\n\nEverything seems to have pushed fine though, because the files seem to be gone from the GitHub repository, if I try and push again I get the same thing:\nerror: Unable to append to .git/logs/refs/remotes/origin/master: Permission denied\nerror: Cannot update the ref 'refs/remotes/origin/master'.\nEverything up-to-date\n\nEDIT\n$ sudo chgrp {user} .git/logs/refs/remotes/origin/master\n$ sudo chown {user} .git/logs/refs/remotes/origin/master\n$ git push\nEverything up-to-date\n\nThanks!\nEDIT\nUh Oh. Problem. I've been working on this project all night and just went to commit my changes:\nerror: Unable to append to .git/logs/refs/heads/master: Permission denied\nfatal: cannot update HEAD ref\n\nSo I:\nsudo chown {user} .git/logs/refs/heads/master\nsudo chgrp {user} .git/logs/refs/heads/master\n\nI try the commit again and I get:\nerror: Unable to append to .git/logs/HEAD: Permission denied\nfatal: cannot update HEAD ref\n\nSo I:\nsudo chown {user} .git/logs/HEAD\nsudo chgrp {user} .git/logs/HEAD\n\nAnd then I try the commit again:\n16 files changed, 499 insertions(+), 284 deletions(-)\ncreate mode 100644 logs/DBerrors.xsl\ndelete mode 100644 logs/emptyPHPerrors.php\ncreate mode 100644 logs/trimXMLerrors.php\nrewrite public/codeCore/Classes/php/DatabaseConnection.php (77%)\ncreate mode 100644 public/codeSite/php/init.php\n$ git push\nCounting objects: 49, done.\nDelta compression using up to 2 threads.\nCompressing objects: 100% (27/27), done.\nWriting objects: 100% (27/27), 7.72 KiB, done.\nTotal 27 (delta 15), reused 0 (delta 0)\nTo [email protected]:IAmCorbin/MooKit.git\n59da24e..68b6397 master -> master\n\nHooray. I jump on http://GitHub.com and check out the repository, and my latest commit is no where to be found. ::scratch head:: So I push again:\nEverything up-to-date\n\nUmm...it doesn't look like it. I've never had this issue before, could this be a problem with github? or did I mess something up with my git project?\nEDIT\nNevermind, I did a simple:\ngit push origin master\n\nand it pushed fine."}, {"role": "assistant", "content": "This looks like you ran git as root locally, thus changing ownership on some of the files tracking the location of the origin branch.\nFix the file ownership, and you should be fine:\n# run this from the root of the git working tree\nsudo chown -R \"${USER:-$(id -un)}\" ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to undelete a branch on github?\n\nIt seems that I delete a branch on github when I should not do it.\nWhat I did was as follow:\n1- I add a new .gitignore to my system \n2- I use \n git rm -r --cached . \n git add . \n git commit -m \".gitignore is now working\" \n\nWhen I did this, I had one branch on my local system but the server had two branch.\nThen I pushed my branches to server and since I had not the second branch, the second branch was deleted on server.\nHow can I bring it back?\nI am using Github as remote server."}, {"role": "assistant", "content": "If you know the last commit message of the deleted branch you can do this:\ngit reflog\n\n# search for message\nfd0e4da HEAD@{14}: commit: This is the commit message I want\n\n# checkout revision\ngit checkout fd0e4da \n\nor\ngit checkout HEAD@{14}\n\n# create branch \ngit branch my-recovered-branch\n\n# push branch\ngit push origin my-recovered-branch:my-recovered-branch"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Use Gitlab's CI/CD with submodules - cannot run ssh\n\nI have a two private repositories: MyProject, MyProjetUtils.\nMy project uses the MyProjectUtils as a submodule.\nMy .gitsubmodules looks like this:\n[submodule \"MyProjetUtils\"]\n path = MyProjetUtils\n url = [email protected]:MyCompany/MyProjetUtils.git\n\nMy .gitlab-ci.yml file looks like this:\ndefault:\n image: python:latest\nvariables:\n GIT_SUBMODULE_STRATEGY: recursive\nall_test:\n stage: test\n script:\n - apt-get update\n - pip install -r requirements.txt\n - python tests/run_tests.py\n\nThe error I'm getting during the job run:\nUpdating/initializing submodules recursively with git depth set to 50...\nSubmodule 'MyProjetUtils' ([email protected]:MyCompany/MyProjetUtils.git) registered for path 'MyProjetUtils'\nCloning into '/builds/MyCompany/MyProject/MyProjetUtils'...\nerror: cannot run ssh: No such file or directory\nfatal: unable to fork\nfatal: clone of '[email protected]:MyCompany/MyProjetUtils.git' into submodule path '/builds/MyCompany/MyProject/MyProjetUtils' failed\nFailed to clone 'MyProjetUtils'. Retry scheduled\n\nThis error occur before the test stage. I've looked for answer here, and here but could not find an answer."}, {"role": "assistant", "content": "The first link you posted has the solution you are looking for:\n\nWhen your submodule is on the same GitLab server, you should use relative URLs in your .gitmodules file. Then you can clone with HTTPS in all your CI/CD jobs. You can also use SSH for all your local checkouts.\n\nAssuming that your submodules are in the same group, update your .gitmodules to use a relative URL.\nie:\n[submodule \"MyProjetUtils\"]\n path = MyProjetUtils\n url = ../../MyCompany/MyProjetUtils.git\n\nMay need to update ../../ to work for your groups."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects %gN"}, {"role": "assistant", "content": "reflog identity name (respecting .mailmap, see git-shortlog or git-blame )"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitglossary - A Git Glossary unmerged index"}, {"role": "assistant", "content": "An index which contains unmerged index entries ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git apply fails with \"patch does not apply\" error\nI have a certain patch called my_pcc_branch.patch.\nWhen I try to apply it, I get following message:\n$ git apply --check my_pcc_branch.patch\nwarning: src/main/java/.../AbstractedPanel.java has type 100644, expected 100755\nerror: patch failed: src/main/java/.../AbstractedPanel.java:13\nerror: src/main/java/.../AbstractedPanel.java: patch does not apply\n\nWhat does it mean?\nHow can I fix this problem?"}, {"role": "assistant", "content": "git apply --reject --whitespace=fix mychanges.patch worked for me.\nExplanation\nThe --reject option will instruct git to not fail if it cannot determine how to apply a patch, but instead to apply the individual hunks it can apply and create reject files (.rej) for hunks it cannot apply. Wiggle can \"apply [these] rejected patches and perform word-wise diffs\".\nAdditionally, --whitespace=fix will warn about whitespace errors and try to fix them, rather than refusing to apply an otherwise applicable hunk.\nBoth options together make the application of a patch more robust against failure, but they require additional attention with respect to the result.\nFor the whole documentation, see https://git-scm.com/docs/git-apply."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects --skip-to=<file> --rotate-to=<file>"}, {"role": "assistant", "content": "Discard the files before the named <file> from the output\n(i.e. skip to ), or move them to the end of the output\n(i.e. rotate to ). These options were invented primarily for the use\nof the git difftool command, and may not be very useful\notherwise."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Publishing to gitlab pypi package registry for a group\n\nI am trying to publish a package to gitlab pypi registry. What is the repository url we need to use to publish to a group package registry?.\nI tried using this https://gitlab.example.com/api/v4/groups/id/packages/pypi\nbut it is throwing 404 now found.\nThe api https://gitlab.example.com/api/v4/groups/id/packages/ returns a empty array for me.\nBut when I manually take the registry from the UI pypy, npm etc are present.\nPublishing to individual project repositories is working fine.\nhttps://gitlab.example.com/api/v4/projects/id/packages/pypi"}, {"role": "assistant", "content": "I run into the same problem.\nAs far as I understand, groups don't have their own registries. If you go in your group settings, you won't see the option to activate it.\nGroups are only placeholders to organize projects, they don't hold any data.\nWhat you see in the UI when clicking on the group registry is the aggregation of all the registries of the projects inside that group.\nThis is only a search UI, not a registry per se.\nBottom-line is that you have to publish your artefacts to a specific project.\nNote that you can have a dedicated project to hold only your registry, and have all your code repositories publish in the same registry."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can I delete all the local branches except the current one?\nI want to delete all branches that get listed in the output of ...\n$ git branch\n\n... but keeping current branch, in one step. Is that possible? If so, how?"}, {"role": "assistant", "content": "$ git branch | grep -v \"master\" | xargs git branch -D \n\nwill delete all branches except master (replace master with branch you want to keep, but then it will delete master)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can I delete a git commit but keep the changes?\nIn one of my development branches, I made some changes to my codebase. Before I was able to complete the features I was working on, I had to switch my current branch to master to demo some features. But just using a \"git checkout master\" preserved the changes I also made in my development branch, thus breaking some of the functionality in master. So what I did was commit the changes on my development branch with a commit message \"temporary commit\" and then checkout master for the demo.\nNow that I'm done with the demo and back to work on my development branch, I would like to remove the \"temporary commit\" that I made while still preserving the changes I made. Is that possible?"}, {"role": "assistant", "content": "It's as simple as this:\ngit reset HEAD^\n\nNote: some shells treat ^ as a special character (for example some Windows shells or ZSH with globbing enabled), so you may have to quote \"HEAD^\" or use HEAD~1 in those cases.\ngit reset without a --hard or --soft moves your HEAD to point to the specified commit, without changing any files. HEAD^ refers to the (first) parent commit of your current commit, which in your case is the commit before the temporary one.\nNote that another option is to carry on as normal, and then at the next commit point instead run:\ngit commit --amend [-m … etc]\n\nwhich will instead edit the most recent commit, having the same effect as above.\nNote that this (as with nearly every git answer) can cause problems if you've already pushed the bad commit to a place where someone else may have pulled it from. Try to avoid that"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Should I .gitignore my gradlew?\n\nMy gradle project includes gradlew and gradlew.bat files inside of the repository, should they be pushed to git or not? I did not see anybody say they should be removed here. What is the purpose of these files?"}, {"role": "assistant", "content": "NOT Really. Reason being if someone download or clone your repo and try to run your application through command line and they do not have gradle installed on their local machine, they have to install and configure Gradle and then run it. The gradlew provides a convenient way to run a gradle build with installing it.\nHere is what Gradle documentation says:\n\nMost tools require installation on your computer before you can use them. If the installation is easy, you may think that’s fine. But it can be an unnecessary burden on the users of the build. Equally importantly, will the user install the right version of the tool for the build? What if they’re building an old version of the software?\nThe Gradle Wrapper (henceforth referred to as the “Wrapper”) solves both these problems and is the preferred way of starting a Gradle build."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "test after build would run in new environment on gitlab-ci\n\nI have the following configuration as .gitlab-ci.yml\nbut I found out after successfully pass build stage (which\nwould create a virtualenv called venv), it seems that \nin test stage you would get a brand new environment(there's\nno venv directory at all). So I wonder should I put setup\nscript in before_script therefor it would run in each phase(build/test/deploy). Is it a right way to do it ?\nbefore_script:\n - uname -r \n\ntypes:\n - build\n - test\n - deploy\n\njob_install:\n type: build\n script:\n - apt-get update\n - apt-get install -y libncurses5-dev\n - apt-get install -y libxml2-dev libxslt1-dev\n - apt-get install -y python-dev libffi-dev libssl-dev \n - apt-get install -y python-virtualenv\n - apt-get install -y python-pip\n - virtualenv --no-site-packages venv\n - source venv/bin/activate\n - pip install -q -r requirements.txt\n - ls -al\n only:\n - master\n\njob_test:\n type: test\n script:\n - ls -al\n - source venv/bin/activate\n - cp crawler/settings.sample.py crawler/settings.py\n - cd crawler \n - py.test -s -v \n only:\n - master\n\nadasd"}, {"role": "assistant", "content": "Gitlab CI jobs supposed to be independent, because they could run on different runners. It is not issue. There two ways to pass files between stages:\n\nThe right way. Using artefacts.\nThe wrong way. Using cache. With cache key \"hack\". Still need same runner.\n\nSo yes, supposed by gitlab way to have everything your job depends on in before script.\nArtifacts example:\n artifacts:\n when: on_success\n expire_in: 1 mos\n paths:\n - some_project_files/\n\nCache example:\ncache:\n key: \"$CI_BUILD_REF_NAME\"\n untracked: true\n paths:\n - node_modules/\n - src/bower_components/\n\nFor correct running environment i suggest using docker with image containing apt-get dependencies. And use artefacts for passing job results between jobs. Note that artefact also uploaded to gitlab web interface and being able to download them. So if they are quite heavy use small expire_in time, for removing them after all jobs done."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Accidentally committed .idea directory files into git\nI have accidentally committed the .idea/ directory into git. This is causing conflicts everywhere else I need to checkout my repo. I was wondering how do I remove these files from the remote?\nI still need these files locally since the Intellij IDE needs them. I just don't want them in the remote. I have added the directory .idea/ to my .gitignore and committed and pushed this file into remote. This seems to have no effect during my checkout on my other machine though. I still get the error message:\nerror: The following untracked working tree files would be overwritten by checkout:\n.idea/.name\n.idea/compiler.xml\n.idea/copyright/profiles_settings.xml\n.idea/encodings.xml\n.idea/misc.xml\n.idea/modules.xml\n.idea/scopes/scope_settings.xml\n.idea/uiDesigner.xml\n.idea/vcs.xml\n.idea/workspace.xml"}, {"role": "assistant", "content": "Add .idea directory to the list of ignored files\nFirst, add it to .gitignore, so it is not accidentally committed by you (or someone else) again:\n.idea\n\nRemove it from repository\nSecond, remove the directory only from the repository, but do not delete it locally. To achieve that, do what is listed here:\n\nRemove a file from a Git repository without deleting it from the local filesystem\n\nSend the change to others\nThird, commit the .gitignore file and the removal of .idea from the repository. After that push it to the remote(s).\nSummary\nThe full process would look like this:\n$ echo '.idea' >> .gitignore\n$ git rm -r --cached .idea\n$ git add .gitignore\n$ git commit -m '(some message stating you added .idea to ignored entries)'\n$ git push\n\n(optionally you can replace last line with git push some_remote, where some_remote is the name of the remote you want to push to)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects %at"}, {"role": "assistant", "content": "author date, UNIX timestamp"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Dealing with SVN keyword expansion with git-svn\nI recently asked about keyword expansion in Git and I'm willing to accept the design not to really support this idea in Git. \nFor better or worse, the project I'm working on at the moment requires SVN keyword expansion like this:\nsvn propset svn:keywords \"Id\" expl3.dtx\n\nto keep this string up-to-date:\n$Id: expl3.dtx 803 2008-09-11 14:01:58Z will $\n\nBut I would quite like to use Git to do my version control. Unfortunately, git-svn doesn't support this, according to the docs:\n\n\"We ignore all SVN properties except svn:executable\"\n\nBut it doesn't seem too tricky to have this keyword stuff emulated by a couple of pre/post commit hooks. Am I the first person to want this? Does anyone have some code to do this?"}, {"role": "assistant", "content": "What's going on here: Git is optimized to switch between branches as quickly as possible. In particular, git checkout is designed to not touch any files that are identical in both branches.\nUnfortunately, RCS keyword substitution breaks this. For example, using $Date$ would require git checkout to touch every file in the tree when switching branches. For a repository the size of the Linux kernel, this would bring everything to a screeching halt.\nIn general, your best bet is to tag at least one version:\n$ git tag v0.5.whatever\n\n...and then call the following command from your Makefile:\n$ git describe --tags\nv0.5.15.1-6-g61cde1d\n\nHere, git is telling me that I'm working on an anonymous version 6 commits past v0.5.15.1, with an SHA1 hash beginning with g61cde1d. If you stick the output of this command into a *.h file somewhere, you're in business, and will have no problem linking the released software back to the source code. This is the preferred way of doing things.\nIf you can't possibly avoid using RCS keywords, you may want to start with this explanation by Lars Hjemli. Basically, $Id$ is pretty easy, and you if you're using git archive, you can also use $Format$.\nBut, if you absolutely cannot avoid RCS keywords, the following should get you started:\ngit config filter.rcs-keyword.clean 'perl -pe \"s/\\\\\\$Date[^\\\\\\$]*\\\\\\$/\\\\\\$Date\\\\\\$/\"'\ngit config filter.rcs-keyword.smudge 'perl -pe \"s/\\\\\\$Date[^\\\\\\$]*\\\\\\$/\\\\\\$Date: `date`\\\\\\$/\"'\n\necho '$Date$' > test.html\necho 'test.html filter=rcs-keyword' >> .gitattributes\ngit add test.html .gitattributes\ngit commit -m \"Experimental RCS keyword support for git\"\n\nrm test.html\ngit checkout test.html\ncat test.html\n\nOn my system, I get:\n$Date: Tue Sep 16 10:15:02 EDT 2008$\n\nIf you have trouble getting the shell escapes in the smudge and clean commands to work, just write your own Perl scripts for expanding and removing RCS keywords, respectively, and use those scripts as your filter.\nNote that you really don't want to do this for more files than absolutely necessary, or git will lose most of its speed."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I add a file to the last commit in Git? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow to modify existing, unpushed commit messages?\n\n (27 answers)\n \n\nClosed 7 years ago.\n\n\n\nSometimes after I did a commit, I found out that I left out a file which should also be included in the commit, but was actually not. I often committed again:\ngit add the_left_out_file\ngit commit \"include the file which should be added in the last commit\"\n\nI think it might not be a good idea to do so. I want to just include the file without adding a commit. Something like this,\ngit add the_left_out_file\ngit add_staged_files_to_previous_commit\n\nIs it possible?"}, {"role": "assistant", "content": "Yes, there's a command, git commit --amend, which is used to \"fix\" the last commit.\nIn your case, it would be called as:\ngit add the_left_out_file\ngit commit --amend --no-edit\n\nThe --no-edit flag allows to make an amendment to the commit without changing the commit message.\nWarning\nYou should never amend public commits that you already pushed to a public repository, because amend is actually removing the last commit from the history and creating a new commit with the combined changes from that commit and new added when amending."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I clean up my Github fork so I can make clean pull requests?\n\nI forked a repository on Github. I've made some minor changes and submitted pull requests to the upstream, but along the way my fork has become so mangled I'm unable to generate clean pull requests; when I start a pull request from a branch with six changes, Github wants to submit thirteen, with seven of them already existing upstream (natch). \nMy problem seems to be related to only pulling the latest commits, but when I create a new branch and cherry-pick commits I still have extras. I've futzed with rebasing as well, but now it looks like even my master is so messed up I can't generate a clean copy of upstream. This is apparently because I didn't understand that I needed to rebase instead of merging, so clearly I've made mistakes; what I'm trying to do is figure out how to unsnarl that knot and get back to a clean state where I can move forward usefully.\nI kind of want to blow away my fork and make a new fork of the upstream, but I gather that, too, is difficult. \nHaving confessed my Git sins, how do I obtain github absolution?"}, {"role": "assistant", "content": "Step 1: Pull upstream changes\nIt's recommended to add the upstream repo as \"upstream\" as explained on the Fork a Repo page:\ngit pull --rebase upstream master\n\nThe --rebase option places your changes on top of the latest commit without merges.\nStep 2: (Optional) Merge your commits into 1 commit\ngit reset --soft upstream/master\n\nThis command will \"undo\" all your commits, but won't change the files. So you can commit all your changes in a single commit.\ngit commit -a\n\nStep 3: Check & test your changes\nTo show the changes use a GUI like the built-in gitk, Sourcetree, TortoiseGit or Tower (paid), etc.\nStep 4: Push\ngit push will throw an error, because the push would change the target repository's history.\nIf you're confident the changes shown in step 3 are correct then push with \"-f\"\ngit push -f origin master\n\n\nAdditional information\nThe command to add a remote is:\ngit remote add upstream git://github.com/[username]/[project].git\n\nYou can also also pull from a direct URL:\ngit pull --rebase git://github.com/[username]/[project].git\n\nBut then you'll need the hash of the latest upstream commit instead of \"upstream/master\" in the other steps."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-help"}, {"role": "assistant", "content": "Display help information about Git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to remove a dangling commit from GitHub?\n\nYesterday, I pushed to my fork of ConnectBot on GitHub. I pushed once, realized that I hadn't made the change the way I wanted, redid the commit and pushed again.\nNow, GitHub has both commits:\n\nhttps://github.com/nylen/connectbot/commit/1cd775d – the first, “bad” commit\nhttps://github.com/nylen/connectbot/commit/987671c – the one I want to keep\n\nMy master branch is only tracking the second commit, but the first commit is still available and is still in my activity feed. How can I remove it to make sure no one accidentally pulls that commit instead of the corrected version?"}, {"role": "assistant", "content": "If you really need it to be removed immediately, you would probably have to contact GitHub Support.\nPulling should generate a pack that contains only objects that are referenced so no one should get that commit as a result of a clone or a pull. For example,\n$ git clone git://github.com/nylen/connectbot.git\nCloning into connectbot...\nremote: Counting objects: 6261, done.\nremote: Compressing objects: 100% (1900/1900), done.\nremote: Total 6261 (delta 3739), reused 5980 (delta 3520)\nReceiving objects: 100% (6261/6261), 3.04 MiB | 3.40 MiB/s, done.\nResolving deltas: 100% (3739/3739), done.\n$ git cat-file -t 1cd775d\nfatal: Not a valid object name 1cd775d"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Multiple bitbucket accounts\nI have a Bitbucket account for my 9-5 job and I also have a personal Bitbucket account. My goal is to be able to use both on the same computer. I have installed the latest git on a Windows 7 pc.\nSo currently everything with my companies Bitbucket account works fine, I can pull/push with no problems. I created a new ssh key using ssh-keygen and assigned a new name in my case \"tech\". But I am having issues on how to tell a local repo to use the new ssh key I created. I am assuming everytime I try to connect it uses the first ssh key.\nI get the error:\n$ git push\nconq: repository access denied.\nfatal: The remote end hung up unexpectedly\nI found some advice on the internet but it seems to relate to a linux/git setup, for example I can't find the \"config\" file on windows."}, {"role": "assistant", "content": "This blog post describes a straightforward way to add multiple ssh keys to a single computer and use one ssh key per a bitbucket account. It is much clearer than the official bitbucket documentation. To summarize:\nFirst, make sure you have a default account setup through a tutorial like this one on Github.\nFor the second account:\n\nCreate a new ssh key:\nssh-keygen -f ~/.ssh/<your second account name> -C \"<you email>\"\n\nAdd the ssh key:\nssh-add ~/.ssh/<key file name> \n\nUse pbcopy < ~/.ssh/<your second account name>.pub to copy the public key and add this key to your bitbucket account (in the settings area)\n\n(On Windows you can copy the ssh key using ssh-keygen -f ~/.ssh/<your account name> -c \"<your email>\" | clip or on Linux you can follow these instructions.)\n\nAdd the following to your ~/.ssh/config file. The first sets the default key for bitbucket.org. The second sets your second key to an alias bitbucket-account2 for bitbucket.org:\nHost bitbucket.org\n Hostname bitbucket.org\n IdentityFile ~/.ssh/id_rsa\n\nHost bitbucket-account2\n Hostname bitbucket.org\n PreferredAuthentications publickey\n IdentityFile ~/.ssh/<your second account name>\n\nYou can now clone projects with your default account the same way as before:\ngit clone [email protected]:username/project.git\n\nTo clone a project with the second identity, replace bitbucket.org with the Host that you specified in the ~/.ssh/config file (i.e. bitbucket-account2 above):\ngit clone git@bitbucket-account2:username/project.git\n\n\nThat's it!"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to use git-svn to checkout only trunk and not branches and tags?\nI'm working on a Java legacy project which has 20 modules connected to each other. So, each module has it's own branch and tag. The structure is like this: \n\n\n/projects\n .svn\n - module1\n .svn\n -trunk\n -branch\n -tag\n - module2\n .svn\n -trunk\n -branch\n -tag\n\n\nThe projects folder is around 30 GB which is nearly impossible to use git-svn clone to checkout all the modules, but it's because it counts all the branches and tags. \nIs it possible to just clone the project only trunk so I can start committing locally?"}, {"role": "assistant", "content": "Edit: I misread the question and answered what I thought you were asking, not what you actually asked.\nTo clone just the trunk\nCloning a single Subversion directory is easy, and it actually doesn't matter which directory you clone. Just don't specify any of the \"layout\" arguments, and give the path to the trunk directly:\ngit svn clone http://path.to.svn.repo/module1/trunk\n\nTo clone a specific module, including tags and branches and so forth\nA \"normal\" git svn clone would look something like the following:\ngit svn clone --stdlayout http://path.to.svn.repo/\n\nWhat you want to use instead will be thus:\ngit svn clone --stdlayout http://path.to.svn.repo/module1/\n\nThat will find the trunk, branch and tag subfolders of the module1 folder, and clone them for you."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-switch - Switch branches --discard-changes"}, {"role": "assistant", "content": "Proceed even if the index or the working tree differs from HEAD . Both the index and working tree are restored to match\nthe switching target. If --recurse-submodules is specified,\nsubmodule content is also restored to match the switching\ntarget. This is used to throw away local changes."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git how to give people push access that needs to be merged in by organizers?\nMy project has quite a few people and I want to give them all push & pull access because right now, they forked the project and when they make changes, they have to push to their fork and send me a pull request. Instead, I want them to be able to clone the main project at myusername/project and be able to push to it automatically.\nSo how would I do that?"}, {"role": "assistant", "content": "Ask for the username of the person you're adding as a collaborator. If they don't have one, they can sign up for GitHub.\nIn the top right corner of any page, click your username.\nOn your profile page, click the Repositories tab, then click the name of your repository.\nIn your repository's right sidebar, click Settings.\nClick the \"Collaborators\" tab.\nStart typing the collaborator's username.\nSelect the user from the drop-down menu.\nClick Add."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Github Authentication Failed - ... GitHub does not provide shell access\n$ git remote add origin [email protected]:lut/EvolutionApp.git\nfatal: remote origin already exists.\n\n$ git push -u origin master\nfatal: 'EvolutionApp' does not appear to be a git repository\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\nMy keys were added succesfully\n $ ssh -T [email protected]\n Hi lut! You've successfully authenticated, but GitHub does not provide shell access.\n\nThe Github article https://help.github.com/articles/generating-ssh-keys/ says that \"Shell access\" should not be an issue? What could the problem be?"}, {"role": "assistant", "content": "Try and redefine the ssh url for remote origin:\ngit remote set-url origin [email protected]:lut/EvolutionApp.git\n\nAnd try again.\nOnly git remote set-url can change an existing remote URL (as opposed to git remote add, to add a new remote name and URL)\nHere, the issue was the URL of the existing remote 'origin', EvolutionApp: it needed to be replaced by a valid one.\nUsing git config url.\"ssh://[email protected]/\".insteadOf https://github.com/ would not have helped, considering there was no HTTPS URL in the first place."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can I use GitHub's 2-Factor Authentication with TortoiseGit?\n\nWe like TortoiseGit, and want to take advantage of GitHub's 2-Factor Authentication...but the two don't seem to want to work together."}, {"role": "assistant", "content": "To compliment Cupcake's answer, use the Personal Access token feature within GitHub.com while using TortoiseGit:\n\nSet up 2-step auth.\nSet up a personal access token - taking note of the generated token (use the Copy to clipboard button next to the generated token).\nSet TortoiseGit to remember your password as detailed here.\nNow perform a pull operation on GitHub.com, enter your username, but instead of using your normal password, use the token that was generated in step #2.\nPerform another pull operation on GitHub.com to ensure the token is remembered."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order --left-right"}, {"role": "assistant", "content": "Mark which side of a symmetric difference a commit is reachable from.\nCommits from the left side are prefixed with < and those from\nthe right with > . If combined with --boundary , those\ncommits are prefixed with - . For example, if you have this topology: y---b---b branch B\n\t / \\ /\n\t / .\n\t / / \\\n\t o---x---a---a branch A you would get an output like this: $ git rev-list --left-right --boundary --pretty=oneline A...B\n\n\t>bbbbbbb... 3rd on b\n\t>bbbbbbb... 2nd on b\n\t<aaaaaaa... 3rd on a\n\t<aaaaaaa... 2nd on a\n\t-yyyyyyy... 1st on b\n\t-xxxxxxx... 1st on a"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "fatal: unable to access \".....\": gnutls_handshake() failed: Handshake failed\n\nI've been using Git for the past few months. Recently when I try to clone or to push, I keep on getting this error. I've researched on the internet but so far no solution has worked for me. Does anyone have an idea?\nExternal note : Now I moved to different country, it was working perfectly where I was before.\nGit Version : 2.11.0 , OS : Debian GNU/Linux 9.11 (stretch)\nError :\ngit push\nfatal: unable to access 'https://**************/': gnutls_handshake() failed: Handshake failed"}, {"role": "assistant", "content": "This is solution fix this issue on ubuntu server 14.04.x\n1, Edit file:\nsudo nano /etc/apt/sources.list\n\n2, Add to file sources.list\ndeb http://security.ubuntu.com/ubuntu xenial-security main\ndeb http://cz.archive.ubuntu.com/ubuntu xenial main universe\n\n3, Run command update and update CURL to new version\napt-get update && apt-get install curl\n\n4, Check version (Optional):\ncurl -V\nResponse :\n\ncurl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.28 librtmp/2.3\nProtocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp \nFeatures: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets \n\n5, Test connect with bitbucket (Optional)\nGIT_CURL_VERBOSE=1 git ls-remote https://bitbucket.org/\nResponse:\n\n\n* Closing connection 0\nfatal: repository 'https://bitbucket.org/' not found\n\nThis done."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What's the use of the staging area in Git?\nWhat is the point of git add . or git add <filename> to add it to the staging area? Why not just git commit -m \"blabla\"?\nI don't understand the value of the staging area."}, {"role": "assistant", "content": "There are many uses of staging in Git. Some are listed below:\n\nstaging helps you split up one large change into multiple commits - Let's say you worked on a large-ish change, involving a lot of files and quite a few different subtasks. You didn't actually commit any of these -- you were \"in the zone\", as they say, and you didn't want to think about splitting up the commits the right way just then. (And you're smart enough not to make the whole thing one honking big commit!).\nNow the change is all tested and working, you need to commit all this properly, in several clean commits each focused on one aspect of the code changes.\nWith the index, just stage each set of changes and commit until no more changes are pending. Really works well with git gui if you're into that too, or you can use git add -p or, with newer gits, git add -e.\n\nstaging helps in reviewing changes - Staging helps you \"check off\" individual changes as you review a complex commit, and to concentrate on the stuff that has not yet passed your review. Let me explain. Before you commit, you'll probably review the whole change by using git diff. If you stage each change as you review it, you'll find that you can concentrate better on the changes that are not yet staged. git gui is great here. It's two left panes show unstaged and staged changes respectively, and you can move files between those two panes (stage/unstage) just by clicking on the icon to the left of the filename. Even better, you can even stage partial changes to a file. In the right pane of git gui, right click on a change that you approve of and choose \"stage hunk\". Just that change (not the entire file) is now staged; in fact, if there are other, unstaged, changes in that same file, you'll find that the file now appears on both top and bottom left panes!\n\nstaging helps when a merge has conflicts - When a merge happens, changes that merge cleanly are updated both in the staging area as well as in your work tree. Only changes that did not merge cleanly (i.e., caused a conflict) will show up when you do a git diff, or in the top left pane of git gui. Again, this lets you concentrate on the stuff that needs your attention -- the merge conflicts.\n\nstaging helps you keep extra local files hanging around - Usually, files that should not be committed go into .gitignore or the local variant, .git/info/exclude. However, sometimes you want a local change to a file that cannot be excluded (which is not good practice but can happen sometimes). For example, perhaps you upgraded your build environment and it now requires an extra flag or option for compatibility, but if you commit the change to the Makefile, the other developers will have a problem. Of course you have to discuss with your team and work out a more permanent solution, but right now, you need that change in your working tree to do any work at all! Another situation could be that you want a new local file that is temporary, and you don't want to bother with the ignore mechanism. This may be some test data, a log file or trace file, or a temporary shell script to automate some test... whatever. In git, all you have to do is never to stage that file or that change. That's it.\n\nstaging helps you sneak in small changes - Let's say you're in the middle of a somewhat large-ish change and you are told about a very important bug that needs to be fixed asap. The usual recommendation is to do this on a separate branch, but let's say this fix is really just a line or two, and can be tested just as easily without affecting your current work. With git, you can quickly make and commit only that change, without committing all the other stuff you're still working on. Again, if you use git gui, whatever's on the bottom left pane gets committed, so just make sure only that change gets there and commit, then push!"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options core.unsetenvvars"}, {"role": "assistant", "content": "Windows-only: comma-separated list of environment variables'\nnames that need to be unset before spawning any other process.\nDefaults to PERL5LIB to account for the fact that Git for\nWindows insists on using its own Perl interpreter."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I tell which remote \"parent\" branch my branch is based on?\nI have a scenario in which there a several remote tracking branches within my local repository that I must sync up to. Our workflow model is:\n\nmake a branch locally, based off of the desired remote tracking branch\nmake our changes\nbuild/test/fix\ncommit\npush back to the remote server\n\nI've noticed that \"git status\" doesn't show me what branch my local branch is based on unless something has changed; i.e. uncommitted local changes or a recent fetch puts my local branch behind the times. Is there some way of knowing what branch my local branch is based on without having to change things? Something like, \"git status -showparentbranch\" or some other command that would show this. Occasionally I run into this need but don't know yet how to satisfy it."}, {"role": "assistant", "content": "try this: \ngit log --graph --decorate"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --no-color"}, {"role": "assistant", "content": "Turn off colored diff.\nThis can be used to override configuration settings.\nIt is the same as --color=never ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to assign a Git SHA1's to a file without Git?\nAs I understand it when Git assigns a SHA1 hash to a file this SHA1 is unique to the file based on its contents. \nAs a result if a file moves from one repository to another the SHA1 for the file remains the same as its contents have not changed. \nHow does Git calculate the SHA1 digest? Does it do it on the full uncompressed file contents? \nI would like to emulate assigning SHA1's outside of Git."}, {"role": "assistant", "content": "This is how Git calculates the SHA1 for a file (or, in Git terms, a \"blob\"):\nsha1(\"blob \" + filesize + \"\\0\" + data)\n\nSo you can easily compute it yourself without having Git installed. Note that \"\\0\" is the NULL-byte, not a two-character string.\nFor example, the hash of an empty file:\nsha1(\"blob 0\\0\") = \"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391\"\n\n$ touch empty\n$ git hash-object empty\ne69de29bb2d1d6434b8b29ae775ad8c2e48c5391\n\nAnother example:\nsha1(\"blob 7\\0foobar\\n\") = \"323fae03f4606ea9991df8befbb2fca795e648fa\"\n\n$ echo \"foobar\" > foo.txt\n$ git hash-object foo.txt \n323fae03f4606ea9991df8befbb2fca795e648fa\n\nHere is a Python implementation:\nfrom hashlib import sha1\ndef githash(data):\n s = sha1()\n s.update(\"blob %u\\0\" % len(data))\n s.update(data)\n return s.hexdigest()"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git pre-commit hooks only for a specific subfolder?\nI currently have a single repo with two projects, each in their own subfolder: one in C# and one in Javascript. I want to have a pre-commit hook that will run jshint but only if any of the staged files are in the Javascript folder If the staged files are only from the C# folder, then the pre-commit hook won't run. \nIs it that possible at all? Or is my only solution to split the two projects into their own repos?"}, {"role": "assistant", "content": "If you use pre-commit, specify files to include (or exclude to exclude) specific directories, e.g. run hooks only in my_dir:\nfiles: ^my_dir/\nrepos:\n- repo: https://github.com/pre-commit/pre-commit-hooks\n hooks:\n ...\n\nor run everywhere but inside my_dir:\nexclude: ^my_dir/\nrepos:\n- repo: https://github.com/pre-commit/pre-commit-hooks\n hooks:\n ...\n\nIf you have a long list of exclusions, use verbose regex:\nexclude: >\n (?x)^(\n path/to/file1.py|\n path/to/file2.py|\n path/to/file3.py\n )$\n\nyou can also apply these to specific hooks only, just do:\n- id: my-hook\n exclude: ^my_dir/"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Unable to auto-detect email address\nI'm new to SmartGit. I can't commit through my repository, the message I'm receiving is:\nUnable to auto-detect email address (got 'Arreane@Arreane-PC.(none)')\n\n*** Please tell me who you are.\n\nRun\n git config --global user.email \"[email protected]\"\n git config --global user.name \"Your Name\"\n\n\nto set your account's default identity.\n\nOmit --global to set the identity only in this repository\n\nI'm using a different PC, but if I commit at home it commits and pushes perfectly, I don't know if this was the cause of the problem.\nI've searched around and others say to edit the .git/config file, but I cannot find this file.\nWhat am I missing?"}, {"role": "assistant", "content": "Well, the message is pretty much self-explanatory. You did not tell git what your name and email address is.\nOpen a command line and type:\ngit config --global user.email \"[email protected]\"\ngit config --global user.name \"Your Name\"\n\nOf course you should enter your real name and email.\nAfterwards git knows who you are and is able to insert this information in your commits.\nSeems like smartgit does not add the git binary to your path. You have to add its path to the PATH environment variable or first change to the corresponding directory. You can find a screencast here: http://blog.dragndream.com/?p=97"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to default to side-by-side view in GitLab\n\nHow can I make Side-by-side be the default diff for my GitLab installation or project or profile?"}, {"role": "assistant", "content": "Update February 2016\nThe issue is now at issue CE 3071 and... was resolved by commit 9fdd605!\nA cookie now retain your diff view choice, with GitLab 8.5.0+.\n\nOriginal answer (February 2015)\nThat doesn't seem to be possible right now, and can be voted up at the suggestion 7082397\n\nRemember side-by-side diff choice\nRight now when I want to review code, I have to choose side-by-side diff each time I open a Merge Request because that choice is not stored/saved anywhere.\nEither store my last choice/change of viewer globally somewhere and use it on all diff views from that point on.\nOr let me have a config option on my account where I can specify my preferred choice.\n\nThe side-by-side diff view was introduced with GitLab 6.4 (Dec. 2013) with commit b51c2c8."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Do I need to publish to npm every time I update a package available via git?\nSay I maintain an incredible crab-season package. I've npm published version 0.1.0 with a package.json containing:\n\"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/example/crab-season.git\"\n}\n\nWhen I add awesome new features, bump the version to 0.2.0, and push to github will the npmjs registry notice my new version or do I need to npm publish each time?"}, {"role": "assistant", "content": "Travis CI can publish to npm when you push a version tag to reduce the overhead of releasing a change. Enable in your .travis.yml with:\ndeploy: \n provider: npm\n api_key: \"YOUR API KEY\"\n on:\n - tags: true\n\nCheck the travis docs for details. There's also a step-by-step guide in this post."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git Cherry-Pick and Conflicts\nThere are two different git branches. In one the development is going in (Branch1).\nIn other branch some PoC work is going on (Branch2). Now, I want to cherry-pick the changes from Branch1 to Branch2, so that Branch2 is up to date.\nNow, after cherry-picking 4 or 5 changes, I am getting some merge conflict and I am unable to proceed with further cherry-picks.\nDo, I need to resolve all the conflicts before proceeding to next cherry -pick or Can I somehow postpone the conflict resolution till I cherry-pick all the changes (and resolve all conflicts together)?\nFurther, is it suggested to do cherry-pick or branch merge in this case?"}, {"role": "assistant", "content": "Before proceeding:\n\nInstall a proper mergetool. On Linux, I strongly suggest you to use meld:\nsudo apt-get install meld\n\nConfigure your mergetool:\ngit config --global merge.tool meld\n\n\nThen, iterate in the following way:\ngit cherry-pick ....\ngit mergetool\ngit cherry-pick --continue"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %b"}, {"role": "assistant", "content": "body"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git/GitHub commit with extended message/description\n\nI recently use GitHub and downloaded GitHub for Mac.\nI noticed you can add an 'extended description' using GitHub for Mac. How do I add an extended description using the command line?\nCan I add an extended description to an existing commit?"}, {"role": "assistant", "content": "From this accepted answer:\ngit commit -m \"Title\" -m \"Description ..........\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git ignore vim temporary files\nWhat is the correct way to make git ignore temporary files produced by vim in all directories (either globally across the system or locally for a single project)?"}, {"role": "assistant", "content": "Vim temporary files end with ~ so you can add to the file .gitignore the line\n*~\n\nVim also creates swap files that have the swp and swo extensions. to remove those use the lines:\n*.swp\n*.swo\n\nThis will ignore all the vim temporary files in a single project\nIf you want to do it globally, you can create a .gitignore file in your home (you can give it other name or location), and use the following command:\ngit config --global core.excludesfile ~/.gitignore\n\nThen you just need to add the files you want to ignore to that file.\nIf you want to comment in a Git file you must do this on a separate line:\n# Ignore vim files:\n*~\n*.swp\n*.swo\n\nAny comments placed on the same line as an active git ignore will cause the whole line to be misinterpreted."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Describe your workflow of using version control (VCS or DVCS) [closed]\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 10 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI'd like to learn other people workflow when using either vcs or dvcs. \nPlease describe your strategy to handle the following tasks:\n\nImplement a feature\nFixing bugs (during development and deployed app)\nCode Review\nRefactoring code (post code-review)\nIncorporate patches\nReleasing the newer version of your app (desktop, web, mobile, would you treat them differently?)\n\nFeel free to organize your answer not grouped by the tasks but grouped by whatever you think is relevant but please organize it by VCS/DVCS (please don't mix them). \nThank you."}, {"role": "assistant", "content": "The main feature all VCS use for the various task you are mentioning is branching: the ability to isolate a development effort in a collaborative way. Since it is a Central VCS, several developers can collaborate on a same branch, with pessimistic or optimistic locks on files, in order to develop a parallel history.\nBut being a VCS has two major impact on branching:\n\nIt tends to discourage commits, because once a file is committed, it will immediately influence the workspace of other views with the same configuration (i.e. \"working on the same branch\").\n~ The \"publication\" process is an active one, with immediate consequences,\n~ while the \"consuming\" part (updating your workspace) is a passive one (you are forced to deal with changes published by other immediately upon update of your workspace) \nIt works well for linear merge workflow (i.e. \"only merge from branch A to branch B, not mixing merges in both directions\" -- A to B to A to B...). The merges are trivial, all modifications from A are simply carried over to B\n\nNow:\nImplementing a feature\nAny VCS will do that by making a branch, but what greatly surprised me is that a \"feature\" branch is not easy:\n* the feature may grow too complicated\n* it may be ready in time for the next release\n* only some part of it may need to be merged back into the main development branch\n* it may depend on other features which are not fully done yet\nSo you need to be careful in the way you manage your feature branch, and your commits: if they are tightly related to the same feature, it will go well (you merge the whole thing back to your main development branch when you need it). Otherwise, partial merges are not easy with those tools.\nFixing bugs\nThe difference between bug fix during development and after release is that, in the former case you can often do it linearly in the same branch, as in the latter case you will have to establish a bug-fix branch, and decide what bugs you will need to back-port to your current development branch.\nCode Review\nIt is best used with external tools (like Crucible for instance), and uses VCS functions like blame or annotations extensively, in order to better assign code fixes after a review.\nRefactoring code (post code-review)\nIf the refactoring is minor, it can go on in the same branch. But if it is big, a special branch needs to be setup, with unit-testing done before beginning said refactoring.\nIncorporate patches\nSame comment as last point. If the patch is a big one, a branch needs to be created.\nReleasing the newer version of your app\nA VCS will only get you so far when it comes to releasing your app, because it is not a release management tool.\nYou will need to formerly identify a version to be released (label), but after that comes the deployment process which involves: \n\nstopping what is currently running\ncopying the new files\ndeploying them (updating sql database, webapp, ...)\ninstantiating all config files (with the right values, addresses, port number, paths, ...)\nrestarting (and if your system is composed of several components, restarting them in the right order!)\n\nThe key things with VCS and release management are:\n\nthey are not very well adapted to store binaries to be released, meaning you need them to build your app, not to store the resulting executable\nthey are not always welcome in the production environment (where security constraints limit writing access, as well as the number of tools running on those platforms, essentially monitoring and reporting tools)\n\nThe release mechanism also has an influence on binary dependencies:\n\nfor external binary dependencies, you will probably use mechanisms like maven to get fixed revisions of external libraries\nbut for internal dependencies, when you are not developing just one app but several which depends one upon an other, you need to know how to reference the binaries produced by the other apps (internal binary dependencies), and they usually won't be stored in your VCS (especially in the development phase, where you can produce a lot of different releases for your other apps to be able to use) \n\nYou can also choose to be in source dependencies (and get all the sources of the other internal projects you need for your own), and a VCS is well adapted for that, but it is not always possible/practical to recompile everything."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to avoid having to do \"git branch --set-upstream\", and instead default to automatically setup remote tracking?\nI create a new branch in Git:\ngit branch my_branch\n\nPush it:\ngit push origin my_branch\n\nNow say someone made some changes on the server and I want to pull from origin/my_branch. I do:\ngit pull\n\nBut I get:\nYou asked me to pull without telling me which branch you\nwant to merge with, and 'branch.my_branch.merge' in\nyour configuration file does not tell me, either. Please\nspecify which branch you want to use on the command line and\ntry again (e.g. 'git pull <repository> <refspec>').\nSee git-pull(1) for details.\n\nIf you often merge with the same branch, you may want to\nuse something like the following in your configuration file:\n\n [branch \"my_branch\"]\n remote = <nickname>\n merge = <remote-ref>\n\n [remote \"<nickname>\"]\n url = <url>\n fetch = <refspec>\n\nSee git-config(1) for details.\n\nI learned that I can make it work with:\ngit branch --set-upstream my_branch origin/my_branch\n\nBut why do I need to do this for every branch I create? Isn't it obvious that if I push my_branch into origin/my_branch, then I would want to pull origin/my_branch into my_branch? How can I make this the default behavior?"}, {"role": "assistant", "content": "Git v2.37.1 and above\nIf you are using the mentioned version or above you can use this new config entry to automatically setup remote tracking:\ngit config --global push.autoSetupRemote true\nAfter that, when you do git push tracking is setup automatically. No need for git push -u origin my_branch\n\nA shortcut, which doesn't depend on remembering the syntax for git branch --set-upstream 1 is to do:\ngit push -u origin my_branch\n\n... the first time that you push that branch. Or, to push to the current branch from a branch of the same name (handy for an alias):\ngit push -u origin HEAD\n\nYou only need to use -u once, and that sets up the association between your branch and the one at origin in the same way as git branch --set-upstream does.\nPersonally, I think it's a good thing to have to set up that association between your branch and one on the remote explicitly. It's just a shame that the rules are different for git push and git pull.\n\n1 It may sound silly, but I very frequently forget to specify the current branch, assuming that's the default - it's not, and the results are most confusing.\nUpdate 2012-10-11: Apparently I'm not the only person who found it easy to get wrong! Thanks to VonC for pointing out that git 1.8.0 introduces the more obvious git branch --set-upstream-to, which can be used as follows, if you're on the branch my_branch:\ngit branch --set-upstream-to origin/my_branch\n\n... or with the short option:\ngit branch -u origin/my_branch\n\nThis change, and its reasoning, is described in the release notes for git 1.8.0, release candidate 1:\n\nIt was tempting to say git branch --set-upstream origin/master, but that tells Git to arrange the local branch origin/master to integrate with the currently checked out branch, which is highly unlikely to be what the user meant. The option is deprecated; use the new --set-upstream-to (with a short-and-sweet -u) option instead."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do you fix a bad merge, and replay your good commits onto a fixed merge?\nI accidentally committed an unwanted file (filename.orig while resolving a merge) to my repository several commits ago, without me noticing it until now. I want to completely delete the file from the repository history. \nIs it possible to rewrite the change history such that filename.orig was never added to the repository in the first place?"}, {"role": "assistant", "content": "Please don't use this recipe if your situation is not the one described in the question. This recipe is for fixing a bad merge, and replaying your good commits onto a fixed merge.\nAlthough filter-branch will do what you want, it is quite a complex command and I would probably choose to do this with git rebase. It's probably a personal preference. filter-branch can do it in a single, slightly more complex command, whereas the rebase solution is performing the equivalent logical operations one step at a time.\nTry the following recipe:\n# create and check out a temporary branch at the location of the bad merge\ngit checkout -b tmpfix <sha1-of-merge>\n\n# remove the incorrectly added file\ngit rm somefile.orig\n\n# commit the amended merge\ngit commit --amend\n\n# go back to the master branch\ngit checkout master\n\n# replant the master branch onto the corrected merge\ngit rebase tmpfix\n\n# delete the temporary branch\ngit branch -d tmpfix\n\n(Note that you don't actually need a temporary branch, you can do this with a 'detached HEAD', but you need to take a note of the commit id generated by the git commit --amend step to supply to the git rebase command rather than using the temporary branch name.)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "On GitLab, how to compare a file of two different commits\n\nOn GitLab, how to compare a file of two different commits? I know that that on command line git, the command is:\ngit diff commit1 commit12 -- file_name\n\nWhat is the link format to do this on GitLab?\nSee my related question"}, {"role": "assistant", "content": "It will compare commits, you will be able to find file in list.\n\ngo to Repository > Compare\npaste this url: https://gitlab.com/$USER/$REPO/compare?from=$SHA1&to=$SHA2 or https://your gitlab domain/$ORG/$GROUP/$REPO/-/compare?from=$SHA1&to=$SHA2\nhit enter (notice: gitlab will set 'Source' and 'Target' properly)\nclick button 'compare'"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git command could not be found and could not find ssh-agent\nI was on GitHub today and realized I was behind on updates from a repo. I tried to fetch updates, but it failed from the outset. I received two messages when I started up Git Shell (from GitHub for Windows):\n\nWarning: git command could not be found. Please create an alias or add it to your PATH.\nWarning: Could not find ssh-agent.\n\nWhen I attempted to enter \"$ git fetch origin\", I got the following error message:\n\nThe term '$' is not recognized as the name of a cmdlet, function, script file,\nor operable program. Check the spelling of the name, or if a path was included,\nverify that the path is correct and try again.\n\nI also tried omitting the $ sign, but that didn't change anything.\nI have no clue what's going on, the last time I used the Shell (beginning of this month), it did not do this. I have tried adding the path to git.exe to the PATH environment variable, but that did not work - nothing appeared to change. I have not restarted my computer after doing so, is that the problem? I have also never set up Git to use SSH."}, {"role": "assistant", "content": "It sounds like you recently updated GitHub application and Git Shell is now broken.\nShort version\nTo fix it\n\nclose Git Shell\nopen GitHub and let it do some post installation.\nOpen Git Shell again and you should be fixed.\n\nLong version\nThis just happened to me and just to make sure I follow you, you just did this\n\nOpen Git Shell\nYou are prompted to update GitHub\nAfter the update, Git Shell opens\n\nNow it gives the error \n\ngit command could not be found. Please create an alias or add it to\n your PATH.\nWarning: Could not find ssh-agent.\n\nIf this is the case, do this\n\nClose Git Shell\nNow open the GitHub application (not Git Shell).\n\nThis will say something along the lines of (not sure of the exact version)\n\nGitHub is extracting git..\n\nLet that go through the process and after it is complete, go open Git Shell and it is fixed. Just worked for me at least."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to specify a git commit message template for a repository in a file at a relative path to the repository?\nIs there a way to specify a git commit.template that is relative to a repository?\nFor configuration an example is\n$ git config commit.template $HOME/.gitmessage.txt\n\nBut I would like to specify a template file relative to the .git folder of the repository."}, {"role": "assistant", "content": "This blog tipped me off that if the path to the template file is not absolute, then the path is considered to be relative to the repository root.\ngit config commit.template /absolute/path/to/file\n\nor\n\ngit config commit.template relative-path-from-repository-root"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-push - Update remote refs along with associated objects git push origin :experimental"}, {"role": "assistant", "content": "Find a ref that matches experimental in the origin repository\n(e.g. refs/heads/experimental ), and delete it."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to rebase a branch off a rebased branch?\nSo my history looks like this:\n\no---o---o---o master\n \\\n o---o---o A\n \\\n o B\n\nSo, to explain:\n\nI have branch A which was started from master\nI have branch B (with only 1 commit) which was started from A\n\nWhat I want is this:\n\no---o---o---o master\n \\\n o---o---o A\n \\\n o B\n\n\nWhat I did was:\n1).\n\ngit checkout A\ngit rebase master\n\nThis resulted in a lot of conflicts which, after some significant time spent fixing, the following history emerged:\n\no---o---o---o master\n \\\n o---o---o A\n\nWhich is exactly what I wanted.\n(I don't know where B is right now)\n\n2).\nAfter this I did a lot of squashes and changed the order of commits on A, to make the history look like I want.\n\n3).\nNow, what I also want to do is:\n\ngit checkout B\ngit rebase A\n\nHowever this doesn't seem to work and I don't know why. If I do git log I see the commits which were there before I did step 1.\nAlso, I get the same huge number of conflicts which I already solved at step 1. I spent significant time doing it, don't want to do it again.\nThis example suggested to use --onto, which I did:\n\ngit checkout B\ngit rebase --onto A\n\nBut this deletes the commit on B entirely and makes A and B point to the same commit i.e. the last one on A.\n\nMy question is: How can I effectively rebase B off A so that it looks like B started from A ? (which was actually true in the beginning).\nMy best guess is that I'm using --onto wrong. Or that I should use something else (like cherry-pick)."}, {"role": "assistant", "content": "Short answer to How can I effectively rebase B off A so that it looks like B started from A?\nAssuming you want to move exactly one commit:\ngit rebase --onto A B~ B\n\nIf you want to move more then one commit use:\ngit rebase --onto A old_A B\n\nThe rest of the answer.\nYour branch of B is still around (you can check it out), but its parent is still the exact commit object that A was before.\nto see a graphical representation of this I use:\ngit log --graph --decorate --all\n\nto see all branches and where they are with respect to each other.\nWhat you originally had:\no---o---o---o master\n \\\n o---o---o A\n \\\n o B\n\nWhat you have now:\no---o---o-----------o master\n \\ \\\n o---o---o(B~) o---o---o A\n \\\n o B\n\nIn terms of using --onto, you need to have a starting point and an ending point.\nuse:\ngit rebase --onto [target] [rebasing stops] [rebasing head]\ngit rebase --onto A B~ B\n\nAnd what you get:\no---o---o----------o master\n \\ \\\n o---o---o o---o---o A\n (old_A) \\\n o B\n\n[branch_name]~ indicates the parent commit of the branch.\nThe B~ is the branch that you do not want to change. (It happens to be the old A)\nAlternatively, if B was the only commit that had A as a parent, (i.e., B is the end of a chain of commits that branch off master) you could do\ngit checkout B\ngit rebase master\ngit checkout B~ # this is the commit before B (the A commit)\ngit branch -d A # remove the old A branch (it was rebased, and so is now invalid\ngit branch A # recreate the A branch on the commit that is based on the original A"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Clone A Private Repository (Github)\n\nI have a private repository on Github for a project I'm working on. Until now I had only worked on my home desktop, but I just bought a laptop, and am trying to set it up so that I can work on the project from either computer, and push / pull changes.\nI added a new SSH key to my Github account for the laptop, and was successful in cloning and making changes to a public test repo that I set up. However, I couldn't clone the private repo. Is there anything special I need to do in the command line in order to clone a private repo? Do I need to set up a new GitHub account for my laptop and set myself up as a collaborator?\nThe command I used was git clone git://github.com/username/reponame.git"}, {"role": "assistant", "content": "Apr, 2022 Update:\nYou can clone a private repository from your account and you can also clone a private repository from organization if you're its owner or member.\n*pat is PAT(Personal Access Token).\ngit clone https://<pat>@github.com/<your account or organization>/<repo>.git\n\nTo clone a private repository from your account or organization, you need to generate a PAT(Personal Access Token) on your Github account, and add it to the command above. *Organization doesn't have PAT generator.\nThis is how you generate a PAT on your Github account:\n1, Go to \"Settings\":\n\n2, Scroll down then go to \"Developer settings\":\n\n3, Press \"Personal access tokens\" then press \"Generate new token\":\n\n4, Fill \"Note\" then check \"repo\":\n*If \"repo\" is not checked, you cannot clone a private repository.\n\n5, Scroll down then press \"Generate token\":\n\n6, Finally, a PAT is generated:\n\nThis is the command with the PAT generated above:\ngit clone https://[email protected]/<your account or organization>/<repo>.git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "'git branch -av' showing remote branch that no longer exists\nThis is probably a dumb question, but I'm brand new to git and am seeing a remote branch that no longer exists.\n$ git branch -a\n* master\n remotes/origin/master\n remotes/origin/production\n\nI don't believe the production branch exists remotely and can't figure out why it still shows locally. How can I delete/remove this branch? Here's what an attempt to remove it looks like:\n$ git push origin :production\n\nerror: unable to push to unqualified destination: production\nThe destination refspec neither matches an existing ref on the remote nor\nbegins with refs/, and we are unable to guess a prefix based on the source ref.\nerror: failed to push some refs to 'git@IP:puppet.git'\n\nI can checkout the supposedly remote production branch but get this:\n$ git checkout origin/production\nNote: checking out 'origin/production'.\n\nYou are in 'detached HEAD' state. You can look around, make experimental\nchanges and commit them, and you can discard any commits you make in this\nstate without impacting any branches by performing another checkout.\n\nIf you want to create a new branch to retain commits you create, you may\ndo so (now or later) by using -b with the checkout command again. Example:\n\n git checkout -b new_branch_name\n\nHEAD is now at c323996... added powerdns module, no really\n\nI have no clue what the heck I'm doing. Any help would be appreciated."}, {"role": "assistant", "content": "You have to do:\ngit remote prune origin"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs -M[<n>] --find-renames[=<n>]"}, {"role": "assistant", "content": "If generating diffs, detect and report renames for each commit.\nFor following files across renames while traversing history, see --follow .\nIf n is specified, it is a threshold on the similarity\nindex (i.e. amount of addition/deletions compared to the\nfile’s size). For example, -M90% means Git should consider a\ndelete/add pair to be a rename if more than 90% of the file\nhasn’t changed. Without a % sign, the number is to be read as\na fraction, with a decimal point before it. I.e., -M5 becomes\n0.5, and is thus the same as -M50% . Similarly, -M05 is\nthe same as -M5% . To limit detection to exact renames, use -M100% . The default similarity index is 50%."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How should I use git diff for long lines?\nI'm running git-diff on a file, but the change is at the end of a long line.\nIf I use cursor keys to move right, it loses colour-coding—and worse the lines don't line up—making it harder to track the change.\nIs there a way to prevent that problem or to simply make the lines wrap instead?\nI'm running Git 1.5.5 via mingw32."}, {"role": "assistant", "content": "Or if you use less as default pager just type -S while viewing the diff to reenable wrapping in less."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-merge - Join two or more development histories together merge.suppressDest"}, {"role": "assistant", "content": "By adding a glob that matches the names of integration\nbranches to this multi-valued configuration variable, the\ndefault merge message computed for merges into these\nintegration branches will omit \"into <branch name>\" from\nits title. An element with an empty value can be used to clear the list\nof globs accumulated from previous configuration entries.\nWhen there is no merge.suppressDest variable defined, the\ndefault value of master is used for backward compatibility."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-notes - Add or inspect object notes copy"}, {"role": "assistant", "content": "Copy the notes for the first object onto the second object (defaults to\nHEAD). Abort if the second object already has notes, or if the first\nobject has none (use -f to overwrite existing notes to the\nsecond object). This subcommand is equivalent to: git notes add [-f] -C $(git notes list <from-object>) <to-object> In --stdin mode, take lines in the format <from-object> SP <to-object> [ SP <rest> ] LF on standard input, and copy the notes from each <from-object> to its\ncorresponding <to-object>. (The optional <rest> is ignored so that\nthe command can read the input given to the post-rewrite hook.)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --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."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-push"}, {"role": "assistant", "content": "Update remote refs along with associated objects"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-parse - Pick out and massage parameters --shared-index-path"}, {"role": "assistant", "content": "Show the path to the shared index file in split index mode, or\nempty if not in split-index mode."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_PRINT_SHA1_ELLIPSIS (deprecated)"}, {"role": "assistant", "content": "If set to yes , print an ellipsis following an\n(abbreviated) SHA-1 value. This affects indications of\ndetached HEADs ( git-checkout ) and the raw\ndiff output ( git-diff ). Printing an\nellipsis in the cases mentioned is no longer considered\nadequate and support for it is likely to be removed in the\nforeseeable future (along with the variable)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker <old|new>-file"}, {"role": "assistant", "content": "are files GIT_EXTERNAL_DIFF can use to read the\ncontents of <old|new>,"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc Various ways to check your working tree"}, {"role": "assistant", "content": "$ git diff (1) $ git diff --cached (2) $ git diff HEAD (3) $ git diff AUTO_MERGE (4) Changes in the working tree not yet staged for the next commit. Changes between the index and your last commit; what you\nwould be committing if you run git commit without -a option. Changes in the working tree since your last commit; what you\nwould be committing if you run git commit -a Changes in the working tree you’ve made to resolve textual\nconflicts so far."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Warning: push.default is unset; its implicit value is changing in Git 2.0\nI've been using Git for a while now and have recently downloaded an update only to find this warning message come up when I try to push.\nwarning: push.default is unset; its implicit value is changing in \nGit 2.0 from 'matching' to 'simple'. To squelch this message \nand maintain the current behavior after the default changes, use: \n\n git config --global push.default matching\n\nTo squelch this message and adopt the new behavior now, use: \n\n git config --global push.default simple\n\nI can obviously set it to one of the values mentioned, but what do they mean? What's the difference between simple and matching?\nIf I change it on one client will I need to do anything on other clients that I share repos with?"}, {"role": "assistant", "content": "It's explained in great detail in the docs, but I'll try to summarize:\n\nmatching means git push will push all your local branches to the ones with the same name on the remote. This makes it easy to accidentally push a branch you didn't intend to. \nsimple means git push will push only the current branch to the one that git pull would pull from, and also checks that their names match. This is a more intuitive behavior, which is why the default is getting changed to this.\n\nThis setting only affects the behavior of your local client, and can be overridden by explicitly specifying which branches you want to push on the command line. Other clients can have different settings, it only affects what happens when you don't specify which branches you want to push."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects --cc"}, {"role": "assistant", "content": "Produce dense combined diff output for merge commits.\nShortcut for --diff-merges=dense-combined -p ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --alternate-refs"}, {"role": "assistant", "content": "Pretend as if all objects mentioned as ref tips of alternate\nrepositories were listed on the command line. An alternate\nrepository is any repository whose object directory is specified\nin objects/info/alternates . The set of included objects may\nbe modified by core.alternateRefsCommand , etc. See git-config ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Add git information to create-react-app\nIn development, I want to be able to see the build information (git commit hash, author, last commit message, etc) from the web. I have tried:\n\nuse child_process to execute a git command line, and read the result (Does not work because browser environment)\ngenerate a buildInfo.txt file during npm build and read from the file (Does not work because fs is also unavailable in browser environment)\nuse external libraries such as \"git-rev\" \n\nThe only thing left to do seems to be doing npm run eject and applying https://www.npmjs.com/package/git-revision-webpack-plugin , but I really don't want to eject out of create-react-app. Anyone got any ideas?"}, {"role": "assistant", "content": "On a slight tangent (no need to eject and works in develop),\nthis may be of help to other folk looking to add their current git commit SHA into their index.html as a meta-tag by adding:\nREACT_APP_GIT_SHA=`git rev-parse --short HEAD`\n\nto the build script in the package.json and then adding (note it MUST start with REACT_APP... or it will be ignored):\n<meta name=\"ui-version\" content=\"%REACT_APP_GIT_SHA%\">\n\ninto the index.html in the public folder.\nWithin react components, do it like this:\n<Component>{process.env.REACT_APP_GIT_SHA}</Component>"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How line ending conversions work with git core.autocrlf between different operating systems\nI've read a lot of different questions and answers on Stack Overflow as well as git documentation on how the core.autocrlf setting works.\nThis is my understanding from what I've read:\nUnix and Mac OSX (pre-OSX uses CR) clients use LF line endings.\nWindows clients use CRLF line endings.\nWhen core.autocrlf is set to true on the client, the git repository always stores files in LF line ending format and line endings in files on the client are converted back and forth on check out / commit for clients (i.e. Windows) that use non-LF line endings, no matter what format the line endings files are on the client (this disagrees with Tim Clem's definition - see update below).\nHere is a matrix that tries to document the same for the 'input' and 'false' settings of core.autocrlf with question marks where I'm not sure of line ending conversion behavior.\nMy questions are:\n\nWhat should the question marks be?\nIs this matrix correct for the \"non-question marks\"?\n\nI'll update the question marks from the answers as consensus appears to be formed.\n\n core.autocrlf value\n true input false\n----------------------------------------------------------\ncommit | convert ? ?\nnew | to LF (convert to LF?) (no conversion?)\n\ncommit | convert to ? no \nexisting | LF (convert to LF?) conversion\n\ncheckout | convert to ? no\nexisting | CRLF (no conversion?) conversion\n\n\nI'm not really looking for opinions on the pros and cons of the various settings. I'm just looking for data which makes it clear how to expect git to operate with each of the three settings.\n--\nUpdate 04/17/2012: After reading the article by Tim Clem linked by JJD in the comments, I have modified some of the values in the \"unknown\" values in the table above, as well as changing \"checkout existing | true to convert to CRLF instead of convert to client\". Here are the definitions he gives, which are more clear than anything I've seen elsewhere:\ncore.autocrlf = false\n\nThis is the default, but most people are encouraged to change this\nimmediately. The result of using false is that Git doesn’t ever mess\nwith line endings on your file. You can check in files with LF or CRLF\nor CR or some random mix of those three and Git does not care. This\ncan make diffs harder to read and merges more difficult. Most people\nworking in a Unix/Linux world use this value because they don’t have\nCRLF problems and they don’t need Git to be doing extra work whenever\nfiles are written to the object database or written out into the\nworking directory.\n\ncore.autocrlf = true\n\nThis means that Git will process all text files and make sure that\nCRLF is replaced with LF when writing that file to the object database\nand turn all LF back into CRLF when writing out into the working\ndirectory. This is the recommended setting on Windows because it\nensures that your repository can be used on other platforms while\nretaining CRLF in your working directory.\n\ncore.autocrlf = input\n\nThis means that Git will process all text files and make sure that\nCRLF is replaced with LF when writing that file to the object\ndatabase. It will not, however, do the reverse. When you read files\nback out of the object database and write them into the working\ndirectory they will still have LFs to denote the end of line. This\nsetting is generally used on Unix/Linux/OS X to prevent CRLFs from\ngetting written into the repository. The idea being that if you pasted\ncode from a web browser and accidentally got CRLFs into one of your\nfiles, Git would make sure they were replaced with LFs when you wrote\nto the object database.\n\nTim's article is excellent, the only thing I can think of that is missing is that he assumes the repository is in LF format, which is not necessarily true, especially for Windows only projects.\nComparing Tim's article to the highest voted answer to date by jmlane shows perfect agreement on the true and input settings and disagreement on the false setting."}, {"role": "assistant", "content": "The best explanation of how core.autocrlf works is found on the gitattributes man page, in the text attribute section.\nThis is how core.autocrlf appears to work currently (or at least since v1.7.2 from what I am aware):\n\ncore.autocrlf = true\n\n\nText files checked-out from the repository that have only LF characters are normalized to CRLF in your working tree; files that contain CRLF in the repository will not be touched\nText files that have only LF characters in the repository, are normalized from CRLF to LF when committed back to the repository. Files that contain CRLF in the repository will be committed untouched.\n\n\ncore.autocrlf = input\n\n\nText files checked-out from the repository will keep original EOL characters in your working tree.\nText files in your working tree with CRLF characters are normalized to LF when committed back to the repository.\n\n\ncore.autocrlf = false\n\n\ncore.eol dictates EOL characters in the text files of your working tree.\ncore.eol = native by default, which means working tree EOLs will depend on where git is running: CRLF on a Windows machine, or LF in *nix.\nRepository gitattributes settings determines EOL character normalization for commits to the repository (default is normalization to LF characters).\n\nI've only just recently researched this issue and I also find the situation to be very convoluted. The core.eol setting definitely helped clarify how EOL characters are handled by git."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-hook"}, {"role": "assistant", "content": "Run git hooks"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to prevent phabricator from eating my commit history\n\nHere is the scenario that is pretty much annoying me.\nJack works in foobar a software house, Jack is a Working Programmer, he loves coding and commits frequently. Paul who is jack's manager tells him that we are going to start using a new code review tool, phabricator. Jack complies, Jack creates a local branch and starts working. He adds features and commits to his local branch very frequently. Now at the end of the day he sends a phabricator request.\narc diff development\n\nJohn who is jacks team member reviews his code and accepts his changes.\nNow Jack opens the terminal and moves to his repository directory.\nJack types the following command to close the revision and merge his code with the development branch.\narc land --onto development\n\nHe sees the following message\nLanding current branch 'feature-awesome-features'.\nSwitched to branch development. Updating branch...\nThe following commit(s) will be landed:\n\nb2ff76e Added the foo to bar\n33f33ba Added a really important check which can destroy the project or save it\n31a4c9a Added that new awesome feature\n8cae3bf rewrote that awful code john wrote\nbc54afb bug fixes\n\nSwitched to branch feature-awesome-features. Identifying and merging...\nLanding revision 'D1067: Added the awesome feature'...\nRebasing feature-awesome-features onto development\nAlready up-to-date.\nPushing change...\n\nNow jack opens Github to see his code , his beautiful commits. but what he sees is pure horror all of his commits have been replaced by a single commit which basically says something like this\nSummary: Added the awesome feature\n\nTest Plan: do foo bar testing\n\nReviewers: John\n\nReviewed By: John\n\nCC: Paul\n\nDifferential Revision: http://phabricator.foobar.com/D1067\n\nNow jack is sad, because he wants to see all of his commits, jack thinks that this commit makes him look like The Hoarder which he is not. He wants to fix this so he goes to ask a question on stackoverflow.\nThat how may he prevent phabricator from eating his commit history."}, {"role": "assistant", "content": "asherkin's answer explains the rationale for this behavior, and why this is the default.\nIf you don't find that argument compelling, you can use the --merge flag to arc land to perform --no-ff merges instead of --squash merges. These merges will not destroy local commits.\nIf you set history.immutable to true in your .arcconfig, arc land will --no-ff merge by default.\nYou can also use raw git commands if you don't like the behavior of arc land; it is provided only for convenience.\nIn your example, we recommend creating five separate reviews -- there are multiple different ideas being implemented, and they are not related and seem easily separable. See Writing Reviewable Code. Combining bugfixes, style changes and new features into one change is hoarding."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rebase - Reapply commits on top of another base tip Hard case: The changes are not the same."}, {"role": "assistant", "content": "This happens if the subsystem rebase had conflicts, or used --interactive to omit, edit, squash, or fixup commits; or\nif the upstream used one of commit --amend , reset , or\na full history rewriting command like filter-repo ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is there a migration tool from CVS to Git?\nI intend to switch over from CVS to Git. \nIn the case of SVN, there seems to be cvs2svn. Is there a similar tool to easily migrate from CVS to Git?"}, {"role": "assistant", "content": "The only tool that has incremental import seems to be git-cvsimport. If you want to convert (migrate) from CVS to Git, the best solution for now seems to be mentioned above cvs2git mode of cvs2svn.\nSee also Interfaces Frontends And Tools page on Git wiki, section about interaction with other revision control systems."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Resolve conflicts using remote changes when pulling from Git remote\nI'm trying to pull code from my GitHub repo onto my server, but the pull keeps failing because of merge conflicts. I don't want to keep any of the changes that may have occurred on my local server since the last pull.\nSo is there a way I can force Git to overwrite with whatever version is in GitHub, rather than bother me about conflicts?"}, {"role": "assistant", "content": "If you truly want to discard the commits you've made locally, i.e. never have them in the history again, you're not asking how to pull - pull means merge, and you don't need to merge. All you need do is this:\n# fetch from the default remote, origin\ngit fetch\n# reset your current branch (master) to origin's master\ngit reset --hard origin/master\n\nI'd personally recommend creating a backup branch at your current HEAD first, so that if you realize this was a bad idea, you haven't lost track of it.\nIf on the other hand, you want to keep those commits and make it look as though you merged with origin, and cause the merge to keep the versions from origin only, you can use the ours merge strategy:\n# fetch from the default remote, origin\ngit fetch\n# create a branch at your current master\ngit branch old-master\n# reset to origin's master\ngit reset --hard origin/master\n# merge your old master, keeping \"our\" (origin/master's) content\ngit merge -s ours old-master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-ls-files - Show information about files in the index and the working tree --exclude-per-directory=<file>"}, {"role": "assistant", "content": "Read additional exclude patterns that apply only to the\ndirectory and its subdirectories in <file>. If you are\ntrying to emulate the way Porcelain commands work, using\nthe --exclude-standard option instead is easier and more\nthorough."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-ls-remote"}, {"role": "assistant", "content": "List references in a remote repository"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Make the current commit the only (initial) commit in a Git repository?\n\nI currently have a local Git repository, which I push to a Github repository.\nThe local repository has ~10 commits, and the Github repository is a synchronised duplicate of this.\nWhat I'd like to do is remove ALL the version history from the local Git repository, so the current contents of the repository appear as the only commit (and therefore older versions of files within the repository are not stored). \nI'd then like to push these changes to Github.\nI have investigated Git rebase, but this appears to be more suited to removing specific versions.\nAnother potential solution is to delete the local repo, and create a new one - though this would probably create a lot of work!\nETA: There are specific directories / files that are untracked - if possible I would like to maintain the untracking of these files."}, {"role": "assistant", "content": "Here's the brute-force approach. It also removes the configuration of the repository.\nNote: This does NOT work if the repository has submodules! If you are using submodules, you should use e.g. interactive rebase\nStep 1: remove all history (Make sure you have a backup, this cannot be reverted)\ncat .git/config # save your <github-uri> somewhere\nrm -rf .git\n\nStep 2: reconstruct the Git repo with only the current content\nBefore step 2 if you have not set up init.defaultBranch configuration then, please do it via git config --global init.defaultBranch <branch-name> you may choose main as <branch-name> in the current example\ngit init\ngit add .\ngit commit -m \"Initial commit\"\n\nStep 3: push to GitHub.\ngit remote add origin <github-uri>\ngit push -u --force origin main"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to clone all repos at once from GitHub?\nI have a company GitHub account and I want to back up all of the repositories within, accounting for anything new that might get created for purposes of automation. I was hoping something like this:\ngit clone [email protected]:company/*.git \n\nor similar would work, but it doesn't seem to like the wildcard there. \nIs there a way in Git to clone and then pull everything assuming one has the appropriate permissions?"}, {"role": "assistant", "content": "Simple script using GitHub CLI (no API keys)\nHere's a simple solution using the official GitHub CLI tool, gh - no need for API keys and can handle up to 4,000 private repos.\nFirst time only: log in with gh for private repos, and follow the prompts:\ngh auth login\n\nNow you can clone thousands of repos under a new ./myorgname folder. Replace myorgname with your org name:\ngh repo list myorgname --limit 4000 | while read -r repo _; do\n gh repo clone \"$repo\" \"$repo\"\ndone\n\nThe default limit is 30.\nThis should work on Mac or Linux.\nFor Windows:\n\nRun this bash script in Git Bash, part of Git for Windows - or in WSL\nOr try the comment here by @Karson for a similar script in PowerShell\n\nSetup\nTo get the GitHub CLI tool:\n\nMac - brew install gh\nLinux or Windows - see GitHub install guide\n\nFuture proofing: the GitHub CLI tool will be supported long-term as and when the GitHub API changes. Some older answers here don't work any more due to this.\nOptional: update existing checkouts\nTo update repo folders already on disk, as well as clone new repos, the script needs to check for failure of the gh repo clone, like this:\ngh repo list myorgname --limit 1000 | while read -r repo _; do\n gh repo clone \"$repo\" \"$repo\" -- -q 2>/dev/null || (\n cd \"$repo\"\n # Handle case where local checkout is on a non-main/master branch\n # - ignore checkout errors because some repos may have zero commits, \n # so no main or master\n git checkout -q main 2>/dev/null || true\n git checkout -q master 2>/dev/null || true\n git pull -q\n )\ndone\n\nTips\n\nDon't want to create repos in the ./myorgname folder? Drop the second \"$repo\" argument to gh repo clone to create them in the current directory\n\nTo filter results:\n\n--no-archived - omit archived repositories\n--source - show only non-forks\n\nTip: Handling thousands of repos\nThis script works with up to about 4,000 repos - see @Ryan Fisher comment below, and comment with your results.\nThe gh repo list command uses the GitHub Search API, which is paginated when returning many results. There is a limit of 4,000 on the number of repos that can be searched.\nTo work around any limits:\n\ncheck the gh repo list command is returning what you expect\nmake sure you are omitting archived and forked repos\nsee gh repo list --help to filter by language, topic, etc\n\nOr you can use a different answer (based on API requests) that replaces the gh repo list command or the whole script.\nTip: Faster cloning for many repos\nIf you are cloning a large number of repos, you can speed up this script with GNU parallel.\ngh repo list <ORG_NAME> --limit <LIMIT> --json nameWithOwner --jq '.[].nameWithOwner' | \\\n parallel -j<JOBS> gh repo clone\n\nThis uses gh's internal jq library, rather than a standalone jq.\nIf you are using the \"update existing checkouts\" option above, you will need to merge this into the above script - perhaps putting the loop contents into a separate bash -c \"...\" command under parallel.\nYou can also use xargs -P to clone repos in parallel - see this answer.\nBackground\n\nGitHub CLI login doc\nScript commands above were derived from an issue comment and gist by davegallant\nGNU parallel script contributed by @RyanFisher"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fetch - Download objects and refs from another repository"}, {"role": "assistant", "content": "SECURITY The fetch and push protocols are not designed to prevent one side from\nstealing data from the other repository that was not intended to be\nshared. If you have private data that you need to protect from a malicious\npeer, your best option is to store it in another repository. This applies\nto both clients and servers. In particular, namespaces on a server are not\neffective for read access control; you should only grant read access to a\nnamespace to clients that you would trust with read access to the entire\nrepository. The known attack vectors are as follows: The victim sends \"have\" lines advertising the IDs of objects it has that\nare not explicitly intended to be shared but can be used to optimize the\ntransfer if the peer also has them. The attacker chooses an object ID X\nto steal and sends a ref to X, but isn’t required to send the content of\nX because the victim already has it. Now the victim believes that the\nattacker has X, and it sends the content of X back to the attacker\nlater. (This attack is most straightforward for a client to perform on a\nserver, by creating a ref to X in the namespace the client has access\nto and then fetching it. The most likely way for a server to perform it\non a client is to \"merge\" X into a public branch and hope that the user\ndoes additional work on this branch and pushes it back to the server\nwithout noticing the merge.) As in #1, the attacker chooses an object ID X to steal. The victim sends\nan object Y that the attacker already has, and the attacker falsely\nclaims to have X and not Y, so the victim sends Y as a delta against X.\nThe delta reveals regions of X that are similar to Y to the attacker."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Notifications for new Github project releases? [closed]\n\nClosed. This question is seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. It does not meet Stack Overflow guidelines. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\n We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.\n\n\nClosed 6 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI'm using a library from a Github project. Is there some way to set up a notification for new project releases?\nFor example, I want to know when a new release appears here\nI know I can be notified on every issue update, but that's not what I'm looking for. Though I see some projects are using that as a way to keep people notified"}, {"role": "assistant", "content": "Don't know about email, but you can subscribe to RSS Atom feed with releases:\nhttps://github.com/dropbox/dropbox-js/releases.atom\nor tags:\nhttps://github.com/dropbox/dropbox-js/tags.atom\n\nEDIT:\nTo get notification via email you can use Sibbell.com or RSS-to-email service like Blogtrottr."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to automatically resolve a Git conflict by taking the version in the current branch?\nLet's suppose that I get a merge conflict on foo/bar.txt when running this:\n$ git checkout A\n$ git merge B\n\nI'd like to automatically resolve the conflict by taking foo/bar.txt from branch A. (I know what I'm doing, and I do need this. The version in branch B is wrong, and I don't care about losing changes in the working tree in this case.) It seems that I can do it by running these commands:\n$ git reset foo/bar.txt\n$ git checkout foo/bar.txt\n\nIs there a simpler, single-command solution?\nUnfortunately these commands change foo/bar.txt even if there is no conflict, and I don't want that. If there is no conflict, I want want to keep foo/bar.txt in whatever state git merge B has left it.\nSo I need a Unix shell command, which would detect if there is a conflict in foo/bar.txt, and if there is, it would resolve the conflict by taking the version of foo/bar.txt from the current branch. It wouldn't do anything else, i.e. it wouldn't modify other files, it wouldn't commit the changes, and it wouldn't change foo/bar.txt if there is no conflict in that file."}, {"role": "assistant", "content": "You can specify the merge strategy option ours to the recursive (the default) merge strategy. It will perform a normal merge, but in case of conflicting hunks, it will choose the version of the current branch (i.e. ours).\ngit checkout A\ngit merge -X ours B\n\n\nNote that this is very different from -s ours, which selects a different merge strategy. Doing so would throw away all changes of the other branch and only keep our version. Refer to How do I 'overwrite', rather than 'merge', a branch on another branch in Git? for more details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc git diff [<options>] --no-index [--] <path> <path>"}, {"role": "assistant", "content": "This form is to compare the given two paths on the\nfilesystem. You can omit the --no-index option when\nrunning the command in a working tree controlled by Git and\nat least one of the paths points outside the working tree,\nor when running the command outside a working tree\ncontrolled by Git. This form implies --exit-code ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fast-import - Backend for fast Git data importers --big-file-threshold=<n>"}, {"role": "assistant", "content": "Maximum size of a blob that fast-import will attempt to\ncreate a delta for, expressed in bytes. The default is 512m\n(512 MiB). Some importers may wish to lower this on systems\nwith constrained memory."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to change the starting point of a branch?\n\nUsually I create a branch by running a command like git checkout -b [branch-name] [starting-branch]. In one case, I forgot to include the starting-branch, and now I want to correct it. How do I do so after the branch has already been created?"}, {"role": "assistant", "content": "The short answer is that once you have some commits, you want to git rebase them, using the long form of git rebase: git rebase --onto newbase upstream. To find out how to identify each of these, see the (very) long answer below. (Unfortunately, it got a bit out of hand and I do not have time to shorten it.)\nThe problem you have here is that in Git, branches don't have a \"starting point\"—at least, not in any useful way.\nThe term \"branch\", in Git, is ambiguous\nThe first issue here is that, in Git, the word \"branch\" has at least two distinct meanings. Usually, when we talk loosely about \"the branch\", it's clear from context whether we mean the branch name—the thing that's a word like master or develop or feature-X—or the thing that I call \"branch ancestry\" or \"branch structure\", or more informally, a \"DAGlet\".1 See also What exactly do we mean by \"branch\"?\nIn this particular case, unfortunately, you mean both of these, at the same time.\n\n1The term DAG is short for Directed Acyclic Graph, which is what the commit graph is: a set of vertices or nodes, and directional (from child to parent) edges, such that there are no cycles through the directed edges from any node back to itself. To this I simply add the \"-let\" diminutive suffix. The resulting word has a happy resemblance to the word aglet, plus a certain assonance with the word \"dagger\", making it sound slightly dangerous: \"Is this a DAGlet which I see before me?\"\nDraw your commit graph\nWhenever you need to grapple with these issues, it helps to draw a graph of what you have now, or at least some useful subset of what you have now. There are of course many ways to draw this (see that linked question for several options, including some bad ones :-) ), but in plain text in a StackOverflow answer, I generally draw them like this:\n...--o--o--o <-- master\n \\\n o--o--o--o <-- develop\n\nThe round o nodes represent commits, and the branch names master and develop point to one specific tip commit on each branch.\nIn Git, every commit points back to its parent commit(s), and this is how Git forms branch structures. By \"branch structures\", I mean here particular subsets of the overall ancestry part of the graph, or what I call the DAGlets. The name master points to the tip-most commit of the master branch, and that commit points back (leftward) to another commit that is the previous commit on the branch, and that commit points leftward again, and so on.\nWhen we need to talk about specific commits within this graph, we can use their actual names, which are the big ugly 40-character hashes that identify each Git object. Those are really clumsy though, so what I do here is replace the little round os with uppercase letters:\n...--A--B--C <-- master\n \\\n D--E--F--G <-- develop\n\nand now it's easy to say, e.g., that the name master points to commit C, and C points to B, and B points to A, which points back to more history that we don't really care about and hence just left as ....\nWhere does a branch begin?\nNow, it's perfectly obvious, to you and me, based on this graph drawing, that branch develop, whose tip commit is G, starts at commit D. But it's not obvious to Git—and if we draw the same graph a little differently, it may be less obvious to you and me too. For instance, look at this drawing:\n o <-- X\n /\n...--o--o--o--o--o--o <-- Y\n\nObviously branch X has just the one commit and the main line is Y, right? But let's put some letters in:\n C <-- X\n /\n...--A--B--D--E--F--G <-- Y\n\nand then move Y down a line:\n C <-- X\n /\n...--A--B\n \\\n D--E--F--G <-- Y\n\nand then look what happens if we move C down to the main line, and realize that X is master and Y is develop? Which branch is commit B on after all?\nIn Git, commits may be on many branches simultaneously; DAGlets are up to you\nGit's answer to this dilemma is that commits A and B are on both branches. The beginning of branch X is way off to the left, in the ... part. But so is the beginning of branch Y. As far as Git is concerned, a branch \"starts\" at whatever root commit(s) it can find in the graph.\nThis is important to keep in mind in general. Git has no real concept of where a branch \"started\", so we wind up having to give it extra information. Sometimes that information is implied, and sometimes it is explicit. It's also important, in general, to remember that commits are often on many branches—so instead of specifying branches, we usually specify commits.\nWe just often use branch names to do this. But if we give Git just a branch name, and tell it to find all the ancestors of the tip commit of that branch, Git goes all the way back in history.\nIn your case, if you write the name develop and ask Git to select that commit and its ancestors, you get commits D-E-F-G (which you wanted) and commit B, and commit A, and so on (which you didn't). The trick, then, is to somehow identify which commits you don't want, along with which commits you do.\nNormally we use the two-dot X..Y syntax\nWith most Git commands, when we want to select some particular DAGlet, we use the two-dot syntax described in gitrevisions, such as master..develop. Most2 Git commands that work on multiple commits treat this as: \"Select all commits starting from the tip of the develop branch, but then subtract from that set, the set of all commits starting from the tip of the master branch.\" Look back at our graph drawing of master and develop: this says \"do take commits starting from G and working backwards\"—which gets us too many, since it includes commits B and A and earlier—\"but exclude commits starting from C and working backwards.\" It's that exclude part that gets us what we want.\nHence, writing master..develop is how we name commits D-E-F-G, and have Git compute that automatically for us, without having to first sit down and draw out a big chunk of the graph.\n\n2Two notable exceptions are git rebase, which is in its own section just below, and git diff. The git diff command treats X..Y as simply meaning X Y, i.e., it effectively just ignores the two dots entirely. Note that this has a very different effect than set subtraction: in our case, git diff master..develop simply diffs the tree for commit C against the tree for commit G, even though master..develop never has commit C in the first set.\nIn other words, mathematically speaking, master..develop is normally ancestors(develop) - ancestors(master), where the ancestors function includes the specified commit, i.e., is testing ≤ rather than just <. Note that ancestors(develop) does not include commit C at all. The set subtraction operation simply ignores the presence of C in the set ancestors(master). But when you feed this to git diff, it does not ignore C: it does not diff, say, B against G. While that might be a reasonable thing to do, git diff instead steals the three-dot master...develop syntax to accomplish this.\nGit's rebase is a little bit special\nThe rebase command is almost always used to move3 one of these DAGlet commit-subsets from one point in the graph to another. In fact, that's what rebase is, or was originally anyway, defined to do. (Now it has a fancy interactive rebase mode, which does this and a bunch more history editing operations. Mercurial has a similar command, hg histedit, with a slightly better name, and much tighter default semantics.4)\nSince we always (or almost always) want to move a DAGlet, git rebase builds in this subset selection for us. And, since we always (or almost always) want to move the DAGlet to come just after the tip of some other branch, git rebase defaults to choosing the target (or --onto) commit using a branch name, and then uses that same branch name in the X..Y syntax.5\n\n3Technically, git rebase actually copies commits, rather than moving them. It has to, because commits are immutable, like all Git's internal objects. The true name, the SHA-1 hash, of a commit is a checksum of the bits making up the commit, so any time you change anything—including something as simple as the parent ID—you have to make a new, slightly-different, commit.\n4In Mercurial, quite unlike Git, branches really do have starting points, and—more important for histedit—commits record their phase: secret, draft, or published. History editing readily applies to secret or draft-phase commits, and not so much to published commits. This is true of Git as well, but since Git has no concept of commit phases, Git's rebase must use these other techniques.\n5Technically the <upstream> and --onto arguments can just be raw commit IDs. Note that 1234567..develop works just fine as a range selector, and you can rebase --onto 1234567 to place the new commits after commit 1234567. The only place that git rebase truly needs a branch name is for the name of the current branch, which it normally just reads from HEAD anyway. However, we usually want to use a name, so that's how I describe it all here.\n\nThat is, if we're currently on branch develop, and in this situation that we drew before:\n...--A--B--C <-- master\n \\\n D--E--F--G <-- develop\n\nwe probably just want to move the D-E-F-G chain onto the tip of master, to get this:\n...--A--B--C <-- master\n \\\n D'-E'-F'-G' <-- develop\n\n(The reason I changed the names from D-E-F-G to D'-E'-F'-G' is that rebase is forced to copy the original commits, rather than actually moving them. The new copies are just as good as the originals, and we can use the same single letter name, but we should at least note, however vaguely, that these are in fact copies. That's what the \"prime\" marks, the ' characters, are for.)\nBecause this is what we usually want, git rebase will do this automatically if we just name the other branch. That is, we're on develop now:\n$ git checkout develop\n\nand we want to rebase commits that are on branch develop and are not on master, moving them to the tip of master. We might express this as git somecmd master..develop master, but then we would have to type the word master twice (such a dreadful fate). So instead, Git's rebase infers this when we just type in:\n$ git rebase master\n\nThe name master becomes the left side of the two-dot .. DAGlet selector, and the name master also becomes the target of the rebase; and Git then rebases D-E-F-G onto C. Git gets our branch's name, develop, by reading out the current branch name. In fact, it uses a shortcut, which is that when you need the current branch name, you can normally just write HEAD instead. So master..develop and master..HEAD mean the same thing, because HEAD is develop.\nGit's rebase calls this name the <upstream>. That is, when we say git rebase master, Git claims, in the documentation, that master is the <upstream> argument to git rebase. The rebase command then operates on commits in <upstream>..HEAD, copying them after whatever commit is in <upstream>.\nThis is going to become a problem for us soon, but for now, just make note of it.\n(Rebase also has the sneaky, but desirable, side feature of omitting any of the D-E-F-G commits that sufficiently resembles commit C. For our purposes we can ignore this.)\nWhat's wrong with the other answer to this question\nIn case the other answer gets deleted, or becomes one of several other answers, I'll summarize it here as \"use git branch -f to move the branch label.\" The flaw in the other answer—and, perhaps more importantly, precisely when it's a problem—becomes obvious once we draw our graph DAGlets.\nBranch names are unique, but tip commits are not necessarily so\nLet's take a look at what happens when you run git checkout -b newbranch starting-point. This asks Git to root around in the current graph for the given starting-point, and make the new branch label point to that specific commit. (I know I said above that branches don't have a starting point. This is still mostly true: we're giving the git checkout command a starting point now, but Git is about to set it and then, crucially, forget it.) Let's say that starting-point is another branch name, and let's draw a whole bunch of branches:\n o--o--o--o <-- brA\n /\n...--o--o--o--o--o--o <-- brB\n \\\n o--o--o <-- brC\n \\\n o--o <-- brD\n\nSince we have four branch names, we have four branch tips: four branch-tip commits, identified by the names brA through brD. We pick one and make a new branch name newbranch that points to the same commit as one of these four. I have arbitrarily picked brA here:\n o--o--o--o <-- brA, newbranch\n /\n...--o--o--o--o--o--o <-- brB\n \\\n o--o--o <-- brC\n \\\n o--o <-- brD\n\nWe now have five names, and five ... er, four? ... well, some tip commits. The tricky bit is that brA and newbranch both point to the same tip commit.\nGit knows—because git checkout sets it—that we're now on newbranch. Specifically Git writes the name newbranch into HEAD. We can make our drawing a bit more accurate by adding this information:\n o--o--o--o <-- brA, HEAD -> newbranch\n /\n...--o--o--o--o--o--o <-- brB\n \\\n o--o--o <-- brC\n \\\n o--o <-- brD\n\nAt this point, the four commits that used to be only on branch brA are now on both brA and newbranch. And, by the same token, Git no longer knows that newbranch starts at the tip of brA. As far as Git is concerned, both brA and newbranch contain those four commits and all the earlier ones too, and both of them \"start\" way back in time somewhere.\nWhen we make new commits, the current name moves\nSince we're on branch newbranch, if we make a new commit now, the new commit's parent will be the old tip commit, and Git will adjust the branch name newbranch to point to the new commit:\n o <-- HEAD -> newbranch\n /\n o--o--o--o <-- brA\n /\n...--o--o--o--o--o--o <-- brB\n \\\n o--o--o <-- brC\n \\\n o--o <-- brD\n\nNote that none of the other labels moved: the four \"old\" branches stay put, only the current (HEAD) branch changes. It changes to accommodate the new commit we just made.\nNote that Git continues to have no idea that branch newbranch \"started\" at brA. It's just the case, now, that newbranch contains one commit that brA does not, plus the four commits that they both contain, plus all those earlier commits.\nWhat git branch -f does\nUsing git branch -f lets us move a branch label. Let's say, for whatever mysterious reason, we don't want branch label brB to point where it does in our current drawing. Instead, we want it to point to the same commit as brC. We can use git branch -f to change the place to which brB points, i.e., to move the label:\n$ git branch -f brB brC\n\n o <-- HEAD -> newbranch\n /\n o--o--o--o <-- brA\n /\n...--o--o--o--o--o--o [abandoned]\n \\\n o--o--o <-- brC, brB\n \\\n o--o <-- brD\n\nThis makes Git \"forget\" or \"abandon\" those three commits that were only on brB before. That's probably a bad idea—why did we decide to do this strange thing?—so we probably want to put brB back.\nReflogs\nFortunately, \"abandoned\" commits are normally remembered in what Git calls reflogs. Reflogs use an extended syntax, name@{selector}. The selector part is usually either a number or date, such as brB@{1} or brB@{yesterday}. Every time Git updates a branch name to point to some commit, it writes a reflog entry for that branch, with the pointed-to commit's ID, a time-stamp, and an optional message. Run git reflog brB to see these. The git branch -f command wrote the new target as brB@{0}, bumping up all the old numbers, so now brB@{1} names the previous tip commit. So:\n$ git branch -f brB 'brB@{1}'\n # you may not need the quotes, 'brB@{...}' --\n # I need them in my shell, otherwise the shell\n # eats the braces. Some shells do, some don't.\n\nwill put it back (and also renumber all the numbers again: each update replaces the old @{0} and makes it @{1}, and @{1} becomes @{2}, and so on).\nAnyway, suppose that we do our git checkout -b newbranch while we're on brC, and fail to mention brA. That is, we start with:\n o--o--o--o <-- brA\n /\n...--o--o--o--o--o--o <-- brB\n \\\n o--o--o <-- HEAD -> brC\n \\\n o--o <-- brD\n\nand run git checkout -b newbranch. Then we get this:\n o--o--o--o <-- brA\n /\n...--o--o--o--o--o--o <-- brB\n \\\n o--o--o <-- brC, HEAD -> newbranch\n \\\n o--o <-- brD\n\nIf we meant to make newbranch point to commit brA, we can in fact do that right now, with git branch -f. But let's say we make a new commit before realizing that we made newbranch start at the wrong point. Let's draw it in:\n o--o--o--o <-- brA\n /\n...--o--o--o--o--o--o <-- brB\n \\\n o--o--o <-- brC\n \\ \\\n | o <-- HEAD -> newbranch\n \\\n o--o <-- brD\n\nIf we use git branch -f now, we'll abandon—lose—the commit we just made. What we want instead is to rebase it, onto the commit that branch brA points-to.\nA simple git rebase copies too much\nWhat if, instead of using git branch -f, we use git rebase brA? Let's analyze this using—what else—our DAGlets. We start with the above drawing above, with the extended leg going out to brD, though in the end we get to ignore that leg, and with the section going to brB, most of which we also get to ignore. What we don't get to ignore is all that stuff in the middle, that we get by tracing the lines back.\nThe git rebase command, in this form, will use brA..newbranch to pick commits to copy. So, starting with the whole DAGlet, let's mark (with *) all the commits that are on (or contained in) newbranch:\n o--o--o--o <-- brA\n /\n...--*--*--*--o--o--o <-- brB\n \\\n *--*--* <-- brC\n \\ \\\n | * <-- HEAD -> newbranch\n \\\n o--o <-- brD\n\nNow, let's un-mark (with x) all the commits that are on (or contained in) brA:\n x--x--x--x <-- brA\n /\n...--x--x--*--o--o--o <-- brB\n \\\n *--*--* <-- brC\n \\ \\\n | * <-- HEAD -> newbranch\n \\\n o--o <-- brD\n\nWhatever remains—all the * commits—are the ones that git rebase will copy. That's way too many!\nWe need to get git rebase to copy just the one commit. What this means is that for the <upstream> argument, we need to give git rebase the name brC.6 That way, Git will use brC..HEAD to select the commits to copy, which will be just the one commit we need to copy.\nBut—alas!—now we have a big problem, because git rebase wants to copy the commit to a point right after the <upstream> we just gave it. That is, it wants to copy the commits to just after brC. That's where the commits are now! (Well, the one commit is.) So this is no good at all!\nFortunately, git rebase has an escape hatch, specifically the --onto argument. I mentioned this several times before, but now is when we need it. We want the copies to go right after brA, so that's what we will supply as the --onto argument. Git's rebase uses the <upstream> by default, but if we give it an --onto, it uses that instead. So:\n$ git branch # just checking...\n brA\n brB\n brC\n brD\n master\n* newbranch\n\nOK, good, we're still on newbranch. (Note that git status works here too, and if you use one of those fancy shell prompt setup things, you can even get your current branch name to be in your prompt, so that you don't need to run git status as often.)\n$ git rebase --onto brA brC\n\nNow Git will select commits in brC..HEAD, which is the right set of commits to copy, and copy them right after the tip of brA, which is the right place to copy them to. Once the copies are all done, Git will abandon the original commits7 and make the name newbranch point to the new, tip-most, copied commit.\nNote that this works even if you have no new commits on the new branch. This is the one case where git branch -f also works. When there are no commits, this git rebase carefully copies all zero of them :-) and then makes the name, newbranch, point to the same commit as brA. Hence git branch -f is not always wrong; but git rebase is always right—albeit somewhat clumsy: you must identify both the <upstream> and the --onto points manually.\n\n6Or, as we noted in an earlier footnote, we can give git rebase the ID of the commit to which the name brC points. Either way, we have to supply this as the upstream argument.\n7Except, of course, reflog entry newbranch@{1} will remember the old, now-abandoned, tip commit. Additional reflog entries for newbranch may remember yet more commits, and remembering the tip commit suffices to keep all its ancestors alive. The reflog entries eventually expire—after 30 days for some cases, and 90 for others, by default—but this gives you up to a month or so, by default, to recover from mistakes."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options push.pushOption"}, {"role": "assistant", "content": "When no --push-option=<option> argument is given from the\ncommand line, git push behaves as if each <value> of\nthis variable is given as --push-option=<value> . This is a multi-valued variable, and an empty value can be used in a\nhigher priority configuration file (e.g. .git/config in a\nrepository) to clear the values inherited from a lower priority\nconfiguration files (e.g. $HOME/.gitconfig ). Example:\n\n/etc/gitconfig\n push.pushoption = a\n push.pushoption = b\n\n~/.gitconfig\n push.pushoption = c\n\nrepo/.git/config\n push.pushoption =\n push.pushoption = b\n\nThis will result in only b (a and c are cleared)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fetch - Download objects and refs from another repository -p --prune"}, {"role": "assistant", "content": "Before fetching, remove any remote-tracking references that no\nlonger exist on the remote. Tags are not subject to pruning\nif they are fetched only because of the default tag\nauto-following or due to a --tags option. However, if tags\nare fetched due to an explicit refspec (either on the command\nline or in the remote configuration, for example if the remote\nwas cloned with the --mirror option), then they are also\nsubject to pruning. Supplying --prune-tags is a shorthand for\nproviding the tag refspec. See the PRUNING section below for more details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git: rename directory (case-only) on Windows\nI want to rename a directory versioned by Git on a Windows system (change the case of the directory name):\n$ git mv docs DOCS\nRename from 'docs' to 'DOCS/docs' failed. Should I try again? (y/n) n\nfatal: renaming 'docs' failed: Permission denied\n\nI've also tried with the force-option - but with the same result:\n$ git mv --force docs DOCS\nRename from 'docs' to 'DOCS/docs' failed. Should I try again? (y/n) n\nfatal: renaming 'docs' failed: Permission denied\n\nFor some reason Git fails because it thinks DOCS already is an existing directory and the directory should be moved inside it. I know that I can rename & commit using a temporary directory name and then rename & amend-commit to the final name, but isn't there a way to tell Git that I don't want to move inside any other directory?"}, {"role": "assistant", "content": "You can try to do it in 2 step.\n$ git mv docs DOCS2\n$ git mv DOCS2 DOCS\n\nit will work"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I revert a single file to a previous version? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow can I reset or revert a file to a specific revision?\n\n (37 answers)\n \n\nClosed 10 years ago.\nThe community reviewed whether to reopen this question 7 months ago and left it closed:\n\nOriginal close reason(s) were not resolved\n\n\n\n\nIs there a way to go through different commits on a file. \nSay I modified a file 5 times and I want to go back to change 2, after I already committed and pushed to a repository.\nIn my understanding the only way is to keep many branches, have I got that right?\nIf I'm right I'm gonna have hundreds of branches in a few days, so I'm probably not understanding it really.\nCould anyone clear that up please?"}, {"role": "assistant", "content": "Let's start with a qualitative description of what we want to do (much of this is said in Ben Straub's answer). We've made some number of commits, five of which changed a given file, and we want to revert the file to one of the previous versions. First of all, git doesn't keep version numbers for individual files. It just tracks content - a commit is essentially a snapshot of the work tree, along with some metadata (e.g. commit message). So, we have to know which commit has the version of the file we want. Once we know that, we'll need to make a new commit reverting the file to that state. (We can't just muck around with history, because we've already pushed this content, and editing history messes with everyone else.)\nSo let's start with finding the right commit. You can see the commits which have made modifications to given file(s) very easily:\ngit log path/to/file\n\nIf your commit messages aren't good enough, and you need to see what was done to the file in each commit, use the -p/--patch option:\ngit log -p path/to/file\n\nOr, if you prefer the graphical view of gitk\ngitk path/to/file\n\nYou can also do this once you've started gitk through the view menu; one of the options for a view is a list of paths to include.\nEither way, you'll be able to find the SHA1 (hash) of the commit with the version of the file you want. Now, all you have to do is this:\n# get the version of the file from the given commit\ngit checkout <commit> path/to/file\n# and commit this modification\ngit commit\n\n(The checkout command first reads the file into the index, then copies it into the work tree, so there's no need to use git add to add it to the index in preparation for committing.)\nIf your file may not have a simple history (e.g. renames and copies), see VonC's excellent comment. git can be directed to search more carefully for such things, at the expense of speed. If you're confident the history's simple, you needn't bother."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is there a command to undo git init?\nI just Git init'ed a repos with a wrong user, and want to undo it. Is there any command for this? Do I actually have to go in and edit the .git directory?"}, {"role": "assistant", "content": "You can just delete .git. Typically:\nrm -rf .git\n\nThen, recreate as the right user."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why is .gitignore not ignoring .DS_Store? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do I make Git forget about a file that was tracked, but is now in .gitignore?\n\n (35 answers)\n \n\nClosed 6 years ago.\n\n\n\nIn this case I want to ignore the files iOS uses, and in particular this file \n.DS_Store\n\nI created a .gitignore file as such\ntouch .gitignore\n\nand put in a single line\n/.DS_Store\n\nI push to a bare repo which has a hook to checkout to a full repo.\nThe file keeps showing up in my full repo."}, {"role": "assistant", "content": "You can also remove committed .DS_Store files like this: git rm --cached .DS_Store"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects --show-signature"}, {"role": "assistant", "content": "Check the validity of a signed commit object by passing the signature\nto gpg --verify and show the output."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %<|( <M> )"}, {"role": "assistant", "content": "make the next placeholder take at least until Mth\ndisplay column, padding spaces on the right if necessary.\nUse negative M values for column positions measured\nfrom the right hand edge of the terminal window."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GIT vs. Perforce- Two VCS will enter... one will leave [closed]\nClosed. This question needs to be more focused. It is not currently accepting answers.\n \n \n\n\n\nClosed 10 years ago.\n\n\n\n\n\n\n\n\n\n\n\nLocked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.\n \n \n\n\n\n\n\n\nSo I'm in the process of getting GIT sold at work. First thing I need is to convince everyone that GIT is better at what they're already used to doing. We currently use Perforce. Anybody else go through a similar sale? Any good links/advice?\nOne of the big wins is that we can work with it disconnected from the network. Another win IMO is the way adds/checkouts are handled. More points are welcome! Also we have about 10-20 devs total."}, {"role": "assistant", "content": "I use Perforce at work. I also use Git because I would still like some form of version control when I'm working on code and can't connect to the server. No, reconcile offline work just is not the same. Here is where I've found git to be a great benefit:\n\nBranching speed - git takes a few seconds at most.\nConflicts - P4Merge's auto resolve destroyed a week's worth of work once. Ever since then I would rather resolve by hand when merging. When Git prompts me about a conflict, it is actually a conflict. The rest of the time, git resolves stuff correctly and I save heaps of time.\nKeeping track of merges - If you have one branch that is continuously receiving merges from two other branches, you know what a headache this can be with perforce. With git, the headache is minimized because the result of a merge in git is actually a new commit which knows who its ancestors are.\nPermissions - I have lost track of the number of times I've tried to work on a file but couldn't because it was not checked out in Perforce. If you worked with XCode (or any editor that does not have a solid Perforce SCM plugin) offline, you know how irritating this can get. I don't have to worry about that with Git. I make my changes. Git does not stop me and tracks them in the background.\nKeeping the main tree tidy - With git, I can sort my commits and tidy the code up so that the history looks nice and tidy. None of that \"checking in this file because it was supposed to be part of the previous checkin\" rubbish. I squash commits like that, because they help nobody.\nStashing - Your perforce server needs to be version 2010.1 or newer to use the p4 shelve command.\nCreating patches - Easy to do in git. Don't know if it is possible in Perforce without using the command line. \nMailing patches from the GUI - again, git wins here.\nDisk space - With perforce, every branch is a copy. That means if your source tree is huge, your disk space gets eaten up fast. This is not even counting the additional space once you start building. Why even have a link between branches and disk space? With git, you can have 100 branches and only one branch at a time ever exists. If you specifically want to work on two versions simultaneously you can clone, do your work and then get rid of one clone if you want, without losing anything.\nIf you're on XCode4, perforce support has been dropped and git support is now built in. If you do cross platform work like I do, this matters a lot. With Visual Studio, you can use git extensions. With perforce, it's equally yuck on both OSes. Well, maybe a little more on mac now with XCode4 on the scene.\nFinding the faulty checkin (or, git bisect rules) - Ever tried to do a binary search with perforce to figure out where a bug was introduced? Quite a hassle, yes? Even more of a hassle when there have been integrates from other branches in the middle. Why? Because there is no automation for such tasks. You need to write your own tool to talk to perforce and you usually don't have the time. With git, you give it the starting points (the \"good\" point and the \"bad\" point) and it automates the search for you. Even better, if you have a script that can automate the build and test process, you can hook git up to the script and the whole process of finding the checkin is automated. That is how it should be. \nTracking changes across refactors - Try splitting BigClass into SmallClass1 and SmallClass2. To Perforce, BigClass has now ceased to exist and two new classes (SmallClass1 and SmallClass2 have joined the source tree). To Perforce, there is no relation between BigClass and SmallClass1 and SmallClass2. Git, on the other hand, is smart enough to know that x% of BigClass is now in SmallClass1 and y% of BigClass is in SmallClass2 and that BigClass has ceased to exist. Now, from the point of view of someone who is reviewing changes across multiple branches, you tell me which approach you'd find more useful - Git's or Perforce's. Personally, I prefer Git's approach because it more accurately reflects the actual change in the code. Git is able to do this because it tracks content within the file and not the file itself.\nCentralized or decentralized: Git is a DVCS system while perforce is centralized. A centralized VCS cannot be decentralized later, but a DVCS (especially git) can be centralized. There are several products that add very fine grained access control to git, if that is something the business needs. Personally, I would go with a system that gives me greater flexibility in the long term.\nBranch mappings: If you want to do branching right in Perforce, you need to create a branch mapping. There are reasons for this, but they are tied to how Perforce conceptualizes a branch. As a developer, or a team, this simply means one more step in the work flow, which I do not consider efficient at all.\nSharing work between teams: With Perforce, you cannot break up a submission. Team A is working on feature A. Team B on feature B. Team C works on bug fixes. Now, Teams A & B have to fix a bunch of bugs in order to implement their features. The only thing is, they weren't so disciplined when committing their changes (probably because they're rushing to a deadline) and so their \"bug fixes\" are parts of larger submissions that also contain new stuff as far as version control on their branches are concerned. However, Team C is now doing a point release and would like to get the bug fixes from the other teams. If they were using Git, Team C could cherry pick the other teams' relevant changes, split them up and only take what they needed without worrying about introducing any partially implemented features. With Perforce, Team C can get the affected files, but would have to separate the relevant changes using a much more manual process. \nChanging platform - If, for whatever reason in the future, you\n decide to change your platform of choice, with Perforce, you're at\n the mercy of Perforce.com and the availability of the tools for the\n platform of your choosing.\nChanging to future amazing source control engine X - If you decide\n to change what you use for source control, extracting your source\n control history from Perforce and moving it to new system X is\n going to be a nightmare, because it is closed source and the best you\n can do is guess - just Google for Perforce to Git migration to get\n a sense of what I'm talking about. At least with Git, its open\n source, so it eliminates a lot of the guesswork involved.\n\nWell, that's my 2 cents. In Perforce's defense, I gotta say their customer support rules and so does their Time Lapse View tool. I do not know how to get a time lapse view with git. But for the convenience and time saved, I'd go with git any day."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options format.pretty"}, {"role": "assistant", "content": "The default pretty format for log/show/whatchanged command.\nSee git-log , git-show , git-whatchanged ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-difftool - Show changes using common diff tools --rotate-to=<file>"}, {"role": "assistant", "content": "Start showing the diff for the given path,\nthe paths before it will move to the end and output."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-update-ref - Update the object name stored in a ref safely start"}, {"role": "assistant", "content": "Start a transaction. In contrast to a non-transactional session, a\ntransaction will automatically abort if the session ends without an\nexplicit commit. This command may create a new empty transaction when\nthe current one has been committed or aborted already."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options merge.autoStash"}, {"role": "assistant", "content": "When set to true, automatically create a temporary stash entry\nbefore the operation begins, and apply it after the operation\nends. This means that you can run merge on a dirty worktree.\nHowever, use with care: the final stash application after a\nsuccessful merge might result in non-trivial conflicts.\nThis option can be overridden by the --no-autostash and --autostash options of git-merge .\nDefaults to false."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fetch - Download objects and refs from another repository fetch.all"}, {"role": "assistant", "content": "If true, fetch will attempt to update all available remotes.\nThis behavior can be overridden by passing --no-all or by\nexplicitly specifying one or more remote(s) to fetch from.\nDefaults to false."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects -c"}, {"role": "assistant", "content": "Produce combined diff output for merge commits.\nShortcut for --diff-merges=combined -p ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options bundle.version"}, {"role": "assistant", "content": "This integer value advertises the version of the bundle list format\nused by the bundle list. Currently, the only accepted value is 1 ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "warning: remote HEAD refers to nonexistent ref, unable to checkout\nThis seems like a popular error for different causes.\nI've got a simple bare git repo called \"kiflea.git\", I clone it like this:\ngit clone git://kipdola.be/kiflea.git\n\nThen git tells me: warning: remote HEAD refers to nonexistent ref, unable to checkout.\nAnd yes, there are no versioned files in the map, except for the .git directory.\nAnyway, the only thing I need to do is:\ncd kiflea\ngit checkout master\n\nAnd it works, all the files are there.\nBut I thought cloning a repo automatically checks out the master, so what is going on exactly, and how do I fix it?\nI have noticed that, after I do the git checkout master bit, this gets added to my local .git config file:\n[branch \"master\"]\n remote = origin\n merge = refs/heads/master\n\nIt's probably interesting to know that this git repository used to be an svn repository in a distant past.\nPs: when browsing the bare repository using gitweb, there clearly is a master branch there: http://kipdola.be/gitweb/?p=kiflea.git;a=summary"}, {"role": "assistant", "content": "The warning: remote HEAD refers to nonexistent ref, unable to checkout. means that the remote (bare) repository contains branch reference in the file called HEAD with a value that does not match any published branch in the same repository. In practice, that file defines which branch should be checked out by default after cloning the repository.\nNote that the warning only means that git didn't do checkout. The cloned repository is otherwise just fine. Just do git branch -a to see possible branches and git checkout the-branch-you-want to workaround the issue.\nThis usually happens because the default contents for that file (.git/HEAD or plain HEAD for bare repositories) is literal string ref: refs/heads/master which says that if somebody is going to clone this repository, they should by default clone the branch refs/heads/master. By default Git will create local branch without the refs/heads/ prefix (that is, master by default). Try git help symbolic-ref for more information.\nThe problem with this situation is that Git does not provide a method for modifying remote symbolic refs so either you use something the Git hosting provider has implemented (e.g. Settings - Default branch in GitHub if you have admin rights) or you have to use branch name master as the default branch (because that's the default content for the file HEAD and if you cannot modify that file, you'll be stuck with master forever).\nIf you have a shell access to your remote git repo, you can simply open a shell on the remote matchine and execute cd path/to/git/repo; git symbolic-ref HEAD refs/heads/XYZ where XYZ is the branch name you want to use by default.\nOne way to hit this issue is to create a new remote bare repo with no commits and then do git push name-of-the-remote my-special-branch-name which will result in bare repository containing a single branch my-special-branch-name but the HEAD symbolic ref still contains the default value pointing to master. As a result, you'll get the aforementioned warning. If you cannot modify the remote HEAD file, you can publish your branch using syntax git push name-of-the-remote my-special-branch-name:master meaning that your local branch called my-special-branch-name should be published as branch master on the remote."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to trigger Jenkins Multibranch Pipeline with Gitlab Webhook\n\nI currently set up a Jenkins Multibranch Pipeline job that is based on a Git repository hosted on our GitLab server. Jenkins can read the branches in the repository and creates a job for every branch in the repository. But I can't figure out how to trigger the jobs with webhooks in GitLab.\nMy questions are:\n\nHow can I trigger the creation of a new branch job in Jenkins from our GitLab server? I can't see a webhook for a new branch being pushed.\n\nHow do I trigger the actual build job for a single branch? I can only add a webhook for push events but then I would have to add the branch name which I don't know how to do.\n\nHow can I make sure that GitLab always triggers the \"creation of the branch job\" before a push to a branch triggers the build job itself.\n\n\nWhat I tried so far is triggering the multi-branch job, but this has no effect and following this post does not work at all."}, {"role": "assistant", "content": "You need to install the GitLab Plugin on Jenkins.\nThis will add a /project endpoint on Jenkins. (See it in Jenkins => Manage Jenkins => Configure System => GitLab)\nNow add a webhook to your GitLab project => Settings => Integrations. (or in older GitLab versions: GitLab project => Wheel icon => Integrations, it seems you need to be owner of the project in this case)\nSet the URL to http://*yourjenkins.com*/**project**(/*foldername*)?/*yourprojectname* then click \"Add webhook\".\nWhen you click \"Test\" on your webhook it should trigger your Jenkins pipeline build (you should get a 200 HTTP response).\nIt works without authentication in the GitLab plugin, configuration with authentication are welcome."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --check"}, {"role": "assistant", "content": "Warn if changes introduce conflict markers or whitespace errors.\nWhat are considered whitespace errors is controlled by core.whitespace configuration. By default, trailing whitespaces (including\nlines that consist solely of whitespaces) and a space character\nthat is immediately followed by a tab character inside the\ninitial indent of the line are considered whitespace errors.\nExits with non-zero status if problems are found. Not compatible\nwith --exit-code."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is 'gitlab/gitlab-runner-helper' docker image used for?\n\nMy overall goal is to install a self-hosted gitlab-runner that is restricted to use prepared docker images from my own docker registry only.\nFor that I have a system.d configuration that looks like:\n/etc/systemd/system/docker.service.d/allow-private-registry-only.conf\nBLOCK_REGISTRY='--block-registry=all'\nADD_REGISTRY='--add-registry=my.private.registry:8080'\n\nBy this, docker pull is allowed to pull images from my.private.registry/ only.\nAfter I had managed to get this working, I wanted to clean up my local registry and remove old docker images. It was during that process when I stumbled over a docker image named gitlab/gitlab-runner-helper which presumably is some component used by the gitlab-runner itself and presumably has been pulled from docker.io.\nNow I'm wondering if it is even possible/advisable to block images from docker.io when using a gitlab-runner?\nAny hints are appreciated!"}, {"role": "assistant", "content": "I feel my sovereign duty to extend the accepted answer (it is great btw), because the word 'handle' basically tells us not so much, it is too abstract. Let me explain the whole flow in far more details:\n\nWhen the build is about to begin, gitlab-runner creates a docker volume (you can observe it with docker volume ls if you want). This volume will server as a storage for caches and artifacts that you are using during the build.\n\nThe second thing - You will have at least 2 containers involved in each stage: gitlab-runner-helper, container and the container created from the image you specified (in .gitlab-ci.yml or in config.toml). What gitlab-runner-helper container does it, essentially, just cloning the remote git repository (that you are building) in the aforementioned docker volume along with caches and artifacts.\n\n\nIt can do it becuase within gitlab-runner-helper image itself are 2 important utilities: git (obviously - to clone the repo) and gitlab-runner-helper binary (this utility can pull and push artifacts, caches)\n\nThe gitlab-runner-helper container starts before each stage for a couple of seconds, to pull artifacts and caches, and then terminates. After that the container, created from image that you specified will be launched, ant it will also have this volume (from step 1) attached - this is how it receives artifacts btw.\n\nThe rest of the details about the registry from where gitlab-runner-helper get pulled are described by @Nicolas pretty well. I append this comment just for someone, who, perhaps, want to know what exactly means this sneaky 'handle' word.\nHope it helps, have a nice day, my friend!"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --cached"}, {"role": "assistant", "content": "Do not consider the on-disk file at all."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-checkout older revision of a file under a new name\nI have the file \"main.cpp\" open in my editor.\nI want to see the previous revision of \"main.cpp\" in the editor too.\nThe way I do it now is like this.\nclose \"main.cpp\" in the editor\n\nprompt> mv main.cpp tmp\nprompt> git checkout HEAD^ main.cpp\nprompt> mv main.cpp old_main.cpp\nprompt> mv tmp main.cpp\nprompt>\n\nopen \"main.cpp\" and \"old_main.cpp\" in the editor\n\nCan it be simplified, so I don't have to close \"main.cpp\" in the editor? \nWhat I'm hoping for is a variant of git-checkout that can do this.\n\nUPDATE: im using git on mac osx 10.5.7\nprompt> git --version\ngit version 1.6.0.4\nprompt> \n\n\nUPDATE2: Jakub Narębski answer is:\nprompt> git show HEAD^:dir1/dir2/dir3/main.cpp > old_main.cpp\nprompt>\n\n\nUPDATE3: Karmi's answer, for a specific revision:\nprompt> git show 4c274dd91dc:higgs/Higgs.xcodeproj/project.pbxproj > old_project.pbxproj\nprompt>"}, {"role": "assistant", "content": "You can use git show for that:\ngit show HEAD^:main.cpp > old_main.cpp\n\n(Note that there is colon [:] character between HEAD^ and main.cpp.) The <revision>:<path> syntax is described in git rev-parse manpage, next to last point in the \"Specifying revisions\" section:\n\n<rev>:<path>, e.g. HEAD:README, :README, master:./README\nA suffix : followed by a path names the blob or tree at the given path in the tree-ish\nobject named by the part before the colon. :path (with an empty part before the colon)\nis a special case of the syntax described next: content recorded in the index at the\ngiven path. A path starting with ./ or ../ is relative to the current working directory.\nThe given path will be converted to be relative to the working tree’s root directory.\nThis is most useful to address a blob or tree from a commit or tree that has the same\ntree structure as the working tree.\n\nNote that <path> here is FULL path relative to the top directory of your project, i.e. the directory with .git/ directory. (Or, to be more exact, to \"<revision>\", which in general can be any <tree-ish>, i.e. something that represents tree.)\nIf you want to use path relative to the current directory, you need to use ./<path> syntax (or ../path to go up from current directory).\nEdit 2015-01-15: added information about relative path syntax\n\nYou can get in most cases the same output using low-level (plumbing) git cat-file command:\ngit cat-file blob HEAD^:main.cpp > old_main.cpp"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Creating a SSH key with ssh-keygen does not create the .ssh folder\nI am trying to create my public/private rsa key pair with msysgit\nI run this command:\nssh-keygen -C \"[email protected]\" -t rsa\n\nEverything looks fine, I have the message \nEnter file in which to save the key (/c/Users/user/.ssh/id_rsa)\n\nThen I have the confirmation:\nYour public key has been saved in project.pub\n\nBut I can't access the folder! It does not exist, it is not even an hidden folder. I don't understand why it does not generate. I am using Windows 7 Ultimate."}, {"role": "assistant", "content": "I had the same problem and I realized I was trying to enter a file name when it asks for the following \"Enter file in which to save the key (c/users/user.name/.ssh/id_rsa)\"\nRather just enter nothing and press Enter key to use the default and you will move on."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "View the change history of a file using github.com\n\nI've found this post about using the command line, but is it possible to view the file change history of a single file in a repository on github.com?\nAn in-browser solution would help me to better illustrate changes to team members while in meetings."}, {"role": "assistant", "content": "You can view the change history of a file by clicking on the history button, or by adding commits to the URL of the file. Here is what it looks like for a file at the Homebrew repository on GitHub:\nhttps://github.com/mxcl/homebrew/commits/master/SUPPORTERS.md\nTo get a line-by-line history, simply add the SHA-1 string of the commit for which you want to see the diff to the URL after the word commit, and then anchor it with the filename you are interested in. For the same file above:\nhttps://github.com/mxcl/homebrew/commit/288f001e924d5365b79c279e4478f372a04011ae#SUPPORTERS.md\nTo see all commits for a single branch use a URL like this\nhttps://github.com/mxcl/homebrew/commits/master\nTo see all commits for all branches use a URL like this\nhttps://github.com/mxcl/homebrew/commits\nThere is no button or link in the web UI for these URLs, but you can bookmark them easily."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Configuring GitLab to use SAML OmniAuth with an Active Directory IdP\n\nI am in the process of altering an existing GitLab installation to use SAML rather than LDAP for authentication. \nAt this point, users can successfully sign into the Web application using the 'Sign in with Saml' button. I am unclear, however, about what seems to be a difference between the LDAP and SAML approaches: users with accounts created via an LDAP sign-in can then access Git repositories (e.g. using clone, push, ...) using their LDAP usernames and passwords, but users with accounts created via a SAML sign-in cannot. \nThrough experimentation, I’ve found that users can access the Git repositories if they use the GitLab UI to set a separate GitLab account password on the account that is created during the initial SAML interaction. I was pointed in this direction by a GitLab message that appeared after creating a project under one of the new user accounts: 'You won't be able to pull or push project code via HTTPS until you set a password on your account'. \nIt seems possible that this separate password configuration is only necessary because I’ve misconfigured the SAML integration somehow. So, my question is whether I am wrong to expect that authenticating access to the GitLab-hosted Git repositories would work the same regardless of whether SAML or LDAP is used? If not, does anyone know of relevant SAML configuration settings that I should review?\nIn case it’s of interest: I have posted a similar question to the GitLab Google group, but I have not received any responses there yet."}, {"role": "assistant", "content": "This is an old question, but I'm responding anyway in hopes it helps someone else who stumbles upon this question. \nAn important distinction between LDAP and SAML is that SAML is a web-based single sign on technology. Part of the SAML sign in process happens between the user's client (browser) and the SAML server directly and then GitLab verifies that information on the backend. In contrast, when given a user's LDAP password GitLab can connect directly to the LDAP server and verify the identity. \nMany GitLab users utilize a combination of LDAP and SAML. SAML provides seamless single sign-on for the web side while LDAP allows Git over HTTPS to accept passwords and also opens the door to advanced features like LDAP Group Sync in Enterprise Edition."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git, error: remote unpack failed: unable to create temporary object directory - By creating new Branch\nI'm trying to create a new branch in my repo.\nI did this:\ngit branch events\n\ngit Checkout events\n\nThat worked. So I changed some files and did:\ngit Status\ngit add --all\ngit commit -m \"Commit\"\n\nThat worked well but I tried to push it and that didn't work:\ngit push -u origin events\n\nThis is the error:\nEnumerating objects: 9, done. \nCounting objects: 100% (9/9), done. \nDelta compression using up to 4 threads. \nCompressing objects: 100% (5/5), done. \nWriting objects: 100% (5/5), 716 bytes | 716.00 KiB/s, done. \nTotal 5 (delta 4), reused 0 (delta 0) \nerror: remote unpack failed: unable to create temporary object directory \nTo http://git.int.censoredlink/scm/freeb/freebrep.git \n ! [remote rejected] events -> events (unpacker error) \nerror: failed to push some refs to 'http://[email protected]/scm/freeb/freebrep.git'\n\nI don't know why it does not work.\nI have Admin rights on the Repo. I censored the link to the repo because its an internal Repo with private link."}, {"role": "assistant", "content": "This error message:\n\nerror: remote unpack failed: unable to create temporary object directory\n\n\nindicates that the Git repository at the server (not your Git) is out of space, or running into similar server problems,1 or installed incorrectly. That is, given:\n\nTo: http://git.int.censoredlink/scm/freeb/freebrep.git\n\n\nyou will have to log in to the machine that serves HTTP traffic at git.int.censoredlink, walk down to the scm/freeb/freebrep.git directory, and correct the installation there. It's most likely a permissions issue: the receiving Git must be able to create, in the objects area, a directory named incoming-XXXXXX with the Xs replaced by a unique identifier, and then create within that directory a pack subdirectory.\nAll incoming objects and pack files are placed in these directories, in a sort of quarantine procedure, until the server-side Git hooks are satisfied with the reference name update requests. If the push fails, the quarantine directory is simply removed. If the push succeeds, the quarantined objects and/or pack files are migrated (and thin packs adjusted) into the normal object storage area. Note that the migration can fail even if the quarantine process succeeds; but if it does so, you get a different error reported to the client. (This error must also be corrected on the server.)\nNote: it's rather unusual to push to http:// rather than https:// or ssh:// URLs. Inspect your server configuration to see who will own the various files thus created, and what permissions the web server will have.\n\n1If a hard drive fails, Linux will sometimes mark the drive and/or its file systems read only. Or, even if you have disk space, you can run out of inodes. A number of different root causes will all lead to the same observed behavior on your client end. If you are a Linux admin checking on a server, look for system log messages, and consider both df and df -i output."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I ignore an error on 'git pull' about my local changes would be overwritten by merge?\nHow do I ignore the following error message on Git pull?\n\nYour local changes to the following files would be overwritten by merge\n\nWhat if I want to overwrite them?\nI've tried things like git pull -f, but nothing works.\nTo be clear, I only want to overwrite specific changes, not everything."}, {"role": "assistant", "content": "If you want remove all local changes - including files that are untracked by git - from your working copy, simply stash them:\ngit stash push --include-untracked\n\nIf you don't need them anymore, you now can drop that stash:\ngit stash drop\n\nIf you don't want to stash changes that you already staged - e.g. with git add - then add the option --keep-index. Note however, that this will still prevent merging if those staged changes collide with the ones from upstream.\n\nIf you want to overwrite only specific parts of your local changes, there are two possibilities:\n\nCommit everything you don't want to overwrite and use the method above for the rest.\nUse git checkout path/to/file/to/revert for the changes you wish to overwrite. Make sure that file is not staged via git reset HEAD path/to/file/to/revert."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-stash - Stash the changes in a dirty working directory away --only-untracked"}, {"role": "assistant", "content": "This option is only valid for the show command. Show only the untracked files in the stash entry as part of the diff."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Run gitlab-ci.yml only when merge request to master made\n\nI am currently having my project in GitLab and Heroku. What I wanna do is as soon as I ask for merge request with my feature branch (let's call it crud-on-spaghetti), I want to automatically run the tests on this branch (npm test basically, using Mocha/Chai), and after they succeed, merge this crud-on-spaghetti with master, commit it and push it to origin/master (which is remote on GitLab) and after git push heroku master (basically, push it to the master branch in Heroku, where my app is stored). I have read several articles on GitLab CI and I think this is more suitable for me (rather than Heroku CI, because I do not have DEV and PROD instances). \nSo, as of now, I do this manually. And this is my .gitlab-ci.yml file now (which is not committed/pushed yet):\nstages:\n - test\n - deploy\n\ntest_for_illegal_bugs:\n stage: test\n script:\n - npm test\n\ndeploy_to_dev:\n stage: deploy\n only:\n - origin master\n script:\n - git commit\n - git push origin master\n - git pull heroku master --rebase\n - git push heroku master\n\nHence, my questions is: What do I exactly need to write in .gitlab-ci.yml in order to automate all these \"manipulations\" (above)?\nPS. And another (theoretical) follow-up question: how is GitLab-CI Runner triggered? For instance, if I want it to trigger upon merge request with master, do I do that using only: ... in .gitlab-ci.yml?"}, {"role": "assistant", "content": "As of 2023 the keywords only and except have been deprecated in favor of rules (see docs).\nIn newer versions\nUsing rules: to restrict the execution of a job to a merge request to the target branch:\n rules:\n - if: '$CI_PIPELINE_SOURCE == \"merge_request_event\" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == \"master\"'\n\nFor older versions\nRestrict stages to Merge Requests:\nTo have your test stage only being executed when a Merge Request (MR) is opened, use:\n only:\n - merge_requests\n\nAccording to the Gitlab docs, you can further restrict this to only being executed for MRs with a certain target branch, e.g. only MRs for master\n only:\n - merge_requests\n except:\n variables:\n - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != \"master\"\n\nThis adds an exception for all target branches that are not master.\nRestrict stages to Branches:\nAs already mentioned by @marcolz, this is achieved by\n only:\n - master\n\nto only execute the stage for pushes to the master branch."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitLab: Is it possible to run pipeline on a specific runner?\n\nIs it possible to run a pipeline on a specific runner? (not using tags)\nIs it feasible to use environments, or even gitlab runner exec maybe?\n\nScenario:\nHave an existing project with multiple runners already attached to it (specific project token used to register the runner) and has it's own associated tags (so can't change these either).\nI'm adding a new runner, however need to test it first to ensure it works, but I need to force the pipeline to build on this machine, without changing any tags, or specific project of the runner."}, {"role": "assistant", "content": "You have two mechanisms by which you can attempt to isolate a new runner for testing:\n\nuse tags and private runner attachment (already called out)\nuse the gitlab-runner exec verb directly on the runner\ncanary the runner for a single build only\n\nOption 1\nuse tags and private runner attachment (already called out).\nTo further expand on this... even in a draconian setup where you can't alter tags and whatnot -- you can always FORK the project. \nIn your new private fork, you can go to Settings >> CI/CD and override the .gitlab-ci.yml file in the Custom CI Configuration Path under the General Pipelines Settings. This allows you to git cp .gitlab-ci.yml .mycustomgitlab-ci.yml and then simply git add/git commit/git push and you're in business.\nOpinion: If you cannot use the mechanisms in place to adjust the tags on the questionable runner and isolate a new forked project, this isn't a technical problem, it is a political problem.\nOption 2\nGitlab-runner exec....\nAssuming you're using a shell gitlab runner...\n\nSSH to the questionable gitlab runner box you're trying to test\nClone the repo for the project in question to ... say ... /tmp/myrepo\nExecute Gitlab-Runner: /path/to/gitlab-runner exec shell {.gitlab-ci.yml target}\n\nSee https://docs.gitlab.com/runner/commands/#gitlab-runner-exec and a blog about it at https://substrakt.com/how-to-debug-gitlab-ci-builds-locally/\nOption 3\nCanary the gitlab-runner for a single build.\nYou can spin up the gitlab-runner process to do N number of builds and then go back offline. See: https://docs.gitlab.com/runner/commands/#gitlab-runner-run-single\n... This is not zero-impact, but will definitely limit the blast radius of any problems."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --suffix=.<sfx>"}, {"role": "assistant", "content": "Instead of using .patch as the suffix for generated\nfilenames, use specified suffix. A common alternative is --suffix=.txt . Leaving this empty will remove the .patch suffix. Note that the leading character does not have to be a dot; for example,\nyou can use --suffix=-patch to get 0001-description-of-my-change-patch ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Should I ignore the launchSettings.json file from being committed in Git?\nI find this relatively known GitHub repository, where they considered launchSettings.json file (which is used by Visual Studio 2017 for .Net Core projects) is to be ignored.\nhttps://github.com/github/gitignore/blob/master/VisualStudio.gitignore\nWhy should it be ignored? I used always in the company I work in to commit it, I am curious to know if there is any reason to ignore it."}, {"role": "assistant", "content": "launchSettings.json should not be ignored. That repository has since been updated to not ignore it: https://github.com/github/gitignore/pull/2705\n\nReasons for making this change:\nIgnoring launchSettings.json does not make much sense. Now .NET CLI even considers this file when running with dotnet run, as you can read here.\nThis settings will be useful if shared among project members, so it should be commited to the repo.\nLinks to documentation supporting these rule changes:\nhttps://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-run?tabs=netcore2x"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git is not working after macOS update (\"xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools\")\nI updated to the latest OS, and/or restarted my computer (this happens on every major update, but this time all I did was restart my computer on 2022-09-13).\nThis morning I navigated to my work's codebase in the command line on my MacBook Pro, typed in \"git status\" in the repository and received an error:\n(In 9/2022, this error was much different, but I didn't capture it)\n\nxcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun\n\nGit will not work!\nHow do I fix Git, and the command-line tools?"}, {"role": "assistant", "content": "The problem is that Xcode Command-line Tools needs to be updated due to a MacOs update.\n\nDid not run into this on Sonoma.\n\nMaybe Apple fixed the process?\n\n\nUpdated for Ventura\n\nAfter opening the terminal after restarting, I tried to go to my code, and do a git status, and I got an error and prompt for command line software agreement:\nSo press space until you get to the [agree, print, cancel] option, so careful hit space to scroll down to the end, if you blow past It you have to run a command to get it back. Use sudo xcodebuild -license to get to it again.\nJust be careful on scrolling down and enter agree and press return and it will launch into an update.\n\nThen I tried to use git after the install, and it prompted me to install Xcode tools again.\nI followed my own advice from previous years (see below), and went to https://developer.apple.com/download/all and downloaded\n\"Command Line Tools for Xcode 14\" (You have to log in with your Apple ID and enter MFA code, so have all the devices you need for that handy. Then select \"Command Line Tools for Xcode 14\", or if you want to get into the alphas or betas, that's up to you. But stable releases are probably the best choice for software developers.\n\nYou have to either download the tools from CLI or the developer page and before you can use git, you need to reboot!!! Or you will get stuck in a loop of prompt & downloading\nRebooting will break the loop and complete the installation of your CLI tools including git so that you can get back to work\nSolutions for previous years, these may or may not be valid these days as the downloads page has changed significantly:\nPREVIOUS YEARS SOLUTIONS, probably #2 is most helpful.\n*** Solution #1:\nGo back to your terminal and enter:\nxcode-select --install\n\nYou'll then receive the following output:\nxcode-select: note: install requested for command line developer tools\n\nYou will then be prompted in a window to update Xcode Command Line tools. (which could take a while)\nOpen a new terminal window and your development tools should be returned.\nAddition: With any major or semi-major update you'll need to update the command line tools in order to get them functioning properly again. Check Xcode with any update. This goes beyond Mojave...\nAfter that restart your terminal\nAlternatively, IF that fails, and it might.... you'll get a pop-up box saying \"Software not found on server\", proceed to solution 2.\n*** Solution #2: (Preferred method)\nIf you hit xcode-select --install and it doesn't find the software, log into Apple Developer, and install it via webpage.\nLog in or sign up here:\nhttps://developer.apple.com/download/more/\nLook for: \"Command Line Tools for Xcode 14.x\" in the list of downloads\nThen click the dmg and download. (See previous image above) either way, you will probably wind up at an apple downloads webpage."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do you revert a git file to its staging area version?\nLet's say I have a file named a.txt. I add it to the staging area, and then I modify it. How could I return it to the way it was when I added it?"}, {"role": "assistant", "content": "Prior to Git 2.23: git checkout a.txt\nStarting from Git 2.23: git restore a.txt\n\nGit tells you this if you type git status.\nPrior to Git 2.23:\n# On branch master\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# modified: a\n#\n# Changed but not updated:\n# (use \"git add <file>...\" to update what will be committed)\n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n# modified: a\n#\n\nStarting from Git 2.23:\nOn branch master\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n modified: a\n\nChanges not staged for commit:\n (use \"git add <file>...\" to update what will be committed)\n (use \"git restore <file>...\" to discard changes in working directory)\n modified: a"}]} {"messages": [{"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?\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."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs <limit>"}, {"role": "assistant", "content": "An integer parameter specifies a cut-off percent (3% by default).\nDirectories contributing less than this percentage of the changes\nare not shown in the output."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What are your pros and cons of git after having used it? [closed]\nClosed. This question is opinion-based. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it can be answered with facts and citations by editing this post.\n\n\nClosed 10 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI'm using SVN right now, and I've used CVS and VSS in the past. SVN is the current favourite in my books, but I've been hearing a lot about git. Of the people that have used git, what are the pros and cons from your experience?"}, {"role": "assistant", "content": "I don't have a lot of experience with git, but:\nPros:\n\nIt's really quick\nLocal commits rock\nQuick to start a new repository (no configuration etc)\ngithub is easy to use\n\n(I haven't really \"needed\" the distributed side of things yet, beyond being able to have a local repository and push to a public one.)\nCons:\n\nWindows support is still lagging behind, I believe - and you can't just use it from a normal command prompt\nLack of IDE and Explorer integration\nIt took me a while to find a good introductory text along the lines of the redbean book.\nThe fact that \"adding\" a changed file only adds the contents at that point of time (so it can show up as staged for commit and still have modifications which require another git add) took a while to grasp"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options gitcvs.dbTableNamePrefix"}, {"role": "assistant", "content": "Database table name prefix. Prepended to the names of any\ndatabase tables used, allowing a single database to be used\nfor several repositories. Supports variable substitution (see git-cvsserver for details). Any non-alphabetic\ncharacters will be replaced with underscores."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options guitool.<name>.revPrompt"}, {"role": "assistant", "content": "Request a single valid revision from the user, and set the REVISION environment variable. In other aspects this option\nis similar to argPrompt , and can be used together with it."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %(trailers[:<options>])"}, {"role": "assistant", "content": "display the trailers of the body as interpreted by git-interpret-trailers . The trailers string may be followed by\na colon and zero or more comma-separated options. If any option is provided\nmultiple times, the last occurrence wins. key=<key> : only show trailers with specified <key>. Matching is done\ncase-insensitively and trailing colon is optional. If option is\ngiven multiple times trailer lines matching any of the keys are\nshown. This option automatically enables the only option so that\nnon-trailer lines in the trailer block are hidden. If that is not\ndesired it can be disabled with only=false . E.g., %(trailers:key=Reviewed-by) shows trailer lines with key Reviewed-by . only[=<bool>] : select whether non-trailer lines from the trailer\nblock should be included. separator=<sep> : specify the separator inserted between trailer\nlines. Defaults to a line feed character. The string <sep> may contain\nthe literal formatting codes described above. To use comma as\nseparator one must use %x2C as it would otherwise be parsed as\nnext option. E.g., %(trailers:key=Ticket,separator=%x2C ) shows all trailer lines whose key is \"Ticket\" separated by a comma\nand a space. unfold[=<bool>] : make it behave as if interpret-trailer’s --unfold option was given. E.g., %(trailers:only,unfold=true) unfolds and shows all trailer lines. keyonly[=<bool>] : only show the key part of the trailer. valueonly[=<bool>] : only show the value part of the trailer. key_value_separator=<sep> : specify the separator inserted between\nthe key and value of each trailer. Defaults to \": \". Otherwise it\nshares the same semantics as separator=<sep> above."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-gc"}, {"role": "assistant", "content": "Cleanup unnecessary files and optimize the local repository"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git log tabular formatting\nI have a simple alias to display few last commits:\nlog --pretty=format:'%h %an %s' -10\n\nHow can I make the results to be displayed in columns, like this:\n898e8789 Author1 Commit message here\n803e8759 Other Author name Commit message here"}, {"role": "assistant", "content": "In Git 1.8.3 and later, there is native support for this in the pretty format, using the %<(N) syntax to format the next placeholder as N columns wide:\n$ git log --pretty=format:'%h %<(20)%an %s' -10\n\nFor versions before 1.8.3, the previous version of this answer, retained below, should work.\nHere's a solution in Bash using read to parse the log lines back apart, and printf to print them out, with a fixed width field for the authors name so the columns will stay lined up. It assumes that | will never appear in the author's name; you can choose another delimiter if you think that might be a problem.\ngit log --pretty=format:'%h|%an|%s' -10 | \n while IFS='|' read hash author message\n do \n printf '%s %-20s %s\\n' \"$hash\" \"$author\" \"$message\"\n done\n\nYou can create this as an alias using:\n[alias]\n mylog = \"!git log --pretty=format:'%h|%an|%s' -10 | while IFS='|' read hash author message; do printf '%s %-20s %s\\n' \\\"$hash\\\" \\\"$author\\\" \\\"$message\\\"; done\"\n\nI'm sure you could do this in fewer characters using awk but as the saying goes,\n\nWhenever faced with a problem, some people say “Lets use AWK.” Now, they have two problems.\n\nOf course, having said that, I had to figure out how to do it in awk which is a bit shorter:\ngit ... | awk -F '|' '{ printf \"%s %-20s %s\\n\", $1, $2, $3 }'"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git: list all commits on all remote branches?\nI would like to list all commits on all remote branches in my repository.\nI just want the SHA1 for each commit."}, {"role": "assistant", "content": "Try this:\ngit log --branches=\"*\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Local git config not overriding global user for project\n\nI have a global git user configured, but want to use a different user for a single git project.\nWithin that project, I've used git config --local user.name \"localuser\" and git config --local user.email \"[email protected]\" to set the local project's user and email.\nHowever, when I try to push to my remote on github, I get this error:\nremote: Permission to localuser/repo.git denied to globaluser.\nfatal: unable to access 'https://github.com/localuser/repo.git/': The requested URL returned error: 403\n\nHere's some output that might help with diagnosis:\ngit remote -v:\ngithub https://github.com/localuser/repo.git (fetch)\ngithub https://github.com/localuser/repo.git (push)\n\ngit config --list:\nuser.name=globaluser\n[email protected]\n...\n\ngit config --local --list:\nuser.name=localuser\n[email protected]\n...\n\ngit config user.name:\nlocaluser"}, {"role": "assistant", "content": "I had committed my changes and received a permission denied with my global user. Subsequently setting the local user did nothing, though git config user.name reported the correct local user.\nWhat worked was (courtesy of this google groups thread):\ngit commit --amend --reset-author\nI presume the committed changes had the original author attached."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can you set Gitlab CI stage so other stages don't wait for it to finish?\n\nLet's say I have these stages defined in .gitlab-ci.yml:\nstages:\n - build\n - analysis\n - tests\n - deploy\n - post-deploy\n\nSince analysis takes a lot of time and I don't really care about the result (I also have allow_failure: true set) - is it possible to somehow define to start analysis and then immediately launch the next stage tests?\nI didn't find any reference to similar topic on official docs.\nEDIT:\nThe main idea is that all other stages can be run as if the analysis didn't even exist. If i put analysis to same stage as tests, then both analysis and tests will run at the same time, however deploy won't be launched until both of them finish. This is no good. I want tests to finish and then launch deploy, after deploy finishes I want to launch post-deploy. I really don't care about analysis result, I simply want to trigger it and continue with the deployment."}, {"role": "assistant", "content": "Since v12.8, you can use needs: [] to start jobs start immediately. Docs: https://docs.gitlab.com/ee/ci/yaml/#needs"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-add - Add file contents to the index -f --force"}, {"role": "assistant", "content": "Allow adding otherwise ignored files."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can Git restructure my folders without losing history?\nI have a git repo, and currently I'm the only one using it.\nI want to take all the files and folders under the root folder, and put them inside a new folder.\nCurrent structure:\n\nmain ->\n src\n res\n\nNew structure:\n\nmain ->\n app1\n src\n res\n\nIs there a way I can do that so that the files don't lose their git history?"}, {"role": "assistant", "content": "TL;DR\nGo ahead: move your files and directories around. Just make sure you don't make any edits to files in the same commit as your directory restructuring.\nWhy It Works\nGit is a content tracker, not a file tracker. If you move/rename files, but make no other changes to the content of those files, then Git just rewrites the tree objects. The file blobs are not changed by directory operations; directory location information is stored separately in tree objects.\nActual rename detection is handled by diffing the blobs and trees, and looking for a configurable percentage of similarity between files. This means that Git doesn't really store moves or renames directly; it computes them from differences between commits.\nThe upshot of all this is that your history is not tied to a particular filename or directory structure. This works really well for most use cases, but stands in contrast to systems like Bazaar that track renames as first-class operations."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-help"}, {"role": "assistant", "content": "Display help information about Git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to make a simple revert work on Git / EGit?\nOk. Simple things should be simple, so I hope it is. :)\nI have changed a file, now I want to revert back to the latest version in the git repo because my changes are crap and I want to start fresh again changing the file.\nAs far as I am concerned you should do this:\ngit checkout -- <NAME OF FILE>\nFirst question: How to do this inside eclipse with EGit? There is no checkout option under team. :( :( :(\nNow let's suppose I have multiple files modified in multiple directors. How do I revert all of them to start fresh again?"}, {"role": "assistant", "content": "In my version \"Replace With...\" -> \"HEAD Revision\" seems to be doing just that...\nIt's not in the \"Team\" submenu, which is a bit confusing, I admit..\nAlso, this might help : Eclipse git checkout (aka, revert)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects %x00"}, {"role": "assistant", "content": "%x followed by two hexadecimal digits is replaced with a\nbyte with the hexadecimal digits' value (we will call this\n\"literal formatting code\" in the rest of this document)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch recursive"}, {"role": "assistant", "content": "This can only resolve two heads using a 3-way merge\nalgorithm. When there is more than one common\nancestor that can be used for 3-way merge, it creates a\nmerged tree of the common ancestors and uses that as\nthe reference tree for the 3-way merge. This has been\nreported to result in fewer merge conflicts without\ncausing mismerges by tests done on actual merge commits\ntaken from Linux 2.6 kernel development history.\nAdditionally this can detect and handle merges involving\nrenames. It does not make use of detected copies. This was\nthe default strategy for resolving two heads from Git v0.99.9k\nuntil v2.33.0. The recursive strategy takes the same options as ort . However,\nthere are three additional options that ort ignores (not documented\nabove) that are potentially useful with the recursive strategy: patience Deprecated synonym for diff-algorithm=patience . diff-algorithm=[patience|minimal|histogram|myers] Use a different diff algorithm while merging, which can help\navoid mismerges that occur due to unimportant matching lines\n(such as braces from distinct functions). See also git-diff --diff-algorithm . Note that ort specifically uses diff-algorithm=histogram , while recursive defaults to the diff.algorithm config setting. no-renames Turn off rename detection. This overrides the merge.renames configuration variable.\nSee also git-diff --no-renames ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs -I<regex> --ignore-matching-lines=<regex>"}, {"role": "assistant", "content": "Ignore changes whose all lines match <regex>. This option may\nbe specified more than once."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Force git to run post-receive hook, even if everything is \"up-to-date\"\nHow do I force git to run a post-receive hook on a server even if I don't have a new commit to push?\nBackground\nI use git to automatically deploy a website to a server. I have a bare repo in a protected area of the server and a post-receive hook that checks out the contents and systematically copies over certain files into a public_html folder. (Inspired by this tutorial)\nI got tired of modifying the post-receive hook manually on the server, so my post-receive hook now actually copies over a new version of itself from the repo:\n#!/bin/sh\n\nrm -rf ~/../protected/*\nGIT_WORK_TREE=~/../protected git checkout -f\n\n# Rewrite over this file with any updates from the post-receive file\ncp ~/../protected/post-receive hooks/post-receive\n\n# Delete public_html\n# Copy stuff public_html\n\nThe problem, of course, is that the new post-receive hook never gets run. A seemingly simple solution would be merely to push again, but now everything is already up to date. This is annoying, because it requires me to fake a new commit every time I update the post-receive hook. Is there a way to invoke the post-receive hook without faking a commit or sshing in? \nWhat I tried\ngit push\ngit push -f"}, {"role": "assistant", "content": "Use '--allow-empty'\nAfter the initial push replacing the script, you can do this :\ngit commit --allow-empty -m 'push to execute post-receive'\n\nThe --allow-empty flag overrides git's default behavior of preventing you from making a commit when there are no changes.\nUse an alias and make your life even easier\nAdd the following to ~/.gitconfig\n[alias]\n pushpr = \"!f() { git push origin master;git commit --allow-empty -m 'push to execute post-receive';git push origin master; }; f\"\n\nNow Just do git pushpr\ngit pushpr\n\nThis will push any changes to master, which in your case will trigger your post receive replacement script, then it will push again (using the --allow-empty flag) which will then execute your updated post-receive script."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to list all commits that changed a specific file?\nIs there a way to list all commits that changed a specific file?"}, {"role": "assistant", "content": "The --follow works for a particular file\ngit log --follow -- filename\n\nDifference to other solutions given\nNote that other solutions include git log path (without the --follow). That approach is handy if you want to track e.g. changes in a directory, but stumbles when files were renamed (thus use --follow filename)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to determine the URL that a local Git repository was originally cloned from\nI pulled a project with several forks on GitHub, but forgot which fork it was. How do I determine which fork I pulled?"}, {"role": "assistant", "content": "To obtain only the remote URL:\ngit config --get remote.origin.url\n\nIf you require full output, and you are on a network that can reach the remote repo where the origin resides:\ngit remote show origin\n\nWhen using git clone (from GitHub, or any source repository for that matter) the default name for the source of the clone is \"origin\". Using git remote show will display the information about this remote name. The first few lines should show:\nC:\\Users\\jaredpar\\VsVim> git remote show origin\n* remote origin\n Fetch URL: [email protected]:jaredpar/VsVim.git\n Push URL: [email protected]:jaredpar/VsVim.git\n HEAD branch: master\n Remote branches:\n\nIf you want to use the value in a script, you would use the first command listed in this answer."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Want to change my master to an older commit, how can I do this?\nI want to rollback to a previous commit, and then publish that code, then go back to the latest commit.\ni.e. so my master is pointing to an older commit version just so I can pulish that version, then I want to go back to the latest commit I was one initially.\nHow can I do this?"}, {"role": "assistant", "content": "If you want to do this and revert the master to the previous commit:\ngit checkout master~1 # Checkout previous commit on master\ngit checkout -b new_master # Create branch for new master\ngit branch -D master # Delete old master\ngit branch -mv new_master master # Make new_master master\n\nAlternatively:\ngit reset --hard master~1 # Reset current branch to one commit ago on master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs git log --follow builtin/rev-list.c"}, {"role": "assistant", "content": "Shows the commits that changed builtin/rev-list.c , including\nthose commits that occurred before the file was given its\npresent name."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git: Recover deleted (remote) branch\nI need to recover two Git branches that I somehow deleted during a push.\nThese two branches were created on a different system and then pushed to my \"shared\" (github) repository.\nOn my system, I (apparently) retrieved the branches during a fetch:\n~/myfolder> git fetch\nremote: Counting objects: 105, done.\nremote: Compressing objects: 100% (58/58), done.\nremote: Total 62 (delta 29), reused 0 (delta 0)\nUnpacking objects: 100% (62/62), done.\nFrom github.com:mygiturl\n * [new branch] contact_page -> origin/contact_page\n 731d1bb..e8b68cc homepage -> origin/homepage\n * [new branch] new_pictures -> origin/new_pictures\n\nRight after that I did a push to send my local changes up to the central repo. For some reason, these branches were deleted from both my local system and the central repo:\n~/myfolder> git push\nCounting objects: 71, done.\nDelta compression using up to 2 threads.\nCompressing objects: 100% (43/43), done.\nWriting objects: 100% (49/49), 4.99 KiB, done.\nTotal 49 (delta 33), reused 0 (delta 0)\nTo [email protected]:mygiturl.git\n - [deleted] contact_page\n + e8b68cc...731d1bb homepage -> homepage (forced update)\n bb7e9f2..e0d061c master -> master\n - [deleted] new_pictures\n e38ac2e..bb7e9f2 origin/HEAD -> origin/HEAD\n 731d1bb..e8b68cc origin/homepage -> origin/homepage\n e38ac2e..bb7e9f2 origin/master -> origin/master\n * [new branch] origin/contact_page -> origin/contact_page\n * [new branch] origin/new_pictures -> origin/new_pictures\n\nIt's not terribly easy to get the branches off of their birthplace machine, so I'd like to try and recover them from my local if possible.\nAll of the git \"undo\" information I've googled has to with recovering lost commits. I don't think that applies here, since I don't have commit UIDs for these branches.\nI'd like to know how I can get these back. I'd also like to know how they were deleted in the first place and how I can avoid this in the future.\nEDIT: by request, here's my repo configuration\nuser.name=Craig Walker\n[email protected]\nalias.unadd=reset HEAD\ncore.repositoryformatversion=0\ncore.filemode=true\ncore.bare=false\ncore.logallrefupdates=true\ncore.ignorecase=true\nremote.origin.fetch=+refs/heads/*:refs/remotes/origin/*\n[email protected]:MyGitURL.git\nremote.origin.mirror=true\nbranch.master.remote=origin\nbranch.master.merge=refs/heads/master\nalias.undo=reset --hard\nalias.test=push -f ci HEAD:master\nalias.st=status\nalias.ci=commit\nalias.br=branch\nalias.co=checkout\nalias.ch=checkout\nalias.df=diff\nalias.lg=log -p\nalias.who=shortlog -s --\nremote.ci.url=ContinuousIntegrationGitURL\nremote.ci.fetch=+refs/heads/*:refs/remotes/ci/*\nbranch.photo.remote=origin\nbranch.photo.merge=refs/heads/photos\nremote.foo.url=FooGitURL\nremote.foo.fetch=+refs/heads/*:refs/remotes/cynthia/*\nbranch.homepage.remote=origin\nbranch.homepage.merge=refs/heads/homepage"}, {"role": "assistant", "content": "I'm not an expert. But you can try\ngit fsck --full --no-reflogs | grep commit\n\nto find the HEAD commit of deleted branch and get them back."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do you `git cherry-pick --continue` with `--no-verify`?\nHow do you git cherry-pick --continue with --no-verify since --no-verify is not a valid option. git cherry-pick --no-commit --continue does not work since those two parameters are mutually exclusive."}, {"role": "assistant", "content": "If your cherry-pick (without --no-commit) had merge conflicts and you want to --continue after solving them, you can temporarily disable git hooks for the current repo with:\n$ git config core.hooksPath # Print current setting\n$ git config core.hooksPath '/dev/null/'\n\nAfter you're done, depending on whether core.hooksPath was set before, you can either restore the previous setting:\n$ git config core.hooksPath '/some/previous/path'\n\nor unset it again:\n$ git config --unset core.hooksPath"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Remove .pyc files from Git remote repository\nAccidentally, I have pushed the .pyc files to the master repository. Now I want to delete them but I can´t do it. Is there any way to remove them directly from the Bitbucket site?"}, {"role": "assistant", "content": "Remove .pyc files using git rm *.pyc. If this not work use git rm -f *.pyc\nCommit git commit -a -m 'all pyc files removed'\nPush git push\nIn future commits you can ignore .pyc files by creating a .gitignore file"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch subtree[=<path>]"}, {"role": "assistant", "content": "This option is a more advanced form of subtree strategy, where\nthe strategy makes a guess on how two trees must be shifted to\nmatch with each other when merging. Instead, the specified path\nis prefixed (or stripped from the beginning) to make the shape of\ntwo trees to match."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options remote.<name>.skipFetchAll"}, {"role": "assistant", "content": "If true, this remote will be skipped by default when updating\nusing git-fetch or the update subcommand of git-remote ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-archive - Create an archive of files from a named tree export-ignore"}, {"role": "assistant", "content": "Files and directories with the attribute export-ignore won’t be\nadded to archive files. See gitattributes for details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can I use my existing git repo with openshift?\nIs it necessary to have git repo on openshift only? I already have bitbucket / github git repo and would prefer to push there only. Can I simply hook into it so that openshift gets intimation ?\nOr for simplification, I push only at github, but when I want to deploy, I do something with openshift?\nI did check this but it confused me: it's talking about merging exiting and new (openshift) git ?"}, {"role": "assistant", "content": "I have the impression that you're not used to use git enough yet. I'd advise you to get into git to fully understand how to push your code to openshift. Nevertheless let me try to explain you the steps involved:\nAs you'd do with git in general, the approach to choose here is to clone your other git repo (ex. on bitbucket) to your local machine: \ngit clone <bitbucket-repo-url>\nYour local clone has then your other repo (bitbucket etc.) as remote repo. Your remote repo is stored with the alias \"origin\" (the default alias used by git if you clone). You then add the openshift repo as remote to your clone. You do that while explicitly using an alias for the remote repo you add - I'm using \"openshift\" as alias here:\ngit remote add openshift -f <openshift-git-repo-url>\nIn order to then be able to push the code from your local git repo to openshift you first have to merge your openshift repo with your local bitbucket clone. You do that by issuing locally:\ngit merge openshift/master -s recursive -X ours\nWith this command you tell git to merge the master branch in the openshift git repo with your local git repo. You tell it to merge using the recursive merging strategy and to choose your (\"ours\") version when there are conflicts.\nOnce the merge is executed you're ready to push your git repo to openshift. You do that by doing:\ngit push openshift HEAD\nYou tell git to push your local code to the HEAD branch on the remote repo called \"openshift\" (the alias we stored the openshift git repo at, some paragraphs further up).\nbtw. I wrote a jboss tools blog which was demonstrating how to use the openshift-java-client some months ago: https://community.jboss.org/wiki/Enable-openshift-ciFullExampleUsingOpenshift-java-client . You'll spot the above steps in the last paragraph \"We're almost there\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-cherry-pick - Apply the changes introduced by some existing commits --ff"}, {"role": "assistant", "content": "If the current HEAD is the same as the parent of the\ncherry-pick’ed commit, then a fast forward to this commit will\nbe performed."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git add multiple files at once\nI had this project with a lot .c files in source directory,then I make the project, there is .o files inside of the project, I also want to push these files to repository,so instead of add each .o which is possible but...,how to add .o files easily?"}, {"role": "assistant", "content": "How to add multiple files with different extensions to git all at one time...\nYou can add to git by explicitly listing each file with spaces as delimiters.\n$ git add file-name-1.php file-name-2.js file-name-3.html …\n\nThe accepted answer is perfect for the OP’s specific case. But I got here—via Google—needing to add multiple files with different extensions. Posting here in case you miss this similar answer to a similar question.\nDon't forget about interactive staging\nGit interactive staging can also work wonders. To enter interactive staging (aka: adding, removing files):\n $ git add -i"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Saving the entire git diff between two commits in a text file\nis there a way where I could save the entire difference between two diff in a text file?\nSuppose I wanted all the changes between A1 and A10 on master branch.\n--A11-A10-A9-A8-A7-A6-A5-A4-A3-A2-A1-master\n\nOr, is there a way where I could get the entire diff in Terminal which I could copy+paste?"}, {"role": "assistant", "content": "Sure:\ngit diff A10..A1 > my.diff"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to tag an older commit in Git?\nWe are new to Git, and I want to set a tag at the beginning of our repository.\nOur production code is the same as the beginning repository, but we've made commits since then.\nA tag at the beginning would allow us to \"roll back\" production to a known, stable state.\nSo how to add a tag to an arbitrary, older commit?"}, {"role": "assistant", "content": "Example:\ngit tag -a v1.2 9fceb02 -m \"Message here\"\n\nWhere 9fceb02 is the beginning part of the commit id.\nYou can then push the tag using git push origin v1.2.\nYou can do git log to show all the commit id's in your current branch.\nThere is also a good chapter on tagging in the Pro Git book.\nWarning: This creates tags with the current date (and that value is what will show on a GitHub releases page, for example). If you want the tag to be dated with the commit date, please look at another answer."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fast-import - Backend for fast Git data importers blob"}, {"role": "assistant", "content": "Convert raw file data into a blob, for future use in a commit command. This command is optional and is not\nneeded to perform an import."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rebase - Reapply commits on top of another base tip -n --no-stat"}, {"role": "assistant", "content": "Do not show a diffstat as part of the rebase process."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-stash - Stash the changes in a dirty working directory away --index"}, {"role": "assistant", "content": "This option is only valid for pop and apply commands. Tries to reinstate not only the working tree’s changes, but also\nthe index’s ones. However, this can fail, when you have conflicts\n(which are stored in the index, where you therefore can no longer\napply the changes as they were originally)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-cherry-pick - Apply the changes introduced by some existing commits -m <parent-number> --mainline <parent-number>"}, {"role": "assistant", "content": "Usually you cannot cherry-pick a merge because you do not know which\nside of the merge should be considered the mainline. This\noption specifies the parent number (starting from 1) of\nthe mainline and allows cherry-pick to replay the change\nrelative to the specified parent."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch subtree"}, {"role": "assistant", "content": "This is a modified ort strategy. When merging trees A and\nB, if B corresponds to a subtree of A, B is first adjusted to\nmatch the tree structure of A, instead of reading the trees at\nthe same level. This adjustment is also done to the common\nancestor tree."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-reset - Reset current HEAD to the specified state Undo a merge or pull"}, {"role": "assistant", "content": "$ git pull (1) Auto-merging nitfol\nCONFLICT (content): Merge conflict in nitfol\nAutomatic merge failed; fix conflicts and then commit the result.\n$ git reset --hard (2) $ git pull . topic/branch (3) Updating from 41223... to 13134...\nFast-forward\n$ git reset --hard ORIG_HEAD (4) Try to update from the upstream resulted in a lot of\nconflicts; you were not ready to spend a lot of time merging\nright now, so you decide to do that later. \"pull\" has not made merge commit, so git reset --hard which is a synonym for git reset --hard HEAD clears the mess\nfrom the index file and the working tree. Merge a topic branch into the current branch, which resulted\nin a fast-forward. But you decided that the topic branch is not ready for public\nconsumption yet. \"pull\" or \"merge\" always leaves the original\ntip of the current branch in ORIG_HEAD , so resetting hard to it\nbrings your index file and the working tree back to that state,\nand resets the tip of the branch to that commit."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to remove origin from git repository\nBasic question: How do I disassociate a git repo from the origin from which it was cloned?\ngit branch -a shows:\n* master\n remotes/origin/HEAD -> origin/master\n\nand I want to remove all knowledge of origin, and the associated revisions.\nLonger question: I want to take an existing subversion repo and make a number of smaller git repos from it. Each of the new git repos should have the full history of just the relevant branch. I can prune the repo to just the wanted subtree using:\ngit filter-branch --subdirectory-filter path/to/subtree HEAD\n\nbut the resulting repo still contains all the revisions of the now-discarded subtrees under the origin/master branch.\nI realise that I could use the -T flag to git-svn to clone the relevant subtree of the subversion repo in the first place. I'm not sure if that would be more efficient than later running multiple instantiations of git filter-branch --subdirectory-filter on copies of the git repo but, in any case, I would still like to break the link with the origin."}, {"role": "assistant", "content": "Fairly straightforward: \ngit remote rm origin\n\n\nAs for the filter-branch question - just add --prune-empty to your filter branch command and it'll remove any revision that doesn't actually contain any changes in your resulting repo:\ngit filter-branch --prune-empty --subdirectory-filter path/to/subtree HEAD"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_ASKPASS"}, {"role": "assistant", "content": "If this environment variable is set, then Git commands which need to\nacquire passwords or passphrases (e.g. for HTTP or IMAP authentication)\nwill call this program with a suitable prompt as command-line argument\nand read the password from its STDOUT. See also the core.askPass option in git-config ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-imap-send"}, {"role": "assistant", "content": "Send a collection of patches from stdin to an IMAP folder"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --compact-summary"}, {"role": "assistant", "content": "Output a condensed summary of extended header information such\nas file creations or deletions (\"new\" or \"gone\", optionally \"+l\"\nif it’s a symlink) and mode changes (\"+x\" or \"-x\" for adding\nor removing executable bit respectively) in diffstat. The\ninformation is put between the filename part and the graph\npart. Implies --stat ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why use 'git rm' to remove a file instead of 'rm'?\nOn SVN, removing something from the filesystem directly (rather than using svn) created a load of headaches.\nI haven't found this to be an issue when using git, but I notice that git has its own rm implementation (git rm).\nWhat is the difference between rm and git rm?"}, {"role": "assistant", "content": "If you just use rm, you will need to follow it up with git add <fileRemoved>. git rm does this in one step.\nYou can also use git rm --cached which will remove the file from the index (staging it for deletion on the next commit), but keep your copy in the local file system."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --pretty[=<format>] --format=<format>"}, {"role": "assistant", "content": "Pretty-print the contents of the commit logs in a given format,\nwhere <format> can be one of oneline , short , medium , full , fuller , reference , email , raw , format:<string> and tformat:<string> . When <format> is none of the above,\nand has %placeholder in it, it acts as if --pretty=tformat:<format> were given. See the \"PRETTY FORMATS\" section for some additional details for each\nformat. When =<format> part is omitted, it defaults to medium . Note: you can specify the default pretty format in the repository\nconfiguration (see git-config )."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git command to display HEAD commit id?\nWhat command can I use to print out the commit id of HEAD?\nThis is what I'm doing by hand:\n$ cat .git/HEAD\nref: refs/heads/v3.3\n$ cat .git/refs/heads/v3.3\n6050732e725c68b83c35c873ff8808dff1c406e1\n\nBut I need a script that can reliably pipe the output of some command to a text file such that the text file contains exactly the commit id of HEAD (nothing more or less, and not just a ref). Can anyone help?"}, {"role": "assistant", "content": "Use the command:\ngit rev-parse HEAD\n\nFor the short version:\ngit rev-parse --short HEAD"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --[no-]rename-empty"}, {"role": "assistant", "content": "Whether to use empty blobs as rename source."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Merging 2 branches together in Git\nI've only just started to use Git and think it is wonderful, however I'm a little confused over what the merge command does.\nLet us say we have a working project in the branch \"A\".\nI go home and make changes to this branch and save it as \"B\".\nAnother programmer makes changes to \"A\" and saves it as \"C\".\nIs there a way to merge the two branches \"B\" and \"C\" together, then commit the changes as a new branch, say \"D\"?\nOr am missing the point of 'merge'?"}, {"role": "assistant", "content": "merge is used to bring two (or more) branches together.\nA little example:\n$ # on branch A:\n$ # create new branch B\n$ git checkout -b B\n$ # hack hack\n$ git commit -am \"commit on branch B\"\n\n$ # create new branch C from A\n$ git checkout -b C A\n$ # hack hack\n$ git commit -am \"commit on branch C\"\n\n$ # go back to branch A\n$ git checkout A\n$ # hack hack\n$ git commit -am \"commit on branch A\"\n\nSo now there are three separate branches (namely A B and C) with different heads.\nTo get the changes from B and C back to A, checkout A (already done in this example) and then use the merge command:\n$ # create an octopus merge\n$ git merge B C\n\nYour history will then look something like this:\n…-o-o-x-------A\n |\\ /|\n | B---/ |\n \\ /\n C---/\n\nIf you want to merge across repository/computer borders, have a look at git pull command, e.g. from the PC with branch A (this example will create two new commits):\n$ # pull branch B\n$ git pull ssh://host/… B\n$ # pull branch C\n$ git pull ssh://host/… C"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects --remerge-diff"}, {"role": "assistant", "content": "Produce remerge-diff output for merge commits.\nShortcut for --diff-merges=remerge -p ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is github 'compare & pull request'\nI am working on a MeteorIntegration (feature) branch that is published. I did a git push assuming the push was going to the checked-out branch MeteorIntegration: \nAnd now I see the following on both master and MeteorIntegration branches. \n\nI read github documentation: Closing a pull request and Tidying up Pull Requests but that didn't help, possibly because I am not dealing with a pull request here?\nHow do I get rid of this compare & pull request?"}, {"role": "assistant", "content": "You don't actually have a pull request; GitHub just sees that you've pushed a branch, and is offering to create a pull request for it if you want.\nIf you don't care about that, just ignore it. It's completely harmless and will go away as soon as GitHub doesn't think the branch is \"recent\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options diff.wordRegex"}, {"role": "assistant", "content": "A POSIX Extended Regular Expression used to determine what is a \"word\"\nwhen performing word-by-word difference calculations. Character\nsequences that match the regular expression are \"words\", all other\ncharacters are ignorable whitespace."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "markdown link to header\n\nI'm using GitLab to write a read.me file. \nI tried to create a link to a header. According to the wiki an id should be automatically created:\nsee here\nI created a header using:\n### 1. This is my Header\n\nand tried to create a link to it:\n[link](#1--this-is-my-header)\n\nbut it is not working. \nWhat am I doing wrong?"}, {"role": "assistant", "content": "In the Documentation you link to we learn that...\n\nThe IDs are generated from the content of the header according to the\n following rules:\n\nAll text is converted to lowercase.\nAll non-word text (e.g., punctuation, HTML) is removed.\nAll spaces are converted to hyphens.\nTwo or more hyphens in a row are converted to one.\nIf a header with the same ID has already been generated, a unique incrementing number is appended, starting at 1.\n\n\nNote rule 4: \"Two or more hyphens in a row are converted to one.\" However, the example you tried has two hyphens in a row (after the 1). Remove one of them and you should have it.\n[link](#1-this-is-my-header)\n\nFrom time to time I have encountered a unique header which is converted into an ID in some non-obvious way. A quick way to work out the ID is to use your browser's view source and/or inspect tools to view the HTML source code. For example, you might find the following HTML for your example:\n<h3 id=\"1-this-is-my-header\">1. This is my Header</h3>\n\nThen just use the contents of the id attribute with a hash to link to that header: #1-this-is-my-header."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Inline code syntax highlighting in GitHub markdown?\n\nGitHub-flavored markdown supports syntax highlighting in codeblocks. This is done by adding the name of the language next to the triple-grave codeblock markers:\n```ruby\nrequire 'redcarpet'\nmarkdown = Redcarpet.new(\"Hello World!\")\nputs markdown.to_html\n```\n\nStandard markdown also supports inline codeblocks by wrapping text in `single graves`. Is there any way to add syntax highlighting to these inline codeblocks?"}, {"role": "assistant", "content": "GitHub comments, wikis, README.md etc. use GFM, essentially CommonMark with some extensions, where it's not possible to add syntax highlighting. (Follow the link to see whether anything has changed, but don't hold your breath because nothing has in the last decade.)\nHowever, GitHub Pages uses Jekyll and by extension kramdown where you can use:\n`x = 4`{:.ruby}\n\nP.S. If you happen to use pandoc, the syntax is:\n`x = 4`{.ruby}"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitignore not ignoring file\nNo matter what I put in .gitignore I can not get git to ignore the UserInterfaceState.xcuserstate file below:\n$ git status\nOn branch master\nYour branch is up-to-date with 'origin/master'.\n\nChanges not staged for commit:\n (use \"git add <file>...\" to update what will be committed)\n (use \"git checkout -- <file>...\" to discard changes in working directory)\n\n modified: .gitignore\n modified: CalFoo.xcodeproj/project.xcworkspace/xcuserdata/wcochran.xcuserdatad/UserInterfaceState.xcuserstate\n\nI am using/editing the .gitignore file listed on this post.\nI tried everything to match the pattern including the exact pathname: CalFoo.xcodeproj/project.xcworkspace/xcuserdata/wcochran.xcuserdatad/UserInterfaceState.xcuserstate to no avail.\nThis particular problem arises from the workflow where Xcode is used to create the initial git repo and the .gitignore file from here is added afterwards. A more general answer to ignoring previously tracked files in git can be found from this question (I guess I never found this post in my search since it didn't have \"gitignore\" in the title)."}, {"role": "assistant", "content": "You can only ignore unversioned files but that file is already known to git.\nIf you want git to track that file, there is no need to tell git to ignore it.\nIf you don't want git to track that file use git rm and your ignore rule will start working.\nCaution: git rm will remove the file. Use git rm --cached to remove from the repo but not from the disk."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %C(…​)"}, {"role": "assistant", "content": "color specification, as described under Values in the\n\"CONFIGURATION FILE\" section of git-config . By\ndefault, colors are shown only when enabled for log output\n(by color.diff , color.ui , or --color , and respecting\nthe auto settings of the former if we are going to a\nterminal). %C(auto,...) is accepted as a historical\nsynonym for the default (e.g., %C(auto,red) ). Specifying %C(always,...) will show the colors even when color is\nnot otherwise enabled (though consider just using --color=always to enable color for the whole output,\nincluding this format and anything else git might color). auto alone (i.e. %C(auto) ) will turn on auto coloring\non the next placeholders until the color is switched\nagain."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %N"}, {"role": "assistant", "content": "commit notes"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-grep - Print lines matching a pattern git grep -e '#define' --and \\( -e MAX_PATH -e PATH_MAX \\)"}, {"role": "assistant", "content": "Looks for a line that has #define and either MAX_PATH or PATH_MAX ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why does Git use a cryptographic hash function?\nWhy does Git use SHA-1, a cryptographic hash function, instead of a faster non-cryptographic hash function?\nRelated question:\nStack Overflow question Why does Git use SHA-1 as version numbers? asks why Git uses SHA-1 as opposed to sequential numbers for commits."}, {"role": "assistant", "content": "TLDR; \n\nfrom 2005 up to 2018/Git 2.18: SHA-1 (see below) \n2019, will switch at some point to SHA-256\n\n\nYou can check that from Linus Torvalds himself, when he presented Git to Google back in 2007:\n(emphasis mine)\n\nWe check checksums that is considered cryptographically secure. Nobody has been able to break SHA-1, but the point is, SHA-1 as far as git is concerned, isn't even a security feature. It's purely a consistency check.\n The security parts are elsewhere. A lot of people assume since git uses SHA-1 and SHA-1 is used for cryptographically secure stuff, they think that it's a huge security feature. It has nothing at all to do with security, it's just the best hash you can get. \nHaving a good hash is good for being able to trust your data, it happens to have some other good features, too, it means when we hash objects, we know the hash is well distributed and we do not have to worry about certain distribution issues. \nInternally it means from the implementation standpoint, we can trust that the hash is so good that we can use hashing algorithms and know there are no bad cases. \nSo there are some reasons to like the cryptographic side too, but it's really about the ability to trust your data.\n I guarantee you, if you put your data in git, you can trust the fact that five years later, after it is converted from your harddisc to DVD to whatever new technology and you copied it along, five years later you can verify the data you get back out is the exact same data you put in. And that is something you really should look for in a source code management system. \n\n\nUpdate Dec. 2017 with Git 2.16 (Q1 2018): this effort to support an alternative SHA is underway: see \"Why doesn't Git use more modern SHA?\".\n\nI mentioned in \"How would git handle a SHA-1 collision on a blob?\" that you could engineer a commit with a particular SHA1 prefix (still an extremely costly endeavor).\nBut the point remains, as Eric Sink mentions in \"Git: Cryptographic Hashes\" (Version Control by Example (2011) book:\n\nIt is rather important that the DVCS never encounter two different pieces of data which have the same digest. Fortunately, good cryptographic hash functions are designed to make such collisions extremely unlikely.\n\nIt is harder to find good non-cryptographic hash with low collision rate, unless you consider research like \"Finding State-of-the-Art Non-cryptographic Hashes with Genetic Programming\".\nYou can also read \"Consider use of non-cryptographic hash algorithm for hashing speed-up\", which mentions for instance \"xxhash\", an extremely fast non-cryptographic Hash algorithm, working at speeds close to RAM limits.\n\nDiscussions around changing the hash in Git are not new:\n\neither to optimize it (August 2009), but you have to take license issue:\n\n(Linus Torvalds)\n\nThere's not really anything remaining of the mozilla code, but hey, I started from it. In retrospect I probably should have started from the PPC asm code that already did the blocking sanely - but that's a \"20/20 hindsight\" kind of thing.\nPlus hey, the mozilla code being a horrid pile of crud was why I was so convinced that I could improve on things. So that's a kind of source for it, even if it's more about the motivational side than any actual remaining code ;)\n\nAnd you need to be careful about how to measure the actual optimization gain\n(Linus Torvalds)\n\nI pretty much can guarantee you that it improves things only because it makes gcc generate crap code, which then hides some of the P4 issues.\n\n\nor to change it altogether (January 2010)\n(for instance to SHA-3, but that would apply to any other hash):\n\n(John Tapsell - johnflux)\n\nThe engineering cost for upgrading git from SHA-1 to a new algorithm is much higher. I'm not sure how it can be done well. \nFirst of all we probably need to deploy a version of git (let's call it version 2 for this conversation) which allows there to be a slot for a new hash value even though it doesn't read or use that space -- it just uses the SHA-1 hash value which is in the other slot. \nThat way once we eventually deploy yet a newer version of git, let's call it version 3, which produces SHA-3 hashes in addition to SHA-1 hashes, people using git version 2 will be able to continue to inter-operate.\n (Although, per this discussion, they may be vulnerable and people who rely on their SHA-1-only patches may be vulnerable.)\n\nIn short, switching to any hash is not easy.\n\nUpdate February 2017: yes, it is in theory possible to compute a colliding SHA1: shattered.io\n\nHow is GIT affected?\nGIT strongly relies on SHA-1 for the identification and integrity checking of all file objects and commits.\n It is essentially possible to create two GIT repositories with the same head commit hash and different contents, say a benign source code and a backdoored one.\n An attacker could potentially selectively serve either repository to targeted users. This will require attackers to compute their own collision. \n\nBut:\n\nThis attack required over 9,223,372,036,854,775,808 SHA1 computations. This took the equivalent processing power as 6,500 years of single-CPU computations and 110 years of single-GPU computations. \n\nSo let's not panic just yet.\nSee more at \"How would Git handle a SHA-1 collision on a blob?\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker --noglob-pathspecs"}, {"role": "assistant", "content": "Add \"literal\" magic to all pathspec. This is equivalent to setting\nthe GIT_NOGLOB_PATHSPECS environment variable to 1 . Enabling\nglobbing on individual pathspecs can be done using pathspec\nmagic \":(glob)\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --left-right"}, {"role": "assistant", "content": "Mark which side of a symmetric difference a commit is reachable from.\nCommits from the left side are prefixed with < and those from\nthe right with > . If combined with --boundary , those\ncommits are prefixed with - . For example, if you have this topology: y---b---b branch B\n\t / \\ /\n\t / .\n\t / / \\\n\t o---x---a---a branch A you would get an output like this: $ git rev-list --left-right --boundary --pretty=oneline A...B\n\n\t>bbbbbbb... 3rd on b\n\t>bbbbbbb... 2nd on b\n\t<aaaaaaa... 3rd on a\n\t<aaaaaaa... 2nd on a\n\t-yyyyyyy... 1st on b\n\t-xxxxxxx... 1st on a"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git ignore all files except one extension and folder structure\nWhat I want is to ignore all kind of files except the .php ones, but with this .gitignore I'm also ignoring folders...\n#ignore all kind of files\n*\n#except php files\n!*.php\n\nIs there a way to tell git to accept my project folder structure while keeping the track only of the .php files?\nIt seems like now I can't add folders to my repo:\nvivo@vivoPC:~/workspace/motor$ git add my_folder/\nThe following paths are ignored by one of your .gitignore files:\nmy_folder\nUse -f if you really want to add them.\nfatal: no files added"}, {"role": "assistant", "content": "This is simple, just add another entry !my_folder in your .gitignore\n#ignore all kind of files\n*\n#except php files\n!*.php\n!my_folder\n\nThe last line will take special care of my_folder, and will not ignore any php files within it; but files within other folders will still be ignored because of the first pattern of *.\nEDIT\nI think I misread your question. If you want to ignore all files except .php files, you can use\n#ignore all kind of files\n*.*\n#except php files\n!*.php\n\nThis will not ignore any file which doesn't have an extension (example: if you have README and not README.txt ), and will ignore any folder with a . in its name (example: directory named module.1).\nFWIW, git doesn't track directories, and hence there is no way to specify ignore rules for directory vs file"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "List all changed files with change status between Git commits (added, modified, deleted) [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow to list only the names of files that changed between two commits\n\n (15 answers)\n \n\nClosed 9 years ago.\n\n\n\nI regularly use the following command to list files changed between two commits:\ngit diff --name-only SHA1 SHA2\n\nIt gives a list of files somewhat like this:\n\n/src/example/file1\n/src/example/file2\n/src/example/file3\n\nThere is almost no end to how useful this is.\nI'd really like to be able also to show alongside each file a brief reference to the change status, indicating whether a file was added, modified or deleted.\nHere's an example to demonstrate the concept:\ngit diff --name-only --and-how-me-the-change-status SHA1 SHA2\n\n\nA /src/example/file1\nM /src/example/file2\nD /src/example/file3\n\nThe change status (A, M, D) is shown as an example only, I don't mind what this is so long as it is unambiguous.\nI'm aware that I can use the --diff-filter option to list only added files, or only modified files or only deleted files. Using this option means I have to run three commands to get three lists of filenames. This is nice but could be nicer.\nIs there a single command I can run to give me the above example output?"}, {"role": "assistant", "content": "Use --name-status, it's the same as --name-only plus the status of changed files:\ngit diff --name-status SHA1 SHA2"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git: checking out a file from a previous commit and amending it to HEAD\nI recently committed a file to the HEAD of my branch which has errors in it. I need to do the following things:\n\n Get that file from one commit previous to HEAD \n Commit that file back into HEAD \n\nWhat's the best way of going about that?"}, {"role": "assistant", "content": "You've practically said it yourself:\nFirst get the file back from one commit before:\n$> git checkout HEAD~1 path/to/file.ext\n\nThen commit it:\n$> git commit -a -m 'Retrieved file from older revision'\n\nIf only the changes to that file were present in the last commit, you can even use git revert:\n$> git revert HEAD\n\nI think it would be better to make this a separate commit, because it tells you exactly what you've reverted, and why. However, you can squash this into the previous commit by using the --amend switch to git commit."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Prevent pushing to master on GitHub?\n\nGitHub allows you to configure your repository so that users can't force push to master, but is there a way to prevent pushing to master entirely? I'm hoping to make it so that the only way of adding to commits to master is through the GitHub pull request UI."}, {"role": "assistant", "content": "Since the original question / answer, Github has added a new option for this to the restricted branches UI which allows you to set this up.\n\nRequire pull request reviews before merging When enabled, all commits must be made to a non-protected branch and submitted via a\npull request with the required number of approving reviews and no\nchanges requested before it can be merged into a branch that matches\nthis rule.\n\nTo find it go to Settings > Branches > Branch Protection Rules\nand click 'Add Rule'.\n\nThen, enter the name of the branch you want to protect and click the checkbox to require pull request reviews before merging.\n\nBy default, this only stops people who are not moderators. There is also another checkbox later down for ensuring that even moderators cannot merge."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "app-release-unsigned.apk is not signed\n\nI downloaded the zip file of an Android app on github and I'm trying to run it, but I get a dialog with this message\napp-release-unsigned.apk is not signed. Please configure the signing information for the selected flavor using the Project Structure dialog.\n\nI'm using Android Studio.\nWhat am I supposed to do?"}, {"role": "assistant", "content": "If anyone wants to debug release build using Android Studio, follow these steps:\n\nSet build variant to release mode.\n\n\n\nRight click on app in left navigation pane, click Open Module Settings. \nGo to Signing Tab. Add a signing config and fill in information. Select your keychain as well.\n\n\n\nGo to Build Type tab. Select release mode and set:\n\n-Debuggable to true.\n-Signing Config to the config. (The one you just created).\n\nSync your gradle. Enjoy!"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Which are the pros (and cons) of self-hosting your repositories (in other words: GitLab vs Bitbucket)? [closed]\n\nClosed. This question is opinion-based. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it can be answered with facts and citations by editing this post.\n\n\nClosed 8 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI have to decide between Bitbucket and GitLab for repository hosting (yes, they have to be private). I've used Bitbucket in the past, but now I've discovered GitLab and I find the idea of having a self-hosted repository manager quite attractive. But, I have to justify the use of one of them (especially in the case of using GitLab, because of the overhead that supposes its installation and configuration).\nWe have to take into account the following considerations:\n\nI'm not sure about the backup frequency of the server where GitLab\nwould be installed in (I think this would be a mayor difference between the two options, but I don't know if Bitbucket assures 100% the integrity of the repos they host).\nI can have access to the server from anywhere with VMWare Horizon Client, so Bitbucket and self-hosted GitLab would be tied in this point.\n\nSo, which are the reasons I should opt for self-hosted repo manager (GitLab), instead of non self-hosted one (Bitbucket)?"}, {"role": "assistant", "content": "I’ve used self-hosted repos in some occasions:\n\nGovernment work. They had strict security policies and a really big team. They also had remote access for some users.\nPharmacy lab, also strict security and big team but no need for remote access though. \nI also keep a home git server for a large range of projects from hardware (Raspberry Pi), to Dockerfiles for Pentests, and complimentary services. \n\nMy Pros: \n\nFlexibility for your git server code (custom integration and modules).\nFlexibility for your infrastructure.\nSecurity - depends on your organisation\nInternet connection independence\nSpeed - depends on your network of course but in my case (Gov work) working on site was much faster.\nData - containment and accessibility depends on you organisation\n\nMy Cons: \n\nIts usually a better fit for large teams because of the different tasks required to maintain it.\nSecurity - continuous monitoring just in case your neighbour gets curious…and lucky. \nMaintenance - to keep up to date with new functionality you’ll have to be upgrading periodically\n\nHosted:\nI also like the private repo functionality from both Bitbucket and Gitlab just take into consideration that Gitlab doesn’t cap user quantity. Also if you use CI Gitlab has it integrated. \nBest of luck"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git doesn't work on MacOS Catalina: \"xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing\" [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nGit is not working after macOS update (\"xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools\")\n\n (41 answers)\n \n\nClosed 4 years ago.\n\n\n\nAfter upgrading to MacOS X 10.15 Catalina, I cannot run any git commands in my shell:\n\nThe default interactive shell is now zsh.\nTo update your account to use zsh, please run chsh -s /bin/zsh.\nFor more details, please visit https://support.apple.com/kb/HT208050.\n~ | git\nxcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun\n\nI thought there's a problem with my shell, so I followed the instructions to change the default Mac OS shell back to bash, using the GUI and also using the command line:\nchsh -s /bin/bash\n\nI also restarted the computer. However, I still see the same message, even though echo \"$SHELL\" outputs /bin/bash."}, {"role": "assistant", "content": "You'll need to reinstall the command line tools:\n$ xcode-select --install"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Reset local repository branch to be just like remote repository HEAD\nHow do I reset my local branch to be just like the branch on the remote repository?\nI tried:\ngit reset --hard HEAD\n\nBut git status claims I have modified files:\nOn branch master\nChanges to be committed:\n (use \"git reset HEAD <file>...\" to unstage)\n modified: java/com/mycompany/TestContacts.java\n modified: java/com/mycompany/TestParser.java"}, {"role": "assistant", "content": "Setting your branch to exactly match the remote branch can be done in two steps:\ngit fetch origin\ngit reset --hard origin/master\n\nIf you want to save your current branch's state before doing this (just in case), you can do:\ngit commit -a -m \"Saving my work, just in case\"\ngit branch my-saved-work\n\nNow your work is saved on the branch \"my-saved-work\" in case you decide you want it back (or want to look at it later or diff it against your updated branch).\nNote that the first example assumes that the remote repo's name is \"origin\" and that the branch named \"master\" in the remote repo matches the currently checked-out branch in your local repo.\nBTW, this situation that you're in looks an awful lot like a common case where a push has been done into the currently checked out branch of a non-bare repository. Did you recently push into your local repo? If not, then no worries -- something else must have caused these files to unexpectedly end up modified. Otherwise, you should be aware that it's not recommended to push into a non-bare repository (and not into the currently checked-out branch, in particular)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Synchronizing a local Git repository with a remote one\nI want to synchronize my local repository with a remote one so that my local repository becomes a 100% copy of the remote one - meaning that if certain files differ in these repositories, we override the local ones with the remote ones, and if there are files in local repositories that do not exist in the remote, the local files get removed.\nIs there any way to achieve that other than by doing a fresh clone of remote repository? \nSimilar question as Sync local git repo with remote in one shot discarding local changes/commits."}, {"role": "assistant", "content": "[Edited answer] There is a few parts to consider:\nWhile not really operating a 'full sync' with the remote, the following will probably achieve what you need.\nNote: you may lose local changes.\nThe Branch references\nWhen fetching from a repository, the new (remote) references are synced up automatically but the old ones aren't cleaned out from the local. The purge option fixes that. [original answer]\ngit fetch --prune\n\n\n-p, --prune\nBefore fetching, remove any remote-tracking references that no longer exist on the remote. git fetch prune option doc on git-scm\n\nThe pull command also has the prune option (--prune or -p) see git-scm doc\ngit pull -p\n\nThe commits\nAll local branches could potentially be out of sync.\nTo sync up the current branch with the remote, and potentially lose local work, reset it to the remote position:\ngit reset --hard origin/<current_branch_name>\n\nAgain, caution: this would clear out the local changes (non-committed changes & non-pushed commits).\nNote: This would have left 'un-synced' any other branch.\nThe files/changes\nThe not staged for commit changes\nThese would have been removed by the above git reset --hard\nThe untracked files\nThese can be cleaned out using\ngit clean -f -d\n\nNote that you may lose some local work.\nThe ignored files\nSome files are declared to be ignored (via .gitignore files) and become hidden to the git tracking.\nTo clean them out, run:\ngit clean -f -d -x\n\nNote that the git clean command comes with a handy dry-run option to avoid making that mistake a little too fast:\ngit clean -f -d -x -n\n\n\n-n, --dry-run\nDon’t actually remove anything, just show what would be done.\n\n\nAs the top-rated answer, I felt compelled to revisit my not really answering former reply. Thanks to the comments and other answers which helped me form a better reply."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I stop a Git commit when VI is on the screen waiting for a commit message?\nI have asked Git to perform a commit from within git bash, It has brought up VI as it always does.\nI now wish to cancel the commit, how do I prevent proceeding with the commit from this point?"}, {"role": "assistant", "content": "You have two options:\n\nProvide an empty commit message. If it's a new commit and you haven't yet saved the message, you can simply use :q! (quit without saving). If you’ve already saved (or you're amending a previous commit), just delete the entire log message and save again. This can be done with ggdG + :wq in Vim.\nHave the editor exit with a non-zero exit code. In Vim, you can use :cq (quit with an error code).\n\nIt's worth noting that you can always reset your working copy to the state it was in before the commit with git reset HEAD^."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --cherry-mark"}, {"role": "assistant", "content": "Like --cherry-pick (see below) but mark equivalent commits\nwith = rather than omitting them, and inequivalent ones with + ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_TRACE_REFS"}, {"role": "assistant", "content": "Enables trace messages for operations on the ref database.\nSee GIT_TRACE for available trace output options."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What does it mean when git says a file \"needs update\"?\nI can't for the life of me find any decent explanation of the \"[file]: needs update\" message that git sometimes spits out from time to time. Even the official git FAQ has explaining this marked as a TODO. If someone could explain A) what it means; and B) how to fix it, I would be extremely grateful."}, {"role": "assistant", "content": "It means you're trying to merge changes from somewhere, but the changes include modifications to a file that's dirty (currently modified in your working tree). You need to commit your outstanding changes, or stash them, pull/rebase/merge/whatever you're doing to update, and unstash"}]} {"messages": [{"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 --date <format>"}, {"role": "assistant", "content": "Specifies the format used to output dates. If --date is not\nprovided, the value of the blame.date config variable is\nused. If the blame.date config variable is also not set, the\niso format is used. For supported values, see the discussion\nof the --date option at git-log ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-commit - Record changes to the repository --allow-empty-message"}, {"role": "assistant", "content": "Like --allow-empty this command is primarily for use by foreign\nSCM interface scripts. It allows you to create a commit with an\nempty commit message without using plumbing commands like git-commit-tree ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database"}, {"role": "assistant", "content": "DISCUSSION git-fsck tests SHA-1 and general object sanity, and it does full tracking\nof the resulting reachability and everything else. It prints out any\ncorruption it finds (missing or bad objects), and if you use the --unreachable flag it will also print out objects that exist but that\naren’t reachable from any of the specified head nodes (or the default\nset, as mentioned above). Any corrupt objects you will have to find in backups or other archives\n(i.e., you can just remove them and do an rsync with some other site in\nthe hopes that somebody else has the object you have corrupted). If core.commitGraph is true, the commit-graph file will also be inspected\nusing git commit-graph verify . See git-commit-graph ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-cherry-pick - Apply the changes introduced by some existing commits stop"}, {"role": "assistant", "content": "The cherry-pick will stop when the commit is applied, allowing\nyou to examine the commit. This is the default behavior."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to interactively (visually) resolve conflicts in SourceTree / git\nI'm using (Windows) SourceTree for my git project. I can do it in either command prompt or Linux terminal.\nBut, I'm wondering whether there is a nice way to interactively and visually resolve conflicts. For example, if pull detects conflicts, popping up a GUI-based conflict tool (e.g., P4Merge). Is it possible?\nI am always doing manual conflict resolving, which is just painful.\nThis is, for example, a git pull message, from SourceTree.\ngit -c diff.mnemonicprefix=false -c core.quotepath=false pull --no-commit origin master\nFrom W:\\repo\\\n * branch master -> FETCH_HEAD \n\nUpdating 33c07bf..41e0249\n\nerror: Your local changes to the following files would be overwritten by merge:\n foo.cpp\n goo.cpp\n goo.hpp\nPlease, commit your changes or stash them before you can merge.\nAborting \n\nCompleted with errors, see above."}, {"role": "assistant", "content": "From SourceTree, click on Tools->Options. Then on the \"General\" tab, make sure to check the box to allow SourceTree to modify your Git config files.\nThen switch to the \"Diff\" tab. On the lower half, use the drop down to select the external program you want to use to do the diffs and merging. I've installed KDiff3 and like it well enough. When you're done, click OK.\nNow when there is a merge, you can go under Actions->Resolve Conflicts->Launch External Merge Tool."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Fatal: could not read username for 'https //github.com' device not configured\nI am trying to push code to github with SublimeGit plugin, but something weird occurs to me.\n\nPushing to https://github.com/username/username.github.io.git\nfatal: could not read Username for 'https://github.com': Device not configured\n\nHave been taken a lot of search before asking, like fatal: could not read Username for 'https://github.com': No such file or directory, Fatal: could not read Username for 'https://github.com': No such device or address.\nBut problem still remains, any effort will be appreciated."}, {"role": "assistant", "content": "Mac OS:\nAndroid Studio Preferences -> Git -> at bottom, Use Credentials helper (make sure it is checked)\nWindows:\nAndroid Studio File -> Settings -> Git -> Check Credentials Helper at bottom"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --ignore-blank-lines"}, {"role": "assistant", "content": "Ignore changes whose lines are all blank."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to generate ssh keys (for github)\nQuestion: How do I generate ssh private and public keys (to be used in GitHub/GitLab) using command line.\nThe command below generates the error\nsh.exe\": syntax error near unexpected token '('\n\nI am using Windows XP.\n$ ssh-keygen -t rsa -C \"[email protected]\"\nGenerating public/private rsa key pair.\nEnter file in which to save the key (/c/Users/xxxx/.ssh/id_rsa):\nEnter passphrase (empty for no passphrase):\nEnter same passphrase again:\nYour identification has been saved in /c/Users/xxxx/.ssh/id_rsa.\nYour public key has been saved in /c/Users/xxxx/.ssh/id_rsa.pub.\nThe key fingerprint is:\n01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db [email protected]"}, {"role": "assistant", "content": "The command to run is only \nssh-keygen -t rsa -C \"[email protected]\"\n\nAll the rest beginning with line 2 of your script is the output of ssh-keygen.\nAnd replace [email protected] with your email address.\nHave a look at the manual for ssh-keygen to look for additional options. You should probably use a longer key by adding -b 4096 to the option list."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to ignore files which are in repository?\nI have a file (config.php), that is already committed to a Git repository, but I want to ignore locally, i.e. I want that file to remain in repository, but force Git to ignore any changes to it.\nI put the file into .gitignore, but it is still marked as changed and Git still is attempting to commit changes to it, every time I commit something.\nAny ideas, what am I missing or doing wrong?"}, {"role": "assistant", "content": "If the file is still displayed in the status, even though it is in the .gitignore, make sure it isn't already tracked.\ngit rm --cached config.php\n\nIf you just want to ignore it locally, you could also make it ignored by the git status:\ngit update-index --assume-unchanged config.php\n\nAs commented, do note that using --assume-unchanged might cause unwanted data loss as git stash resets the \"ignored\" files to the state in upstream, undoing local changes, without a warning or saving."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I get a side-by-side diff when I do \"git diff\"?\nWhen I type git diff, I'd like to see a side-by-side diff, like with diff -y, or like to display the diff in an interactive diff tool like kdiff3. How can this be done?"}, {"role": "assistant", "content": "Try git difftool\nUse git difftool instead of git diff. You'll never go back.\nUPDATE to add an example usage:\nHere is a link to another stackoverflow that talks about git difftool: How do I view 'git diff' output with my preferred diff tool/ viewer?\nFor newer versions of git, the difftool command supports many external diff tools out-of-the-box. For example vimdiff is auto supported and can be opened from the command line by:\ncd /path/to/git/repo\ngit difftool --tool=vimdiff\n\nOther supported external diff tools are listed via git difftool --tool-help here is an example output:\n'git difftool --tool=<tool>' may be set to one of the following:\n araxis\n kompare\n vimdiff\n vimdiff2\n\nThe following tools are valid, but not currently available:\n bc3\n codecompare\n deltawalker\n diffuse\n ecmerge\n emerge\n gvimdiff\n gvimdiff2\n kdiff3\n meld\n opendiff\n tkdiff\n xxdiff"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why can't I push to this bare repository?\nCan you explain what is wrong with this workflow?\n$ git init --bare bare\nInitialized empty Git repository in /work/fun/git_experiments/bare/\n$ git clone bare alice\nCloning into alice...\ndone.\nwarning: You appear to have cloned an empty repository.\n$ cd alice/\n$ touch a\n$ git add a\n$ git commit -m \"Added a\"\n[master (root-commit) 70d52d4] Added a\n 0 files changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 a\n$ git push\nNo refs in common and none specified; doing nothing.\nPerhaps you should specify a branch such as 'master'.\nfatal: The remote end hung up unexpectedly\nerror: failed to push some refs to '/work/fun/git_experiments/bare'\n\nDoesn't git push always push to the repository I cloned from?"}, {"role": "assistant", "content": "Yes, the problem is that there are no commits in \"bare\". This is a problem with the first commit only, if you create the repos in the order (bare,alice). Try doing:\ngit push --set-upstream origin master\n\nThis would only be required the first time. Afterwards it should work normally.\nAs Chris Johnsen pointed out, you would not have this problem if your push.default was customized. I like upstream/tracking."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Multiple GitHub accounts on the same computer?\n\nTrying to work on both my actual \"work\" repos, and my repos on GitHub, from my computer.\nThe work account was set up first, and everything works flawlessly.\nMy account, however, cannot seem to push to my repo, which is set up under a different account/email.\nI've tried copying my work key up to my account, but that throws an error because of course a key can only be attached to one account.\nHow can I push/pull to and from both accounts with their respective GitHub credentials?"}, {"role": "assistant", "content": "All you need to do is configure your SSH setup with multiple SSH keypairs.\n\nThis link is easy to follow (Thanks Eric):\nhttp://code.tutsplus.com/tutorials/quick-tip-how-to-work-with-github-and-multiple-accounts--net-22574\n\nGenerating SSH keys (Win/msysgit):\nhttps://help.github.com/articles/generating-an-ssh-key/\n\n\nRelevant steps from the first link:\n\nGenerate an SSH-key:\nssh-keygen -t ed25519 -C \"[email protected]\"\n\nFollow the prompts and decide a name, e.g. id_ed25519_example_company.\n\nCopy the SSH public-key to GitHub from ~/.ssh/id_ed25519_doe_company.pub and tell ssh about the key:\nssh-add ~/.ssh/id_ed25519_doe_company\n\n\nCreate a config file in ~/.ssh with the following contents:\nHost github-doe-company\n HostName github.com\n User git\n IdentityFile ~/.ssh/id_ed25519_doe_company\n\n\nAdd your remote:\ngit remote add origin git@github-doe-company:username/repo.git\n\nor change using:\ngit remote set-url origin git@github-doe-company:username/repo.git\n\n\n\n\nAlso, if you're working with multiple repositories using different personas, you need to make sure that your individual repositories have the user settings overridden accordingly:\nSetting user name, email and GitHub token – Overriding settings for individual repos\nhttps://help.github.com/articles/setting-your-commit-email-address-in-git/\nNote:\nSome of you may require different emails to be used for different repositories, from git 2.13 you can set the email on a directory basis by editing the global config file found at: ~/.gitconfig using conditionals like so:\n[user]\n name = Default Name\n email = [email protected]\n\n[includeIf \"gitdir:~/work/\"]\n path = ~/work/.gitconfig\n\nAnd then your work-specific config ~/work/.gitconfig would look like this:\n[user]\n name = Pavan Kataria\n email = [email protected]\n\nThank you @alexg for informing me of this in the comments."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitglossary - A Git Glossary commit graph concept, representations and usage"}, {"role": "assistant", "content": "A synonym for the DAG structure formed by the commits\nin the object database, referenced by branch tips,\nusing their chain of linked commits.\nThis structure is the definitive commit graph. The\ngraph can be represented in other ways, e.g. the \"commit-graph\" file ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git pull origin master does not update origin/master?\n\nAccording to the documentation, git pull performs a git fetch then a git merge, however in that case performing git pull origin master should perform a git fetch origin master right? However, it does not appear to be doing so. Here is an example.\nSupposed my remote origin master (on GitHub in my case) has the following history:\ncommit 1111111 : my first commit\ncommit 2222222 : a commit from someone else\n\nand I only have my first commit locally as doing following shows\ngit checkout master\ngit log --pretty=format:'%h' -n 1\n1111111\n\ngit checkout origin/master\ngit log --pretty=format:'%h' -n 1\n1111111\n\nFrom here I do my pull and look at the results as follows:\ngit checkout master\ngit pull origin master\n\ngit log --pretty=format:'%h' -n 1\n2222222\n\ngit checkout origin/master\ngit log --pretty=format:'%h' -n 1\n1111111\n\nAs can be seen, the pull did in fact update my master branch with the new commit(s) from the remote origin, but my local origin/master is still where it was. Forcing me to do the following\ngit fetch origin master\n\ngit checkout origin/master\ngit log --pretty=format:'%h' -n 1\n2222222\n\nIs this correct behavior for git pull or might I have something miss configured? I looked through the git pull man page and didn't see anything that suggested this but I may have missed it."}, {"role": "assistant", "content": "It's a bit weird, but if you use git pull [remote] <refspec> it actually doesn't update the remote refs. It sort of makes sense if you think about it a certain way: since you're specifying a specific ref to fetch, it doesn't have to look up anything about your remote branches, so it doesn't inherently know what remote branch it should update. It of course could figure it out, and I wouldn't be surprised if it gets fixed eventually, but that's the existing behavior. (There may be messages on the mailing list about it - I don't know.)\nYou can easily work around it, though. If you use git pull origin/master, since you're specifying what to fetch via a remote branch, it should update that remote branch. And if you're on your master branch anyway (or any other branch tracking origin/master), you can just do git pull and let it fill in the defaults, and it will update remote branches.\nThis is documented in the git-pull man page, most concisely under EXAMPLES but also elsewhere. The relevant part:\n\nMerge into the current branch the remote branch next:\n$ git pull origin next\n\nThis leaves a copy of next temporarily in FETCH_HEAD, but does not update any remote-tracking branches. Using remote-tracking branches, the same can be done by invoking fetch and merge:\n$ git fetch origin\n$ git merge origin/next"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.colorMovedWS"}, {"role": "assistant", "content": "When moved lines are colored using e.g. the diff.colorMoved setting,\nthis option controls the <mode> how spaces are treated.\nFor details of valid modes see --color-moved-ws in git-diff ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why doesn't my SSH key work for connecting to github?\n\nNote: I'm not a newb, and I've done this a gazillion times, but for some reason today it decided not to work.\nI keep getting the Permission denied (publickey). error message when trying to connect to github via SSH or when trying to clone a repo, even after remaking the ssh key and adding it to \"SSH Keys\" in my account.\nThis is what I tried to do ten times today without success:\n\nmake a key with ssh-keygen.\nopen ~/.ssh/id_rsa.pub with Gedit or Notepad++ and copy the contents.\nGo to account settings on github.com\nGo to SSH Keys\nClick on the Add Key button.\ngive the key a title\npaste the key into the key box.\nSave the key (enter my github password to verify).\n\nAnd now, when I try doing ssh github.com it just won't work.... What in the world? Am I just too tired right now or am I missing something?\nHere's the output from ssh -vvv github.com\nOpenSSH_5.9p1, OpenSSL 1.0.0f 4 Jan 2012\ndebug1: Reading configuration data /etc/ssh/ssh_config\ndebug2: ssh_connect: needpriv 0\ndebug1: Connecting to github.com [207.97.227.239] port 22.\ndebug1: Connection established.\ndebug3: Incorrect RSA1 identifier\ndebug3: Could not load \"/home/trusktr/.ssh/id_rsa\" as a RSA1 public key\ndebug1: identity file /home/trusktr/.ssh/id_rsa type 1\ndebug1: identity file /home/trusktr/.ssh/id_rsa-cert type -1\ndebug1: identity file /home/trusktr/.ssh/id_dsa type -1\ndebug1: identity file /home/trusktr/.ssh/id_dsa-cert type -1\ndebug1: identity file /home/trusktr/.ssh/id_ecdsa type -1\ndebug1: identity file /home/trusktr/.ssh/id_ecdsa-cert type -1\ndebug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5github2\ndebug1: match: OpenSSH_5.1p1 Debian-5github2 pat OpenSSH*\ndebug1: Enabling compatibility mode for protocol 2.0\ndebug1: Local version string SSH-2.0-OpenSSH_5.9\ndebug2: fd 3 setting O_NONBLOCK\ndebug3: load_hostkeys: loading entries for host \"github.com\" from file \"/home/trusktr/.ssh/known_hosts\"\ndebug3: load_hostkeys: found key type RSA in file /home/trusktr/.ssh/known_hosts:16\ndebug3: load_hostkeys: loaded 1 keys\ndebug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],ssh-rsa\ndebug1: SSH2_MSG_KEXINIT sent\ndebug1: SSH2_MSG_KEXINIT received\ndebug2: kex_parse_kexinit: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1\ndebug2: kex_parse_kexinit: [email protected],[email protected],ssh-rsa,[email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-dss\ndebug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]\ndebug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]\ndebug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96\ndebug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96\ndebug2: kex_parse_kexinit: none,[email protected],zlib\ndebug2: kex_parse_kexinit: none,[email protected],zlib\ndebug2: kex_parse_kexinit: \ndebug2: kex_parse_kexinit: \ndebug2: kex_parse_kexinit: first_kex_follows 0 \ndebug2: kex_parse_kexinit: reserved 0 \ndebug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1\ndebug2: kex_parse_kexinit: ssh-rsa,ssh-dss\ndebug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr\ndebug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr\ndebug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96\ndebug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96\ndebug2: kex_parse_kexinit: none,[email protected]\ndebug2: kex_parse_kexinit: none,[email protected]\ndebug2: kex_parse_kexinit: \ndebug2: kex_parse_kexinit: \ndebug2: kex_parse_kexinit: first_kex_follows 0 \ndebug2: kex_parse_kexinit: reserved 0 \ndebug2: mac_setup: found hmac-md5\ndebug1: kex: server->client aes128-ctr hmac-md5 none\ndebug2: mac_setup: found hmac-md5\ndebug1: kex: client->server aes128-ctr hmac-md5 none\ndebug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent\ndebug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP\ndebug2: dh_gen_key: priv key bits set: 122/256\ndebug2: bits set: 510/1024\nd ebug1: SSH2_MSG_KEX_DH_GEX_INIT sent\ndebug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY\ndebug1: Server host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48\ndebug3: load_hostkeys: loading entries for host \"github.com\" from file \"/home/trusktr/.ssh/known_hosts\"\ndebug3: load_hostkeys: found key type RSA in file /home/trusktr/.ssh/known_hosts:16\ndebug3: load_hostkeys: loaded 1 keys\ndebug3: load_hostkeys: loading entries for host \"207.97.227.239\" from file \"/home/trusktr/.ssh/known_hosts\"\ndebug3: load_hostkeys: found key type RSA in file /home/trusktr/.ssh/known_hosts:16\ndebug3: load_hostkeys: loaded 1 keys\ndebug1: Host 'github.com' is known and matches the RSA host key.\ndebug1: Found key in /home/trusktr/.ssh/known_hosts:16\ndebug2: bits set: 497/1024\ndebug1: ssh_rsa_verify: signature correct\ndebug2: kex_derive_keys\ndebug2: set_newkeys: mode 1\ndebug1: SSH2_MSG_NEWKEYS sent\ndebug1: expecting SSH2_MSG_NEWKEYS\ndebug2: set_newkeys: mode 0\ndebug1: SSH2_MSG_NEWKEYS received\ndebug1: Roaming not allowed by server\ndebug1: SSH2_MSG_SERVICE_REQUEST sent\ndebug2: service_accept: ssh-userauth\ndebug1: SSH2_MSG_SERVICE_ACCEPT received\ndebug2: key: /home/trusktr/.ssh/id_rsa (0x14cce60)\ndebug2: key: trusktr@rocketship (0x14ce2b0)\ndebug2: key: /home/trusktr/.ssh/id_dsa ((nil))\ndebug2: key: /home/trusktr/.ssh/id_ecdsa ((nil))\ndebug1: Authentications that can continue: publickey\ndebug3: start over, passed a different list publickey\ndebug3: preferred publickey,keyboard-interactive,password\ndebug3: authmethod_lookup publickey\ndebug3: remaining preferred: keyboard-interactive,password\ndebug3: authmethod_is_enabled publickey\ndebug1: Next authentication method: publickey\ndebug1: Offering RSA public key: /home/trusktr/.ssh/id_rsa\ndebug3: send_pubkey_test\ndebug2: we sent a publickey packet, wait for reply\ndebug1: Authentications that can continue: publickey\ndebug1: Offering RSA public key: trusktr@rocketship\ndebug3: send_pubkey_test\ndebug2: we sent a publickey packet, wait for reply\ndebug1: Authentications that can continue: publickey\ndebug1: Trying private key: /home/trusktr/.ssh/id_dsa\ndebug3: no such identity: /home/trusktr/.ssh/id_dsa\ndebug1: Trying private key: /home/trusktr/.ssh/id_ecdsa\ndebug3: no such identity: /home/trusktr/.ssh/id_ecdsa\ndebug2: we did not send a packet, disable method\ndebug1: No more authentication methods to try.\nPermission denied (publickey)."}, {"role": "assistant", "content": "The GitHub ssh setup mentions testing your GitHub connection with:\n$ ssh -T [email protected]\n\nThat follow the ssh uri syntax (also illustrated in \"this answer\").\nBut you did:\nssh github.com\n\n(without any user). In that case, ssh reverts to the SCP syntax, which relies on a ~/.ssh/config file, with a section \"github.com\", to list:\n\nthe user\nthe hostname\n(and optionally the public key location, but by default it will try ~/.ssh/id_rsa.pub)\n\nTo change it to a regular SSH URL, don't edit directly your .git/config file, as shown below.\nUse the command git remote set-url:\ngit remote set-url origin [email protected]:username/repo.git\n\n\nAs noted by STEEL in the comments, should your private SSH key have a passphrase, you can add it to the ssh-agent with:\n\non Mac: ssh-add -K or (2023) ssh-add --apple-use-keychain\non Linux/Windows: ssh-add"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I move a directory in a Git repo for all commits?\nLet's say I have a repo that includes this directory structure:\nrepo/\n blog/\n _posts/\n some-post.html\n another-file.txt\n\nI want to move _posts to the top level of the repo, so the structure will look like this:\nrepo/\n _posts/\n some-post.html\n another-file.txt\n\nThis is simple enough with git mv, but I want to make the history look as though _posts always existed at the root of the repo, and I want to be able to get the entire history of some-post.html via git log -- _posts/some-post.html. I imagine I can use some magic with git filter-branch to accomplish this, but I haven't figured out exactly how to do that. Any ideas?"}, {"role": "assistant", "content": "You can use the subdirectory filter to achieve this\n $ git filter-branch --subdirectory-filter blog/ -- --all\n\nEDIT 1: If you don't want to effectively make _posts the root, use a tree-filter instead:\n $ git filter-branch --tree-filter 'mv blog/_posts .' HEAD\n\nEDIT 2: If blog/_posts did not exist in some of the commits, the above will fail. Use this instead:\n $ git filter-branch --tree-filter 'test -d blog/_posts && mv blog/_posts . || echo \"Nothing to do\"' HEAD"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-for-each-ref - Output information on each ref"}, {"role": "assistant", "content": "EXAMPLES An example directly producing formatted text. Show the most recent\n3 tagged commits: #!/bin/sh\n\ngit for-each-ref --count=3 --sort='-*authordate' \\\n--format='From: %(*authorname) %(*authoremail)\nSubject: %(*subject)\nDate: %(*authordate)\nRef: %(*refname)\n\n%(*body)\n' 'refs/tags' A simple example showing the use of shell eval on the output,\ndemonstrating the use of --shell. List the prefixes of all heads: #!/bin/sh\n\ngit for-each-ref --shell --format=\"ref=%(refname)\" refs/heads | \\\nwhile read entry\ndo\n\teval \"$entry\"\n\techo `dirname $ref`\ndone A bit more elaborate report on tags, demonstrating that the format\nmay be an entire script: #!/bin/sh\n\nfmt='\n\tr=%(refname)\n\tt=%(*objecttype)\n\tT=${r#refs/tags/}\n\n\to=%(*objectname)\n\tn=%(*authorname)\n\te=%(*authoremail)\n\ts=%(*subject)\n\td=%(*authordate)\n\tb=%(*body)\n\n\tkind=Tag\n\tif test \"z$t\" = z\n\tthen\n\t\t# could be a lightweight tag\n\t\tt=%(objecttype)\n\t\tkind=\"Lightweight tag\"\n\t\to=%(objectname)\n\t\tn=%(authorname)\n\t\te=%(authoremail)\n\t\ts=%(subject)\n\t\td=%(authordate)\n\t\tb=%(body)\n\tfi\n\techo \"$kind $T points at a $t object $o\"\n\tif test \"z$t\" = zcommit\n\tthen\n\t\techo \"The commit was authored by $n $e\nat $d, and titled\n\n $s\n\nIts message reads as:\n\"\n\t\techo \"$b\" | sed -e \"s/^/ /\"\n\t\techo\n\tfi\n'\n\neval=`git for-each-ref --shell --format=\"$fmt\" \\\n\t--sort='*objecttype' \\\n\t--sort=-taggerdate \\\n\trefs/tags`\neval \"$eval\" An example to show the usage of %(if)…​%(then)…​%(else)…​%(end).\nThis prefixes the current branch with a star. git for-each-ref --format=\"%(if)%(HEAD)%(then)* %(else) %(end)%(refname:short)\" refs/heads/ An example to show the usage of %(if)…​%(then)…​%(end).\nThis prints the authorname, if present. git for-each-ref --format=\"%(refname)%(if)%(authorname)%(then) Authored by: %(authorname)%(end)\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "View a file in a different Git branch without changing branches\nIs it possible to open a file in a git branch without checking out that branch? How?\nEssentially I want to be able to open a file in my github pages branch without switching branches all the time. I don't want to modify it, just want to view it."}, {"role": "assistant", "content": "This should work:\ngit show branch:file\n\nWhere branch can be any ref (branch, tag, HEAD, ...) and file is the full path of the file. To export it you could use\ngit show branch:file > exported_file\n\nYou should also look at VonC's answers to some related questions:\n\nHow to retrieve a single file from specific revision in Git?\nHow to get just one file from another branch\n\nUPDATE 2015-01-19:\nNowadays you can use relative paths with git show a1b35:./file.txt."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs -t"}, {"role": "assistant", "content": "Show the tree objects in the diff output."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Change SSH host for cloning\n\nIs there any way to change default ssh host for gitlab (displayed at top of repository view in web interface)? I mean only for SSH in clone urls.\nFor example I have my gitlab installation on git.example.com, but example.com also points to the same machine (different site). Can I change ssh clone urls from:\ngit clone [email protected]:user/repository\n\nto:\ngit clone [email protected]:user/repositiory\n\nbut for http and https leave it with git.example.com?"}, {"role": "assistant", "content": "Yes,\nIf you are using the omnibus package you can edit /etc/gitlab/gitlab.rb and add gitlab_rails['gitlab_ssh_host'] = 'example.host.com'\nThere is the equivalent option somewhere in gitlab.yml : ssh_host: example.host.com"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Error with gradlew: /usr/bin/env: bash: No such file or directory\nAfter committing my project's gradlew file from my Windows machine to the remote repo using Git, invoking gradlew on my Linux server failed with this message:\n\n/usr/bin/env: bash: No such file or directory\n\nWhat happened?"}, {"role": "assistant", "content": "The problem's cause was that Git on Windows converted the line endings of gradlew from Unix style (LF) to Windows style (CRLF).\nYou can turn off that automatic conversion using git config core.autocrlf false.\nSetting the line endings of gradlew back to Unix style fixed the problem. In Vim this is done using :set fileformat=unix."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitHub \"fatal: remote origin already exists\"\nI am trying to follow along Michael Hartl's Rails tutorial but I've run across an error.\nI signed up at GitHub, issued a new SSH key, and created a new repository. But when I enter the next line into the terminal, I get the following error:\nParkers-MacBook-Pro:.ssh ppreyer$ git remote add origin [email protected]:ppreyer/first_app.git\nfatal: remote origin already exists.\n\nJust wondered if anybody else has run across this problem?"}, {"role": "assistant", "content": "Short version:\nYou should just update the existing remote:\ngit remote set-url origin [email protected]:ppreyer/first_app.git\n\nLong version:\nAs the error message indicates, there is already a remote configured with the same name. So you can either add the new remote with a different name or update the existing one if you don't need it.\nTo add a new remote, called for example github instead of origin (which obviously already exists in your system), do the following:\ngit remote add github [email protected]:ppreyer/first_app.git\n\nRemember though, everywhere in the tutorial you see \"origin\" you should replace it with \"github\". For example $ git push origin master should now be $ git push github master.\nHowever, if you want to see what that already existing origin remote is, you can do a $ git remote -v. If you think this is there by some error, you can update it like so:\ngit remote set-url origin [email protected]:ppreyer/first_app.git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options receive.fsck.skipList"}, {"role": "assistant", "content": "Acts like fsck.skipList , but is used by git-receive-pack instead of git-fsck . See the fsck.skipList documentation for\ndetails."}]} {"messages": [{"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 ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Import an existing git project into GitLab?\n\nI have an account of a Gitlab installation where I created the repository \"ffki-startseite\"\nNow I want to clone the repository git://freifunk.in-kiel.de/ffki-startseite.git into that repository with all commits and branches, so I can start working on it in my own scope.\nHow can I import it?"}, {"role": "assistant", "content": "I was able to fully export my project along with all commits, branches and tags to gitlab via following commands run locally on my computer:\n\nTo illustrate my example, I will be using https://github.com/raveren/kint as the source repository that I want to import into gitlab. I created an empty project named Kint (under namespace raveren) in gitlab beforehand and it told me the http git url of the newly created project there is http://gitlab.example.com/raveren/kint.git\nThe commands are OS agnostic.\n\nIn a new directory:\ngit clone --mirror https://github.com/raveren/kint\ncd kint.git\ngit remote add gitlab http://gitlab.example.com/raveren/kint.git\ngit push gitlab --mirror\n\nNow if you have a locally cloned repository that you want to keep using with the new remote, just run the following commands* there:\ngit remote remove origin\ngit remote add origin http://gitlab.example.com/raveren/kint.git\ngit fetch --all\n\n*This assumes that you did not rename your remote master from origin, otherwise, change the first two lines to reflect it."}]} {"messages": [{"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 -w"}, {"role": "assistant", "content": "Ignore whitespace when comparing the parent’s version and\nthe child’s to find where the lines came from."}]} {"messages": [{"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"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Move .git repo to parent directory [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\n\nMy Git repository is in the wrong root directory. Can I move it? (../ instead of ./)\n\n (10 answers)\n \n\nClosed 7 years ago.\n\n\n\nI have a subdirectory named \"www\" that is a repo:\nsite\n|-- www/\n| |-- .git/\n| |-- index.html\n|-- design/\n| |-- images.jpg\n\nI'd like to change the repo to the parent directory so that the repo structure mirrors the original file structure as follows:\nsite\n|-- .git/\n|-- www/\n| |-- index.html\n|-- design/\n| |-- images.jpg\n\nCan this be done? Are there implications with then pushing the changes up to Gitlab?"}, {"role": "assistant", "content": "Create a www directory in your repo.\ngit mv the HTML files to that directory. Optionally commit this step.\nmv the design directory into your repo, and git add .\nCommit.\nRename/move your whole repo."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "AWS Cloudfront error? invalidation max times while deploying?\n\nI got the error while I'm deploying something from gitlab.\n$ aws cloudfront create-invalidation --distribution-id=EVB1B2B3B4B56 --paths \"/*\"\n**An error occurred (ServiceUnavailable) when calling the CreateInvalidation operation (reached max retries: 2): CloudFront encountered an internal error. Please try again.**\n\nI sort it out by creating invalidation manually from AWS console and it works . This is the case happens sometimes causes this error, at that time I'm doing manually . What was the permanent solution ? Please help me to sort it out this."}, {"role": "assistant", "content": "I experienced a similar issue when creating multiple invalidations while deploying the same application to many distributions. The error still happens randomly, sometimes just retrying the deployment later works fine, and others fail on a different distribution.\nI found a related issue showing the same error in the github aws-cdk repo, there seems to be an error with the AWS Cloudfront API during peak hours.\n\nFrom the CloudFront team:\nCreateInvalidation API suffers from high fault rate during the daily\ntraffic peaks. It will return faults upto 50% of the requests. It is\nprimarily due to the limited capacity of the API.\nWe have evidence that some requests failed even after six retries ,\nduring the peak. We are working on improving this , but there is no\nquick fix for this and we are expecting it will get better by the end\nof Q1 2022.\n\nI still didn´t find a \"clean\" solution to this, what I have done is handle the error within my CLI script and automatically retry until it eventually succeeds."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database hasDotgit"}, {"role": "assistant", "content": "(WARN) A tree contains an entry named .git ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git interoperability with a Mercurial Repository\nI use GIT on a Mac. Enough said. I have the tools, I have the experience. And I want to continue to use it. No wars here...\nThe problem is always with interoperability. Most people use SVN, which is great for me. Git SVN works out of the box, and is a no frills solution. People can continue happily use SVN and I don't lose my workflow and neither my tools.\nNow... Some guys come along with Mercurial. Fine for them: they have their reasons. But I can't find any GIT HG out-of-the-box. I don't want to switch to HG, but I still need to interoperate with their repository.\nAny of you guys know a simple solution for this?"}, {"role": "assistant", "content": "There's a new git-remote-hg tool that provides native support:\nBridge support in Git for Mercurial and Bazaar.\nJust copy git-remote-hg to your $PATH, make it executable, and that's it, no dependencies (other than Mercurial):\ngit clone hg::https://www.mercurial-scm.org/repo/hg/\n\nYou should be able to push and pull from it as if it was a native Git repository.\nWhen you push new Git branches, Mercurial bookmarks will be created for them.\nSee the git-remote-hg wiki for more information."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Issue pushing new code in Github\nI created a new repository on Github which has only Readme.md file now.\nI have a newly created RoR project which I wanted to push to this repository.\nFollowing are the commands I gave in my Terminal to execute this along with the error I am getting.\ngit remote add origin https://github.com/aniruddhabarapatre/learn-rails.git\n\nAfter which I entered my username and password\ngit push -u origin master\n\nError ---\nTo https://github.com/aniruddhabarapatre/learn-rails.git\n ! [rejected] master -> master (fetch first)\nerror: failed to push some refs to 'https://github.com/aniruddhabarapatre/learn-rails.git'\nhint: Updates were rejected because the remote contains work that you do\nhint: not have locally. This is usually caused by another repository pushing\nhint: to the same ref. You may want to first merge the remote changes (e.g.,\nhint: 'git pull') before pushing again.\nhint: See the 'Note about fast-forwards' in 'git push --help' for details.\n\nThis is my first time pushing my code to a Github repository and I'm lost with the errors. I searched few other questions that are asked here, but none of them had issues first time."}, {"role": "assistant", "content": "If this is your first push, then you might not care about the history on the remote. You could then do a \"force push\" to skip checks that git does to prevent you from overwriting any existing, or differing, work on remote. Use with extreme care!\njust change the\ngit push **-u** origin master\n\nchange it like this!\ngit push -f origin master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitHub fork a repo from previous commit\n\nI've found a repository on GitHub I would like to fork - but not the current version.\nI want to fork the repo as it was quite a few commits back - is this possible? The repo has not marked any releases, so I'm not sure how to do this. I could obviously copy the code as it was in that commit, but I would prefer to fork, as then I get the link back to the original repo."}, {"role": "assistant", "content": "You can only fork the current repository.\nYou can reset the forked repository's master branch to an earlier commit though, making it look like as if you had forked it at that point.\nSee: How can I rollback a github repository to a specific commit?\nIf you reset every branch, it effectively resets your repository to an earlier state of the original repository (with exception of branch-independent data, like configuration, hooks etc which are not reset). Since it's possible that not all branches contain the commit from the master branch, you might need to look up commits by date for each branch, to reset them to the last commit before the commit from which you want to fork."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git status - list last modified date\nUsing git, is it possible to list an unstaged file's last modified date alongside it's path? using eg. \ngit status\nor\ngit diff --name-only"}, {"role": "assistant", "content": "Not directly but you can use a pipe:\n\nNote: original answer updated based on comments\n\nLinux:\ngit status -s | while read mode file; do echo $mode $file $(stat -c %y $file); done\n\nWindows:\ngit status -s | while read mode file; do echo $mode $(date --reference=$file +\"%Y-%m-%d %H:%M:%S\") $file; done\n\nOSX (source):\ngit status -s | while read mode file; do echo $mode $(stat -f \"%Sm\" $file) $file; done|sort"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Who is \"us\" and who is \"them\" according to Git?\nAfter a Git rebase, and in other circumstances, you can find some files marked as deleted by us in the git status report. Who is us according to Git and why?\nIs it referring to me sitting on this branch and it working for me? Or is it referring to itself and the folks working on the branch I am rebasing against?"}, {"role": "assistant", "content": "When you merge, us refers to the branch you're merging into, as opposed to them, the branch to be merged.\nWhen you rebase, us refers the upstream branch, and them is the branch you're moving about. It's a bit counter-intuitive in case of a rebase.\nThe reason is that Git uses the same merge-engine for rebase, and it's actually cherry-picking your stuff into the upstream branch. us = into, them = from."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --dirstat-by-file[=<param1,param2>…​]"}, {"role": "assistant", "content": "Synonym for --dirstat=files,<param1>,<param2>…​"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I undo the most recent local commits in Git?\nI accidentally committed the wrong files to Git, but didn't push the commit to the server yet.\nHow do I undo those commits from the local repository?"}, {"role": "assistant", "content": "Undo a commit & redo\n$ git commit -m \"Something terribly misguided\" # (0: Your Accident)\n$ git reset HEAD~ # (1)\n[ edit files as necessary ] # (2)\n$ git add . # (3)\n$ git commit -c ORIG_HEAD # (4)\n\n\ngit reset is the command responsible for the undo. It will undo your last commit while leaving your working tree (the state of your files on disk) untouched. You'll need to add them again before you can commit them again.\nMake corrections to working tree files.\ngit add anything that you want to include in your new commit.\nCommit the changes, reusing the old commit message. reset copied the old head to .git/ORIG_HEAD; commit with -c ORIG_HEAD will open an editor, which initially contains the log message from the old commit and allows you to edit it. If you do not need to edit the message, you could use the -C option.\n\nAlternatively, to edit the previous commit (or just its commit message), commit --amend will add changes within the current index to the previous commit.\nTo remove (not revert) a commit that has been pushed to the server, rewriting history with git push origin main --force[-with-lease] is necessary. It's almost always a bad idea to use --force; prefer --force-with-lease instead, and as noted in the git manual:\n\nYou should understand the implications of rewriting history if you amend a commit that has already been published.\n\n\nFurther Reading\nYou can use git reflog to determine the SHA-1 for the commit to which you wish to revert. Once you have this value, use the sequence of commands as explained above.\n\nHEAD~ is the same as HEAD~1. The article What is the HEAD in git? is helpful if you want to uncommit multiple commits."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects -a --text"}, {"role": "assistant", "content": "Treat all files as text."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to move the current working branch to master branch in git\nI have currently one of the project it contain more branches. master branch not yet merger long time. So i want switched to master with latest code.\nCan you please give me necessary commands and steps.\nLet me re-frame my question. \nI am working in a project with different branches. The latest changes were in some branch other than master. Now my requirement is: is there a way to move the current working branch to master without merging it with master, to avoid conflicts?"}, {"role": "assistant", "content": "If you want to have in master exactly the same files state as in other_branch and save history - do the following (and note the period at the end):\ngit checkout master\ngit checkout other_branch .\n\nNow you will have a full copy of other_branch in current master (it is softer than reset), not yet committed. Then make a regular commit:\ngit add --all\ngit commit -m \"* copy other_branch to master working tree\"\n\nNote: untracked (unindexed) files (directories) from other_branch will remain, if they are not tracked by master. To remove those untracked files (directories):\ngit clean -fd\n\nSee How to remove local (untracked) files from the current Git working tree? for more details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fetch - Download objects and refs from another repository reason"}, {"role": "assistant", "content": "A human-readable explanation. In the case of successfully fetched\nrefs, no explanation is needed. For a failed ref, the reason for\nfailure is described."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitLab CI: Export variable in before_script build job\n\nI try to implement a conditional versioning depending on if the CI script runs for a tagged branch or not.\nHowever the version var is not resolved. Instead it is printed as a string.\nThe relevant jobs of the GitLab CI script:\n# build template\n.build_base_template: &build_base_template\n image: registry.gitlab.com/xxxxxxx/npm:latest\n tags:\n - docker\n stage: LintBuildTest\n script:\n - export CUR_VERSION='$(cat ./version.txt)$BUILD_VERSION_SUFFIX'\n - npm ci\n - npm run build\n artifacts:\n expire_in: 1 week\n paths:\n - dist/\n\n# default build job\nbuild:\n before_script:\n - export BUILD_VERSION_SUFFIX='-$CI_COMMIT_REF_SLUG-SNAPSHOT-$CI_COMMIT_SHORT_SHA'\n <<: *build_base_template\n except:\n refs:\n - tags\n only:\n variables:\n - $FEATURE_NAME == null\n\n# specific build job for tagged versions\nbuild_tag:\n before_script:\n - export BUILD_VERSION_SUFFIX=''\n <<: *build_base_template\n only:\n refs:\n - tags"}, {"role": "assistant", "content": "Variables which are exported within before_script are visible within script.\nbefore:\n before_script:\n - export HELLOWELT=\"hi martin\"\n script:\n - echo $HELLOWELT # prints \"hi martin\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Github: How to embed a gist into README.md?\n\nIs it possible to embed gists into README.md file that resides in a GitHub repository?\nSomething like:\n<code id=\"gist-3167145\"></code>"}, {"role": "assistant", "content": "Update : My answer works with github pages, built via jekyll. I use the script tags in markdown which is then processed by jekyll.\nSince markdown supports html, one can simply use the <script> tag to embed gist.\nSimply copy the embed url of the gist provided by github\n\n..and paste it in you markdown file.\nExample : Copy the below and paste in your markdown file.\n<script src=\"https://gist.github.com/nisrulz/11c0d63428b108f10c83.js\"></script>\n..and this is what you will get"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker gitprotocol-pack"}, {"role": "assistant", "content": "How packs are transferred over-the-wire"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options diff.indentHeuristic"}, {"role": "assistant", "content": "Set this option to false to disable the default heuristics\nthat shift diff hunk boundaries to make patches easier to read."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "List Git commits not pushed to the origin yet [duplicate]\nThis question already has answers here:\n \n \n\n\n\nClosed 11 years ago.\n\n\n\n\nPossible Duplicate:\nViewing Unpushed Git Commits \n\nHow do I list all commits which have not been pushed to the origin yet?\nAlternatively, how to determine if a commit with particular hash have been pushed to the origin already?"}, {"role": "assistant", "content": "git log origin/master..master\nor, more generally:\ngit log <since>..<until>\nYou can use this with grep to check for a specific, known commit:\ngit log <since>..<until> | grep <commit-hash>\nOr you can also use git-rev-list to search for a specific commit:\ngit rev-list origin/master | grep <commit-hash>"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to rename a directory/folder on GitHub website?\nI was able to find a way on GitHub Website to rename a single file and did so with success.\nI was also able to find a way to rename a whole repository and did that with success.\nDoes anyone know how to do this to a single directory without using command line? For reference, I am trying to change a directory named InterviewTesting (that contains source files, etc) to something else. I tried doing it the single file way. But this didn't allow me to change the name of the directory (InterviewTesting), only the actual file name."}, {"role": "assistant", "content": "Actually, there is a way to rename a folder using web interface.\n\nSee https://github.com/blog/1436-moving-and-renaming-files-on-github"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options core.packedGitWindowSize"}, {"role": "assistant", "content": "Number of bytes of a pack file to map into memory in a\nsingle mapping operation. Larger window sizes may allow\nyour system to process a smaller number of large pack files\nmore quickly. Smaller window sizes will negatively affect\nperformance due to increased calls to the operating system’s\nmemory manager, but may improve performance when accessing\na large number of large pack files. Default is 1 MiB if NO_MMAP was set at compile time, otherwise 32\nMiB on 32 bit platforms and 1 GiB on 64 bit platforms. This should\nbe reasonable for all users/operating systems. You probably do\nnot need to adjust this value. Common unit suffixes of k , m , or g are supported."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Warning: Multiple merge bases detected. The list of commits displayed might be incomplete\nIn Azure Repos, I have created a PR from branch A to branch B. There aren't any merge conflict displayed. But I end up with the warning message\n\nWarning: Multiple merge bases detected. The list of commits displayed might be incomplete.\n\n\nWhat does this mean?"}, {"role": "assistant", "content": "I got the same message today. I just pulled the latest changes from the destination branch and merged them in the source branch and the issue was resolved."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is it better to keep Git repository inside or outside of Eclipse workspace?\nI am a typical Eclipse/Subversion user beginning the migration to Git. I've researched the basic concepts of git and have decided to stick to a one project per repository approach initially to keep things simple. I am still having trouble, though, deciding where to place the repository for each project.\nI have spent a lot of time reviewing the answers to this question, although I believe the author of that question was assuming that you can only use Eclipse to manage the repository if the repository is located within the Eclipse workspace, which is, of course, not true.\nThe thing that struck me most about that question, though, was the fact that all but one answer (including the accepted answer) suggested keeping the repository inside the Eclipse workspace, whereas only one answer pointed out that the EGit User Guide recommends the exact opposite.\nIt would appear in practice, however, that there are a number of approaches implemented by Eclipse/EGit, some of which seem to contradict the EGit recommendations.\nFor example, if you use the New Project Wizard to create a New PHP Project from Git and the repository is remote, Eclipse/EGit will happily create a project folder in the Eclipse workspace and put the repository (.git) in the project folder. This is the end result that I actually want, as it keeps everything encapsulated within the Eclipse workspace.\nHowever, if you use the New Project Wizard and select a Git repository that is local, Eclipse/EGit doesn't clone the repository like it does for remote repositories. Instead it uses the working copy of that repository as the project location, creates its .project and other meta stuff in that location and also creates a new (seemingly unnecessary) folder within that working copy with the same name as your project (so you end up with, for example, ~/git/blah/blah). If you delete that superfluous folder you end up with a structure that is identical to the first example, the only difference being that the project folder is not a sub-folder of your Eclipse workspace folder, it is somewhere else on your file system (eg. ~/git/blah). The only positive thing this approach seems to have going for it is that it adheres to the recommendations in the EGit User Guide, but from a technical perspective, its hard to see how this is really all that different to the first example.\nGiven these puzzling observations, I'm wondering what sort of experiences people have had using each of these approaches and what the pitfalls might be if one ignores the recommendations in the EGit User Guide."}, {"role": "assistant", "content": "The implications of both solutions are listed directly in the user guide that you linked. I can tell you that the part\n\nThis can result in performance issues\n\nis unfortunately very true. So if you have a git directory with a huge number of files inside your workspace, many git operations will start with a \"counting objects...\" dialog that blocks your IDE because it scans all files in the workspace. For my current 20000 files this means waiting 10 to 20 seconds for every commit, every switch, ...\nIn spare time activities, where I can fortunately use the other alternative (having the git working directory outside the workspace) everything feels much snappier and it is fun to merge and switch.\nSo if you go for large projects, consider the git directory outside the workspace as first choice."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %ai"}, {"role": "assistant", "content": "author date, ISO 8601-like format"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc Munging the diff output"}, {"role": "assistant", "content": "$ git diff --find-copies-harder -B -C (1) $ git diff -R (2) Spend extra cycles to find renames, copies and complete\nrewrites (very expensive). Output diff in reverse."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs files"}, {"role": "assistant", "content": "Compute the dirstat numbers by counting the number of files changed.\nEach changed file counts equally in the dirstat analysis. This is\nthe computationally cheapest --dirstat behavior, since it does\nnot have to look at the file contents at all."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --no-indent-heuristic"}, {"role": "assistant", "content": "Disable the indent heuristic."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitworkflows - An overview of recommended workflows with Git"}, {"role": "assistant", "content": "NAME gitworkflows - An overview of recommended workflows with Git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to cherry-pick only changes to certain files?\nIf I want to merge into a Git branch the changes made only to some of the files changed in a particular commit which includes changes to multiple files, how can this be achieved?\nSuppose the Git commit called stuff has changes to files A, B, C, and D but I want to merge only stuff's changes to files A and B. It sounds like a job for git cherry-pick but cherry-pick only knows how to merge entire commits, not a subset of the files."}, {"role": "assistant", "content": "I'd do it with cherry-pick -n (--no-commit) which lets you inspect (and modify) the result before committing:\ngit cherry-pick -n <commit>\n\n# unstage modifications you don't want to keep, and remove the\n# modifications from the work tree as well.\n# this does work recursively!\ngit checkout HEAD <path>\n\n# commit; the message will have been stored for you by cherry-pick\ngit commit\n\nIf the vast majority of modifications are things you don't want, instead of checking out individual paths (the middle step), you could reset everything back, then add in what you want:\n# unstage everything\ngit reset HEAD\n\n# stage the modifications you do want\ngit add <path>\n\n# make the work tree match the index\n# (do this from the top level of the repo)\ngit checkout ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc files"}, {"role": "assistant", "content": "Compute the dirstat numbers by counting the number of files changed.\nEach changed file counts equally in the dirstat analysis. This is\nthe computationally cheapest --dirstat behavior, since it does\nnot have to look at the file contents at all."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-write-tree - Create a tree object from the current index --missing-ok"}, {"role": "assistant", "content": "Normally git write-tree ensures that the objects referenced by the\ndirectory exist in the object database. This option disables this\ncheck."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Excluding files from git-diff\nI am tracking a project with git. There are some Xcode project files in the working copy that I want to keep tracking, but do not want to see in diffs, because there are always dozens of changed lines that I am never interested in. Is there a simple way to have git-diff skip these files? I’ve tried to set up a custom “silent” diff tool:\n\n$ cat .gitattributes \nProject.xcodeproj/* diff=nodiff\n\n$ cat ~/.gitconfig \n[diff \"nodiff\"]\n command = /bin/true\n\nBut:\n\n$ git diff\nexternal diff died, stopping at Project.xcodeproj/zoul.mode1v3.\n\nWhat am I doing wrong?"}, {"role": "assistant", "content": "The problem is that /bin/true will return immediately without reading its input. git diff therefore thinks, quite reasonably, that it has died prematurely.\nYou really want to unset the diff attribute, not set it to a bogus command. Try this in your .gitattributes:\nProject.xcodeproj/* -diff"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git reset --hard and push to remote repository\nI had a repository that had some bad commits on it (D, E and F for this example).\n\nA-B-C-D-E-F master and origin/master\n\nI've modified the local repository specifically with a git reset --hard. I took a branch before the reset so now I have a repo that looks like:\nA-B-C master \n \\ D-E-F old_master\n\nA-B-C-D-E-F origin/master\n\nNow I needed some parts of those bad commits so I cherry picked the bits I needed and made some new commits so now I have the following locally:\nA-B-C-G-H master\n \\ D-E-F old_master\n\nNow I want to push this state of affairs to the remote repo. However, when I try to do a git push Git politely gives me the brush off:\n$ git push origin +master:master --force \nTotal 0 (delta 0), reused 0 (delta 0) \nerror: denying non-fast forward refs/heads/master (you should pull first) \nTo [email protected]:myrepo.git \n! [remote rejected] master -> master (non-fast forward) \nerror: failed to push some refs to '[email protected]:myrepo.git' \n\nHow do I get the remote repo to take the current state of the local repo?"}, {"role": "assistant", "content": "If forcing a push doesn't help (git push --force origin or git push --force origin master should be enough), it might mean that the remote server is refusing non fast-forward pushes, via either receive.denyNonFastForwards config variable (see git config manpage for description), or via an update/pre-receive hook.\nWith older Git you can work around that restriction by deleting git push origin :master (note the : before branch name) and then re-creating git push origin master given branch.\nIf you can't change this, then the only solution would be instead of rewriting history to create a commit reverting changes in D-E-F:\nA-B-C-D-E-F-[(D-E-F)^-1] master\n\nA-B-C-D-E-F origin/master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I check out a particular version of one file in Git?\nHow can I check out a particular version of one file in git?\nI found this mail on the mailing list, which said:\n$ git checkout HEAD~43 Makefile\n$ git reset Makefile\n\nBut I don't understand how to find out 'HEAD~43', if I do a git log aFile, how can I find out which 'HEAD~43' I should use?\nAnd why do I need to run git reset for that file? What does it do?"}, {"role": "assistant", "content": "You know what commit (ie: the specific revision) the file belongs to? Then do:\ngit checkout <commit> <file>\n\nThe other command:\ngit checkout HEAD~N <file>\n\nIs for when you want to get a version of the file from a range back (which I do for nostalgia)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Which files in .idea folder should be tracked by Git?\nUnlike Netbeans, in Jetbrains IDEs, the setting files related to user and team are mixed in the same folder that makes it tricky when you need to push them to git.\nThere is a number of sample git ignore files for these IDEs and https://intellij-support.jetbrains.com/hc/articles/206544839 page on git site.\nHowever, after using them for a months we figure out that it is safer and actually more convenient to do the reverse. I mean ignoring all .idea files and adding only team-related settings explicitly. (instead of adding all and ignoring some).\nThe main thing that can be shared among developers is code style configs. So, by using IDE auto-reformatting option all the team will follow a consistent style.\nBesides that, the question is which other files are recommended to be included and not ignored? Why?\nAnswer: I came across with this: https://github.com/salarmehr/idea-gitignore"}, {"role": "assistant", "content": "Jetbrains has some official guidance on which files should not be checked in, and which files should probably not be checked in, depending on your usage. According to that page, you should check in all files in the .idea directory except:\n\nworkspace.xml\ntasks.xml\n\nAnd probably also:\n\nthe xml files in the dictionary subdirectory\n\nWhile the particular answer may depend on your team's particular practices, in my experience, following that guidance generally results in correct separation of user settings and shared project configuration.\nSome examples of files that should be shared, according to this guidance:\n\nant.xml, which, if you use Ant to build your project, points IDEA to your build files and configures properties that should be used to build.\nvcs.xml, which specifies the Version Control configuration for your project\nencodings.xml, which specifies how IDEA should treat the text files in your project\nmodules.xml, which points IDEA to each of your project's module configuration files, which should also be shared in your VCS.\nall files under the runConfigurations subdirectory, which tells IDEA what it needs to do to run your application\ncodeStyleSettings.xml, which, as you have alluded to, puts your whole team on the same page in terms of automatic code formatting\n\nDepending on your team's usage, there may be more or less, but those are some of the biggest examples."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --summary"}, {"role": "assistant", "content": "Output a condensed summary of extended header information\nsuch as creations, renames and mode changes."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Switch on another branch (create if not exists), without checking if already exists?\ngit checkout -b foo switches on foo branch (even if it doesn't exist, it is created), but if the foo branch already exists it throws an error like this:\nfatal: A branch named 'foo' already exists.\n\nWhat's the command that does the following check?\n\nif the branch already exists, just switch on it (git checkout foo)\nif the branch doesn't exist, create it and switch on it (git checkout -b foo)"}, {"role": "assistant", "content": "Update Q3 2019 (Git 2.23): there now actually is a git switch command!\ngit switch -c aBranch \n\nOr, if the branch already exists:\ngit switch aBranch\n\nAs I explained in 2020, the git switch command is \"experimental\" in name only, and is here to stay.\nYou would need an alias though, which tries first to switch to the existing branch and, if it fails (because the branch might actually not exist), creates it:\nswitchoc = \"!f() { git switch $1 2>/dev/null || git switch -c $1; }; f\"\n\nNote the name of the alias: switchoc (for \"switch or create\").\nThat combination git switch+git switch -c does precisely what the OP is asking for.\nAs jar pointed out in the comments:\n\nAnyone trying this in 2021, note that you cannot shadow existing git commands with aliases.\nSince git switch is a git command, this alias (named \"switch\") won't work. You must create your unique name for the alias, like \"switchit\" or something.\n\n\nbgusach's alias mentioned below in the comment is safer (based on Jiří Pavelka 's answer):\nswitch = \"!f() { git checkout $1 2>/dev/null || git checkout -b $1; }; f\"\n\ngit switch abranch\n\n\nOriginal answer (2014) You can try:\ngit checkout -B foo\n\nFrom git checkout man page:\n\nIf -B is given, <new_branch> is created if it doesn’t exist; otherwise, it is reset. This is the transactional equivalent of\n\n$ git branch -f <branch> [<start point>]\n$ git checkout <branch>\n\nAs mentioned below, use it with caution as it does reset the branch, which is not always desirable.\nIf you did reset the branch by mistake with this command, you can easily revert to its previous state with:\ngit reset HEAD@{1}\n\n\nTal Jacob - Sir Jacques proposes in the comments:\n\nConfigure git alias with:\ngit config alias.switchoc '!f() { git switch $1 2>/dev/null || git switch -c $1; }; f' \n\nThen use with:\ngit switchoc <branch>"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git squash all commits in branch without conflicting\nA common development workflow for us is to checkout branch b, commit a bunch to it, then squash all those commits into one (still on b).\nHowever, during the rebase -i process to squash all the commits, there are frequently conflicts at multiple steps.\nI essentially want to alter the branch into one commit that represents the state of the repository at the time of the final commit on b\nI've done some searching but I haven't found exactly what I'm looking for. I don't want to merge --squash because we would like to test the squashed feature branch before merging."}, {"role": "assistant", "content": "If you don't need the commit information, then you could just do a soft reset. Then files remain as they were and when you commit, this commit will be on top of the commit you did reset to.\nTo find the commit to reset to:\ngit merge-base HEAD BRANCH_YOU_BRANCHED_FROM\n\nThen\ngit reset --soft COMMIT_HASH\n\nThen re-craft the commit, perhaps:\ngit commit -am 'This is the new re-created one commit'"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-notes - Add or inspect object notes -m <msg> --message=<msg>"}, {"role": "assistant", "content": "Use the given note message (instead of prompting).\nIf multiple -m options are given, their values\nare concatenated as separate paragraphs.\nLines starting with # and empty lines other than a\nsingle line between paragraphs will be stripped out.\nIf you wish to keep them verbatim, use --no-stripspace ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs plain"}, {"role": "assistant", "content": "Show words as [-removed-] and {+added+} . Makes no\nattempts to escape the delimiters if they appear in the input,\nso the output may be ambiguous."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git: rename local branch failed\nI don't know why my attempt of renaming local branch failed. I basically cloned the project, then I also have a submodule within the project, and I downloaded the submodule code as well. However, when I use git branch within the submodule, I have:\n* (no branch)\n master\n\nThe code looks like I'm on another branch but the output shows that it doesn't have a name. Then I searched online to find how to rename local branch and I got this:\ngit branch -m <newname>\n\nAfter I run this command git gave me this error:\nerror: refname refs/heads/HEAD not found\nfatal: Branch rename failed\n\nAnybody know why this happens? Thanks."}, {"role": "assistant", "content": "I get into this issue too. The reason is that I didn't have any commit on this git repository.\nWhen I run the command git branch -M main. I get the following error message.\nerror: refname refs/heads/master not found\nfatal: Branch rename failed\n\nAfter I add my first commit by the following command, all things work.\ngit add .\ngit commit -m 'Init'"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "ArgoCD - what need be done after build a new image\n\nI have deployed the application via ArgoCD successfully, and I can access it via its ingress url\nThe applicaiton uses the image name with latest tag, such as\nimage: <private_registry>/app_1_service:latest\n\nI also manage other tags on same of tag latest, such as image:<commit_id> or image:<1.0.xxx>\nNow, developers will update the codes, after commit changes, a gitlab pipeline automatically runs and build a new image and override to tag latest with other tags and push to private docker registry\nSo what's the next step in ArgoCD?\nHow argocd know the application is changed, and need be redeployed, and the image:latest need be pull again?"}, {"role": "assistant", "content": "You can use ArgoCD image-updater\nBut before using the the image-updater, you need to install and set appropriate permission\nhelm repo add argo https://argoproj.github.io/argo-helm\nhelm install argocd-image-updater argo/argocd-image-updater\n\nOnce image-updator is up and running, then you need to set a few annotations in the Argocd application, as the update workers on different strategies\n\nsemver - Update to the latest version of an image considering semantic versioning constraints\nlatest - Update to the most recently built image found in a registry\ndigest - Update to the latest version of a given version (tag), using the tag's SHA digest\nname - Sorts tags alphabetically and update to the one with the highest cardinality\n\nlatest strategies working awesome with tagging under some regex and digest more suited for testing environment.\nupdate-strategies\nYou can also pull the private image from gitlab as well.\nHere is the working example with helm-release\napiVersion: argoproj.io/v1alpha1\nkind: Application\nmetadata:\n annotations:\n argocd-image-updater.argoproj.io/image-alias.allow-tags: 'regexp:^1.3.0-SNAPSHOT.[0-9]+$'\n argocd-image-updater.argoproj.io/image-alias.force-update: 'true'\n argocd-image-updater.argoproj.io/image-alias.pull-secret: 'pullsecret:develop-namespace/develop-app-gitlab-secrets'\n argocd-image-updater.argoproj.io/image-alias.update-strategy: latest\n argocd-image-updater.argoproj.io/image-list: >-\n image-alias=registry.gitlab.com/myorg/my-test-image\n finalizers:\n - resources-finalizer.argocd.argoproj.io\n labels:\n app.kubernetes.io/instance: develop-platform\n name: develop-app\n namespace: argocd\nspec:\n destination:\n namespace: develop-app\n server: 'https://kubernetes.default.svc'\n project: develop-app-west6-b\n source:\n helm:\n releaseName: develop-app\n valueFiles:\n - develop-platform/values.yaml\n path: helm-chart/helm-chart\n repoURL: 'https://gitlab.com/my-org/develop-app.git'\n targetRevision: staging\n syncPolicy:\n automated:\n prune: true\n selfHeal: true\n\nIf you need digest or just a latest then remove this\n argocd-image-updater.argoproj.io/image-alias.allow-tags: 'regexp:^1.3.0-SNAPSHOT.[0-9]+$'\n\nthis is working base on regex.\nso in your case <1.0.xxx>\nit can be 'regexp:^1.0.[0-9]+$'\nIf everything configured properly and image updater working fine then you should be able to see logs image updater logs like this\ntime=\"2022-04-27T15:18:36Z\" level=info msg=\"Successfully updated image 'registry.gitlab.com/test-image:0.3.0-SNAPSHOT.115' to 'registry.gitlab.com/test-image:0.3.0-SNAPSHOT.118'"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git --parents"}, {"role": "assistant", "content": "Create parent folders. This parameter is equivalent to the parameter\n--parents on svn cp commands and is useful for non-standard repository\nlayouts."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I throw away local git commits when getting \"Your branch and 'origin/master' have diverged\"?\nI have the following message in git: \n# Your branch and 'origin/master' have diverged,\n# and have 3 and 8 different commits each, respectively.\n# (use \"git pull\" to merge the remote branch into yours)\n\nI would like to throw away the 3 local commits, and pull the 8 remote commits at origin/master. \n(Merging is going to be too difficult, I'd rather make the 3 local commits again once master is up to date.)\nHow can I do this?"}, {"role": "assistant", "content": "git fetch origin\ngit reset --hard origin/master\n\nNote that any non-pushed commits or local changes will be lost."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_ALTERNATE_OBJECT_DIRECTORIES"}, {"role": "assistant", "content": "Due to the immutable nature of Git objects, old objects can be\narchived into shared, read-only directories. This variable\nspecifies a \":\" separated (on Windows \";\" separated) list\nof Git object directories which can be used to search for Git\nobjects. New objects will not be written to these directories. Entries that begin with \" (double-quote) will be interpreted\nas C-style quoted paths, removing leading and trailing\ndouble-quotes and respecting backslash escapes. E.g., the value \"path-with-\\\"-and-:-in-it\":vanilla-path has two paths: path-with-\"-and-:-in-it and vanilla-path ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fetch - Download objects and refs from another repository --prefetch"}, {"role": "assistant", "content": "Modify the configured refspec to place all refs into the refs/prefetch/ namespace. See the prefetch task in git-maintenance ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git \"revert\" current directory\nIn Subversion (SVN), it's possible to do svn revert ./* in which the current directory and only the current directory gets reverted.\nWhat is the Git equivalent to svn revert in which only the current directory gets reverted?\nI know that there's git reset --hard, but it reverts everything and not just the current directory.\nHow would I revert just the current directory in Git?"}, {"role": "assistant", "content": "Like vcsjones says, the solution here is git checkout:\ngit checkout <refspec> -- path/to/directory # or path/to/file\n\nwhere <refspec> can, for instance, be HEAD, that is, the current working commit. Note that this usage of the checkout command will affect the working tree but not the index.\ngit revert is used to \"revert a commit\", and by this, it should not be understood that the commit disappears from the tree (it would play havoc with history -- if you want that, look at git rebase -i). A reverted commit consists of applying, in reverse, all changes from the commit given as an argument to the tree and create a new commit with the changes (with a default commit message, which you can modify)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-fast-import"}, {"role": "assistant", "content": "Backend for fast Git data importers"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git rename from index.lock to index failed\n\nUsing the GitHub Windows client I did a sync to pull remote changes to my local machine, but before finishing the sync, I ran out of disk space and the sync failed. Now I seem to have a bunch of local changes that are actually changes that were being pulled from origin. I tried to run git pull but got:\nC:\\Users\\Tom\\SourceLog [master +4 ~26 -0 !]> git pull\nUpdating b3a86e1..5afd74f\nerror: Your local changes to the following files would be overwritten by merge:\n SourceLog.Interface/IChangedFile.cs\n SourceLog.Interface/ILogEntry.cs\n ...\nPlease, commit your changes or stash them before you can merge.\nerror: The following untracked working tree files would be overwritten by merge:\n Lib/MSBuildExtensionPack/4.0.6.0/Ionic.Zip.dll\n Lib/MSBuildExtensionPack/4.0.6.0/MSBuild.ExtensionPack.dll\n ...\nAborting\n\nSo now I'm trying to discard the local changes but I'm getting:\nC:\\Users\\Tom\\SourceLog [master +4 ~26 -0 !]> git checkout -- .\nRename from '.git/index.lock' to '.git/index' failed. Should I try again? (y/n) y\nRename from '.git/index.lock' to '.git/index' failed. Should I try again? (y/n) n\nfatal: unable to write new index file\n\nHow can I clean this up? (I didn't have any local changes before starting the sync.)\nUpdate\nCan't seem to reset head..\nC:\\Users\\Tom\\SourceLog [master +4 ~0 -0 !]> git reset head\nRename from '.git/index.lock' to '.git/index' failed. Should I try again? (y/n) y\nRename from '.git/index.lock' to '.git/index' failed. Should I try again? (y/n) n\nerror: Could not write new index file.\nfatal: Could not reset index file to revision 'head'."}, {"role": "assistant", "content": "In my case, this was caused by using the same Git repo from both admin and non-admin command prompts. When last git pull was from admin cmd, the index was created by it, and then non-admin cmd had insufficient permissions to modify it.\nMy solution was re-creating the index (while keeping the worktree intact):\ndel .git\\index\ndel .git\\index.lock\ngit reset --mixed head"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I properly force a Git push?\nI've set up a remote non-bare \"main\" repo and cloned it to my computer. I made some local changes, updated my local repository, and pushed the changes back to my remote repo. Things were fine up to that point.\nNow, I had to change something in the remote repo. Then I changed something in my local repo. I realized that the change to the remote repo was not needed. So I tried to git push from my local repo to my remote repo, but I got an error like:\n\nTo prevent you from losing history, non-fast-forward updates were\n rejected Merge the remote changes before pushing again. See the 'Note\n about fast-forwards' section of git push --help for details.\n\nI thought that probably a\ngit push --force\n\nwould force my local copy to push changes to the remote one and make it the same. It does force the update, but when I go back to the remote repo and make a commit, I notice that the files contain outdated changes (ones that the main remote repo previously had).\nAs I mentioned in the comments to one of the answers:\n\n[I] tried forcing, but when going back to master server to save the changes, i get outdated staging. Thus, when i commit the repositories are not the same. And when i try to use git push again, i get the same error.\n\nHow can I fix this issue?"}, {"role": "assistant", "content": "Just do:\ngit push origin <your_branch_name> --force\n\nor if you have a specific repo:\ngit push https://git.... --force\n\nThis will delete your previous commit(s) and push your current one.\nIt may not be proper, but if anyone stumbles upon this page, thought they might want a simple solution...\nShort flag\nAlso note that -f is short for --force, so\ngit push origin <your_branch_name> -f\n\nwill also work."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Gitlab CI - ERROR: Job failed: executor requires OSType=linux, but Docker Engine supports only OSType=windows\n\nGetting this error while running Gitlab CI pipeline. As I understand the error says that I'm trying to run a Linux type docker image on a windows docker-engine? But the thing is I'm using a windows docker image. What could be the problem?\n\nERROR: Job failed: executor requires OSType=linux, but Docker Engine supports only OSType=windows\n\nMy CI:\nimage: hello-world:nanoserver\n\nstages:\n - build\n\nbuild1:\n stage: build\n script:\n - echo \"Hello world\""}, {"role": "assistant", "content": "What's the difference between \"Shared\" and \"Simple\" tags?\n\nSome images have separated \"Simple Tags\" and \"Shared Tags\" sections\n under \"Supported tags and respective Dockerfile links\" (see the mongo\n image for an example).\n\"Simple Tags\" are instances of a \"single\" Linux or Windows image. It\n is often a manifest list that can include the same image built for\n other architectures; for example, mongo:4.0-xenial currently has\n images for amd64 and arm64v8. The Docker daemon is responsible for\n picking the appropriate image for the host architecture.\n\"Shared Tags\" are tags that always point to a manifest list which\n includes some combination of potentially multiple versions of Windows\n and Linux images across all their respective images' architectures --\n in the mongo example, the 4.0 tag is a shared tag consisting of (at\n the time of this writing) all of 4.0-xenial,\n 4.0-windowsservercore-ltsc2016, 4.0-windowsservercore-1709, and 4.0-windowsservercore-1803.\nThe \"Simple Tags\" enable docker run mongo:4.0-xenial to \"do the right\n thing\" across architectures on a single platform (Linux in the case of\n mongo:4.0-xenial). The \"Shared Tags\" enable docker run mongo:4.0 to\n roughly work on both Linux and as many of the various versions of\n Windows that are supported (such as Windows Server Core LTSC 2016,\n where the Docker daemon is again responsible for determining the\n appropriate image based on the host platform and version).\n\nI suggest you to try shared tags:\nimage: hello-world\n\nthe latest tag has:\nlinux/386\n\nwindows v10.0.17134.1069/amd64\n\nwindows v10.0.17763.802/amd64\n\nand Docker will pick up the right one for you\nFrom here you need the executer docker-windows to run Windows Container\nso you may add executor = \"docker-windows\" to your runners config"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to recover stashed uncommitted changes\nI had some uncommitted changes in my development branch and I stashed them using git stash, but there were some changes which were very important among those stashed ones. Is there any way to get back those changes?\nAlso, I have made some changes on top of the stashed code files since. \nIs there any chance I can retrieve the stashed changes to a new branch if possible?"}, {"role": "assistant", "content": "The easy answer to the easy question is git stash apply\nJust check out the branch you want your changes on, and then git stash apply. Then use git diff to see the result.\nAfter you're all done with your changes—the apply looks good and you're sure you don't need the stash any more—then use git stash drop to get rid of it.\nI always suggest using git stash apply rather than git stash pop. The difference is that apply leaves the stash around for easy re-try of the apply, or for looking at, etc. If pop is able to extract the stash, it will immediately also drop it, and if you subsequently realize that you wanted to extract it somewhere else (in a different branch), or with --index, or some such, that's not so easy. If you apply, you get to choose when to drop.\nIt's all pretty minor one way or the other though, and for a newbie to Git, it should be about the same. (And you can skip all the rest of this!)\n\nWhat if you're doing more-advanced or more-complicated stuff?\nThere are at least three or four different \"ways to use git stash\", as it were. The above is for \"way 1\", the \"easy way\":\n\nYou started with a clean branch, were working on some changes, and then realized you were doing them in the wrong branch. You just want to take the changes you have now and \"move\" them to another branch.\n\nThis is the easy case, described above. Run git stash save (or plain git stash, same thing). Check out the other branch and use git stash apply. This gets Git to merge in your earlier changes, using Git's rather powerful merge mechanism. Inspect the results carefully (with git diff) to see if you like them, and if you do, use git stash drop to drop the stash. You're done!\n\nYou started some changes and stashed them. Then you switched to another branch and started more changes, forgetting that you had the stashed ones.\n\nNow you want to keep, or even move, these changes, and apply your stash too.\nYou can in fact git stash save again, as git stash makes a \"stack\" of changes. If you do that, you have two stashes, one just called stash—but you can also write stash@{0}—and one spelled stash@{1}. Use git stash list (at any time) to see them all. The newest is always the lowest-numbered. When you git stash drop, it drops the newest, and the one that was stash@{1} moves to the top of the stack. If you had, even more, the one that was stash@{2} becomes stash@{1}, and so on.\nYou can apply and then drop a specific stash, too: git stash apply stash@{2}, and so on. Dropping a specific stash renumbers only the higher-numbered ones. Again, the one without a number is also stash@{0}.\nIf you pile up a lot of stashes, it can get fairly messy (was the stash I wanted stash@{7} or was it stash@{4}? Wait, I just pushed another, now they're 8 and 5?). I personally prefer to transfer these changes to a new branch, because branches have names, and cleanup-attempt-in-December means a lot more to me than stash@{12}. (The git stash command takes an optional save-message, and those can help, but somehow, all my stashes just wind up named WIP on branch.)\n\n(Extra-advanced) You've used git stash save -p, or carefully git add-ed and/or git rm-ed specific bits of your code before running git stash save. You had one version in the stashed index/staging area and another (different) version in the working tree. You want to preserve all this. So now you use git stash apply --index, and that sometimes fails with:\nConflicts in index. Try without --index.\n\n\nYou're using git stash save --keep-index in order to test \"what will be committed\". This one is beyond the scope of this answer; see this other StackOverflow answer instead.\n\n\nFor complicated cases, I recommend starting in a \"clean\" working tree first, by committing any changes you have now (on a new branch if you like). That way the \"somewhere\" that you are applying them, has nothing else in it, and you'll just be trying the stashed changes:\ngit status # see if there's anything you need to commit\n # uh oh, there is - let's put it on a new temp branch\ngit checkout -b temp # create new temp branch to save stuff\ngit add ... # add (and/or remove) stuff as needed\ngit commit # save first set of changes\n\nNow you're on a \"clean\" starting point. Or maybe it goes more like this:\ngit status # see if there's anything you need to commit\n # status says \"nothing to commit\"\ngit checkout -b temp # optional: create a new branch for \"apply\"\ngit stash apply # apply stashed changes; see below about --index\n\nThe main thing to remember is that the \"stash\" is a commit, it's just a slightly \"funny/weird\" commit that's not \"on a branch\". The apply operation looks at what the commit changed and tries to repeat it wherever you are now. The stash will still be there (apply keeps it around), so you can look at it more, or decide this was the wrong place to apply it and try again differently, or whatever.\n\nAny time you have a stash, you can use git stash show -p to see a simplified version of what's in the stash. (This simplified version looks only at the \"final work tree\" changes, not the saved index changes that --index restores separately.) The command git stash apply, without --index, just tries to make those same changes in your working tree now.\nThis is true even if you already have some changes. The apply command is happy to apply a stash to a modified working tree (or at least, to try to apply it). You can, for instance, do this:\ngit stash apply stash # apply top of stash stack\ngit stash apply stash@{1} # and mix in next stash stack entry too\n\nYou can choose the \"apply\" order here, picking out particular stashes to apply in a particular sequence. Note, however, that each time you're basically doing a \"git merge\", and as the merge documentation warns:\n\nRunning git merge with non-trivial uncommitted changes is\ndiscouraged: while possible, it may leave you in a state that is hard\nto back out of in the case of a conflict.\n\nIf you start with a clean tree and are just doing several git apply operations, it's easy to back out: use git reset --hard to get back to the clean state, and change your apply operations. (That's why I recommend starting in a clean working tree first, for these complicated cases.)\n\nWhat about the very worst possible case?\nLet's say you're doing Lots Of Advanced Git Stuff, and you've made a stash, and want to git stash apply --index, but it's no longer possible to apply the saved stash with --index because the branch has diverged too much since the time you saved it.\nThis is what git stash branch is for.\nIf you:\n\ncheck out the exact commit you were on when you did the original stash, then\ncreate a new branch, and finally\ngit stash apply --index\n\nthe attempt to re-create the changes definitely will work. This is what git stash branch newbranch does. (And it then drops the stash since it was successfully applied.)\n\nSome final words about --index (what the heck is it?)\nWhat the --index does is simple to explain, but a bit complicated internally:\n\nWhen you have changes, you have to git add (or \"stage\") them before commit-ing.\nThus, when you ran git stash, you might have edited both files foo and zorg, but only staged one of those.\nSo when you ask to get the stash back, it might be nice if it git adds the added things and does not git add the non-added things. That is, if you are add-ed foo but not zorg back before you did the stash, it might be nice to have that exact same setup. What was staged, should again be staged; what was modified but not staged, should again be modified but not staged.\n\nThe --index flag to apply tries to set things up this way. If your working tree is clean, this usually just works. If your working tree already has stuff add-ed, though, you can see how there might be some problems here. If you leave out --index, the apply operation does not attempt to preserve the whole staged/unstaged setup. Instead, it just invokes Git's merge machinery, using the working tree commit in the \"stash bag\". If you don't care about preserving staged/unstaged, leaving out --index makes it a lot easier for git stash apply to do its thing."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options push.useForceIfIncludes"}, {"role": "assistant", "content": "If set to \"true\", it is equivalent to specifying --force-if-includes as an option to git-push in the command line. Adding --no-force-if-includes at the\ntime of push overrides this configuration setting."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.colorMovedWS"}, {"role": "assistant", "content": "When moved lines are colored using e.g. the diff.colorMoved setting,\nthis option controls the <mode> how spaces are treated.\nFor details of valid modes see --color-moved-ws in git-diff ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git: undo all working dir changes including new files\nHow to delete all changes from working directory including new untracked files. I know that git checkout -f does that, but it doesn't delete new untracked files created since last commit.\nDoes anybody have an idea how to do that?"}, {"role": "assistant", "content": "git reset --hard # removes staged and working directory changes\n\n## !! be very careful with these !!\n## you may end up deleting what you don't want to\n## read comments and manual.\ngit clean -f -d # remove untracked\ngit clean -f -x -d # CAUTION: as above but removes ignored files like config.\ngit clean -fxd :/ # CAUTION: as above, but cleans untracked and ignored files through the entire repo (without :/, the operation affects only the current directory)\n\nTo see what will be deleted before-hand, without actually deleting it, use the -n flag (this is basically a test-run). When you are ready to actually delete, then remove the -n flag:\ngit clean -nfd"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs -w --ignore-all-space"}, {"role": "assistant", "content": "Ignore whitespace when comparing lines. This ignores\ndifferences even if one line has whitespace where the other\nline has none."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Start a Git commit message with a hashmark (#)\nGit treats lines starting with # (hash, number sign, octothorpe, pound sign) as comment lines when committing. This is very annoying when working with a ticket tracking system, and trying to write the ticket number at the beginning of the line, e.g.\n#123 salt hashed passwords\n\nGit will simply remove the line from the commit message. Is there a way to escape the hash? I tried \\ and !, but nothing works. White space before # is preserved, so that's not a working solution to the problem either."}, {"role": "assistant", "content": "This behaviour is part of git commit's default 'clean-up' behaviour. If you want to keep lines starting with # you can use an alternative clean-up mode.\nE.g.\ngit commit --cleanup=whitespace\n\nIf you do this you have to be careful to remove all # lines that you don't want to appear in the commit."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to remove the first commit in git?\nI am curious about how to remove the first commit in git.\nWhat is the revision before committing any thing? Does this revision have a name or tag?"}, {"role": "assistant", "content": "For me, the most secure way is to use the update-ref command:\ngit update-ref -d HEAD\n\nIt will delete the named reference HEAD, so it will reset (softly, you will not lose your work) ALL your commits of your current branch.\nIf what you want is to merge the first commit with the second one, you can use the rebase command:\ngit rebase -i --root\n\nA last way could be to create an orphan branch, a branch with the same content but without any commit history, and commit your new content on it:\ngit checkout --orphan <new-branch-name>"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "`git commit -v` by default\nHow can I configure git commit to act as git commit -v (showing the full diff being committed) by default?\nUsing an alias is not quite satisfactory, as it does not affect commit message editing during operations which may indirectly commit, such as git rebase."}, {"role": "assistant", "content": "If you are using git 2.9, this can be done with a config.\ngit config --global commit.verbose true\n\nGit 2.9.0 Release Notes: \nhttps://github.com/git/git/blob/v2.9.0/Documentation/RelNotes/2.9.0.txt\n\n\"git commit\" learned to pay attention to the \"commit.verbose\"\n configuration variable and act as if the \"--verbose\" option\n was given from the command line."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Get a list of all Git commits, including the 'lost' ones\nLet's say that I have a graph like this:\nA---B---C---D (master)\n \\\n \\-E---F (HEAD)\n\nIf I do git log --all --oneline, I will get all six of my commits.\nBut if the graph is:\nA---B---C---D (master, HEAD)\n \\\n \\-E---F\n\nI will not see E and F. Can I get Git to tell me all the commits, including those on branches which are not named?"}, {"role": "assistant", "content": "Try:\ngit log --reflog\n\nwhich lists all git commits by pretending that all objects mentioned by reflogs (git reflog) are listed on the command line as <commit>."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why does the same conflict reappear when I use git rebase?\nI have read relevant questions about git merge and git rebase on SO, but I still cannot fully understand what is happening under the hood.\nHere is our branching situation:\nMASTER------------------------\n \\ \\\n \\ \\----Feature B---\n \\ \\\n \\-----Feature A----------\\---Feature A+B\n\nGiven 2 feature branches that stem from master at different times, we now want to combine the 2 branches. We want to follow the first rebase then merge practice, but when we rebase Feature A onto Feature B, we get conflicts. That's expected, because both features (and master) have changes in the same areas. But the strange thing is that the same conflict keeps reappearing after git rebase --continue. This drives us crazy, so we end up aborting the rebase, and use git merge. It turns out the conflicts are actually easy to resolve.\nMy question is two-fold:\n\nIs git rebase suitable for our situation? Or is rebase only good for pulling in a few (e.g., 1 or 2) changes?\nWhat is happening under the hood that causes the same conflict to reappear again and again? My understanding is rebase resolves conflicts one at a time, but which commit does it compare, and what does it compare it to?\n\nRelavant posts on SO:\n\nWhy do I have to resolve the same conflict over and over?\nhttps://stackoverflow.com/questions/7241678/how-to-prevent-lot-of-git-conflicts-when-git-rebasing-lot-of-commits\\\ngit rebase resolve conflicts again and again?"}, {"role": "assistant", "content": "Is rebase suitable for your situation?\nBased on the fact that Feature A and Feature B seem to be shared branches, I'd say no.\nRebasing is a way to merge branches without having merge commits (i.e. commits that have two or more parents) making it appear as a linear history. It's best used to merge local branches, that is branches that only exist in your local repository and haven't been published to other people. Why? Because of at least two reasons:\n\nRebasing changes the commit IDs (i.e. the SHA-1 hashes of their metadata). This means that once you push the rebased commits to the shared branch, they will appear as completely new commits to anyone that fetches them on their local repo, even if they still contain the same changes. Now, if someone has added new commits on top of the old ones in the meantime, they will have to move them. This creates unnecessary confusion.\nWhen you merge public branches you often want to have those merge commits in order to be able to track how commits moved across branches. That information is lost with rebasing.\n\nWhat's happening under the hood?\nJust a regular merge. The difference is that git rebase merges one commit at a time on top of the previous one starting from the common parent. git merge merges two commits – with their entire set of changes – as a single operation, so you only have to resolve the conflicts once.\nUpdate: Resolving recurring conflicts\nAs @Jubobs pointed out in the comments, Git does have an automated solution for resolving conflicts that occur multiple times: git rerere, or \"reuse recorded resolution\".\nAfter you enable rerere in your configuration file (rerere.enabled true) every time a merge conflict occurs, Git will record the state of the conflicting files before and after you merge them. Next time the same conflict occurs – a conflict involving the exact same lines on both sides of the merge – Git will automatically apply the same resolution it had recorded previously. It will also let you know about it in the merge output:\n\nCONFLICT (content): Merge conflict in 'somefile'\n Resolved 'somefile' using previous resolution.\n\nHere you can find more details on how to deal with conflicts using git rerere."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to configure an existing git repo to be shared by a UNIX group\nI have an existing git repo (a bare one) which has up to this point only been writable by me. I want to open it up to some UNIX user group, foo, so that all members of foo can push to it. I'm aware that I can easily set up a new git repo with:\ngit init --bare --shared=group repodir\nchgrp -R foo repodir\n\nBut I need the equivalent operation for an existing repo dir."}, {"role": "assistant", "content": "Try this to make an existing repository in repodir work for users in group foo:\nchgrp -R foo repodir # set the group\nchmod -R g+rw repodir # allow the group to read/write\nchmod g+s `find repodir -type d` # new files get group id of directory\ngit init --bare --shared=all repodir # sets some important variables in repodir/config (\"core.sharedRepository=2\" and \"receive.denyNonFastforwards=true\")"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to wrap long lines inside of markdown ``` code ``` in Github and Gitlab issues?\n\neg:\n```\nsome very long line; some very long line; some very long line; some very long line; some very long line; some very long line; some very long line; some very long line; some very long line; some very long line; \n```\n\nwill force user to scroll in github/gitlab issues.\nIs there a way to soft-line wrap inside code block ?\nI've read the related questions but they seem different (eg jekyll etc).\nEDIT: manually editing code to limit to 80 columns is not a viable option (eg, when pasting from a compiler output/log etc; that's a lot of work and should not be necessary)\nEDIT: see also https://github.com/softvar/enhanced-github/issues/95"}, {"role": "assistant", "content": "A quick workaround is to quote your codeblocks, e.g.\n\nthis line is very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long\n\nMake sure you keep the three backticks inline with the very long line. Like this:\n> ```this line is very long```"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Merging a branch of a branch after first branch is squashed when merged to master\nHere's a workflow that I commonly deal with at work.\ngit checkout -b feature_branch\n# Do some development\ngit add .\ngit commit\ngit push origin feature_branch\n\nAt this point the feature branch is up for review from my colleagues, but I want to keep developing on other features that are dependent on feature_branch. So while feature_branch is in review...\ngit checkout feature_branch\ngit checkout -b dependent_branch\n# Do some more development\ngit add .\ngit commit\n\nNow I make some changes in response to the code review on feature_branch\ngit checkout feature_branch\n# Do review fixes\ngit add .\ngit commit\ngit checkout dependent_branch\ngit merge feature_branch\n\nNow this is where we get have problems. We have a squash policy on master, which means that feature branches that are merged into master have to be squashed into a single commit.\ngit checkout feature_branch\ngit log # Look for hash at beginning of branch\ngit rebase -i first_hash_of_branch # Squash feature_branch into a single commit\ngit merge master\n\nEverything is cool, except with dependent_branch. When I try to rebase dependent branch onto master or try and merge master into it, git is confused by the re-written/squashed history and basically marks every single change in depedendent_branch as a conflict. It's a PITA to go through and basically re-do or de-conflicticize all of the changes in dependent_branch. Is there some solution to this? Sometimes, I'll manually create a patch and apply it off a fresh branch of master, but if there's any real conflicts with that, its even worse to fix.\ngit checkout dependent_branch\ngit diff > ~/Desktop/dependent_branch.diff\ngit checkout master\ngit checkout -b new_dependent_branch\npatch -p1 < ~/Desktop/dependent_branch.diff\n# Pray for a clean apply.\n\nAny ideas? I know this happens because of the re-written history during the squash, but that's a requirement that I can't change. What's the best solution / workaround? Is there some magic I can do? Or is there a faster way to do all the steps involved with manually creating the diff?"}, {"role": "assistant", "content": "A little bit about why this happens:\nI'll let O be \"original master\" and FB be \"new master\", after a feature branch has been merged in:\nSay feature_branch looks like:\nO - A - B - C \n\ndependent_feature has a few extra commits on top of that:\nO - A - B - C - D - E - F\n\nYou merge your original feature branch into master and squash it down, giving you:\nO - FB\n\nNow, when you try to rebase the dependent branch, git is going to try to figure out the common ancestor between those branches. While it originally would have been C, if you had not squashed the commits down, git instead finds O as the common ancestor. As a result, git is trying to replay A, B, and C which are already contained in FB, and you're going to get a bunch of conflicts.\nFor this reason, you can't really rely on a typical rebase command, and you have to be more explicit about it by supplying the --onto parameter:\ngit rebase --onto master HEAD~3 # instruct git to replay only the last\n # 3 commits, D E and F, onto master.\n\nModify the HEAD~3 parameter as necessary for your branches, and you shouldn't have to deal with any redundant conflict resolution.\nSome alternate syntax, if you don't like specifying ranges and you haven't deleted your original feature branch yet:\ngit rebase --onto master feature_branch dependent_feature\n\n # replay all commits, starting at feature_branch\n # exclusive, through dependent_feature inclusive \n # onto master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fetch - Download objects and refs from another repository --upload-pack <upload-pack>"}, {"role": "assistant", "content": "When given, and the repository to fetch from is handled\nby git fetch-pack , --exec=<upload-pack> is passed to\nthe command to specify non-default path for the command\nrun on the other end."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "List all local branches without a remote\nProblem: I want a way of deleting all the local branches I have that do not have a remote. It's easy enough to pipe the names of the branches into a git branch -D {branch_name}, but how do I get that list in the first place?\nFor example:\nI create a new branch without a remote:\n$ git co -b no_upstream\n\nI list all my branches, and there's only one with a remote\n$ git branch -a\nmaster\n* no_upstream\nremotes/origin/HEAD -> origin/master\nremotes/origin/master\n\nWhat command can I run to get no_upstream as an answer?\nI can run git rev-parse --abbrev-ref --symbolic-full-name @{u} and that will show that it has no remote:\n$ git rev-parse --abbrev-ref --symbolic-full-name @{u}\nerror: No upstream configured for branch 'no_upstream'\nerror: No upstream configured for branch 'no_upstream'\nfatal: ambiguous argument '@{u}': unknown revision or path not in the working tree.\nUse '--' to separate paths from revisions, like this:\n'git <command> [<revision>...] -- [<file>...]'\n\nBut as this is an error, it won't let me use it or pipe it to other commands. I'm intending to use this as either a shell script alias'd to git-delete-unbranched or maybe make a super simple Gem like git-branch-delete-orphans"}, {"role": "assistant", "content": "I recommend using git branch --format to specify the exact output you want from the git branch command. By doing that, you can pull out just the refname and the upstream, like this:\ngit branch --format \"%(refname:short) %(upstream)\"\n\nIt outputs the branches along with the remote branches if they exist, in the following format:\n25-timeout-error-with-many-targets\n31-target-suggestions refs/remotes/origin/31-target-suggestions\n54-feedback-link refs/remotes/origin/54-feedback-link\n65-digest-double-publish\n\nOnce you have this nicely formatted output, it's as easy as piping it through awk to get your list:\ngit branch --format \"%(refname:short) %(upstream)\" | awk '{if (!$2) print $1;}'\n\nResults in the following output:\n25-timeout-error-with-many-targets\n65-digest-double-publish\n\nThe awk portion prints the first column if there is no second column.\nBonus: Create an alias\nMake it easy to run by creating an alias in your global .gitconfig file (or wherever):\n[alias]\n local-branches = \"!git branch --format '%(refname:short) %(upstream:short)' | awk '{if (!$2) print $1;}'\"\n\nBonus: Remote Filtering\nIf for some reason you have multiple tracking remotes for different branches, it's easy enough to specify which remote you want to check against. Just add the remote name to the awk pattern. In my case, it's origin so I can do this:\ngit branch --format \"%(refname:short) %(upstream)\" | awk '$2 !~/\\/origin\\// { print $1 }'\n\nImportant: The backslash needs to be escaped in the alias or else you will have an invalid gitconfig file.\n\nPrevious Answer\nThe previous answer was functionally similar, but used the following as it's starting point. Over time, commenters have pointed out that a regex is unreliable due to the variance possible in a commit message, so I no longer recommend this method. But, here it is for reference:\nI recently discovered git branch -vv which is the \"very verbose\" version of the git branch command.\nIt outputs the branches along with the remote branches if they exist, in the following format:\n 25-timeout-error-with-many-targets 206a5fa WIP: batch insert\n 31-target-suggestions f5bdce6 [origin/31-target-suggestions] Create target suggestion for team and list on save\n* 54-feedback-link b98e97c [origin/54-feedback-link] WIP: Feedback link in mail\n 65-digest-double-publish 2de4150 WIP: publishing-state\n\nOnce you have this nicely formatted output, it's as easy as piping it through cut and awk to get your list:\ngit branch -vv | cut -c 3- | awk '$3 !~/\\[/ { print $1 }'"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Put whole gitlab installation to read-only mode\n\nI wish to deny to push changes to any repository by any user. Technically, I need to switch whole gitlab to read-only mode. \nIs there simple way to do this?"}, {"role": "assistant", "content": "Actually a better answer is to change this flag to true. This makes the entire instance read only and adds a nice header in the app."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I make git use the editor of my choice for editing commit messages?\nHow do I globally configure git to use a particular editor (e.g. vim) for commit messages?"}, {"role": "assistant", "content": "Setting the default editor for Git\nPick one:\n\nSet core.editor in your Git config:\ngit config --global core.editor \"vim\"\n\n\nSet the GIT_EDITOR environment variable:\nexport GIT_EDITOR=vim\n\n\n\n\nSetting the default editor for all programs\nSet the standardized VISUAL and EDITOR environment variables*:\nexport VISUAL=vim\nexport EDITOR=\"$VISUAL\"\n\nNOTE: Setting both is not necessarily needed, but some programs may not use the more-correct VISUAL. See VISUAL vs. EDITOR.\n\nFixing compatibility issues\nSome editors require a --wait flag, or they will open a blank page. For example:\n\nSublime Text (if correctly set up; or use the full path to the executable in place of subl):\nexport VISUAL=\"subl --wait\"\n\n\nVS Code (after adding the shell command):\nexport VISUAL=\"code --wait\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Protect Github branches from being deleted\n\nIt looks like the Github UI changed for settings/branches for a repo. I can no longer figure out how to prevent a branch from being deleted.\n\nDoes anyone know how to prevent a branch from being deleted? Aka, protect the branch?"}, {"role": "assistant", "content": "By default if you create a Branch protection rule for any branch, it Disables force-pushes to all matching branches and prevents them from being deleted. So if you create a rule with the pattern master, it would prevent the master branch from deletion by default.\nAbout how the rule pattern works, it uses fnmatch to match against any pattern provided to find out the branches to which the rule applies. For eg :\n\nRule pattern as * would apply to all the branches\nRule pattern as release* would apply to all the branches whose name starts with release\n\nCurrently I don't think you can set any single rule pattern on GitHub (I have tried) to match multiple branches like for eg master and develop, since ideally {master,develop} should match both the branches, but currently it doesn't, and according to the fnmatch documentation {a,b} matches pattern a and pattern b if File::FNM_EXTGLOB flag is enabled\nCheck out more details on the above on GitHub help and the fnmatch documentation"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can I specify in .git/config to fetch multiple refspecs?\nI do not want to fetch every branch from origin because there are many. I just want to track a few (e.g., master) and my branches (organized under my_name sub-directory). I can do the following:\n$ git fetch origin refs/heads/my_name/*:refs/remotes/origin/my_name/* refs/heads/master:refs/remotes/origin/master refs/heads/some_branch:refs/remotes/origin/some_branch\n\nI want to specify the above \"set\" of refspecs to be the default of git fetch. I have tried\n$ git config remote.origin.fetch refs/heads/my_name/*:refs/remotes/origin/my_name/*\n$ git config --add remote.origin.fetch refs/heads/master:refs/remotes/origin/master\n\nIt fails:\n$ git config remote.origin.fetch\nrefs/heads/my_name/*:refs/remotes/origin/my_name/*\nerror: More than one value for the key remote.origin.fetch: refs/heads/master:refs/remotes/origin/master\n\nI also try the following but it also fails:\n$ git config remote.origin.fetch 'refs/heads/my_name/*:refs/remotes/origin/my_name/* refs/heads/master:refs/remotes/origin/master refs/heads/some_branch:refs/remotes/origin/some_branch'\n$ git fetch\nfatal: Invalid refspec 'refs/heads/my_name/*:refs/remotes/origin/my_name/* refs/heads/master:refs/remotes/origin/master refs/heads/some_branch:refs/remotes/origin/some_branch'\n\nNote: Git 1.7.11"}, {"role": "assistant", "content": "You can add the following lines in your .git/config to specify multiple refspecs for fetch:\n[remote \"origin\"]\n fetch = refs/heads/my_name/*:refs/remotes/origin/my_name/*\n fetch = refs/heads/master:refs/remotes/origin/master\n fetch = refs/heads/some_branch:refs/remotes/origin/some_branch\n\nYou can add the prefix + before the refspec, if you would like to override fetching non-fast-forward references as well, like this:\n[remote \"origin\"]\n fetch = +refs/heads/my_name/*:refs/remotes/origin/my_name/*\n fetch = +refs/heads/master:refs/remotes/origin/master\n fetch = +refs/heads/some_branch:refs/remotes/origin/some_branch\n\nNote that partial globbing is not supported (i.e. a/b/ca* is not supported, but a/b/* is).\n10.5 Git Internals - The Refspec"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitglossary - A Git Glossary porcelain"}, {"role": "assistant", "content": "Cute name for programs and program suites depending on core Git , presenting a high level access to\ncore Git. Porcelains expose more of a SCM interface than the plumbing ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Should we commit pod files to version control system (GIT or SVN)\nSo far I was working on an app and my Team Lead said not to commit the pod files and I just followed his instructions. \nThen our Lead changed and he said to commit the pod file to Git. So I was confused which one to go with. \nShould we commit the pod file or not and if we should not then why. Please help me clear on this thing as I went through some articles as well but didn't find any satisfactory answer."}, {"role": "assistant", "content": "Whether or not you check in your Pods folder is up to you, as workflows vary from project to project. It is recommended that you keep the Pods directory under source control.\nBenefits of checking in the Pods directory\n\nAfter cloning the repo, the project can immediately build and run, even without having CocoaPods installed on the machine. There is no need to run pod install, and no Internet connection is necessary.\nThe Pod artifacts (code/libraries) are always available, even if the source of a Pod (e.g. GitHub) were to go down.\nThe Pod artifacts are guaranteed to be identical to those in the original installation after cloning the repo.\n\nBenefits of ignoring the Pods directory\n\nThe source control repo will be smaller and take up less space.\nAs long as the sources (e.g. GitHub) for all Pods are available, CocoaPods is generally able to recreate the same installation. (Technically there is no guarantee that running pod install will fetch and recreate identical artifacts when not using a commit SHA in the Podfile. This is especially true when using zip files in the Podfile.)\nThere won't be any conflicts to deal with when performing source control operations, such as merging branches with different Pod versions.\n\nSource: Cocoapods"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Logon failed, use ctrl+c to cancel basic credential prompt to Git in Azure DevOps\nWhen cloning a git repository sitting up in Azure Repos into my local machine clone succeeds but I get a line that says:\nLogon failed, use ctrl+c to cancel basic credential prompt \n\nNot sure what this is referring to, any ideas?\nI'm using PAT token to authenticate my clone, command is:\ngit clone https://*************PAT*************@dev.azure.com/orgname/projectname/_git/reponame"}, {"role": "assistant", "content": "It happens if the git is not updated to the latest version.\nPlease update the git and you are good to go.\nTo update the git, just follow the below command depending on the type of OS you are using:\nwindows: git update-git-for-windows\nLinux/Unix: git update\nor follow the below link to get the latest copy of the git client for your OS\nhttps://git-scm.com/downloads"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --patch-with-stat"}, {"role": "assistant", "content": "Synonym for -p --stat ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why does Git use a colon (:<branch>) to delete remote branches?\nWhy does Git use\ngit push <remote> :<branch>\n\nas in\ngit push origin :featureA\n\nto delete the branch featureA from the remote server?\nI am interested in why the colon was used as the delete flag.\nIt's so different from git branch -d <localbranch>.\nWhy don't we do something like\ngit branch -d --remote origin <branchname>\n\nor is there a deeper meaning behind the colon symbol that I didn't know?"}, {"role": "assistant", "content": "It is not the meaning of the : per se, but what is present, or rather absent before it.\nThe refspec format is\n<+><source>:<destination>\n\n(optional + for non-fast forward)\nSo when you do something like git push origin :featureA, you are specifying an empty source ref and basically making the destination \"empty\" or deleting it.\nPS: Note that the refspec of : or nothing doesn't mean push nothing to nothing however. It makes git to push \"matching\" branches: for every branch that exists on the local side, the remote side is updated if a branch of the same name already exists on the remote side."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker GIT_TRACE_FSMONITOR"}, {"role": "assistant", "content": "Enables trace messages for the filesystem monitor extension.\nSee GIT_TRACE for available trace output options."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Copy/fork a git repo on github into same organization\n\nI have a repo on github that contains a web application that's deployed to two different domains. The application has slight logic forks here and there to behave differently depending on which domain it's deployed to.\nIt's come to the point to where I want to split it into two separate repos, one for each domain.\nGithub won't let me fork it into the same organization. Searching for \"git duplicate repo\" suggests I should bare clone and mirror push it, but that seems to be for keeping both repos in sync, which I don't want to do.\nWhat's the best way to go about this? I'd like to preserve the old commit history in the new copy if possible."}, {"role": "assistant", "content": "Just create a new repository and push to it from your working copy:\ngit clone [email protected]:me/myrepo-original\ncd myrepo-original\ngit remote set-url origin [email protected]:me/myrepo-new\ngit push origin master\n\nNow you have a new repository, myrepo-new, which is identical to myrepo-original."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "key_load_public: invalid format\n\nI used PuTTY Key Generator to generate a 4096 bit RSA-2 key with a passphrase.\nI save the .ppk and an openSSL format public key. The putty format public key doesn't work.\nIn any case, my error is as follows:\n$ ssh -T [email protected]\nkey_load_public: invalid format\nEnter passphrase for key '/c/Users/Dan/.ssh/id_rsa':\nHi Dan! You've successfully authenticated, but GitHub does not provide shell access.\n\nWhat's the issue?\nI use Pageant to load the keys and i use Git Bash to try the ssh connection. I've also loaded the key into GitHub, not sure what i'm doing wrong.\nI've tried adding a new line and not adding a new line in GitHub"}, {"role": "assistant", "content": "As Roland mentioned in their answer, it's a warning that the ssh-agent doesn't understand the format of the public key and even then, the public key will not be used locally.\nHowever, I can also elaborate and answer why the warning is there. It simply boils down to the fact that the PuTTY Key Generator generates two different public key formats depending on what you do in the program.\nNote: Throughout my explanation, the key files I will be using/generating will be named id_rsa with their appropriate extensions. Furthermore, for copy-paste convenience, the parent folder of the keys will be assumed to be ~/.ssh/. Adjust these details to suit your needs as desired.\nThe Formats\nLink to the relevant PuTTY documentation\nSSH-2\nWhen you save a key using the PuTTY Key Generator using the \"Save public key\" button, it will be saved in the format defined by RFC 4716.\nExample:\n---- BEGIN SSH2 PUBLIC KEY ----\nComment: \"github-example-key\"\nAAAAB3NzaC1yc2EAAAABJQAAAQEAhl/CNy9wI1GVdiHAJQV0CkHnMEqW7+Si9WYF\ni2fSBrsGcmqeb5EwgnhmTcPgtM5ptGBjUZR84nxjZ8SPmnLDiDyHDPIsmwLBHxcp\npY0fhRSGtWL5fT8DGm9EfXaO1QN8c31VU/IkD8niWA6NmHNE1qEqpph3DznVzIm3\noMrongEjGw7sDP48ZTZp2saYVAKEEuGC1YYcQ1g20yESzo7aP70ZeHmQqI9nTyEA\nip3mL20+qHNsHfW8hJAchaUN8CwNQABJaOozYijiIUgdbtSTMRDYPi7fjhgB3bA9\ntBjh7cOyuU/c4M4D6o2mAVYdLAWMBkSoLG8Oel6TCcfpO/nElw==\n---- END SSH2 PUBLIC KEY ----\n\nOpenSSH\nContrary to popular belief, this format doesn't get saved by the generator. However it is generated and shown in the text box titled \"Public key for pasting into OpenSSH authorized_keys file\". To save it as a file, you have to manually copy it from the text box and paste it into a new text file.\nFor the key shown above, this would be:\nssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAhl/CNy9wI1GVdiHAJQV0CkHnMEqW7+Si9WYFi2fSBrsGcmqeb5EwgnhmTcPgtM5ptGBjUZR84nxjZ8SPmnLDiDyHDPIsmwLBHxcppY0fhRSGtWL5fT8DGm9EfXaO1QN8c31VU/IkD8niWA6NmHNE1qEqpph3DznVzIm3oMrongEjGw7sDP48ZTZp2saYVAKEEuGC1YYcQ1g20yESzo7aP70ZeHmQqI9nTyEAip3mL20+qHNsHfW8hJAchaUN8CwNQABJaOozYijiIUgdbtSTMRDYPi7fjhgB3bA9tBjh7cOyuU/c4M4D6o2mAVYdLAWMBkSoLG8Oel6TCcfpO/nElw== github-example-key\n\nThe format of the key is simply ssh-rsa <signature> <comment> and can be created by rearranging the SSH-2 formatted file.\nRegenerating Public Keys\nIf you are making use of ssh-agent, you will likely also have access to ssh-keygen.\nIf you have your OpenSSH Private Key (id_rsa file), you can generate the OpenSSH Public Key File using:\nssh-keygen -f ~/.ssh/id_rsa -y > ~/.ssh/id_rsa.pub\n\nIf you only have the PUTTY Private Key (id_rsa.ppk file), you will need to convert it first.\n\nOpen the PuTTY Key Generator\nOn the menu bar, click \"File\" > \"Load private key\"\nSelect your id_rsa.ppk file\nOn the menu bar, click \"Conversions\" > \"Export OpenSSH key\"\nSave the file as id_rsa (without an extension)\n\nNow that you have an OpenSSH Private Key, you can use the ssh-keygen tool as above to perform manipulations on the key.\nBonus: The PKCS#1 PEM-encoded Public Key Format\nTo be honest, I don't know what this key is used for as I haven't needed it. But I have it in my notes I've collated over the years and I'll include it here for wholesome goodness. The file will look like this:\n-----BEGIN RSA PUBLIC KEY-----\nMIIBCAKCAQEAhl/CNy9wI1GVdiHAJQV0CkHnMEqW7+Si9WYFi2fSBrsGcmqeb5Ew\ngnhmTcPgtM5ptGBjUZR84nxjZ8SPmnLDiDyHDPIsmwLBHxcppY0fhRSGtWL5fT8D\nGm9EfXaO1QN8c31VU/IkD8niWA6NmHNE1qEqpph3DznVzIm3oMrongEjGw7sDP48\nZTZp2saYVAKEEuGC1YYcQ1g20yESzo7aP70ZeHmQqI9nTyEAip3mL20+qHNsHfW8\nhJAchaUN8CwNQABJaOozYijiIUgdbtSTMRDYPi7fjhgB3bA9tBjh7cOyuU/c4M4D\n6o2mAVYdLAWMBkSoLG8Oel6TCcfpO/nElwIBJQ==\n-----END RSA PUBLIC KEY-----\n\nThis file can be generated using an OpenSSH Private Key (as generated in \"Regenerating Public Keys\" above) using:\nssh-keygen -f ~/.ssh/id_rsa -y -e -m pem > ~/.ssh/id_rsa.pem\n\nAlternatively, you can use an OpenSSH Public Key using:\nssh-keygen -f ~/.ssh/id_rsa.pub -e -m pem > ~/.ssh/id_rsa.pem\n\n##References:##\n\n\"key_load_public: invalid format...\" on AskUbuntu\nThe Secure Shell (SSH) Public Key File Format\nConverting OpenSSH public keys"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Deleting remote master branch, refused due to being the current branch\n\nHow do I delete a remote master branch from GitHub/Bitbucket?\nI'm trying:\n# git push bb --delete master\nremote: bb/acl: user is allowed. accepted payload.[K\nremote: error: refusing to delete the current branch: refs/heads/master[K\nTo ssh://[email protected]/user/reponame.git\n ! [remote rejected] master (deletion of the current branch prohibited)\nerror: failed to push some refs to 'ssh://[email protected]/user/reponame.git' \n\nAlso I tried\ngit push bb :master\n\nBut all this does not work."}, {"role": "assistant", "content": "Note: for Bitbucket, you would change the default branch by accessing the settings of your repository, and changing the branch at the \"Main branch\" combo box.\n\nOnce the main branch is no longer master, then you can push and remove master.\nMarsAndBack confirms in the comments this applies to GitHub as well."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker"}, {"role": "assistant", "content": "Reporting Bugs Report bugs to the Git mailing list < git@vger.kernel.org > where the\ndevelopment and maintenance is primarily done. You do not have to be\nsubscribed to the list to send a message there. See the list archive\nat https://lore.kernel.org/git for previous bug reports and other\ndiscussions. Issues which are security relevant should be disclosed privately to\nthe Git Security mailing list < git-security@googlegroups.com >."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-ls-files - Show information about files in the index and the working tree --error-unmatch"}, {"role": "assistant", "content": "If any <file> does not appear in the index, treat this as an\nerror (return 1)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --pickaxe-regex"}, {"role": "assistant", "content": "Treat the <string> given to -S as an extended POSIX regular\nexpression to match."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Get the creation date of a stash\nIs there a way to tell when a stash was created?\ngit stash list only lists the stashes, and git stash show XXXXXX shows all the files and changes, but not the date of the stash creation."}, {"role": "assistant", "content": "Try:\ngit stash list --date=local\n\nIt should print something like:\nstash@{Thu Mar 21 10:30:17 2013}: WIP on master: 2ffc05b Adding resource"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitHub: How to do case sensitive search for the code in repository?\nI want to do a case sensitive search for a particular piece of code in a GitHub repository. Is it possible?\nI checked https://help.github.com/articles/searching-code/ and didn't find such a syntax rule."}, {"role": "assistant", "content": "Say you want results for my_var but not MY_VAR, My_Var, etc. Use this regex search:\n/(?-i)my_var/\n\nThe -i flag here is essentially the opposite of the same grep option (grep is case-sensitive by default and -i makes it case-insensitive).\nThis was a new option included in the 2023 rollout of GitHub's Code Search feature. See the announcement blog post and the official syntax documentation."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-parse - Pick out and massage parameters"}, {"role": "assistant", "content": "SYNOPSIS git rev-parse [<options>] <arg>…​"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why does my git history look like a christmas tree?\nWhen doing git log --decorate --oneline --graph in one of our repositories shortly before Christmas, we found that the following structure had appeared (rotated to emphasize the tenuous festive theme):\n\nHow did this pattern in the commit graph arise?\nThis is deliberately somewhat silly, of course, but there's a interesting point here — it's often difficult to see how to interpret particular patterns in the commit graph when you see them in you git history browser."}, {"role": "assistant", "content": "In this case the situation was that there was an unpushed commit at the tip of the master branch in one clone of the repository. Then git pull was run many times in the same repository, over a period of time when there was lots of new work being done upstream. (In this case, it happened because of an automated script, but the same thing can happen if a developer just pulls repeatedly into a branch in order to keep it up-to-date, rather than, say, rebasing.)\nEvery pull when there were new commits upstream created a new merge commit, since there was always a commit in master that wasn't in master upstream.\nEventually, the history from the master branch in this repository was pushed upstream, so other developers saw this structure in the commit graph suddenly appear when they next pulled from the upstream repository.\nIf you have some history with a similar structure, and want to find out which commit / developer it was that caused this problem, you can just look down the line with the stars (basically following the first parent of every merge) until you get to the first non-merge commit. In the case in the picture, that was b275805 — the commit that should have been pushed earlier.\nThis is one reason people often prefer to use git pull --rebase — it keeps your unpushed history simple.\nTo give credit where it's due, my colleague Matthew Somerville spotted this and worked out what was going on."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options diff.statGraphWidth"}, {"role": "assistant", "content": "Limit the width of the graph part in --stat output. If set, applies\nto all commands generating --stat output except format-patch."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I check out a GitHub pull request with git?\nI'd like to check out a previously created pull request (created via GitHub web interface). I searched and found different places where a refs/pull or refs/pull/pr\nBut when I add fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to the git config file and do a git fetch\nWhat I'm doing wrong? Should GitHub create automatically the pull/xyz stuff, or do I have to configure something?"}, {"role": "assistant", "content": "To fetch a remote PR into your local repo,\ngit fetch origin pull/$ID/head:$BRANCHNAME\n\nwhere $ID is the pull request id and $BRANCHNAME is the name of the new branch that you want to create. Once you have created the branch, then simply\ngit checkout $BRANCHNAME\n\nFor instance, let's imagine you want to checkout pull request #2 from the origin main branch:\ngit fetch origin pull/2/head:MASTER\n\nSee the official GitHub documentation for more."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %(describe[:<options>])"}, {"role": "assistant", "content": "human-readable name, like git-describe ; empty string for\nundescribable commits. The describe string may be followed by a colon and\nzero or more comma-separated options. Descriptions can be inconsistent when\ntags are added or removed at the same time. tags[=<bool-value>] : Instead of only considering annotated tags,\nconsider lightweight tags as well. abbrev=<number> : Instead of using the default number of hexadecimal digits\n(which will vary according to the number of objects in the repository with a\ndefault of 7) of the abbreviated object name, use <number> digits, or as many\ndigits as needed to form a unique object name. match=<pattern> : Only consider tags matching the given glob(7) pattern, excluding the \"refs/tags/\" prefix. exclude=<pattern> : Do not consider tags matching the given glob(7) pattern, excluding the \"refs/tags/\" prefix."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %H"}, {"role": "assistant", "content": "commit hash"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-for-each-ref - Output information on each ref upstream"}, {"role": "assistant", "content": "The name of a local ref which can be considered “upstream”\nfrom the displayed ref. Respects :short , :lstrip and :rstrip in the same way as refname above. Additionally\nrespects :track to show \"[ahead N, behind M]\" and :trackshort to show the terse version: \">\" (ahead), \"<\"\n(behind), \"<>\" (ahead and behind), or \"=\" (in sync). :track also prints \"[gone]\" whenever unknown upstream ref is\nencountered. Append :track,nobracket to show tracking\ninformation without brackets (i.e \"ahead N, behind M\"). For any remote-tracking branch %(upstream) , %(upstream:remotename) and %(upstream:remoteref) refer to the name of the remote and the\nname of the tracked remote ref, respectively. In other words, the\nremote-tracking branch can be updated explicitly and individually by\nusing the refspec %(upstream:remoteref):%(upstream) to fetch from %(upstream:remotename) . Has no effect if the ref does not have tracking information associated\nwith it. All the options apart from nobracket are mutually exclusive,\nbut if used together the last option is selected."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc git diff [<options>] <commit> <commit>…​ <commit> [--] [<path>…​]"}, {"role": "assistant", "content": "This form is to view the results of a merge commit. The first\nlisted <commit> must be the merge itself; the remaining two or\nmore commits should be its parents. Convenient ways to produce\nthe desired set of revisions are to use the suffixes ^@ and ^! . If A is a merge commit, then git diff A A^@ , git diff A^! and git show A all give the same combined diff."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options core.protectHFS"}, {"role": "assistant", "content": "If set to true, do not allow checkout of paths that would\nbe considered equivalent to .git on an HFS+ filesystem.\nDefaults to true on Mac OS, and false elsewhere."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %>>( <N> ) , %>>|( <M> )"}, {"role": "assistant", "content": "similar to %>( <N> ) , %>|( <M> ) respectively, except that if the next\nplaceholder takes more spaces than given and\nthere are spaces on its left, use those\nspaces"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-reset - Reset current HEAD to the specified state Keep changes in working tree while discarding some previous commits"}, {"role": "assistant", "content": "Suppose you are working on something and you commit it, and then you\ncontinue working a bit more, but now you think that what you have in\nyour working tree should be in another branch that has nothing to do\nwith what you committed previously. You can start a new branch and\nreset it while keeping the changes in your working tree. $ git tag start\n$ git switch -c branch1\n$ edit\n$ git commit ... (1) $ edit\n$ git switch -c branch2 (2) $ git reset --keep start (3) This commits your first edits in branch1 . In the ideal world, you could have realized that the earlier\ncommit did not belong to the new topic when you created and switched\nto branch2 (i.e. git switch -c branch2 start ), but nobody is\nperfect. But you can use reset --keep to remove the unwanted commit after\nyou switched to branch2 ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fast-import - Backend for fast Git data importers get-mark cat-blob ls"}, {"role": "assistant", "content": "Require that the backend support the get-mark , cat-blob ,\nor ls command respectively.\nVersions of fast-import not supporting the specified command\nwill exit with a message indicating so.\nThis lets the import error out early with a clear message,\nrather than wasting time on the early part of an import\nbefore the unsupported command is detected."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git Interactive Merge?\nI have two branches with the exact same file (incase you are wondering it is a .sql file) and I want to interactively merge it.\nPretty much I want to open up a diff program like I do when there is a conflict (or command line) and select exactly what lines go where.\nIs there anyway to do this?"}, {"role": "assistant", "content": "Yes, but it will mostly be by manually making that happen. You'll tell Git you're merging the two relevant branches, but that it shouldn't try to commit the result on its own, (edited to add: nor fast-forward if it thinks the merge is trivial):\ngit merge --no-commit --no-ff branch-to-merge\n\nThen you'll ask git for the file as it appeared in the two branches:\ngit show HEAD:filename >filename.HEAD\ngit show branch-to-merge:filename >filename.branch\n\nand their merge base,\ngit show `git merge-base HEAD branch-to-merge`:filename >filename.base\n\nYou'll merge them using whatever tool you want (e.g.)\nmeld filename.{HEAD,branch,base}\n\nyou'll stage that (git add filename), and then commit the merge (git commit)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How well does Git LFS handle small files?\nIs there a best practice for the type files stored in Git LFS? Specifically for the minimum size?\nFor instance, a 10mb music file would be a obvious fit, but what about a 25kb png? Is it worth putting in LFS or it better to just let Git handle it?\nMy concern is performance degradation when checking too many small files into an LFS repo. Is there any data on how the LFS extension stands up to a bunch of smaller binary files? Is it advisable to only store files over a certain size threshold?"}, {"role": "assistant", "content": "I would not expect a an exact threshold value being given.\nLFS saves on the amount of data the needs to be exchanged for for synchronizing with a remote repository. However, the saving only applies as long as the large file itself is not changing. Actually for a changed file you would need a second rountrip to process the change on an LFS object.\nSo, you may include smaller files with LFS if in your use case those are not changing (frequently). The specific break even will depend on the I/O speed of the server and mostly on the latency and throughput between repository and client.\nIn your example, I'd still expect improvements in case the pngs are close to never changing. As soon as they are going to change (almost) on each and every commit even larger files might not benefit from being put to LFS. \nAlso the extra cost of second round trip will become less and less important the larger the typical files will be. Especially when the size of a file class (suffix) will vary over a broad range and/or the change frequency within a file class is covering a wide spectrum there might not be a clear answer to your question."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options submodule.alternateLocation"}, {"role": "assistant", "content": "Specifies how the submodules obtain alternates when submodules are\ncloned. Possible values are no , superproject .\nBy default no is assumed, which doesn’t add references. When the\nvalue is set to superproject the submodule to be cloned computes\nits alternates location relative to the superprojects alternate."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git branching: master vs. origin/master vs. remotes/origin/master\nI think I'm on the right track to understand the basic concepts of git.\nI've already set up and cloned a remote repository. I also created a server side empty repository, and linked my local repository to it.\nMy problem is that I don't understand the difference between:\n\norigin/master vs. remotes/origin/master\n\nAs far as I have understood, master is a local branch, and remotes/origin/master is a remote one. \nBut what exactly is origin/master?"}, {"role": "assistant", "content": "Take a clone of a remote repository and run git branch -a (to show all the branches git knows about). It will probably look something like this:\n* master\n remotes/origin/HEAD -> origin/master\n remotes/origin/master\n\nHere, master is a branch in the local repository. remotes/origin/master is a branch named master on the remote named origin. You can refer to this as either origin/master, as in:\ngit diff origin/master..master\n\nYou can also refer to it as remotes/origin/master:\ngit diff remotes/origin/master..master\n\nThese are just two different ways of referring to the same thing (incidentally, both of these commands mean \"show me the changes between the remote master branch and my master branch).\nremotes/origin/HEAD is the default branch for the remote named origin. This lets you simply say origin instead of origin/master."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects git show v1.0.0^{tree}"}, {"role": "assistant", "content": "Shows the tree pointed to by the tag v1.0.0 ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-branch - List, create, or delete branches --no-merged [<commit>]"}, {"role": "assistant", "content": "Only list branches whose tips are not reachable from the\nspecified commit (HEAD if not specified). Implies --list ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rm - Remove files from the working tree and from the index git rm -f git-*.sh"}, {"role": "assistant", "content": "Because this example lets the shell expand the asterisk\n(i.e. you are listing the files explicitly), it\ndoes not remove subdir/git-foo.sh ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git clone fails with \"index-pack\" failed?\nSo I created a remote repo that's not bare (because I need redmine to be able to read it),\nand it's set to be shared with the group (so git init --shared=group). I was able to push to the remote repo and now I'm trying to clone it. \nIf I clone it over the net I get this:\nremote: Counting objects: 4648, done.\nremote: Compressing objects: 100% (2837/2837), done.\nerror: git-upload-pack: git-pack-objects died with error.B/s \nfatal: git-upload-pack: aborting due to possible repository corruption on the remote side.\nremote: aborting due to possible repository corruption on the remote side.\nfatal: early EOF\nfatal: index-pack failed\n\nI'm able to clone it locally without a problem, and I ran \"git fsck\", which only reports some dangling trees/blobs, which I understand aren't a problem. What could be causing this? I'm still able to pull from it, just not clone. I should note the remote git version is 1.5.6.5 while local is 1.6.0.4\nI tried cloning my local copy of the repo, stripping out the .git folder and pushing to a new repo, then cloning the new repo and I get the same error, which leads me to believe it may be a file in the repo that's causing git-upload-pack to fail... \nEdit:\nI have a number of windows binaries in the repo, because I just built the python modules and then stuck them in there so everyone else didn't have to build them as well. If I remove the windows binaries and push to a new repo, I can clone again, perhaps that gives a clue. Trying to narrow down exactly what file is causing the problem now."}, {"role": "assistant", "content": "The way I solved this problem is this: My git daemon is running on windows, and clients are on other computers.\nI found a workaround (but it will only work on windows).\nStart git daemon with verbose from cmd.exe:\n\"C:\\Program Files\\Git\\bin\\sh.exe\" --login -i -c 'git.exe daemon --verbose '\n\nNot tested, if it works directly in git bash. Maybe it will.\nThen (before starting any clone, pull, fetch,...) select some text in the window (note: \"Quick Edit Mode\" must be enabled (can be found in: cmd.exe --> Properties (click the top left corner of your cmd window) --> Edit Options)) in which git daemon runs. That will prevent it from printing any further messages in that window.\nWhen the output thread of git daemon is blocked that way, then the error does not happen"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I push a part of my git repo to Heroku?\nI have a multi-module app that is already on Github. It is comprised of two modules, one of them an Android app and the other a Rails based Web app. So my project's directory structure is in the form of:\nProjectRoot\n|\n+-- web\n|\n+-- android\n|\n+-- .git\n\nAs such I cannot simply cd into ProjectRoot and push my app to Heroku as the root folder of the Rails app is ProjectRoot/web. Is there a way to push the web folder to Heroku? If I turn web into a git sub module, it should be easy to accomplish this, but then I only have 5 private repos on Git and I prefer to consume only 1 repo for my whole app."}, {"role": "assistant", "content": "You can use git subtree push. It will generate a new commit tree with your directory as root, and push it.\ngit subtree push --prefix web heroku master\n\nFull documentation is here."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to Integrate GitLab-Ci w/ Azure Kubernetes + Kubectl + ACR for Deployments?\n\nOur previous GitLab based CI/CD utilized an Authenticated curl request to a specific REST API endpoint to trigger the redeployment of an updated container to our service, if you use something similar for your Kubernetes based deployment this Question is for you.\n\nMore Background\nWe run a production site / app (Ghost blog based) on an Azure AKS Cluster. Right now we manually push our updated containers to a private ACR (Azure Container Registry) and then update from the command line with Kubectl.\nThat being said we previously used Docker Cloud for our orchestration and fully integrated re-deploying our production / staging services using GitLab-Ci.\nThat GitLab-Ci integration is the goal, and the 'Why' behind this question.\nMy Question\nSince we previously used Docker Cloud (doh, should have gone K8s from the start) how should we handle the fact that GitLab-Ci was able to make use of Secrets created the Docker Cloud CLI and then authenticate with the Docker Cloud API to trigger actions on our Nodes (ie. re-deploy with new containers etc).\nWhile I believe we can build a container (to be used by our GitLab-Ci runner) that contains Kubectl, and the Azure CLI, I know that Kubernetes also has a similar (to docker cloud) Rest API that can be found here (https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster) — specifically the section that talks about connecting WITHOUT Kubectl appears to be relevant (as does the piece about the HTTP REST API).\nMy Question to anyone who is connecting to an Azure (or potentially other managed Kubernetes service):\n\nHow does your Ci/CD server authenticate with your Kubernetes service provider's Management Server, and then how do you currently trigger an update / redeployment of an updated container / service?\n\nIf you have used the Kubernetes HTTP Rest API to re-deploy a service your thoughts are particularly value-able!\nKubernetes Resources I am Reviewing\n\nHow should I manage deployments with kubernetes\nKubernetes Deployments\n\nWill update as I work through the process."}, {"role": "assistant", "content": "Creating the integration\nI had the same problem of how to integrate the GitLab CI/CD with my Azure AKS Kubernetes cluster. I created this question because I was having some error when I tried to add my Kubernetes cluester info into GitLab.\nHow to integrate them:\n\nInside GitLab, go to \"Operations\" > \"Kubernetes\" menu.\nClick on the \"Add Kubernetes cluster\" button on the top of the page\nYou will have to fill some form fields, to get the content that you have to put into these fields, connect to your Azure account from the CLI (you need Azure CLI installed on your PC) using az login command, and then execute this other command to get the Kubernetes cluster credentials: az aks get-credentials --resource-group <resource-group-name> --name <kubernetes-cluster-name>\nThe previous command will create a ~/.kube/config file, open this file, the content of the fields that you have to fill in the GitLab \"Add Kubernetes cluster\" form are all inside this .kube/config file\n\nThese are the fields:\n\nKubernetes cluster name: It's the name of your cluster on Azure, it's in the .kube/config file too. \nAPI URL: It's the URL in the field server of the .kube/config file.\nCA Certificate: It's the field certificate-authority-data of the .kube/config file, but you will have to base64 decode it.\n\nAfter you decode it, it must be something like this:\n-----BEGIN CERTIFICATE-----\n...\nsome base64 strings here\n...\n-----END CERTIFICATE-----\n\n\nToken: It's the string of hexadecimal chars in the field token of the .kube/config file (it might also need to be base 64 decoded?). You need to use a token belonging to an account with cluster-admin privileges, so GitLab can use it for authenticating and installing stuff on the cluster. The easiest way to achieve this is by creating a new account for GitLab: create a YAML file with the service account definition (an example can be seen here under Create a gitlab service account in the default namespace) and apply it to your cluster by means of kubectl apply -f serviceaccount.yml.\nProject namespace (optional, unique): I leave it empty, don't know yet for what or where this namespace can be used.\n\nClick in \"Save\" and it's done. Your GitLab project must be connected to your Kubernetes cluster now.\nDeploy\nIn your deploy job (in the pipeline), you'll need some environment variables to access your cluster using the kubectl command, here is a list of all the variables available:\nhttps://docs.gitlab.com/ee/user/project/clusters/index.html#deployment-variables\nTo have these variables injected in your deploy job, there are some conditions:\n\nYou must have added correctly the Kubernetes cluster into your GitLab project, menu \"Operations\" > \"Kubernetes\" and these steps that I described above\nYour job must be a \"deployment job\", in GitLab CI, to be considered a deployment job, your job definition (in your .gitlab-ci.yml) must have an environment key (take a look at the line 31 in this example), and the environment name must match the name you used in menu \"Operations\" > \"Environments\".\n\nHere are an example of a .gitlab-ci.yml with three stages:\n\nBuild: it builds a docker image and push it to gitlab private registry\nTest: it doesn't do anything yet, just put an exit 0 to change it later\nDeploy: download a stable version of kubectl, copy the .kube/config file to be able to run kubectl commands in the cluster and executes a kubectl cluster-info to make sure it is working. In my project I didn't finish to write my deploy script to really execute a deploy. But this kubectl cluster-info command is executing fine.\n\nTip: to take a look at all the environment variables and their values (Jenkins has a page with this view, GitLab CI doesn't) you can execute the command env in the script of your deploy stage. It helps a lot to debug a job."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitLab CI Pipeline on specific branch only\nI'm trying to implement GitLab CI Pipelines to build and deploy an Angular app. In our project we have two general branches: master (for production only) and develop. For development we create feature/some-feature branches from develop branch. When development finished, we create merge request from feature/some-feature to develop. When merge request approved and merged into develop branch I want to run a Pipeline in order to build application and deploy the build on some environment.\nI use the following setup in .gitlab-ci.yml:\nimage: node:7.5-configured\n\nstages:\n - build\n - deploy\n\nbuild_job:\n stage: build\n only:\n - develop\n script:\n - /bin/bash <some script here>\n\n...\n\nThe problem is that Pipeline executed every time I push into any feature/some-feature branch. What's wrong with my setup? How can I force the Pipeline to be executed only when push performed into develop branch directly?\nSolution\nIt was my mistake - I had two different .gitlab-ci.yml files in develop branch and feature/some-feature branch."}, {"role": "assistant", "content": "Although it has been passed much time on this discussion I would like to suggest an opinion, which I am using most of the time.\nrules:\n - if: '$CI_PIPELINE_SOURCE == \"push\" && $CI_COMMIT_BRANCH == \"master\"'\n when: on_success\n changes:\n - folder/some_folder/**/* \n - if: '$CI_PIPELINE_SOURCE == \"web\" && $CI_COMMIT_BRANCH == \"development\"'\n when: manual\n changes:\n - folder/some_other_folder/**/* \n\nThis structure solved my various problems, I hope it helps you to!\nRegards."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git flow branches have diverged\nI'm using the git flow tools and I've gotten myself in a bit of problem. My git branches have diverged. I've read master branch and 'origin/master' have diverged, how to 'undiverge' branches'? and have tried to follow the steps, both attempting to merge and to rebase my local repository.\n $ git flow feature finish showFindLogs\n Branches 'develop' and 'origin/develop' have diverged.\n And branch 'develop' may be fast-forwarded.\n $ git merge origin/develop\n Already up-to-date.\n $ git rebase origin/develop\n Current branch feature/showFindLogs is up to date.\n $ git status\n # On branch feature/showFindLogs\n nothing to commit (working directory clean)\n\nHow can I get out of this? I'm done with the git flow feature and I'd just like to get my changes up to the remote. Thanks!"}, {"role": "assistant", "content": "What happens here is that the remote has received updates, and git-flow requires that develop and origin/develop to be at the same commit before merging back the feature. This is to prevent bad conflicts when publishing the branch.\nTo solve this, you need to:\n\nsync your local develop with origin: checkout develop, and pull from origin to develop (git checkout develop && git pull origin)\nrebase your feature on develop with git flow feature rebase showFindLogs. You may have conflicts here if you're unlucky\ncheck that it doesn't break anything\ngit flow feature finish showFindLogs"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "\"Make sure you configure your 'user.email' and 'user.name' in git\" when trying to push to git lab\nI keep getting the same message when I try to push to my git lab account: \n\n\"Make sure you configure your 'user.email' and 'user.name' in git\".\n\nI've already done \ngit config --global user.name \"John Doe\"\n\ngit config --global user.email \"[email protected]\"\n\nAnd I've checked w/\ngit remote -v\n\nAnyone have any ideas on what else I can do?"}, {"role": "assistant", "content": "Make sure you run this commands\ngit config --global user.name \"John Doe\"\n\ngit config --global user.email \"[email protected]\"\n\nIn the terminal. In this directory -I´m a Windows user-: C:\\Program Files\\Git\\bin\nHad the same issue. Solved running those commands there"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What's the difference between HEAD, working tree and index, in Git?\nCan someone tell me the difference between HEAD, working tree and index, in Git?\nFrom what I understand, they are all names for different branches. Is my assumption correct?\nI found this:\n\nA single git repository can track an arbitrary number of branches, but your working tree is associated with just one of them (the \"current\" or \"checked out\" branch), and HEAD points to that branch.\n\nDoes this mean that HEAD and working tree are always the same?"}, {"role": "assistant", "content": "A few other good references on those topics:\n\nMy Git Workflow\n\n\n\nI use the index as a checkpoint.\n\n\nWhen I'm about to make a change that might go awry — when I want to explore some direction that I'm not sure if I can follow through on or even whether it's a good idea, such as a conceptually demanding refactoring or changing a representation type — I checkpoint my work into the index.\nIf this is the first change I've made since my last commit, then I can use the local repository as a checkpoint, but often I've got one conceptual change that I'm implementing as a set of little steps.\nI want to checkpoint after each step, but save the commit until I've gotten back to working, tested code.\n\n\nNotes:\n\nthe workspace is the directory tree of (source) files that you see and edit.\n\nThe index is a single, large, binary file in <baseOfRepo>/.git/index, which lists all files in the current branch, their sha1 checksums, time stamps and the file name -- it is not another directory with a copy of files in it.\n\nThe local repository is a hidden directory (.git) including an objects directory containing all versions of every file in the repo (local branches and copies of remote branches) as a compressed \"blob\" file.\n\n\nDon't think of the four 'disks' represented in the image above as separate copies of the repo files.\n\n\nWhy Git is better than X\n\n\n\nGit Is Your Friend not a Foe Vol. 3: Refs and Index\n\n\nThey are basically named references for Git commits. There are two major types of refs: tags and heads.\n\nTags are fixed references that mark a specific point in history, for example v2.6.29.\nOn the contrary, heads are always moved to reflect the current position of project development.\n\n\n\n(note: as commented by Timo Huovinen, those arrows are not what the commits point to, it's the workflow order, basically showing arrows as 1 -> 2 -> 3 -> 4 where 1 is the first commit and 4 is the last)\n\nNow we know what is happening in the project.\nBut to know what is happening right here, right now there is a special reference called HEAD. It serves two major purposes:\n\nit tells Git which commit to take files from when you checkout, and\nit tells Git where to put new commits when you commit.\n\nWhen you run git checkout ref it points HEAD to the ref you’ve designated and extracts files from it. When you run git commit it creates a new commit object, which becomes a child of current HEAD. Normally HEAD points to one of the heads, so everything works out just fine."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fast-import - Backend for fast Git data importers --force"}, {"role": "assistant", "content": "Force updating modified existing branches, even if doing\nso would cause commits to be lost (as the new commit does\nnot contain the old commit)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --date=<format>"}, {"role": "assistant", "content": "Only takes effect for dates shown in human-readable format, such\nas when using --pretty . log.date config variable sets a default\nvalue for the log command’s --date option. By default, dates\nare shown in the original time zone (either committer’s or\nauthor’s). If -local is appended to the format (e.g., iso-local ), the user’s local time zone is used instead. --date=relative shows dates relative to the current time,\ne.g. “2 hours ago”. The -local option has no effect for --date=relative . --date=local is an alias for --date=default-local . --date=iso (or --date=iso8601 ) shows timestamps in a ISO 8601-like format.\nThe differences to the strict ISO 8601 format are: a space instead of the T date/time delimiter a space between time and time zone no colon between hours and minutes of the time zone --date=iso-strict (or --date=iso8601-strict ) shows timestamps in strict\nISO 8601 format. --date=rfc (or --date=rfc2822 ) shows timestamps in RFC 2822\nformat, often found in email messages. --date=short shows only the date, but not the time, in YYYY-MM-DD format. --date=raw shows the date as seconds since the epoch (1970-01-01\n00:00:00 UTC), followed by a space, and then the timezone as an offset\nfrom UTC (a + or - with four digits; the first two are hours, and\nthe second two are minutes). I.e., as if the timestamp were formatted\nwith strftime(\"%s %z\") ).\nNote that the -local option does not affect the seconds-since-epoch\nvalue (which is always measured in UTC), but does switch the accompanying\ntimezone value. --date=human shows the timezone if the timezone does not match the\ncurrent time-zone, and doesn’t print the whole date if that matches\n(ie skip printing year for dates that are \"this year\", but also skip\nthe whole date itself if it’s in the last few days and we can just say\nwhat weekday it was). For older dates the hour and minute is also\nomitted. --date=unix shows the date as a Unix epoch timestamp (seconds since\n1970). As with --raw , this is always in UTC and therefore -local has no effect. --date=format:... feeds the format ... to your system strftime ,\nexcept for %s, %z, and %Z, which are handled internally.\nUse --date=format:%c to show the date in your system locale’s\npreferred format. See the strftime manual for a complete list of\nformat placeholders. When using -local , the correct syntax is --date=format-local:... . --date=default is the default format, and is based on ctime(3)\noutput. It shows a single line with three-letter day of the week,\nthree-letter month, day-of-month, hour-minute-seconds in \"HH:MM:SS\"\nformat, followed by 4-digit year, plus timezone information, unless\nthe local time zone is used, e.g. Thu Jan 1 00:00:00 1970 +0000 ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Atom editor does not reload changed file\nI am using Atom editor on Windows 7. On the git shell when I run the command, git reset --hard , all the other editors reset/undo all the modified files. but if I am using ATOM editor, changes are retained. If I try to close the file in editor, Atom ask, file is changed, do you want to save the changes. \nHow can I force Atom to undo changes when files are modified externally."}, {"role": "assistant", "content": "According to https://discuss.atom.io/t/auto-reload-changed-files/8451/6, FileWatcher is an Atom package which will do what you want."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-parse - Pick out and massage parameters <rev>^{} , e.g. v0.99.8^{}"}, {"role": "assistant", "content": "A suffix ^ followed by an empty brace pair\nmeans the object could be a tag,\nand dereference the tag recursively until a non-tag object is\nfound."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git: Discard all changes on a diverged local branch\nI have a local topic branch that's tracking a remote branch. For the sake of argument, say the commit histories look like this:\nA--B--C--O1--O2--O3 (origin/phobos)\n \\\n L1--L2--L3 (phobos)\n\nHaving looked at the relative commit histories, I now want to discard all the changes to the local phobos branch and get it back to being a direct copy of origin/phobos, so that the local history looks like this:\nA--B--C--O1--O2--O3 (phobos origin/phobos)\n\nI really don't want the local changes to the phobos branch, and I really don't want any merges to show up in the origin repository afterwards. (So, just merging isn't what I have in mind.)\nThis seems like it should be really easy, but my google-fu has failed me. How do I do this?"}, {"role": "assistant", "content": "git checkout phobos\ngit reset --hard origin/phobos\n\nThis tells Git to reset the head of phobos to the same commit as origin/phobos, and to update the working tree to match."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-archive - Create an archive of files from a named tree git config tar.tar.xz.command \"xz -c\""}, {"role": "assistant", "content": "Configure a \"tar.xz\" format for making LZMA-compressed tarfiles.\nYou can use it specifying --format=tar.xz , or by creating an\noutput file like -o foo.tar.xz ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options diff.srcPrefix"}, {"role": "assistant", "content": "If set, git diff uses this source prefix. Defaults to \"a/\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "what is the difference between a gitlab runner and a gitlab agent?\n\nI'm new to Gitlab and Kubernetes and I'm wondering what the difference between a Gitlab runner and a Gitlab agent is.\nOn gitlab it says an agent is used to connect to the cluster, run pipelines, and deploy applications.\nBut with a regular runner you could just have a pipeline that invokes kubectl to interact with the cluster.\nWhat is possible with an agent that isn't with a runner using kubectl?"}, {"role": "assistant", "content": "The GitLab Agent (for Kubernetes) is the way GitLab interacts with the Kubernetes cluster (https://docs.gitlab.com/ee/user/clusters/agent/) and is used to allow GitLab to generate GitLab runners which are like Jenkins agents (https://docs.gitlab.com/runner/install/). Consider it like a broker or manager in this case. The agent would spawn the runners inside the cluster with the configuration you have setup.\nFor example, in my case, I have a node-pool dedicated specifically for gitlab runners. These nodes are more expensive to run, since they're higher-spec than the standard nodes used by the rest of the cluster, so I want to make sure only the GitLab runners spawn on there. I configure the Runner to have a node selector and toleration pointing at that specific node pool so the cluster scales up that node pool to put the runner on it.\nThe agent itself provides way more functionality than just spawning runners, but your question only asks about the GitLab agent and Runner. You can review the pages I've linked if you would like to find out more."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Github committing (push) gist\nI cannot understand this.\nI have created a gist. Then I run\n$ mkdir mygist\n$ cd mygist\n$ git init\n$ git pull [email protected]:869085.git\nThen I add files, change files and try to commit.\n$ git add .\n$ git commit -a -m \"Better comments\"\nThen I do not know how to send it back to github and commit this git."}, {"role": "assistant", "content": "It's probably easiest if you just start by cloning the gist, so that origin (a \"remote\" that refers to the original repository) is set up for you. Then you can just do git push origin master. For example:\ngit clone [email protected]:869085.git mygist\ncd mygist\n# Make your changes...\ngit add .\ngit commit -m \"Better comments\"\ngit push origin master\n\nHowever, if you don't want to redo your changes, you can do:\ncd mygist\ngit remote add origin [email protected]:869085.git\ngit fetch origin\n# Push your changes, also setting the upstream for master:\ngit push -u origin master\n\nStrictly speaking, the git fetch origin and -u argument to git push origin master are optional, but they will helpfully associate the upstream branch master in origin with your local branch master."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Differences between Commit, Commit and Push, Commit and Sync\nI'm using visual studio 2013, and I'm faced with 3 options for when I commit my C# code. I need an explanation of the differences between each of the options with regards to what happens to my local repo vs. the GitHub repo. \n\nOption 1 says Commit\nOption 2 says Commit and Push\nOption 3 says Commit and Sync\n\nI don't quite understand the difference between the last 2 options. When should I use Commit and Sync as opposed to Commit and Push?"}, {"role": "assistant", "content": "Commit will simply make record of your changes that you have made on your local machine. It will not mark the change in the remote repository.\nCommit and Push will do the above and push it to the remote repository. This means that any changes you have made will be saved to the remote repository as well.\nCommit and Sync does three things. First, it will commit. Second, it will perform a pull (grabs the updated information from the remote repo). Finally, it will push.\n\nSee more from Microsoft here"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options gc.worktreePruneExpire"}, {"role": "assistant", "content": "When git gc is run, it calls git worktree prune --expire 3.months.ago .\nThis config variable can be used to set a different grace\nperiod. The value \"now\" may be used to disable the grace\nperiod and prune $GIT_DIR/worktrees immediately, or \"never\"\nmay be used to suppress pruning."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options --get-urlmatch <name> <URL>"}, {"role": "assistant", "content": "When given a two-part <name> as <section>.<key>, the value for\n<section>.<URL>.<key> whose <URL> part matches the best to the\ngiven URL is returned (if no such key exists, the value for\n<section>.<key> is used as a fallback). When given just the\n<section> as name, do so for all the keys in the section and\nlist them. Returns error code 1 if no value is found."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "snap and gitlab-CI: error: cannot communicate with server: Post http://localhost/v2/snaps/hello-world\n\nIf I try to run snap under a gitlab-CI pipeline, installing the most simple package, it fails with:\n\n$ snap install hello-world\nerror: cannot communicate with server: Post\n http://localhost/v2/snaps/hello-world: dial unix /run/snapd.socket:\n connect: no such file or directory\n\nThe gitlab-ci yml configuration file is the simplest ever:\nimage: ubuntu:18.04\n\nbefore_script:\n - apt-get update -qq\n\ntest:\n script:\n - apt-get install -y snapd\n - snap version\n - snap install hello-world\n - hello-world\n\nWhat's going on?"}, {"role": "assistant", "content": "Unfortunately, snaps use many of the underlying security tech used by docker, and they don't play very nicely. Installing a snap also requires snapd to be running, which it's not in docker (hence the error). I'm afraid you simply cannot reliably install snaps in docker containers today.\nNote that there are other non-docker-based CI systems. You can, with a little custom work, use LXD as the backend for your GitLab CI runner, which handle snaps fine. You can also use GitHub Actions, which seem so be based on a Azure VM, which also handles snaps fine."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects plain"}, {"role": "assistant", "content": "Show words as [-removed-] and {+added+} . Makes no\nattempts to escape the delimiters if they appear in the input,\nso the output may be ambiguous."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-commit - Record changes to the repository --no-status"}, {"role": "assistant", "content": "Do not include the output of git-status in the\ncommit message template when using an editor to prepare the\ndefault commit message."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to see an HTML page on Github as a normal rendered HTML page to see preview in browser, without downloading?\n\nOn http://github.com developer keep the HTML, CSS, JavaScript and images files of the project. How can I see the HTML output in browser?\nFor example this: https://github.com/necolas/css3-social-signin-buttons/blob/master/index.html\nWhen I open this it doesn't show the rendered HTML of the code of author. It shows the page as a source code.\nIs it possible to see it as rendered HTML directly? Otherwise I always need to download the whole ZIP just to see the result."}, {"role": "assistant", "content": "New fork because the old project is abandoned; \nThe URLs are now (htmlpreview -> html-preview):\n\nhttps://html-preview.github.io/\nhttps://html-preview.github.io/?url=https://github.com/bartaz/impress.js/blob/master/index.html\n\n\npreviously:\nThe most comfortable way to preview HTML files on GitHub is to go to https://htmlpreview.github.io/ or just prepend it to the original URL, i.e.: https://htmlpreview.github.io/?https://github.com/bartaz/impress.js/blob/master/index.html"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I git clone --recursive and checkout master on all submodules in a single line?\nI really like this command to fetch a repo with submodules:\ngit clone [email protected]:my_user/my_repo.git --recursive\n\nHowever, the submodules are all set to \"no branch\" when they arrive, and I have to manually checkout master on each and every one. Is there a way to recursively pull submodules and automatically set the branch to master?"}, {"role": "assistant", "content": "After cloning the repository containing your submodules, the following command will checkout the master branch on all of these in one go:\ngit submodule foreach --recursive git checkout master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --no-notes"}, {"role": "assistant", "content": "Do not show notes. This negates the above --notes option, by\nresetting the list of notes refs from which notes are shown.\nOptions are parsed in the order given on the command line, so e.g.\n\"--notes --notes=foo --no-notes --notes=bar\" will only show notes\nfrom \"refs/notes/bar\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Updating and committing only a file's permissions using git version control\nJust turned an some.sh file into an executable (chmod 755 ...), the permissions were updated but not the content. Is there a way to commit the file into git, so that the executable bit will be restored/set on clone / checkout / pull ?\nUpdate: how can I track that the new permissions were submitted to github?"}, {"role": "assistant", "content": "@fooMonster article worked for me\n# git ls-tree HEAD\n100644 blob 55c0287d4ef21f15b97eb1f107451b88b479bffe script.sh\n\nAs you can see the file has 644 permission (ignoring the 100). We would like to change it to 755:\n# git update-index --chmod=+x script.sh\n\ncommit the changes\n# git commit -m \"Changing file permissions\"\n[master 77b171e] Changing file permissions\n0 files changed, 0 insertions(+), 0 deletions(-)\nmode change 100644 => 100755 script.sh"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git SSH public key authentication failed with git on Azure DevOps\nI am trying to push a git repo from PowerShell into an Azure DevOps repo, and I keep getting different auth errors when trying to push it.\nI am hoping somebody can shed some light on what I check, and do a proper walkthrough.\nE.g.,\ngit remote add origin [email protected]:v3/MyAzure/MyProject/MyRepo\ngit push -u origin --all\n\nI keep getting:\n\n[email protected]'s password:\n\nI've input all sorts of passwords, but it's still failing. Which password is it talking about?\nAlternatively, I've also gotten:\n\nPermission denied, please try again.\nfatal: Could not read from remote repository.\nPlease make sure you have the correct access rights and the repository exists.\n\nVerification:\n$ ssh -T [email protected]\nssh: connect to host mycompany.com port 22: Connection refused\n\nI have done the following:\n\nCreated a repo in Azure DevOps\nCreated a SSH key using git-bash, as per Microsoft's documentation, copied and pasted without spaces into Azure DevOps security.\nGone to my profile/security and added an SSH key (generated in git-bash)\n\nAm I missing the obvious? Is it better to use personal access token? Can anyone provide a walk through of the correct steps?"}, {"role": "assistant", "content": "Add these lines to ~/.ssh/config before any wildcard entry:\nHost ssh.dev.azure.com\n IdentityFile ~/.ssh/your_private_key\n IdentitiesOnly yes\n HostkeyAlgorithms +ssh-rsa\n PubkeyAcceptedKeyTypes=ssh-rsa\n\nThis link by @wcoder helped. Additionally, DevOps only allows deprecated ssh-rsa keys which new versions of OpenSSH now block\nFinally, in even more absurdity, if you have a wildcard entry (Host *) you will need to exclude DevOps from using any keys in that entry because DevOps will blindly accept the first key that the client provides 🤦🏻‍♂️:\nHost * !ssh.dev.azure.com\n ..."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to generate stats for a GitHub project?\nIs there an easy/efficient way to generate some high-level reports for a particular GitHub project? \ne.g. lines of code committed over time, top contributors, etc"}, {"role": "assistant", "content": "You can try applying gitstats to a cloned repo of your GitHub repo.\nSee for example the activity of the Git repo itself, with many data like the commits per year/month:\n\n\nSee also \"Looking at Git Statistics\", with the GitHub 'yearly_stats' for a simple little script.\n\nUpdate April 2013 (\"Get up to speed with Pulse\"):\nCheck out Pulse\n\nPulse is a great way to discover recent activity on projects.\n Maybe you haven't checked on your favorite repository in a while or you just discovered a project that looks interesting to you. \n Pulse will show you who has been actively committing and what has changed in a project's default branch:\n\n\nYou can find the link to the left of the nav bar."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-revert - Revert some existing commits --reference"}, {"role": "assistant", "content": "Instead of starting the body of the log message with \"This\nreverts <full-object-name-of-the-commit-being-reverted>.\",\nrefer to the commit using \"--pretty=reference\" format\n(cf. git-log ). The revert.reference configuration variable can be used to enable this option by\ndefault."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is there a \"theirs\" version of \"git merge -s ours\"?\nWhen merging topic branch \"B\" into \"A\" using git merge, I get some conflicts. I know all the conflicts can be solved using the version in \"B\".\nI am aware of git merge -s ours. But what I want is something like git merge -s theirs.\nWhy doesn't it exist? How can I achieve the same result after the conflicting merge with existing git commands? (git checkout every unmerged file from B)\nThe \"solution\" of just discarding anything from branch A (the merge commit point to B version of the tree) is not what I am looking for."}, {"role": "assistant", "content": "A similar alternative is the --strategy-option (short form -X) option, which accepts theirs. For example:\ngit checkout branchA\ngit merge -X theirs branchB\n\nHowever, this is more equivalent to -X ours than -s ours. The key difference being that -X performs a regular recursive merge, resolving any conflicts using the chosen side, whereas -s ours changes the merge to just completely ignore the other side.\nIn some cases, the main problem using -X theirs instead of the hypothetical -s theirs is deleted files. In this case, just run git rm with the name of any files that were deleted:\ngit rm {DELETED-FILE-NAME}\n\nAfter that, the -X theirs may work as expected.\nOf course, doing the actual removal with the git rm command will prevent the conflict from happening in the first place."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-am - Apply a series of patches from a mailbox --skip"}, {"role": "assistant", "content": "Skip the current patch. This is only meaningful when\nrestarting an aborted patch."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitmodules - Defining submodule properties submodule.<name>.shallow"}, {"role": "assistant", "content": "When set to true, a clone of this submodule will be performed as a\nshallow clone (with a history depth of 1) unless the user explicitly\nasks for a non-shallow clone."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Finding a branch point with Git?\nI have a repository with branches master and A and lots of merge activity between the two. How can I find the commit in my repository when branch A was created based on master?\nMy repository basically looks like this:\n-- X -- A -- B -- C -- D -- F (master) \n \\ / \\ /\n \\ / \\ /\n G -- H -- I -- J (branch A)\n\nI'm looking for revision A, which is not what git merge-base (--all) finds."}, {"role": "assistant", "content": "I was looking for the same thing, and I found this question. Thank you for asking it!\nHowever, I found that the answers I see here don't seem to quite give the answer you asked for (or that I was looking for) -- they seem to give the G commit, instead of the A commit.\nSo, I've created the following tree (letters assigned in chronological order), so I could test things out:\nA - B - D - F - G <- \"master\" branch (at G)\n \\ \\ /\n C - E --' <- \"topic\" branch (still at E)\n\nThis looks a little different than yours, because I wanted to make sure that I got (referring to this graph, not yours) B, but not A (and not D or E). Here are the letters attached to SHA prefixes and commit messages (my repo can be cloned from here, if that's interesting to anyone):\nG: a9546a2 merge from topic back to master\nF: e7c863d commit on master after master was merged to topic\nE: 648ca35 merging master onto topic\nD: 37ad159 post-branch commit on master\nC: 132ee2a first commit on topic branch\nB: 6aafd7f second commit on master before branching\nA: 4112403 initial commit on master\n\nSo, the goal: find B. Here are three ways that I found, after a bit of tinkering:\n\n1. visually, with gitk:\nYou should visually see a tree like this (as viewed from master):\n\nor here (as viewed from topic):\n\nin both cases, I've selected the commit that is B in my graph. Once you click on it, its full SHA is presented in a text input field just below the graph.\n\n2. visually, but from the terminal:\ngit log --graph --oneline --all\n(Edit/side-note: adding --decorate can also be interesting; it adds an indication of branch names, tags, etc. Not adding this to the command-line above since the output below doesn't reflect its use.)\nwhich shows (assuming git config --global color.ui auto):\n\nOr, in straight text:\n\n* a9546a2 merge from topic back to master\n|\\ \n| * 648ca35 merging master onto topic\n| |\\ \n| * | 132ee2a first commit on topic branch\n* | | e7c863d commit on master after master was merged to topic\n| |/ \n|/| \n* | 37ad159 post-branch commit on master\n|/ \n* 6aafd7f second commit on master before branching\n* 4112403 initial commit on master\n\nin either case, we see the 6aafd7f commit as the lowest common point, i.e. B in my graph, or A in yours.\n\n3. With shell magic:\nYou don't specify in your question whether you wanted something like the above, or a single command that'll just get you the one revision, and nothing else. Well, here's the latter:\ndiff -u <(git rev-list --first-parent topic) \\\n <(git rev-list --first-parent master) | \\\n sed -ne 's/^ //p' | head -1\n6aafd7ff98017c816033df18395c5c1e7829960d\n\nWhich you can also put into your ~/.gitconfig as (note: trailing dash is important; thanks Brian for bringing attention to that):\n[alias]\n oldest-ancestor = !zsh -c 'diff -u <(git rev-list --first-parent \"${1:-master}\") <(git rev-list --first-parent \"${2:-HEAD}\") | sed -ne \\\"s/^ //p\\\" | head -1' -\n\nWhich could be done via the following (convoluted with quoting) command-line:\ngit config --global alias.oldest-ancestor '!zsh -c '\\''diff -u <(git rev-list --first-parent \"${1:-master}\") <(git rev-list --first-parent \"${2:-HEAD}\") | sed -ne \"s/^ //p\" | head -1'\\'' -'\n\nNote: zsh could just as easily have been bash, but sh will not work -- the <() syntax doesn't exist in vanilla sh. (Thank you again, @conny, for making me aware of it in a comment on another answer on this page!)\nNote: Alternate version of the above:\nThanks to liori for pointing out that the above could fall down when comparing identical branches, and coming up with an alternate diff form which removes the sed form from the mix, and makes this \"safer\" (i.e. it returns a result (namely, the most recent commit) even when you compare master to master):\nAs a .git-config line:\n[alias]\n oldest-ancestor = !zsh -c 'diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent \"${1:-master}\") <(git rev-list --first-parent \"${2:-HEAD}\") | head -1' -\n\nFrom the shell:\ngit config --global alias.oldest-ancestor '!zsh -c '\\''diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent \"${1:-master}\") <(git rev-list --first-parent \"${2:-HEAD}\") | head -1'\\'' -'\n\nSo, in my test tree (which was unavailable for a while, sorry; it's back), that now works on both master and topic (giving commits G and B, respectively). Thanks again, liori, for the alternate form.\n\nSo, that's what I [and liori] came up with. It seems to work for me. It also allows an additional couple of aliases that might prove handy:\ngit config --global alias.branchdiff '!sh -c \"git diff `git oldest-ancestor`..\"'\ngit config --global alias.branchlog '!sh -c \"git log `git oldest-ancestor`..\"'\n\nHappy git-ing!"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --source"}, {"role": "assistant", "content": "Print out the ref name given on the command line by which each\ncommit was reached."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker --noglob-pathspecs"}, {"role": "assistant", "content": "Add \"literal\" magic to all pathspec. This is equivalent to setting\nthe GIT_NOGLOB_PATHSPECS environment variable to 1 . Enabling\nglobbing on individual pathspecs can be done using pathspec\nmagic \":(glob)\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker --bare"}, {"role": "assistant", "content": "Treat the repository as a bare repository. If GIT_DIR\nenvironment is not set, it is set to the current working\ndirectory."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --patience"}, {"role": "assistant", "content": "Generate a diff using the \"patience diff\" algorithm."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Max length of git branch name\n\nI want to understand what is maximum allowed size of a git branch name.\nI am trying to create some long names (as an experiment) so a name with 370 characters was valid, but 380 characters gave me fatal: Failed to lock ref for update: File name too long\nSo the questions are: what is the maximum number of characters that can be in git branch name? Does it depend on the system? Is it possible to create long branch name in a repository that will be rejected on remote repository (i.e. Github)?"}, {"role": "assistant", "content": "The 'File name too long' is indeed an error coming from your system. It is not a restriction in Git. I don't think there's a way of testing the maximum branch name lengths of other systems, like GitHub's, without experimenting - although I don't see why you would want to know...\n.\nSource: the error mentioned is thrown on line 291 of branch.c. \"File name too long\" is the standard description for the ENAMETOOLONG error."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-send-email - Send a collection of patches as emails"}, {"role": "assistant", "content": "EXAMPLES Use gmail as the smtp server To use git send-email to send your patches through the GMail SMTP server,\nedit ~/.gitconfig to specify your account settings: [sendemail]\n\tsmtpEncryption = tls\n\tsmtpServer = smtp.gmail.com\n\tsmtpUser = yourname@gmail.com\n\tsmtpServerPort = 587 If you have multi-factor authentication set up on your Gmail account, you can\ngenerate an app-specific password for use with git send-email . Visit https://security.google.com/settings/security/apppasswords to create it. Once your commits are ready to be sent to the mailing list, run the\nfollowing commands: $ git format-patch --cover-letter -M origin/master -o outgoing/\n$ edit outgoing/0000-*\n$ git send-email outgoing/* The first time you run it, you will be prompted for your credentials. Enter the\napp-specific or your regular password as appropriate. If you have credential\nhelper configured (see git-credential ), the password will be saved in\nthe credential store so you won’t have to type it the next time. Note: the following core Perl modules that may be installed with your\ndistribution of Perl are required:\nMIME::Base64, MIME::QuotedPrint, Net::Domain and Net::SMTP.\nThese additional Perl modules are also required:\nAuthen::SASL and Mail::Address."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitHub Error: Key already in use\nI have created two GitHub accounts. One for my work user and one for my personal self. I needed to do catch up on some work and as such cloned my work repo onto my personal PC. In order to do simple \"git push origin master\" commits without entering my username and password the whole time I simply want to add my public key from my home pc to the work repo. However Github gives this error:\nError: Key already use\n\nAfter a bit of Googling I came across this link which states \"To resolve the issue, remove the key from the other account or repository and add it to your account\" Of course there is a duplicate key as I've added my home public key to github so that I can code on my own personal projects. After all I want to be able to code to my work repo using both my work pc and personal pc.\nHow can you add multiple \"same\" public keys without Github throwing that error and also why in the world, is that error thrown in the first place?"}, {"role": "assistant", "content": "You can create one more key pair, say id_rsa_personal.pub, and add it to the Github account.\nNext, create/edit the .ssh/config file.\n# Default GitHub\nHost github.com\n HostName github.com\n User git\n IdentityFile ~/.ssh/id_rsa\n\nHost github-public\n HostName github.com\n User git\n IdentityFile ~/.ssh/id_rsa_public\n\nHost github-personal\n HostName github.com\n User git\n IdentityFile ~/.ssh/id_rsa_personal\n\nThe above file will help you to use more than one Github account. For background info, refer to the answers to this question.\nNext, you will need to alter your .git/config remote url to point to:\ngithub-personal:<gh_username>/<gh_reponame>.git\nRather than the usual:\n[email protected]:<gh_username>/<gh_reponame>.git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-tag - Create, list, delete or verify a tag object signed with GPG -l --list"}, {"role": "assistant", "content": "List tags. With optional <pattern>... , e.g. git tag --list\n'v-*' , list only the tags that match the pattern(s). Running \"git tag\" without arguments also lists all tags. The pattern\nis a shell wildcard (i.e., matched using fnmatch(3)). Multiple\npatterns may be given; if any of them matches, the tag is shown. This option is implicitly supplied if any other list-like option such\nas --contains is provided. See the documentation for each of those\noptions for details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-cat-file - Provide contents or details of repository objects --filters"}, {"role": "assistant", "content": "Show the content as converted by the filters configured in\nthe current working tree for the given <path> (i.e. smudge filters,\nend-of-line conversion, etc). In this case, <object> has to be of\nthe form <tree-ish>:<path> , or :<path> ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Gitlab-CI how to use artifacts in different pipeline\n\nCurrently, I have two main project.\n1-) Vue Project which contains (webviews for IOS and Android, websites, and renderer for our Electron ) they are sharing components & API's. \n2-) Electron Project which builds desktop app for (windows, darwin, linux) \ni would like to automate our building, releasing process. my current setup..\n before_script: \n - apt-get update\n - apt-get install zip unzip \n - rm -rf vue-project\n - git clone vue-project\n - cd vue-project\n - git checkout dev\n - git pull\n - sed -i \"/\\b\\(areaCode\\|inline-svg-loader\\)\\b/d\" ./packages/devtool/package.json\n - yarn install\n - ln -s vue-project/packages/desktop/ web\n - npm install\n\n build_darwin:\n stage: build\n script:\n - npm run package -- darwin --deploy\n cache:\n paths:\n - vue-project/node_modules\n - node_modules\n\nwhich basically before bundling electron project it's cloning vue-project install dependencies and bundling electron-renderer then when it's finish. i'm running package.\nI would like to separate this two different job from each other. is there anyway i could use artifacts from different project gitlab-CI pipelines ?\nany help would be an appreciated."}, {"role": "assistant", "content": "Gitlab has a API for do a lot of tricks.\ncurl --header \"PRIVATE-TOKEN:YOURPRIVATETOKEN\" \"https://gitlab.example.com/api/v4/projects/1/jobs/artifacts/master/download?job=test\"\n\nfor download it as a file.\ncurl --header \"PRIVATE-TOKEN:YOURPRIVATETOKEN\" -o artifacts.zip \"http://gitlab.example.net/api/v4/projects/<projectnumber>/jobs/artifacts/master/download?job=build_desktop"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -M[<n>] --find-renames[=<n>]"}, {"role": "assistant", "content": "Detect renames.\nIf n is specified, it is a threshold on the similarity\nindex (i.e. amount of addition/deletions compared to the\nfile’s size). For example, -M90% means Git should consider a\ndelete/add pair to be a rename if more than 90% of the file\nhasn’t changed. Without a % sign, the number is to be read as\na fraction, with a decimal point before it. I.e., -M5 becomes\n0.5, and is thus the same as -M50% . Similarly, -M05 is\nthe same as -M5% . To limit detection to exact renames, use -M100% . The default similarity index is 50%."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Gitlab CI runner configuration with cache on docker\n\nI can't seem to get the cache or the artifacts to carry over between jobs in gitlab CI. I suspect it's something to do with my configuration, but I'm not sure what. I'm running gitlab and gitlab-ci-multirunner, both in docker, using the following docker-compose config. I've left out the database config and some environment variables for brevity:\nversion: '2'\n\nservices:\n gitlab:\n image: sameersbn/gitlab:8.5.1\n links:\n - redis:redisio\n - postgresql:postgresql\n ports:\n - \"10080:80\"\n - \"10022:22\"\n environment:\n ...\n volumes:\n - gitlab_data:/home/git/data\n\n gitlab-ci-runner:\n restart: always\n image: gitlab/gitlab-runner\n volumes:\n - gitlab_runner_config_data:/etc/gitlab-runner\n - /var/run/docker.sock:/var/run/docker.sock\n - /etc/nginx/ssl/gitlab.crt:/etc/gitlab-runner/certs/ca.crt\n - /etc/ssh:/ssh\n links:\n - gitlab:gitlab\n\n redis:\n ...\n postgresql:\n ...\n\n\nvolumes:\n postgresql_data:\n redis_data:\n gitlab_data:\n gitlab_runner_config_data:\n\nThe runner configuration (config.toml) is:\nconcurrent = 1\n\n[[runners]]\n name = \"docker\"\n url = <public gitlab url>/ci \n token = <gitlab token>\n tls-ca-file = \"/etc/gitlab-runner/certs/ca.crt\"\n executor = \"docker\"\n [runners.docker]\n image = \"docker-bash\"\n volumes = [\"/var/run/docker.sock:/var/run/docker.sock\", \"/cache\"]\n\nThe docker-bash image referred to is just the official docker:1.10 image with bash installed.\nMy build process consists of 3 steps:\n\nRun npm install and the tests in the official node:5 image. For now, I've left this step out in order to test the deploy.\nBuild a docker image containing the code\nUse ansible, via a custome built ansible docker image to deploy the built image to the production server.\n\nThe .gitlab-ci.yml file looks like this:\nvariables:\n FULL_IMAGE_TAG: deploy-$CI_BUILD_REF_NAME:$CI_BUILD_ID-$CI_BUILD_REF\n IMAGE_FILE: deploy-$CI_BUILD_REF_NAME.tar.gz\n\ncache:\n paths:\n - $IMAGE_FILE\n\nbuild:\n stage: build\n script:\n - docker build -t $FULL_IMAGE_TAG .\n - docker save $FULL_IMAGE_TAG | gzip -cf - > $IMAGE_FILE\n artifacts:\n paths:\n - $IMAGE_FILE\n\ndeploy:\n stage: deploy\n image: ansible-ssh\n script:\n - ls\n - ansible-playbook -e image_file=$IMAGE_FILE -e branch=$CI_BUILD_REF_NAME -e full_image_name=$FULL_IMAGE_TAG deploy-playbook.yml\n only:\n - develop\n - master\n\nAs you can see, the compressed docker image is referred to here both in the cache and artifacts sections, but is not actually available in the deploy step, where ansible is supposed to copy it to the remote machine. I have tried including an ls command so check the folder contents and the file is clearly not there, but it is definitely built and I can download it from the gitlab UI. Here is the log from the deploy job:\ngitlab-ci-multi-runner 1.0.4 (014aa8c)\nUsing Docker executor with image ansible-ssh ...\nPulling docker image ansible-ssh ...\nWARNING: Cannot pull the latest version of image ansible-ssh : Error: image library/ansible-ssh not found\nWARNING: Locally found image will be used instead.\n\nRunning on runner-59d43cf3-project-8-concurrent-0 via 381c2ea97744...\nFetching changes...\nRemoving artifacts.zip\nRemoving deploy-develop.tar.gz\nHEAD is now at 6009bd0 test\nChecking out 6009bd0f as develop...\nHEAD is now at 6009bd0... test\n\n$ ls\nDockerfile\ndeploy-playbook.yml\nserver\n$ ansible-playbook -e image_file=$IMAGE_FILE -e branch=$CI_BUILD_REF_NAME -e full_image_name=$FULL_IMAGE_TAG deploy-playbook.yml\nUsing /etc/ansible/ansible.cfg as config file\n1 plays in deploy-playbook.yml\n\nPLAY ***************************************************************************\n\nTASK [setup] *******************************************************************\nok: [deploy-host]\n\nTASK [copy docker image] *******************************************************\ntask path: /builds/test/test/deploy-playbook.yml:44\nfatal: [deploy-host]: FAILED! => {\"changed\": false, \"failed\": true, \"msg\": \"could not find src=/builds/test/test/deploy-develop.tar.gz\"}\n\nNO MORE HOSTS LEFT *************************************************************\n to retry, use: --limit @deploy-playbook.retry\n\nPLAY RECAP *********************************************************************\ndeploy-host : ok=1 changed=0 unreachable=0 failed=1 \n\n\nERROR: Build failed with: exit code 1\n\nI suspect that I am not setting up or using the runner correctly, but I can't find much in the documentation for anything beyond really simple cases and I don't know the tool well enough to know how it all fits together under the hood."}, {"role": "assistant", "content": "Caching is not designed to pass files between stages of a build.\nFrom the doc\n\ncache : Define list of files that should be cached between subsequent\n runs\n\nI think what you need is in fact in progress : WIP: Download build artifacts from previous stages and restore them in context of the build (Technology Preview)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker gitformat-chunk"}, {"role": "assistant", "content": "Chunk-based file formats"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to share files across git repositories?\nI have several applications across sub domains on various servers. Each application has its own Git repository. Each application uses several shared files. Essentially, my repositories overlap.\nHow is this situation best handled with multiple editors of multiple projects?"}, {"role": "assistant", "content": "I would try making all the overlapping parts git submodules."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-worktree - Manage multiple working trees -n --dry-run"}, {"role": "assistant", "content": "With prune , do not remove anything; just report what it would\nremove."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %<( <N> [,trunc|ltrunc|mtrunc])"}, {"role": "assistant", "content": "make the next placeholder take at\nleast N column widths, padding spaces on\nthe right if necessary. Optionally\ntruncate (with ellipsis .. ) at the left (ltrunc) ..ft ,\nthe middle (mtrunc) mi..le , or the end\n(trunc) rig.. , if the output is longer than\nN columns.\nNote 1: that truncating\nonly works correctly with N >= 2.\nNote 2: spaces around the N and M (see below)\nvalues are optional.\nNote 3: Emojis and other wide characters\nwill take two display columns, which may\nover-run column boundaries.\nNote 4: decomposed character combining marks\nmay be misplaced at padding boundaries."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to properly rebase in SourceTree?\nSourceTree 1.6.4.0 on Windows 7.\nLet's say the following is my starting point: \n\n C <- master\n/\n- A - B <- topic\n\nI want to rebase topic onto master.\nMy goal is to have:\n C - A - B\n ^ ^\nmaster topic\n\nbut I end up with: \n\nI can then do\ngit push origin topic -f\n\nand I get the intended result, but what is the proper way to do this in SourceTree?"}, {"role": "assistant", "content": "Update: SourceTree 1.9.1\nYou can enable force push in Tools/Options/Git/Enable Force Push. After it is enabled you can check \"Force Push\" check box in the \"Push\" dialog.\nOriginal answer\nYou have to do a force push, because topic branch is already published and you are rewriting history. Commits A and B from origin/topic are removed if you rebase.\nYou should make a merge if you don't want to do a force push, specially if you have a team members already working on topic.\nYou can't do a force push with SourceTree for Windows yet (see answers at atlassian forums).\nYou can vote for this feature here: https://jira.atlassian.com/browse/SRCTREEWIN-338"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I get a gitlab pipeline to stop and ask me to input variables?\n\nI have created a pipeline in gitlab, with \nimage:\n name: hashicorp/terraform:light\n entrypoint:\n - '/usr/bin/env'\n - 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\n\nvariables:\n PLAN: dbrest.tfplan\n STATE: dbrest.tfstate\n\ncache:\n paths:\n - .terraform\n\nbefore_script:\n - terraform --version\n - terraform init\n\nstages:\n - validate\n - build\n - deploy\n - destroy\n\nvalidate:\n stage: validate\n script:\n - terraform validate\n\nplan:\n stage: build\n script:\n - terraform plan -state=$STATE -out=$PLAN\n artifacts:\n name: plan\n paths:\n - $PLAN\n - $STATE\n\napply:\n stage: deploy\n environment:\n name: production\n script:\n - terraform apply -state=$STATE -input=false $PLAN\n - terraform state show aws_instance.bastion\n dependencies:\n - plan\n when: manual\n only:\n - master\n\ndestroy:\n stage: destroy\n environment:\n name: production\n script:\n - terraform destroy -state=$STATE -auto-approve\n dependencies:\n - apply\n when: manual\n only:\n - master\n\nI have also created a variable under 'Settings. -> 'CI/CD' -> 'Variables' - I was under the impression that when I came to the manual stage deploy, gitlab should pause and ask me to input a value for that variable, but this does not happen - what is missing?"}, {"role": "assistant", "content": "You have mixed a job with when: manual to when you trigger a pipeline manually. This is the one you want:\nhttps://docs.gitlab.com/ee/ci/pipelines/#run-a-pipeline-manually\nYou could use this together with an only for some variable. Something like:\n...\napply:\n stage: deploy\n environment:\n name: production\n script:\n - terraform apply -state=$STATE -input=false $PLAN\n - terraform state show aws_instance.bastion\n dependencies:\n - plan\n only:\n refs:\n - master\n variables:\n - $RELEASE == \"yes\" \n\ndestroy:\n stage: destroy\n environment:\n name: production\n script:\n - terraform destroy -state=$STATE -auto-approve\n dependencies:\n - apply\n only:\n refs:\n - master\n variables:\n - $RELEASE == \"yes\" \n\nWith something like this, you can have jobs that are never run normally, but only if you manually start a new pipeline on the master branch and set the variable $RELEASE to yes. I haven't tested this, so my apologies if it doesn't work!"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Bots can't be created from Xcode Server hosted repository\nAfter creating a new repository on my Xcode Server, I can't access it by ssh, but I can perform both the git clone command and the git push command by using the https protocol. \nFurthermore I encounter the following error when I try to create a Xcode Bot:\nOct 25 12:43:46 mokii.com xcsbuildd[99898]: XCSCheckoutIntegrationStep.m:160 [XCSCheckoutIntegrationStep logUnderlyingErrorForError:]\n [SourceControl, Error] SSL error: received early EOF (-1)\nOct 25 12:43:46 mokii.com xcsbuildd[99898]: XCSCheckoutIntegrationStep.m:119 [XCSCheckoutIntegrationStep enqueueOperations]\n [SourceControl, Error] Error checkout/clone Error Domain=com.apple.dt.SourceControlErrorDomain Code=-1 \"SSL error: received early EOF (-1)\" UserInfo=0x7fcf244d3cd0 {com.apple.dt.sourcecontrol.UnderlyingErrorString=SSL error: received early EOF (-1), NSLocalizedDescription=SSL error: received early EOF (-1)}\nOct 25 12:43:46 mokii.com xcsbuildd[99898]: XCSIntegrationExecutor.m:229 [XCSIntegrationExecutor integrationStep:didFinishWithError:result:]\n [BuildService, Error] XCSCheckoutIntegrationStep finished integration with an error: Error Domain=com.apple.dt.SourceControlErrorDomain Code=-1 \"SSL error: received early EOF (-1)\" UserInfo=0x7fcf23e117f0 {com.apple.dt.sourcecontrol.UnderlyingErrorString=SSL error: received early EOF (-1), NSLocalizedDescription=SSL error: received early EOF (-1), XCSErrorFixItType=scm-failure}\n\nWhen I try to execute the git clone command the hosted repository in Terminal.app, another error occurs:\nlarryhou:repo larryhou$ git clone ssh://[email protected]/git/HostedRepo.git\nCloning into 'HostedRepo'...\nPassword:\nfatal: '/git/HostedRepo.git' does not appear to be a git repository\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\nAnd I can find additional information in the Console.app:\n Marker - Oct 25, 2014, 12:25:13 PM\nOct 25 12:25:15 --- last message repeated 1 time ---\nOct 25 12:25:15 mokii com.apple.xpc.launchd[1] (com.openssh.sshd.4EA7979A-127B-452C-832D-3A9A7FCB5A04): Service instances do not support events yet.\nOct 25 12:25:16 mokii.com kdc[380]: AS-REQ [email protected] from 127.0.0.1:62481 for krbtgt/[email protected]\nOct 25 12:25:16 --- last message repeated 1 time ---\nOct 25 12:25:16 mokii.com kdc[380]: Client sent patypes: REQ-ENC-PA-REP\nOct 25 12:25:16 mokii.com kdc[380]: user has no SRP keys\nOct 25 12:25:16 mokii.com kdc[380]: Need to use PA-ENC-TIMESTAMP/PA-PK-AS-REQ\nOct 25 12:25:16 mokii.com kdc[380]: AS-REQ [email protected] from 127.0.0.1:58943 for krbtgt/[email protected]\nOct 25 12:25:16 --- last message repeated 1 time ---\nOct 25 12:25:16 mokii.com kdc[380]: Client sent patypes: ENC-TS, REQ-ENC-PA-REP\nOct 25 12:25:16 mokii.com sandboxd[508] ([380]): kdc(380) deny file-read-data /private/etc/krb5.conf\nOct 25 12:25:16 mokii.com kdc[380]: ENC-TS pre-authentication succeeded -- [email protected]\nOct 25 12:25:16 mokii.com kdc[380]: DSUpdateLoginStatus: Unable to synchronize login time for jason: 77009 \nOct 25 12:25:17 mokii.com kdc[380]: Client supported enctypes: aes256-cts-hmac-sha1-96, aes128-cts-hmac-sha1-96, des3-cbc-sha1, arcfour-hmac-md5, using aes256-cts-hmac-sha1-96/aes256-cts-hmac-sha1-96\nOct 25 12:25:17 mokii.com kdc[380]: Requested flags: forwardable\nOct 25 12:25:17 mokii.com kdc[380]: TGS-REQ [email protected] from 127.0.0.1:60555 for host/[email protected] [canonicalize, forwardable]\nOct 25 12:25:17 mokii.com kdc[380]: TGS-REQ [email protected] from 127.0.0.1:59504 for host/[email protected] [forwardable]\nOct 25 12:25:17 mokii.com kdc[380]: TGS-REQ [email protected] from 127.0.0.1:49478 for ldap/[email protected] [canonicalize, forwardable]\nOct 25 12:25:17 mokii.com kdc[380]: TGS-REQ [email protected] from 127.0.0.1:58173 for ldap/[email protected] [forwardable]\nOct 25 12:25:17 mokii.com sshd[61715]: Accepted keyboard-interactive/pam for jason from 192.168.2.3 port 58668 ssh2\nOct 25 12:25:17 mokii.com sshd[61722]: Received disconnect from 192.168.2.3: 11: disconnected by user\nOct 25 12:25:17 mokii com.apple.xpc.launchd[1] (com.openssh.sshd.4EA7979A-127B-452C-832D-3A9A7FCB5A04[61715]): Service exited with abnormal code: 255"}, {"role": "assistant", "content": "You have got the SSH URL all wrong. You cannot use SSH simply by replacing the protocol and leave the URL in the same form as HTTPS. Here is a step by step guide for using SSH with Git on XCode Server and setting up the bots:\nhttp://ikennd.ac/blog/2013/10/xcode-bots-common-problems-and-workarounds/\nOne more that is a bit newer and might be more accurate:\nhttps://honzadvorsky.com/articles/2015-08-04-xcs_tutorials_1_getting_started/"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is there a way to increase the API Rate limit or to bypass it altogether for GitHub?\n\nI am developing a web application which needs to send a lot of HTTP requests to GitHub. After n number of successful requests, I get HTTP 403: Forbidden with the message API Rate Limit Exceeded.\nIs there a way to increase the API Rate limit or to bypass it altogether for GitHub?"}, {"role": "assistant", "content": "This is a relative solution, because the limit is still 5000 API calls per hour,\nor ~80 calls per minute, which is really not that much.\nI am writing a tool to compare over 350 repositories in an organization and\nto find their correlations.\nOk, the tool uses python for git/github access, but I think\nthat is not the relevant point, here.\nAfter some initial success, I found out that the capabilities of the GitHub API\nare too limited in # of calls and also in bandwidth, if you really want to ask\nthe repos a lot of deep questions.\nTherefore, I switched the concept, using a different approach:\nInstead of doing everything with the GitHub API, I wrote a GitHub Mirror script \nthat is able to mirror all of those repos in less than 15 minutes using my\nparallel python script via pygit2.\nThen, I wrote everything possible using the local repositories and pygit2.\nThis solution became faster by a factor of 100 or more, because there was neither an API nor a bandwidth bottle neck.\nOf course, this did cost extra effort, because the pygit2 API is quite a bit\ndifferent from github3.py that I preferred for the GitHub solution part.\nAnd that is actually my conclusion/advice:\nThe most efficient way to work with lots of Git data is:\n\nclone all repos you are interested in, locally\nwrite everything possible using pygit2, locally\nwrite other things, like public/private info, pull requests, access to\nwiki pages, issues etc. using the github3.py API or what you prefer.\n\nThis way, you can maximize your throughput, while your limitation is now the\nquality of your program. (also non-trivial)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git discard all changes and pull from upstream\nHow do I fetch upstream repo and make it replace master? I only have one branch on my repo, which is master, and I completely messed it up, so I basically need to start over from the upstream. I think init will do the job, but is there an easier way?"}, {"role": "assistant", "content": "There are (at least) two things you can do here–you can reclone the remote repo, or you can reset --hard to the common ancestor and then do a pull, which will fast-forward to the latest commit on the remote master.\nTo be concrete, here's a simple extension of Nevik Rehnel's original answer:\ngit reset --hard origin/master\ngit pull origin master\n\nNote:\n\nUsing git reset --hard will discard any uncommitted changes, and it can be easy to confuse yourself with this command if you're new to git, so make sure you have a sense of what it is going to do before proceeding.\n\nThis answer is pretty old, and main is often the branch name nowadays instead of master."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git how to rollback a rebase\nIn Git, how do you rollback a rebase if you're not happy with it?\nGit doesn't have dry-run for rebase. If I did a rebase and have not pushed it yet, how do I rollback to before, as if it never happened?"}, {"role": "assistant", "content": "You can use the reflog to find the first action before the rebase started and then reset --hard back to it. e.g.\n$ git reflog\n\nb710729 HEAD@{0}: rebase: some commit\n5ad7c1c HEAD@{1}: rebase: another commit\ndeafcbf HEAD@{2}: checkout: moving from master to my-branch\n...\n\n$ git reset HEAD@{2} --hard\n\nNow you should be back to before the rebase started.\nTo find the right place to reset to, you just pick the entry closest to the top that doesn't start with \"rebase\".\nUpdate: As mentioned in comments and other answers, you can also use ORIG_HEAD as an easier way to find where to reset to: git reset ORIG_HEAD --hard\nAlternative approach\nIf the rebase is the only thing you have done on the branch, i.e. you have no unpushed commits/changes - then you could just delete the local branch with git branch -D and then check it out again:\n$ git checkout my-branch\n$ git rebase master\n// not happy with the result\n$ git checkout master\n$ git branch -D my-branch\n$ git checkout my-branch\n\nOr for the same effect, you could reset --hard to the origin branch:\n$ git reset --hard origin/my-branch\n\nIf you did do this while you had other unpushed commits, then you will have lost them. In that case, just use the reflog approach above to jump back to the reflog entry where you made the commit(s)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options trace2.eventBrief"}, {"role": "assistant", "content": "Boolean. When true time , filename , and line fields are\nomitted from event output. May be overridden by the GIT_TRACE2_EVENT_BRIEF environment variable. Defaults to false."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is it possible to pull just one file in Git?\nI am working on a Git branch that has some broken tests, and I would like to pull (merge changes, not just overwrite) these tests from another branch where they are already fixed.\nI know I can do\ngit pull origin that_other_branch\n\nbut this will attempt to merge lots of other files, for that I am not yet ready.\nIs it possible to pull and merge only the specified file (and not everything) from that another branch?\nThis is not a duplicate of Git pull request for just one file as all answers to that question are how to revert the locally changed file to the repository version, without changing any branches."}, {"role": "assistant", "content": "Here is a slightly easier method I just came up with when researching this:\ngit fetch {remote}\ngit checkout FETCH_HEAD -- {file}"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-merge - Join two or more development histories together -X <option> --strategy-option=<option>"}, {"role": "assistant", "content": "Pass merge strategy specific option through to the merge\nstrategy."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options core.multiPackIndex"}, {"role": "assistant", "content": "Use the multi-pack-index file to track multiple packfiles using a\nsingle index. See git-multi-pack-index for more\ninformation. Defaults to true."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to configure Travis-CI to build pull requests & merges to master w/o redundancy\n\nTo put it in \"BDD\" terms:\n\nBackground: \n Given I'm contributing to a GH repo\nWhen I create a pull request\n Then Travis should build the latest commit\nWhen I push to an existing pull request\n Then Travis should build the latest commit\nWhen I merge a pull request to master \n Then Travis should build master\n\nI was confused by Travis-CI's \"build pushes\" and \"build PRs\" settings, as:\n\nEnabling both causes each Pull Request to be build twice by Travis\n\n\nonce for the commit on that branch\nand once again for the merge commit of that branch into its destination\n\nEnabling just \"build PRs\" causes PRs to be built, but doesn't result in post-merge builds (i.e. on master).\nEnabling \"pushes\" brute-force satisfies the above criteria by building all pushes to the repo. You can try to finagle things by white- & black-listing branches, but that will probably bite you unless you're rigorously disciplined with branch names.\n\nThis is explained more in Travis-CI docs and GH issue #3241.\nAnyone know a configuration that satisfies the above criteria?"}, {"role": "assistant", "content": "I eventually found another GH issue (#2111) which gave me the idea to try enabling both PRs & pushes, but with a whitelist to restrict pushes to a specific branch. This seems to satisfy the criteria for my workflow. Here's what I did:\n\nEnable both PRs & branch pushes in the Travis settings for the repo:\n\n\n\nChange .travis.yml to white-list master branch (i.e. only build pushes to master):\n\n\nbranches:\n only: \n - master\n\n\nTest it by creating a PR with the .travis.yml change, and another PR with some empty commits to verify it works for forks too.\nVerify successful merge commit build from master."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git under windows: MSYS or Cygwin?\nI plan to migrate my projects over to git, and I'm currently wondering which is the best and / or most stable option under windows.\nFrom what I gather I basically have 2.5 options:\n\nMSYSgit\ngit under Cygwin\n(aka 2.5) MSYSgit from a Cygwin prompt (given that Cygwin git is already installed).\n\nNote: IMO Cygwin in itself is a big plus as you can have access to pretty much all the *nix command line tools, as where with MSYSgit bash, you only have access to a rather small subset of these tools.\nGiven that, what option would you suggest?"}, {"role": "assistant", "content": "Edit (2 more years later: October 2014)\nJohannes Schindelin just explained (Oct. 2014) that msysgit is phased out:\n\nwe now have a light-weight Git for Windows SDK – which is essentially a standard MinGW/MSys system managed through the package manager mingw-get.\nWe decided to just phase out the name \"msysGit\" (as well as the GitHub org of the same name) and work on Git for Windows (with the corresponding GitHub org), and using the name \"Git for Windows\" for the installer aimed at \"end-users\" and \"Git for Windows SDK\" for the development environment targeting Git for Windows developers).\n\n\nEdit (3 years later: April 2012)\nMsysGit (now on GitHub) is the way to go if you want a light-weight fast start in Git world: unzip the archive, launch git-cmd.bat or git-bash.bat and you are done.\nIts latest release (1.7.10, April 2012) now includes support for UTF-8, also included in GitExtension.\nDon't forget to set your autocrlf to false though.\nIf you are really missing all the other unix commands not packages with msysgit, simply download a release of GoW (Gnu on Windows), aptly named \"The lightweight alternative to Cygwin\".\nI mean: 130 unix commands...\nCygwin should be a backup solution only for certain cases, like the transfer speed of large Git repositories, as mentioned below by incrementor in his answer.\n\nJune 2012: if you want to interact with GitHub, you now have http://windows.github.com (see also \"Designing GitHub for Windows\").\nIt not only will configure the ssh keys for you (and add the generated public key to your GitHub profile), but it will also install, for all git operations, a... MsysGit.\n\nOriginal answer (April 2009)\nI have no problem with the latest version of MsysGit:\nI use the option 2, which means I only add the git\\bin directory to the PATH environment variable, but without overriding some built-in windows tools.\nI managed to defined external tools like Notepad++ and WinMerge (or DiffMerge)\nI did run successfully scripts like svn2git because, from MsysGit1.6.2+, it does include the 'git svn' command.\nAnd finally I look forward to MsysGit1.6.2.3 for it will include finally 'git filter-branch' command! (a slow version of filter-branch, but still).\nFor the Unix command, I prefer to install a GnuWin32 coreutils package, and use them only when I need them.\nSo all in all, I do not use the Cygwin layer, and managed to run Git very well in its Windows-based release MsysGit."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options core.warnAmbiguousRefs"}, {"role": "assistant", "content": "If true, Git will warn you if the ref name you passed it is ambiguous\nand might match multiple refs in the repository. True by default."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to recover Git objects damaged by hard disk failure?\nI have had a hard disk failure which resulted in some files of a Git repository getting damaged. When running git fsck --full I get the following output:\nerror: .git/objects/pack/pack-6863e0a0e4b4ded6090fac5d12eba6ca7346b19c.pack SHA1 checksum mismatch\nerror: index CRC mismatch for object 6c8cae4994b5ec7891ccb1527d30634997a978ee from .git/objects/pack/pack-6863e0a0e4b4ded6090fac5d12eba6ca7346b19c.pack at offset 97824129\nerror: inflate: data stream error (invalid code lengths set)\nerror: cannot unpack 6c8cae4994b5ec7891ccb1527d30634997a978ee from .git/objects/pack/pack-6863e0a0e4b4ded6090fac5d12eba6ca7346b19c.pack at offset 97824129\nerror: inflate: data stream error (invalid stored block lengths)\nerror: failed to read object 0dcf6723cc69cc7f91d4a7432d0f1a1f05e77eaa at offset 276988017 from .git/objects/pack/pack-6863e0a0e4b4ded6090fac5d12eba6ca7346b19c.pack\nfatal: object 0dcf6723cc69cc7f91d4a7432d0f1a1f05e77eaa is corrupted\n\nI have backups of the repository, but the only backup that includes the pack file has it already damaged. So I think that I have to find out a way to retrieve the single objects from different backups and somehow instruct Git to produce a new pack with only correct objects.\nCan you please give me hints how to fix my repository?"}, {"role": "assistant", "content": "In some previous backups, your bad objects may have been packed in different files or may be loose objects yet. So your objects may be recovered.\nIt seems there are a few bad objects in your database. So you could do it the manual way.\nBecause of git hash-object, git mktree and git commit-tree do not write the objects because they are found in the pack, then start doing this:\nmv .git/objects/pack/* <somewhere>\nfor i in <somewhere>/*.pack; do\n git unpack-objects -r < $i\ndone\nrm <somewhere>/*\n\n(Your packs are moved out from the repository, and unpacked again in it; only the good objects are now in the database)\nYou can do:\ngit cat-file -t 6c8cae4994b5ec7891ccb1527d30634997a978ee\n\nand check the type of the object.\nIf the type is blob: retrieve the contents of the file from previous backups (with git show or git cat-file or git unpack-file; then you may git hash-object -w to rewrite the object in your current repository.\nIf the type is tree: you could use git ls-tree to recover the tree from previous backups; then git mktree to write it again in your current repository.\nIf the type is commit: the same with git show, git cat-file and git commit-tree.\nOf course, I would backup your original working copy before starting this process.\nAlso, take a look at How to Recover Corrupted Blob Object."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff-index - Compare a tree to the working tree or index files"}, {"role": "assistant", "content": "Compute the dirstat numbers by counting the number of files changed.\nEach changed file counts equally in the dirstat analysis. This is\nthe computationally cheapest --dirstat behavior, since it does\nnot have to look at the file contents at all."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.renameLimit"}, {"role": "assistant", "content": "The number of files to consider in the exhaustive portion of\ncopy/rename detection; equivalent to the git diff option -l . If not set, the default value is currently 1000. This\nsetting has no effect if rename detection is turned off."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitHub Actions: how to target all branches EXCEPT master?\nI want to be able to let an action run on any given branch except master.\nI am aware that there is a prebuilt filter action, but I want the exact opposite. \nMore like GitLab's except keyword. \nSince this is not inside the official docs, has anyone prepared a decent workaround?\nThank you very much."}, {"role": "assistant", "content": "Update:\nThere is a newer filter described in Samy's answer that provides a more succinct way of achieving this.\n\nThe documentation has been updated with more information now:\n\nWhen you specify a branches or tags filter, the workflow only runs if at least one pattern matches. Any changes to branches or tags that don't match a defined pattern will not trigger a workflow. The order that you define patterns matters:\n\n\nA matching negative pattern after a positive match will exclude the\nref again.\nA matching positive pattern after a negative match will\ninclude the ref again.\n\nSo in order to exclude master, you need to ensure that a pattern matching everything is included first:\non:\n push:\n branches: \n - '*' # matches every branch that doesn't contain a '/'\n - '*/*' # matches every branch containing a single '/'\n - '**' # matches every branch\n - '!master' # excludes master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-add - Add file contents to the index --pathspec-file-nul"}, {"role": "assistant", "content": "Only meaningful with --pathspec-from-file . Pathspec elements are\nseparated with NUL character and all other characters are taken\nliterally (including newlines and quotes)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Symfony2 - creating own vendor bundle - project and git strategy\nWe're considering creating our own common bundle for entity mapping and services for use within few separate apps. A bundle should be easy to modify, run, include and test. I know about Best Practices for Structuring Bundles, but I don't know what git strategy to use when it comes to development.\nShould we create common bundle as a whole project and commit whole repository to our git server, or is it better to start source control only for root of common bundle and push only its contents? I see this approach in bundles available on github, but I don't know easy and comfortable way to develop bundles that way."}, {"role": "assistant", "content": "Create a new empty symfony project\nphp composer.phar create-project symfony/framework-standard-edition demo/ 2.4.1\ncd demo\n\nGenerate a new bundle\n(for example src/Company/DemoBundle)\nphp app/console generate:bundle\ncd src/Company/DemoBundle/\n\nInit your github repository in src/Company/DemoBundle\ngit init\ntouch README.md\ngit add .\ngit commit -m \"initial commit\"\ngit remote add origin https://github.com/YourAccount/DemoBundle.git\ngit push -u origin master\n\nAdd a composer.json file\nsrc/Company/DemoBundle/composer.json:\n{\n \"name\" : \"company/demobundle\",\n \"description\" : \"A demo bundle\",\n \"type\" : \"symfony-bundle\",\n \"authors\" : [{\n \"name\" : \"demo\",\n \"email\" : \"[email protected]\"\n }],\n \"keywords\" : [\n \"demo bundle\"\n ],\n \"license\" : [\n \"MIT\"\n ],\n \"require\" : {\n },\n \"autoload\" : {\n \"psr-0\" : {\n \"Company\\\\DemoBundle\" : \"\"\n }\n },\n \"target-dir\" : \"Company/DemoBundle\",\n \"repositories\" : [{\n }],\n \"extra\" : {\n \"branch-alias\" : {\n \"dev-master\" : \"some_version-dev\"\n }\n }\n}\n\nNow you have the base structure of your bundle\nUse it in another project\ncomposer.json:\n [...]\n \"require\" : {\n [...]\n \"company/demobundle\" : \"dev-master\"\n },\n \"repositories\" : [{\n \"type\" : \"vcs\",\n \"url\" : \"https://github.com/Company/DemoBundle.git\"\n }],\n [...]\n\nDo:\ncurl -sS https://getcomposer.org/installer | php\nphp composer.phar update company/demobundle\n\napp/AppKernel:\nnew Company\\DemoBundle\\CompanyDemoBundle(),\n\nWork on it\n\nYou can clone your DemoBundle in the src/Company folder, then manually install it\nYou can use symlink\n\nConclusion\nYou can develop and test your bundle in your first project and use it with github and composer in your second project."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options status.showUntrackedFiles"}, {"role": "assistant", "content": "By default, git-status and git-commit show\nfiles which are not currently tracked by Git. Directories which\ncontain only untracked files, are shown with the directory name\nonly. Showing untracked files means that Git needs to lstat() all\nthe files in the whole repository, which might be slow on some\nsystems. So, this variable controls how the commands display\nthe untracked files. Possible values are: no - Show no untracked files. normal - Show untracked files and directories. all - Show also individual files in untracked directories. If this variable is not specified, it defaults to normal .\nAll usual spellings for Boolean value true are taken as normal and false as no .\nThis variable can be overridden with the -u|--untracked-files option\nof git-status and git-commit ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why am I seeing \"TypeError: string indices must be integers\"?\n\nI'm playing with both learning Python and am trying to get GitHub issues into a readable form. Using the advice on How can I convert JSON to CSV?, I came up with this:\nimport json\nimport csv\n\nf = open('issues.json')\ndata = json.load(f)\nf.close()\n\nf = open(\"issues.csv\", \"wb+\")\ncsv_file = csv.writer(f)\n\ncsv_file.writerow([\"gravatar_id\", \"position\", \"number\"])\n\nfor item in data:\n csv_file.writerow([item[\"gravatar_id\"], item[\"position\"], item[\"number\"]])\n\nWhere \"issues.json\" is the JSON file containing my GitHub issues. When I try to run that, I get\nTypeError: string indices must be integers\n\nWhat am I missing here? Which are the \"string indices\"?\nHere's a bit of my JSON content:\n{\"issues\": [{\"gravatar_id\": \"44230311a3dcd684b6c5f81bf2ec9f60\", \"position\": 2.0, \"number\": 263..."}, {"role": "assistant", "content": "The variable item is a string. An index looks like this:\n>>> mystring = 'helloworld'\n>>> print mystring[0]\n'h'\n\nThe above example uses the 0 index of the string to refer to the first character.\nStrings can't have string indices (like dictionaries can). So this won't work:\n>>> mystring = 'helloworld'\n>>> print mystring['stringindex']\nTypeError: string indices must be integers"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Update an outdated branch against master in a Git repo\nI have a Git repository that has branch (local and remote) that has become outdated. I would like to bring this branch up to date with the master branch, but I don't know how to do this. There will also probably be many merge conflicts. \nHow can I bring or update this out-of-date branch to the same state as the master branch?"}, {"role": "assistant", "content": "Update the master branch, which you need to do regardless.\nThen, one of:\n\nRebase the old branch against the master branch. Solve the merge conflicts during rebase, and the result will be an up-to-date branch that merges cleanly against master.\nMerge your branch into master, and resolve the merge conflicts.\nMerge master into your branch, and resolve the merge conflicts. Then, merging from your branch into master should be clean.\n\nNone of these is better than the other, they just have different trade-off patterns.\nI would use the rebase approach, which gives cleaner overall results to later readers, in my opinion, but that is nothing aside from personal taste.\nTo rebase and keep the branch you would:\ngit checkout <branch> && git rebase <target>\n\nIn your case, check out the old branch, then \ngit rebase master \n\nto get it rebuilt against master."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-branch - List, create, or delete branches branch.sort"}, {"role": "assistant", "content": "This variable controls the sort ordering of branches when displayed by git-branch . Without the \"--sort=<value>\" option provided, the\nvalue of this variable will be used as the default.\nSee git-for-each-ref field names for valid values."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I deal with this Git warning? \"Pulling without specifying how to reconcile divergent branches is discouraged\"\nAfter a git pull origin master, I get the following message:\nwarning: Pulling without specifying how to reconcile divergent branches is\ndiscouraged. You can squelch this message by running one of the following\ncommands sometime before your next pull:\n\n git config pull.rebase false # merge (the default strategy)\n git config pull.rebase true # rebase\n git config pull.ff only # fast-forward only\n\nYou can replace \"git config\" with \"git config --global\" to set a default\npreference for all repositories. You can also pass --rebase, --no-rebase,\nor --ff-only on the command line to override the configured default per\ninvocation.\n\nremote: Enumerating objects: 4, done.\nremote: Counting objects: 100% (4/4), done.\nremote: Compressing objects: 100% (4/4), done.\nremote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0\nUnpacking objects: 100% (4/4), 51.49 KiB | 850.00 KiB/s, done.\n\nThe pull seems successful, but I am unsure.\nWhat can I do to fix this?"}, {"role": "assistant", "content": "In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD.\n\nWhen you do a git pull origin master, \ngit pull performs a merge, which often creates a merge commit. Therefore, by default, pulling from the remote is not a harmless operation: it can create a new commit SHA hash value that didn’t exist before. This behavior can confuse a user, because what feels like it should be a harmless download operation actually changes the commit history in unpredictable ways.\nTo avoid this, you need\ngit pull --ff-only\n\n(or not? read on to see which one fits your requirements)\nWith git pull --ff-only, Git will update your branch only if it can be “fast-forwarded” without creating new commits. If this can’t be done, git pull --ff-only simply aborts with an error message.\nYou can configure your Git client to always use --ff-only by default, so you get this behavior even if you forget the command-line flag:\ngit config --global pull.ff only\n\nNote: The --global flag applies the change for all repositories on your machine. If you want this behaviour only for the repository you're in, omit the flag.\nTaken from here\n\n\n\nThis warning was added in Git 2.27.\nThis is what the complete warning looks like:\n\nPulling without specifying how to reconcile divergent branches is\ndiscouraged. You can squelch this message by running one of the following\ncommands sometime before your next pull: \ngit config pull.rebase false     # merge (the default strategy) \ngit config pull.rebase true      # rebase \ngit config pull.ff only               # fast-forward only \nYou can replace \"git config\" with \"git config --global\" to set a default\npreference for all repositories. You can also pass --rebase, --no-rebase,\nor --ff-only on the command line to override the configured default per\ninvocation.\n\nThe warning presents three commands as options, all of these will suppress the warning. But they serve different purposes:\ngit config pull.rebase false # merge (the default strategy)\n\nThis keeps the default behaviour and suppresses the warning.\ngit config pull.rebase true # rebase\n\nThis actually commits on top of the remote branch, maintaining a single branch both locally and remotely (unlike the default behaviour where two different branches are involved - one on local and the other on remote - and, to combine the two, a merge is performed).\ngit config pull.ff only # fast-forward only\n\nThis only performs the pull if the local branch can be fast-forwarded. If not, it simply aborts with an error message (and does not create any commits).\n\nUpdate 1: \nIf you have Git 2.29 or above, you can now set pull.ff to false, true or only to get rid of the warning.\ngit config pull.ff true\n\ntrue - This is the default behaviour. Pull is fast-forwarded if possible, otherwise it's merged.\ngit config pull.ff false\n\nfalse - Pull is never fast-forwarded, and a merge is always created.\ngit config pull.ff only\n\nonly - Pull is fast-forwarded if possible, otherwise operation is aborted with an error message.\n\nUpdate 2: \nThere was a bug in this newly implemented feature until version 2.35 where Git would show this warning even if the user passed one of the three flags with the git pull command. This has now been fixed, consider updating your Git to version 2.36 or above.\n\nNotes:\n\nRead this very well written answer by torek to get a much clearer picture on what actually happens behind the scene and to understand which option is the most appropriate option for you.\n\nYou may want to keep an eye on VonC's answer here for updates on changes made to this feature in future updates."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to put a label on an issue in GitHub if you are not a contributor / owner?\n\nI've submitted an issue for a project on GitHub which is not mine and I'm not a contributor, but I cannot find a way to label my issue. Is there a way for me to label it, or is this only available for contributors?"}, {"role": "assistant", "content": "It's only available for contributors.\nThis way, you can avoid random people assigning the wrong labels and messing up your categories.\nIt would however be useful if you could in some manner propose labels. Then you could mark an issue as what you think is a bug, so the owner can just confirm that. Many people suggest labels in the title: [proposed Label] actual title"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-send-email - Send a collection of patches as emails sendemail.<identity>.*"}, {"role": "assistant", "content": "Identity-specific versions of the sendemail.* parameters\nfound below, taking precedence over those when this\nidentity is selected, through either the command-line or sendemail.identity ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I see all the projects I'm watching on github?\n\nIs there a way to see a list of all projects I'm watching and maybe unwatch some in bulk?"}, {"role": "assistant", "content": "Make sure you're logged in and go to https://github.com/watching\nProfit! ;-)\n\nMore information about this and related features can be in the official announcement"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git Force push syntax, \"-f\" versus \"+branch\"\nWhat is the difference between these two git commands when force pushing changes?\ngit push -f origin branch and git push origin +branch"}, {"role": "assistant", "content": "TL;DR\nIf you're only pushing one branch, there is no difference.\ngit push -f origin branch\n\nand\ngit push origin +branch\n\nare exact equivalents. The difference arises when you're pushing more than one branch with a single git push.\nIn a nutshell, the optional + gives you finer control than -f does: if you're pushing more than one ref at a time, the + allows you to specify which of the pushed refs get force-pushed, whereas --force (or -f) applies to all the refs that are getting pushed.\nMore details\nWhat the git-push man page tells you\nThe most basic form of git push that involve one or more refspec(s) is\ngit push <repository> <refspec>...\n\nThe form that the <refspec>... argument must satisfy is described in the git-push man page thus:\n\n<refspec>...\nSpecify what destination ref to update with what source object. The\nformat of a `<refspec>` parameter is an optional plus `+`, followed by\nthe source object `<src>`, followed by a colon `:`, followed by the\ndestination ref `<dst>`.\n\n\nSo, just to be clear, the syntax for <refspec> is\n[+]<src>[:<dest>]\n\nIf :<dst> is omitted, the same ref as <src> will be updated... unless the remote.<repository>.push entry (if any) in your Git config says otherwise.\nFurther down in the git-push man page, you find\n\nBy having the optional leading +, you can tell Git to update the <dst>\n ref even if it is not allowed by default (e.g., it is not a\n fast-forward.) This does not attempt to merge <src> into <dst>.\n\nAnd still further down:\n\nNote that --force applies to all the refs that are pushed, hence\n using it with push.default set to matching or with multiple push\n destinations configured with remote.*.push may overwrite refs other\n than the current branch (including local refs that are strictly behind\n their remote counterpart). To force a push to only one branch, use a +\n in front of the refspec to push (e.g git push origin +master to force\n a push to the master branch).\n\nExample\nConsider a local repo with two branches, master and develop, which you want to push (with a single git push command) to an origin remote.\n\ngit push origin master develop will push both branches, but neither will get force-pushed.\ngit push origin +master develop will push both branches, but only master will get force-pushed. \ngit push origin master +develop , conversely, will push both branches, but only develop will get force-pushed.\ngit push origin +master +develop will force-push both branches. It's an exact equivalent to git push -f origin master develop."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to disambiguate an ambiguous abbreviated sha1 in git\nI was intrigued by Josh Stone's analysis of sha1 abbreviation collisions.\nLet's say somebody wrote down an abbreviated commit id, 8b82547e33, at a time when it was unambiguous. But since then other objects have been created with that same prefix, so that now git tells you (twice, for some reason):\n$ git show 8b82547e33\nerror: short SHA1 8b82547e33 is ambiguous.\nerror: short SHA1 8b82547e33 is ambiguous.\nfatal: ambiguous argument '8b82547e33': unknown revision or path not in the working tree.\nUse '--' to separate paths from revisions, like this:\n'git <command> [<revision>...] -- [<file>...]'\n\nNow, as a human, I could probably tell which object I meant if git would just show me the ambiguous objects. How can I achieve something like the following?\n$ git objects-starting-with 8b82547e33\n8b82547e33e: commit: l2tp: Restore socket refcount when sendmsg succeeds\n8b82547e338: tree [2 files, 26 subtrees]\n\n(Note: the above examples are using a relatively current clone of http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git.)"}, {"role": "assistant", "content": "You can use git rev-parse, assuming you have at least a 4-digit prefix of the full hash.\ngit rev-parse --disambiguate=8b82547e33"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to use rule in gitlab-ci\n\nI'm trying to build a job that can be conditionally executed depends on whether the files or subdirectories in WebClient is modified in develop branch, using rules. If there are changes found in the develop branch only, then a pipeline will be built.\nCurrently what I got in my .gitlab-ci.yml is\ndeploy_dev_client:\n stage: client\n tags:\n - my tags\n script:\n - '& cd WebClient'\n - 'npm rebuild node-sass'\n - 'npm install @angular/[email protected]'\n - '& npm run build-release --max_old_space_size=$NODE_MEMORY_SIZE'\n\n rules:\n - changes:\n - WebClient/**/*\n when: always\n - when: never\n\nHowever, after testing, I realized that the pipeline is executed whenever I push something from my local repo to gitlab, even at the other side branches.\nI have tried using only:-develop', however it results in yaml invalid error, maybe due to not being able to use only if rules has already been used. Is there anyway I can still using rules to target only develop branch?"}, {"role": "assistant", "content": "In this link:\nhttps://docs.gitlab.com/ee/ci/yaml/#ruleschanges\nThey write that rules: changes should work exactly like only/except. If you read about only/except, there are a few strange things with it:\nhttps://docs.gitlab.com/ee/ci/yaml/#using-onlychanges-without-pipelines-for-merge-requests\n\nWhen pushing a new branch or a new tag to GitLab, the policy always evaluates to true.\n\nTo get around this and only run your job on the development branch, you should be able to combine an if with changes:\ndeploy_dev_client:\n stage: client\n tags:\n - my tags\n script:\n - '& cd WebClient'\n - 'npm rebuild node-sass'\n - 'npm install @angular/[email protected]'\n - '& npm run build-release --max_old_space_size=$NODE_MEMORY_SIZE'\n\n rules:\n - if: '$CI_COMMIT_REF_NAME== \"development\"'\n changes:\n - WebClient/**/*\n when: always\n\n(I haven't tested this code, so let me know if it is all wrong!)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Warning: you are leaving 1 commit behind, not connected to any of your branches\nEGit strikes again. I made the mistake of trying to switch to a different branch in EGit and it somehow messed up and checked out no branch. I then made a commit to this non-branch, and then when I realized I wasn't tracking the right branch, I ran the following:\n$ git checkout issue2\nWarning: you are leaving 1 commit behind, not connected to any of your branches:\n\n bada553d My commit message\n\nIf you want to keep them by creating a new branch, this may be a good time to do so with:\n\n git branch new_branch_name ....\n\nBranch issue2 set up to track remote branch issue2 from origin.\nSwitched to a new branch issue2. \n\nNow that I've botched things, how do I associate that commit with my current branch? I'm not interested in creating a brand new branch, I just want to pull that commit into my branch, issue2."}, {"role": "assistant", "content": "you can git cherry-pick bada553d if it's just the one commit.\nYou can also reference anywhere you've been by using the reflog:\ngit reflog\n\nthen use one of those commits:\ngit checkout -b temp HEAD@{3}\n\nto checkout and make a branch temp from where your current commit was 3 \"times\" ago. It's a bread crumb of where you used to be."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git --incremental"}, {"role": "assistant", "content": "supported"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %e"}, {"role": "assistant", "content": "encoding"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How does origin/HEAD get set?\nI have a branch set up to track a ref in origin. git checkout <branchname> switches to that branch, and a git status will show me how far ahead or behind my branch is from origin, but I'm surprised that origin/HEAD still points at origin/master, and not origin/<branchname>\nSo my question is, under what circumstances does origin/HEAD get moved?\nEDIT:\nI appreciate the answers about how to move origin/HEAD, but I'm interested in what \"organically\" moves it, outside of me explicitly telling it to do so.\nFor example, when I switch branches, git makes HEAD point at the branch I'm checking out, so I'm surprised that origin/HEAD doesn't move in the same manner."}, {"role": "assistant", "content": "Note first that your question shows a bit of misunderstanding. origin/HEAD represents the default branch on the remote, i.e. the HEAD that's in that remote repository you're calling origin. When you switch branches in your repo, you're not affecting that. The same is true for remote branches; you might have master and origin/master in your repo, where origin/master represents a local copy of the master branch in the remote repository. \norigin's HEAD will only change if you or someone else actually changes it in the remote repository, which should basically never happen - you want the default branch a public repo to stay constant, on the stable branch (probably master). origin/HEAD is a local ref representing a local copy of the HEAD in the remote repository. (Its full name is refs/remotes/origin/HEAD.)\nI think the above answers what you actually wanted to know, but to go ahead and answer the question you explicitly asked... origin/HEAD is set automatically when you clone a repository, and that's about it. Bizarrely, that it's not set by commands like git remote update - I believe the only way it will change is if you manually change it. (By change I mean point to a different branch; obviously the commit it points to changes if that branch changes, which might happen on fetch/pull/remote update.)\n\nEdit: The problem discussed below was corrected in Git 1.8.4.3; see this update.\n\nThere is a tiny caveat, though. HEAD is a symbolic ref, pointing to a branch instead of directly to a commit, but the git remote transfer protocols only report commits for refs. So Git knows the SHA1 of the commit pointed to by HEAD and all other refs; it then has to deduce the value of HEAD by finding a branch that points to the same commit. This means that if two branches happen to point there, it's ambiguous. (I believe it picks master if possible, then falls back to first alphabetically.) You'll see this reported in the output of git remote show origin:\n$ git remote show origin\n* remote origin\n Fetch URL: ...\n Push URL: ...\n HEAD branch (remote HEAD is ambiguous, may be one of the following):\n foo\n master\n\nOddly, although the notion of HEAD printed this way will change if things change on the remote (e.g. if foo is removed), it doesn't actually update refs/remotes/origin/HEAD. This can lead to really odd situations. Say that in the above example origin/HEAD actually pointed to foo, and origin's foo branch was then removed. We can then do this:\n$ git remote show origin\n...\nHEAD branch: master\n$ git symbolic-ref refs/remotes/origin/HEAD\nrefs/remotes/origin/foo\n$ git remote update --prune origin\nFetching origin\n x [deleted] (none) -> origin/foo\n (refs/remotes/origin/HEAD has become dangling)\n\nSo even though remote show knows HEAD is master, it doesn't update anything. The stale foo branch is correctly pruned, and HEAD becomes dangling (pointing to a nonexistent branch), and it still doesn't update it to point to master. If you want to fix this, use git remote set-head origin -a, which automatically determines origin's HEAD as above, and then actually sets origin/HEAD to point to the appropriate remote branch."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to undo git flow feature finish?\nI am learning git-flow and I just did git flow feature finish <feature-name>, which merged my feature branch to develop and removed it.\nInstead of this, I want to push the feature branch to github, so I can merge it after a peer review.\nSo the question is, how do I 'undo' this command. Or in other words , how can I move my last two commits from develop to my feature branch?"}, {"role": "assistant", "content": "These steps should do the trick:\nGet the sha's needed:\ngit log\n\n<sha1> is the commit right before the merge\n<sha2> is the last commit on develop before you started working on the feature\ngit checkout develop\ngit checkout -b feature/<feature-name>\ngit reset <sha1> --hard\ngit checkout develop\ngit reset <sha2> --hard\n\nPush your feature branch."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I do a git pull to a specific branch?\nI am trying to pull from my heroku remote, I get this message:\n>git pull heroku\nYou asked to pull from the remote 'heroku', but did not specify\na branch. Because this is not the default configured remote\n\nMy local branch is 'develop'.\nHow do I pull from Heroku to my local branch 'develop' ?\nThanks."}, {"role": "assistant", "content": "Updated answer: You need to specify what branch you want to pull from, since your local branch is not configured to pull from heroku's master.\nSo try something like:\ngit pull heroku master\n\nRemember that you have to have checked out develop in order for this command to pull to the local branch develop."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitLab push error: LFS objects are missing\n\nI've used Git LFS for GitLab for a few months now without any problems, but it returned the following error while pushing files lately:\n$ git push origin master\nGit LFS: (14 of 14 files) 8.88 MB / 8.88 MB\nCounting objects: 54, done.\nDelta compression using up to 6 threads.\nCompressing objects: 100% (49/49), done.\nWriting objects: 100% (54/54), 5.42 KiB | 0 bytes/s, done.\nTotal 54 (delta 15), reused 0 (delta 0)\nremote: GitLab: LFS objects are missing. Ensure LFS is properly set up or try a manual \"git lfs push --all\".\nTo https://gitlab.com/<gitURL>.git\n! [remote rejected] master -> master (pre-receive hook declined)\nerror: failed to push some refs to 'https://gitlab.com/<gitURL>.git'\n\nwhere gitURL is my git-repository URL.\nAs the error suggests I tried to manually push my binary files, using git lfs push --all, which gives me the following output:\n$ git lfs push --all origin master\nGit LFS: (0 of 0 files, 1370 skipped) 0 B / 0 B, 1.77 GB skipped\n\nwhich means by my understanding that all my local files are already successfully stored on my server.\nTrying to fetch all lfs files does work fine as well:\n$ git lfs fetch --all\nScanning for all objects ever referenced...\n* 1446 objects found\nFetching objects...\n\nwhich finishes without any errors.\nMoreover checking all lfs files for consistency using git lfs fsck seems to work fine too:\n$ git lfs fsck\nGit LFS fsck OK\n\nI'm starting to run out of ideas about fixing this error now. \nAny help would be greatly appreciated."}, {"role": "assistant", "content": "I got this error even though (to my knowledge) I did not have any LFS objects in my gitlab repository.\nremote: GitLab: LFS objects are missing. Ensure LFS is properly set up or try a manual \"git lfs push --all\".\n\nThe solution was to disable Git Large File Storage (LFS) in the gitlab project settings.\nSettings > General > Visibility, project features, permissions > Expand > Git Large File Storage (LFS)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-svn not a git command?\nWhile attempting to get an old svn dump of a project under git control, I ran into an interesting problem. Whenever I run git svn, I get an error saying it isn't a git command, yet there is documentation for it that I can pull up using git help. Is there something wrong with my install, or am I just missing something here?\nEdit: I should probably also mention that I am running msysGit version 1.6.1.9.g97c34 under Windows XP, and the error I get is:\n$ git svn \ngit: 'svn' is not a\ngit-command. See 'git --help'.\n\nDid you mean one of these?\n fsck\n show"}, {"role": "assistant", "content": "I just check on my newly installed ubuntu box and it wasn't installed even with git-core installed. A simple:\nsudo apt-get install git-svn\n\nor your distro equivalent should fix it."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-apply - Apply a patch to files and/or to the index --exclude=<path-pattern>"}, {"role": "assistant", "content": "Don’t apply changes to files matching the given path pattern. This can\nbe useful when importing patchsets, where you want to exclude certain\nfiles or directories."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to skip \"Loose Object\" popup when running 'git gui'\nWhen I run 'git gui' I get a popup that says\n\nThis repository currently has approximately 1500 loose objects.\n\nIt then suggests compressing the database. I've done this before, and it reduces the loose objects to about 250, but that doesn't suppress the popup. Compressing again doesn't change the number of loose objects. \nOur current workflow requires significant use of 'rebase' as we are transitioning from Perforce, and Perforce is still the canonical SCM. Once Git is the canonical SCM, we will do regular merges, and the loose objects problem should be greatly mitigated. \nIn the mean time, I'd really like to make this 'helpful' popup go away."}, {"role": "assistant", "content": "Since nobody had yet an answer, I looked into the code to see how to remove the code which shows up that dialog. I found the hint_gc procedure which does it and the place where it is called. At the same time I noticed that late 2011 there was added a configuration option for disabling the dialog. This change (part of git-gui 0.16.0) was merged to Git's mainline on 2011-12-14.\nSo if you use Git v1.7.9 or newer, you can disable the warning dialog with the following command:\ngit config --global gui.gcwarning false\n\nIf you are using an older version, then you can edit /lib/git-core/git-gui and remove the after 1000 hint_gc line, or edit /usr/share/git-gui/lib/database.tcl and remove the body of the hint_gc procedure. (These file paths are on Cygwin - on other environments the files might be in a different locations. For Windows it is c:\\Program Files\\Git\\mingw64\\libexec\\git-core\\git-gui.tcl)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git enter long passphrase for every push\nEvery time I try to push anything to GitHub it asks me the address [email protected]:... and after that it wants the passphrase. Is there a way to automate this?\nI am using Linux Ubuntu."}, {"role": "assistant", "content": "You can use ssh-agent to remember your passphrase (Gnome automatically runs this for you, normally...).\n$ ssh-agent bash\n$ ssh-add \nEnter passphrase for /home/elyobo/.ssh/id_rsa: \nIdentity added: /home/elyobo/.ssh/id_rsa (/home/elyobo/.ssh/id_rsa)\n\nFrom now on, from within the terminal that you run this, your pass phrase will be remembered.\nIdeally you'd get it working automatically, so all shells running within gnome would work; check out Gnome Keyring."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "curl command not found on .gitlab-ci.yml\n\nI have a .gitlab-ci.yml file. Its creating some docker images and pushing it to AWS ECR.\nWhen I am running curl command to push some artifacts to remote repository it says curl: not found. I am already using openjdk image to do ./gradlew build. Don't know how to install curl on Gitlab runner.\nPlease guide."}, {"role": "assistant", "content": "I was able to resolve it by using apk utility.\napk add --update curl && rm -rf /var/cache/apk/*\n\nOr more recently using no-cache:\napk add --no-cache curl"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-bisect"}, {"role": "assistant", "content": "Use binary search to find the commit that introduced a bug"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-update-index - Register file contents in the working tree to the index --replace"}, {"role": "assistant", "content": "By default, when a file path exists in the index, git update-index refuses an attempt to add path/file .\nSimilarly if a file path/file exists, a file path cannot be added. With --replace flag, existing entries\nthat conflict with the entry being added are\nautomatically removed with warning messages."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Concurrency in a GIT repo on a network shared folder\nI want to have a bare git repository stored on a (windows) network share. I use linux, and have the said network share mounted with CIFS. My coleague uses windows xp, and has the network share automounted (from ActiveDirectory, somehow) as a network drive.\nI wonder if I can use the repo from both computers, without concurrency problems. \nI've already tested, and on my end I can clone ok, but I'm afraid of what might happen if we both access the same repo (push/pull), at the same time.\nIn the git FAQ there is a reference about using network file systems (and some problems with SMBFS), but I am not sure if there is any file locking done by the network/server/windows/linux - i'm quite sure there isn't.\nSo, has anyone used a git repo on a network share, without a server, and without problems?\nThank you,\nAlex\nPS: I want to avoid using an http server (or the git-daemon), because I do not have access to the server with the shares. Also, I know we can just push/pull from one to another, but we are required to have the code/repo on the share for back-up reasons.\nUpdate:\nMy worries are not about the possibility of a network failure. Even so, we would have the required branches locally, and we'll be able to compile our sources.\nBut, we usually commit quite often, and need to rebase/merge often. From my point of view, the best option would be to have a central repo on the share (so the backups are assured), and we would both clone from that one, and use it to rebase.\nBut, due to the fact we are doing this often, I am afraid about file/repo corruption, if it happens that we both push/pull at the same time. Normally, we could yell at each other each time we access the remote repo :), but it would be better to have it secured by the computers/network.\nAnd, it is possible that GIT has an internal mechanism to do this (since someone can push to one of your repos, while you work on it), but I haven't found anything conclusive yet.\nUpdate 2:\nThe repo on the share drive would be a bare repo, not containing a working copy."}, {"role": "assistant", "content": "Git requires minimal file locking, which I believe is the main cause of problems when using this kind of shared resource over a network file system. The reason it can get away with this is that most of the files in a Git repo--- all the ones that form the object database--- are named as a digest of their content, and immutable once created. So there the problem of two clients trying to use the same file for different content doesn't come up.\nThe other part of the object database is trickier-- the refs are stored in files under the \"refs\" directory (or in \"packed-refs\") and these do change: although the refs/* files are small and always rewritten rather than being edited. In this case, Git writes the new ref to a temporary \".lock\" file and then renames it over the target file. If the filesystem respects O_EXCL semantics, that's safe. Even if not, the worst that could happen would be a race overwriting a ref file. Although this would be annoying to encounter, it should not cause corruption as such: it just might be the case that you push to the shared repo, and that push looks like it succeeded whereas in fact someone else's did. But this could be sorted out simply by pulling (merging in the other guy's commits) and pushing again.\nIn summary, I don't think that repo corruption is too much of a problem here--- it's true that things can go a bit wrong due to locking problems, but the design of the Git repo will minimise the damage.\n(Disclaimer: this all sounds good in theory, but I've not done any concurrent hammering of a repo to test it out, and only share them over NFS not CIFS)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Do a \"git export\" (like \"svn export\")?\nI've been wondering whether there is a good \"git export\" solution that creates a copy of a tree without the .git repository directory. There are at least three methods I know of:\n\ngit clone followed by removing the .git repository directory.\ngit checkout-index alludes to this functionality but starts with \"Just read the desired tree into the index...\" which I'm not entirely sure how to do.\ngit-export is a third-party script that essentially does a git clone into a temporary location followed by rsync --exclude='.git' into the final destination.\n\nNone of these solutions really strike me as being satisfactory. The closest one to svn export might be option 1, because both require the target directory to be empty first. But option 2 seems even better, assuming I can figure out what it means to read a tree into the index."}, {"role": "assistant", "content": "Probably the simplest way to achieve this is with git archive. If you really need just the expanded tree you can do something like this.\ngit archive master | tar -x -C /somewhere/else\n\nMost of the time that I need to 'export' something from git, I want a compressed archive in any case so I do something like this.\ngit archive master | bzip2 >source-tree.tar.bz2\n\nZIP archive:\ngit archive --format zip --output /full/path/to/zipfile.zip master \n\ngit help archive for more details, it's quite flexible.\n\nBe aware that even though the archive will not contain the .git directory, it will, however, contain other hidden git-specific files like .gitignore, .gitattributes, etc. If you don't want them in the archive, make sure you use the export-ignore attribute in a .gitattributes file and commit this before doing your archive. Read more...\n\nNote: If you are interested in exporting the index, the command is\ngit checkout-index -a -f --prefix=/destination/path/\n\n(See Greg's answer for more details)\n\nHere's a real-world example using libchrony on Linux:\nmkdir $HOME/dev\ncd $HOME/dev\npushd /tmp\ngit clone https://gitlab.com/chrony/libchrony.git\ncd libchrony\nBRANCH=$(git rev-parse --abbrev-ref HEAD)\ngit archive -o ../libchrony.zip --prefix=\"libchrony/\" $BRANCH\npopd\nunzip /tmp/libchrony.zip\n\nThose commands produce a zip file and extract it into $HOME/dev/libchrony. We can peek into the archive using:\n$ unzip -v /tmp/libchrony\nArchive: /tmp/libchrony.zip\ne0a3807f770b56f6b0e9833254baa7c4fc13564b\n Length Method Size Cmpr Date Time CRC-32 Name\n-------- ------ ------- ---- ---------- ----- -------- ----\n 0 Stored 0 0% 2023-07-20 09:37 00000000 libchrony/\n 49 Defl:N 47 4% 2023-07-20 09:37 37c3f2e2 libchrony/.gitignore\n 26530 Defl:N 9350 65% 2023-07-20 09:37 5622583e libchrony/COPYING\n 961 Defl:N 467 51% 2023-07-20 09:37 da9221e3 libchrony/Makefile\n 475 Defl:N 304 36% 2023-07-20 09:37 cae27f70 libchrony/README.adoc\n 3313 Defl:N 1119 66% 2023-07-20 09:37 37eb110f libchrony/chrony.h\n 7673 Defl:N 2261 71% 2023-07-20 09:37 5d455a52 libchrony/client.c\n 6190 Defl:N 2093 66% 2023-07-20 09:37 7ea9d81b libchrony/example-reports.c\n 16348 Defl:N 3855 76% 2023-07-20 09:37 e82f5fe3 libchrony/message.c\n 2946 Defl:N 1099 63% 2023-07-20 09:37 945ee82b libchrony/message.h\n-------- ------- --- -------\n 64485 20595 68% 10 files"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-clean - Remove untracked files from the working tree clean.requireForce"}, {"role": "assistant", "content": "A boolean to make git-clean refuse to delete files unless -f\nis given. Defaults to true."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-branch - List, create, or delete branches <branchname>"}, {"role": "assistant", "content": "The name of the branch to create or delete.\nThe new branch name must pass all checks defined by git-check-ref-format . Some of these checks\nmay restrict the characters allowed in a branch name."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git shortcut to pull with clone if no local there yet?\nIs there a one-command way to get an up-to-date mirror of a remote repo? \nThat is\n\nif local repo not there yet: clone\nif it's there: pull\n\nI know I could script this around (e.g if [ -d repo ]; then (cd repo && git pull); else git clone $repourl;fi\n) , but I need the simplest possible cross-platform way (actually used for Jenkins-CI, which I know does this by default, however I need 2 repos for which support is limited).\nGit has similar shortcuts for other things (eg. checkout -b, and pull itself), so I'm wondering if I missed something. Thanks!"}, {"role": "assistant", "content": "There is not, given that the commands which operate on existing repos all assume that they're being run inside a given repo.\nThat said, if you're running in a shell, you could simply make use of the shell built-ins. For instance, here's bash:\nif cd repo; then git pull; else git clone https://server/repo repo; fi\n\nThis checks to see if repo is a valid directory, and if so, does a pull within it; otherwise it does a clone to create the directory."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I change the url for a project in GitLab?\n\nI have a project in Gitlab that is available over HTTP/SSH:\n[email protected]:MyGroup/MyProject.git\n\nI want to change that using another IP, i.e.:\n[email protected]:MyGroup/MyProject.git\n\nWhere or how can I change that?"}, {"role": "assistant", "content": "You can use below command to set new URL for your repository.\ngit remote set-url origin git://[email protected]:MyGroup/MyProject.git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Added SSH key to Gitlab but it still asks for my credentials\n\nGitLab's HTTP pull & push are working when I enter my credentials. \nBut when using an added SSH key, it is always is asking for my password, which I don't know. Why is GitLab doing this? Is it a server fault?\nAnd when calling ssh -vT [email protected] there is an error:\n\nPermission denied (publickey)\n\nI've tried everything, even re-installing Git, but nothing works. Even their own solution is not working, as described here: https://help.github.com/articles/error-permission-denied-publickey/"}, {"role": "assistant", "content": "I had the same issue, after checking\n/var/log/auth.log\n\nI got : \n*User git not allowed because account is locked\n*input_userauth_request: invalid user git [preauth]\n*Connection closed by IP.IP.IP.IP [preauth]\n\nSo the fix was \n\nsudo passwd -d git\n\nThanks to Noah (source)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Finding out the name of the original repository you cloned from in Git\nWhen you do your first clone using the syntax\ngit clone username@server:gitRepo.git\n\nIs it possible using your local repository to find the name of that initial clone?\n(So in the above example, find gitRepo.git.)"}, {"role": "assistant", "content": "git config --get remote.origin.url"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "github actions: how to check if current push has new tag (is new release)?\n\nname: test-publish\n\non: [push]\n\njobs:\n test:\n strategy:\n ...\n steps:\n ...\n\n publish:\n needs: test\n if: github.event_name == 'push' && github.ref???\n steps:\n ... # eg: publish package to PyPI\n\nWhat should I put in jobs.publish.if in order to check that this commit is new release?\nIs this okay: contains(github.ref, '/tags/')?\nWhat will happen if I push code and tag at the same time?"}, {"role": "assistant", "content": "You could do this to check if the current push event is for a tag starting with v.\n publish:\n needs: test\n if: startsWith(github.ref, 'refs/tags/v')\n\nAs you pointed out though, I don't think you can guarantee that this is a new release. My suggestion would be to use on: release instead of on: push. This will only trigger on a newly tagged release.\nSee the docs for on: release here:\nhttps://docs.github.com/en/actions/reference/events-that-trigger-workflows#release"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-format-patch - Prepare patches for e-mail submission -s --signoff"}, {"role": "assistant", "content": "Add a Signed-off-by trailer to the commit message, using\nthe committer identity of yourself.\nSee the signoff option in git-commit for more information."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Github permission denied: ssh add agent has no identities\n\nThis is my first time accessing GitHub and I'm not experienced using a console. I am on a MacBook using Bash. When I try to access GitHub, I get this:\ngit clone [email protected]:dhulihan/league-of-legends-data-scraper.git\nCloning into 'league-of-legends-data-scraper'...\nPermission denied (publickey).\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\nI've tried following the instructions on Github page about permission being denied.\nWhen I use ssh -vT [email protected], I get the following:\nOpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011\ndebug1: Reading configuration data /etc/ssh_config\ndebug1: /etc/ssh_config line 20: Applying options for *\ndebug1: Connecting to github.com [192.30.252.129] port 22.\ndebug1: Connection established.\ndebug1: identity file /Users/XXXX/.ssh/id_rsa type -1\ndebug1: identity file /Users/XXXX/.ssh/id_rsa-cert type -1\ndebug1: identity file /Users/XXXX/.ssh/id_dsa type -1\ndebug1: identity file /Users/XXXX/.ssh/id_dsa-cert type -1\ndebug1: Enabling compatibility mode for protocol 2.0\ndebug1: Local version string SSH-2.0-OpenSSH_6.2\ndebug1: Remote protocol version 2.0, remote software version libssh-0.6.0\ndebug1: no match: libssh-0.6.0\ndebug1: SSH2_MSG_KEXINIT sent\ndebug1: SSH2_MSG_KEXINIT received\ndebug1: kex: server->client aes128-ctr hmac-sha1 none\ndebug1: kex: client->server aes128-ctr hmac-sha1 none\ndebug1: sending SSH2_MSG_KEXDH_INIT\ndebug1: expecting SSH2_MSG_KEXDH_REPLY\ndebug1: Server host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48\ndebug1: Host 'github.com' is known and matches the RSA host key.\ndebug1: Found key in /Users/XXXX/.ssh/known_hosts:1\ndebug1: ssh_rsa_verify: signature correct\ndebug1: SSH2_MSG_NEWKEYS sent\ndebug1: expecting SSH2_MSG_NEWKEYS\ndebug1: SSH2_MSG_NEWKEYS received\ndebug1: Roaming not allowed by server\ndebug1: SSH2_MSG_SERVICE_REQUEST sent\ndebug1: SSH2_MSG_SERVICE_ACCEPT received\ndebug1: Authentications that can continue: publickey\ndebug1: Next authentication method: publickey\ndebug1: Trying private key: /Users/XXXX/.ssh/id_rsa\ndebug1: Trying private key: /Users/XXXX/.ssh/id_dsa\ndebug1: No more authentication methods to try.\nPermission denied (publickey).\n\nNext, eval \"$(ssh-agent -s)\" returns \"Agent pid 2314\",\nhowever ssh-add -l returns \"The agent has no identities.\"\nAnd that is where I am stuck."}, {"role": "assistant", "content": "Full details in this answer. \nIn summary, when ssh-add -l returns “The agent has no identities”, it means that keys used by ssh (stored in files such as ~/.ssh/id_rsa, ~/.ssh/id_dsa, etc.) are either missing, they are not known to ssh-agent, which is the authentication agent, or that their permissions are set incorrectly (for example, world writable).\nIf your keys are missing or if you have not generated any, use ssh-keygen -t rsa, then ssh-add to add them.\nIf keys exist but are not known to ssh-agent (like if they are in a non-standard folder), use ssh-add /path/to/my-non-standard-ssh-folder/id_rsa to add them.\nSee this answer if you are having trouble with ssh-add or ssh-agent."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options maintenance.incremental-repack.auto"}, {"role": "assistant", "content": "This integer config option controls how often the incremental-repack task should be run as part of git maintenance run --auto . If zero,\nthen the incremental-repack task will not run with the --auto option. A negative value will force the task to run every time.\nOtherwise, a positive value implies the command should run when the\nnumber of pack-files not in the multi-pack-index is at least the value\nof maintenance.incremental-repack.auto . The default value is 10."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git: Checkout only files without repository?\ni'd like to just checkout the files without the .git files and the whole repository. It's because i'd like to manage a website (php & html) with git and i'm looking for an easy way to update the files in the htdocs folder from the repository, without having the repository public. (now it's in the home-dir and is accessed via ssh, but i have to put the new files to htdocs manually."}, {"role": "assistant", "content": "The git-archive manpage contains the following example:\n\ngit archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)\n\nCreate a tar archive that contains the contents of the latest commit on the current branch, and extract it in the '/var/tmp/junk' directory.\n\n\nOr you can use low level git-checkout-index, which manpage contains the following example:\n\nUsing git checkout-index to \"export an entire tree\"\n\nThe prefix ability basically makes it trivial to use 'git checkout-index' as an \"export as tree\" function. Just read the desired tree into the index, and do\n $ git checkout-index --prefix=git-export-dir/ -a\n\ngit checkout-index will \"export\" the index into the specified directory.\nThe final \"/\" is important. The exported name is literally just prefixed with the specified string.\n\n\nOr you can try to use --work-tree option to git wrapper, or GIT_WORK_TREE environment variable, e.g. by using \"git --work-tree=/somwehere/else checkout -- .\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options commitGraph.readChangedPaths"}, {"role": "assistant", "content": "If true, then git will use the changed-path Bloom filters in the\ncommit-graph file (if it exists, and they are present). Defaults to\ntrue. See git-commit-graph for more information."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to configure Jenkins to access Gitlab private repository without Gitlab plugin?\n\nI have installed latest Jenkins on ubuntu server and Jenkinsfile in my project repo on Gitlab.\nI am able to connect to private repo on Gitlab using username/password credential on Jenkins configuration for the project pipeline without using Jenkins Gitlab plugin. This does not seem safe to me. How can I use Gitlab API token instead of username/password for Jenkins to access remote private Gitlab repo without using Jenkins Gitlab plugin. Another option is to set ssh private key on Jenkins server to athenticate against Gitlab repo. Is this option possible? \nJenkins Gitlab plugin is not officially supported and not well maintained because Gitlab wants customers to user their own CI/CD solution in order to tie customers to their platform for marketing reasons."}, {"role": "assistant", "content": "A relatively safe way to handle this situation is to store your credentials is the credentials system in Jenkins (that way you do not have to include the credentials in the JenkinsFile), and using a deploy token (available for Gitlab 10.7 and later) for the relevant repository. That token allows you to provide read-only rights to the repository.\nStep 1 - setup the deploy token in GitLab\nFrom the GitLab documentation\n\nYou can create as many deploy tokens as you like from the settings of your project:\n\nLog in to your GitLab account.\nGo to the project you want to create Deploy Tokens for.\nGo to Settings > Repository.\nClick on “Expand” on Deploy Tokens section.\nChoose a name and optionally an expiry date for the token.\nChoose the desired scopes.\nClick on Create deploy token.\nSave the deploy token somewhere safe. Once you leave or refresh the page, you won’t be able to access it again.\n\n\nStep 2 - Saving the deploy token in Jenkins' credentials system\nSince the deploy tokens have a username and password, pick that as the type in the steps below. Write down the id you will use in this step (see below) as you will need it in your pipeline declaration.\nFrom the Jenkins documentation\n\nTo add new global credentials to your Jenkins instance:\n\nIf required, ensure you are logged in to Jenkins (as a user with the Credentials > Create permission).\nFrom the Jenkins home page (i.e. the Dashboard of the Jenkins classic UI), click Credentials > System on the left.\nUnder System, click the Global credentials (unrestricted) link to access this default domain.\nClick Add Credentials on the left. Note: If there are no credentials in this default domain, you could also click the add some credentials link (which is the same as clicking the Add Credentials link).\nFrom the Kind field, choose the type of credentials to add.\nFrom the Scope field, choose either:\n \n \n\nGlobal - if the credential/s to be added is/are for a Pipeline project/item. Choosing this option applies the scope of the credential/s to the Pipeline project/item \"object\" and all its descendent objects.\nSystem - if the credential/s to be added is/are for the Jenkins instance itself to interact with system administration functions, such as email authentication, agent connection, etc. Choosing this option applies the scope of the credential/s to a single object only.\n\n\nAdd the credentials themselves into the appropriate fields for your chosen credential type:\n \n \n(...)\n\nUsername and password - specify the credential’s Username and Password in their respective fields.\n (...)\n\n\nIn the ID field, specify a meaningful credential ID value - for example, jenkins-user-for-xyz-artifact-repository. You can use upper- or lower-case letters for the credential ID, as well as any valid separator character. However, for the benefit of all users on your Jenkins instance, it is best to use a single and consistent convention for specifying credential IDs. Note: This field is optional. If you do not specify its value, Jenkins assigns a globally unique ID (GUID) value for the credential ID. Bear in mind that once a credential ID is set, it can no longer be changed.\nSpecify an optional Description for the credential/s.\nClick OK to save the credentials.\n\n\nStep 3 - Use the credentials in your pipeline declaration\nYou can use the credentials in your jenkinsFile like so:\npipeline {\n stages {\n stage('Clone stage') {\n steps {\n git url: 'https://gitlab.com/[username]/[my-repo].git', branch: 'master', credentialsId: 'my-gitlab-repo-creds'\n }\n }\n } \n}\n\nIn the above example I assume you picked the id my-gitlab-repo-creds in step 2."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git Error : 'upstream' does not appear to be a git repository\nI'm very new to Git, so facing some issues with it correct usage.\nHere is my scenario.\nI have a fork of my master repository and cloned it into my local.\nIn that, I have 2 branches for different fixes.\nWhen I commit, I saw a statement in the git-we saying that I'm 3 commits ahead and around 20 commits behind.\nI understand that my fork is not in sync with master. Also I need to merge the two branches too (or should i do it?)\nI used the windows client to syncing. But seems I'm not following the Git way. So, I tried to follow the steps described in https://help.github.com/articles/syncing-a-fork/ which is giving me an error as follows (I'm using windows).\n $>git fetch upstream\n fatal: 'upstream' does not appear to be a git repository\n fatal: Could not read from remote repository.\n\n Please make sure you have the correct access rights\n and the repository exists.\n\nI'm a bit confused.\nPlease help me with steps I should follow in this scenario.\n@HuStmpHrrr\nSorry for adding the details in comments\nI'll modify the question for readability\nBy executing the command:\n $>git remote returning two values\n acme-development (which the name of my actual/main repository, from where I forked) and\n origin\n\n\nAdding some more info.\n\nAfter making a fetch, I tried a origin/master merge on to my master\nPlease see the screenshot\n\nBut, if I login to my Github online account, it is saying a different story.\n\nMy git client says that the local repo is up to date.\nBut the online git says that we are 42 commits behind and 7 commits ahead."}, {"role": "assistant", "content": "The article you link to (though it may have changed since you asked) starts with a reference to https://help.github.com/articles/configuring-a-remote-for-a-fork/. If you complete this you will have a new remote repository named upstream pointing to the original repository which you forked, and git fetch upstream will work."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I use git bisect?\nI have read some articles saying that git bisect is awesome. However, I can't understand why it's awesome.\n\nHow do I use it?\nIs it just like svn blame?"}, {"role": "assistant", "content": "The idea behind git bisect is to perform a binary search in the history to find a particular regression. Imagine that you have the following development history:\n... --- 0 --- 1 --- 2 --- 3 --- 4* --- 5 --- current\n\nYou know that your program is not working properly at the current revision, and that it was working at the revision 0. So the regression was likely introduced in one of the commits 1, 2, 3, 4, 5, current.\nYou could try to check out each commit, build it, check if the regression is present or not. If there are a large number of commits, this can take a long time. This is a linear search. We can do better by doing a binary search. This is what the git bisect command does. At each step it tries to reduce the number of revisions that are potentially bad by half.\nYou'll use the command like this:\n$ git stash save\n$ git bisect start\n$ git bisect bad\n$ git bisect good 0\nBisecting: 2 revisions left to test after this (roughly 2 steps)\n[< ... sha ... >] 3\n\nAfter this command, git will checkout a commit. In our case, it'll be commit 3. You need to build your program, and check whether or not the regression is present. You'll also need to tell git the status of this revision with either git bisect bad if the regression is present, or git bisect good if it is not.\nLet's suppose that the regression was introduced in commit 4. Then the regression is not present in this revision, and we tell it to git.\n$ make\n$ make test\n... ... ...\n$ git bisect good\nBisecting: 0 revisions left to test after this (roughly 1 step)\n[< ... sha ... >] 5\n\nIt will then checkout another commit. Either 4 or 5 (as there are only two commits). Let's suppose it picked 5. After a build we test the program and see that the regression is present. We then tell it to git:\n$ make\n$ make test\n... ... ...\n$ git bisect bad\nBisecting: 0 revisions left to test after this (roughly 0 steps)\n[< ... sha ... >] 4\n\nWe test the last revision, 4. And since it is the one that introduced the regression, we tell it to git:\n$ make\n$ make test\n... ... ...\n$ git bisect bad\n< ... sha ... > is the first bad commit\n< ... commit message ... >\n\nIn this simple situation, we only had to test 3 versions (3, 4, 5) instead of 4 (1, 2, 3, 4). This is a small win, but this is because our history is so small. If the search range is of N commits, we should expect to test 1 + log2 N commits with git bisect instead of roughly N / 2 commits with a linear search.\nOnce you've found the commit that introduced the regression, you can study it to find the issue. Once this is done, you use git bisect reset to put everything back on the original state before using git bisect command."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git: How to edit/reword a merge commit's message?\nHow do I edit or reword a merge commit's message?\ngit commit --amend works if it's the last commit made (HEAD), but what if it comes before HEAD?\ngit rebase -i HEAD~5 doesn't list the merge commits."}, {"role": "assistant", "content": "If you add the --preserve-merges option (or its synonym, -p) to the git rebase -i command then git will try to preserve the merges when rebasing, rather than linearizing the history, and you should be able to amend the merge commits as well:\ngit rebase -i -p HEAD~5\n\nNote. --perserve-merges has been deprecated in favour of --rebase-merges as of git v2.22 (https://www.infoq.com/news/2019/07/git-2-22-rebase-merges/)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --expand-tabs=<n> --expand-tabs --no-expand-tabs"}, {"role": "assistant", "content": "Perform a tab expansion (replace each tab with enough spaces\nto fill to the next display column that is a multiple of <n> )\nin the log message before showing it in the output. --expand-tabs is a short-hand for --expand-tabs=8 , and --no-expand-tabs is a short-hand for --expand-tabs=0 ,\nwhich disables tab expansion. By default, tabs are expanded in pretty formats that indent the log\nmessage by 4 spaces (i.e. medium , which is the default, full ,\nand fuller )."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options log.showSignature"}, {"role": "assistant", "content": "If true, makes git-log , git-show , and git-whatchanged assume --show-signature ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to reset or change the passphrase for a GitHub SSH key?\n\nI have forgoten my passphrase in Git. How do I reset it? I found two solutions on Stack Overflow, but I want to know what process to follow to reset it or to get it."}, {"role": "assistant", "content": "If you had generate a SSH-key with passphrase and then you forget your passphrase for this SSH-key,there's no way to recover it, You'll need to generate a brand new SSH keypair or switch to HTTPS cloning so you can use your GitHub password instead.\nBUT,there are exceptions\nIf you configured your SSH passphrase with the OS X Keychain, you may be able to recover it.\n\nIn Finder, search for the Keychain Access app.\nIn Keychain Access, search for SSH.\nDouble click on the entry for your SSH key to open a new dialog box.\nKeychain access dialogIn the lower-left corner, select Show password.\nYou'll be prompted for your administrative password. Type it into the \"Keychain Access\" dialog box.\nYour password will be revealed.\n\nRefer to Github help - How do I recover my SSH key passphrase?"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options nodense"}, {"role": "assistant", "content": "make equal size columns"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-cherry-pick - Apply the changes introduced by some existing commits --cleanup=<mode>"}, {"role": "assistant", "content": "This option determines how the commit message will be cleaned up before\nbeing passed on to the commit machinery. See git-commit for more\ndetails. In particular, if the <mode> is given a value of scissors ,\nscissors will be appended to MERGE_MSG before being passed on in the case\nof a conflict."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is there a way to wrap a Github README video link in a table cell?\n\nI would like to wrap a video link like this in a table cell in a README Markdown file. Is there any way to accomplish this?"}, {"role": "assistant", "content": "You can achieve that by using HTML tag <video>.\nExample:\n| Video 1 | Video 2 |\n| ------------- | ------------- |\n| <video src=\"https://user-images.githubusercontent.com/13440061/129455220-23fa27a2-c8f0-4953-b291-b4893959d5d9.mp4\"> | <video src=\"https://user-images.githubusercontent.com/13440061/129455220-23fa27a2-c8f0-4953-b291-b4893959d5d9.mp4\">|"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git - Moving Pushed Commits to a Different Branch\n\nMy boss decided recently to try out an outsourcing group \"for increased capacity\" as we modify an existing application to add new features. Despite my concern that the group he chose didn't seem to communicate well and wasn't asking enough questions to truly understand and be effective, we went with them anyway.\nWe set them up to collaborate on our Git repository (hosted on GitHub). We created a branch just for them (TheOutsourcedBranch, we'll call it) and requested that they to do all of their work within this branch.\nAdditionally, we asked that they push their commits at the end of each day so that we can get a decent idea of how fast they work and (more importantly) how good their code is.\nToday they pushed for the first time. Five commits, all of them in master. I'm trying to figure out how to move their commits from master into TheOutsourcedBranch, without losing the work they've done (although from the looks of it, we're going to have to throw it away anyway).\n\nOrange dots are their commits, gray dots are mine.\nI know there are a zillion questions about rebasing (and that might be what I need to do here) but I'm having a hard time figuring out which of them apply to my specific case. And in case it matters, the outsourcing group and myself are the only people that are really using the repo right now.\nThanks in advance!\n\nEdit:\nI may have found what I'm looking for: Move the most recent commit(s) to a new branch with Git\nI'd like to check my understanding, though. Locally, I create a branch off of master (TheOutsourcedBranch), which would contain everything A-H. Then I reset master back to C. Master would now contain A-C.\nAssuming that is correct, that would be fine for me (locally). But then what do I need to do to \"force\" the remote repository (GitHub) to accept my local view of how things played out and discard its version of the history?\nOnce this has played out I think I can re-work this question to make it more generic/informative and cut out some fluff--otherwise it's probably a good candidate for deletion, I would guess."}, {"role": "assistant", "content": "Getting the branch is easy:\ngit branch their-branch master\ngit reset --hard master $SHA1_OF_C\ngit push --force $SHARED_REPO_REMOTE\n\nThis will rewrite history; it creates a new branch that is equivalent to the current master branch named their-branch, then resets your local master to point to a random SHA1 (...or branch, or tag, or whatever), and finally forcibly updates the remote repository branch to match your local branch.\nThat delivers exactly the situation you want.\nCaveats: this will rewrite history, and can screw up anyone who has built off the old master. Watch out for merge problems following.\nNo rebasing desired or required.\n(As an aside, I suggest you either give them a staging repository, or get them to use git send-email, or use GitHub pull requests, or otherwise prevent them pushing to master until they get it right. Which, based on your summary, might be some time away.)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to use Git Revert\nHow is git revert used?\nThis might sound like a duplicate question but when people ask it, the response is often, use git reset as per Revert to a commit by a SHA hash in Git?.\nThen when someone asks how to use git reset people reply saying you should use git revert as per Git - how to rollback.\nBefore you know it, eight different people appeared with their own unique ways to save the OP's ass, all of which is over your head.\nSo let’s try and stick the brief and write a Dummies Guide to git revert.\nA scenario: you've committed twice to master and it’s bad. You've pushed and other people have your bad changes.\nYou want to undo it. It’s not something you can hand-undo in code yourself, say some wizard or package manager changed tons of stuff all over the place - you just want to put it all back how it was.\nThis is what source control is all about. I'm sure it’s easy.\nOkay, you're going to use git revert, but how?\nAnd after running git revert, do you have to do something else after? Do you have to commit the changes revert made or does revert directly commit to the repository or what??\nObviously, you'll need to push again and probably announce your balls-up to the team."}, {"role": "assistant", "content": "git revert makes a new commit\ngit revert simply creates a new commit that is the opposite of an existing commit.\nIt leaves the files in the same state as if the commit that has been reverted never existed. For example, consider the following simple example:\n$ cd /tmp/example\n$ git init\nInitialized empty Git repository in /tmp/example/.git/\n$ echo \"Initial text\" > README.md\n$ git add README.md\n$ git commit -m \"initial commit\"\n[master (root-commit) 3f7522e] initial commit\n 1 file changed, 1 insertion(+)\n create mode 100644 README.md\n$ echo \"bad update\" > README.md \n$ git commit -am \"bad update\"\n[master a1b9870] bad update\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\nIn this example the commit history has two commits and the last one is a mistake. Using git revert:\n$ git revert HEAD\n[master 1db4eeb] Revert \"bad update\"\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\nThere will be 3 commits in the log:\n$ git log --oneline\n1db4eeb Revert \"bad update\"\na1b9870 bad update\n3f7522e initial commit\n\nSo there is a consistent history of what has happened, yet the files are as if the bad update never occured:\ncat README.md \nInitial text\n\nIt doesn't matter where in the history the commit to be reverted is (in the above example, the last commit is reverted - any commit can be reverted).\nClosing questions\n\ndo you have to do something else after?\n\nA git revert is just another commit, so e.g. push to the remote so that other users can pull/fetch/merge the changes and you're done.\n\nDo you have to commit the changes revert made or does revert directly commit to the repo?\n\ngit revert is a commit - there are no extra steps assuming reverting a single commit is what you wanted to do.\n\nObviously, you'll need to push again and probably announce your balls-up to the team.\n\nIndeed - if the remote is in an unstable state - communicating to the rest of the team that they need to pull to get the fix (the reverting commit) would be the right thing to do :)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git error: fatal: unable to connect a socket (Invalid argument)\nI've got MSysGit (Git on Windows) working just fine on my home machine, but at work, where we are behind a Microsoft ISA proxy, I get the following error when I do a Git clone:\nH:\ncd \\\ngit clone git://github.com/akitaonrails/vimfiles.git\n\nOutput:\nInitialized empty Git repository in H:/vimfiles/.git/\ngithub.com[0: 65.74.177.129]: errno=Invalid argument\nfatal: unable to connect a socket (Invalid argument)\n\nI've tried setting the http_proxy environment variable to:\nhttp://our-proxy-server:8088\n\nI've set the Git http.proxy configuration directive:\ngit config --global http.proxy http://our-proxy-server:8088\n\nNeither of the above makes a difference.\nDoing a Git clone with http:// instead of git:// yields this:\nH:\ncd \\\ngit clone http://github.com/akitaonrails/vimfiles.git\n\nOutput:\nInitialized empty Git repository in H:/vimfiles/.git/\nfatal: http://github.com/akitaonrails/vimfiles.git/info/refs download error - The requested URL returned error: 407\n\n407 is of course an authentication error.\nIs there a way to get Git working from behind a proxy, specifically an ISA proxy? I don't know if it's going to be worth pursing this."}, {"role": "assistant", "content": "I had the exact same error; but the ~/.gitconfig global config file was the key.\nIf you have a proxy with authentication you need to put in it:\ngit config --global http.proxy http://login:password@our-proxy-server:8088\n\nAnd it just works (with 'git clone http:')\nExample of a blog detailing the same setup: GIT clone over HTTP: who knew?\n\nIf it still fails in 407, it could be related to a problem with git-fetch losing authentication tokens on the second HTTP GET. A more recent version of libcurl might be needed.\n\nUpdate January 2011: jbustamovej mentions in his answer (upvoted) his blog post \"GitHub Behind Corporate Proxy\", which adds this:\n\nIt’s important to note that if your login has a backslash, as in domain\\login, you must escape the backslash, as in:\n\ngit config --global http.proxy http://domain\\\\\\login:password@our-proxy-server:8088"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order --header"}, {"role": "assistant", "content": "Print the contents of the commit in raw-format; each record is\nseparated with a NUL character."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --indent-heuristic"}, {"role": "assistant", "content": "Enable the heuristic that shifts diff hunk boundaries to make patches\neasier to read. This is the default."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options pack.island"}, {"role": "assistant", "content": "An extended regular expression configuring a set of delta\nislands. See \"DELTA ISLANDS\" in git-pack-objects for details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Github: readonly access to a private repo\n\nI am developing some private projects on Github, and I would like to add nightly cronjobs to my deployments servers to pull the latest version from github. I am currently doing this by generating keypairs on every deployment server and adding the public key to the github project as 'Deployment key'. \nHowever, I recently found out that these deployment keys actually do have write access to the project. Hence, every of the server administrators could potentially start editing. Furthermore I can add every deployment key to only one repository, whereas I would like to be able to deploy multiple repositories on one and the same deployment server.\nIs there a way to provide read-only access for private repositories to selected users on Github?"}, {"role": "assistant", "content": "I have it on good authority that the (relatively new) \"Organizations\" feature allows you to add people with read-only access to a private repository."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -B[<n>][/<m>] --break-rewrites[=[<n>][/<m>]]"}, {"role": "assistant", "content": "Break complete rewrite changes into pairs of delete and\ncreate. This serves two purposes: It affects the way a change that amounts to a total rewrite of a file\nnot as a series of deletion and insertion mixed together with a very\nfew lines that happen to match textually as the context, but as a\nsingle deletion of everything old followed by a single insertion of\neverything new, and the number m controls this aspect of the -B\noption (defaults to 60%). -B/70% specifies that less than 30% of the\noriginal should remain in the result for Git to consider it a total\nrewrite (i.e. otherwise the resulting patch will be a series of\ndeletion and insertion mixed together with context lines). When used with -M, a totally-rewritten file is also considered as the\nsource of a rename (usually -M only considers a file that disappeared\nas the source of a rename), and the number n controls this aspect of\nthe -B option (defaults to 50%). -B20% specifies that a change with\naddition and deletion compared to 20% or more of the file’s size are\neligible for being picked up as a possible source of a rename to\nanother file."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can I schedule only one specific GitLab CI/CD job?\n\nAt the moment, I have a couple of CI/CD jobs configured in gitlab-ci.yaml within a pipeline. For instance, I have the build and deploy configured within one branch. One of the jobs is creating a backup.\nI would like to schedule only the backup job every night. However, in the schedule section of GitLab CI/CD, I can only select a branch or a tag. This will result in all the stages/jobs to be triggered, whereas I only want the backup to be triggered.\nI've seen the option to configure rules and excepts to only trigger the jobs in a certain context. That, however, feels a bit like a patch solution. Is there another way to trigger only a single job in the Gitlab CI/CD scheduler?"}, {"role": "assistant", "content": "I've seen the option to configure rules and excepts to only trigger the jobs in a certain context. That, however, feels a bit like a patch solution. Is there another way to trigger only a single job in the Gitlab CI/CD scheduler?\n\nNo, there's no other way than using rules: or only:/except: to control which jobs run when the pipeline is triggered by a schedule.\nYou can make this more manageable by splitting your pipeline configuration to multiple files then using the appropriate rules: on the include:\ninclude:\n - local: /do-backup.yml\n rules:\n - if: '$CI_PIPELINE_SOURCE == \"schedule\"'\n - local: /do-pipeline.yml\n rules:\n - if: '$CI_PIPELINE_SOURCE != \"schedule\"'\n\nThat way you don't have to necessarily apply the same rules: to every single job and you can define additional rules: per job with less conflict."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Gitlab CI/CD pipeline giving Dockerfile error\n\nGood Evening,\nI am trying to deploy my nodeJS app to my Digital Ocean Server and its saying it cant find my Dockerfile. I did check and the Dockerfile does not have a .txt extension. Any guidance is appreciated. I have my variables set in my Gitlab project.\nThe pipeline throws the below error:\n\"$ chmod og= $ID_RSA\nchmod: unrecognized option: ---BEGIN\nBusyBox v1.31.1 () multi-call binary.\nUsage: chmod [-Rcvf] MODE[,MODE]... FILE...\nEach MODE is one or more of the letters ugoa, one of the\nsymbols +-= and one or more of the letters rwxst\n-R Recurse\n-c List changed files\n-v List all files\n-f Hide errors\"\n\n\nstages:\n - build\n - publish\n - deploy\n\nvariables:\n TAG_LATEST: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest\n TAG_COMMIT: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA\n\nbuild:\n image: node:latest\n stage: build\n script:\n - npm install\n - echo \"ACCOUNT_SID=$ACCOUNT_SID\" >> .env\n - echo \"AUTH_TOKEN=$AUTH_TOKEN\" >> .env\n - echo \"API_KEY=$API_KEY\" >> .env\n - echo \"API_SECRET=$API_SECRET\" >> .env\n - echo \"PHONE_NUMBER=$PHONE_NUMBER\" >> .env\n - echo \"sengrid_api=$sengrid_api\" >> .env\n\npublish:\n image: docker:latest\n stage: publish\n services:\n - docker:dind\n script:\n - docker build . -t $TAG_COMMIT -t $TAG_LATEST \n - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY\n - docker push $TAG_COMMIT\n - docker push $TAG_LATEST\n\ndeploy:\n image: alpine:latest\n stage: deploy\n tags:\n - deployment\n script:\n - chmod og= $ID_RSA\n - apk update && apk add openssh-client\n - ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP \"docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY\"\n - ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP \"docker pull $TAG_COMMIT\"\n - ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP \"docker container rm -f my-app || true\"\n - ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP \"docker run -d -p 80:3000 --name my-app $TAG_COMMIT\"\n environment:\n name: production\n url: http://167.172.225.124\n only:\n - master"}, {"role": "assistant", "content": "If you have followed this tutorial as I do (which looks to be the case), It looks the tutorial assumes to run on the master branch, protected.\nI was running on another branch not protected. So I had to unprotect all variables to work on unprotected branches. The job succeeds immediately."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How does Git create unique commit hashes, mainly the first few characters?\nI find it hard to wrap my head around how Git creates fully unique hashes that aren't allowed to be the same even in the first 4 characters. I'm able to call commits in Git Bash using only the first four characters. Is it specifically decided in the algorithm that the first characters are \"ultra\"-unique and will not ever conflict with other similar hashes, or does the algorithm generate every part of the hash in the same way?"}, {"role": "assistant", "content": "Git uses the following information to generate the sha-1:\n\nThe source tree of the commit (which unravels to all the subtrees and\nblobs) \nThe parent commit sha1 \nThe author info (with timestamp)\nThe committer info (right, those are different!, also with timestamp)\nThe commit message\n\n(on the complete explanation; look here).\nGit does NOT guarantee that the first 4 characters will be unique. In chapter 7 of the Pro Git Book it is written:\n\nGit can figure out a short, unique abbreviation for your SHA-1 values.\n If you pass --abbrev-commit to the git log command, the output will\n use shorter values but keep them unique; it defaults to using seven\n characters but makes them longer if necessary to keep the SHA-1\n unambiguous:\n\nSo Git just makes the abbreviation as long as necessary to remain unique. They even note that:\n\nGenerally, eight to ten characters are more than enough to be unique\n within a project.\nAs an example, the Linux kernel, which is a pretty large project with\n over 450k commits and 3.6 million objects, has no two objects whose\n SHA-1s overlap more than the first 11 characters.\n\nSo in fact they just depend on the great improbability of having the exact same (X first characters of a) sha."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Add Github remote to GitKraken\n\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."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I update Homebrew?\nWhen I ran:\nbrew update\n\nI got a message saying it initialized an empty repository in /usr/local/.git/, then I got this error:"}, {"role": "assistant", "content": "cd /usr/local\ngit status\nDiscard all the changes (unless you actually want to try to commit to Homebrew - you probably don't)\ngit status til it's clean\nbrew update"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --full-index"}, {"role": "assistant", "content": "Instead of the first handful of characters, show the full\npre- and post-image blob object names on the \"index\"\nline when generating patch format output."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-submodule"}, {"role": "assistant", "content": "Initialize, update or inspect submodules"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -I<regex> --ignore-matching-lines=<regex>"}, {"role": "assistant", "content": "Ignore changes whose all lines match <regex>. This option may\nbe specified more than once."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git - Push subfolder to different repository\n\nI have a big repository with many files and projects. One of the sub-folders in this repo has to be a new, separated repository.\nI don't need to preserve history in the new one, but I have to be able, at any time, to update new repo with changes from the original repo.\nThe idea is that the old repo is a private, internal gitlab and the new repo is a public repo for deployed project.\nHow can I do this?"}, {"role": "assistant", "content": "You can treat the new repo as subtree for the old repo, and update new repo with old repo by git subtree push. Detail steps as below:\nAssume the old repo has folders project1, project2, project3 etc for different projects. And the project1 has managed in the new repo.\nFrist, replace the project1 folder in old repo by the new repo.\n# Copy project1 folder out of old repo\n# Delete the project1 folder in old repo, then use the commands in old repo\ngit add .\ngit commit -m 'delete project1 folder in old repo'\ngit subtree add --prefix=project1 <URL for new repo> master\n\nNow project1 folder in old repo is the subtree from new repo. You can make change and commit (git commit) in old repo.\nWhen you need to update the new repo by the old repo, you can use:\ngit subtree push --prefix=project1 <URL for new repo> master\n\nNow the new repo will be updated."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-merge - Join two or more development histories together merge.renameLimit"}, {"role": "assistant", "content": "The number of files to consider in the exhaustive portion of\nrename detection during a merge. If not specified, defaults\nto the value of diff.renameLimit. If neither\nmerge.renameLimit nor diff.renameLimit are specified,\ncurrently defaults to 7000. This setting has no effect if\nrename detection is turned off."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Showing commits made directly to a branch, ignoring merges in Git\nWhen using git, is there a way to show commits made to a branch, while ignoring all commits that were brought in by merging? \nI'm trying to review the code changes made on a branch while ignoring the ones we made on other branches that were merged in. I know it's damn near impossible to show a diff in that fashion, but I'd like to be able to find out which commits I need to review."}, {"role": "assistant", "content": "--no-merges\nBoth parents have equal weight in many contexts in git. If you've always been consistent in merging other changes in then you may find that this gives you what you want.\ngit log --no-merges --first-parent\n\nOtherwise you may be able to exclude commits from other named branches.\ngit log --no-merges ^other-branch-1 ^other-branch-2 ^other-branch-3\n\nIf you want to review the changes that you are going to merge back into a principal branch then the easiest thing to do is to perform the merge on a local clone and then just look at the diff with the first parent before publishing the merge."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Differences between git remote update and fetch?\nIs git remote update the equivalent of git fetch?"}, {"role": "assistant", "content": "Yes and no. git remote update fetches from all remotes, not just one.\nWithout looking at the code to see if remote update is just a shell script (possible) it, basically, runs fetch for each remote. git fetch can be much more granular."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-send-pack"}, {"role": "assistant", "content": "Push objects over Git protocol to another repository"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --submodule[=<format>]"}, {"role": "assistant", "content": "Specify how differences in submodules are shown. When specifying --submodule=short the short format is used. This format just\nshows the names of the commits at the beginning and end of the range.\nWhen --submodule or --submodule=log is specified, the log format is used. This format lists the commits in the range like git-submodule summary does. When --submodule=diff is specified, the diff format is used. This format shows an\ninline diff of the changes in the submodule contents between the\ncommit range. Defaults to diff.submodule or the short format\nif the config option is unset."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --textconv --no-textconv"}, {"role": "assistant", "content": "Allow (or disallow) external text conversion filters to be run\nwhen comparing binary files. See gitattributes for\ndetails. Because textconv filters are typically a one-way\nconversion, the resulting diff is suitable for human\nconsumption, but cannot be applied. For this reason, textconv\nfilters are enabled by default only for git-diff and git-log , but not for git-format-patch or\ndiff plumbing commands."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs on, m"}, {"role": "assistant", "content": "Make diff output for merge commits to be shown in the default\nformat. The default format can be changed using log.diffMerges configuration variable, whose default value\nis separate ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git checkout tag, git pull fails in branch\nI have cloned a git repository and then checked out a tag:\n# git checkout 2.4.33 -b my_branch\n\nThis is OK, but when I try to run git pull in my branch, git spits out this error: \n\nThere is no tracking information for the current branch. Please\n specify which branch you want to merge with. See git-pull(1) for\n details\ngit pull <remote> <branch>\n\nIf you wish to set tracking information for this branch you can do so\n with:\ngit branch --set-upstream new origin/<branch>\n\n\nI want git pull to only update the master branch and leave my current branch alone (it's a tag anyway). Is something like this possible?\nThe reason I need this is that I have a automatic script which always git pulls the repository and of course fails because of the error above.."}, {"role": "assistant", "content": "Edit: For newer versions of Git, --set-upstream master has been deprecated, you should use --set-upstream-to instead:\ngit branch --set-upstream-to=origin/master master\n\n\nAs it prompted, you can just run:\ngit branch --set-upstream master origin/master\n\nAfter that, you can simply run git pull to update your code."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git add, commit and push commands in one?\nIs there any way to use these three commands in one?\ngit add .\ngit commit -a -m \"commit\" (do not need commit message either)\ngit push\n\nSometimes I'm changing only one letter, CSS padding or something. Still, I have to write all three commands to push the changes. There are many projects where I'm only one pusher, so this command would be awesome!"}, {"role": "assistant", "content": "Building off of @Gavin's answer:\nMaking lazygit a function instead of an alias allows you to pass it an argument. I have added the following to my .bashrc (or .bash_profile if Mac):\nfunction lazygit() {\n git add .\n git commit -a -m \"$1\"\n git push\n}\n\nThis allows you to provide a commit message, such as \nlazygit \"My commit msg\"\n\nYou could of course beef this up even more by accepting even more arguments, such as which remote place to push to, or which branch."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects --output-indicator-new=<char> --output-indicator-old=<char> --output-indicator-context=<char>"}, {"role": "assistant", "content": "Specify the character used to indicate new, old or context\nlines in the generated patch. Normally they are + , - and\n' ' respectively."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-bugreport"}, {"role": "assistant", "content": "Collect information for user to file a bug report"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git merge commits [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do I squash my last N commits together?\n\n (46 answers)\n \n\n\nHow to check if a string \"StartsWith\" another string?\n\n (19 answers)\n \n\nClosed 5 years ago.\n\n\n\nI'm new to git (and enjoying it a lot!). While developing in a new branch, I kept committing the various development 'states' of my application. Now I have to check it in for review but didn't want everything to go in different commits (different comments and ids).\nHow can I do a push of all changes as if it was the first time?"}, {"role": "assistant", "content": "git rebase -i HEAD~5\n\nallows you to interactively select which of the 5 last commits to join into one; off the top of my head it opens the editor with something like this\npick xxxx commit1\npick xxxx commit2\npick xxxx commit3\npick xxxx commit4\npick xxxx commit5\n\nyou change this into\npick xxxx commit1\nsquash xxxx commit2\nsquash xxxx commit3\nsquash xxxx commit4\npick xxxx commit5\n\nwhich results in two commits being left: first one that has combined commits 1 - 4, and commit 5 (the newest one) which is left alone"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-remote"}, {"role": "assistant", "content": "Manage set of tracked repositories"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Gitlab CI setup error - Could not find a JavaScript runtime\n\nI am trying to setup Gitlab CI for my Ruby on Rails project, but ran into an error that I don't know how to fix.\nThe application is running on Ruby 2.3.1, Rails 5.0 and is using a postgreSQL database.\nMy current .gitlab.ci.yml file looks like this:\n# https://hub.docker.com/r/library/ruby/tags/\nimage: \"ruby:2.3.0\"\n\n# Pick zero or more services to be used on all builds.\n# Only needed when using a docker container to run your tests in.\n# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service\nservices:\n - redis:latest\n - postgres:latest\n - node:latest\n\n# This is a basic example for a gem or script which doesn't use\n# services such as redis or postgres\nbefore_script:\n - gem install bundler # Bundler is not installed with the image\n - bundle install -j $(nproc) # Install dependencies\n\nrubocop:\n script:\n - rubocop\n\nrspec:\n script:\n - rspec spec\n\nrails:\n script:\n - rails db:migrate\n - rspec spec\n\nSo it's supposed to be using NodeJS as runtime. However, I get the following error:\n$ rails db:migrate\nrails aborted!\nBundler::GemRequireError: There was an error while trying to load the gem 'uglifier'.\nGem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.\nBacktrace for gem load error is:\n/usr/local/bundle/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect'\n/usr/local/bundle/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'\n/usr/local/bundle/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>'\n/usr/local/bundle/gems/activesupport-5.0.0.rc2/lib/active_support/dependencies.rb:293:in `require'\n/usr/local/bundle/gems/activesupport-5.0.0.rc2/lib/active_support/dependencies.rb:293:in `block in require'\n/usr/local/bundle/gems/activesupport-5.0.0.rc2/lib/active_support/dependencies.rb:259:in `load_dependency'\n/usr/local/bundle/gems/activesupport-5.0.0.rc2/lib/active_support/dependencies.rb:293:in `require'\n/usr/local/bundle/gems/uglifier-3.0.0/lib/uglifier.rb:5:in `<top (required)>'"}, {"role": "assistant", "content": "You need to have a javascript runtime (e.g. nodejs). You can install it by using the following command:\nFor Ubuntu Users\nsudo apt-get install nodejs\n\nFor CentOS / RedHat Users\nsudo yum install nodejs\n\nIn case you can't install nodejs you can install and then use therubyracer gem. \nDescription from repository:\n\nEmbed the V8 JavaScript interpreter into Ruby.\n\nAdd this line to your Gemfile\ngem 'therubyracer', platforms: :ruby"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-send-email - Send a collection of patches as emails --8bit-encoding=<encoding>"}, {"role": "assistant", "content": "When encountering a non-ASCII message or subject that does not\ndeclare its encoding, add headers/quoting to indicate it is\nencoded in <encoding>. Default is the value of the sendemail.assume8bitEncoding ; if that is unspecified, this\nwill be prompted for if any non-ASCII files are encountered. Note that no attempts whatsoever are made to validate the encoding."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Pushing a large github repo fails with \"unable to push to unqualified destination: master\"\nI have a large git repo (created from an SVN repo) and I want to push it to github. Given it's large, I can't just try and push it directly, as it fails with a \"pack too large\" error.\nAll good so far, I can push the repo one commit at a time. But when I try to do this what happens is: \ngit push origin 86c310d8a680d6d0e052fa7db89adb25348f3e54:master\nerror: unable to push to unqualified destination: master\nThe destination refspec neither matches an existing ref on the remote nor\nbegins with refs/, and we are unable to guess a prefix based on the source ref.\n\nSo, there is no master branch at the remote repo yet, but I'm trying to push to it and it fails.\nHow do I fix this? Or how do I create an empty master branch at the remote so I can push to it?"}, {"role": "assistant", "content": "Push to refs/heads/master, just this one time. \ngit push origin whatever:refs/heads/master\nThat will create it unambiguously as a branch, and you'll be able to push to it normally in the future.\nThis works because there's no remote ref named master (it hasn't been created yet), the target ref isn't fully-qualified with refs/ so git can't figure it out based on that, and the source ref is a hash rather than a name, so it can't figure it out based on that either. By pushing to refs/heads/master it works because the second condition is true, and then afterwards master exists on the remote so the first condition is true"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git shallow clone (clone --depth) misses remote branches\nAfter cloning a remote repository it does not show any remote branch by -a option. What could be the problem? How to debug it? In this snippet two of the remote branches are not shown: \n$ git clone --depth 1 git://git.savannah.gnu.org/pythonwebkit.git\n$ cd pythonwebkit\n$ git branch -a\n* master\n remotes/origin/HEAD -> origin/master\n remotes/origin/master\n$ git --version\ngit version 1.8.3.1\n\nTried the same command on another machine, it works well: \n$ git clone --depth 1 git://git.savannah.gnu.org/pythonwebkit.git\nReceiving objects: 100% (186886/186886), 818.91 MiB | 3.44 MiB/s, done.\n$ cd pythonwebkit/\n$ git branch -a\n* master\n remotes/origin/HEAD -> origin/master\n remotes/origin/debian\n remotes/origin/master\n remotes/origin/python_codegen\n$ git --version\ngit version 1.7.1\n\nTried also cloning another repo, it works well. Though I can try it on this machine again, but it would be better to know what's wrong. \nAny suggestions or hints will be more than welcome. \nEdit: Answer summary: Since git version 1.8.3.2 the \"--depth\" and \"--no-single-branch\" need to be used together to get the same behavior as before. This is deemed a bug fix."}, {"role": "assistant", "content": "After doing a shallow clone,\nto be able to checkout other branches from remote do:\n\nRun (thanks @jthill) doc about set-branches:\ngit remote set-branches origin '*'\n\n\nAfter that, do a git fetch -v --depth=1\n\nFinally git checkout the-branch-i-ve-been-looking-for\n\n\n\nStep 1 can also be done manually by editing .git/config.\nFor instance, change the following line from:\nfetch = +refs/heads/master:refs/remotes/origin/master\n\nto (replace master with *):\nfetch = +refs/heads/*:refs/remotes/origin/*"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options core.splitIndex"}, {"role": "assistant", "content": "If true, the split-index feature of the index will be used.\nSee git-update-index . False by default."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-stash - Stash the changes in a dirty working directory away -p --patch"}, {"role": "assistant", "content": "This option is only valid for push and save commands. Interactively select hunks from the diff between HEAD and the\nworking tree to be stashed. The stash entry is constructed such\nthat its index state is the same as the index state of your\nrepository, and its worktree contains only the changes you selected\ninteractively. The selected changes are then rolled back from your\nworktree. See the “Interactive Mode” section of git-add to learn how to operate the --patch mode. The --patch option implies --keep-index . You can use --no-keep-index to override this."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to have npm install a typescript dependency from a GitHub url?\n\nConsider the following scenario:\n\nThere is a code library. The library is written in TypeScript and the typescript code is published in GitHub. The package.json file has a build script which creates JavaScript files based on the TypeScript code and a publish script which then places the resulting JS files on npm.\nI make a fork of the GitHub repo, make some modifications to the typescript files and push those changes to GitHub. (I also open a PR to the original GitHub repo but there is a time lage before these changes can be merged.)\nI wish to consume these code changes in a downstream NPM package so in the downstream packages I change the reference (in the downstream's package.json file) to the modified package to the GitHub URL of my fork and do an npm install.\n\nThis doesn't work because:\n\nThe package.json file of the modified package does not list the typescript files in the dist field, only the automatically generated JS files so the TypeScript files are not pulled during the npm install.\nThe compiled JS files aren't present since they aren't checked in to GitHub.\n\nHow can I solve this? Is there a way that I can modify the behavoir of npm install so that it fetches files in the repo that aren't in dist and then runs the build script during the install?"}, {"role": "assistant", "content": "I had the same problem. Saw a lot of articles about monorepos (links below), but not much about how to split a TypeScript project into separate repositories. \nIn short, you need to build JS files at one step or the other.\nSee https://github.com/stared/yarn-adding-pure-typescript-package-example for a working code example.\nSo, there are a few solutions. Let's say that the repository is someuser/package-to-import\nPostinstall\nUsing yarn you can get the project directly from a GitHub repository:\nyarn add someuser/package-to-import#master\n\n(or the same with npm install someuser/package-to-import#master)\nIf you work on a fork of this repository, you can make your life easier by adding to package.json in package-to-import repo this part:\n \"scripts\": {\n ...,\n \"postinstall\": \"tsc --outDir ./build\"\n }\n\nNow it just works with yarn add/upgrade with no extra scripts.\nAlternatively, you can do it semi-manually, i.e. create a script in your main repository package.json\n \"scripts\": {\n ...,\n \"upgrade-package-to-import\": \"yarn upgrade package-to-import && cd node_modules/package-to-import && yarn build\"\n }\n\nLink\nThere is a different approach to clone the repository into a different folder, build the files, and link it.\ngit clone [email protected]:someuser/package-to-import.git\ncd package-to-import\nnpm run build # or any other instruction to build\nnpm link\n\nIf you use yarn, the two last lines would be:\nyarn build\nyarn link\n\nThen, enter the folder of your project and write\nnpm link package-to-import\n\nor in case of yarn\nyarn link package-to-import\n\nThese are symlinks, so when you pull from the repo and build files, you will use the updated version.\nSee also:\n\nnpm link andyarn link official documentations\nThe magic behind npm link\n\nMonorepos\nAn entirely different approach.\nWith mixed advice for using git submodules:\n\n4 Ways to Go Monorepo in 2019\n4 Git Submodules Alternatives You Should Know\nA (multi-) monorepo setup with Git Submodules"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git stash apply @stash{x} not working for me\nI am trying to apply a specific stash using:\ngit stash apply stash@{2}\n\nBut end up with this error:\n\nfatal: ambiguous argument 'stash@': unknown revision or path not in\n the working tree.\n\nI have plenty of stashed entries, over 20 if I do a git stash list\nI am unsure what this error is trying to tell me, can someone advise further? Thanks"}, {"role": "assistant", "content": "You need to quote the string, because your shell is eating the content of the {} as an expansion. So use git stash apply 'stash@{2}'. Alternatively you can use the SHA of the stash, or next time when you apply it, you can name the stash yourself."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git copy file, as opposed to `git mv`\nI realize that git works by diff'ing the contents of files. I have some files that I want to copy. To absolutely prevent git from ever getting confused, is there some git command that can be used to copy the files to a different directory (not mv, but cp), and stage the files as well?"}, {"role": "assistant", "content": "The short answer is just \"no\". But there is more to know; it just requires some background. (And as JDB suggests in a comment, I'll mention why git mv exists as a convenience.)\nSlightly longer: you're right that Git will diff files, but you may be wrong about when Git does these file-diffs.\nGit's internal storage model proposes that each commit is an independent snapshot of all the files in that commit. The version of each file that goes into the new commit, i.e., the data in the snapshot for that path, is whatever is in the index under that path at the time you run git commit.1\nThe actual implementation, to the first level, is that each snapshotted-file is captured in compressed form as a blob object in the Git database. The blob object is quite independent of every previous and subsequent version of that file, except for one special case: if you make a new commit in which no data have changed, you will re-use the old blob. So when you make two commits in a row, each of which holds 100 files, and only one file is changed, the second commit re-uses 99 previous blobs, and need only snapshot one actual file into a new blob.2\nHence the fact that Git will diff files doesn't enter into making commits at all. No commit depends on a previous commit, other than to store the previous commit's hash ID (and perhaps to re-use exactly-matching blobs, but that's a side effect of them exactly matching, rather than a fancy computation at the time you run git commit).\nNow, all these independent blob objects do eventually take up an exorbitant amount of space. At this point, Git can \"pack\" objects into a .pack file. It will compare each object to some selected set of other objects—they may be earlier or later in history, and have the same file name or different file names, and in theory Git could even compress a commit object against a blob object or vice versa (though in practice it doesn't)—and try to find some way to represent many blobs using less disk space. But the result is still, at least logically, a series of independent objects, retrieved completely intact in their original form using their hash IDs. So even though the amount of disk space used goes down (we hope!) at this point, all of the objects are exactly the same as before.\nSo when does Git compare files? The answer is: Only when you ask it to. The \"ask time\" is when you run git diff, either directly:\ngit diff commit1 commit2\n\nor indirectly:\ngit show commit # roughly, `git diff commit^@ commmit`\ngit log -p # runs `git show commit`, more or less, on each commit\n\nThere are a bunch of subtleties about this—in particular, git show will produce what Git calls combined diffs when run on merge commits, while git log -p normally just skips right over the diffs for merge commits—but these, along with some other important cases, are when Git runs git diff.\nIt's when Git runs git diff that you can (sometimes) ask it to find, or not to find, copies. The -C flag, also spelled --find-copies=<number>, asks Git to find copies. The --find-copies-harder flag (which the Git documentation calls \"computationally expensive\") looks harder for copies than the plain -C flag. The -B (break inappropriate pairings) option affects -C. The -M aka --find-renames=<number> option also affects -C. The git merge command can be told to adjust its level of rename detection, but—at least currently—cannot be told to find copies, nor break inappropriate pairings.\n(One command, git blame, does somewhat different copy-finding and the above does not entirely apply to it.)\n\n1If you run git commit --include <paths> or git commit --only <paths> or git commit <paths> or git commit -a, think of these as modifying the index before running git commit. In the special case of --only, Git uses a temporary index, which is a little bit complicated, but it still commits from an index—it just uses the special temporary one instead of the normal one. To make the temporary index, Git copies all the files from the HEAD commit, then overlays those with the --only files you listed. For the other cases, Git just copies the work-tree files into the regular index, then goes on to make the commit from the index as usual.\n2In fact, the actual snapshotting, storing the blob into the repository, happens during git add. This secretly makes git commit much faster, since you don't normally notice the extra time it takes to run git add before you fire up git commit.\n\nWhy git mv exists\nWhat git mv old new does is, very roughly:\nmv old new\ngit add new\ngit add old\n\nThe first step is obvious enough: we need to rename the work-tree version of the file. The second step is similar: we need to put the index version of the file into place. The third, though, is weird: why should we \"add\" a file we just removed? Well, git add doesn't always add a file: instead, in this case it detects that the file was in the index and isn't anymore.\nWe could also spell that third step as:\ngit rm --cached old\n\nAll we're really doing is taking the old name out of the index.\nBut there's an issue here, which is why I said \"very roughly\". The index has a copy of each file that will be committed the next time you run git commit. That copy might not match the one in the work-tree. In fact, it might not even match the one in HEAD, if there is one in HEAD at all.\nFor instance, after:\necho I am a foo > foo\ngit add foo\n\nthe file foo exists in the work-tree and in the index. The work-tree contents and the index contents match. But now let's change the work-tree version:\necho I am a bar > foo\n\nNow the index and work-tree differ. Suppose we want to move the underlying file from foo to bar, but—for some strange reason3—we want to keep the index contents unchanged. If we run:\nmv foo bar\ngit add bar\n\nwe'll get I am a bar inside the new index file. If we then remove the old version of foo from the index, we lose the I am a foo version entirely.\nSo, git mv foo bar doesn't really move-and-add-twice, or move-add-and-remove. Instead, it renames the work-tree file and renames the in-index copy. If the index copy of the original file differs from the work-tree file, the renamed index copy still differs from the renamed work-tree copy.\nIt's very difficult to do this without a front end command like git mv.4 Of course, if you plan to git add everything, you don't need all of this stuff in the first place. And, it's worth noting that if git cp existed, it probably should also copy the index version, not the work-tree version, when making the index copy. So git cp really should exist. There also should be a git mv --after option, a la Mercurial's hg mv --after. Both should exist, but currently don't. (There's less call for either of these, though, than there is for straight git mv, in my opinion.)\n\n3For this example, it's kind of silly and pointless. But if you use git add -p to carefully prepare a patch for an intermediate commit, and then decide that along with the patch, you would like to rename the file, it's definitely handy to be able to do that without messing up your carefully-patched-together intermediate version.\n4It's not impossible: git ls-index --stage will get you the information you need from the index as it is right now, and git update-index allows you to make arbitrary changes to the index. You can combine these two, and some complex shell scripting or programming in a nicer language, to build something that implements git mv --after and git cp."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I see the size of a GitHub repository before cloning it?\nIs there a way to see how big a Git repository is on GitHub before you decide to clone it?\nThis seems like a really obvious/basic statistic, but I can't find how to see it on GitHub at all."}, {"role": "assistant", "content": "There's a way to access this information through the GitHub API.\n\nSyntax: GET /repos/:user/:repo\nExample: https://api.github.com/repos/git/git\n\nWhen retrieving information about a repository, a property named size is valued with the size of the whole repository (including all of its history), in kilobytes.\nFor instance, the Git repository weights around 124 MB. The size property of the returned JSON payload is valued to 124283.\nUpdate\nThe size is indeed expressed in kilobytes based on the disk usage of the server-side bare repository. However, in order to avoid wasting too much space with repositories with a large network, GitHub relies on Git Alternates. In this configuration, calculating the disk usage against the bare repository doesn't account for the shared object store and thus returns an \"incomplete\" value through the API call.\nThis information has been given by GitHub support."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-archimport"}, {"role": "assistant", "content": "Import a GNU Arch repository into Git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git search all diffs\nI'm trying to search for changes in my git history relating to a very specific variable name.\nI've tried doing this: \ngit diff HEAD~25000 | grep -in mydistinctvariablename\n\nThe results don't tell me which commit the result lines are from and it takes quite a bit of time (about 5-7 minutes).\nDoes anyone have a better solution, time and results wise?"}, {"role": "assistant", "content": "git log is generally the command to use when examining commit history. git log --grep can be used to search for regular expressions in the commit message.\nWhat you are after is git log -S which searches the commit content simply or git log -G which searches it with a regular expression:\n\n-S<string>\nLook for differences that introduce or remove an instance of <string>. Note that this is different than the string simply appearing in diff output; see the pickaxe entry in gitdiffcore(7) for more details.\n\nSo, for instance, in the msysGit repository I can find the commit that introduced Tcl 8.5.8 using either:\nC:\\src\\msysgit\\src>git log --oneline --grep \"8\\.5\\.8\"\nd938476 Make `NO_SFX=1 portable-release.sh` work\nef1dc94 Update tk to version 8.5.8\na910049 Update tcl to version 8.5.8\na702d7f tcltk: update to 8.5.8 and exclude release.sh from the cleanup list\n\nwhich just looked for 8.5.8 in the commit messages or as you want to do looking at a string that only occurred in the committed diff:\nC:\\src\\msysgit\\src>git log --oneline -S\"version=8.5.8\"\n7be8622 tcltk: update release.sh script for tcl/tk 8.5.9\na702d7f tcltk: update to 8.5.8 and exclude release.sh from the cleanup list\n\nThe range limiting you have in your sample can still be used here to limit the commits to be examined. Read though the git log manual carefully to get a good idea of all the things it can do.\nNote that -S just looks for simple string differences - if you really want to search the content using a regular expression similar to you example then you should use the -G option instead of -S but this will be significantly slower."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-format-patch - Prepare patches for e-mail submission -X[<param1,param2,…​>] --dirstat[=<param1,param2,…​>]"}, {"role": "assistant", "content": "Output the distribution of relative amount of changes for each\nsub-directory. The behavior of --dirstat can be customized by\npassing it a comma separated list of parameters.\nThe defaults are controlled by the diff.dirstat configuration\nvariable (see git-config ).\nThe following parameters are available: changes Compute the dirstat numbers by counting the lines that have been\nremoved from the source, or added to the destination. This ignores\nthe amount of pure code movements within a file. In other words,\nrearranging lines in a file is not counted as much as other changes.\nThis is the default behavior when no parameter is given. lines Compute the dirstat numbers by doing the regular line-based diff\nanalysis, and summing the removed/added line counts. (For binary\nfiles, count 64-byte chunks instead, since binary files have no\nnatural concept of lines). This is a more expensive --dirstat behavior than the changes behavior, but it does count rearranged\nlines within a file as much as other changes. The resulting output\nis consistent with what you get from the other --*stat options. files Compute the dirstat numbers by counting the number of files changed.\nEach changed file counts equally in the dirstat analysis. This is\nthe computationally cheapest --dirstat behavior, since it does\nnot have to look at the file contents at all. cumulative Count changes in a child directory for the parent directory as well.\nNote that when using cumulative , the sum of the percentages\nreported may exceed 100%. The default (non-cumulative) behavior can\nbe specified with the noncumulative parameter. <limit> An integer parameter specifies a cut-off percent (3% by default).\nDirectories contributing less than this percentage of the changes\nare not shown in the output. Example: The following will count changed files, while ignoring\ndirectories with less than 10% of the total amount of changed files,\nand accumulating child directory counts in the parent directories: --dirstat=files,10,cumulative ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-shortlog - Summarize git log output --basic-regexp"}, {"role": "assistant", "content": "Consider the limiting patterns to be basic regular expressions;\nthis is the default."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "diff current working copy of a file with another branch's committed copy\nI have a repo with file foo in the master branch. I switched to bar branch and made some changes to foo. How can I now run a git diff between this copy (which isn't committed yet) and the copy of the master branch?"}, {"role": "assistant", "content": "The following works for me:\ngit diff master:foo foo\nIn the past, it may have been:\ngit diff foo master:foo"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --dense"}, {"role": "assistant", "content": "Commits that are walked are included if they are not TREESAME\nto any parent."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-shortlog - Summarize git log output --cherry"}, {"role": "assistant", "content": "A synonym for --right-only --cherry-mark --no-merges ; useful to\nlimit the output to the commits on our side and mark those that\nhave been applied to the other side of a forked history with git log --cherry upstream...mybranch , similar to git cherry upstream mybranch ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Github oauth multiple authorization callback URL\n\nI want to work in my localhost and my live domain, there is any way to insert more then one callback to github oauth settings? How we solve this problem?\nRedirect URLs"}, {"role": "assistant", "content": "I solved this issue by creating a dedicated OAuth application on Github for my local development environment. So I have the following 2 OAuth applications:\n\nMy official OAuth application for production\n\nClient ID: ABC\nClient Secret: 123\nAuthorization callback URL: https://example.com/api/v1/security/oauth/github/callback\n\nMy private OAuth application for development\n\nClient ID: XYZ\nClient Secret: 456\nAuthorization callback URL: https://localhost/api/v1/security/oauth/github/callback\n\n\nWhen I configure my API in local, I use the ID and secret of the development application (2). And in production I use the ID and secret of my official application (1)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git list of branch names of specific remote\nHow can it possible to get all names of some remote origin branches?\nI started from --remote --list options, but got redundant origin/HEAD -> origin/master message and branches from the another origin.\n$> git branch --remote --list\n origin/HEAD -> origin/master\n origin1/develop\n origin1/feature/1\n origin1/feature/2\n origin1/feature/3\n origin1/master\n origin2/develop\n origin2/feature/1\n origin2/feature/2\n origin2/master\n\nBranches of specific origin could be matched with <pattern> option, but redundant message is still there. Actually that pattern is not really correct, because some origin's name could be a substring of another origin name, or even some branch.\n$> git branch --remote --list origin1*\n origin1/HEAD -> origin/master\n origin1/develop\n origin1/feature/1\n origin1/feature/2\n origin1/feature/3\n origin1/master\n\nWhat am I looking for is a list of branch names of origin1, any of them I could use for git checkout command. Something like that:\ndevelop\nfeature/1\nfeature/2\nfeature/3\nmaster\n\nIt's important that it should be done without grep, sed, tail or even ghc -e wrappers, only with true git power, because of their unsafeness and variation."}, {"role": "assistant", "content": "It's important that it should be done without grep, sed, tail or even ghc -e wrappers, only with true git power, because of their unsafeness and variation.\n\nThat is only true for git porcelain commands (see \"What does the term porcelain mean in Git?\")\nUse the plumbing command ls-remote, and then you will be able to filter its output.\nls-remote without parameter would still list the remote HEAD:\ngit@vonc-VirtualBox:~/ce/ce6/.git$ git ls-remote origin\n8598d26b4a4bbe416f46087815734d49ba428523 HEAD\n8598d26b4a4bbe416f46087815734d49ba428523 refs/heads/master\n38325f657380ddef07fa32063c44d7d6c601c012 refs/heads/test_trap\n\nBut if you ask only for the heads of said remote:\ngit@vonc-VirtualBox:~/ce/ce6/.git$ git ls-remote --heads origin\n8598d26b4a4bbe416f46087815734d49ba428523 refs/heads/master\n38325f657380ddef07fa32063c44d7d6c601c012 refs/heads/test_trap\n\nFinal answer:\ngit@vonc-VirtualBox:~/ce/ce6/.git$ git ls-remote --heads origin | sed 's?.*refs/heads/??'\nmaster\ntest_trap\n\n(Yes, it uses sed, but the output of a plumbing command is supposed to be stable enough to be parsed)\n\nSee also Git 2.23 (Q3 2019) which documents an example:\ngit branch -r -l '<remote>/<pattern>'\ngit for-each-ref 'refs/remotes/<remote>/<pattern>'"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Maintain git repo inside another git repo\nHere's what I'd like:\nREPO-A\n /.git\n /otherFiles\n /REPO-B\n /.git\n /moreFiles\n\nI want to be able to push all of REPO-A's contents to REMOTE-A and only REPO-B to REMOTE-B.\nPossible?"}, {"role": "assistant", "content": "It sounds like you want to use Git submodules.\n\nGit addresses this issue using submodules. Submodules allow you to keep a Git repository as a subdirectory of another Git repository. This lets you clone another repository into your project and keep your commits separate."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects %(describe[:<options>])"}, {"role": "assistant", "content": "human-readable name, like git-describe ; empty string for\nundescribable commits. The describe string may be followed by a colon and\nzero or more comma-separated options. Descriptions can be inconsistent when\ntags are added or removed at the same time. tags[=<bool-value>] : Instead of only considering annotated tags,\nconsider lightweight tags as well. abbrev=<number> : Instead of using the default number of hexadecimal digits\n(which will vary according to the number of objects in the repository with a\ndefault of 7) of the abbreviated object name, use <number> digits, or as many\ndigits as needed to form a unique object name. match=<pattern> : Only consider tags matching the given glob(7) pattern, excluding the \"refs/tags/\" prefix. exclude=<pattern> : Do not consider tags matching the given glob(7) pattern, excluding the \"refs/tags/\" prefix."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc lines"}, {"role": "assistant", "content": "Compute the dirstat numbers by doing the regular line-based diff\nanalysis, and summing the removed/added line counts. (For binary\nfiles, count 64-byte chunks instead, since binary files have no\nnatural concept of lines). This is a more expensive --dirstat behavior than the changes behavior, but it does count rearranged\nlines within a file as much as other changes. The resulting output\nis consistent with what you get from the other --*stat options."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to configure 'git log' to show 'commit date'\nHow can I configure git log to show commit date instead of author date?"}, {"role": "assistant", "content": "There are several options to pretty print the date. Probably the easiest is to just use one of the pre-baked --pretty formats, like git log --pretty=fuller - this will show both dates. If you want to see only one date, but make it the commit date, you can use git log --format=<some stuff>. All the allowable codes for defining the format are documented in git help log. The commit date is one of %cd, %cD, %cr, %ct or %ci, depending on what format you prefer it in.\nIf it's something you want to do often, put it in an alias or write an auxiliary script to save on typing."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options core.hideDotFiles"}, {"role": "assistant", "content": "(Windows-only) If true, mark newly-created directories and files whose\nname starts with a dot as hidden. If dotGitOnly , only the .git/ directory is hidden, but no other files starting with a dot. The\ndefault mode is dotGitOnly ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --raw"}, {"role": "assistant", "content": "For each commit, show a summary of changes using the raw diff\nformat. See the \"RAW OUTPUT FORMAT\" section of git-diff . This is different from showing the log\nitself in raw format, which you can achieve with --format=raw ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options trace2.destinationDebug"}, {"role": "assistant", "content": "Boolean. When true Git will print error messages when a\ntrace target destination cannot be opened for writing.\nBy default, these errors are suppressed and tracing is\nsilently disabled. May be overridden by the GIT_TRACE2_DST_DEBUG environment variable."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to rebase all the commits from the beginning\nSo I'm migrating from svn (code.google.com) to git(github).\nI've imported my project from the svn repo, and it imported all the commit history along way.\nI'm not really proud of those comments as it was one of my first project, not really serious.\nI'd like to rebase everything into a single 'initial import' commit.\nI've pulled everything on my computer and I'm trying to do that. But all I found was: \ngit rebase -i master but it only rebases new modifications and commits.\nHow can I clean my github repository from all history with a rebase?"}, {"role": "assistant", "content": "git rebase -i --root will start an interactive rebase of all commits from the beginning.\nFrom there, you can squash all commits into one and/or perform other edits."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Link and execute external JavaScript file hosted on GitHub\n\nWhen I try to change the linked reference of a local JavaScript file to a GitHub raw version my test file stops working. The error is: \n\nRefused to execute script from ... because its MIME type (text/plain) is not executable, and strict MIME type checking is enabled. \n\nIs there a way to disable this behavior or is there a service that allows linking to GitHub raw files?\nWorking code:\n<script src=\"bootstrap-wysiwyg.js\"></script>\n\nNon-working code:\n<script src=\"https://raw.github.com/mindmup/bootstrap-wysiwyg/master/bootstrap-wysiwyg.js\"></script>"}, {"role": "assistant", "content": "There is a good workaround for this, now, by using jsdelivr.net.\nSteps:\n\nFind your link on GitHub, and click to the \"Raw\" version.\nCopy the URL.\nChange raw.githubusercontent.com to cdn.jsdelivr.net\nInsert /gh/ before your username.\nRemove the branch name.\n(Optional) Insert the version you want to link to, as @version (if you do not do this, you will get the latest - which may cause long-term caching)\n\n\nExamples:\nhttp://raw.githubusercontent.com/<username>/<repo>/<branch>/path/to/file.js\n\nUse this URL to get the latest version:\nhttp://cdn.jsdelivr.net/gh/<username>/<repo>/path/to/file.js\n\nUse this URL to get a specific version or commit hash:\nhttp://cdn.jsdelivr.net/gh/<username>/<repo>@<version or hash>/path/to/file.js\n\nFor production environments, consider targeting a specific tag or commit-hash rather than the branch. Using the latest link may result in long-term caching of the file, causing your link to not be updated as you push new versions. Linking to a file by commit-hash or tag makes the link unique to version.\n\nWhy is this needed?\nIn 2013, GitHub started using X-Content-Type-Options: nosniff, which instructs more modern browsers to enforce strict MIME type checking. It then returns the raw files in a MIME type returned by the server, preventing the browser from using the file as-intended (if the browser honors the setting).\nFor background on this topic, please refer to this discussion thread."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs %<( <N> [,trunc|ltrunc|mtrunc])"}, {"role": "assistant", "content": "make the next placeholder take at\nleast N column widths, padding spaces on\nthe right if necessary. Optionally\ntruncate (with ellipsis .. ) at the left (ltrunc) ..ft ,\nthe middle (mtrunc) mi..le , or the end\n(trunc) rig.. , if the output is longer than\nN columns.\nNote 1: that truncating\nonly works correctly with N >= 2.\nNote 2: spaces around the N and M (see below)\nvalues are optional.\nNote 3: Emojis and other wide characters\nwill take two display columns, which may\nover-run column boundaries.\nNote 4: decomposed character combining marks\nmay be misplaced at padding boundaries."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git pull not pulling everything\nI have a server where there's some config that I don't properly know where i just git pull and it gets what is in a github repo, then restart it in order to deploy.\nThe thing is, there's a commit which isn't my latest, that isn't really on my server. The files aren't in .gitignore. How do I assure that a pull, pulled a commit?\nI really don't know how to fix it, I'm thinking about restarting everything :(\n14:41][root@someserver] someserver_dir (master)$ git status\n# On branch master\n# Changes not staged for commit:\n# (use \"git add <file>...\" to update what will be committed)\n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n# modified: Gemfile\n# modified: Gemfile.lock\n# modified: config/assets.yml\n# modified: config/database.yml\n#\n# Untracked files:\n# (use \"git add <file>...\" to include in what will be committed)\n#\n# randomfiles"}, {"role": "assistant", "content": "If you always want your server version to reflect a commit from your repo, it's probably better to use git reset instead of git pull - that way you never invoke merge functionality, but instead set all of the files to exactly what they are in the commit you reset to. For example:\ngit fetch origin master\ngit reset --hard FETCH_HEAD"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to view file diff in git before commit\nThis often happens to me: \nI'm working on a couple related changes at the same time over the course of a day or two, and when it's time to commit, I end up forgetting what changed in a specific file. (This is just a personal git repo, so I'm ok with having more than one update in a commit.) \nIs there any way to preview the changes between my local file, which is about to be checked in, and the last commit for that file? \nSomething like:\ngit diff --changed /myfile.txt\n\nAnd it would print out something like:\nline 23\n (last commit): var = 2+2\n (current): var = myfunction() + 2\n\nline 149\n (last commit): return var\n (current): return var / 7\n\nThis way, I could quickly see what I had done in that file since it was last checked in."}, {"role": "assistant", "content": "If you want to see what you haven't git added yet:\ngit diff myfile.txt\n\nor if you want to see already added changes\ngit diff --cached myfile.txt"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-push - Update remote refs along with associated objects summary"}, {"role": "assistant", "content": "For a successfully pushed ref, the summary shows the old and new\nvalues of the ref in a form suitable for using as an argument to git log (this is <old>..<new> in most cases, and <old>...<new> for forced non-fast-forward updates). For a failed update, more details are given: rejected Git did not try to send the ref at all, typically because it\nis not a fast-forward and you did not force the update. remote rejected The remote end refused the update. Usually caused by a hook\non the remote side, or because the remote repository has one\nof the following safety options in effect: receive.denyCurrentBranch (for pushes to the checked out\nbranch), receive.denyNonFastForwards (for forced\nnon-fast-forward updates), receive.denyDeletes or receive.denyDeleteCurrent . See git-config . remote failure The remote end did not report the successful update of the ref,\nperhaps because of a temporary error on the remote side, a\nbreak in the network connection, or other transient error."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --do-walk"}, {"role": "assistant", "content": "Overrides a previous --no-walk ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Rename file with Git\n\nI would like to rename file from README to README.md. What is the best practice to do that?\n\nI have only one repo called \"change-z-index\".\n\nI open and login like that:\nssh -T [email protected]\n\n\n\nAnd I enter my passphrase.\n\nI try to rename the file like that:\ngit mv README README.md\ngit commit -m \"renamed\"\ngit push origin master\n\n\n\nIt gives me an error saying bad source.\nI think I need to select my repo first... its name is \"change-z-index\". I have read manual many times, but still can't understand how to do it."}, {"role": "assistant", "content": "As far as I can tell, GitHub does not provide shell access, so I'm curious about how you managed to log in in the first place.\n$ ssh -T [email protected]\nHi username! You've successfully authenticated, but GitHub does not provide\nshell access.\n\nYou have to clone your repository locally, make the change there, and push the change to GitHub.\n$ git clone [email protected]:username/reponame.git\n$ cd reponame\n$ git mv README README.md\n$ git commit -m \"renamed\"\n$ git push origin master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitlab: Runner is offline, last contact was about some hours ago\n\nrecently my runners have been stopped and I don't know why?\nI've just upgraded nodejs on the server and it did happen.\nafter this problem, I've tried to update gitlab to the latest version and check the runner status but the problem still persists and in the title of grey icon shows: \n\nRunner is offline, the last contact was about 22 hours ago.\n\n\nWhat should I do?\nand when I try to Retry stuck jobs, see this error:\n\nThis job is stuck, because you don't have any active runners online with any of these tags assigned to them: 'my label'.\n\nAny Help is appreciated!"}, {"role": "assistant", "content": "To me, the following solved the problem:\ngitlab-runner restart\n\nWhere gitlab-runner is a symlink to gitlab-ci-multi-runner:\n\nGitLab Runner is the open source project that is used to run your jobs and send the results back to GitLab. It is used in conjunction with GitLab CI, the open-source continuous integration service included with GitLab that coordinates the jobs."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What's the strategy for handling CRLF (carriage return, line feed) with Git?\nI tried committing files with CRLF-ending lines, but it failed.\nI spent a whole work day on my Windows computer trying different strategies and was almost drawn to stop trying to use Git and instead try Mercurial.\nHow to properly handle CRLF line endings?"}, {"role": "assistant", "content": "Almost four years after asking this question, I have finally\nfound an answer that completely satisfies me!\nSee the details in github:help's guide to\nDealing with line endings.\n\nGit allows you to set the line ending properties for a\n repo directly using the text attribute in the\n .gitattributes file. This file is committed into\n the repo and overrides the core.autocrlf setting,\n allowing you to ensure consistent behaviour for all\n users regardless of their git settings.\n\nAnd thus\n\nThe advantage of this is that your end of line\n configuration now travels with your repository and you\n don't need to worry about whether or not collaborators\n have the proper global settings.\n\nHere's an example of a .gitattributes file\n# Auto detect text files and perform LF normalization\n* text=auto\n\n*.cs text diff=csharp\n*.java text diff=java\n*.html text diff=html\n*.css text\n*.js text\n*.sql text\n\n*.csproj text merge=union\n*.sln text merge=union eol=crlf\n\n*.docx diff=astextplain\n*.DOCX diff=astextplain\n\n# absolute paths are ok, as are globs\n/**/postinst* text eol=lf\n\n# paths that don't start with / are treated relative to the .gitattributes folder\nrelative/path/*.txt text eol=lf\n\nThere is a convenient collection of ready to use .gitattributes files for the most popular programming languages. It's useful to get you started.\nOnce you've created or adjusted your .gitattributes, you should perform a once-and-for-all line endings re-normalization.\nNote that the GitHub Desktop app can suggest and create a .gitattributes file after you open your project's Git repo in the app. To try that, click the gear icon (in the upper right corner) > Repository settings ... > Line endings and attributes. You will be asked to add the recommended .gitattributes and if you agree, the app will also perform a normalization of all the files in your repository.\nFinally, the Mind the End of Your Line article\nprovides more background and explains how Git has evolved\non the matters at hand. I consider this required reading.\nYou've probably got users in your team who use EGit or JGit (tools like Eclipse and TeamCity use them) to commit their changes. Then you're out of luck, as @gatinueta explained in this answer's comments:\n\nThis setting will not satisfy you completely if you have people working with Egit or JGit in your team, since those tools will just ignore .gitattributes and happily check in CRLF files https://bugs.eclipse.org/bugs/show_bug.cgi?id=342372\n\nOne trick might be to have them commit their changes in another client, say SourceTree. Our team back then preferred that tool to Eclipse's EGit for many use cases.\nWho said software is easy? :-/"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-archive - Create an archive of files from a named tree"}, {"role": "assistant", "content": "DESCRIPTION Creates an archive of the specified format containing the tree\nstructure for the named tree, and writes it out to the standard\noutput. If <prefix> is specified it is\nprepended to the filenames in the archive. git archive behaves differently when given a tree ID as opposed to a\ncommit ID or tag ID. When a tree ID is provided, the current time is\nused as the modification time of each file in the archive. On the\nother hand, when a commit ID or tag ID is provided, the commit time as\nrecorded in the referenced commit object is used instead.\nAdditionally the commit ID is stored in a global extended pax header\nif the tar format is used; it can be extracted using git\nget-tar-commit-id . In ZIP files it is stored as a file comment."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-branch - List, create, or delete branches --color[=<when>]"}, {"role": "assistant", "content": "Color branches to highlight current, local, and\nremote-tracking branches.\nThe value must be always (the default), never, or auto."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to revert Master branch to upstream\n\nI have forked a git repository and setup upstream. I've made some changes in Master branch and committed and pushed to github.\nNow what should I do to abandon all my changes in Master branch and make it identical to the upstream's master branch?"}, {"role": "assistant", "content": "(I'm assuming that the changes that you now want to ignore are at your origin remote, you're on your master branch, and you want to revert to the contents of the upstream remote)\nFirstly, reset your working copy to the upstream master:\ngit remote update\n# the double hyphen ensures that upstream/master is\n# considered as a revision and not confused as a path\ngit reset --hard upstream/master --\n\nThen push this new branch-head to your origin repository, ignoring the fact that it won't be a fast-forward:\ngit push origin +master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Ignore files with names starting with 'output'\nI have a program that generates text files output1.txt, output2.txt, output3.txt, etc.. I want Git to ignore these files. I can't block text files, as I have some text files that shouldn't be ignored. Also, the files are dynamically generated (there is no limit to the number appearing after “output”), so can't add the file names statically. Can someone please help me with this?\nPS. I've checked out this Make .gitignore ignore everything except a few files, but it refers to a set of files alread known. In my case it might be a long list."}, {"role": "assistant", "content": "Pattern matching doesn’t just work before the extension. Just as much as you can ignore *.txt, you can ignore:\noutput*.txt"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects files"}, {"role": "assistant", "content": "Compute the dirstat numbers by counting the number of files changed.\nEach changed file counts equally in the dirstat analysis. This is\nthe computationally cheapest --dirstat behavior, since it does\nnot have to look at the file contents at all."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Visual Studio 2013 and BitBucket\nVisual Studio 2013 apparently has some nice slick Git integration.\nHowever, after an hour of head-scratching with absolutely nothing making even the slightest bit of sense, I've only been able to create a local repository and despite cloning a remote bitbucket repository I simply cannot find a way to publish to my remote repository.\nI've used TFS, Subversion, Perforce and just about everything else, but this is completely baffling, with no instructions and a completely un-intuitive user interface.\nAny ideas anyone ?"}, {"role": "assistant", "content": "John's statement that \"you need Team Foundation Server\" to work with BitBucket is not correct.\nI just published a project to BitBucket from Visual Studio 2013 (preview version). Here's how.\n\nAdd solution to Source Control\n\n\n\nCommit to local Git\n\n\n\nIn the \"Changes\" area, click \"Commits\". This takes you to the dialog where you can publish to a Remote Repository.\n\n\n\nEnter the URL to your BitBucket repository (must already exist in BitBucket and must be empty) and click \"Publish\"\n\n\n\nEnter your BitBucket credentials when prompted. After the publish finishes you'll get a results message like this.\n\n\n\nUse the \"Sync\" button to update BitBucket with your local commits"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git returns http error 407 from proxy after CONNECT\n\nI have a problem while connecting to github from my PC, using git. System Win 7.\nI have connection through proxy, so i specified it in git config files (both in general git folder, and in git repo folder). To do this i entered next line to my git bush:\n$ git config --global http.proxy http://<username>:<userpsw>@<proxy>:<port>\n\nThe way it works on other programms (ex: maven) it looks like that:\n<username> - my login to our corp system\n<userpsw> -my password to corporat system\n<proxy> - 10.65.64.77\n<port> - 3128\n\nBut when i try to push or to clone my repo, i receive\nfatal: unable to access '<repo githup link>' Received HTTP code 407 from proxy after CONNECT\n\nI try already to enter not just my username but domain\\username, changed my password in case there are problems with code language tables. And i even entered wrong password. Error stayed the same.\nWhen i entered in '10.65.64.177.com' and tried to push repo, i received:\nfatal: unable to access '<repo github link>': Failed connect to github.com:3128; No error\n\nJust don't know what to try."}, {"role": "assistant", "content": "What worked for me is something similar to what rohitmohta is proposing ; in regular DOS command prompt (not on git bash) :\nfirst\ngit config --global http.proxy http://username:password@proxiURL:proxiPort\n\nand in some cases also\ngit config --global https.proxy http://username:password@proxiURL:proxiPort\n\nthen\ngit config --global http.sslVerify false\n\n(I confirm it's necessary : if set to true getting \"SSL certificate problem: unable to get local issuer certificate\" error)\nin my case, no need of defining all_proxy variable\nand finally \ngit clone https://github.com/someUser/someRepo.git"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Make 'git diff' ignore ^M\nIn a project where some of the files contain ^M as newline\nseparators, diffing these files is apparently impossible, since\ngit diff sees the entire file as just a single line.\nHow does one git diff when comparing the current and previous\nversions of a source code file?\nIs there an option like \"treat ^M as newline when diffing\" ?\nprompt> git-diff \"HEAD^\" -- MyFile.as \ndiff --git a/myproject/MyFile.as b/myproject/MyFile.as\nindex be78321..a393ba3 100644\n--- a/myproject/MyFile.cpp\n+++ b/myproject/MyFile.cpp\n@@ -1 +1 @@\n-<U+FEFF>import flash.events.MouseEvent;^Mimport mx.controls.*;^Mimport mx.utils.Delegate\n\\ No newline at end of file\n+<U+FEFF>import flash.events.MouseEvent;^Mimport mx.controls.*;^Mimport mx.utils.Delegate\n\\ No newline at end of file\nprompt>\n\n\nUPDATE:\nI have written a Ruby script that checks out the latest 10 revisions and converts CR to LF.\nrequire 'fileutils'\n\nif ARGV.size != 3\n puts \"a git-path must be provided\"\n puts \"a filename must be provided\"\n puts \"a result-dir must be provided\"\n puts \"example:\"\n puts \"ruby gitcrdiff.rb project/dir1/dir2/dir3/ SomeFile.cpp tmp_somefile\"\n exit(1)\nend\n\ngitpath = ARGV[0]\nfilename = ARGV[1]\nresultdir = ARGV[2]\n\nunless FileTest.exist?(\".git\")\n puts \"this command must be run in the same dir as where .git resides\"\n exit(1)\nend\n\nif FileTest.exist?(resultdir)\n puts \"the result dir must not exist\"\n exit(1)\nend\nFileUtils.mkdir(resultdir)\n\n10.times do |i|\n revision = \"^\" * i\n cmd = \"git show HEAD#{revision}:#{gitpath}#{filename} | tr '\\\\r' '\\\\n' > #{resultdir}/#{filename}_rev#{i}\"\n puts cmd \n system cmd\nend"}, {"role": "assistant", "content": "GitHub suggests that you should make sure to only use \\n as a newline character in git-handled repos. There's an option to auto-convert:\n$ git config --global core.autocrlf true\n\nOf course, this is said to convert crlf to lf, while you want to convert cr to lf. I hope this still works …\nAnd then convert your files:\n# Remove everything from the index\n$ git rm --cached -r .\n\n# Re-add all the deleted files to the index\n# You should get lots of messages like: \"warning: CRLF will be replaced by LF in <file>.\"\n$ git diff --cached --name-only -z | xargs -0 git add\n\n# Commit\n$ git commit -m \"Fix CRLF\"\n\ncore.autocrlf is described on the man page."}]} {"messages": [{"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 ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "how can I get a global rss feed on Gitlab?\n\nIn Gitlab there is an RSS news feed button for every project. \nhttp://git.domain.name/userName/projectName/commits/master.atom?private_token=xxxxxxxxxxxxx\nIs there a way to retrieve a global RSS feed for all projects related to one user?\nOr even better, if there is a way to capture all user's feeds across all projects, that would be cool.\nthanks"}, {"role": "assistant", "content": "This is currently not supported.\nThe closest feature request there is would be \"Team-/groupwide RSS feeds\", to have RSS feeds for all events in a team or a group. (not enough vote for now).\n\nThe global \"RSS\" shown on demo.gitlab.com is actually a html result of the event-items representing the activity in response to http://demo.gitlab.com/?limit=20&offset=0:\nThat would be for all public projects, but I don't see it exposed as an RSS feed.\nThe OP mauro reports in the comments\n\nthe global \"RSS\" shown in demo.gitlab.com is also showing on my gitlab dashboard, the only thing is that mine is giving a 500 error instead."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Install npm module from gitlab private repository\n\nWe are using GitLab for our private project. There are some forked libraries from github, that we want to install as npm module. Installing that module directly from npm is ok and for example this:\nnpm install git://github.com/FredyC/grunt-stylus-sprite.git\n\n...works correctly too, but doing the same for GitLab, just changing domain gets me this error.\nnpm WARN `git config --get remote.origin.url` returned wrong result (git://git.domain.com/library/grunt-stylus-sprite.git)\nnpm ERR! git clone git://git.domain.com/library/grunt-stylus-sprite.git Cloning into bare repository 'D:\\users\\Fredy\\AppData\\Roaming\\npm-cache\\_git-remotes\\git-git-domain-com-library-grunt-stylus-sprite-git-6f33bc59'...\nnpm ERR! git clone git://git.domain.com/library/grunt-stylus-sprite.git fatal:unable to connect to git.domain.com:\nnpm ERR! git clone git://git.domain.com/library/grunt-stylus-sprite.git git.domain.com[0: 77.93.195.214]: errno=No error\nnpm ERR! Error: Command failed: Cloning into bare repository 'D:\\users\\Fredy\\App\nData\\Roaming\\npm-cache\\_git-remotes\\git-git-domain-com-library-grunt-stylus-spr\nite-git-6f33bc59'...\nnpm ERR! fatal: unable to connect to git.domain.com:\nnpm ERR! git.domain.com[0: xx.xx.xx.xx]: errno=No error\n\nFrom the web interface of GitLab, I have this URL\n[email protected]:library/grunt-stylus-sprite.git. Running this against npm install it tries to install git module from npm registry.\nHowever using URL: [email protected]:library/grunt-stylus-sprite.git is suddenly asking me for the password. My SSH key doesn't include passphrase, so I assume it wasn't able to load that key. Maybe there is some configuration for that I have missed ? Key is located at standard location in my home directory with the name \"id_rsa\".\nI am on Windows 7 x64.\nUPDATE\nSince NPM v3 there is built-in support for GitLab and other sources (BitBucket, Gist), from where you can install packages. It works for public and private ones so it's not exactly related to this, but some might find it useful.\nnpm install gitlab:<gitlabname>/<gitlabrepo>[#<commit-ish>]\n\nCheck out documentation: https://docs.npmjs.com/cli/install\nI you want to work with private repos in Gitlab you are required to manage your credentials/auth-token in your .npmrc. See here: https://docs.gitlab.com/ee/user/packages/npm_registry/#authenticate-to-the-package-registry"}, {"role": "assistant", "content": "You have the following methods for connecting to a private gitlab repository\nWith SSH\ngit+ssh://[email protected]:Username/Repository#{branch|tag}\ngit+ssh://[email protected]/Username/Repository#{branch|tag}\n\nWith HTTPS\ngit+https://[email protected]/Username/Repository#{branch|tag}\n\nWith HTTPS and deploy token\ngit+https://<token-name>:<token>@gitlab.com/Username/Repository#{branch|tag}"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.submodule"}, {"role": "assistant", "content": "Specify the format in which differences in submodules are\nshown. The \"short\" format just shows the names of the commits\nat the beginning and end of the range. The \"log\" format lists\nthe commits in the range like git-submodule summary does. The \"diff\" format shows an inline diff of the changed\ncontents of the submodule. Defaults to \"short\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I get a list of all the GitHub projects I've contributed to in the last year? [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\n\nGitHub API: Repositories Contributed To\n\n (13 answers)\n \n\nClosed 8 years ago.\n\n\n\nI realize I can hit https://api.github.com/users/:user_id/repos to get a list of all the repos I own or have forked. But what I would like to do is figure out all of the projects I have contributed to (commits, pull requests, issues, etc.) over the last year. The events API lets me get the last 300 events, but I have contributed a lot more than that in the last twelve months. Is this possible?"}, {"role": "assistant", "content": "Thanks to a tweet from @caged, I wrote this Perl script to iterate over months in my contributions:\nuse v5.12;\nuse warnings;\nuse utf8;\nmy $uname = 'theory';\n\nmy %projects;\nfor my $year (2012..2014) {\n for my $month (1..12) {\n last if $year == 2014 && $month > 1;\n my $from = sprintf '%4d-%02d-01', $year, $month;\n my $to = sprintf '%4d-%02d-01', $month == 12 ? ($year + 1, 1) : ($year, $month + 1);\n my $res = `curl 'https://github.com/$uname?tab=contributions&from=$from&to=$to' | grep 'class=\"title\"'`;\n while ($res =~ /href=\"([^\"?]+)/g) {\n my (undef, $user, $repo) = split m{/} => $1;\n $projects{\"$user/$repo\"}++;\n }\n }\n}\n\nsay \"$projects{$_}: $_\" for sort keys %projects;\n\nYeah, HTML scraping is kind of ugly, but did the trick for my needs."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is it possible to completely empty a remote Git repository?\nLet's say I make a mistake in my first push to a remote Git repository. Can I somehow revert this so that the repository is back to it's initial state? I don't have access to the remote machine, so deleting .git directory is not possible.\nThe problem, as far as I can see is that you can't \"unset\" the head.\nThis is what I (or actually a colleague who asked about this) did (I do a local \"remote\" repo here so anyone can test this):\nmkdir git-remote\ncd git-remote\ngit init --bare\ncd ..\nmkdir git-local\ncd git-local\ngit clone ../git-remote .\ntouch a\ngit add a\ngit commit -m \"initial\"\ngit push origin master\n\nAnd at this point he realised he pushed the wrong stuff to the remote repository.\nThe only idea I had is the delete everything from his repo && git rm && git push which would still leave the faulty commit there, but the files wouldn't bother a second push."}, {"role": "assistant", "content": "I think you may have an XY problem. You don't actually need to get the remote repository back into its original state in order to start over; you simply need to start over locally, then force-push that to the remote.\n# create a new repository that has the initial commit that you want\nmkdir foo; cd foo; git init; ...; git commit\n\n# set up a remote\ngit remote add origin <url-of-remote>\ngit branch --set-upstream master origin/master\n\n# push your new history\ngit push -f\n\n# delete obsolete remote branches\ngit push origin :deprecated-branch\n\nThe remote repository never returns to a no-commits state, but it ends up where you want it, and that's all that matters!\n(Under the hood, the old commits are actually still in the remote repository, but they're left dangling, with no refs pointing to them. They'll be automatically removed when git gc --auto is triggered by a push at some point.)\nIf you really, really want to empty it for some reason, you can set receive.denyDeleteCurrent in the remote repository, and push-delete all branches, including the current one. I don't see why you actually need to, though!"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I get the diff between all the commits that occurred between two dates with Git?\nOr just all the commits that occurred between two dates? In SVN, you could do something like \nsvn diff -r{date}:{date}\n\nto do it! I can't seem to find a Git equivalent to this.\nSpecifically I'm looking at writing a script to send out daily emails with all the code committed that day and by who."}, {"role": "assistant", "content": "You could use git whatchanged --since=\"1 day ago\" -p\nIt also takes a --until argument.\nDocs"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git remove file from stash\nI have a stash with a bunch of files in it.\nBut I can't apply my stash because of a conflicting file. I've identified the problematic file in my stash and I want to remove it.\nHow can I remove a single file from a stash without destroying the entire thing?"}, {"role": "assistant", "content": "A stash is a commit (or really, two or even sometimes three commits) and you cannot change a commit. The literal answer to your question, then, is \"you can't\". Fortunately, you don't need to.\nYou say you can't apply your stash because of a conflicting file. But you can apply it, you just get a merge conflict. All you need to do is resolve the merge conflict.\nLet's say the conflict is in file README.txt, just so there's something to write about here.\nIf you want to resolve it by keeping the on-branch version, apply the stash, then check out the on-branch version to resolve the conflict:\ngit stash apply\ngit checkout --ours -- README.txt # or git checkout HEAD -- README.txt\n\nIf you want to keep the in-stash version, extract that one:\ngit checkout --theirs -- README.txt # or git checkout stash -- README.txt\n\nOr, use any old merge resolution tool (I just use a text editor), and then \"git add\" the result.\nOnce you are all done with the stash, git stash drop will \"forget\" the commits that make up the stash. (Don't do this until you are sure you are done with it; it's very hard to get it back afterward.)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git index.lock File exists when I try to commit, but I cannot delete the file\nWhen I do 'git commit', I'm getting the following:\nfatal: Unable to create 'project_path/.git/index.lock': File exists.\nHowever, when I do ls project_path/.git/index.lock it's saying the file doesn't exist. What should I do? I've also noticed that project_path/.git is owned by root and am not sure if that has anything to do with the problem I'm encountering.\nThe Git version is 1.7.5.4\n\nIt seems that the problem most likely was another process I had running, that was writing (unbeknownst to me) to the project directory. I restarted my machine and then I had no problem committing."}, {"role": "assistant", "content": "On Linux, Unix, Git Bash, or Cygwin, try:\nrm -f .git/index.lock\nOn Windows Command Prompt, try:\ndel .git\\index.lock"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Find unmerged Git branches?\nI have a Git repository with many branches, some of them already merged and some not. Since the number of branches is quite large, how can I determine which branches have not yet been merged? I would like to avoid having to do an \"octopus\" merge and re-merging branches that have already been merged."}, {"role": "assistant", "content": "Try this:\ngit branch --merged master\n\nIt does what it says on the tin (lists branches which have been merged into master). You can also pull up the inverse with:\ngit branch --no-merged master\n\nIf you don't specify master, e.g...\ngit branch --merged\n\nthen it will show you branches which have been merged into the current HEAD (so if you're on master, it's equivalent to the first command; if you're on foo, it's equivalent to git branch --merged foo).\nYou can also compare upstream branches by specifying the -r flag and a ref to check against, which can be local or remote:\ngit branch -r --no-merged origin/master"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Prune empty merge commits from history in Git repository\nI have cleaned up our Git repository quite a bit, we need to remove big parts from the history. I do this using:\ngit filter-branch --prune-empty --tree-filter 'rm -rf some_stuff'\n\nThe --prune-empty flag will remove commits that are left empty after the process, except commits with multiple parents (merge commits). Even if the branch being merged in contains absolutely nothing, and the merge adds nothing to the tree.\nHow do I also prune these empty merge commits from the history?"}, {"role": "assistant", "content": "This is superior to the rebase solution because it preserves committer info, committer dates, and non-empty merges of the original history.\ngit filter-branch --prune-empty --parent-filter \\\n 'sed \"s/-p //g\" | xargs -r git show-branch --independent | sed \"s/\\</-p /g\"'\n\nThis is inspired by the same thread on the kernel mailing list than Lucas' solution. However it does not require Ruby and is a one-liner. It does require GNU versions of xargs and sed though."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitrevisions - Specifying revisions and ranges for Git ^<rev>"}, {"role": "assistant", "content": "Exclude commits that are reachable from <rev> (i.e. <rev> and its\nancestors)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Error unauthorized: HTTP Basic: Access denied on docker push registry.gitlab.com\n\nI have error with:\ndocker push registry.gitlab.com/user/rep-name\n\nThe push refers to repository [registry.gitlab.com/user/rep]\nf319ccdf8ee4: Preparing \n..\n7032a7172c0a: Preparing \nb16cd70f3a2c: Waiting \n...\nunauthorized: HTTP Basic: Access denied\n\nBut prev login is Succeeded:\ndocker login registry.gitlab.com\nUsername: user\nPassword: \nLogin Succeeded\n\nDocker ver:\ndocker -v\nDocker version 19.03.8, build afacb8b7f0\n\nI use Personal Access Token is \"api\"\nhttps://gitlab.com/profile/personal_access_tokens\nbecause I have 2-factor athorization."}, {"role": "assistant", "content": "I change:\n\nPersonal Access Token scope:\nhttps://gitlab.com/-/profile/personal_access_tokens to \"api\" and \"read_registry\"\n\nusename in docker login from @user to [email protected]\n\n\nnow it is works.\nSeems issue is in \"read_registry\" scope.\nAnd it is strange because \"api\" also have read access.\nFrom Gitlab:\n\nGrants complete read/write access to the API, including all groups and\nprojects, the container registry, and the package registry."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "clone a specific branch from git through ansible playbook\n\nI am using ansible to deploy my app. I am cloning the app from github using the following:\n- name: Deploy site files from Github repository\n sudo: yes\n git: [email protected]:xyz/abc.git dest=/home/{{deploy_user}}/{{app_name}} key_file=/home/ubuntu/.ssh/id_rsa accept_hostkey=yes force=yes\n\nI want to clone a specific branch from the repository. I read the documentation of ansible but couldn't find any option to clone a specific branch. It has an option to clone a version but not branch."}, {"role": "assistant", "content": "From the documentation:\n\nversion\nWhat version of the repository to check out. This can be the full 40-character SHA-1 hash, the literal string HEAD, a branch name, or a tag name.\n\n(emphasis mine)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git:// through proxy\nI'm behind a firewall that is blocking port 9418 (git) and am trying to install some tools that are explicitly doing a checkout of git://github.com/..., so I can't switch to https for the checkout.\nSo I'm wondering if it's possible to redirect all traffic to port 9418 through a proxy and if so how :)"}, {"role": "assistant", "content": "If you are talking about git submodules, try this:\ngit config --global url.https://github.com/.insteadOf git://github.com/\n\n...taken from here.\nThis way, you don't need to set any proxy, nor run any script."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Merge branches without checking out branch\nI have 3 branches. \n master [ Live Server]\n \\\n stage [ Stage Server Where we test changes; merge commits ]\n \\ \n Dev [ Local Machine ]\n\nI would like to downstream the changes to. Each of these branches are set to tracking each other.\nNormally, to downstream the changes i do this:\ngit checkout stage && git merge master\nThen i checkout dev and i do the same\ngit checkout dev && git merge stage\nThen push them all:\ngit push origin --all\nIs there a way to downstream those changes without checking out into each branch? \nI maybe using the wrong terminology. I'm not totally sure if i'm using upstream/downstream terminology correctly."}, {"role": "assistant", "content": "You can indeed \"merge\" a branch B into branch A without having to check out branch A, but only if it's a fast-forward merge.\nYou can use a refspec with fetch to do the \"merge\". If merging branch B into branch A using git merge would result in a fast-forward merge, then you can do the following without having to checkout A:\ngit fetch <remote> B:A\n\nThe Documentation\nThe above matches the refspec format\ngit fetch <remote> <source>:<destination>\n\nFrom the documentation for git fetch (emphasis mine):\n\nThe remote ref that matches <src> is fetched, and if <dst> is not empty string, the local ref that matches it is fast-forwarded using <src>.\n\nSee Also\n\nGit checkout and merge without touching working tree\nMerge, update, and pull Git branches without using checkouts\nMerging without changing the working directory\nMerging Branches Without Checkout"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GIT commit as different user without email / or only email\nI'm trying to commit some changes as a different user, but i do not have a valid email address, following command is not working for me:\ngit commit --author=\"john doe\" -m \"some fix\"\nfatal: No existing author found with 'john doe'\n\nI have the same problem when trying to commit with only an email address\ngit commit --author=\"[email protected]\" -m \"some fix\"\nfatal: No existing author found with '[email protected]'\n\nOn the GIT man pages for the commit command it says i can use the \nstandard A U Thor <[email protected]> format\n\nFor the --author option.\nWhere is this format defined ?\nwhat does A and U stand for ? how do i commit for a different user with only a username or only an email?"}, {"role": "assistant", "content": "The minimal required author format, as hinted to in this SO answer, is\nName <email>\n\nIn your case, this means you want to write\ngit commit --author=\"Name <email>\" -m \"whatever\"\n\nPer Willem D'Haeseleer's comment, if you don't have an email address, you can use <>:\ngit commit --author=\"Name <>\" -m \"whatever\"\n\nAs written on the git commit man page that you linked to, if you supply anything less than that, it's used as a search token to search through previous commits, looking for other commits by that author."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Remove deleted files from git history\nI'm trying to split a subproject off of my git repository.\nHowever unlike in\nDetach (move) subdirectory into separate Git repository\nI don't have it in it's own subdirectory (and moving it in and doing the above only yields the history after the move).\nI've cloned the branch from which I want to split off the subproject into it's own repository and removed everything that isn't used by the subproject, so basically I could use this as the repository of my subproject. \nNow I want to get rid of the history of all files that are no longer in this repository so as to only keep the file history for the files that made it into the offspring.\nI think it must be possible with git-filter-branch but I can't figure out how\nMany thanks in advance"}, {"role": "assistant", "content": "Here are some instructions to do what you want.\nThis will remove file_to_remove:\ngit filter-branch --index-filter 'git rm --cached --ignore-unmatch file_to_remove' --prune-empty -- --all"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options submodule.active"}, {"role": "assistant", "content": "A repeated field which contains a pathspec used to match against a\nsubmodule’s path to determine if the submodule is of interest to git\ncommands. See gitsubmodules for details."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options safe.directory"}, {"role": "assistant", "content": "These config entries specify Git-tracked directories that are\nconsidered safe even if they are owned by someone other than the\ncurrent user. By default, Git will refuse to even parse a Git\nconfig of a repository owned by someone else, let alone run its\nhooks, and this config setting allows users to specify exceptions,\ne.g. for intentionally shared repositories (see the --shared option in git-init ). This is a multi-valued setting, i.e. you can add more than one directory\nvia git config --add . To reset the list of safe directories (e.g. to\noverride any such directories specified in the system config), add a safe.directory entry with an empty value. This config setting is only respected in protected configuration (see SCOPES ). This prevents untrusted repositories from tampering with this\nvalue. The value of this setting is interpolated, i.e. ~/<path> expands to a\npath relative to the home directory and %(prefix)/<path> expands to a\npath relative to Git’s (runtime) prefix. To completely opt-out of this security check, set safe.directory to the\nstring * . This will allow all repositories to be treated as if their\ndirectory was listed in the safe.directory list. If safe.directory=* is set in system config and you want to re-enable this protection, then\ninitialize your list with an empty value before listing the repositories\nthat you deem safe. As explained, Git only allows you to access repositories owned by\nyourself, i.e. the user who is running Git, by default. When Git\nis running as root in a non Windows platform that provides sudo,\nhowever, git checks the SUDO_UID environment variable that sudo creates\nand will allow access to the uid recorded as its value in addition to\nthe id from root .\nThis is to make it easy to perform a common sequence during installation\n\"make && sudo make install\". A git process running under sudo runs as root but the sudo command exports the environment variable to record\nwhich id the original user has.\nIf that is not what you would prefer and want git to only trust\nrepositories that are owned by root instead, then you can remove\nthe SUDO_UID variable from root’s environment before invoking git."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I \"git blame\" a deleted line?\ngit blame is great for modified and added lines, but how can I find when a line that existed in a specific previous commit was eventually deleted. I'm thinking bisect, but I was hoping for something handier.\n(Before you ask: in this case, I just did a git log -p and searched through for the code line and (a) some idiot had just deleted the vital line in the previous commit and (b) I was that idiot.)"}, {"role": "assistant", "content": "If you know the contents of the line, this is an ideal use case for:\ngit log -S <string> path/to/file\n\nwhich shows you commits which introduce or remove an instance of that string. There's also the -G<regex> which does the same thing with regular expressions! See man git-log and search for the -G and -S options, or pickaxe (the friendly name for these features) for more information.\nThe -S option is actually mentioned in the header of the git-blame manpage too, in the description section, where it gives an example using git log -S...."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-log - Show commit logs --left-only --right-only"}, {"role": "assistant", "content": "List only commits on the respective side of a symmetric difference,\ni.e. only those which would be marked < resp. > by --left-right . For example, --cherry-pick --right-only A...B omits those\ncommits from B which are in A or are patch-equivalent to a commit in A . In other words, this lists the + commits from git cherry A B .\nMore precisely, --cherry-pick --right-only --no-merges gives the exact\nlist."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Github: how to fork after cloning?\n\nI cloned a git repo to my local machine, played around with it a bit and found it cool.\nNow I would like to keep the result as I modified it in my own github space. How can I proceed?\nI suppose the regular way would have been to fork the repo on the first place to my space, clone it, modify and then push it to GitHub, but now I cloned the original's author repo, how can I commit that as a new thing in my personnal?"}, {"role": "assistant", "content": "First rename the old remote as upstream, in case you want to be able to keep in sync with the original repository.\ngit remote rename origin upstream\n\nThen add your forked repository as origin:\ngit remote add origin https://github.com/<your-username>/<your-project>\n\nOr if you're using ssh:\ngit remote add origin [email protected]:<your-username>/<your-project>.git\n\nTo push to your repository:\ngit push -u origin master\n\nTo pull from the base repository:\ngit pull upstream\n\nI recommend you do all of your work in a separate branch, not the master branch. It will be easier to rebase to the upstream/master branch in case you want to make a pull request.\nYou don't really have to rename the origin to upstream - the remote names can be arbitrary, however I recommended you to do so to keep up with the naming convention used by GitHub."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-switch - Switch branches"}, {"role": "assistant", "content": "EXAMPLES The following command switches to the \"master\" branch: $ git switch master After working in the wrong branch, switching to the correct branch\nwould be done using: $ git switch mytopic However, your \"wrong\" branch and correct \"mytopic\" branch may differ\nin files that you have modified locally, in which case the above\nswitch would fail like this: $ git switch mytopic\nerror: You have local changes to 'frotz'; not switching branches. You can give the -m flag to the command, which would try a three-way\nmerge: $ git switch -m mytopic\nAuto-merging frotz After this three-way merge, the local modifications are not registered in your index file, so git diff would show you what\nchanges you made since the tip of the new branch. To switch back to the previous branch before we switched to mytopic\n(i.e. \"master\" branch): $ git switch - You can grow a new branch from any commit. For example, switch to\n\"HEAD~3\" and create branch \"fixup\": $ git switch -c fixup HEAD~3\nSwitched to a new branch 'fixup' If you want to start a new branch from a remote branch of the same\nname: $ git switch new-topic\nBranch 'new-topic' set up to track remote branch 'new-topic' from 'origin'\nSwitched to a new branch 'new-topic' To check out commit HEAD~3 for temporary inspection or experiment\nwithout creating a new branch: $ git switch --detach HEAD~3\nHEAD is now at 9fc9555312 Merge branch 'cc/shared-index-permbits' If it turns out whatever you have done is worth keeping, you can\nalways create a new name for it (without switching away): $ git switch -c good-surprises"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Google Code + SVN or GitHub + Git [closed]\nClosed. This question is opinion-based. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it can be answered with facts and citations by editing this post.\n\n\nClosed 9 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nLet me start by telling you that I never used anything besides SVN and I'm also a Windows user.\nI have a couple of simple projects that are open-source, others are on their way when I'm happy enough to release their source code. Either way, I was thinking of using Google Code and SVN to share the source code of my projects instead of providing a link to the source on my website. This has always been a pain because I had to update the binaries and the code every time I released a new version. This would also help me to have a backup of my code some where instead of just my local machine (I used to have a local Subversion server running).\nWhat I want from a service like this is very simple... I just want a place to store my source code that people can download if they want, that allows me to control revisions and provide a simple and easy issue/bug system so people can submit bugs and stuff like that. I guess both of them have this.\nBut I don't want to host any binaries in their websites. I want this to be hosted on my website so I can control download statistics with my own scripts. I also don't have a need for wiki pages as I prefer to have all the documentation on my own website. Do any of these services provide a way to \"disable\" features like wiki and downloads and not show them at all for my project(s)?\nNow, I'm sure there are lots of pros and cons about using Google Code with SVN and GitHub with Git (of course) but here's what's important for me on each one, and why I like them:\nGoogle Code:\n\nAs with any Google page, the complexity is almost non-existent\nEveryone (or almost everyone) has a Google account, whcih is nice if people want to report problems using the issues system\n\nGitHub:\n\nMay (or may not) be a little more complex (not a problem for me though) than Google's pages but...\n...has a much prettier interface than Google's service\nIt needs people to be registered on GitHub to post about issues\nI like the fact that with Git, you have your own revisions locally (can I use TortoiseGit for this or?)\n\nBasically that's it. Not much, I know...\nWhat other common pros and cons can you tell me about each site/software? Keep in mind that my projects are simple, I'm probably the only one who will ever develop these projects on these repositories (or maybe not, but for now I am)."}, {"role": "assistant", "content": "Google Code is supporting Mercurial now. Mercurial should give you most of the benefits of Git, but you get the maturity of Google Code. You also have the option to go with subversion there as well should you want to."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git pull / push - unable to access HTTPS, SSL routines seem to be down\n\nI'm using Git (and GitHub) on a daily basis and everything has been working fine and all of a sudden, I can no longer communicate with my remote GitHub repository through my Git commands. When I try to \"Git pull\", it gives the following error:\n\nfatal: unable to access 'https://github.com/snahrvar/eatibl.git/':\n error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert\n protocol version\n\nSo, I tested across multiple repositories, and I get the same errors on my computer. I had someone else interact with those same repositories, and it works fine for them. Prior to this error, I did an \"npm install sharp\" on a project and that ended up failing, and I suspect this may have messed with some SSL setting, but that's a wild guess!\nAny general thoughts or guidance would be much appreciated!\nIf it's helpful at all, here is my environment:\n\nGit version: 1.9.4.msysgit.2\nWindows version: Windows 8.1"}, {"role": "assistant", "content": "Updating TortoiseGit and GCM didn't help me, but updating Git itself did, as per @Frederic's advice in comments.\nhttps://git-scm.com/download/win\nTo make sure the new version of Git installs properly and doesn't conflict with previous installations (it might, if you used TortoiseGit's, because it would use different folders and mess with PATH variable), remove the existing Git installation before installing the updated Git. Might also need to install with administrator rights."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I give access to a private GitHub repository?\n\nI have a private git repository and I would like to extend its access to a member of my team. Will I be able to do it through the Github website? I have the username of my member.\nI have tried to do this by going through the admin page of the repository but there isn't such an option as I am not the owner."}, {"role": "assistant", "content": "If you are the owner it is simple:\n\nGo to your repo and click the Settings button.\nIn the left menu click Collaborators\nThen Add their name.\n\nThen collaborator should visit this example repo link https://github.com/user/repo/invitations\nSource: Github Docs."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to specify a certain commit in dependencies in Cargo.toml?\n\nI am trying to configure my Rust project with an external dependency in GitHub. Unfortunately, some last commits made some changes in interfaces so I am unable to use the latest version. The developers also do not care of tags and separate branches for different versions, so I think the only correct way is to specify a certain commit somehow where the interface fits what I worked with.\nWhat I have now in Cargo.toml is:\n[dependencies]\n...\nthelib = { git = 'https://github.com/someguys/thelib' }\n\nI saw it is possible to specify a branch like this:\nthelib = { git = 'https://github.com/someguys/thelib', branch = 'branch1' }\n\nBut I have not seen a working example with a commit. Could anybody provide one here?"}, {"role": "assistant", "content": "As hinted in the Cargo.toml vs Cargo.lock section of the Cargo guide, you can use the rev property to specify a commit hash:\n\n[...] If you build this package today, and then you send a copy to me, and I build this package tomorrow, something bad could happen. There could be more commits to rand in the meantime, and my build would include new commits while yours would not. Therefore, we would get different builds. This would be bad because we want reproducible builds.\nWe could fix this problem by putting a rev line in our Cargo.toml:\n[dependencies]\nrand = { git = \"https://github.com/rust-lang-nursery/rand.git\", rev = \"9f35b8e\" }\n\n\nIt is also mentioned in Specifying dependencies, although no example is given (emphasis mine):\n\nSince we haven’t specified any other information, Cargo assumes that we intend to use the latest commit on the master branch to build our package. You can combine the git key with the rev, tag, or branch keys to specify something else. [...]"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options mergetool.<tool>.path"}, {"role": "assistant", "content": "Override the path for the given tool. This is useful in case\nyour tool is not in the PATH."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can git ignore a specific line?\nI'm using git to sync to phonegap while testing on the phone's native browser. As such I have the following line:\nvar isPhoneGap = false;\n\nObviously I change this when building, but is there any way I can set up git to ignore this one line or do I have to go and put it in its own file and ignore it that way?\nI'm using Gitx and the terminal on OSX 10.6."}, {"role": "assistant", "content": "If your file is of a specific type, you can declare a content filter driver, that you can declare in a .gitattributes file (as presented in the \"Keyword expansion\" of \"Git Attributes\"):\n\n*.yourType filter=yourFilterName\n\n(you can even set that filter for a specific file, if you want)\nImplement:\n\nyourFilterName.smudge (triggered on git checkout) and\n git config --global filter.yourFilterName.smudge 'sed \"s/isPhoneGap = .*/isPhoneGap = true/\"'\n\n\nyourFilterName.clean (triggered on git add)\n git config --global filter.yourFilterName.clean 'sed \"s/isPhoneGap = .*/isPhoneGap = false/\"'\n\n\n\nYour file would appear unchanged on git status, yet its checked out version would have the right value for isPhoneGap.\n\nNote: in the comments, ohaal and Roald suggest to isolate the sed calls in a separate helper.sh script:\nsed \"s/isPhoneGap = .*/isPhoneGap = true/\" \"$@\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --abbrev[=<n>]"}, {"role": "assistant", "content": "Instead of showing the full 40-byte hexadecimal object\nname in diff-raw format output and diff-tree header\nlines, show the shortest prefix that is at least <n> hexdigits long that uniquely refers the object.\nIn diff-patch output format, --full-index takes higher\nprecedence, i.e. if --full-index is specified, full blob\nnames will be shown regardless of --abbrev .\nNon default number of digits can be specified with --abbrev=<n> ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-grep - Print lines matching a pattern -q --quiet"}, {"role": "assistant", "content": "Do not output matched lines; instead, exit with status 0 when\nthere is a match and with non-zero status when there isn’t."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git ignore local changes to portions of tracked files\nSpecifically, I maintain a git repository of my dotfiles. I recently started working on a new machine and cloned my repository on the same.\nNow, I wish to make some changes to my dotfiles which are specific to this system only. These changes I wish to ignore in my repository.\nOther changes that I make, should continue to be tracked and committed. \nFor example, in my .gitconfig, I have a setting as:\n[push]\n default = simple\n\nNow, on my new machine, the version of git being used it very old. It still not not support the setting simple for push. So, I'd like to change this, but only locally.\nHowever, if I make any other changes to my .gitconfig, I'd like to keep track of those. Anyway I can achieve this?\nEDIT:\nI know of git update-index --assume-unchanged. The problem with it is that git will no longer track my file at all, until I reverse it. And then, it will track all changes.\nI wish to ignore certain changes and track the rest."}, {"role": "assistant", "content": "Try using this command:\ngit update-index --assume-unchanged FILENAME_TO_IGNORE\n\nTo reverse it (if you ever want to commit changes to it), use:\ngit update-index --no-assume-unchanged\n\nUPDATE:\nHere's how to list 'assume unchanged' files under current directory:\ngit ls-files -v | grep -E \"^[a-z]\"\n\nAs the -v option will use lowercase letters for 'assume unchanged' files."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database badDateOverflow"}, {"role": "assistant", "content": "(ERROR) Invalid date value in an author/committer line."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I publish an npm package with distribution files?\nI would like to publish a npm package that contains my source as well as distribution files. My GitHub repository contains src folder which contains JavaScript source files. The build process generates dist folder that contains the distribution files. Of course, the dist folder is not checked into the GitHub repository.\nHow do I publish a npm package in a way that when someone does npm install, they get src as well as dist folder? Currently when I run npm publish from my Git repository, it results in only the src folder being published.\nMy package.json file looks like this:\n{\n \"name\": \"join-js\",\n \"version\": \"0.0.1\",\n \"homepage\": \"https://github.com/archfirst/joinjs\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/archfirst/joinjs.git\"\n },\n \"main\": \"dist/index.js\",\n \"scripts\": {\n \"test\": \"gulp\",\n \"build\": \"gulp build\",\n \"prepublish\": \"npm run build\"\n },\n \"dependencies\": {\n ...\n },\n \"devDependencies\": {\n ...\n }\n}"}, {"role": "assistant", "content": "When you npm publish, if you don't have an .npmignore file, npm will use your .gitignore file (in your case you excluded the dist folder).\nTo solve your problem, create a .npmignore file based on your .gitignore file, without ignoring the dist folder.\nSource: Keeping files out of your Package"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitfaq - Frequently asked questions about using Git How do I ignore changes to a tracked file?"}, {"role": "assistant", "content": "Git doesn’t provide a way to do this. The reason is that if Git needs\nto overwrite this file, such as during a checkout, it doesn’t know\nwhether the changes to the file are precious and should be kept, or\nwhether they are irrelevant and can safely be destroyed. Therefore, it\nhas to take the safe route and always preserve them. It’s tempting to try to use certain features of git update-index , namely the\nassume-unchanged and skip-worktree bits, but these don’t work properly for this\npurpose and shouldn’t be used this way. If your goal is to modify a configuration file, it can often be helpful to have\na file checked into the repository which is a template or set of defaults which\ncan then be copied alongside and modified as appropriate. This second, modified\nfile is usually ignored to prevent accidentally committing it."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc git diff [<options>] <commit>..<commit> [--] [<path>…​]"}, {"role": "assistant", "content": "This is synonymous to the earlier form (without the .. ) for\nviewing the changes between two arbitrary <commit>. If <commit> on\none side is omitted, it will have the same effect as\nusing HEAD instead."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I make git ignore future revisions to a file?\nI have created a default version of a file included in a git repository. It's important that when someone clones the repository, they get a copy of this file. However, I would like to set git so that it ignores changes to this file later. .gitignore works only on untracked files.\nMy motivation is that this file contains machine-specific information. I would like to provide default values, while allowing people to make local changes that won't get pushed back to the origin repository, creating merge conflicts when we pull new changes.\nWe are generally pretty lazy and use git add . a lot, so I'm pretty sure if I can't tell git to ignore this file, changes to it will end up getting committed and pushed.\nTo summarize,\n\nI would like to create a file, call it default_values.txt that is added to my git repository and is included when someone clones that repository.\ngit add . should not add default_values.txt to the commit.\nThis behavior should be passed on to any clones of the repository."}, {"role": "assistant", "content": "As many others have mentioned, a good modern solution is:\ngit update-index --skip-worktree default_values.txt\n\nThat will ignore changes to that file, both local and upstream, until you decide to allow them again with:\ngit update-index --no-skip-worktree default_values.txt\n\nYou can get a list of files that are marked skipped with:\ngit ls-files -v . | grep ^S\n\nNote that unlike --skip-worktree, the --assume-unchanged status will get lost once an upstream change is pulled."}]} {"messages": [{"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\ndiff is produced."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-init - Create an empty Git repository or reinitialize an existing one"}, {"role": "assistant", "content": "NAME git-init - Create an empty Git repository or reinitialize an existing one"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git push Out of memory, malloc failed\nI am trying to push my changes remotely to GitHub, every so often git fails due to \nC:\\dev\\projects>git push -v\nPushing to https://[email protected]/mycompany/My-Project.git\nPassword for 'github.com':\nfatal: Out of memory, malloc failed (tried to allocate 524288000 bytes)\nfatal: write error: Invalid argument\n\nThis is very, very aggravating. I have run the following commands, upgraded git (which wiped out my settings and caused lots of pain, but I digress)\ngit gc --auto --prune=today --aggressive\ngit repack\n\nI have even bumped the value of\nhttp.postbuffer\n\nbut eventually it will fail again.\nThis is a typical Rails 3.1 application, total project size on disk is 9.69 MB."}, {"role": "assistant", "content": "My advice is to try several git parameters related with pack:\n[pack]\n threads = 1\n deltaCacheSize = 128m\n windowMemory = 50m\n\nWhat it got better results for me was setting git config pack.threads 1 and git config pack.windowMemory 50m (default is 10m).\nStill, my host didn't have enough RAM memory (2GB) and kept failing. I hard copied the repo and moved it to another machine with more RAM (8GB). It got better but still failed.\nFinally, I downloaded the latest version of git (https://github.com/git/git), compile it and install it. That fixed the problem just by running git repack -adf with the same parameters. After that I run git gc --aggressive --prune=now \nOnce I got the repo fixed in my local machine I pushed it to master, overwriting the remote repo, git push -f origin master. \nTo prevent similar errors in the future try not to add unnecessary large files to the repo (in my case I got a SQL dump of 3.5GB :)) and disable delta compression for large files (such as images, PDFs, videos). Add the following lines to .gitattributes:\n*.pdf -delta\n*.jpg -delta"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Notorious Git Error: remote rejected (failed to lock)\n\nI am trying to push to a branch from my local to the origin. The branch name and the path is same. I have been pushing and pulling from this branch for a while and never had a problem. But suddenly, it started behaving badly. Last time when I tried to push to origin with following command:\ngit push origin feature/Prizefulfilment\n\nIt gives me following errror:\n72c6c1da98e5cff4484e254a538d9e3b472156ff but expected 0000000000000000000000000000000000000000\n\nI have Googled around but did not find a quite satisfying solution to it yet. \nMy exact error looks like following:\n$ git push origin feature/Prizefulfilment\nCounting objects: 126, done.\nDelta compression using up to 4 threads.\nCompressing objects: 100% (75/75), done.\nWriting objects: 100% (78/78), 8.83 KiB, done.\nTotal 78 (delta 61), reused 0 (delta 0)\nerror: Ref refs/heads/feature/Prizefulfilment is at 72c6c1da98e5cff4484e254a538d9e3b472156ff but expected 0000000000000000000000000000000000000000\nremote: error: failed to lock refs/heads/feature/Prizefulfilment\nTo [email protected]:OpusOneSCRUM\n ! [remote rejected] feature/Prizefulfilment -> feature/Prizefulfilment (failed to lock)\nerror: failed to push some refs to '[email protected]:OpusOneSCRUM'`\n\nAny ideas?"}, {"role": "assistant", "content": "git push feature/prizeFulfilment: feature/Prizefulfilment\n\nThat is similar to this answer:\n\nFor the record, I believe the root cause of this problem was the difference in capitalisation between the local and remote branch names, and the case-insensitive nature of the Windows share that hosted the remote repository.\nWe just encountered this exact same error and were able to resolve the problem simply by renaming the local branch to match the capitalisation of the existing remote branch.\n\nTry and make sure to use the same capitalization between local and remote branches.\nYou second command make the link between the prizeFulfilment and remote Prizefulfilment explicit, which is why it worked. But it isn't a good solution to keep a local branch with that kind of difference."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Getting a working copy of a bare repository\nI have a server on which I have a bare repository for pushing. However, my server needs to have a working copy of the master branch.\nHow do I get a working copy and that only from a bare repository?"}, {"role": "assistant", "content": "You can simply clone the repository to another directory on the same machine:\ngit clone /bare/repo/dir\n\nThe current directory will become a non-bare clone of your repo, and you'll get a checkout of the master branch automatically. Then use the usual commands like git pull to update it as needed.\nAs a side benefit, this operation is very efficient — if you specify a local directory to git clone, git will use hard links to share the read-only parts of the object databases of the two repos."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Squash in SourceTree\nIs it possible to squash in SourceTree? I saw that apparently you can \"drag and drop\" commits in order to squash them. However, when I do that it only highlights several commits."}, {"role": "assistant", "content": "Updated Answer\nSourceTree for Windows\nAs of version 1.5, you can now do interactive rebases, which will allow you to squash.\nSourceTree for Mac\nInteractive rebase has been available in SourceTree for Mac since version 1.6 (emphasis mine):\n\nThe git rebase –interactive command allows you to reorganise your commits after you’ve created them (but before you’ve made them public), and now you can do this inside SourceTree. Combine (squash) multiple commits together, or re-order them, simply by dragging & dropping. You can also change the commit message, or edit the content of the commits. Just right-click on a commit in the log and choose ‘Rebase children of <sha> interactively’ to kick the process off.\n\nOld Answer\nApparently squashing commits is a feature in SourceTree version 1.6 for the Mac.\nHowever, the feature doesn't seem to be available in the Windows version of SourceTree, which is currently still at version 1.0.8.\nUsing the command line\nYou still have the option of using the command line to squash commits:\ngit rebase -i <sha-of-base-commit>\n\nIn the TODO list, put an s (for squash) next to commits to squash into the previous commit:\npick e953225 Add meow meow meow\ns def892d Add master\n\nTo learn more about how to squash commits using the command line, see Squashing Commits, from the FREE online Pro Git book."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options format.coverFromDescription"}, {"role": "assistant", "content": "The default mode for format-patch to determine which parts of\nthe cover letter will be populated using the branch’s\ndescription. See the --cover-from-description option in git-format-patch ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git ignore vs. exclude vs. assume-unchanged\nI've read the docs on this several times over and I still don't completely get the differences between these different commands. Maybe it's just me, but the documentation could be more lucid:\nhttp://git-scm.com/docs/gitignore\nhttps://help.github.com/articles/ignoring-files\nMoreover, a lot of the commentary on this subject seems to use the words \"indexed\", \"committed\", \"tracked\" somewhat loosely, which makes the differences between these three less clear.\nMy current (admittedly limited) understanding:\n\nFiles matched in .gitignore will not be tracked in the future.\n(Though they may have been tracked previously.) This means that they\nwon't ever show up in a future git status list as changed.\nHowever, future changes will still be synced with remote repos. In other words, the files are still \"indexed\", but they are not \"tracked\".\nBecause a .gitignore file is in the project directory, the file\nitself can be versioned.\n\nFiles matched in .git/info/exclude will also not be \"tracked\". In\naddition, these files will not ever be remotely synced, and thus will\nnever be seen in any form by any other users. These files should be files that\nare specific to a single user's editor or workflow. Because it is in the .git\ndirectory, the exclude file can't itself be versioned.\n\nFiles that have had assume-unchanged run on them also don't show up in git status or git diff. This seems similar to exclude, in that these files are neither \"indexed\" nor \"tracked\". However, the last version of the file to be committed before assume-unchanged will remain visible to all users in the repo.\n\n\nMy questions:\n\nIs the above interpretation correct? Please correct me.\n\nIf a file has already been in a commit, what is the functional\ndifferent between matching it in .exclude and running\nassume-unchanged on it? Why would one prefer one approach to\nanother?\n\nMy basic use case is that I want to avoid sorting through diffs on\ncompiled files, but I still want those compiled files synced along\nwith the source files. Will a gitignore'd file still be pushed? If not, how to manage final deployment of the compiled files?"}, {"role": "assistant", "content": "I'm going to accept this emailed answer from Junio Hamano (the maintainer of Git) because I think it explains some things more lucidly than the official docs, and it can be taken as \"official\" advice:\n\nThe .gitignore and .git/info/exclude are the two UIs to invoke the\nsame mechanism. In-tree .gitignore are to be shared among project\nmembers (i.e. everybody working on the project should consider the\npaths that match the ignore pattern in there as cruft). On the other\nhand, .git/info/exclude is meant for personal ignore patterns (i.e.\nyou, while working on the project, consider them as cruft).\nAssume-unchanged should not be abused for an ignore mechanism. It is,\n\"I know my filesystem operations are slow. My intention is not to\nchange these paths so I have Git mark them with the 'assume-unchanged' bit.\nSo, Git will not check for changes in these paths every time I ask\nfor 'git status' output\". It does not mean anything other than that.\nEspecially, Git does not promise to always consider that\nthese paths are unmodified. If Git can determine any of these paths\nhave changed without incurring extra\nlstat(2) cost, it reserves the right to mark them as modified. As a result, \"git commit -a\" will commit that change."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-apply - Apply a patch to files and/or to the index --check"}, {"role": "assistant", "content": "Instead of applying the patch, see if the patch is\napplicable to the current working tree and/or the index\nfile and detects errors. Turns off \"apply\"."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to grep (search through) committed code in the Git history\nI have deleted a file or some code in a file sometime in the past. Can I search through the content (not just the commit messages)?\nA very poor solution is to grep the log:\ngit log -p | grep <pattern>\n\nHowever, this doesn't return the commit hash straight away. I played around with git grep to no avail."}, {"role": "assistant", "content": "To search for commit content (i.e., actual lines of source, as opposed to commit messages and the like), you need to do:\ngit grep <regexp> $(git rev-list --all)\n\ngit rev-list --all | xargs git grep <expression> will work if you run into an \"Argument list too long\" error.\nIf you want to limit the search to some subtree (for instance, \"lib/util\"), you will need to pass that to the rev-list subcommand and grep as well:\ngit grep <regexp> $(git rev-list --all -- lib/util) -- lib/util\n\nThis will grep through all your commit text for regexp.\nThe reason for passing the path in both commands is because rev-list will return the revisions list where all the changes to lib/util happened, but also you need to pass to grep so that it will only search in lib/util.\nJust imagine the following scenario: grep might find the same <regexp> on other files which are contained in the same revision returned by rev-list (even if there was no change to that file on that revision).\nHere are some other useful ways of searching your source:\nSearch working tree for text matching regular expression regexp:\ngit grep <regexp>\n\nSearch working tree for lines of text matching regular expression regexp1 or regexp2:\ngit grep -e <regexp1> [--or] -e <regexp2>\n\nSearch working tree for lines of text matching regular expression regexp1 and regexp2, reporting file paths only:\ngit grep -l -e <regexp1> --and -e <regexp2>\n\nSearch working tree for files that have lines of text matching regular expression regexp1 and lines of text matching regular expression regexp2:\ngit grep -l --all-match -e <regexp1> -e <regexp2>\n\nSearch working tree for changed lines of text matching pattern:\ngit diff --unified=0 | grep <pattern>\n\nSearch all revisions for text matching regular expression regexp:\ngit grep <regexp> $(git rev-list --all)\n\nSearch all revisions between rev1 and rev2 for text matching regular expression regexp:\ngit grep <regexp> $(git rev-list <rev1>..<rev2>)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git Workflows: Rebasing Published/Shared Branches\nOur team at work has enthusiastically adopted a rebase workflow, but we might have gotten a little carried away, which is the point of this question: you be the judge.\nUsing pull --rebase is a no-brainer to me now. However, we also have large feature branches that multiple people work on. Periodically, we want to bring in changes that are happening on master. Conventional wisdom would have us merge since it's a shared branch. However, in our rebase-obsession, we've decided to rebase those branches. Of course that requires everyone's cooperation. The workflow goes something like this:\n1) The rebaser coordinates with everyone to make sure they're all checked-in and pushed on the feature branch, then asks them to do no more work on that branch until they get the all clear.\n2) The rebaser rebases the feature branch onto master, deletes the remote feature branch (git push origin :feature), and then pushes the new, rebased feature branch (git push origin feature)\n3) The rebaser has everyone fetch, which updates their feature branch, then delete their local feature branch (git branch -D feature), then create a new local feature branch that tracks the remote feature branch. Everyone then gets the all-clear.\nThis workflow is working, partially because we're a small group, and the work interruptions are small. However, I worry that we're learning poor Git habits (rebasing a shared branch), or that the workflow won't scale well.\nOn the upside, our repository history is lovely.\nWhat do you think, Git gurus? Are we playing with fire, or rocking a reasonable workflow?\nUPDATE:\nIt's two years since I originally asked the question, and my has our workflow changed since then. We still routinely do git pull --rebase, so that hasn't changed. It's common sense, and it prevents all the unsightly, confusing mini-merges. (We keep mostly in sync, so there's little cost to git pull --rebase).\nOther than that, however, and the occasional heroic action to correct a mistake, we are over our rebase madness. Merging makes sense most of the time. However, wanton merging is problematic, and does contribute to the confusing, chaotic history I was concerned about two years ago.\nOur solution has several components:\n\nThe master branch is \"pristine\". Topic branches get merged in, and once they do, the topic branch is retired. In other words, merging a topic branch in signifies that that work is ready for production, and is now part of the master branch. Looking at our version history, it's very clear what's happening: topic branches getting merged into master, and that's that.\nWe use disposable integration branches when necessary. For example, if we have topic branches A, B, and C, and none of them are ready for integration into master, but we need to test them together, we just create a QA branch (usually off of master), and then merge A, B, and C in. At some point, the QA branch is deleted or re-used. The point is that it's not intended to be permanent in any way, and it doesn't have the same restrictions as the master branch (you can merge in your topic branches as many times as you want). If the history gets too confusing, you can just delete the QA branch and start fresh (an approach we have found to be very natural).\nWhen merging, always use git merge --no-ff. This is such a tremendous reversal from our \"linear commit history\" obsession from two years ago that it deserves comment. Now that we've relaxed about a linear commit history, and seen that merges are good and useful, we've started to rely on topic branches being actual branches off of master, not just a series of commits that eventually becomes one with master. git merge --no-ff ensures there's always a merge commit, even when it's not necessary.\nWe have a well-understood convention for commit messages and branches and, more importantly, it cross-references our issue-tracking system. Our issue tracking system uses numeric issue numbers, and for any feature (or defect), we have an issue number (1234, for example). If you're working on that issue, you would create a branch _1234 and start every commit message with \"_1234: doing blah blah\". It may seem a little obsessive, but it has really worked well for us, and significantly reduced/eliminated confusion.\nUse a git wrapper to encourage workflow adhesion. This is something we're currently working on, but we've realized is entirely necessary to prevent simple and understandable mistakes, like branching off of the wrong thing (we recently had a complete disaster when a developer created a topic branch off of a disposable QA branch: that topic branch was approved to go live, it was merged in...and a bunch of changers that weren't approved to go live were sucked in). Our git wrapper will require confirmation whenever you do something unusual (like creating a branch off of anything but master, creating a branch not named _NNNN, making a commit that doesn't start with _NNNN, etc.). Occasionally, we do need to do these things, so the wrapper doesn't prevent it, but it does keep people from accidentally doing something they shouldn't."}, {"role": "assistant", "content": "This sounds like it's overly complicated and won't scale well. It's probably a heck of a lot simpler just to merge master into your feature branch periodically, and then when it comes time to merge back into master, then you can do the rebase first (to remove the intermediate unnecessary merge) and merge back into master (presumably with --no-ff to produce a merge commit). This only requires one person deal with the rebase, and they don't have to do any coordination because nobody else needs to force-update anything (because, presumably, the branch is going to be deleted after it's merged, rather than kept around in a rewritten state). You may also decide to skip the rebase entirely and just leave the intermediate merges in place, which would more accurately reflect your development workflow and remove the risk of producing commits that don't actually build."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git merge without auto commit\nIs it possible to do a git merge, but without a commit?\n\"man git merge\" says this:\nWith --no-commit perform the merge but pretend the merge failed and do not autocommit,\nto give the user a chance to inspect and further tweak the merge result before\ncommitting.\n\nBut when I try to use git merge with the --no-commit it still auto-commits. Here's what I did:\n$> ~/git/testrepo$ git checkout master\nSwitched to branch 'master'\n\n$> ~/git/testrepo$ git branch\n* master\n v1.0\n\n$> ~/git/testrepo$ git merge --no-commit v1.0\nUpdating c0c9fd2..18fa02c\nFast-forward\n file1 | 1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\n$> ~/git/testrepo$ git status\n# On branch master\n# Your branch is ahead of 'origin/master' by 1 commit.\n#\nnothing to commit (working directory clean)\n\nA subsequent git log reveals all the commits from the v1.0 branch merged into master."}, {"role": "assistant", "content": "Note the output while doing the merge - it is saying Fast Forward.\nIn such situations, you want to do:\ngit merge <name-of-branch> --no-commit --no-ff\n\nImportant: If you do it this way, then you are not able to do any changes to the files in the staging area e.g. you can't remove/add files or make any changes to the files.\nIf you want to merge the changes and then commit as if you had manually typed all of the changes you merged in (as opposed to a traditional merge) you need to run rm .git/MERGE_HEAD afterward, which will force git to forget that the merge happened."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-remote - Manage set of tracked repositories update"}, {"role": "assistant", "content": "Fetch updates for remotes or remote groups in the repository as defined by remotes.<group> . If neither group nor remote is specified on the command line,\nthe configuration parameter remotes.default will be used; if\nremotes.default is not defined, all remotes which do not have the\nconfiguration parameter remote.<name>.skipDefaultUpdate set to true will\nbe updated. (See git-config ). With --prune option, run pruning against all the remotes that are updated."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git - the stupid content tracker git-clean"}, {"role": "assistant", "content": "Remove untracked files from the working tree"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git -m --merge -s<strategy> --strategy=<strategy> -p --rebase-merges"}, {"role": "assistant", "content": "These are only used with the dcommit and rebase commands. Passed directly to git rebase when using dcommit if a git reset cannot be used (see dcommit )."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git: Could not resolve host github.com error while cloning remote repository in git\n\nWhat I did: I have created a remote repository on Github and I am trying to clone the remote repository on my local machine. While cloning I am providing the clone URL & target folder.\nBut every time I try to clone, I am getting this error:\nError: \"fatal: unable to access 'https://github.com/hyperion057/spring-repo.git/': Could not resolve host: github.com\"\nWhat do I need to do to connect to GitHub ?"}, {"role": "assistant", "content": "I got a similar error, and it's caused by incorrect proxy setting. This command saved me:\ngit config --global --unset http.proxy\n\nhttps version:\ngit config --global --unset https.proxy"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects %cd"}, {"role": "assistant", "content": "committer date (format respects --date= option)"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options merge.conflictStyle"}, {"role": "assistant", "content": "Specify the style in which conflicted hunks are written out to\nworking tree files upon merge. The default is \"merge\", which\nshows a <<<<<<< conflict marker, changes made by one side,\na ======= marker, changes made by the other side, and then\na >>>>>>> marker. An alternate style, \"diff3\", adds a ||||||| marker and the original text before the ======= marker. The\n\"merge\" style tends to produce smaller conflict regions than diff3,\nboth because of the exclusion of the original text, and because\nwhen a subset of lines match on the two sides, they are just pulled\nout of the conflict region. Another alternate style, \"zdiff3\", is\nsimilar to diff3 but removes matching lines on the two sides from\nthe conflict region when those matching lines appear near either\nthe beginning or end of a conflict region."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Don't add \"+\" to linux kernel version\nI am building linux kernel, if my kernel under git, then kernel version every time is:\nImage Name: Linux-2.6.39+\n\nIf I am not using git, then everything is OK without any plus at the end.\nI know that this done by scripts/setlocalversion script:\nif test \"$CONFIG_LOCALVERSION_AUTO\" = \"y\"; then\n # full scm version string\n res=\"$res$(scm_version)\"\nelse\n # append a plus sign if the repository is not in a clean\n # annotated or signed tagged state (as git describe only\n # looks at signed or annotated tags - git tag -a/-s) and\n # LOCALVERSION= is not specified\n if test \"${LOCALVERSION+set}\" != \"set\"; then\n scm=$(scm_version --short)\n res=\"$res${scm:++}\"\n fi\nfi\n\nSo, it is possible without code changes say to build system that no need to add \"+\" at the end of version line?"}, {"role": "assistant", "content": "The plus sign at the end of your version string is there as an indicator that the kernel was built from modified sources (that is, there were non-committed changes). This is also indicated by the comments in scripts/setlocalversion.\nTo avoid the '+' being appended despite having a dirty working directory, simply set LOCALVERSION explicityly when running make:\nmake LOCALVERSION=\n\nYou may also have to change the configuration option CONFIG_LOCALVERSION_AUTO to n in your kernel config (.config) before building:\nsed -i \"s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|\" .config"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "In Jenkins, how to checkout a project into a specific directory (using GIT)\n\nSorry for the 'svn' style - we are in a process of migration from SVN to GIT (including our CI Jenkins environment).\nWhat we need is to be able to make Jenkins to checkout (or should I say clone?) the GIT project (repository?) into a specific directory. We've tried some refspecs magic but it wasn't too obvious to understand and use successfully.\nFurthermore, if in the same Jenkins project we need to checkout several private GitHub repositories into several separate dirs under a project root, how can we do it please?\nWe have GitHub plugin installed. Hope we've phrased the things right."}, {"role": "assistant", "content": "In the new Jenkins 2.0 pipeline (previously named the Workflow Plugin), this is done differently for:\n\nThe main repository\nOther additional repositories\n\nHere I am specifically referring to the Multibranch Pipeline version 2.9.\nMain repository\nThis is the repository that contains your Jenkinsfile.\nIn the Configure screen for your pipeline project, enter your repository name, etc.\nDo not use Additional Behaviors > Check out to a sub-directory. This will put your Jenkinsfile in the sub-directory where Jenkins cannot find it.\nIn Jenkinsfile, check out the main repository in the subdirectory using dir():\ndir('subDir') {\n checkout scm\n}\n\nAdditional repositories\nIf you want to check out more repositories, use the Pipeline Syntax generator to automatically generate a Groovy code snippet.\nIn the Configure screen for your pipeline project:\n\nSelect Pipeline Syntax. In the Sample\nStep drop down menu, choose checkout: General SCM.\nSelect your SCM system, such as Git. Fill in the usual information\nabout your repository or depot.\nNote that in the Multibranch Pipeline, environment variable\nenv.BRANCH_NAME contains the branch name of the main repository.\nIn the Additional Behaviors drop down menu, select\nCheck out to a sub-directory\nClick Generate Groovy. Jenkins will display the Groovy code snippet\ncorresponding to the SCM checkout that you specified.\nCopy this code into your pipeline script or Jenkinsfile."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git: change one line in file for the complete history\nWhen I started my git repo I commited a few files as initial commit to it. Now, many commits later, I noticed that I included in those files a line with information which I do not want to publish (unlike the rest of the code). So I want to remove/change this one line and keep the rest of the code.\nSearching around I found this solution: Insert an empty commit as initial commit (described here: Insert a commit before the root commit in Git?), do a rebase on it and then edit the old first commit via amend. Unfortunately, many cruel merge conflicts arise during rebase (as described here: git: solving conflicts caused by rebase).\nIs there a different way to solve my problem or do have to rebase and edit all conflicts by hand?\nThanks in advance :)"}, {"role": "assistant", "content": "Here's a command that will remove an offending line from a file's history in all your branches:\ngit filter-branch --tree-filter 'sed -i \"/sensitive information/ d\" filename' -- --all\n\nThis checks out every revision, runs the sed command on it, then commits that revision back. \nThe sed command in this case matches any lines containing the pattern sensitive information in the file named filename and deletes those lines.\nNote: it's good if you have a backup, and try the sed script on its own first to make sure it's doing what you want, because it can take quite a while to run on a long history."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "github/git Checkout Returns 'error: invalid path' on Windows\nWhen I attempt to checkout a repository from github I get the error:\nerror: invalid path 'configs/perl-modules/DIST.64/perl-HTML-Tree-1:5.03-1.el6.noarch.rpm'\n\nI suspect the issue is that the path contains a : which is illegal on Windows.\nAfter researching the error, I've found 2 possible answers:\n1) Change the path on the repository file. Unfortunately, this is is a team resource and can not be fixed in the foreseeable future. \n2) Use sparse-checkout. I've tried this with no effect as evidenced in the following:\n\n$ git clone -n [email protected]:XXXXXX/deploy.git \nCloning into 'deploy'... \nremote: Enumerating objects: 57, done. \nremote: Counting objects: 100% (57/57), done. \nremote: Compressing objects: 100% (49/49), done. \nremote: Total 86457 (delta 10), reused 22 (delta 8), pack-reused 86400 \nReceiving objects: 100% (86457/86457), 1.50 GiB | 4.73 MiB/s, done. \nResolving deltas: 100% (59779/59779), done. \n$ cd deploy/ \n$ git config core.sparsecheckout true \n$ echo www >> .git/info/sparse-checkout \n$ git checkout centos6 \nerror: invalid path 'configs/perl-modules/DIST.64/perl-HTML-Tree-1:5.03-1.el6.noarch.rpm'\nerror: invalid path 'configs/perlbrew/perls/perl-5.24.1/man/man3/App::Cpan.3'\n.\n. (repeat for many files)\n.\n\nThis was done with Git for Windows \"git version 2.28.0.windows.1\". I have also tried both types of line endings and using various version of .git/info/sparse-checkout such as:\n/*\n!/configs/perl-modules\n!/configs/perlbrew/perls/perl-5.24.1/man/man3\n\nCheckout works fine on Linux, MacOS and WSL, only problem is that my IDEs don't work there. Why isn't sparse-checkout working on Windows. Is there any other possibilities?"}, {"role": "assistant", "content": "After I opened an issue on the git-for-windows bug tracker (https://github.com/git-for-windows/git/issues/2803), I found that my issue had already been filed as https://github.com/git-for-windows/git/issues/2777. That issue suggested that I need to set another git flag:\ngit config core.protectNTFS false\n\nThis (#2777) indeed contains a bypass for the my problem. I hope the git or git-for-windows (who were very responsive) come up with a better warning message, or even a true fix like a filepath mapping scheme.\nNote that this is only an issue when using sparse-checkout with windows."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitHub - How to revert changes to previous state\n\nI am using GitHub as my remote repository.\nI have already pushed 5 commits to the server and want to revert back to the state before the those commits.\nIf the commit hash is 3425661dba2aadccdbab, how do I revert the entire local/remote back to that commit? I tried \n$ reset --hard 3425661dba2aadccdbab\n\nbut that only resetted my working head to that branch and requires me to do a git pull again. I tried checkout, but this caused me to land in a \"detached head\" branch."}, {"role": "assistant", "content": "You basically have two options to revert changes:\n\ncreate a new commit which applies reverse changes. This is the preferred option as it doesn't changes history on a public repository\nRemove the commits and force push them.\n\nThe first option can be achieved by using git revert\n\ngit-revert - Revert some existing commits\nGiven one or more existing commits, revert the changes that the related patches introduce, and record some new commits that record them.\n\nAn example would be git revert -n HEAD~5..HEAD. This command creates 5 new commits, each of which undoes one of the last 5 commits of the currently checked out branch.\nThe second option would be to actually remove the commits. Note that this changes history in the repository. So anyone who has already pull the changes will probably be rather surprised and things can get messy quickly. That said, you can do\ngit reset --hard HEAD~5\ngit push --force\n\nThe first command will wipe any uncommitted changes in your current working copy. and reset your local repository to the state of the current HEAD - 5 commits. The second command will force-push to the default remote (i.e. GitHub) There, any changes diverging from your current local repository are overwritten.\nA note of warning again: If you don't really know what you are doing, don't use this option as it can lead to data loss for you or others if not done right. Use the first option instead as it will transparently remove changes but without the nasty side-effects of history-rewriting."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to have a Gitlab CI Pipeline run some jobs always and other jobs only on merge-requests?\n\nTL/DR: \nMy goal is to have a Gitlab (CE-12.4.2) pipeline that executes some jobs only on merge-requests and other jobs always (on merge-requests and on all normal pushes). How must the .gitlab-ci.yml look to do this?\nMy use-case: \nI have a big pipeline running a lot of jobs (tests, validation, dep's, build, doc's, ...). Now I have added a staging environment (using kubernetes) and have the pipeline build a new image and deploy that in the staging-environment. This allows me to instantly open up the changed (web-)application and see how the changes behave and look without having to check them out locally. Now building an image and deploying it to staging would be much too resource-heavy to do for every push, so I only want deployments to staging when someone creates a merge-request for me to review.\nA very simplified example:\ninstall:\n script: ...\n\ntest:\n script: ...\n\nbuild-image:\n script: ...\n only: [merge_requests]\n\ndeploy-staging:\n script: ...\n only: [merge_requests]\n\nFor all normal pushes, the jobs install and test should be executed.\nFor merge-requests, the jobs install, test, build-image and deploy-staging should be executed.\nWhat i have tried: Gitlab has this feature to define only: [merge_requests] on a job, this causes that job to only be executed when the pipeline is executed for a merge-request. Sounds like exactly what I am looking for, but there is a big catch. Once that attribute is applied to one job in a pipeline, all other jobs in that pipeline that do not have that attribute will be removed from the pipeline when executed inside merge-requests. That seemed like a bug to me at first, but is actually documented behaviour:\nIn the above example, the pipeline contains only a test job. Since the build and deploy jobs don’t have the only: [merge_requests] parameter, they will not run in the merge request.\n\nIn order to re-introduce all the other jobs to the pipeline for merge-requests, I have to apply only: [merge_requests] to all other jobs. The problem with that approach is that now these regular jobs do not get executed for normal git-pushes anymore. And I have no way to re-introduce these regular jobs to pipelines for normal pushes, because Gitlab has no support for only: [always] or anything like that.\nNow I also have noticed that the only syntax is candidate for deprecation and one should prefer the rules syntax instead, so I took a look at that. There are multiple problems with that approach: \n\nThe only way to detect with rules whether the pipeline is executed for a merge-request or not is to evaluate the variables related to merge-requests, like $CI_MERGE_REQUEST_ID. Unfortunately these variables only exist when only: [merge_requests] is used, which would re-introduce the above problems.\nRules only allow the conditional application of other attributes, so I still would have to use only, except or when attributes to actually remove or add jobs from or to the pipeline. Unfortunately Gitlab does not support anything like only: [never] or when: never, so i have no way to actually remove or add the jobs.\n\nI also tried to have the jobs depend on another using need or dependencies attributes, this seemed to have no effect on whether the job is included to the pipeline or not.\nThe last thing I desperately tried was including all jobs always and just mark them as when: manual to be triggered manually by pushing a button. This somewhat works, but is very tedious because the deployment to staging is a multi-job process with every job taking quite some time to finish. So I would see a merge-request, push the button for the first job, wait 5 minutes, press the next button, wait 5 minutes again, and only then am able to use the staging. For many small merge-requests, this would take up a lot of my time and would not be a efficient solution. I also cannot just mark the first of these jobs as manual because Gitlab will then just skip that job and execute that later ones out of order (And again, needs and dependencies seem to have no effect on this when dealing with manually triggered jobs).\nWhat i am a bit baffled about is that after searching the net, I have found nobody having the same problem. Either I am the only Gitlab User that wants to execute some jobs only for merge-requests without excluding all other jobs (which seems highly unlikely) or I am missing something obvious (which seems more likely). Am I missing something or does Gitlab really not support this use-case?"}, {"role": "assistant", "content": "From the previous answer:\n\nBut there is a problem. This example launches two pipelines for every push after MR is created. One for only: [branch], one for only: [merge_requests]\n\nCheck if the last GitLab 13.8 (January 2021) can help:\n\nUse both branch and MR pipelines without duplication\nPreviously it was not possible to run pipelines for branches first, then switch to merge requests pipelines when the MR is created.\nConsequently, with some configurations, a push to a branch could result in duplicate pipelines if a merge request was already open on the branch: one pipeline on the branch and another for the merge request.\nNow you can use the new $CI_OPEN_MERGE_REQUESTS predefined environment variable in your CI configurations to switch from branch pipelines to MR pipelines at the right time, and prevent redundant pipelines.\n\nSee Documentation and Issue.\n\nuser2993689 points out in the comments to the documentation for a similar example:\n\nAvoid duplicate pipeline"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database badTreeSha1"}, {"role": "assistant", "content": "(ERROR) A tree has an invalid format."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why does git say \"Pull is not possible because you have unmerged files\"?\nWhen I try to pull in my project directory in the terminal, I see the following error:\nharsukh@harsukh-desktop:~/Sites/branch1$ git pull origin master\nU app/config/app.php\nU app/config/database.php\nU app/routes.php\nPull is not possible because you have unmerged files.\nPlease, fix them up in the work tree, and then use 'git add/rm <file>'\nas appropriate to mark resolution, or use 'git commit -a'.\n\nWhy does git say \"Pull is not possible because you have unmerged files\", and how can I resolve it?"}, {"role": "assistant", "content": "What is currently happening is, that you have a certain set of files, which you have tried merging earlier, but they threw up merge conflicts.\nIdeally, if one gets a merge conflict, they should resolve them manually, and commit the changes using git add file.name && git commit -m \"removed merge conflicts\".\nNow, another user has updated the files in question on their repository, and has pushed their changes to the common upstream repo.\nIt so happens, that your merge conflicts from (probably) the last commit were not not resolved, so your files are not merged all right, and hence the U(unmerged) flag for the files.\nSo now, when you do a git pull, git is throwing up the error, because you have some version of the file, which is not correctly resolved.\nTo resolve this, you will have to resolve the merge conflicts in question, and add and commit the changes, before you can do a git pull.\nSample reproduction and resolution of the issue:\n# Note: commands below in format `CUURENT_WORKING_DIRECTORY $ command params`\nDesktop $ cd test\n\nFirst, let us create the repository structure\ntest $ mkdir repo && cd repo && git init && touch file && git add file && git commit -m \"msg\"\nrepo $ cd .. && git clone repo repo_clone && cd repo_clone\nrepo_clone $ echo \"text2\" >> file && git add file && git commit -m \"msg\" && cd ../repo\nrepo $ echo \"text1\" >> file && git add file && git commit -m \"msg\" && cd ../repo_clone\n\nNow we are in repo_clone, and if you do a git pull, it will throw up conflicts\nrepo_clone $ git pull origin master\nremote: Counting objects: 5, done.\nremote: Total 3 (delta 0), reused 0 (delta 0)\nUnpacking objects: 100% (3/3), done.\nFrom /home/anshulgoyal/Desktop/test/test/repo\n * branch master -> FETCH_HEAD\n 24d5b2e..1a1aa70 master -> origin/master\nAuto-merging file\nCONFLICT (content): Merge conflict in file\nAutomatic merge failed; fix conflicts and then commit the result.\n\nIf we ignore the conflicts in the clone, and make more commits in the original repo now,\nrepo_clone $ cd ../repo\nrepo $ echo \"text1\" >> file && git add file && git commit -m \"msg\" && cd ../repo_clone\n\nAnd then we do a git pull, we get\nrepo_clone $ git pull\nU file\nPull is not possible because you have unmerged files.\nPlease, fix them up in the work tree, and then use 'git add/rm <file>'\nas appropriate to mark resolution, or use 'git commit -a'.\n\nNote that the file now is in an unmerged state and if we do a git status, we can clearly see the same:\nrepo_clone $ git status\nOn branch master\nYour branch and 'origin/master' have diverged,\nand have 1 and 1 different commit each, respectively.\n (use \"git pull\" to merge the remote branch into yours)\n\nYou have unmerged paths.\n (fix conflicts and run \"git commit\")\n\nUnmerged paths:\n (use \"git add <file>...\" to mark resolution)\n\n both modified: file\n\nSo, to resolve this, we first need to resolve the merge conflict we ignored earlier\nrepo_clone $ vi file\n\nand set its contents to\ntext2\ntext1\ntext1\n\nand then add it and commit the changes\nrepo_clone $ git add file && git commit -m \"resolved merge conflicts\"\n[master 39c3ba1] resolved merge conflicts"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Is there an upper limit to the number of commits a git repository can handle?\nI'm wondering if there's an upper limit to the number of commits that a git repository can handle.\nIn a solo project I'm working on right now, I've been coding locally, committing/pushing changes in git, then pulling the changes on my development server.\nI treat this as an easier alternative to working locally and uploading changes via FTP... Fortunately/Unfortunately it's such an easy workflow that I sometimes go through many edit/commit/push/pull/browser-refresh cycles while coding.\nI'm wondering if this is going to turn around and bite me somewhere down the line. If it's likely to be a problem, I'm wondering how I can avoid that trouble ... It seems like a rebase might be the way to go, especially since I won't have to worry about conflicting branches etc."}, {"role": "assistant", "content": "Well the \"upper limit\" would likely be the point at which a SHA1 collision occurs, but since the SHAs are 40 hexadecimal digits long (16^40 ~ 1.4x10^48 possibilities), it's so close to zero possibility that it's not even funny. So there's roughly a zero percent chance you'll have any problems for at least the next several millennia.\nHyperbolic Example (just for fun): 1 commit/minute (just changing one file -> three new SHAs used (file, commit, tree) = 3 new shas used / minute = ... = 1.6M shas used / year = 1.6 Billion shahs / millennia = 1x10^-37 % used each millenia... (at 1000 files/commmit/min, it's still 3.6x10^-35%)\nThat being said, if you want to clean up your history, squashing them down with rebase is probably your best bet. Just make sure you understand the implications if you've shared the repo publicly at all.\nYou might also want to garbage collect after rebasing to free up some space (make sure the rebase worked right first, though, and you might need to tell it to collect everything or it will, by default, not collect anything newer than two-weeks old)."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options gc.auto"}, {"role": "assistant", "content": "When there are approximately more than this many loose\nobjects in the repository, git gc --auto will pack them.\nSome Porcelain commands use this command to perform a\nlight-weight garbage collection from time to time. The\ndefault value is 6700. Setting this to 0 disables not only automatic packing based on the\nnumber of loose objects, but also any other heuristic git gc --auto will\notherwise use to determine if there’s work to do, such as gc.autoPackLimit ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to git bundle a complete repo\nI need to transfer a complete repo to a new non-networked machine, preferable as a single file entity. The git bundle allows a git fetch, git pull style operation in a sneakernet environment but appears to assume that you already have a working version of the repo on the destination machine.\nWhat is the right invocation to:\n\nBundle all the branches in the current repo\nStart up the new repo on the destination directory, i.e. get the root commit correctly installed\n\n\nI've sent a patch upstream to clarify:\n`git clone` can use any bundle created without negative refspecs\n(e.g., `new`, but not `old..new`).\nIf you want to match `git clone --mirror`, which would clone other\nrefs such as `refs/remotes/*`, use `--all`.\nIf you want to provide the same set of refs that a clone directly\nfrom the source repository would get, use `--branches --tags` for\nthe `<git-rev-list-args>`.\n\nSo $ git bundle create repo.bundle --branches --tags best matches cloning.\n$ git bundle create repo.bundle --all will provide a mirror image of your source machine, including its remote refs."}, {"role": "assistant", "content": "What is the right invocation to:\n\nBundle all the branches in the current repo\n\n\nSimple:\n$ git bundle create repo.bundle --all\n\nHere repo.bundle is the name of bundle file you want to create. Note that --all would not include remote-tracking branches... just like ordinary clone wouldn't either.\n\n\nStart up the new repo on the destination directory, i.e. get the root commit correctly installed\n\n\nFirst, clone is just init + fetch (+ administrativia).\nSecond, you can use bundle file everywhere the repository URL can be used, so you can simply clone from a bundle file:\n$ git clone repo.bundle\n\nThis would create repo as a git repository."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options receive.autogc"}, {"role": "assistant", "content": "By default, git-receive-pack will run \"git maintenance run --auto\" after\nreceiving data from git-push and updating refs. You can stop\nit by setting this variable to false."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do I disable git's credential helper for a single repository?\nIf I have a credential helper set in my ~/.gitconfig, how can I disable/bypass it in a specific repo and use no credential helper?\nI've tried editing the repo's .git/config file to blank out the credential.helper property like this:\n[credential]\n helper = \n\n... but when I do a git push I get the following error message, and Git uses my default credential helper from ~/.gitconfig anyway:\ngit: 'credential-' is not a git command. See 'git --help'.\n\nDid you mean this?\n credential\n\nI'm using git version 1.7.12.\n(Backstory/use case: Git is configured to use the store helper, which stores passwords unencrypted on disk. The cache helper is unavailable on this system. I have a couple repos for which I'd rather type the password every time than keep it on disk.)"}, {"role": "assistant", "content": "With git 2.9 (June 2016), this (helper = ) will actually work!\nThe credential.helper configuration variable is cumulative and there is no good way to override it from the command line.\nAs a special case, giving an empty string as its value now serves as the signal to clear the values specified in various files.\nSee commit 2432137 (26 Feb 2016) by Jeff King (peff).\n(Merged by Junio C Hamano -- gitster -- in commit 1b68962, 03 Apr 2016)\n\ncredential: let empty credential specs reset helper list\n\n\nSince the credential.helper key is a multi-valued config list, there's no way to \"unset\" a helper once it's been set. So if your system /etc/gitconfig sets one, you can never avoid running it, but only add your own helpers on top.\nSince an empty value for credential.helper is nonsensical (it would just try to run \"git-credential-\"), we can assume nobody is using it. Let's define it to reset the helper list, letting you override lower-priority instances which\nhave come before.\n\n\nEven more convenient: With Git 2.26 (Q1 2020), this override applies even for any value.\nSee commit 46fd7b3, commit 82eb249, commit 588c70e, commit 732f934, commit 3fa0e04 (20 Feb 2020) by brian m. carlson (``).\n(Merged by Junio C Hamano -- gitster -- in commit 2cbb058, 05 Mar 2020)\n\ncredential: use the last matching username in the config\nSigned-off-by: brian m. carlson\n\n\nEverywhere else in the codebase, we use the rule that the last matching configuration option is the one that takes effect.\nThis is helpful because it allows more specific configuration settings (e.g., per-repo configuration) to override less specific settings (e.g., per-user configuration).\nHowever, in the credential code, we didn't honor this setting, and instead picked the first setting we had, and stuck with it.\nThis was likely to ensure we picked the value from the URL, which we want to honor over the configuration.\nIt's possible to do both, though, so let's check if the value is the one we've gotten over our protocol connection, which if present will have come from the URL, and keep it if so.\nOtherwise, let's overwrite the value with the latest version we've got from the configuration, so we keep the last configuration value.\n\n\nNote: user202729 adds in the comments:\n\nIf credential helper A is set as global and you want to use B in a local repository (change, not remove the helper), use:\ngit config --local credential.helper ''\ngit config --local --add credential.helper B\n\nThe first empty item removes the global setting A.\nEquivalently, set two lines helper = and helper = B in .git/config."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitglossary - A Git Glossary unborn"}, {"role": "assistant", "content": "The HEAD can point at a branch that does not yet exist and that does not have any commit on\nit yet, and such a branch is called an unborn branch. The\nmost typical way users encounter an unborn branch is by\ncreating a repository anew without cloning from elsewhere.\nThe HEAD would point at the main (or master , depending\non your configuration) branch that is yet to be born. Also\nsome operations can get you on an unborn branch with their orphan option."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Editing the git commit message in GitHub\nIs there any way of online editing the commit message in GitHub.com, after submission?\nFrom the command line, one can do\ngit commit --amend -m \"New commit message\"\n\nas correctly suggested in the following question:\n\nHow to modify existing, unpushed commit messages?\n\nTrying git pull and then git push has worked (without any other commit having interfered in the mean time).\nBut can it be done via the GitHub website?"}, {"role": "assistant", "content": "GitHub's instructions for doing this:\n\nOn the command line, navigate to the repository that contains the commit you want to amend.\nType git commit --amend and press Enter.\nIn your text editor, edit the commit message and save the commit.\nUse the git push --force origin example-branch command to force push over the old commit.\n\nSource: https://help.github.com/articles/changing-a-commit-message/"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Download single files from GitHub\nWhat are some tips on downloading a single file from a GitHub repo?\nI don't want the URL for displaying the raw file; in the case of binaries, there's nothing.\nhttp://support.github.com/discussions/feature-requests/41-download-single-file\nIs it even possible to use GitHub as a \"download server\"?\nIf we decide to switch to Google Code, is the mentioned functionality presented there?\nOr is there any free-of-charge hosting and VCS for open-source projects?"}, {"role": "assistant", "content": "Go to the file you want to download.\nClick it to view the contents within the GitHub UI.\nIn the top right, right click the Raw button.\nSave as..."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-fast-import - Backend for fast Git data importers Reading from the active commit"}, {"role": "assistant", "content": "This form can only be used in the middle of a commit .\nThe path names a directory entry within fast-import’s\nactive commit. The path must be quoted in this case. 'ls' SP <path> LF"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Find the root of the git repository where the file lives\nWhen working in Python (e.g. running a script), how can I find the path of the root of the git repository where the script lives?\nSo far I know I can get the current path with:\npath_to_containing_folder = os.path.dirname(os.path.realpath(__file__))\n\nHow can I then find out where the git repository lives?"}, {"role": "assistant", "content": "Use the GitPython module http://gitpython.readthedocs.io/en/stable/.\npip install gitpython\n\nAssume you have a local Git repo at /path/to/.git. The below example receives /path/to/your/file as input, it correctly returns the Git root as /path/to/.\nimport git\n\ndef get_git_root(path):\n\n git_repo = git.Repo(path, search_parent_directories=True)\n git_root = git_repo.git.rev_parse(\"--show-toplevel\")\n print git_root\n\nif __name__ == \"__main__\":\n get_git_root(\"/path/to/your/file\")"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "GitLab.com CI shared runner for Android projects\n\nI'd like to use GitLab CI system for my Android application gradle project. The project repository is hosted on GitLab.com, so I'd like to use one of the Shared Runners provided by Gitlab Inc.\nWhile the official tutorial provides an example for NodeJS project runner configuration and there are also shared runners for Ruby projects, I couldn't find any example or even a runner that supports Android applications. \n\nIs there a shared runner provided by GitLab.com, which supports Android projects out of the box (by specifying image: android:4.2.2 or something like this)?\nIs there a way to configure existing shared runner provided by GitLab.com to support Android projects (by modifying the .gitlab-ci.yml file)?"}, {"role": "assistant", "content": "I'm using this docker image to run android build on gitlab-ci\nUpdate: \nMoved to Gitlab registry\nimage: registry.gitlab.com/showcheap/android-ci:latest\n\nbefore_script:\n - export GRADLE_USER_HOME=`pwd`/.gradle\n - chmod +x ./gradlew\n\ncache:\n paths:\n - .gradle/wrapper\n - .gradle/caches\n\nbuild:\n stage: build\n script:\n - ./gradlew assemble\n\ntest:\n stage: test\n script:\n - ./gradlew check\n\nFull Guide can check in this Gitlab Repository:\nhttps://gitlab.com/showcheap/android-ci\nIf your Target SDK and Build Tools version are not listed, please make a pull request or fork my repo then make your custom target and build version."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Changing the Git user inside Visual Studio Code\nThe user for my Git commits has changed, but I am not able to change that inside of Visual Studio Code.\nI changed the global settings in Git, but when I want to push or sync via Visual Studio Code inside my new repositories I get the error that the oldusername has not the permission to push into newrepository.\nAt this point it is not the permission. The change of the username did not work for Visual Studio Code. When I use the terminal I can push. It is also not a solution to allow the olduser to push to the newrepository.\nI am on Windows 10. So all other tools are working, but just at Visual Studio Code I was not able to change the user.\nHow can I fix this problem?"}, {"role": "assistant", "content": "I resolved this issue by setting an email address in Git:\ngit config --global user.email \"[email protected]\""}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-show - Show various types of objects %aE"}, {"role": "assistant", "content": "author email (respecting .mailmap, see git-shortlog or git-blame )"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Git: warning: refname 'master' is ambiguous\nI saw a few people asking the same question on here but it seems none of their advice is applicable to me. I'm getting the warning that is in the title of this but I don't have any tags named \"master\". This is the result of git branch -a:\n* master\n remotes/origin/HEAD -> origin/master\n remotes/origin/master\n\nAny idea what could be going wrong here? I've only been using git for a few months now, so it mostly just worries me that this ambiguity might mess with the repo in the future."}, {"role": "assistant", "content": "For me I tracked down the source of this warning to much earlier when I incorrectly issued an \"update-ref\" command. If you forget to specify the full refs/heads/mybranchname path in the first arg, then a file .git/mybranchname gets created, which later leads to this warning when you try to switch to that branch.\nIt is solved by simply deleting the .git/mybranchname, eg:\nrm .git/master\n\nAnd for reference, the correct form for the update-ref command is:\ngit update-ref refs/heads/mybranchname mytargetbranch\n\nDon't forget the \"refs/heads\" part!\nAlso, my most common use-case for update-ref is simply manually moving a branch to point to another commit, which I've found a simpler syntax to do:\ngit branch -f myBranchToMove destinationBranchOrHash\nThis syntax is easier for me because it doesn't require that error-prone refs/heads path qualifier."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-config - Get and set repository or global options fetchShowForcedUpdates"}, {"role": "assistant", "content": "Shown when git-fetch takes a long time\nto calculate forced updates after ref updates, or to warn\nthat the check is disabled."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-parse - Pick out and massage parameters HEAD"}, {"role": "assistant", "content": "names the commit on which you based the changes in the working tree."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How to determine the URL that a local Git repository was originally cloned from\n\nI pulled a project with several forks on GitHub, but forgot which fork it was. How do I determine which fork I pulled?"}, {"role": "assistant", "content": "To obtain only the remote URL:\ngit config --get remote.origin.url\n\nIf you require full output, and you are on a network that can reach the remote repo where the origin resides:\ngit remote show origin\n\nWhen using git clone (from GitHub, or any source repository for that matter) the default name for the source of the clone is \"origin\". Using git remote show will display the information about this remote name. The first few lines should show:\nC:\\Users\\jaredpar\\VsVim> git remote show origin\n* remote origin\n Fetch URL: [email protected]:jaredpar/VsVim.git\n Push URL: [email protected]:jaredpar/VsVim.git\n HEAD branch: master\n Remote branches:\n\nIf you want to use the value in a script, you would use the first command listed in this answer."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-rev-parse - Pick out and massage parameters <rev>^{/<text>} , e.g. HEAD^{/fix nasty bug}"}, {"role": "assistant", "content": "A suffix ^ to a revision parameter, followed by a brace\npair that contains a text led by a slash,\nis the same as the :/fix nasty bug syntax below except that\nit returns the youngest matching commit which is reachable from\nthe <rev> before ^ ."}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How do you rename a Git tag?\nToday I was looking through the logs for a project and realized that I fat fingered a tag name some time ago. Is there some way to rename the tag? Google hasn't turned up anything useful.\nI realize I could check out the tagged version and make a new tag, I even tried that. But that seems to create a tag object that isn't quite right. For one,\ngit tag -l\n\nlists it out of order relative to all of the other tags. I have no idea if that's significant, but it leads me to believe that the new tag object isn't quite what I want. I can live with that, because I really only care that the tag name matches the documentation, but I'd rather do it \"right\", assuming there is a right way to do this."}, {"role": "assistant", "content": "Here is how I rename a lightweight tag old to new:\ngit tag new old # Create a new local tag named `new` from tag `old`.\ngit tag -d old # Delete local tag `old`.\ngit push origin new :old # Push `new` to your remote named \"origin\", and delete\n # tag `old` on origin (by pushing an empty tag\n # name to it).\n\nThe colon in the push command removes the tag from the remote repository. If\nyou don't do this, Git will create the old tag on your machine when you pull.\nFinally, make sure that the other users remove the deleted tag. Please tell\nthem (co-workers) to run the following command:\ngit fetch --prune --prune-tags\n\nNote that if you are renaming an annotated tag, you need to ensure that the new tag name is referencing the underlying commit and not the old annotated tag object that you're about to delete. If the old tag is an annotated tag, or you aren't sure, you can use ^{} to dereference the object until a non-tag object is found:\n# create a new annotated tag \"new\" referencing the object\n# which the old annotated tag \"old\" was referencing:\ngit tag -a new old^{}"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git -r <n>[:<n>] --revision=<n>[:<n>]"}, {"role": "assistant", "content": "is supported, non-numeric args are not:\nHEAD, NEXT, BASE, PREV, etc …​"}]} {"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "gitglossary - A Git Glossary"}, {"role": "assistant", "content": "NAME gitglossary - A Git Glossary"}]}