messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git - how to find first commit of specific branch\nIn following example tree:\nA-B-C-D-E (master branch)\n \\\n F-G-H (xxx branch)\n\nI'm looking for F - the first commit in xxx branch. I think that it is possible with:\ngit log xxx --not master\n\nand the last listed commit should be F. Is it correct solution or maybe there are some disadvantages of it? \nI know that there were similar questions on stackoverflow, but nobody proposed such solution, and I'm not sure if I do it right." }, { "role": "assistant", "content": "git log master..branch --oneline | tail -1\n\nWhere \"branch\" is your specific branch name. The dot-dot gives you all of the commits that the branch has that master doesn't have. tail -1 returns the last line from the previous output." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order --cherry-mark" }, { "role": "assistant", "content": "Like --cherry-pick (see below) but mark equivalent commits\nwith = rather than omitting them, and inequivalent ones with + ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I remove the old history from a git repository?\nI'm afraid I couldn't find anything quite like this particular scenario.\nI have a git repository with a lot of history: 500+ branches, 500+ tags, going back to mid-2007. It contains ~19,500 commits. We'd like to remove all of the history before Jan 1, 2010, to make it smaller and easier to deal with (we would keep a complete copy of the history in an archive repository).\nI know the commit that I want to have become the root of the new repository. I can't, however, figure out the correct git mojo to truncate the repo to start with that commit. I'm guessing some variant of \ngit filter-branch\n\ninvolving grafts would be necessary; it might also be necessary to treat each of the 200+ branches we want to keep separately and then patch the repo back together (something I do know how to do).\nHas anyone ever done something like this? I've got git 1.7.2.3 if that matters." }, { "role": "assistant", "content": "If you want to free some space in your git repo, but do not want to rebuild all your commits (rebase or graft), and still be able to push/pull/merge from people who has the full repo, you may use the git clone shallow clone (--depth parameter).\n; Clone the original repo into limitedRepo\ngit clone file:///path_to/originalRepo limitedRepo --depth=10\n\n; Remove the original repo, to free up some space\nrm -rf originalRepo\ncd limitedRepo\ngit remote rm origin\n\nYou may be able to shallow your existing repo, by following these steps:\n; Shallow to last 5 commits\ngit rev-parse HEAD~5 > .git/shallow\n\n; Manually remove all other branches, tags and remotes that refers to old commits\n\n; Prune unreachable objects\ngit fsck --unreachable ; Will show you the list of what will be deleted\ngit gc --prune=now ; Will actually delete your data\n\nHow to remove all git local tags?\nPs: Older versions of git didn't support clone/push/pull from/to shallow repos." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I add an SSH key in gitlab?\n\nHere is what my dashboard looks like: \n\nNot really sure where to add an SSH key. Anyone have any idea?" }, { "role": "assistant", "content": "Go to your GitLab account: https://gitlab.com/\nClick on Settings on the top right drop-down, which will appear once you select the icon(white-fox image [specific to my profile]).\n\nClick on Settings on the top right drop-down, which will appear once you select the icon(white-fox image). \nClick on SSH Keys:\n\nAdd/Paste the SSH Key.\nHow to generate the ssh key: Download gitbash or putty: \nAfter downloading gitbash/putty follow the steps: \n\nOpen a terminal on Linux or macOS, or Git Bash / WSL on Windows. \nGenerate a new ED25519 SSH key pair: \nssh-keygen -t ed25519 -C \"[email protected]\" \n\nOr, if you want to use RSA: \nssh-keygen -t rsa -b 4096 -C \"[email protected]\" \n\nIt will generate the key in => C:\\Users\\yourname.ssh directory.\nCopy the public key and paste in the gitlab location: \n\n\nCommand to run on gitbash to clone the repository: \nssh-agent $(ssh-add C:\\Users\\youname\\.ssh\\id_rsa; git clone [email protected]:xyz/SpringBootStarter.git)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What algorithm does git use to detect changes on your working tree?\nThis is about the internals of git.\nI've been reading the great 'Pro Git' book and learning a little about how git is working internally (all about the SHA1, blobs, references, trees, commits, etc, etc). Pretty clever architecture, by the way.\nSo, to put into context, git references the content of a file as a SHA1 value, so it's able to know if a specific content has changed just comparing the hash values. But my question is specifically about how git checks that the content in the working tree has changed or not.\nThe naive approach will be thinking that each time you run a command as git status or similar command, it will search through all the files on the working directory, calculating the SHA1 and comparing it with the one that has the last commit. But that seems very inefficient for big projects, as the Linux kernel.\nAnother idea could be to check last modification date on the file, but I think git is not storing that information (when you clone a repository, all the files have a new time)\nI'm sure it's doing it in an efficient way (git is really fast), does anyone know how that is achieved?\nPD: Just to add an interesting link about the git index, specifically stating that the index keeps information about files timestamps, even when the tree objects do not." }, { "role": "assistant", "content": "Git’s index maintains timestamps of when git last wrote each file into the working tree (and updates these whenever files are cached from the working tree or from a commit). You can see the metadata with git ls-files --debug. In addition to the timestamp, it records the size, inode, and other information from lstat to reduce the chance of a false positive.\nWhen you perform git-status, it simply calls lstat on every file in the working tree and compares the metadata in order to quickly determine which files are unchanged. This is described in the documentation under racy-git and update-index." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --decorate-refs=<pattern> --decorate-refs-exclude=<pattern>" }, { "role": "assistant", "content": "For each candidate reference, do not use it for decoration if it\nmatches any patterns given to --decorate-refs-exclude or if it\ndoesn’t match any of the patterns given to --decorate-refs . The log.excludeDecoration config option allows excluding refs from\nthe decorations, but an explicit --decorate-refs pattern will\noverride a match in log.excludeDecoration . If none of these options or config settings are given, then references are\nused as decoration if they match HEAD , refs/heads/ , refs/remotes/ , refs/stash/ , or refs/tags/ ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-archive - Create an archive of files from a named tree -o <file> --output=<file>" }, { "role": "assistant", "content": "Write the archive to <file> instead of stdout." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options interactive.singleKey" }, { "role": "assistant", "content": "In interactive commands, allow the user to provide one-letter\ninput with a single key (i.e., without hitting enter).\nCurrently this is used by the --patch mode of git-add , git-checkout , git-restore , git-commit , git-reset , and git-stash ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Point branch to new commit\n(This question is the opposite of this one)\nHow can I go from this\ndev C - D\n /\nmaster A - B \n\nto this?\ndev D\n /\nmaster A - B - C \n\nI know I'm going to kick myself when I see the answer, but for the moment I'm a bit stuck..." }, { "role": "assistant", "content": "Solution\ngit checkout master\ngit merge C\n\nWith C being the SHA1 of commit C.\nResult\n D (dev)\n /\nmaster A - B - C (move master HEAD)\n\nIt should be a fast-forward merge." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order --basic-regexp" }, { "role": "assistant", "content": "Consider the limiting patterns to be basic regular expressions;\nthis is the default." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-push - Update remote refs along with associated objects --all --branches" }, { "role": "assistant", "content": "Push all branches (i.e. refs under refs/heads/ ); cannot be\nused with other <refspec>." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I diff the same file between two different commits on the same branch?\nIn Git, how could I compare the same file between two different commits (not contiguous) on the same branch (master for example)?\nI'm searching for a compare feature like the one in Visual SourceSafe (VSS) or Team Foundation Server (TFS).\nIs it possible in Git?" }, { "role": "assistant", "content": "From the git-diff manpage:\ngit diff [--options] <commit> <commit> [--] [<path>...]\n\nFor instance, to see the difference for a file \"main.c\" between now and two commits back, here are three equivalent commands:\n$ git diff HEAD^^ HEAD main.c\n$ git diff HEAD^^..HEAD -- main.c\n$ git diff HEAD~2 HEAD -- main.c" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What does the \"Next\" flag indicate on GitLab top bar?\n\nThis morning when I logged into GitLab I noticed this \"Next\" flag on the top bar: \n\nIt appears whether I am logged in or not. What does \"Next\" indicate? \nA Google search turns up nothing. It doesn't appear in any GitLab screen shots I am able to find either." }, { "role": "assistant", "content": "This is the canary version of Gitlab you are being served, you can find out more here: https://about.gitlab.com/handbook/engineering/#canary-testing\nYou can swap the version of Gitlab you see here: https://next.gitlab.com/?nav_source=navbar\nThe reasoning behind providing the Canary versions to users either at random or by those who have opt-ed in:\n\nGitLab makes use of a 'Canary' stage. Production Canary is a series of\n servers running GitLab code in production environment. The Canary\n stage contains code functional elements like web, container registry\n and git servers while sharing data elements such as sidekiq, database,\n and file storage with production. This allows UX code and most\n application logic code to be consumed by smaller subset of users under\n real world scenarios before being made available to all users on\n GitLab.com." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc <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." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git reset --hard HEAD leaves untracked files behind\nWhen I run git reset --hard HEAD, it's supposed to reset to a pristine version of what you pulled, as I understand it. Unfortunately, it leaves files lying around, as a git status shows a big list of untracked files.\nHow do you tell git \"Just bring it back to EXACTLY what was in the last pull, nothing more, nothing less\"?" }, { "role": "assistant", "content": "You have to use git clean -f -d to get rid of untracked files and directories in your working copy.\nYou can add -x to also remove ignored files, more info on that in this excellent SO answer.\nIf you need to reset an entire repository with submodules to the state on master, run this script:\ngit fetch origin master\ngit checkout --force -B master origin/master\ngit reset --hard\ngit clean -fdx\ngit submodule update --init --recursive --force\ngit submodule foreach git fetch\ngit submodule foreach git checkout --force -B master origin/master\ngit submodule foreach git reset --hard\ngit submodule foreach git clean -fdx" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to publish an organization repository in Github using VSCode\n\nI added my files and commited with no problem.\nThe problem is that when I press \"Publish to Github\" the only options there appear are private and public repositories as individual.\nBut I would like to publish as an organization." }, { "role": "assistant", "content": "Workaround for the lack of functionality:\nYou can add your project to a local repository by pressing \"Initialize Repository\" in your \"Source Control\" tab.\nAfter that, go to Github and make a new empty organisation repository.\nNow you can hit F1 and type \"Add Remote\". You can now choose \"Git: Add remote...\" and then paste the repository's URL, instead of adding from Github.\nNow committing and pushing should work as expected." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub Wiki pages sort order?\n\nI don't seem to be able to give a sort order to the Wiki pages of a project on GitHub. Does this option even exist?" }, { "role": "assistant", "content": "It does not. \nBut you can use the side bar to make a custom 'table of contents' where you can put them in any order you want, with headings and everything, see below (from https://github.com/BrechtDeMan/WebAudioEvaluationTool/wiki)\nYou may want to have a look at the answers to this question." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-add - Add file contents to the index -A --all --no-ignore-removal" }, { "role": "assistant", "content": "Update the index not only where the working tree has a file\nmatching <pathspec> but also where the index already has an\nentry. This adds, modifies, and removes index entries to\nmatch the working tree. If no <pathspec> is given when -A option is used, all\nfiles in the entire working tree are updated (old versions\nof Git used to limit the update to the current directory and its\nsubdirectories)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-apply - Apply a patch to files and/or to the index -v --verbose" }, { "role": "assistant", "content": "Report progress to stderr. By default, only a message about the\ncurrent patch being applied will be printed. This option will cause\nadditional information to be reported." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-update-index - Register file contents in the working tree to the index" }, { "role": "assistant", "content": "USING --INDEX-INFO --index-info is a more powerful mechanism that lets you feed\nmultiple entry definitions from the standard input, and designed\nspecifically for scripts. It can take inputs of three formats: mode SP type SP sha1 TAB path This format is to stuff git ls-tree output into the index. mode SP sha1 SP stage TAB path This format is to put higher order stages into the\nindex file and matches git ls-files --stage output. mode SP sha1 TAB path This format is no longer produced by any Git command, but is\nand will continue to be supported by update-index --index-info . To place a higher stage entry to the index, the path should\nfirst be removed by feeding a mode=0 entry for the path, and\nthen feeding necessary input lines in the third format. For example, starting with this index: $ git ls-files -s\n100644 8a1218a1024a212bb3db30becd860315f9f3ac52 0 frotz you can feed the following input to --index-info : $ git update-index --index-info\n0 0000000000000000000000000000000000000000\tfrotz\n100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1\tfrotz\n100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2\tfrotz The first line of the input feeds 0 as the mode to remove the\npath; the SHA-1 does not matter as long as it is well formatted.\nThen the second and third line feeds stage 1 and stage 2 entries\nfor that path. After the above, we would end up with this: $ git ls-files -s\n100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1\tfrotz\n100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2\tfrotz" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is there some way to work with git using .NET application? [closed]\nClosed. This question 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 Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.\n\n\nClosed 10 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nHow can I pull (maybe push too) some folder from GitHub?\nI mean I need API for .NET to access within C#, not GUI for git." }, { "role": "assistant", "content": "As James Manning mentioned in a comment in the currently accepted answer, the library libgit2sharp is an actively supported project providing a .NET API for Git." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options grep.lineNumber" }, { "role": "assistant", "content": "If set to true, enable -n option by default." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Exclude specific files from 'git pull'\nI have a production git repo that I only pull changes from the main repo into; I never change this repo or do commits/pushes from here. I recently accidentally pushed some untracked (at least I thought they were) image files to the main repo from my local dev repo. Now when I try to pull the latest from the main repo, git reports an error regarding overwriting the exiting image file with the file from the main repo. I don't even want this file from the repo (it's located in a .gitignored directory on the production repo).\nHow can I a) get rid of these unwanted image files in my main repo, or b) exclude these files from my git pull?" }, { "role": "assistant", "content": "This allowed me to tell git to ignore a specific file, even though it was already part of a project. All changes I make to it will be ignored:\ngit update-index --assume-unchanged Localization/el-GR.js\n\nNotes\n\nIt's ignored by git status, but not by git pull. You can solve it with something like git remote update && git checkout origin/main -- Localization/el-GR.js in order to retrieve the updated version.\n\nSource: http://codethug.com/2013/09/20/4-ways-to-ignore-files-with-git/" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I finish the merge after resolving my merge conflicts?\nI've read the Basic Branching and Merging section of the Git Community Book.\nSo I follow it and create one branch: experimental.\nThen I:\n\nswitch to experimental branch (git checkout experimental)\nmake a bunch of changes\ncommit it (git commit -a)\nswitch to master branch (git checkout master)\nmake some changes and commit there\nswitch back to experimental (git checkout experimental)\nmerge master change to experimental (git merge master)\nthere are some conflicts but after I resolve them, I did 'git add myfile'\nAnd now i am stuck, I can't move back to master\n\nwhen I do \n $ git checkout master\nerror: Entry 'res/layout/my_item.xml' would be overwritten by merge. Cannot merge.\n\nand I did:\n$ git rebase --abort\n\nNo rebase in progress?\nand I did :\n$ git add res/layout/socialhub_list_item.xml\n$ git checkout master\nerror: Entry 'res/layout/my_item.xml' would be overwritten by merge. Cannot merge.\n\nWhat can I do so that I can go back to my master branch?" }, { "role": "assistant", "content": "When there is a conflict during a merge, you have to finish the merge commit manually. It sounds like you've done the first two steps, to edit the files that conflicted and then run git add on them to mark them as resolved. Finally, you need to actually commit the merge with git commit. At that point you will be able to switch branches again.\nQuick Tip: You can use git commit -am \"your commit message\" to perform add and commit operations on tracked files simultaneously. (Credit: @vaheeds)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab CI / Docker: Use custom image for job\n\nThis is how I do some linter test (eslint).\nlinter:\n image: ubuntu:16.04\n stage: test\n tags:\n - testing\n before_script:\n - apt-get update -y\n - apt-get install nodejs-legacy -yqq\n - apt-get install curl -yqq\n - curl https://install.meteor.com/ | sh\n - meteor npm install eslint eslint-plugin-react\n script:\n - ./node_modules/.bin/eslint --ext .js --ext .jsx .\n\nBut with this every test will have to install the packages to the ubuntu image, which takes time.\nSo I thought to build a image with exact this. I came up with this Dockerfile:\nFROM ubuntu:16.04\nRUN apt-get update -y\nRUN apt-get install nodejs-legacy -yqq\nRUN apt-get install curl -yqq\nRUN apt-get clean && apt-get autoclean && apt-get autoremove\nRUN curl https://install.meteor.com/ | sh\n\nThen I do\n$ docker build -t linter-testing:latest .\n\nand this yml file:\nlinter:\n image: linter-testing:latest\n stage: test\n tags:\n - testing\n before_script:\n - meteor npm install eslint eslint-plugin-react\n script:\n - ./node_modules/.bin/eslint --ext .js --ext .jsx .\n\nBut it fails with this error:\nERROR: Job failed: Error response from daemon: repository linter-testing not found: does not exist or no pull access\n\nSo why is this image not existing, althoug docker images shows me exact that image..." }, { "role": "assistant", "content": "You need to edit your config.toml file which is in /etc/gitlab-runner on your runner machine with the following \n[runners.docker]\n pull_policy = \"if-not-present\"\n\nSee related issue here." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-push - Update remote refs along with associated objects --[no-]force-with-lease --force-with-lease=<refname> --force-with-lease=<refname>:<expect>" }, { "role": "assistant", "content": "Usually, \"git push\" refuses to update a remote ref that is\nnot an ancestor of the local ref used to overwrite it. This option overrides this restriction if the current value of the\nremote ref is the expected value. \"git push\" fails otherwise. Imagine that you have to rebase what you have already published.\nYou will have to bypass the \"must fast-forward\" rule in order to\nreplace the history you originally published with the rebased history.\nIf somebody else built on top of your original history while you are\nrebasing, the tip of the branch at the remote may advance with their\ncommit, and blindly pushing with --force will lose their work. This option allows you to say that you expect the history you are\nupdating is what you rebased and want to replace. If the remote ref\nstill points at the commit you specified, you can be sure that no\nother people did anything to the ref. It is like taking a \"lease\" on\nthe ref without explicitly locking it, and the remote ref is updated\nonly if the \"lease\" is still valid. --force-with-lease alone, without specifying the details, will protect\nall remote refs that are going to be updated by requiring their\ncurrent value to be the same as the remote-tracking branch we have\nfor them. --force-with-lease=<refname> , without specifying the expected value, will\nprotect the named ref (alone), if it is going to be updated, by\nrequiring its current value to be the same as the remote-tracking\nbranch we have for it. --force-with-lease=<refname>:<expect> will protect the named ref (alone),\nif it is going to be updated, by requiring its current value to be\nthe same as the specified value <expect> (which is allowed to be\ndifferent from the remote-tracking branch we have for the refname,\nor we do not even have to have such a remote-tracking branch when\nthis form is used). If <expect> is the empty string, then the named ref\nmust not already exist. Note that all forms other than --force-with-lease=<refname>:<expect> that specifies the expected current value of the ref explicitly are\nstill experimental and their semantics may change as we gain experience\nwith this feature. \"--no-force-with-lease\" will cancel all the previous --force-with-lease on the\ncommand line. A general note on safety: supplying this option without an expected\nvalue, i.e. as --force-with-lease or --force-with-lease=<refname> interacts very badly with anything that implicitly runs git fetch on\nthe remote to be pushed to in the background, e.g. git fetch origin on your repository in a cronjob. The protection it offers over --force is ensuring that subsequent\nchanges your work wasn’t based on aren’t clobbered, but this is\ntrivially defeated if some background process is updating refs in the\nbackground. We don’t have anything except the remote tracking info to\ngo by as a heuristic for refs you’re expected to have seen & are\nwilling to clobber. If your editor or some other system is running git fetch in the\nbackground for you a way to mitigate this is to simply set up another\nremote: git remote add origin-push $(git config remote.origin.url)\ngit fetch origin-push Now when the background process runs git fetch origin the references\non origin-push won’t be updated, and thus commands like: git push --force-with-lease origin-push Will fail unless you manually run git fetch origin-push . This method\nis of course entirely defeated by something that runs git fetch\n--all , in that case you’d need to either disable it or do something\nmore tedious like: git fetch # update 'master' from remote\ngit tag base master # mark our base point\ngit rebase -i master # rewrite some commits\ngit push --force-with-lease=master:base master:master I.e. create a base tag for versions of the upstream code that you’ve\nseen and are willing to overwrite, then rewrite history, and finally\nforce push changes to master if the remote version is still at base , regardless of what your local remotes/origin/master has been\nupdated to in the background. Alternatively, specifying --force-if-includes as an ancillary option\nalong with --force-with-lease[=<refname>] (i.e., without saying what\nexact commit the ref on the remote side must be pointing at, or which\nrefs on the remote side are being protected) at the time of \"push\" will\nverify if updates from the remote-tracking refs that may have been\nimplicitly updated in the background are integrated locally before\nallowing a forced update." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Merge conflict marker encountered\nSourceTree Merge Conflict\nI have created a local \"Test\" branch in SourceTree for testing some new features and everything seemed to work fine. Then I merged the \"master\" branch into my local \"Test\" branch and unfortunately, pushed it. But since then by running \"ng serve\" I'm getting the following error: \n\n52 <<<<<<< HEAD\napp/app.module.ts:54:1 - error TS1185: Merge conflict marker encountered.\n\n54 =======\napp/app.module.ts:56:1 - error TS1185: Merge conflict marker encountered.\n\n56 >>>>>>> master\napp/example/example.module.ts:9:1 - error TS1185: Merge conflict marker encountered.\n\n9 <<<<<<< HEAD\n\nI have no idea what's going on here. Is there any way to solve this issue easily?" }, { "role": "assistant", "content": "For anyone coming from Google, I had a similar issue in React, but I was 100% confident that I had already resolved all conflicts.\nI fixed it by switching to another branch, then switching back to the original.\n\nIf this still does not fix the issue, remove the Node Modules cache with rm -Rf node_modules/.cache" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker gitcore-tutorial" }, { "role": "assistant", "content": "A Git core tutorial for developers" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Updates were rejected because the tip of your current branch is behind its remote counterpart\nOur workflow is such. We have a branch called dev which I can reach at origin/dev. When we do changes, we create a branch off dev:\ngit checkout -b FixForBug origin/dev\n\nNow I have a branch called FixForBug which is tracking (I think that's the right word) origin/dev. Thus, if I do a git pull it'll bring in new changes from origin/dev which is great. Now, when I'm finished with my fix, I push to a remote branch called the same thing.\nFirst I pull down any changes from origin/dev and do a rebase:\ngit pull --rebase\n\nThen I push the changes to a remote branch of the same name:\ngit push origin FixForBug\n\nNow, there's a branch on the remote server and I can create a pull request for that change to be approved and merged back in to the dev branch. I don't ever push anything to origin/dev myself. I'm guessing this is as pretty common workflow.\nThe first time I do a git push, it works fine and creates the remote branch. However, if I push a second time (let's say during code-review, someone points out a problem), I get the following error:\n\nerror: failed to push some refs to\n'https://github.mydomain.info/Product/product.git'\nhint: Updates were rejected because the tip of your current branch is behind its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again.\nSee the 'Note about fast-forwards' in 'git push --help' for details.\n\nHowever, if I do a git status it says I'm ahead of origin/dev by 1 commit (which makes sense) and if I follow the hint and run git pull, it says everything is up to date. I think this is because I'm pushing to a different branch than my upstream branch. I can fix this issue by running:\ngit push -f origin FixForBug\nIn that case, it'll push the changes to the remote branch, saying (forced update) and everything appears to be good on the remote branch.\nMy Questions:\nWhy is -f required in this scenario? Usually when you're forcing something, it's because you were doing something wrong or at least against standard practice. Am I ok doing this, or will it mess up something in the remote branch or create a hassle for whoever has to eventually merge my stuff into dev?" }, { "role": "assistant", "content": "The -f is actually required because of the rebase. Whenever you do a rebase you would need to do a force push because the remote branch cannot be fast-forwarded to your commit. You'd always want to make sure that you do a pull before pushing, but if you don't like to force push to master or dev for that matter, you can create a new branch to push to and then merge or make a PR." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --grep-reflog=<pattern>" }, { "role": "assistant", "content": "Limit the commits output to ones with reflog entries that\nmatch the specified pattern (regular expression). With\nmore than one --grep-reflog , commits whose reflog message\nmatches any of the given patterns are chosen. It is an\nerror to use this option unless --walk-reflogs is in use." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I ignore a directory in the root of my git repository, but include it further down in the tree?\nI need to use .gitignore to exclude a directory in the root of my repository. However, other directories with the same name exist deeper in the directory tree, and I need those to be included. It seems that when I put the name of the directory into .gitignore, it catches all of these directories, not just the one I need to ignore. I understand that .gitignore is actually not a list of files, but patterns. So how can I construct a pattern to ignore just a file in my root directory, but not files with the same name further down?" }, { "role": "assistant", "content": "Use a leading /\n /file.x\n\nThat will only match a top level file.x but not one lower down, in \"want/file.x\", say." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git am error: \"patch does not apply\"\nI am trying to move several commits from one project to the second, similar one, using git. \nSo I created a patch, containing 5 commits: \ngit format-patch 4af51 --stdout > changes.patch\n\nThen move the patch to second project's folder and wants to apply the patch: \ngit am changes.patch \n\n...but it gives me error: \nApplying: Fixed products ordering in order summary.\nerror: patch failed: index.php:17\nerror: index.php: patch does not apply\nPatch failed at 0001 Fixed products ordering in order summary.\nThe copy of the patch that failed is found in:\n c:/.../project2/.git/rebase-apply/patch\nWhen you have resolved this problem, run \"git am --continue\".\nIf you prefer to skip this patch, run \"git am --skip\" instead.\nTo restore the original branch and stop patching, run \"git am --abort\".\n\nSo I opened the index.php, but nothing changed there. I assume some >>>>>>> marks etc., like when resolving merge conflict, but no conflict was marked in the file. git status gave me also empty list of changed files (only changes.patch was there). So I run git am --continue, but another error appears: \nApplying: Fixed products ordering in order summary.\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.\nWhen you have resolved this problem, run \"git am --continue\".\nIf you prefer to skip this patch, run \"git am --skip\" instead.\nTo restore the original branch and stop patching, run \"git am --abort\". \n\nI am using Windows 7 and newest git version \"1.9.4.msysgit.1\" \nP.S. After few hours of googling, I found few solutions, but nothing works for me: \n\ngit am -3 changes.patch \n\ngives strange \"sha1 information\" error: \nApplying: Fixed products ordering in order summary.\nfatal: sha1 information is lacking or useless (index.php).\nRepository lacks necessary blobs to fall back on 3-way merge.\nCannot fall back to three-way merge.\nPatch failed at 0001 Fixed products ordering in order summary.\nThe copy of the patch that failed is found in:\n c:/.../project2/.git/rebase-apply/patch\nWhen you have resolved this problem, run \"git am --continue\".\nIf you prefer to skip this patch, run \"git am --skip\" instead.\nTo restore the original branch and stop patching, run \"git am --abort\". \n\n\ngit am changes.patch --ignore-whitespace --no-scissors --ignore-space-change\n\ngives first error as above: \"error: patch failed: index.php:17\", but no conflict marks in index.php was added." }, { "role": "assistant", "content": "What is a patch?\nA patch is little more (see below) than a series of instructions: \"add this here\", \"remove that there\", \"change this third thing to a fourth\". That's why Git tells you:\n\nThe copy of the patch that failed is found in:\nc:/.../project2/.git/rebase-apply/patch\n\n\nYou can open that patch in your favorite viewer or editor, open the files-to-be-changed in your favorite editor, and \"hand apply\" the patch, using what you know (and Git does not) to figure out how \"add this here\" is to be done when the files-to-be-changed now look little or nothing like what they did when they were changed earlier, with those changes delivered to you as a patch.\nA little more\nA three-way merge introduces that \"little more\" information than the plain \"series of instructions\": it tells you what the original version of the file was as well. If your repository has the original version, your Git software, working in your repository, can compare what you did to a file, to what the patch says to do to the file.\nAs you saw above, if you request the three-way merge, Git can't find the \"original version\" in the other repository, so it can't even attempt the three-way merge. As a result you get no conflict markers, and you must do the patch-application by hand.\n(There are cases where the \"a little more\" part is missing. The extra information is supplied by the Index: line in the patch, e.g.:\ndiff --git a/go.mod b/go.mod\nindex 1fefa60..38a3a41 100644\n\nThe second line may read, e.g.:\nindex 1fefa6021dcd205c1243e236d686595920d9621b..38a3a41434fda3a68ce3356092a89afca81eb614 100644\n\nin more-complete cases. Note the two hash IDs, separated by two dots. The one on the left is the one your Git software will use, to attempt to find a file in your own repository that has the given hash ID. Applying the supplied patch to that file, which must exist, must work and must produce a file whose hash ID will be that on the right, and doing all of this gives Git all the additional information required.)\nUsing --reject\nWhen you have to apply the patch by hand, it's still possible that Git can apply most of the patch for you automatically and leave only a few pieces to the entity with the ability to reason about the code (or whatever it is that needs patching). Adding --reject tells Git to do that, and leave the \"inapplicable\" parts of the patch in rejection files. If you use this option, you must still hand-apply each failing patch, and figure out what to do with the rejected portions.\nOnce you have made the required changes, you can git add the modified files and use git am --continue to tell Git to commit the changes and move on to the next patch.\nWhat if there's nothing to do?\nSince we don't have your code, I can't tell if this is the case, but sometimes, you wind up with one of the patches saying things that amount to, e.g., \"fix the spelling of a word on line 42\" when the spelling there was already fixed.\nIn this particular case, you, having looked at the patch and the current code, should say to yourself: \"aha, this patch should just be skipped entirely!\" That's when you use the other advice Git already printed:\n\nIf you prefer to skip this patch, run \"git am --skip\" instead.\n\n\nIf you run git am --skip, Git will skip over that patch, so that if there were five patches in the mailbox, it will end up adding just four commits, instead of five (or three instead of five if you skip twice, and so on)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub OAuth2 Token: How to restrict access to read a single private repo\nUse-case:\n\nCommand-line application (which is deployed to a 3rd party machine) needs to be able to download a tarball copy of a private repo that belongs to an organization via the GitHub API (v3)\nApplication should only be able to access this one private repo and no other repos with read-only permission.\n\nI have been able to accomplish (1) by creating an authorization for the application after registering a client_id/secret on my github account. However, it does not seem that the tokens returned by the authorization allow read-only access to the repo nor are they restricted to one repo (e.g. one could potentially use the token to modify this repo along with others belonging to the organization).\nIs it possible to restrict access via the proper scope? I don't see anything relevant in the API docs (https://developer.github.com/v3/oauth/#scopes)." }, { "role": "assistant", "content": "I don't believe you can restrict github OAuth tokens in that way. The github docs for OAuth say that\n\nWhile Git over HTTP with OAuth reduces friction for some types of applications, keep in mind that unlike deploy keys, OAuth tokens work for any repository for which the user has access.\n\nSo while you can limit the scope of the token in terms of the types of activities, you can't limit it to a subset of repos.\nDeploy keys can be restricted to a single repo, but allow write access.\nThe obvious tactic (as mentioned by Thomas) is to create a dummy account that represents the application. Given the goals of OAuth, this might be a better workflow in any case -- it'll let you easily change the permissions the app has as if it were in fact a user.\nGithub even mentions/endorses this strategy explicitly, calling them machine users." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database multipleAuthors" }, { "role": "assistant", "content": "(ERROR) Multiple author lines found in a commit." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to change git branch in Android Studio\nI have 2 branches in my gitlab project. Now I'm on the master (default) branch. I want to change it to another base, this is what I tried:\nWhen I go to VCS -> Git -> Branches, and click Checkout tag or revision I always get an error :\n\npathspec 'my branch' did not match any files known to git\n\nWhat should I do? All I want to do is to change the branch and do a pull request." }, { "role": "assistant", "content": "To checkout a different branch from within Android Studio:\nUnder VCS -> Git -> Branches you will see this screen\n\nunder Local branches you will see the local branches you can checkout. At the very bottom you see the currently checked out branch (in my case master). To checkout a different branch, select it and click Checkout.\n\nIn my example I only have one other local branch, named test. That is why it only shows that one.\nAfter checking out a different branch, this window will pop up in the bottom of the screen\n\n\nIn order to get your remote branches to show up in Android Studio, you first need to fetch them:\nVCS -> Git -> Fetch. After that, it will show up" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-add - Add file contents to the index --sparse" }, { "role": "assistant", "content": "Allow updating index entries outside of the sparse-checkout cone.\nNormally, git add refuses to update index entries whose paths do\nnot fit within the sparse-checkout cone, since those files might\nbe removed from the working tree without warning. See git-sparse-checkout for more details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Shell: don't fail git clone if folder already exists\nI'm writing an automated script.\nAt some point, I'm calling git clone <repo>. But there is a chance this operation is already done.\nHow can I call git clone --no-fail so that it ignores if repository exists?\nThanks" }, { "role": "assistant", "content": "The most stable solution would be to simply let it fail and print the error message. If you think that's too ugly for your scenario, you may redirect it to /dev/null:\nfolder=\"foo\"\nif ! git clone \"${url}\" \"${folder}\" 2>/dev/null && [ -d \"${folder}\" ] ; then\n echo \"Clone failed because the folder ${folder} exists\"\nfi\n\n\nOtherwise you can do something like this:\nif [ ! -d \"$FOLDER\" ] ; then\n git clone \"$URL\" \"$FOLDER\"\nfi\n\nbut that would be vulnerable to race conditions." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitattributes - Defining attributes per path" }, { "role": "assistant", "content": "SYNOPSIS $GIT_DIR/info/attributes, .gitattributes" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git: 'lfs' is not a git command unclear\nEvery time I enter in my command window\ngit lfs install\n\nthe message I get is git: 'lfs' is not a git command. See 'git --help'.\nI tried looking up for a solution, but none of the answers were clear. Can someone explain clear how to fix this?" }, { "role": "assistant", "content": "It looks like you haven't downloaded git-lfs on your machine, so git lfs install isn't a registered command by git.\nInstall git-lfs as outlined below:\n\n1. Pre-Requisites\n\ngit-lfs requires git version 1.8.3.1 or later. You can check the version you have by running git --version, and update if required.\nIf you are installing on macOS, make sure you have Homebrew installed.\n\n2. Download\nDownload git-lfs by following the steps based on your operating system.\nDebian / Ubuntu\n$ curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash\n$ sudo apt-get install git-lfs\n\nMacOS (Using Homebrew)\n$ brew update\n$ brew install git-lfs\n\nWindows\nDownload and run the latest windows installer.\n3. Install\nFinally, run git-lfs install to install git-lfs on your system.\nYou can always run git-lfs uninstall to uninstall.\n\nMore detailed information (such as for installation on other platforms) can be found on git-lfs's installation page." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: how to reverse-merge a commit?\nWith SVN it is easy to reverse-merge a commit, but how to do that with Git?" }, { "role": "assistant", "content": "To revert a merge commit, you need to use: git revert -m <parent number>. So for example, to revert the recent most merge commit using the parent with number 1 you would use:\ngit revert -m 1 HEAD\n\nTo revert a merge commit before the last commit, you would do:\ngit revert -m 1 HEAD^\n\nUse git show <merge commit SHA1> to see the parents, the numbering is the order they appear e.g. Merge: e4c54b3 4725ad2\ngit merge documentation:\nhttp://schacon.github.com/git/git-merge.html\ngit merge discussion (confusing but very detailed): \nhttp://schacon.github.com/git/howto/revert-a-faulty-merge.txt" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-instaweb - Instantly browse your working repository in gitweb -m --module-path" }, { "role": "assistant", "content": "The module path (only needed if httpd is Apache).\n(Default: /usr/lib/apache2/modules)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects %p" }, { "role": "assistant", "content": "abbreviated parent hashes" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab CI - How to skip job if cache exists\n\nI have a setup job in my CI which installs all npm packages and stores them in cache:\nsetup:\n stage: pre-build\n cache:\n untracked: true\n when: on_success\n key:\n files:\n - repo-hash\n prefix: workspace\n script:\n - yarn install --frozen-lockfile\n\nCurrently, if the repo-hash does not change between two pipelines, the job successfully downloads the existing cache, but it still runs yarn install --frozen-lockfile.\nHow to change this behaviour, so that if the cache exists, this job is skipped?" }, { "role": "assistant", "content": "Right now on an NPM-based Preact project, I'm using gitlab-ci.yml's only feature to run an install job if there was any change to package-lock.json (and to skip install if not). Then my build job picks up the node_modules cache from the install job:\ninstall:\n stage: setup # gitlab.com shared runners are slow; don't run unless there's a reason to install\n cache: # even a \"echo 'hello world'\" script would be about a 30s job, worse if queued\n key:\n files: [package-lock.json] # the key is a hash of package-lock; branches with it will use this cache :D\n paths: [node_modules] # we're not caching npm (ie `npm ci --prefer-offline --cache`) because it's slow\n policy: push # override the default behavior of wasting time downloading and unpacking node_modules\n script: [npm ci] # I believe in package-lock/npm ci's mission\n only:\n changes: [package-lock.json] # our forementioned reason to install\n refs:\n - master\n - develop\n - merge_requests\n\nbuild: # uses the default behavior, which runs even if install is skipped; but not if install failed\n stage: build\n cache:\n key:\n files: [package-lock.json]\n paths: [node_modules]\n policy: pull # override the default behavior of wasting time packing and uploading node_modules\n script:\n - npm run build\n artifacts:\n paths: [build]\n only:\n changes:\n - src/**/*\n - tsconfig.json\n - preact.config.js\n - package-lock.json\n refs:\n - master\n - develop\n - merge_requests\n\nFor Yarn you would simply replace any package-lock.json you see here with yarn.lock, and replace npm ci with yarn install --frozen-lockfile.\nPreviously, I was doing it all in the build job like this (similar to one of the other answers here):\nbuild:\n stage: build\n cache:\n key:\n files: [package-lock.json]\n paths: [node_modules]\n script:\n - test -d node_modules || npm ci\n - npm run build\n artifacts:\n paths: [build]\n only:\n changes:\n - src/**/*\n - tsconfig.json\n - preact.config.js\n - package-lock.json\n refs:\n - master\n - develop\n - merge_requests\n\nI changed to the more complicated approach because I thought I was also going to implement caching for npm cache, but I couldn't seem to get that to improve any actual install times -- things actually got worse. I stuck with it though simply because it allowed me to squeeze another 20 seconds out of the lockfile-wasn't-changed scenario. I find both approaches to be valid and effective. In my specific case, caching node_modules has cut about a minute and a half off of deployments." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is it possible to retrieve your source code from heroku?\nOnce you have uploaded your source code to Heroku, is it possible to download it from there if necessary such as in the case of a failure of your local disk? \nBecause of heroku's integration with git, I would assume this might be possible at least in theory." }, { "role": "assistant", "content": "Just go to https://dashboard.heroku.com/apps/YOUR_APP_NAME/deploy/heroku-git. \nInstall the Heroku Toolbelt\nDownload and install the Heroku Toolbelt\nIf you haven't already, log in to your Heroku account and follow the prompts to create a new SSH public key.\n$ heroku login\n\nClone the repository\nUse Git to clone YOUR_APP_NAME's source code to your local machine.\n$ heroku git:clone -a YOUR_APP_NAME\n$ cd YOUR_APP_NAME\n\nDeploy your changes\nMake some changes to the code you just cloned and deploy them to Heroku using Git.\n$ git add .\n$ git commit -am \"make it better\"\n$ git push heroku master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-tag" }, { "role": "assistant", "content": "Create, list, delete or verify a tag object signed with GPG" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to execute a command right after a fetch or pull command in git?\nI cloned the GHC (Glasgow Haskell Compiler) repository. In order to build the compiler, you need several libraries, all of them are available as git repositories too. In order to ease ones live, the GHC hackers included a script sync-all that, when executed, updates all the dependent repositories.\nNow to my question: How can I make git execute ./sync-all pull after I did a git pull automatically? I heard something about using hooks, but I don't really know, what I have to do." }, { "role": "assistant", "content": "If you need to execute a script after a git pull on the client side (your machine), then a there is no reliable solution.\nThe post-merge client-side hook (mentioned here) won't be triggered by every pull (for instance, not in a pull rebase, not in case of fast-forward merge)\nSo an alias wrapping both commands remains a possible workaround.\n\nOriginal answer (2011)\nIf you need that on the server side, where you would checkout the bare repo and pull from a working tree (on the server) after each push to a bare repo (on the server):\nA post-receive or post-update hook is generally used for this kind of task, executed after each push.\nThe difference between the post-receive and post-update hooks is in the arguments: a post-receive will get both the old and the new values of all the refs in addition to their names.\nThe missing piece is: where that hook executes itself?\nThe blog post \"Missing git hooks documentation\" from (a great) SO contributor Mark Longair sheds some light on this:\n\nthe current working directory will be the git directory. \n\nSo, if this is a bare repository called “/src/git/test.git/”, that will be the current working directory \n – if this is a non-bare repository and the top level of the working tree is “/home/mark/test/” then the current working directory will be “/home/mark/test/.git/”\n\nChris Johnsen details in his SO answer: \"If –-git-dir or GIT_DIR are specified but none of -–work-tree, GIT_WORK_TREE and core.worktree is specified, the current working directory is regarded as the top directory of your working tree.\"\nIn other words, your working tree will also be the current directory (the “.git” directory), which almost certainly isn’t what you want.\n\nMake sure your hook/post-receive script, once created and made executable, sets the GIT_WORK_TREE at the right path, in order for your ./sync-all pull to be executed in the right directory (i.e. not \"xxx.git\" one)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to manage multiple maven projects in gitlab\n\nWe have multiple (about 75) maven projects, which we have pushed to Gitlab individually in following manner:\nGROUP1 - 4 projects\nGROUP2 - 2 projects\nGROUP3 - 10 Projects\n.\n.\nGROUP10 - 6 Projects\n\nWe now want to implement CI tool like Jenkins. But creating and managing all 75 projects in jenkins individuality is very time consuming. So that we have 2 methods in mind. \n\ngit submodules: In this case we might get many complications, as individual developer is forking the multiple project and works in his forked repo.\nSingle git Project: In this case if every developer will fork the main repo, then disk space required is much and the performance will also get degrade. But it will be better than git submodules to manage, as build can be simplified with maven multiple module way. \n\nSo according to you, is there any other approach we can think about, or can we go with Single git project?" }, { "role": "assistant", "content": "I also manage over 50 Gitlab Maven Projects and use Gitlab CI to build each project and deploy the artifact to our central artifact repository. Gitlab CI does not support re-building consumers of Maven artifacts when a downstream artifact changes. They have a concept of \"Triggering\" but this simply does not work well when you have so many projects.\nI usually push changes in one at a time and wait for the previous commit to fully build and publish to the central repository before pushing in the next commit.\nThis was very time consuming so as an alternative we did build an internal tool to solve this. I made the tool public a few days ago and it's in the Alpha stage, but you are free to try it if you'd like.\nIt's called Gitlab Pipes. The documentation has a quick start to get you started quickly." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to apply unmerged upstream pull requests from other forks into my fork?\nA project on GitHub that I have a fork of has a new pull requests that I want to pull into my fork that the author has not pulled in yet.\nIs there a simple way to apply pull request from other forks into my fork? Is there something else here that I am missing?" }, { "role": "assistant", "content": "Update: Via Webpage\nYou can also do this via the github webpage.\nI assume, you should have already a fork (MyFork) of the common repo (BaseRepo) which has the pending pull request from a fork (OtherFork) you are interested in.\n\nNavigate to the fork (OtherFork) which has initiated the pull request which you like to get into your fork (MyFork)\nGo to the pull requests page of OtherFork\nClick new pull request\nThe pending pull request(s) should be offered. Remember to select proper OtherFork branch too. Select on the left side as the base fork your fork (MyFork) (IMPORTANT).\nNow the option of View pull request should change to Create pull request. Click this.\n\nNow you should have a pending pull request in your fork (MyFork), which you can simply accept." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git + LaTeX workflow\nI'm writing a very long document in LaTeX. I have my work computer and my laptop, and I work on them both. I need to keep all the files synchronized between the two computers, and also would like to keep a revision history. I chose git as my DVCS, and I'm hosting my repository on my server. I'm also using Kile + Okular to do the editing. Kile doesn't have an integrated git plugin. I'm also not collaborating with anyone on this text. I'm also thinking about putting another private repository on codaset, if my server for some reason is not accessible.\nWhat is the recommended workflow practice in this case? How can branching be fitted in this working scheme? Is there a way to compare two versions of the same file? What about using a stash?" }, { "role": "assistant", "content": "Changes to your LaTeX workflow:\nThe first step in efficiently managing a Git+LaTeX workflow is to make a few changes to your LaTeX habits.\n\nFor starters, write each sentence on a separate line. Git was written to version control source code, where each line is distinct and has a specific purpose. When you write documents in LaTeX, you often think in terms of paragraphs and write it as a free flowing document. However, in git, changes to a single word in a paragraph get recorded as a change to the entire paragraph.\nOne solution is to use git diff --color-words (see my answer to a similar question How to use Mercurial for version control of text documents? where I show an example). However, I must emphasize that splitting into separate lines is a much better option (I only mentioned it in passing in that answer), as I've found it to result in very minimal merge conflicts.\n\nIf you need to look at the code diff, use Git's native diff. To see the difference between two arbitrary commits (versions), you can do so with the shas of each of the commits. See the documentation for more details and also Showing which files have changed between two revisions.\nOn the other hand, if you need to look at the diff of your formatted output, use latexdiff which is an excellent utility (written in perl) that takes two latex files and produces a neat diffed output in pdf like this (image source):\n\nYou can combine git and latexdiff (plus latexpand if needed) in a single command using git-latexdiff (e.g. git latexdiff HEAD^ to view the diff between your worktree and the last-but-one commit).\n\nIf you're writing a long document in LaTeX, I'd suggest splitting different chapters into their own files and call them in the main file using the \\include{file} command. This way it is easier for you to edit a localized part of your work, and it is also easier for version control, as you know what changes have been made to each chapter, instead of having to figure it out from the logs of one big file.\n\n\nUsing Git efficiently:\n\nUse branches!. There is perhaps no better advice I can give. I've found branches to be very helpful to keep track of \"different ideas\" for the text or for \"different states\" of the work. The master branch should be your main body of work, in its most current \"ready to publish\" state i.e., if of all the branches, if there is one that you are willing to put your name on it, it should be the master branch.\nBranches are also extremely helpful if you are a graduate student. As any grad student will attest, the advisor is bound to have numerous corrections, most of which you don't agree with. Yet, you might be expected to atleast change them for the time being, even if they are reverted later after discussions. So in such cases, you could create a new branch advisor and make changes to their liking, at the same time maintaining your own development branch. You can then merge the two and cherry pick what you need.\n\nI would also suggest splitting each section into a different branch and focus only the section corresponding to the branch that you're on. Spawn a branch when you create a new section or dummy sections when you make your initial commit (your choice, really). Resist the urge to edit a different section (say, 3) when you're not on its branch. If you need to edit, commit this one and then checkout the other before branching. I find this very helpful because it keeps the history of the section in its own branch and also tells you at a glance (from the tree) how old some section is. Perhaps you've added material to section 3 that requires tweaking to section 5… Of course, these will, in all probability, be observed during a careful reading, but I find it helpful to see this at a glance so that I can shift gears if I'm getting bored of a section.\nHere's an example of my branches and merges from a recent paper (I use SourceTree on OS X and Git from the command line on Linux). You'll probably notice that I'm not the world's most frequent committer nor do I leave useful comments all the time, but that's no reason for you not to follow those good habits. The main takeaway message is that working in branches is helpful. My thoughts, ideas and development proceeds non-linearly, but I can keep track of them via branches and merge them when I'm satisfied (I also had other branches that led nowhere that were later deleted). I can also \"tag\" commits if they mean something (e.g., initial submissions to journals/revised submissions/etc.). Here, I've tagged it \"version 1\", which is where the draft is as of now. The tree represents a week's worth of work.\n\n\nAnother useful thing to do would be to make document wide changes (such as changing \\alpha to \\beta everywhere) commits on their own. That way, you can revert changes without having to rollback something else along with it (there are ways you can do this using git, but hey, if your can avoid it, then why not?). The same goes for additions to the preamble.\n\nUse a remote repo and push your changes upstream regularly. With free service providers like GitHub and Bitbucket (both allow you to create private repos with a free account), there is no reason to not be using these if you're working with Git/Mercurial. At the very least, consider it as a secondary backup (I hope you have a primary one!) for your LaTeX files and a service that allows you to continue editing from where you left on a different machine." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options log.excludeDecoration" }, { "role": "assistant", "content": "Exclude the specified patterns from the log decorations. This is\nsimilar to the --decorate-refs-exclude command-line option, but\nthe config option can be overridden by the --decorate-refs option." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Undo a Git merge that hasn't been pushed yet\nI accidentally ran git merge some_other_branch on my local master branch. I haven't pushed the changes to origin master. How do I undo the merge?\n\nAfter merging, git status says:\n# On branch master\n# Your branch is ahead of 'origin/master' by 5 commits.\n\nHow do I undo all these commits?" }, { "role": "assistant", "content": "With git reflog check which commit is one prior the merge (git reflog will be a better option than git log). Then you can reset it using:\ngit reset --hard commit_sha\n\nThere's also another way:\ngit reset --hard HEAD~1\n\nIt will get you back 1 commit.\nBe aware that any modified and uncommitted/unstashed files will be reset to their unmodified state. To keep them either stash changes away or see --merge option below. \n\nAs @Velmont suggested below in his answer, in this direct case using:\ngit reset --hard ORIG_HEAD\n\nmight yield better results, as it should preserve your changes. ORIG_HEAD will point to a commit directly before merge has occurred, so you don't have to hunt for it yourself.\n\nA further tip is to use the --merge switch instead of --hard since it doesn't reset files unnecessarily:\ngit reset --merge ORIG_HEAD\n\n\n--merge\nResets the index and updates the files in the working tree that are different between <commit> and HEAD, but keeps those which are different between the index and working tree (i.e. which have changes which have not been added)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-grep - Print lines matching a pattern --no-color" }, { "role": "assistant", "content": "Turn off match highlighting, even when the configuration file\ngives the default to color output.\nSame as --color=never ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git diff says subproject is dirty\nI have just run a git diff, and I am getting the following output for all of my approx 10 submodules \ndiff --git a/.vim/bundle/bufexplorer b/.vim/bundle/bufexplorer\n--- a/.vim/bundle/bufexplorer\n+++ b/.vim/bundle/bufexplorer\n@@ -1 +1 @@\n-Subproject commit 8c75e65b647238febd0257658b150f717a136359\n+Subproject commit 8c75e65b647238febd0257658b150f717a136359-dirty\n\nWhat does this mean? How do I fix it?" }, { "role": "assistant", "content": "Update Jan. 2021, ten years later:\n\"git diff\"(man) showed a submodule working tree with untracked cruft as Submodule commit <objectname>-dirty, but a natural expectation is that the \"-dirty\" indicator would align with \"git describe --dirty\"(man), which does not consider having untracked files in the working tree as source of dirtiness.\nThe inconsistency has been fixed with Git 2.31 (Q1 2021).\nSee commit 8ef9312 (10 Nov 2020) by Sangeeta Jain (sangu09).\n(Merged by Junio C Hamano -- gitster -- in commit 0806279, 25 Jan 2021)\n\ndiff: do not show submodule with untracked files as \"-dirty\"\nSigned-off-by: Sangeeta Jain\n\n\nGit diff reports a submodule directory as -dirty even when there are only untracked files in the submodule directory.\nThis is inconsistent with what git describe --dirty(man) says when run in the submodule directory in that state.\nMake --ignore-submodules=untracked the default for git diff(man) when there is no configuration variable or command line option, so that the command would not give '-dirty' suffix to a submodule whose working tree has untracked files, to make it consistent with git describe --dirty that is run in the submodule working tree.\nAnd also make --ignore-submodules=none the default for git status(man) so that the user doesn't end up deleting a submodule that has uncommitted (untracked) files.\n\ngit config now includes in its man page:\n\nBy default this is set to untracked so that any untracked\nsubmodules are ignored.\n\n\nOriginal answer (2011)\nAs mentioned in Mark Longair's blog post Git Submodules Explained,\n\nVersions 1.7.0 and later of git contain an annoying change in the behavior of git submodule.\nSubmodules are now regarded as dirty if they have any modified files or untracked files, whereas previously it would only be the case if HEAD in the submodule pointed to the wrong commit.\n\n\nThe meaning of the plus sign (+) in the output of git submodule has changed, and the first time that you come across this it takes a little while to figure out what’s going wrong, for example by looking through changelogs or using git bisect on git.git to find the change. It would have been much kinder to users to introduce a different symbol for “at the specified version, but dirty”.\n\nYou can fix it by:\n\neither committing or undoing the changes/evolutions within each of your submodules, before going back to the parent repo (where the diff shouldn't report \"dirty\" files anymore). To undo all changes to your submodule just cd into the root directory of your submodule and do git checkout .\n\ndotnetCarpenter comments that you can do a: git submodule foreach --recursive git checkout .\n\nor add --ignore-submodules to your git diff, to temporarily ignore those \"dirty\" submodules.\n\nNew in Git version 1.7.2\nAs Noam comments below, this question mentions that, since git version 1.7.2, you can ignore the dirty submodules with:\ngit status --ignore-submodules=dirty" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Show git diff on file in staging area [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do I show the changes which have been staged?\n\n (16 answers)\n \n\nClosed 4 years ago.\n\n\n\nIs there a way I can see the changes that were made to a file after I have done git add file?\nThat is, when I do: \ngit add file\ngit diff file\n\nno diff is shown. I guess there's a way to see the differences since the last commit but I don't know what that is." }, { "role": "assistant", "content": "You can show changes that have been staged with the --cached flag:\n$ git diff --cached\n\nIn more recent versions of git, you can also use the --staged flag (--staged is a synonym for --cached):\n$ git diff --staged" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Using Git, show all commits that are in one branch, but not the other(s)\nI have an old branch, which I would like to delete. However, before doing so, I want to check that all commits made to this branch were at some point merged into some other branch. Thus, I'd like to see all commits made to my current branch which have not been applied to any other branch [or, if this is not possible without some scripting, how does one see all commits in one branch which have not been applied to another given branch?]." }, { "role": "assistant", "content": "To see a list of which commits are on one branch but not another, use git log:\ngit log --no-merges oldbranch ^newbranch\n\n...that is, show commit logs for all commits on oldbranch that are not on newbranch. You can list multiple branches to include and exclude, e.g.\ngit log --no-merges oldbranch1 oldbranch2 ^newbranch1 ^newbranch2\n\nNote: on Windows command prompt (not Powershell) ^ is an escape key, so it needs to be escaped with another ^:\ngit log --no-merges oldbranch ^^newbranch" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-remote - Manage set of tracked repositories" }, { "role": "assistant", "content": "EXIT STATUS On success, the exit status is 0 . When subcommands such as add , rename , and remove can’t find the\nremote in question, the exit status is 2 . When the remote already\nexists, the exit status is 3 . On any other error, the exit status may be any other non-zero value." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to resolve \"git pull,fatal: unable to access 'https://github.com...\\': Empty reply from server\"\nIt's failed when I used Git command \"git pull\" to update my repository, messages as below:\nfatal: unable to access '...': Empty reply from server. \nAnd the I tried to use the GitHub App, but alert this: \nCloning into 'renren_mobile'...\nwarning: templates not found /Applications/GitHub.app/Contents/Resources/git/templates\n2014-11-23 13:58:57.975 GitHub for Mac Login[659:11891] AskPass with arguments: (\n \"/Applications/GitHub.app/Contents/MacOS/GitHub for Mac Login\",\n \"Username for 'https://github.com': \"\n)\n2014-11-23 13:58:58.032 GitHub for Mac Login[660:11915] AskPass with arguments: (\n \"/Applications/GitHub.app/Contents/MacOS/GitHub for Mac Login\",\n \"Password for '': \"\n)\nfatal: unable to access '...': Empty reply from server\n (128)" }, { "role": "assistant", "content": "I was stuck in this problem until I noticed that I was not logged into my VPN.\n\nIf you have configured your proxy for a VPN, you need to login to your VPN to use the proxy.\n\nto use it outside the VPN use the unset command:\ngit config --global --unset http.proxy\n\n\n\nAnd remember to set the proxy when within the VPN." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options pushNonFFMatching" }, { "role": "assistant", "content": "Shown when the user ran git-push and pushed\n\"matching refs\" explicitly (i.e. used : , or\nspecified a refspec that isn’t the current branch) and\nit resulted in a non-fast-forward error." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-reset - Reset current HEAD to the specified state git reset [<mode>] [<commit>]" }, { "role": "assistant", "content": "This form resets the current branch head to <commit> and\npossibly updates the index (resetting it to the tree of <commit> ) and\nthe working tree depending on <mode> . Before the operation, ORIG_HEAD is set to the tip of the current branch. If <mode> is omitted,\ndefaults to --mixed . The <mode> must be one of the following: --soft Does not touch the index file or the working tree at all (but\nresets the head to <commit> , just like all modes do). This leaves\nall your changed files \"Changes to be committed\", as git status would put it. --mixed Resets the index but not the working tree (i.e., the changed files\nare preserved but not marked for commit) and reports what has not\nbeen updated. This is the default action. If -N is specified, removed paths are marked as intent-to-add (see git-add ). --hard Resets the index and working tree. Any changes to tracked files in the\nworking tree since <commit> are discarded. Any untracked files or\ndirectories in the way of writing any tracked files are simply deleted. --merge Resets the index and updates the files in the working tree that are\ndifferent between <commit> and HEAD , but keeps those which are\ndifferent between the index and working tree (i.e. which have changes\nwhich have not been added).\nIf a file that is different between <commit> and the index has\nunstaged changes, reset is aborted. In other words, --merge does something like a git read-tree -u -m <commit> ,\nbut carries forward unmerged index entries. --keep Resets index entries and updates files in the working tree that are\ndifferent between <commit> and HEAD .\nIf a file that is different between <commit> and HEAD has local\nchanges, reset is aborted. --[no-]recurse-submodules When the working tree is updated, using --recurse-submodules will\nalso recursively reset the working tree of all active submodules\naccording to the commit recorded in the superproject, also setting\nthe submodules' HEAD to be detached at that commit." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to add a single file to GIT LFS?\nHow can I add just a single file to GIT LFS?\nMost examples show adding a pattern that specifies which files to add to LFS. However, I wish to add single file. If, for example, I do\ngit lfs track \"file.bin\"\n\nthis will track all files named file.bin regardless of what directory they are in.\nI considered adding an exclusion filter (! pattern) to .gitattributes so exclude all directories but that is not supported.\nThe best I've done so far is to track the file pattern for the file I want to add, add the file and then remove the tracking of that file pattern. This is a little fiddly. Is there a better way?\nI want to express the file pattern $ROOT_OF_GIT_REPO/file.bin but am lacking a way to express the $ROOT_OF_GIT_REPO part." }, { "role": "assistant", "content": "Use:\ngit lfs track --filename [file path]\nSource: git lfs track --help\n\n--filename\nTreat the arguments as literal filenames, not as patterns. Any special glob\ncharacters in the filename will be escaped when writing the .gitattributes\nfile.\n\nThis option has been available since v2.9.0 of the LFS extension (pull request). You can check your local version: git lfs version." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-stash - Stash the changes in a dirty working directory away branch <branchname> [<stash>]" }, { "role": "assistant", "content": "Creates and checks out a new branch named <branchname> starting from\nthe commit at which the <stash> was originally created, applies the\nchanges recorded in <stash> to the new working tree and index.\nIf that succeeds, and <stash> is a reference of the form stash@{<revision>} , it then drops the <stash> . This is useful if the branch on which you ran git stash push has\nchanged enough that git stash apply fails due to conflicts. Since\nthe stash entry is applied on top of the commit that was HEAD at the\ntime git stash was run, it restores the originally stashed state\nwith no conflicts." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Github not update `raw` after commit\nUpdated: Seem it has about 5 minutes to update raw. I will close my question at here.\nI have a problem with Github.\nI want to get the file as raw format.\nI add new commit and my file is updated.\nLook like this:\n\nI add JUST keyword in variable tech.\n\nWhen I click raw. It keeps the previous version.\nLook like this:\n\nHave any method to get raw version of the file was commit." }, { "role": "assistant", "content": "GitHub serves \"raw\" pages with Cache-Control: max-age=300. That's specified in seconds, meaning the pages are intended to be cached for 5 minutes.\nYou can see this if you open the Developer Tools in your web browser of choice before clicking the \"Raw\" button on GitHub." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git produces Gtk-WARNING: cannot open display\n\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." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-clone - Clone a repository into a new directory --mirror" }, { "role": "assistant", "content": "Set up a mirror of the source repository. This implies --bare .\nCompared to --bare , --mirror not only maps local branches of the\nsource to local branches of the target, it maps all refs (including\nremote-tracking branches, notes etc.) and sets up a refspec configuration such\nthat all these refs are overwritten by a git remote update in the\ntarget repository." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why is .gitignore not ignoring my files?\nSee the image below. My .gitignore file should be ignoring all files in src/dist, but isn't." }, { "role": "assistant", "content": ".gitignore only ignores files that are not part of the repository yet. If you already git added some files, their changes will still be tracked.\nTo remove those files from your repository (but not from your file system) use git rm --cached on them." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --simplify-by-decoration" }, { "role": "assistant", "content": "Commits that are referred by some branch or tag are selected." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --src-prefix=<prefix>" }, { "role": "assistant", "content": "Show the given source prefix instead of \"a/\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is it possible to fork a public GitHub repo into an enterprise repository?\nThere exist a public repo for Quick framework here. I'd like to be able to fork this into a private enterprise GitHub repository. Forking would allow all the branches to remain. \nthe alternative would be to clone the repo and push up only a single branch to the enterprise but then I lose on not having all the branches from the source/original. \nupdate:\nI ended up pushing all my branches into the enterprise git. \nif you just do a git push yourRemoteName myNewBranch then it will push the code into that branch on the enterprise git while creating that branch in enterprise GitHub." }, { "role": "assistant", "content": "It's not possible, because your GitHub Enterprise (GHE) installation is separate from the public one, so there's no way for the two systems to track each other's branch relationships.\nThe best you can do is exactly as you describe: Clone the repo, then push it to your GHE installation, and yes, you will then lose the branching relationships across repos.\nThe other option would be to keep a fork on the public GitHub (GH) repo--possibly keeping it in sync (manually, or with a cronjob) with your GHE repo. Then you'll have two instances of your repo, and the public one would retain branch relationships with the original repo.\nDepending on why you need to put this on GHE, it may or may not work. If you're making private contributions, it clearly won't work--as your private contributions would no longer be private. If you want it on GHE due to some corporate policy that all open source projects used internally are kept on the GHE, or something similar, then it would work, with the added administrative overhead of keeping the repo in sync two places." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to clone a private git repository into a kubernetes pod using ssh keys in secrets?\n\nI am trying to clone a private git repository(gitLab) into a kubernetes pod, using SSH keys for authentication. I have stored my keys in a secret. Here is the yaml file for the job that does the desired task.\nHeres the same question, but doesnt give the exact solution : \nClone a secure git repo in Kubernetes pod\nLogs of the init container after execution:\nfetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz\nfetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz\nv3.7.1-66-gfc22ab4fd3 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]\nv3.7.1-55-g7d5f104fa7 [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]\nOK: 9064 distinct packages available\nOK: 23 MiB in 23 packages\nCloning into '/tmp'...\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 yaml file which works perfectly for public repo:\napiVersion: batch/v1\nkind: Job\nmetadata:\n name: nest-build-kaniko\n labels:\n app: nest-kaniko-example\nspec:\n template:\n spec:\n containers:\n -\n image: 'gcr.io/kaniko-project/executor:latest'\n name: kaniko\n args: [\"--dockerfile=/workspace/Dockerfile\",\n \"--context=/workspace/\",\n \"--destination=aws.dest.cred\"]\n volumeMounts:\n -\n mountPath: /workspace\n name: source\n -\n name: aws-secret\n mountPath: /root/.aws/\n -\n name: docker-config\n mountPath: /kaniko/.docker/\n initContainers:\n -\n name: download\n image: alpine:3.7\n command: [\"/bin/sh\",\"-c\"]\n args: ['apk add --no-cache git && git clone https://github.com/username/repo.git /tmp/']\n volumeMounts:\n -\n mountPath: /tmp\n name: source\n restartPolicy: Never\n volumes:\n -\n emptyDir: {}\n name: source\n -\n name: aws-secret\n secret:\n secretName: aws-secret\n -\n name: docker-config\n configMap:\n name: docker-config\n\nThe yaml file after using git-sync for cloning private repository:\napiVersion: batch/v1\nkind: Job\nmetadata:\n name: nest-build-kaniko\n labels:\n app: nest-kaniko-example\nspec:\n template:\n spec:\n containers:\n -\n image: 'gcr.io/kaniko-project/executor:latest'\n name: kaniko\n args: [\"--dockerfile=/workspace/Dockerfile\",\n \"--context=/workspace/\",\n \"--destination=aws.dest.cred\"]\n volumeMounts:\n -\n mountPath: /workspace\n name: source\n -\n name: aws-secret\n mountPath: /root/.aws/\n -\n name: docker-config\n mountPath: /kaniko/.docker/\n initContainers:\n -\n name: git-sync\n image: gcr.io/google_containers/git-sync-amd64:v2.0.4\n volumeMounts:\n -\n mountPath: /git/tmp\n name: source\n -\n name: git-secret\n mountPath: \"/etc/git-secret\"\n env:\n - name: GIT_SYNC_REPO\n value: \"[email protected]:username/repo.git\"\n - name: GIT_SYNC_SSH\n value: \"true\"\n - name: GIT_SYNC_DEST\n value: \"/tmp\"\n - name: GIT_SYNC_ONE_TIME\n value: \"true\"\n securityContext:\n runAsUser: 0\n restartPolicy: Never\n volumes:\n -\n emptyDir: {}\n name: source\n -\n name: aws-secret\n secret:\n secretName: aws-secret\n -\n name: git-secret\n secret:\n secretName: git-creds\n defaultMode: 256\n -\n name: docker-config\n configMap:\n name: docker-config" }, { "role": "assistant", "content": "You can use git-sync\napiVersion: apps/v1\nkind: StatefulSet\nmetadata:\n name: git-sync-test\nspec:\n selector:\n matchLabels:\n app: git-sync-test\n serviceName: \"git-sync-test\"\n replicas: 1\n template:\n metadata:\n labels:\n app: git-sync-test\n spec:\n containers:\n - name: git-sync-test\n image: <your-main-image>\n volumeMounts:\n - name: service\n mountPath: /var/magic\n initContainers:\n - name: git-sync\n image: k8s.gcr.io/git-sync-amd64:v2.0.6\n imagePullPolicy: Always\n volumeMounts:\n - name: service\n mountPath: /magic\n - name: git-secret\n mountPath: /etc/git-secret\n env:\n - name: GIT_SYNC_REPO\n value: <repo-path-you-want-to-clone>\n - name: GIT_SYNC_BRANCH\n value: <repo-branch>\n - name: GIT_SYNC_ROOT\n value: /magic\n - name: GIT_SYNC_DEST\n value: <path-where-you-want-to-clone>\n - name: GIT_SYNC_PERMISSIONS\n value: \"0777\"\n - name: GIT_SYNC_ONE_TIME\n value: \"true\"\n - name: GIT_SYNC_SSH\n value: \"true\"\n securityContext:\n runAsUser: 0\n volumes:\n - name: service\n emptyDir: {}\n - name: git-secret\n secret:\n defaultMode: 256\n secretName: git-creds # your-ssh-key\n\nFor more details check this link." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Azure DevOps - compare two commits right in the web UI?\nThis is surely something simple I'm overlooking. In the Azure DevOps web interface (not integrated as part of an IDE), I see how to compare any commit to its parent, but I can't figure out how to compare it to an arbitrary commit.\nie, I'm looking for the equivalent of GitHub's compare/hash1..hash2 functionality.\nThe appeal is that the web UI is a view/tool common to everyone, and presumably I could get a link to the specific diff I'm interested in and share it with colleagues.\nThe web UI suggests it might be possible because when viewing the changes for a particular commit it has text Diff to Parent 1 - <my commit hash> but I haven't figured out how to change Parent 1." }, { "role": "assistant", "content": "If you go to the list of branches for a repository, you can click on ... (More Actions) on one of the branches and choose Compare branches\nThis will take you to a URL in the form:\nhttps://dev.azure.com/{organisation}/{project}/_git/{repository}/branches?baseVersion=GB{baseBranch}&targetVersion=GB{targetBranch}&_a=files\nYou can then change the baseVersion and targetVersion parameters in the query string. These can take the following forms, and can be mixed and matched:\n\nGB{branchName}\nGC{commitHash}\nGT{tagName}\n\nJust in case that link gets broken, clicking \"View Merge Changes\" on a pull request takes you to the same page but with a slightly different URL https://dev.azure.com/{organisation}/{project}/_git/{repository}/branchCompare?baseVersion=GC{baseCommit}&targetVersion=GC{targetCommit}&_a=files\nI'm not sure if there's a nicer way of comparing commits from the UI, as it only shows branches and tags, but if you do it this way you don't have to temporarily tag commits or create temporary branches just to get a diff that shows all of the changed files." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "github: Adding commits to existing pull request\nI opened a pull request to rails repo on github by using Fork & Edit this file file button.\nNow, \nAfter getting feedback on my PR, I wanted to add some more commits. so here is what I ended by doing\n$ git clone [email protected]:gaurish/rails.git #my forked repo\n$ git rebase -i 785a2e5 #commit hash of my commit using which PR was opened\n$ git checkout patch-3 #branch name I had to send my commits under to be shown in that PR\n$ git commit -am \"Changes done as per feedback\"\n$ git push origin patch-3\n\nThis worked fine but seems quite a complex workflow. Maybe I am wrong something wrong here? \nmy question is:\nAm I doing this the correct way? if not, then what is the proper way to do this?" }, { "role": "assistant", "content": "Since you're using GitHub's tools and just changing one file, you could also browse to the file on GitHub, select the proper branch from the upper left corner under the \"tree:\" dropdown (patch-3 in your case), and now choose \"Edit this file\". Now your changes will be committed to this branch and will show up in your pull request" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I rename a repository on GitHub?\nI wanted to rename one of my repositories on GitHub, but I got scared when a big red warning said:\n\n\nWe will not set up any redirects from the old location\nYou will need to update your local repositories to point to the new location\nRenaming may take a few minutes to complete\n\n\nDoes anyone have step-by-step instructions on how to accomplish #1 and #2 manually? Or what do I have to do locally?" }, { "role": "assistant", "content": "If you are the only person working on the project, it's not a big problem, because you only have to do #2.\nLet's say your username is someuser and your project is called someproject.\nThen your project's URL will be1\n[email protected]:someuser/someproject.git\n\nIf you rename your project, it will change the someproject part of the URL, e.g.\n[email protected]:someuser/newprojectname.git\n\n(see footnote if your URL does not look like this).\nYour working copy of Git uses this URL when you do a push or pull.\nSo after you rename your project, you will have to tell your working copy the new URL.\nYou can do that in two steps:\nFirstly, cd to your local Git directory, and find out what remote name(s) refer to that URL:\n$ git remote -v\norigin [email protected]:someuser/someproject.git\n\nThen, set the new URL\n$ git remote set-url origin [email protected]:someuser/newprojectname.git\n\nOr in older versions of Git, you might need:\n$ git remote rm origin\n$ git remote add origin [email protected]:someuser/newprojectname.git\n\n(origin is the most common remote name, but it might be called something else.)\nBut if there are lots of people who are working on your project, they will all need to do the above steps, and maybe you don't even know how to contact them all to tell them. That's what #1 is about.\nFurther reading:\n\nGitHub - working with remotes\nGit Reference - remotes\nGit Book - Distributed Workflows\n\nFootnotes:\n1 The exact format of your URL depends on which protocol you are using, e.g.\n\nSSH = [email protected]:someuser/someproject.git\nHTTPS = https://[email protected]/someuser/someproject.git\nGIT = git://github.com/someuser/someproject.git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to rename main branch to master on a Github repository\n\nI'd like to create a github repository and rename the main branch to master.\nIf I create a new repository on github and do\ngit init\ngit add README.md\ngit commit -m \"first commit\"\ngit branch -M master\n\nI get\nerror: refname refs/heads/master not found\nfatal: Branch rename failed\n\nso I seem to somehow not understand git well enough. What's the issue here?\n\nI must have gotten confused when I was playing around with the above. The following happens:\ngit init create the repository\ngit add README.md adds the file\ngit commit -m \"first commit\" adds the file to the master branch since that still default for git\nso I never have to rename it in the first place. Now Github uses the default main, which can be changed in settings -> repositories on github.com" }, { "role": "assistant", "content": "Using the -m option (move/rename) instead of -M with the name of the branch you're renaming from, here main, will work. Then you can push your renamed branch and maintain your reflog as well.\ngit branch -m main master\ngit push -u origin master\n\nI also wrote a blog post with more details which can in case the repo was cloned by someone else before renaming the branch. You can check it out here." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options grep.fullName" }, { "role": "assistant", "content": "If set to true, enable --full-name option by default." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-gc - Cleanup unnecessary files and optimize the local repository gc.maxCruftSize" }, { "role": "assistant", "content": "Limit the size of new cruft packs when repacking. When\nspecified in addition to --max-cruft-size , the command line\noption takes priority. See the --max-cruft-size option of git-repack ." } ]
[ { "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 objecttype" }, { "role": "assistant", "content": "The object type of the file which is recorded in the index." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options man.viewer" }, { "role": "assistant", "content": "Specify the programs that may be used to display help in the man format. See git-help ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary index" }, { "role": "assistant", "content": "A collection of files with stat information, whose contents are stored\nas objects. The index is a stored version of your working tree . Truth be told, it can also contain a second, and even\na third version of a working tree, which are used\nwhen merging ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Download a single folder or directory from a GitHub repository\nHow can I download only a specific folder or directory from a remote Git repository hosted on GitHub?\nSay the example GitHub repository lives here:\n[email protected]:foobar/Test.git\n\nIts directory structure:\nTest/\n├── foo/\n│ ├── a.py\n│ └── b.py\n└── bar/\n ├── c.py\n └── d.py\n\nI want to download only the foo folder and not clone the whole Test project." }, { "role": "assistant", "content": "Update April 2021: there are a few tools created by the community that can do this for you:\n\nDownload Directory (Credits to fregante)\n\nIt has also been integrated into the excellent Refined GitHub Chrome extension as a button in the GitHub web user interface.\n\n\nGitZip (Credits to Kino—see his answer here)\nDownGit (Credits to Minhas Kamal—see his answer here)\n\nNote: if you're trying to download a large number of files, you may need to provide a token to these tools to avoid rate limiting.\n\nOriginal (manual) approach: Checking out an individual directory is not supported by Git natively, but GitHub can do this via Subversion (SVN). If you checkout your code with Subversion, GitHub will essentially convert the repository from Git to Subversion on the backend, and then serve up the requested directory.\nHere's how you can use this feature to download a specific folder. I'll use the popular JavaScript library Lodash as an example.\n\nNavigate to the folder you want to download. Let's download /test from master branch.\n\n\nModify the URL for subversion. Replace tree/master with trunk.\nhttps://github.com/lodash/lodash/tree/master/test ➜\nhttps://github.com/lodash/lodash/trunk/test\n\nDownload the folder. Go to the command line and grab the folder with SVN.\nsvn checkout https://github.com/lodash/lodash/trunk/test\n\n\n\nYou might not see any activity immediately because GitHub takes up to 30 seconds to convert larger repositories, so be patient.\n\nFull URL format explanation:\n\nIf you're interested in master branch, use trunk instead. So the full path is trunk/foldername\nIf you're interested in foo branch, use branches/foo instead. The\nfull path looks like branches/foo/foldername\nPro tip: You can use svn ls to see available tags and branches before downloading if you wish\n\n\nThat's all! GitHub supports more Subversion features as well, including support for committing and pushing changes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GIT: How dangerous is \"deleted by us\" conflict?\nA few days ago I made a new branch called \"new_branch\" based on \"master\". While I worked on my \"new_branch\" with file \"file.php\", a second developer on his branch deleted the file \"file.php\" and merged his branch with \"master\". Now I need to rebase my branch on current \"master\". After the command git pull --rebase origin master I have the conflict\n\ndeleted by us: app/file.php\n\nI don't know what to do, I don't want to lose changes I've made in this file. After commands\ngit add -A\ngit rebase --continue \n\nwill the file disappear in my \"new_branch\"?" }, { "role": "assistant", "content": "The message deleted by us: app/file.php means precisely what you described, namely that someone deleted this file in the master branch on which you are rebasing new_branch.\nAssuming that the delete has not yet been staged and you want to keep this file, then you should git add the file to mark it that it should be kept:\ngit add app/file.php\n\nThen, resolve all other merge conflicts and do git rebase --continue\nNote that if you wanted to accept the delete you would do git rm instead." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects %s" }, { "role": "assistant", "content": "subject" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I move forward and backward between commits in git?\nI am doing a git bisect and after arriving to the problematic commit, I am now trying to get a step forward/backward to make sure I am in the right one.\nI know of HEAD^ to go backwards in history but is there another shortcut to get me forward (towards a specific commit in the future) like so:\nA - B - C(HEAD) - D - E - F\n\nI know that my target is F and I want to move from C to D.\n\nNOTE: this is not a duplicate of Git: How to move back and forth between commits, my question is slightly different and is not answered there" }, { "role": "assistant", "content": "I believe you can do:\ngit reset HEAD@{1}\n\nTo go one commit forward in time. To go forward multiple commits, use HEAD@{2}, HEAD@{3}, etc." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Download a specific tag with Git\nI'm trying to figure out how I can download a particular tag of a Git repository - it's one version behind the current version.\nI saw there was a tag for the previous version on the git web page, with object name of something long hex number. \nBut the version name is \"Tagged release 1.1.5\" according the site.\nI tried a command like this (with names changed):\ngit clone http://git.abc.net/git/abc.git my_abc\n\nAnd I did get something - a directory, a bunch of subdirectories, etc. \nIf it's the whole repository, how do I get at the version I'm seeking? If not, how do I download that particular version?" }, { "role": "assistant", "content": "$ git clone\n\nwill give you the whole repository.\nAfter the clone, you can list the tags with $ git tag -l and then checkout a specific tag:\n$ git checkout tags/<tag_name>\n\nEven better, checkout and create a branch (otherwise you will be on a branch named after the revision number of tag):\n$ git checkout tags/<tag_name> -b <branch_name>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I override the title of a GitLab wiki page?\n\nI'm am editing pages in a GitLab project wiki.\nIf I name a page \"first-last\", the URL is \"project/wikis/first-last\" and the page title is rendered in sentence case as \"First last\". If I name a page \"first-(last)\", the URL is \"project/wikis/first-(last)\" and the page title is rendered in sentence case as \"First (last)\".\nI want the URL to be \"project/wikis/first-last\" and the page title to be \"First (last)\". Thus, I want to override the page title.\nMy understanding is that GitLab project wikis run on Gollum. According to the Gollum docs page titles can be overridden with one of two methods:\n\nEnable --h1-title. The first H1-level title on the page will override the page title.\nUse the metadata directive. If the first line of the page is <!-- --- title: My page title -->, the given value will override the page title.\n\nI don't have access to option 1. I tried option 2 and nothing happened.\nHow can I override the title of a GitLab wiki page?" }, { "role": "assistant", "content": "From what I can find, there might not be a way to do it. I haven't tried using that Gollum flag, yet.\nThe GitLab documentation has this section:\n\nNotes on Gollum\nWe only use Gollum as a storage abstraction layer, to handle the mapping between wiki page slugs and files in the repository.\nWhen rendering wiki pages, we don’t use Gollum at all and instead go through a custom Banzai pipeline. This adds some wiki-specific markup, such as Gollum’s [[link]] syntax.\nBecause we do not make use of most of Gollum’s features, we plan to move away from it entirely at some point. See this epic for reference." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects -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." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to 'Watch' only a directory in a GitHub repository?\nFor example, https://github.com/vanillaforums/Garden is the GitHub repository. But I only want to 'watch' this directory https://github.com/vanillaforums/Garden/tree/master/plugins in the repository.\nHow do I do that? There doesn't seem to be a way." }, { "role": "assistant", "content": "GitHub provides feeds that can do this for both directories and files.1 Using that syndication, a service like Blog Trottr can send you an email whenever the feed is updated.\nSome samples, taken from the Linux source code on master:\n\n\n\n\n\nDirectory\nFile\n\n\n\n\nSource on GitHub\n/Documentation\n/Documentation/Makefile\n\n\nHistory on GitHub\n/Documentation\n/Documentation/Makefile\n\n\nHistory Atom feed\n/Documentation\n/Documentation/Makefile\n\n\n\n\n1 Thank you, youfu." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "fatal: Not a valid object name: 'master'\nI have a private server running git 1.7\nWhen I \ngit init \n\na folder it doesn't create a master branch.\nCause when i do: \ngit branch \n\nit doesn't list anything.\nWhen I do:\ngit --bare init\n\nit creates the files.\nWhen I type \ngit branch master \n\nit says:\nfatal: Not a valid object name: 'master'." }, { "role": "assistant", "content": "When I git init a folder it doesn't create a master branch\n\nThis is true, and expected behaviour. Git will not create a master branch until you commit something.\n\nWhen I do git --bare init it creates the files.\n\nA non-bare git init will also create the same files, in a hidden .git directory in the root of your project.\n\nWhen I type git branch master it says \"fatal: Not a valid object name: 'master'\"\n\nThat is again correct behaviour. Until you commit, there is no master branch.\nYou haven't asked a question, but I'll answer the question I assumed you mean to ask. Add one or more files to your directory, and git add them to prepare a commit. Then git commit to create your initial commit and master branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-checkout" }, { "role": "assistant", "content": "Switch branches or restore working tree files" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to cause a job to finish with warning in Gitlab\n\nI mean to get this status:\n\nI can finish my job with failure, by \"exit 1\" , but can't do the same with warning" }, { "role": "assistant", "content": "This is possible since 13.8:\ntest_job:\n script:\n - execute_script_that_will_fail \n # if the script exit code is 137 or 255 the job will allow to be \n # failed and the pipeline will continue to run\n allow_failure:\n exit_codes: # User defined exit code\n - 137\n - 255" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I stop git bisect?\nI tried git bisect a while ago and it helped me well, but apparently I didn't stop it. When I do git status I still get:\nYou are currently bisecting.\n(use \"git bisect reset\" to get back to the original branch)\n\nI don't really want to reset to anywhere, I just want to stop bisecting. It's really just a matter of getting rid of this message." }, { "role": "assistant", "content": "git bisect reset is how you stop bisecting. By default it will reset the HEAD to where it was before you started, although you can also use git bisect reset <commit> to go to that one instead.\nIf you just want to stop bisecting without changing the commit, from the documentation, git bisect reset HEAD would do what you want.\n\nBisect reset\nAfter a bisect session, to clean up the bisection state and return to the original HEAD (i.e., to quit bisecting), issue the following command:\n$ git bisect reset\nBy default, this will return your tree to the commit that was checked out before git bisect start. (A new git bisect start will also do that, as it cleans up the old bisection state.)\nWith an optional argument, you can return to a different commit instead:\n$ git bisect reset <commit>\nFor example, git bisect reset HEAD will leave you on the current bisection commit and avoid switching commits at all, while git bisect reset bisect/bad will check out the first bad revision.\n\nSource: http://git-scm.com/docs/git-bisect" } ]
[ { "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": "CONFIGURATION This command uses the diff.color.* and pager.range-diff settings\n(the latter is on by default).\nSee git-config ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Checkout, Fetch and Pull in BitBucket SourceTree\n\nI am using BitBucket for web based hosting of our projects. Along with that I am using their SourceTree for committing and such purpose. I am a bit confused with the Checkout, Fetch and Pull option available in the SourceTree interface and their usage. Can someone familiar with this tool explains the usage of these options available in SourceTree?" }, { "role": "assistant", "content": "Using Atlassian's Git tutorial (link updated) as a reference.\nGit checkout:\n\nThe git checkout command lets you navigate between the branches\n created by git branch. Checking out a branch updates the files in the\n working directory to match the version stored in that branch, and it\n tells Git to record all new commits on that branch. Think of it as a\n way to select which line of development you’re working on.\nSource: https://www.atlassian.com/git/tutorials/using-branches#git-checkout\n\nGit pull:\n\nYou can think of git pull as Git's version of svn update. It’s an easy\n way to synchronize your local repository with upstream changes. The\n following diagram explains each step of the pulling process.\nSource: https://www.atlassian.com/git/tutorials/syncing#git-pull\n\nGit fetch:\n\nThe git fetch command imports commits from a remote repository into\n your local repo. The resulting commits are stored as remote branches\n instead of the normal local branches that we’ve been working with.\n This gives you a chance to review changes before integrating them into\n your copy of the project.\nSource: https://www.atlassian.com/git/tutorials/syncing#git-fetch" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I delete a Git branch locally and remotely?\nThis question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.\n \n \n\n\n\n\n\n\nFailed Attempts to Delete a Remote Branch:\n$ git branch -d remotes/origin/bugfix\nerror: branch 'remotes/origin/bugfix' not found.\n\n$ git branch -d origin/bugfix\nerror: branch 'origin/bugfix' not found.\n\n$ git branch -rd origin/bugfix\nDeleted remote branch origin/bugfix (was 2a14ef7).\n\n$ git push\nEverything up-to-date\n\n$ git pull\nFrom github.com:gituser/gitproject\n\n* [new branch] bugfix -> origin/bugfix\nAlready up-to-date.\n\nHow do I properly delete the remotes/origin/bugfix branch both locally and remotely?" }, { "role": "assistant", "content": "Executive Summary\ngit push -d <remote_name> <branchname>\ngit branch -d <branchname>\n\nNote: In most cases, <remote_name> will be origin.\nDelete Local Branch\nTo delete the local branch, use one of the following:\ngit branch -d <branch_name>\ngit branch -D <branch_name>\n\n\nThe -d option is an alias for --delete, which only deletes the branch if it has already been fully merged in its upstream branch.\nThe -D option is an alias for --delete --force, which deletes the branch \"irrespective of its merged status.\" [Source: man git-branch]\nAs of Git v2.3, git branch -d (delete) learned to honor the -f (force) flag.\nYou will receive an error if you try to delete the currently selected branch.\n\nDelete Remote Branch\nAs of Git v1.7.0, you can delete a remote branch using\n$ git push <remote_name> --delete <branch_name>\n\nwhich might be easier to remember than\n$ git push <remote_name> :<branch_name>\n\nwhich was added in Git v1.5.0 \"to delete a remote branch or a tag.\"\nStarting with Git v2.8.0, you can also use git push with the -d option as an alias for --delete. Therefore, the version of Git you have installed will dictate whether you need to use the easier or harder syntax.\nDelete Remote Branch [Original Answer from 5-Jan-2010]\nFrom Chapter 3 of Pro Git by Scott Chacon:\n\nDeleting Remote Branches\nSuppose you’re done with a remote branch — say, you and your collaborators are finished with a feature and have merged it into your remote’s main branch (or whatever branch your stable code-line is in). You can delete a remote branch using the rather obtuse syntax git push [remotename] :[branch]. If you want to delete your serverfix branch from the server, you run the following:\n$ git push origin :serverfix\nTo [email protected]:schacon/simplegit.git\n - [deleted] serverfix\n\nBoom. No more branches on your server. You may want to dog-ear this page, because you’ll need that command, and you’ll likely forget the syntax. A way to remember this command is by recalling the git push [remotename] [localbranch]:[remotebranch] syntax that we went over a bit earlier. If you leave off the [localbranch] portion, then you’re basically saying, “Take nothing on my side and make it be [remotebranch].”\n\nI ran git push origin :bugfix, and it worked beautifully. Scott Chacon was right—I will want to dog-ear that page (or virtually dog ear-by answering this on Stack Overflow).\nFinally, execute the following on other machines to propagate changes:\n# Fetch changes from all remotes and locally delete \n# remote deleted branches/tags etc\n# --prune will do the job :-;\ngit fetch --all --prune" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_CEILING_DIRECTORIES" }, { "role": "assistant", "content": "This should be a colon-separated list of absolute paths. If\nset, it is a list of directories that Git should not chdir up\ninto while looking for a repository directory (useful for\nexcluding slow-loading network directories). It will not\nexclude the current working directory or a GIT_DIR set on the\ncommand line or in the environment. Normally, Git has to read\nthe entries in this list and resolve any symlink that\nmight be present in order to compare them with the current\ndirectory. However, if even this access is slow, you\ncan add an empty entry to the list to tell Git that the\nsubsequent entries are not symlinks and needn’t be resolved;\ne.g., GIT_CEILING_DIRECTORIES=/maybe/symlink::/very/slow/non/symlink ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "github Dependabot alert: Inefficient Regular Expression Complexity in nth-check\n\nPossible duplicate, but couldn't find any clear answers.\n\nDependabot cannot update nth-check to a non-vulnerable version\nThe latest possible version that can be installed is 1.0.2 because of the following >conflicting dependency:\n\n[email protected] requires nth-check@^1.0.2 via a transitive dependency on [email protected]\n\n\njust upgraded to [email protected] from 4.0.0." }, { "role": "assistant", "content": "As Dan Abramov explains in this issue, it is (very likely) a false alarm and can be safely dismissed.\nMore specifically, if you are using CRA and nth-check is referenced only from it, it is not an issue, because CRA is a build tool and the vulnerable code will never get into the resulting application bundle and thus will never be called by client code.\nYou can verify this by moving \"react-scripts\" into \"devDependencies\" in package.json and running npm audit --production." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.dirstat" }, { "role": "assistant", "content": "A comma separated list of --dirstat parameters specifying the\ndefault behavior of the --dirstat option to git-diff and friends. The defaults can be overridden on the command line\n(using --dirstat=<param1,param2,...> ). The fallback defaults\n(when not changed by diff.dirstat ) are changes,noncumulative,3 .\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: files,10,cumulative ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fast-import - Backend for fast Git data importers" }, { "role": "assistant", "content": "TECHNICAL DISCUSSION fast-import tracks a set of branches in memory. Any branch can be created\nor modified at any point during the import process by sending a commit command on the input stream. This design allows a frontend\nprogram to process an unlimited number of branches simultaneously,\ngenerating commits in the order they are available from the source\ndata. It also simplifies the frontend programs considerably. fast-import does not use or alter the current working directory, or any\nfile within it. (It does however update the current Git repository,\nas referenced by GIT_DIR .) Therefore an import frontend may use\nthe working directory for its own purposes, such as extracting file\nrevisions from the foreign source. This ignorance of the working\ndirectory also allows fast-import to run very quickly, as it does not\nneed to perform any costly file update operations when switching\nbetween branches." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Getting Git to Acknowledge Previously Moved Files\nI've moved a bunch of files around manually without thinking, and can't find a way to get git to recognize that the files are just moved and not actually different files. Is there a way to do this other than removing old and adding the new (and thus losing the history), or redoing all the changes with git-mv?" }, { "role": "assistant", "content": "To have git remove files that are removed or moved already, just enter\ngit add -u" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options status.short" }, { "role": "assistant", "content": "Set to true to enable --short by default in git-status .\nThe option --no-short takes precedence over this variable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %Cblue" }, { "role": "assistant", "content": "switch color to blue" } ]