messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-status - Show the working tree status --ahead-behind --no-ahead-behind" }, { "role": "assistant", "content": "Display or do not display detailed ahead/behind counts for the\nbranch relative to its upstream branch. Defaults to true." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git as mercurial client? Why no git-hg?\nThis is a question that's been bothering me for a while. I've done my homework and checked stackoverflow and found at least these two topics about my question:\nGit for Mercurial like git-svn and\nGit interoperability with a Mercurial repository\nI've done some serious googling to solve this issue, but so far with no luck. I've also read the Git Internals book, and the Mercurial Definitive Behind the Scenes to try to figure this out. I'm still a bit puzzled why I haven't been able to find any suitable git-hg type of a tool. \nFrom my perspective git-svn is one of the main features, why I've chosen to use git over mercurial also at work. It allows me to use a workflow I like, and nobody else needs to bother, if they don't care. I just don't see the point in using the intermediate hg repo to convert back and forth, as suggested in one of the chains. \nSo anyway, from what I've read hg and git seem very similar in conceptual design. There are differences under the hood, but none of those should prevent creating a git client for hg. As it seems to me, remote tracking branches and octopus merges make git even more powerful than hg is. \nSo, the real question, is there any real reason why git-hg does not exist (or at least is very hard to find)? \nIs there some animosity from git users (and developers) towards their hg counterparts that has caused the lack of the git-hg tool?\nDo any of you have any plans to develop something like this, and go public with it? I could volunteer (although with very feeble C-skills) to participate to get this done. I just don't possess the full knowledge to start this up myself.\nCould this be the tool to end all DVCS wars for good?" }, { "role": "assistant", "content": "I haven't tried this, but there seems to be a git-hg project. The project describes itself on the page and the README as:\n\nA git-hg utility for checking out and\ntracking a mercurial repo.\nA set of\nscripts for checking out and tracking\na mercrial [sic] project.\n\nIt doesn't seem to work bi-directionally though (see issue tracker)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-stash - Stash the changes in a dirty working directory away pop [--index] [-q|--quiet] [<stash>]" }, { "role": "assistant", "content": "Remove a single stashed state from the stash list and apply it\non top of the current working tree state, i.e., do the inverse\noperation of git stash push . The working directory must\nmatch the index. Applying the state can fail with conflicts; in this case, it is not\nremoved from the stash list. You need to resolve the conflicts by hand\nand call git stash drop manually afterwards." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-grep - Print lines matching a pattern --heading" }, { "role": "assistant", "content": "Show the filename above the matches in that file instead of\nat the start of each shown line." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options column.status" }, { "role": "assistant", "content": "Specify whether to output untracked files in git status in columns.\nSee column.ui for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc allow-indentation-change" }, { "role": "assistant", "content": "Initially ignore any whitespace in the move detection, then\ngroup the moved code blocks only into a block if the change in\nwhitespace is the same per line. This is incompatible with the\nother modes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Push origin master error on new repository\n\nI just started using git with github. I followed their instructions and ran into errors on the last step. I'm checking in an existing directory that isn't currently source-controlled (project about a week old). Other than that, my use case should be pretty run of the mill.\nHere's what's happening:\n$ git push origin master\nerror: src refspec master does not match any.\nfatal: The remote end hung up unexpectedly\nerror: failed to push some refs to '[email protected]:{username}/{projectname}.git'\n\nGithub's instructions:\nGlobal setup:\n\n Download and install Git\n git config --global user.name \"Your Name\"\n git config --global user.email {username}@gmail.com\n\nNext steps:\n\n mkdir projectname\n cd projectname\n git init\n touch README\n git add README\n git commit -m 'first commit'\n git remote add origin [email protected]:{username}/{projectname}.git\n git push origin master" }, { "role": "assistant", "content": "I was having the same issue and then smacked myself in the head because I hadn't actually added my project files.\ngit add -A\ngit commit -am \"message\"\ngit push origin master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Disable Git LFS for a remote\nI'm trying to push to a second remote that doesn't support Git LFS. Is there a way to disable Git LFS for a specific remote using git config?" }, { "role": "assistant", "content": "The workaround given by amiuhle works fine for me:\ngit push --no-verify\n\nIt prevents the pre-push hook of git lfs from trying to upload the files. So link-files are committed, but the actual binaries are missing." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I change the remote/target repository URL on Windows? [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\n\nHow do I change the URI (URL) for a remote Git repository?\n\n (34 answers)\n \n\nClosed 10 years ago.\n\n\n\nI created a local GIT repository on Windows. Let's call it AAA. I staged, committed, and pushed the contents to GitHub. [email protected]:username/AAA.git \nI realized I made a mistake with the name.\nOn GitHub, I renamed it to [email protected]:username/BBB.git \nNow, on my Windows machine, I need to change [email protected]:username/AAA.git to [email protected]:username/BBB.git because the settings are still trying to \"push\" to [email protected]:username/AAA.git but I need to push to [email protected]:username/BBB.git now.\nHow could I do that?" }, { "role": "assistant", "content": "git remote set-url origin <URL>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Installing git on Windows: Git Bash Here or git-cheetah shell extension?\nI'm installing Git on Windows XP. During the setup, the installer asks whether I want:\n\n1: Context menu entries: \"Git Bash Here\" (and the \"Git GUI Here\" option)\n\nor\n\n2: \"git-cheetah shell extension (32-bit only)\"\n\nBasically, which should I do? I can't do both.\nMore specifically, what is the most commonly used version? Is the Git Bash tool the same as the shell extension?" }, { "role": "assistant", "content": "git bash here will give you a console window with access to git commands, shell extension will give you right click menu access to git commands creating an environment similar to TortoiseSVN and such." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do you push just a single Git branch (and no other branches)?\nI am working on a local git repository. There are two branches, master and feature_x.\nI want to push feature_x to the remote repo, but I do not want to push the changes on the master branch.\nWill a git push origin feature_x from my feature_x branch (feature_x branch already exists on remote) work?\nI do not want to test this on my box, because I cannot push to master right now." }, { "role": "assistant", "content": "yes, just do the following\ngit checkout feature_x\ngit push origin feature_x" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab: Get merge request from a commit id\n\nI'm using the API of gitlab and I'm building a changelog. I use merge request in my project. In my changelog I get all commits ordered by id and now I want to get the merge request of gitlab to get his message. How can I get a merge request from a commit id?\nThanks," }, { "role": "assistant", "content": "It is an open issue in gitlab:\nhttps://gitlab.com/gitlab-org/gitlab-ce/issues/28037" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-commit - Record changes to the repository -C <commit> --reuse-message=<commit>" }, { "role": "assistant", "content": "Take an existing commit object, and reuse the log message\nand the authorship information (including the timestamp)\nwhen creating the commit." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Checking for a dirty index or untracked files with Git\nHow can I check if I have any uncommitted changes in my git repository:\n\nChanges added to the index but not committed\nUntracked files\n\nfrom a script?\ngit-status seems to always return zero with git version 1.6.4.2." }, { "role": "assistant", "content": "The key to reliably “scripting” Git is to use the ‘plumbing’ commands.\nThe developers take care when changing the plumbing commands to make sure they provide very stable interfaces (i.e. a given combination of repository state, stdin, command line options, arguments, etc. will produce the same output in all versions of Git where the command/option exists). New output variations in plumbing commands can be introduced via new options, but that can not introduce any problems for programs that have already been written against older versions (they would not be using the new options, since they did not exist (or at least were not used) at the time the script was written).\nUnfortunately the ‘everyday’ Git commands are the ‘porcelain’ commands, so most Git users may not be familiar with with the plumbing commands. The distinction between porcelain and plumbing command is made in the main git manpage (see subsections titled High-level commands (porcelain) and Low-level commands (plumbing).\n\nTo find out about uncomitted changes, you will likely need git diff-index (compare index (and maybe tracked bits of working tree) against some other treeish (e.g. HEAD)), maybe git diff-files (compare working tree against index), and possibly git ls-files (list files; e.g. list untracked, unignored files).\n(Note that in the below commands, HEAD -- is used instead of HEAD because otherwise the command fails if there is a file named HEAD.)\nTo check whether a repository has staged changes (not yet committed) use this:\ngit diff-index --quiet --cached HEAD --\n\n\nIf it exits with 0 then there were no differences (1 means there were differences).\n\nTo check whether a working tree has changes that could be staged:\ngit diff-files --quiet\n\n\nThe exit code is the same as for git diff-index (0 == no differences; 1 == differences).\n\nTo check whether the combination of the index and the tracked files in the working tree have changes with respect to HEAD:\ngit diff-index --quiet HEAD --\n\n\nThis is like a combination of the previous two. One prime difference is that it will still report “no differences” if you have a staged change that you have “undone” in the working tree (gone back to the contents that are in HEAD). In this same situation, the two separate commands would both return reports of “differences present”.\n\nYou also mentioned untracked files. You might mean “untracked and unignored”, or you might mean just plain “untracked” (including ignored files). Either way, git ls-files is the tool for the job:\nFor “untracked” (will include ignored files, if present):\ngit ls-files --others\n\nFor “untracked and unignored”:\ngit ls-files --exclude-standard --others\n\nMy first thought is to just check whether these commands have output:\ntest -z \"$(git ls-files --others)\"\n\n\nIf it exits with 0 then there are no untracked files. If it exits with 1 then there are untracked files.\n\nThere is a small chance that this will translate abnormal exits from git ls-files into “no untracked files” reports (both result in non-zero exits of the above command). A bit more robust version might look like this:\nu=\"$(git ls-files --others)\" && test -z \"$u\"\n\n\nThe idea is the same as the previous command, but it allows unexpected errors from git ls-files to propagate out. In this case a non-zero exit could mean “there are untracked files” or it could mean an error occurred. If you want the “error” results combined with the “no untracked files” result instead, use test -n \"$u\" (where exit of 0 means “some untracked files”, and non-zero means error or “no untracked files”).\n\nAnother idea is to use --error-unmatch to cause a non-zero exit when there are no untracked files. This also runs the risk of conflating “no untracked files” (exit 1) with “an error occurred” (exit non-zero, but probably 128). But checking for 0 vs. 1 vs. non-zero exit codes is probably fairly robust:\ngit ls-files --others --error-unmatch . >/dev/null 2>&1; ec=$?\nif test \"$ec\" = 0; then\n echo some untracked files\nelif test \"$ec\" = 1; then\n echo no untracked files\nelse\n echo error from ls-files\nfi\n\nAny of the above git ls-files examples can take --exclude-standard if you want to consider only untracked and unignored files." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --all" }, { "role": "assistant", "content": "Pretend as if all the refs in refs/ , along with HEAD , are\nlisted on the command line as <commit> ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --remerge-diff" }, { "role": "assistant", "content": "Produce remerge-diff output for merge commits.\nShortcut for --diff-merges=remerge -p ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-merge - Join two or more development histories together merge.<driver>.driver" }, { "role": "assistant", "content": "Defines the command that implements a custom low-level\nmerge driver. See gitattributes for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database duplicateEntries" }, { "role": "assistant", "content": "(ERROR) A tree contains duplicate file entries." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "There is no tracking information for the current branch\n\nI've been using github from a relatively short period, and I've always used the client to perform commits and pulls. I decided to try it from the git bash yesterday, and I successfully created a new repo and committed files.\nToday I did changes to the repository from another computer, I've committed the changes and now I'm back home and performed a git pull to update my local version and I get this:\nThere is no tracking information for the current branch.\n Please specify which branch you want to merge with.\n See git-pull(1) for details\n\n git pull <remote> <branch>\n\nIf you wish to set tracking information for this branch you can do so with:\n\n git branch --set-upstream develop origin/<branch>\n\nthe only contributor to this repo is me and there are no branches (just a master). I'm on windows and I've performed the pull from git bash:\n\ngit status:\n$ git status\n# On branch master\nnothing to commit, working directory clean\n\ngit branch:\n$ git branch\n* master\n\nWhat am I doing wrong?" }, { "role": "assistant", "content": "You could specify what branch you want to pull:\ngit pull origin master\n\nOr you could set it up so that your local master branch tracks github master branch as an upstream:\ngit branch --set-upstream-to=origin/master master\ngit pull\n\nThis branch tracking is set up for you automatically when you clone a repository (for the default branch only), but if you add a remote to an existing repository you have to set up the tracking yourself. Thankfully, the advice given by git makes that pretty easy to remember how to do." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order --skip=<number>" }, { "role": "assistant", "content": "Skip number commits before starting to show the commit output." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-commit - Record changes to the repository --reset-author" }, { "role": "assistant", "content": "When used with -C/-c/--amend options, or when committing after a\nconflicting cherry-pick, declare that the authorship of the\nresulting commit now belongs to the committer. This also renews\nthe author timestamp." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --word-diff-regex=<regex>" }, { "role": "assistant", "content": "Use <regex> to decide what a word is, instead of considering\nruns of non-whitespace to be a word. Also implies --word-diff unless it was already enabled. Every non-overlapping match of the\n<regex> is considered a word. Anything between these matches is\nconsidered whitespace and ignored(!) for the purposes of finding\ndifferences. You may want to append |[^[:space:]] to your regular\nexpression to make sure that it matches all non-whitespace characters.\nA match that contains a newline is silently truncated(!) at the\nnewline. For example, --word-diff-regex=. will treat each character as a word\nand, correspondingly, show differences character by character. The regex can also be set via a diff driver or configuration option, see gitattributes or git-config . Giving it explicitly\noverrides any diff driver or configuration setting. Diff drivers\noverride configuration settings." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "xcodebuild: error: 'APP.xcworkspace' does not exist\n\nI am trying to set up CI with gitlab. When I try to build locally, I get this error : xcodebuild: error: 'APP.xcworkspace' does not exist.\n\"APP\" not being the real name. I am also using CocoaPods.\nThis happens after I run this command in terminal:\ngitlab-ci-multi-runner exec shell build_project\nI have checked and the file does exist in the same folder I call the command.\nThis is my .gitlab-ci.yml file:\nstages:\n - build\n\nbuild_project:\n stage: build\n script:\n - xcodebuild clean -workspace APP.xcworkspace -scheme APP | xcpretty\n - xcodebuild test -workspace APP.xcworkspace -scheme APP -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.2' | xcpretty -s\n tags:\n - v0.0.1\n\nXcode version: 8.2.1\nCocoapods version: 1.2.0\nGitlab-runner version : 1.11.0\nAlex" }, { "role": "assistant", "content": "On React Native I've solved this issue by running command inside /ios folder." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git push local branch with same name as remote tag\nI'm trying to push a new local branch product-0.2 to remote where there is already a tag with the same name (but the branch itself does not exist)\ngit push -v --tags --set-upstream origin product-0.2:product-0.2 \nPushing to https://****@github.com/mycompany/product.git\nerror: src refspec product-0.2 matches more than one.\nerror: failed to push some refs to 'https://****@github.com/mycompany/product.git'\n\nSame with:\ngit push origin product-0.2:/refs/heads/product-0.2 \n\nAlthough the other way around it works, e.g. create a branch product-0.1, commit on it then apply a tag product-0.1.\nSome people work around this by removing the conflicting tag locally, then push the branch, then retrieve the remote tag, but it seems cumbersome and error prone.\nHow can I create my branch with minimal fuss?\nThanks for your input" }, { "role": "assistant", "content": "The following command should work.\ngit push origin refs/heads/product-0.2:refs/heads/product-0.2" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git pull till a particular commit\nI want to do a git pull but only till a specific commit.\n A->B->C->D->E->F (Remote master HEAD)\n\nso suppose my local master HEAD points to B, and I want to pull till E. What should I do ?\nThis is not pulling a specific commit, this is pulling upto a specific commit." }, { "role": "assistant", "content": "git pull is nothing but git fetch followed by git merge. So what you can do is\ngit fetch remote example_branch\ngit merge <commit_hash>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Listing each branch and its last revision's date in Git\nI need to delete old and unmaintained branches from our remote repository. I'm trying to find a way with which to list the remote branches by their last modified date, and I can't.\nIs there an easy way to list remote branches this way?" }, { "role": "assistant", "content": "commandlinefu has 2 interesting propositions:\nfor k in $(git branch | perl -pe s/^..//); do echo -e $(git show --pretty=format:\"%Cgreen%ci %Cblue%cr%Creset\" $k -- | head -n 1)\\\\t$k; done | sort -r\n\nor:\nfor k in $(git branch | sed s/^..//); do echo -e $(git log --color=always -1 --pretty=format:\"%Cgreen%ci %Cblue%cr%Creset\" $k --)\\\\t\"$k\";done | sort\n\nThat is for local branches, in a Unix syntax. Using git branch -r, you can similarly show remote branches:\nfor k in $(git branch -r | perl -pe 's/^..(.*?)( ->.*)?$/\\1/'); do echo -e $(git show --pretty=format:\"%Cgreen%ci %Cblue%cr%Creset\" $k -- | head -n 1)\\\\t$k; done | sort -r\n\n\nMichael Forrest mentions in the comments that zsh requires escapes for the sed expression:\nfor k in git branch | perl -pe s\\/\\^\\.\\.\\/\\/; do echo -e git show --pretty=format:\"%Cgreen%ci %Cblue%cr%Creset\" $k -- | head -n 1\\\\t$k; done | sort -r \n\nkontinuity adds in the comments:\n\nIf you want to add it your zshrc the following escape is needed.\n\nalias gbage='for k in $(git branch -r | perl -pe '\\''s/^..(.*?)( ->.*)?$/\\1/'\\''); do echo -e $(git show --pretty=format:\"%Cgreen%ci %Cblue%cr%Creset\" $k -- | head -n 1)\\\\t$k; done | sort -r'\n\nIn multiple lines:\nalias gbage='for k in $(git branch -r | \\\n perl -pe '\\''s/^..(.*?)( ->.*)?$/\\1/'\\''); \\\n do echo -e $(git show --pretty=format:\"%Cgreen%ci %Cblue%cr%Creset\" $k -- | \\\n head -n 1)\\\\t$k; done | sort -r'\n\n\nNote: n8tr's answer, based on git for-each-ref refs/heads is cleaner. And faster.\nSee also \"Name only option for git branch --list?\"\nMore generally, tripleee reminds us in the comments:\n\n\nPrefer modern $(command substitution) syntax over obsolescent backtick syntax.\n\n\n(I illustrated that point in 2014 with \"What is the difference between $(command) and `command` in shell programming?\")\n\n\nDon't read lines with for.\nProbably switch to git for-each-ref refs/remote to get remote branch names in machine-readable format" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Forgot \"git rebase --continue\" and did \"git commit\". How to fix?\nI was rebasing code in git, I got some merge conflicts. I resolved the conflicts and did:\ngit add\n\nAt this point I forgot to do:\ngit rebase --continue\n\nI continued coding and did:\ngit commit\n\nfor the changes. Now I am on \"no branch\" and can't do:\ngit rebase --continue \n\nHow do I fix this?" }, { "role": "assistant", "content": "Just do git reset --soft HEAD^. It moves the HEAD pointer to its parent but keeps the work tree and adds the merge change to the index. So you can continue rebasing with git rebase --continue as before." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Cant commit after starting a merge in Sourcetree\nWhen trying to commit after a merge I'm getting this error message:\n\n\"fatal: You are in the middle of a merge -- cannot amend.\"\n\nHow do i resolve this? as far as I know I have resolved all conflicts, i just need to complete the merge and commit the changes. but the product won't let me and doesn't give me any clues as to what I am meant to do next, and there is no option to \"complete the merge\"\nEverytime I try to commit my changes I get the error message and I now have no idea what to do about it!" }, { "role": "assistant", "content": "You can manually delete .git/MERGE_HEAD and Git won't be able to tell that you were just doing a merge. It will let you amend the previous commit with the changes in your index just like normal.\nPlease read:\nThough this would work, it is a hack and not recommended. All is needed here is to let git know the merge is completed git commit -a as per this answer" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git reset" }, { "role": "assistant", "content": "Undoes the effects of fetch back to the specified revision.\nThis allows you to re- fetch an SVN revision. Normally the\ncontents of an SVN revision should never change and reset should not be necessary. However, if SVN permissions change,\nor if you alter your --ignore-paths option, a fetch may fail\nwith \"not found in commit\" (file not previously visible) or\n\"checksum mismatch\" (missed a modification). If the problem\nfile cannot be ignored forever (with --ignore-paths) the only\nway to repair the repo is to use reset . Only the rev_map and refs/remotes/git-svn are changed (see $GIT_DIR/svn/**/.rev_map.* in the FILES section below for details).\nFollow reset with a fetch and then git reset or git rebase to\nmove local branches onto the new tree. -r <n> --revision=<n> Specify the most recent revision to keep. All later revisions\nare discarded. -p --parent Discard the specified revision as well, keeping the nearest\nparent instead. Example: Assume you have local changes in \"master\", but you need to refetch \"r2\". r1---r2---r3 remotes/git-svn\n \\\n A---B master Fix the ignore-paths or SVN permissions problem that caused \"r2\" to\nbe incomplete in the first place. Then: git svn reset -r2 -p\ngit svn fetch r1---r2'--r3' remotes/git-svn\n \\\n r2---r3---A---B master Then fixup \"master\" with git rebase .\nDo NOT use git merge or your history will not be compatible with a\nfuture dcommit ! git rebase --onto remotes/git-svn A^ master r1---r2'--r3' remotes/git-svn\n \\\n A'--B' master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.renames" }, { "role": "assistant", "content": "Whether and how Git detects renames. If set to \"false\",\nrename detection is disabled. If set to \"true\", basic rename\ndetection is enabled. If set to \"copies\" or \"copy\", Git will\ndetect copies, as well. Defaults to true. Note that this\naffects only git diff Porcelain like git-diff and git-log , and not lower level commands such as git-diff-files ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-push - Update remote refs along with associated objects push.autoSetupRemote" }, { "role": "assistant", "content": "If set to \"true\" assume --set-upstream on default push when no\nupstream tracking exists for the current branch; this option\ntakes effect with push.default options simple , upstream ,\nand current . It is useful if by default you want new branches\nto be pushed to the default remote (like the behavior of push.default=current ) and you also want the upstream tracking\nto be set. Workflows most likely to benefit from this option are simple central workflows where all branches are expected to\nhave the same name on the remote." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Trying to git pull with error: cannot open .git/FETCH_HEAD: Permission denied\nHelp me please, I am trying to run this in my terminal:\nasgard@asgard-A7N8X2-0:~/CollegePortal$ git pull\nerror: cannot open .git/FETCH_HEAD: Permission denied\n\nThen I try this one\nasgard@asgard-A7N8X2-0:~/CollegePortal$ sudo git pull\nPermission denied (publickey).\nfatal: The remote end hung up unexpectedly\n\nHelp me, I don't understand this problem." }, { "role": "assistant", "content": "It seems like the first one isn't working because your user doesn't have the permissions for changing that directory, and the second because your root user doesn't have the right SSH keys for accessing that git repository.\nDepending on what you're trying to do, it might be better to clone the repository to a different directory, or maybe chown the current directory to have full access for your user" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Mercurial clients and GitLab?\n\nIs there a good way to let both git and hg clients use one repo system, like GitLab? \nPretty much like bitbucket. Should we just use https://hg-git.github.io/?" }, { "role": "assistant", "content": "One (commercial) solution (developed by the same company behind Stack Exchange) is Kiln, which can managed a repo with Git or mercurial.\nSee kiln Harmony.\nIf you use a git hosting service, then you need to manage a conversion system like hg-git yourself." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git Warning: remote HEAD refers to nonexistent ref, unable to checkout\nI'm trying to setup gitosis according to the instructions here.\nIt works fine from my remote machine so the server seems to be setup fine but I'd also like to be able to do development on my gitosis server machine from a different user account (not the git user created in the gitosis setup).\nI've copied the key and modified the gitosis.conf so that the other user account has access but when I try to clone it seems to work except at the end it says: \ngit Warning: remote HEAD refers to nonexistent ref, unable to checkout\n\nand I end up with an empty directory except for .git\nI've google for this a bit but have no real insight into what the problem is" }, { "role": "assistant", "content": "I found out what was going wrong. The problem was that I wasn't paying attention to the warnings when I was pushing to my gitosis server so I didn't realize that I wasn't pushing a particular branch. I had assumed it would just push the current but that isn't the case until you set:\ngit config push.default current" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-request-pull" }, { "role": "assistant", "content": "Generates a summary of pending changes" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options checkout.guess" }, { "role": "assistant", "content": "Provides the default value for the --guess or --no-guess option in git checkout and git switch . See git-switch and git-checkout ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-archive - Create an archive of files from a named tree" }, { "role": "assistant", "content": "NAME git-archive - Create an archive of files from a named tree" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --notes[=<ref>]" }, { "role": "assistant", "content": "Show the notes (see git-notes ) that annotate the\ncommit, when showing the commit log message. This is the default\nfor git log , git show and git whatchanged commands when\nthere is no --pretty , --format , or --oneline option given\non the command line. By default, the notes shown are from the notes refs listed in the core.notesRef and notes.displayRef variables (or corresponding\nenvironment overrides). See git-config for more details. With an optional <ref> argument, use the ref to find the notes\nto display. The ref can specify the full refname when it begins\nwith refs/notes/ ; when it begins with notes/ , refs/ and otherwise refs/notes/ is prefixed to form the full name of the ref. Multiple --notes options can be combined to control which notes are\nbeing displayed. Examples: \"--notes=foo\" will show only notes from\n\"refs/notes/foo\"; \"--notes=foo --notes\" will show both notes from\n\"refs/notes/foo\" and from the default notes ref(s)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --color-words[=<regex>]" }, { "role": "assistant", "content": "Equivalent to --word-diff=color plus (if a regex was\nspecified) --word-diff-regex=<regex> ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc no" }, { "role": "assistant", "content": "Moved lines are not highlighted." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can't pop git stash, 'Your local changes to the following files would be overwritten by merge'\nSo I had a load of changes and some untracked files. I needed to tweak something, so I used git stash -u, modified a couple of things, committed those changes, pushed them, and then tried to git stash pop.\nBecause I'd modified a couple of files that I'd stashed, I got the following message:\nerror: Your local changes to the following files would be overwritten by merge:\n file_1.py\n file_2.py\nPlease, commit your changes or stash them before you can merge.\nAborting\n\nThis seems odd, I had committed all new changes, my checkout was clean when I ran the command.\nIt seems the git stash pop operation un-stashed half of my changes and the untracked files, but if I try and git stash pop again I get output like:\nsome_file.html already exists, no checkout\nsome_other_file.html already exists, no checkout\nyet_another_file.html already exists, no checkout\nCould not restore untracked files from stash\n\ngit stash show still shows a list of my stashed changes, but I'm at a loss as to what I do now.\nHow can I get myself unstuck?" }, { "role": "assistant", "content": "For those who do have un-committed work, and want to pop their stash without losing that work, here is a way (with thanks to @iFreilicht):\n\nTemporarily stage any uncommitted changes:\n git add -u .\n\n\nNow you can apply your stash without git complaining (hopefully):\n git stash pop\n\n\nNow unstage everything, but leave the files as they are now:\n git reset\n\n\n\nIf step 2 couldn't patch cleanly due to conflicting changes, then you will need to resolve the conflicts manually. git diff should help you find them. git mergetool might help by opening your editor with before and current files." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-shell" }, { "role": "assistant", "content": "Restricted login shell for Git-only SSH access" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch --autostash --no-autostash" }, { "role": "assistant", "content": "Automatically create a temporary stash entry before the operation\nbegins, record it in the ref MERGE_AUTOSTASH and apply it after the operation ends. This means\nthat you can run the operation on a dirty worktree. However, use\nwith care: the final stash application after a successful\nmerge might result in non-trivial conflicts." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --word-diff[=<mode>]" }, { "role": "assistant", "content": "Show a word diff, using the <mode> to delimit changed words.\nBy default, words are delimited by whitespace; see --word-diff-regex below. The <mode> defaults to plain , and\nmust be one of: color Highlight changed words using only colors. Implies --color . plain Show words as [-removed-] and {+added+} . Makes no\nattempts to escape the delimiters if they appear in the input,\nso the output may be ambiguous. porcelain Use a special line-based format intended for script\nconsumption. Added/removed/unchanged runs are printed in the\nusual unified diff format, starting with a + / - /` `\ncharacter at the beginning of the line and extending to the\nend of the line. Newlines in the input are represented by a\ntilde ~ on a line of its own. none Disable word diff again. Note that despite the name of the first mode, color is used to\nhighlight the changed parts in all modes if enabled." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Ignores and Maven targets\nAnyone know if it is possible to ignore all the instances of a particular directory in a file structure managed by git. \nI'm looking to exclude all the 'target' folders in a maven project with a number of submodules. I know I can explicitly exclude each of them in a top level .gitignore, but I'd really like to be able to specify a pattern like **/target/* there to have it automatically ignore the instance in sub directories?\nIs this possible?" }, { "role": "assistant", "content": "The .gitignore file in the root directory does apply to all subdirectories. Mine looks like this:\n.classpath\n.project\n.settings/\ntarget/\n\nThis is in a multi-module maven project. All the submodules are imported as individual eclipse projects using m2eclipse. I have no further .gitignore files. Indeed, if you look in the gitignore man page:\n\nPatterns read from a .gitignore file\n in the same directory as the path, or\n in any parent directory…\n\nSo this should work for you." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.indentHeuristic" }, { "role": "assistant", "content": "Set this option to false to disable the default heuristics\nthat shift diff hunk boundaries to make patches easier to read." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Collapsing a Group of Commits into One on Git\nI have the habit of making a huge number of small commits, and I'm fine with it. But I would like to, from time to time, take a bunch of those linear commits and collapse them together as just one commit with the ability to write a new commit message.\nI've looked into the documentation but seemed a little to cryptic to me. Does anybody knows how to do that?" }, { "role": "assistant", "content": "Assuming you don't care about retaining any of your existing commit messages, there's a nifty (and fast) git recipe you can use. First, make sure your branch is checked out:\ngit checkout <branch-to-squash>\n\nFor safety, lets tag the current commit.\ngit tag my-branch-backup\n\nNext, move the branch HEAD back to your last good commit (without modifying the workspace or index). EDIT: The last good commit is the most recent commit on your branch that you want to retain.\ngit reset --soft <last-good-commit>\n\nUsing git status, you'll notice that all changes on your feature branch are now staged. All that's left to do is ...\ngit commit\n\nThis method is great for consolidating long, convoluted git histories and gnarly merges. Plus, there's no merge/rebase conflicts to resolve!\nNow, if you need to retain any of your existing commit messages or do anything fancier than the above allows, you'll want to use git rebase --interactive.\nSolution derived from: http://makandracards.com/makandra/527-squash-several-git-commits-into-a-single-commit\nReference: http://git-scm.com/docs/git-reset\nReference: http://git-scm.com/docs/git-rebase" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What does each of the [y,n,q,a,d,/,K,j,J,g,e,?] stand for in context of git -p\nWhen using -p mode of git add -p or git stash -p what does each of the letters stand for?\nI'm guessing y is yes and n is no. What are the rest?\n\n[y,n,q,a,d,/,K,j,J,g,e,?]" }, { "role": "assistant", "content": "The -p mode means patch, the help for which is hard-ish to find, but if you check git add --help you'll find the following\n patch\n This lets you choose one path out of a status like selection. After choosing the path, it presents the diff between the index and the working tree file and asks you if you want to stage the change of each hunk. You can select one of the following options and type return:\n\n y - stage this hunk\n n - do not stage this hunk\n q - quit; do not stage this hunk nor any of the remaining ones\n a - stage this hunk and all later hunks in the file\n d - do not stage this hunk nor any of the later hunks in the file\n g - select a hunk to go to\n / - search for a hunk matching the given regex\n j - leave this hunk undecided, see next undecided hunk\n J - leave this hunk undecided, see next hunk\n k - leave this hunk undecided, see previous undecided hunk\n K - leave this hunk undecided, see previous hunk\n s - split the current hunk into smaller hunks\n e - manually edit the current hunk\n ? - print help" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Continuous Deployment of a Node.js app to Heroku using GitLab\n\nThere are tutorials covering the deployment of Ruby and Python apps but I can't find good documentation or examples for NodeJS. \nhttp://docs.gitlab.com/ce/ci/examples/test-and-deploy-python-application-to-heroku.html\nhttp://docs.gitlab.com/ce/ci/examples/test-and-deploy-ruby-application-to-heroku.html\nDoes anyone have a .gitlab-ci.yml to share?" }, { "role": "assistant", "content": "create a project \n\n npm init -y\n npm i #install dependencies \n\n\nadd the following lines in package.json\n\n \"engines\": {\n \"node\": \"8.12.0\", //node version\n \"npm\": \"6.4.1\" //npm version\n },\n \"scripts\": {\n \"start\": \"node app.js\", //heroku will using the following script to run node app\n }\n\n\ncreate a heroku project\n\nselect NEW -> Create new app\nset the App name & choose a region\nclick on Create app\n\nGitlab setup create new repo or add to exist project given on gitlab website\ncreate a .gitlab-ci.yml file\nimage: node:latest\nstages:\n- production\nproduction:\ntype: deploy\nstage: production\nimage: ruby:latest\nscript:\n - apt-get update -qy\n - apt-get install -y ruby-dev\n - gem install dpl\n - dpl --provider=heroku --app=APPNAME_OF_Heroku App --api-key=$HEROKU_API_KEY # security add the heroku api to CI/CD setting\nonly:\n - master #branch name to deploy on heroku\n\n\nSetting HEROKU_API_KEY\n\nSetting -> CI/CD -> Variable -> Expand\nInput Variable key -> variable name in .gitlab-ci.yml\nInput Variable value -> Heroku Api Key\n\nGet the Heroku Api Key \n\nHeroki Dashborad -> Account Settings \n\nset the Runner on Gitlab\n\nSetting -> CI/CD -> Variable -> Expand\n\n\nSpecific Runners\n\n\nInstall the gitlab-runner \nWindows\nLinux\nMacOS\nFor setup steps here\n\nShared Runners\n\n\njust click Disable shared Runners to enable the shared runner \n\n\n\npush the files to gitlab it will automatically deploy on heroku \ngit add . #to add all the files)\ngit commit -m \"message\" #to commit files\ngit push origin master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options core.fsmonitor" }, { "role": "assistant", "content": "If set to true, enable the built-in file system monitor\ndaemon for this working directory ( git-fsmonitor--daemon ). Like hook-based file system monitors, the built-in file system monitor\ncan speed up Git commands that need to refresh the Git index\n(e.g. git status ) in a working directory with many files. The\nbuilt-in monitor eliminates the need to install and maintain an\nexternal third-party tool. The built-in file system monitor is currently available only on a\nlimited set of supported platforms. Currently, this includes Windows\nand MacOS. Otherwise, this variable contains the pathname of the \"fsmonitor\"\nhook command. This hook command is used to identify all files that may have changed\nsince the requested date/time. This information is used to speed up\ngit by avoiding unnecessary scanning of files that have not changed. See the \"fsmonitor-watchman\" section of githooks . Note that if you concurrently use multiple versions of Git, such\nas one version on the command line and another version in an IDE\ntool, that the definition of core.fsmonitor was extended to\nallow boolean values in addition to hook pathnames. Git versions\n2.35.1 and prior will not understand the boolean values and will\nconsider the \"true\" or \"false\" values as hook pathnames to be\ninvoked. Git versions 2.26 thru 2.35.1 default to hook protocol\nV2 and will fall back to no fsmonitor (full scan). Git versions\nprior to 2.26 default to hook protocol V1 and will silently\nassume there were no changes to report (no scan), so status\ncommands may report incomplete results. For this reason, it is\nbest to upgrade all of your Git versions before using the built-in\nfile system monitor." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git rebase merge conflict\nI forked a github repo and worked on my github repo.\nI have made pull-requests and it was completed. \nAfter that the upstream had some more commits so now I want to rebase, I guess thats what I have to do.\nBut I'm getting these merge conflicts:\nFirst, rewinding head to replay your work on top of it...\nApplying: Issue 135 homepage refresh\nUsing index info to reconstruct a base tree...\n<stdin>:17: trailing whitespace.\n %h4 \nwarning: 1 line adds whitespace errors.\nFalling back to patching base and 3-way merge...\nAuto-merging app/views/layouts/application.html.haml\nCONFLICT (content): Merge conflict in app/views/layouts/application.html.haml\nAuto-merging app/views/home/index.html.haml\nCONFLICT (content): Merge conflict in app/views/home/index.html.haml\nAuto-merging app/views/home/_group_projects.html.haml\nCONFLICT (content): Merge conflict in app/views/home/_group_projects.html.haml\nFailed to merge in the changes.\nPatch failed at 0001 Issue 135 homepage refresh\n\nWhen you have resolved this problem run \"git rebase --continue\".\nIf you would prefer to skip this patch, instead run \"git rebase --skip\".\nTo check out the original branch and stop rebasing run \"git rebase --abort\".\n\nI don't know how to fix these, please help." }, { "role": "assistant", "content": "Rebasing can be a real headache. You have to resolve the merge conflicts and continue rebasing. For example you can use the merge tool (which differs depending on your settings)\ngit mergetool\n\nThen add your changes and go on\ngit rebase --continue\n\nGood luck" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Distributing git configuration with the code\nIn trying to standardise the platform for the developers, one of my needs would be to commit the .git/config so that everybody have the same CRLF config without forgetting to set it by hand.\nHow do I set this up?\nI'm a bit concerned by all this negativity against autocrlf. Why not remove this feature if it doesn't work? Either the makers of this feature are misunderstood or they made a failed experiment with it and it should be removed to stop more people from wasting their time (reading the obscure man page, asking questions, people answering those questions etc.)." }, { "role": "assistant", "content": "I have always found the autocrlf config property problematic.\n(as expressed in my answer Git 1.6.4 beta on Windows (msysgit) - Unix or DOS line termination)\n\nit not only make some merges tricky\nit can vary depending on the shell used within one environment\nit also has issue with git status\nand with svn import.\n\nNote: msysgit issue 538 advocated for setting it to false by default, instead of true (which is the default value set by the msysgit installer of the time -- 2010!), but I am not convinced.\nI would prefer one of the three following solutions for:\n\nconfiguring one end-of-line style\nmaking that configuration propagate through the different Git repos\n\nFirst: git config --global core.autocrlf false\nThen:\n1. Using the new config setting core.eol (1.7.2+)\n\nSets the line ending type to use in the working directory for files that have the text property set.\nAlternatives are 'lf', 'crlf' and 'native', which uses the platform's native line ending.\nThe default value is native.\n\n2. a checkout/checking .gitattribute.\nSee gitattributes man page:\ncrlf or core.autocrlf is the way to record in a .gitattributes file what is was previously a local config attribute.\nYou can add checkout/checkin attributes like:\n*.vcproj text eol=crlf\n*.sh text eol=lf\n\n3. a git attribute filter driver which can:\n\nenforce any kind of formatting standard you may want to set\napply those standards to certain files/directories\nbe recorded as a config file (.gitattributes) able to be pushed anywhere." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to git pull from public repo via ssh without a key?\n\nI have a public repo, https://github.com/rlpowell/config . I used to be able to run git pull without any ssh keys (i.e. from cron), and it work work fine, using the [email protected]:rlpowell/config.git URL (i.e. the SSH URL). This no longer works, and I've no idea why, but it does work for two of my friends.\nI would like to be able to git pull a public repo without an ssh key, or at least understand why it doesn't work for me and does for other people.\nHere's a friend trying my test case:\n$ git clone [email protected]:rlpowell/config.git ; cd config ; (unset SSH_AUTH_SOCK ; ssh-add -l ; git pull )\nCloning into 'config'...\nWarning: Permanently added the RSA host key for IP address '192.30.253.113' to the list of known hosts.\nremote: Counting objects: 1061, done.\nremote: Total 1061 (delta 0), reused 0 (delta 0), pack-reused 1061\nReceiving objects: 100% (1061/1061), 544.42 KiB | 495.00 KiB/s, done.\nResolving deltas: 100% (632/632), done.\nChecking connectivity... done.\nCould not open a connection to your authentication agent.\nAlready up-to-date.\n\nAnd here's me doing exactly the same thing:\n$ git clone [email protected]:rlpowell/config.git ; cd config ; (unset SSH_AUTH_SOCK ; ssh-add -l ; git pull )\nCloning into 'config'...\nremote: Counting objects: 1061, done.\nremote: Total 1061 (delta 0), reused 0 (delta 0), pack-reused 1061\nReceiving objects: 100% (1061/1061), 544.42 KiB | 0 bytes/s, done.\nResolving deltas: 100% (632/632), done.\nChecking connectivity... done.\nCould not open a connection to your authentication agent.\nEnter passphrase for key '/home/rlpowell/.ssh/id_rsa':\nPermission denied (publickey).\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\n(I hit enter at the ssh key password prompt).\nIn the repo, the .git/config is:\n[core]\n repositoryformatversion = 0\n filemode = true\n bare = false\n logallrefupdates = true\n[remote \"origin\"]\n url = [email protected]:rlpowell/config.git\n fetch = +refs/heads/*:refs/remotes/origin/*\n[branch \"master\"]\n remote = origin\n merge = refs/heads/master\n\nAnd git config -l is:\n$ git config -l\n[email protected]\nuser.name=Robin Lee Powell\npush.default=matching\ncore.repositoryformatversion=0\ncore.filemode=true\ncore.bare=false\ncore.logallrefupdates=true\n[email protected]:rlpowell/config.git\nremote.origin.fetch=+refs/heads/*:refs/remotes/origin/*\nbranch.master.remote=origin\nbranch.master.merge=refs/heads/master\n\ngit version is 2.5.5\nstrace says the thing actually running ssh is\nssh [email protected] git-upload-pack 'rlpowell/config.git'" }, { "role": "assistant", "content": "I just tried it without key, and I confirm it cannot work (without SSH key):\n$ git clone [email protected]:rlpowell/config.git\nCloning into 'config'...\nPermission denied (publickey).\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\nThat is because GitHub won't authorize anonymous access through SSH (as opposed to https), as other git repo servers decided to do (like Gogits or go-gitea)\nGitHub does mention:\n\nSSH URLs provide access to a Git repository via SSH, a secure protocol.\n To use these URLs, you must generate an SSH keypair on your computer and add the public key to your GitHub account.\n\n(emphasis on must)\nWhy? (asked in 2015). While sshd can be configured to allow anonymous access, no public site would ever consider setting this up: it is too big of a security risk.\n\nneeds to work without a specific key\n\nIf you need anonymous access, you can use:\n\nan https URL\na git URL: git://github.com/<user>/<repo>, although it uses the port 9418, which is often blocked in an enterprise environment." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs -R" }, { "role": "assistant", "content": "Swap two inputs; that is, show differences from index or\non-disk file to tree contents." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc files" }, { "role": "assistant", "content": "Compute the dirstat numbers by counting the number of files changed.\nEach changed file counts equally in the dirstat analysis. This is\nthe computationally cheapest --dirstat behavior, since it does\nnot have to look at the file contents at all." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to get the changes on a branch in Git\nWhat is the best way to get a log of commits on a branch since the time it was branched from the current branch? My solution so far is:\ngit log $(git merge-base HEAD branch)..branch\n\nThe documentation for git-diff indicates that git diff A...B is equivalent to git diff $(git-merge-base A B) B. On the other hand, the documentation for git-rev-parse indicates that r1...r2 is defined as r1 r2 --not $(git merge-base --all r1 r2).\nWhy are these different? Note that git diff HEAD...branch gives me the diffs I want, but the corresponding git log command gives me more than what I want.\nIn pictures, suppose this:\n\n x---y---z---branch\n /\n---a---b---c---d---e---HEAD\n\nI would like to get a log containing commits x, y, z.\n\ngit diff HEAD...branch gives these commits\nhowever, git log HEAD...branch gives x, y, z, c, d, e." }, { "role": "assistant", "content": "In the context of a revision list, A...B is how git-rev-parse defines it. git-log takes a revision list. git-diff does not take a list of revisions - it takes one or two revisions, and has defined the A...B syntax to mean how it's defined in the git-diff manpage. If git-diff did not explicitly define A...B, then that syntax would be invalid. Note that the git-rev-parse manpage describes A...B in the \"Specifying Ranges\" section, and everything in that section is only valid in situations where a revision range is valid (i.e. when a revision list is desired).\nTo get a log containing just x, y, and z, try git log HEAD..branch (two dots, not three). This is identical to git log branch --not HEAD, and means all commits on branch that aren't on HEAD." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I move a single directory from a git repository to a new repository whilst maintaining the history?\nI have inherited a git repository containing multiple projects in separate directories. I'd like to split the repository into new individual repositories, one for each project and then have the master repository contain the projects as submodules. I'd like to do all this whilst maintaining the revision history of the individual projects if possible.\nI could clone the repository for each project and remove all the other projects each time, but it there a better way to avoid having the cloned history in each new project repository?" }, { "role": "assistant", "content": "You can use git filter-branch to rewrite the history of a project. From the documentation:\n\nTo rewrite the repository to look as\n if foodir/ had been its project root,\n and discard all other history:\ngit filter-branch --subdirectory-filter foodir -- --all\n\n\nMake several copies of your repo, do that for each subdirectory you want to split out, and you should wind up with what you're looking for." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Change a branch name in a Git repo\nHow do I rename an existing branch in a Git repo?\nI want the current branch to have a new name." }, { "role": "assistant", "content": "Assuming you're currently on the branch you want to rename:\ngit branch -m newname\n\nThis is documented in the manual for git-branch, which you can view using\nman git-branch\n\nor\ngit help branch\n\nSpecifically, the command is\ngit branch (-m | -M) [<oldbranch>] <newbranch>\n\nwhere the parameters are:\n <oldbranch>\n The name of an existing branch to rename.\n\n <newbranch>\n The new name for an existing branch. The same restrictions as for <branchname> apply.\n\n<oldbranch> is optional, if you want to rename the current branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Publish Jenkins Job build status to Gitlab commit with Jenkins Pipeline job\n\nI have integrated my Gitlab CE version 9.3.5 with jenkins version 2.60.1 . \nI am able to trigger builds with Gitlab webhook and publish the result back to the commit with a jenkins freestyle job. \nI was wondering how can i achieve the same with jenkins pipeline job as every article on the above integration works with jenkins freestyle job." }, { "role": "assistant", "content": "If I follow the documentation about the Gitlab Jenkins plugin, you should be able to use the gitlabCommitStatus method which will publish the status of the build steps declared after (here is an example from the doc) : \nnode() {\n stage 'Checkout'\n checkout <your-scm-config>\n\n gitlabCommitStatus {\n <script that builds, tests, etc. your project>\n }\n}\n\nIf this is not enough, you also have the possibility to use updateGitlabCommitStatus name: 'build', state: 'pending' to control more precisely which state you're sending to the gitlab instance." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-grep - Print lines matching a pattern --" }, { "role": "assistant", "content": "Signals the end of options; the rest of the parameters\nare <pathspec> limiters." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can I get a patch-compatible output from git-diff?\nI am doing something very simple wrong. I'm trying to prepare an ordinary patch file, so I can reapply some changes:\n$ git diff > before\n$ git diff something_here > save.patch\n$ git checkout . \n$ patch < save.patch\n$ git diff > after\n$ diff before after\n$\n\nWith something_here blank it almost works, but the file names aren't right. I think I'm just I'm missing some option.\nIn real life, I am going to do a merge after the checkout, so the patch might fail there, but you see what I'm getting at.\nEdit\nMy fault here for asking the wrong question. The actual question is, I want to save my changes away, do a merge, then re-apply the changes, if possible? I asked it the wrong way because I am used to using patch to solve these sorts of problems and git diff looked like that's what it wanted me to do.\nCharles Bailey's comment had the right answer. For me, git-apply is the right thing to do (git-stash looks more heavy-weight than I need and rebasing and bundles is definitely beyond my current skill level.) I'm going to accept the answer Charles gave (because you can't accept a comment). Thanks for all the suggestions.\nEdit, 6 years later\nAs anyone familiar with the subject knows, I over-estimated the difficulty of git stash. Pretty much every day or so, I will use the following sequence:\n$ git stash\n$ git merge\n$ git stash pop\n\nEdit, 5 years further down the road I have largely abandoned git apply and don’t even used git stash much. git rebase FTW." }, { "role": "assistant", "content": "Just use -p1: you will need to use -p0 in the --no-prefix case anyway, so you can just leave out the --no-prefix and use -p1:\n$ git diff > save.patch\n$ patch -p1 < save.patch\n\n$ git diff --no-prefix > save.patch\n$ patch -p0 < save.patch" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitignore all folders beginning with a period\nI want to use a .gitignore file to ignore all folders beginning with a period (hidden folders of linux). \nI can't figure out the syntax, though I'm sure it's simple.\nHow's it done?" }, { "role": "assistant", "content": "Use one of these patterns:\n# ignore all . files but include . folders\n.*\n!.*/\n\n\n# ignore all . files and . folders\n.*\n\n# Dont ignore .gitignore (this file)\n# This is just for verbosity, you can leave it out if\n# .gitignore is already tracked or if you use -f to\n# force-add it if you just created it\n!/.gitignore\n\n\n# ignore all . folders but include . files\n.*/\n\n\nWhat is this pattern?\n.*\n- This patter tells git to ignore all the files which starts with .\n! - This tells git not to ignore the pattern. In your case /.gitignore\nA demo can be found in this answer:\nGit: how to ignore hidden files / dot files / files with empty file names via .gitignore?" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --ext-diff" }, { "role": "assistant", "content": "Allow an external diff helper to be executed. If you set an\nexternal diff driver with gitattributes , you need\nto use this option with git-log and friends." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Cloning a repo from someone else's Github and pushing it to a repo on my Github\n\nI cloned the repo at https://github.com/railstutorial/sample_app_rails_4 and made a lot of changes to it (I used it as a starting point for my own app), and now I would like to push the changed app to a repo on my own github account. \nHow can I change what github repo it is linked to?" }, { "role": "assistant", "content": "As Deefour says, your situation isn't much unlike the one in Change the URI (URL) for a remote Git repository. When you clone a repository, it is added as a remote of yours, under the name origin. What you need to do now (as you're not using the old source anymore) is change origin's URL:\n$ git remote set-url origin http://github.com/YOU/YOUR_REPO\n\nIf the original repository would update often and you want to get those updates from time to time, then instead of editing origin it would be best to add a new remote:\n$ git remote add personal http://github.com/YOU/YOUR_REPO\n\nOr maybe even call the old one upstream:\n$ git remote rename origin upstream\n$ git remote add origin http://github.com/YOU/YOUR_REPO\n\nThen, whenever you want to get changes from upstream, you can do:\n$ git fetch upstream\n\nAs this the source is a sample repository (seems to be kind of a template to start off), I don't think there's a need to keep it nor fork it at all - I'll go with the first alternative here." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-add" }, { "role": "assistant", "content": "Add file contents to the index" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Pull-Request for only certain files/commits\n\nI have a repository that is forked from GitHub that has a few modifications made to it. However, in a certain commit, a few files were changed that I want to submit a pull-request for, leaving the other modified files out of the request.\nDo pull requests merge all commits, or do I need to do something special to isolate this commit?" }, { "role": "assistant", "content": "A pull request being made of whole commits, you need to split this commit into two separate commits one containing the change to put in the pull request, and the other holding the other changes. To do this you need git rebase -i, see for example How can I split up a Git commit buried in history? for a good explanation on how to do it.\nOnce you have split the commit, move the ones you want to include into a topic branch, see for example How to move certain commits to another branch in git?, but it depends if the commits that make your pull request are sequential.\nThen finally you can push to Github and create the pull request from your topic branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-reflog" }, { "role": "assistant", "content": "Manage reflog information" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to compare two revisions in Bitbucket?\nMy team is using Bitbucket for our git repository and we've recently starting using the pull request functionality for code reviews. It works fine on the first review, but if it goes through multiple iterations (that is, changes are made and pull request updated), I would like to see a link with just the new changes that were made since the last code review.\nI looked into the \"compare\" functionality but the UI looks like it can only compare between branches. Is there a simple way to get a diff between two commits?" }, { "role": "assistant", "content": "This is just a slight modification to the answers already given but adding #diff to the end instead of #commits is usually what I'm looking for. Also as others may have mentioned the best results for me are usually obtained by placing the newer commit first and the older one second but that will depend on your particular needs.\nhttps://bitbucket.org/<OWNER>/<REPO>/branches/compare/<commit-hash>..<commit-hash-older>#diff" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options color.advice.hint" }, { "role": "assistant", "content": "Use customized color for hints." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitattributes - Defining attributes per path" }, { "role": "assistant", "content": "NAME gitattributes - Defining attributes per path" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Do GitHub and GitLab support git clone's --filter parameter?\n\nI want to use git's partialClone feature. In this answer I saw the git clone --filter=tree:none <repo> command.\nBut when trying to execute on github, the prompt warning: filtering not recognized by server, ignoring. It did not work.\nI want to know if it is not supported by the GitHub website, or if there is a problem with my settings.\nI asked the feedback staff of GitHub and have not got the answer from the technician." }, { "role": "assistant", "content": "This almost certainly isn't supported by GitHub or GitLab yet.\nThe --filter option is under active development and isn't really ready for general-purpose consumption yet. GitHub's blog post about the release of Git 2.19 in September, 2018 says\n\nNote that most public servers do not yet support the feature, but you can play with git clone --filter=blob:none against your local Git 2.19 install.\n\nOnce this feature becomes more fully-developed and hosts start to support it I'm sure they won't do so quietly. As far as I know, no major cloud provider has made such an announcement yet.\nUpdate from OP 2019-03-21:\n\nNot long ago, I received an official reply from github. They think that the --filter parameter is still an immature feature and is accompanied by some security issues. Therefore, this feature will not be supported in the short term." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --no-abbrev-commit" }, { "role": "assistant", "content": "Show the full 40-byte hexadecimal commit object name. This negates --abbrev-commit , either explicit or implied by other options such\nas \"--oneline\". It also overrides the log.abbrevCommit variable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git status shows files as changed even though contents are the same\nI received a git checkout from someone else and am trying to commit the unstaged changes to the local repository. However, a lot (if not every) file appears as modified even though the contents are exactly the same.\nI already set core.fileMode to false and also set core.autocrlf to false, without success.\nWorth mentioning is that the Git repo I received was from someone using Windows, while I use Linux.\nWhat can I do to commit the actual changes?\nEDIT: output of git config -l:\nuser.name=Aron Rotteveel\nuser.email=<removed>\ncolor.diff=auto\ncolor.status=auto\ncolor.branch=auto\ncolor.interactive=auto\ncolor.ui=true\ncolor.pager=true\ncolor.branch.current=yellow reverse\ncolor.branch.local=yellow\ncolor.branch.remote=green\ncolor.diff.meta=yellow bold\ncolor.diff.frag=magenta bold\ncolor.diff.old=red bold\ncolor.diff.new=green bold\ncolor.status.added=yellow\ncolor.status.changed=green\ncolor.status.untracked=cyan\ncore.pager=less -FRSX\ncore.whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol\nalias.co=checkout\ncore.repositoryformatversion=0\ncore.filemode=false\ncore.bare=false\ncore.logallrefupdates=true\ncore.symlinks=false\ncore.ignorecase=true\ncore.hidedotfiles=dotGitOnly\ncore.autocrlf=false\nremote.origin.url=<removed>\nremote.origin.fetch=+refs/heads/*:refs/remotes/origin/*\n\nUpdate: added some random example files. These files are just plaintext, so are the easiest to include.\nOriginal files are located here: https://gist.github.com/c3c5302430935155ef3d. Hexdumps definitely indicate that the files are different, but I have no clue what causes this, and how to fix it.\nHEAD version:\n0000000: 4854 4d4c 2e53 6166 654f 626a 6563 740d HTML.SafeObject.\n0000010: 0a54 5950 453a 2062 6f6f 6c0d 0a56 4552 .TYPE: bool..VER\n0000020: 5349 4f4e 3a20 332e 312e 310d 0a44 4546 SION: 3.1.1..DEF\n0000030: 4155 4c54 3a20 6661 6c73 650d 0a2d 2d44 AULT: false..--D\n0000040: 4553 4352 4950 5449 4f4e 2d2d 0d0a 3c70 ESCRIPTION--..<p\n0000050: 3e0d 0a20 2020 2057 6865 7468 6572 206f >.. Whether o\n0000060: 7220 6e6f 7420 746f 2070 6572 6d69 7420 r not to permit \n0000070: 6f62 6a65 6374 2074 6167 7320 696e 2064 object tags in d\n0000080: 6f63 756d 656e 7473 2c20 7769 7468 2061 ocuments, with a\n0000090: 206e 756d 6265 7220 6f66 2065 7874 7261 number of extra\n00000a0: 0d0a 2020 2020 7365 6375 7269 7479 2066 .. security f\n00000b0: 6561 7475 7265 7320 6164 6465 6420 746f eatures added to\n00000c0: 2070 7265 7665 6e74 2073 6372 6970 7420 prevent script \n00000d0: 6578 6563 7574 696f 6e2e 2054 6869 7320 execution. This \n00000e0: 6973 2073 696d 696c 6172 2074 6f0d 0a20 is similar to.. \n00000f0: 2020 2077 6861 7420 7765 6273 6974 6573 what websites\n0000100: 206c 696b 6520 4d79 5370 6163 6520 646f like MySpace do\n0000110: 2074 6f20 6f62 6a65 6374 2074 6167 732e to object tags.\n0000120: 2020 596f 7520 7368 6f75 6c64 2061 6c73 You should als\n0000130: 6f20 656e 6162 6c65 0d0a 2020 2020 254f o enable.. %O\n0000140: 7574 7075 742e 466c 6173 6843 6f6d 7061 utput.FlashCompa\n0000150: 7420 696e 206f 7264 6572 2074 6f20 6765 t in order to ge\n0000160: 6e65 7261 7465 2049 6e74 6572 6e65 7420 nerate Internet \n0000170: 4578 706c 6f72 6572 0d0a 2020 2020 636f Explorer.. co\n0000180: 6d70 6174 6962 696c 6974 7920 636f 6465 mpatibility code\n0000190: 2066 6f72 2079 6f75 7220 6f62 6a65 6374 for your object\n00001a0: 2074 6167 732e 0d0a 3c2f 703e 0d0a 2d2d tags...</p>..--\n00001b0: 2320 7669 6d3a 2065 7420 7377 3d34 2073 # vim: et sw=4 s\n00001c0: 7473 3d34 0d0a ts=4..\n\nCopied version:\n0000000: 4854 4d4c 2e53 6166 654f 626a 6563 740a HTML.SafeObject.\n0000010: 5459 5045 3a20 626f 6f6c 0a56 4552 5349 TYPE: bool.VERSI\n0000020: 4f4e 3a20 332e 312e 310a 4445 4641 554c ON: 3.1.1.DEFAUL\n0000030: 543a 2066 616c 7365 0a2d 2d44 4553 4352 T: false.--DESCR\n0000040: 4950 5449 4f4e 2d2d 0a3c 703e 0a20 2020 IPTION--.<p>. \n0000050: 2057 6865 7468 6572 206f 7220 6e6f 7420 Whether or not \n0000060: 746f 2070 6572 6d69 7420 6f62 6a65 6374 to permit object\n0000070: 2074 6167 7320 696e 2064 6f63 756d 656e tags in documen\n0000080: 7473 2c20 7769 7468 2061 206e 756d 6265 ts, with a numbe\n0000090: 7220 6f66 2065 7874 7261 0a20 2020 2073 r of extra. s\n00000a0: 6563 7572 6974 7920 6665 6174 7572 6573 ecurity features\n00000b0: 2061 6464 6564 2074 6f20 7072 6576 656e added to preven\n00000c0: 7420 7363 7269 7074 2065 7865 6375 7469 t script executi\n00000d0: 6f6e 2e20 5468 6973 2069 7320 7369 6d69 on. This is simi\n00000e0: 6c61 7220 746f 0a20 2020 2077 6861 7420 lar to. what \n00000f0: 7765 6273 6974 6573 206c 696b 6520 4d79 websites like My\n0000100: 5370 6163 6520 646f 2074 6f20 6f62 6a65 Space do to obje\n0000110: 6374 2074 6167 732e 2020 596f 7520 7368 ct tags. You sh\n0000120: 6f75 6c64 2061 6c73 6f20 656e 6162 6c65 ould also enable\n0000130: 0a20 2020 2025 4f75 7470 7574 2e46 6c61 . %Output.Fla\n0000140: 7368 436f 6d70 6174 2069 6e20 6f72 6465 shCompat in orde\n0000150: 7220 746f 2067 656e 6572 6174 6520 496e r to generate In\n0000160: 7465 726e 6574 2045 7870 6c6f 7265 720a ternet Explorer.\n0000170: 2020 2020 636f 6d70 6174 6962 696c 6974 compatibilit\n0000180: 7920 636f 6465 2066 6f72 2079 6f75 7220 y code for your \n0000190: 6f62 6a65 6374 2074 6167 732e 0a3c 2f70 object tags..</p\n00001a0: 3e0a 2d2d 2320 7669 6d3a 2065 7420 7377 >.--# vim: et sw\n00001b0: 3d34 2073 7473 3d34 0a =4 sts=4." }, { "role": "assistant", "content": "Have you changed the mode of the files?\nI did it on my machine and the local dev machine had 777 given to all the files whereas the repo had 755 which showed every file as modified. I did git diff and it showed the old mode and new mode are different.\nIf that is the problem then you can easily ignore them by\ngit config core.filemode false" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to disable pull requests in GitHub?\nI am trying to understand how will I be able to disable \"pull requests\" in github.\nQuestion 1: \nWe are trying to use the rebase workflow and that means using pull requests can be harmful if that isn't a fast forward push.\nOne Solution: Setup branch permissions for the branches where I want to disable pull request. Or add me as the reviewer to anything that goes into master. \nQuestion 2:\nSo that begs the question, can I setup branch permissions in github ?? Can I add myself as a reviewer for any change that wants to get into master ?\nQuestion 3:\nGithub has definitely removed pre-receive hooks, so how can I do any enforcements before the source hits the server ? pre-commit hooks can be done, but at the same time can be pain. \nI had asked a similar question here: Commit message hook on github\nIt seems github could be useful for the merge workflow or even git-flow, but it can be hard to maintain for the rebase workflow, is that a fair assumption ? \nCan I consider atlassian Stash as a better tool for the rebase workflow ?" }, { "role": "assistant", "content": "It is not possible according to GitHub support\nI asked support [email protected] on February 2018 if it was possible to remove the Pull Requests tab, and the reply from @nickcannariato was:\n\nThanks for writing in! We've definitely heard some users requesting this feature over the last couple of years, and it's currently on our feature request list. I can't make any promises about if or when we may add this ability in the future, but I'll add your +1 to that feature request so the team can see it.\n\nconfirming that it is not possible.\nRequest on the de-facto trackers:\n\nhttps://github.com/isaacs/github/issues/1191\nhttps://github.com/dear-github/dear-github/issues/84" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-count-objects - Count unpacked number of objects and their disk consumption -v --verbose" }, { "role": "assistant", "content": "Provide more detailed reports: count: the number of loose objects size: disk space consumed by loose objects, in KiB (unless -H is specified) in-pack: the number of in-pack objects size-pack: disk space consumed by the packs, in KiB (unless -H is specified) prune-packable: the number of loose objects that are also present in\nthe packs. These objects could be pruned using git prune-packed . garbage: the number of files in the object database that are neither valid loose\nobjects nor valid packs size-garbage: disk space consumed by garbage files, in KiB (unless -H is\nspecified) alternate: absolute path of alternate object databases; may appear\nmultiple times, one line per path. Note that if the path contains\nnon-printable characters, it may be surrounded by double-quotes and\ncontain C-style backslashed escape sequences." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --expand-tabs=<n> --expand-tabs --no-expand-tabs" }, { "role": "assistant", "content": "Perform a tab expansion (replace each tab with enough spaces\nto fill to the next display column that is a multiple of <n> )\nin the log message before showing it in the output. --expand-tabs is a short-hand for --expand-tabs=8 , and --no-expand-tabs is a short-hand for --expand-tabs=0 ,\nwhich disables tab expansion. By default, tabs are expanded in pretty formats that indent the log\nmessage by 4 spaces (i.e. medium , which is the default, full ,\nand fuller )." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git Skip \"branches\" and \"tags\" of first level directories" }, { "role": "assistant", "content": "--ignore-paths=\"^[^/]+/(?:branches|tags)\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-update-index - Register file contents in the working tree to the index --index-info" }, { "role": "assistant", "content": "Read index information from stdin." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --no-renames" }, { "role": "assistant", "content": "Turn off rename detection, even when the configuration\nfile gives the default to do so." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.colorMovedWS" }, { "role": "assistant", "content": "When moved lines are colored using e.g. the diff.colorMoved setting,\nthis option controls the <mode> how spaces are treated.\nFor details of valid modes see --color-moved-ws in git-diff ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker -P --no-pager" }, { "role": "assistant", "content": "Do not pipe Git output into a pager." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_SSH GIT_SSH_COMMAND" }, { "role": "assistant", "content": "If either of these environment variables is set then git fetch and git push will use the specified command instead of ssh when they need to connect to a remote system.\nThe command-line parameters passed to the configured command are\ndetermined by the ssh variant. See ssh.variant option in git-config for details. $GIT_SSH_COMMAND takes precedence over $GIT_SSH , and is interpreted\nby the shell, which allows additional arguments to be included. $GIT_SSH on the other hand must be just the path to a program\n(which can be a wrapper shell script, if additional arguments are\nneeded). Usually it is easier to configure any desired options through your\npersonal .ssh/config file. Please consult your ssh documentation\nfor further details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Correct Git workflow for shared feature branch?\nI am trying to figure out the right workflow for this situation:\nOn the shared repo, we have these branches:\n-master\n-feature\n\nThe feature branch is a shared branch, since many developers are working on a new feature together. They are actively pushing their changes to the feature branch.\nI'm trying to avoid 'conflict hell' for the day that feature finally gets merged back into master. Currently, I see some options:\n1) Actively merge master into feature, and do it often. However, this is not recommended in the git docs, and I'm starting to see why. When I try this, I seem to fix the same conflicts over and over again.\n2) Use rebase in some way. I've read up on this, but it looks like it wont work since the feature branch is actually shared. All it takes is one developer to do 2 rebases, and other developers could have conflicts from mismatched history.\n3) Turn the feature branch into an integration branch, and have the developers use their own independent feature branches with rebasing to keep things sane. \n4) Something completely different?" }, { "role": "assistant", "content": "For a shared branch, I would go with #3, and use it as an \"integration\" branch to consolidate their work.\nThe developers would have to use rebase to constantly replay their private branch on top of feature before merging back their work to feature, that way they are:\n\nsolving any merge conflict locally (in their own repo)\nmaking the final merge (from their private branch to feature) a trivial one (normally fast-forward)\n\n(as described in \"git rebase vs. merge\" answer)\nThe idea is that, once feature branch has to be merged in master, no more contribution is accepted on feature (the branch is \"frozen\"), and you can safely rebase it on top of master first, or merge it directly to master.\nAnd then you start a new feature branch (which can actually start in parallel of the previous feature branch if needed)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to give user level access to private GitLab repository?\nI have a private repository in GitLab. I have to give its access to members of my team. How can I do that using GitLab web-interface?\nI know, how to do this in GitHub, but in GitLab it's somehow different." }, { "role": "assistant", "content": "Update 2021: This answer is out of date, scroll down for the 2021 info.\nUPDATE: Gitlab has changed a bit in 2 years, so here is the updated flow.\n\nClick on the project that you want to share.\nClick on the Settings tab (the gear icon on the left).\nClick on the Members subtab.\nAdd member, and find the user if it exists on GitLab, or insert\nemail to send an invitation.\nSelect access level for the user, the possible levels are:\n\n\nGuest, can see wiki pages, view and create issues.\nReporter, can do what the guest can plus view the code.\nDeveloper, normal developer access, can develop, but cannot push or merge to procted branches by default.\nMaintainer, can do everything except managing the project.\n\n\nFor more info about the user access level refer to gitlab official help.\n(Optional) Set expiration date of the user access.\n\n\nOld instructions:\n\nClick on the project that you want to share.\nClick on members.\nAdd member, and find the user if it exists on GitLab, or insert\nemail to send an invitation." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_CONFIG_GLOBAL GIT_CONFIG_SYSTEM" }, { "role": "assistant", "content": "Take the configuration from the given files instead from global or\nsystem-level configuration files. If GIT_CONFIG_SYSTEM is set, the\nsystem config file defined at build time (usually /etc/gitconfig )\nwill not be read. Likewise, if GIT_CONFIG_GLOBAL is set, neither $HOME/.gitconfig nor $XDG_CONFIG_HOME/git/config will be read. Can\nbe set to /dev/null to skip reading configuration files of the\nrespective level." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-clone - Clone a repository into a new directory --dissociate" }, { "role": "assistant", "content": "Borrow the objects from reference repositories specified\nwith the --reference options only to reduce network\ntransfer, and stop borrowing from them after a clone is made\nby making necessary local copies of borrowed objects. This\noption can also be used when cloning locally from a\nrepository that already borrows objects from another\nrepository—​the new repository will borrow objects from the\nsame repository, and this option can be used to stop the\nborrowing." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options merge.defaultToUpstream" }, { "role": "assistant", "content": "If merge is called without any commit argument, merge the upstream\nbranches configured for the current branch by using their last\nobserved values stored in their remote-tracking branches.\nThe values of the branch.<current branch>.merge that name the\nbranches at the remote named by branch.<current branch>.remote are consulted, and then they are mapped via remote.<remote>.fetch to their corresponding remote-tracking branches, and the tips of\nthese tracking branches are merged. Defaults to true." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-bundle" }, { "role": "assistant", "content": "Move objects and refs by archive" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I split up a large Git branch into lots of smaller branches?\nI have imported from SVN into Git, now I have one big branch, like this:\n\nwork on feature C\nwork on feature B\nwork on feature C\nwork on feature C\nwork on feature B\nwork on feature A\n\nI want separate feature branches, for A, B, C. I'm cherry picking commits to new branches but this doesn't remove them from the original branch so I have to manually track which ones I have pulled out.\nThere are around 800 commits to split up, and maybe 50 features/bugfixes.\nIt would be nice to have the ones I have pulled out reflected this way somehow in the git log, so I know which ones I have already done. Is this possible?\nI can rebase the entire branch, skipping the commits I have pulled out, but I'm worried this will cause lots of conflicts. I don't want to resolve 500 conflicts every time I pull a commit out. \nWhat's the best method of pulling out commits from one uber branch onto smaller feature branches, whilst keeping track of your progress?" }, { "role": "assistant", "content": "What I do in this case is use interactive rebase.\nAt your HEAD, create your branches A, B, and C. Also create a \"backup\" branch (you could name it backup) in case things go wrong and you need your original HEAD back.\ngit branch feature-a\ngit branch feature-b\ngit branch feature-c\ngit branch backup-before-rebase\n\nThen, create a branch at the commit you want them to start from, maybe at a convenient stable commit. Call it new_trunk or something.\ngit checkout HEAD~50 ## this will be the new tree-trunk\ngit branch new_trunk\n\nThen, do interactive rebases and pick out the commits you want to keep in that branch. Used this way, it's basically like cherry-picking in bulk.\ngit checkout feature-a\ngit rebase -i new_trunk ## -i is for \"Interactive\"\n\nWhen you're done, you should have 3 branches with separate histories starting from new_trunk and a backup branch reflecting the old HEAD if you still need it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I delete unpushed git commits?\nI accidentally committed to the wrong branch.\nHow do I delete that commit?" }, { "role": "assistant", "content": "Delete the most recent commit, keeping the work you've done:\ngit reset --soft HEAD~1\n\nDelete the most recent commit, destroying the work you've done:\ngit reset --hard HEAD~1" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why put the _site-directory of a Jekyll site in .gitignore?\n\nThe documentation of Jekyll tells me, that the _site-directory of a Jekyll site contains the compiled version of the site I have created after running \nJekyll build\n\nSeveral articles recommend, that I include the _site-directory in my .gitignore-file because \"it just contains the compiled version of my site\". (that's what some articles recommend. So, I am not sure if I don't understand some concept of Jekyll or some concept of Git.\nIf the _site-directory contains the compiled version of a site, shouldn't that be the thing that is on the server the provides the final website? I do understand why you put source code on github and what to do with it, but in the case of github pages, Github is not a versioning system but a file hosting system and the file hosting system should host compiled versions of my work to provide it via MyUsername.github.io to users, right?\nMy question is: shouldn't it be only the _site-directory of my Jekyll website that I deploy to Github because that should be the compiled source code that github provides to users? So, shouldn't I put anything else in the .gitignore-file EXCEPT the _site-directory?\nIf I got this all wrong: what is the point in compiling my website via\nJekyll build\n\nif I don't use the compiled source code for anything?" }, { "role": "assistant", "content": "Two solutions :\nYou don't use Jekyll plugins (or only those supported by github pages)\nYou build your site only if you need to test it locally (jekyll build or jekyll serve). The generated code (in _site) will not be versioned as github pages will generate pages from the sources.\n\nPut _site to .gitignore\nPush you sources to github pages\n\nYou use Jekyll plugins\nIn this case, you need to build locally because Github pages cannot do the job with plugins.\n\nJekyll build locally\nPut _site to .gitignore\ncommit your sources in one branch\ncommit your _site in another branch\n\nSee this post for more explanations." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why should I use version control? [closed]\nClosed. This question is opinion-based. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it can be answered with facts and citations by editing this post.\n\n\nClosed 4 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI was reading a blog where the writer said this \n\n\"Code doesn’t exist unless it’s checked into a version control system. Use version control for everything you do. Any version control, SVN, Git, even CVS, master it and use it.\" \n\nI have never used any sort of version control and I do not find it that great. I have googled it and looked at it before, but I just need it put into children's terms if you will please. \nAs I understand it right now, things like SVN are for storing your code online for a group of users or other developers to have access to the same code. Once you update some code, you can submit the new version and the SVN will keep copies of old code as well as the new ones you update. \nIs this the basic idea of it or am I getting it completely wrong? \nIf I am right, then it might not be much use if I:\n\nDo not have other people working on the code.\nDo not plan on letting others have the code." }, { "role": "assistant", "content": "Have you ever:\n\nMade a change to code, realised it was a mistake and wanted to revert back?\nLost code or had a backup that was too old?\nHad to maintain multiple versions of a product?\nWanted to see the difference between two (or more) versions of your code?\nWanted to prove that a particular change broke or fixed a piece of code?\nWanted to review the history of some code?\nWanted to submit a change to someone else's code?\nWanted to share your code, or let other people work on your code?\nWanted to see how much work is being done, and where, when and by whom? \nWanted to experiment with a new feature without interfering with working code?\n\nIn these cases, and no doubt others, a version control system should make your life easier. \nTo misquote a friend: A civilised tool for a civilised age." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git tag" }, { "role": "assistant", "content": "Create a tag in the SVN repository. This is a shorthand for branch -t ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I get the latest version of my code?\nI'm using Git 1.7.4.1.\nI want to get the latest version of my code from the repository, but I'm getting errors:\n$ git pull\n….\nM selenium/ant/build.properties\n….\nM selenium/scripts/linux/get_latest_updates.sh\nM selenium/scripts/windows/start-selenium.bat\nPull is not possible because you have unmerged files.\nPlease, fix them up in the work tree, and then use 'git add/rm <file>' as appropriate to mark resolution, or use 'git commit -a'.\n\nI've deleted the local copies of the files the tool is complaining about, but I still get the errors.\nHow do I check out the latest version from the remote repository?" }, { "role": "assistant", "content": "If you don't care about any local changes (including untracked or generated files or subrepositories which just happen to be here) and just want a copy from the repo:\ngit reset --hard HEAD\ngit clean -xffd\ngit pull\n\nAgain, this will nuke any changes you've made locally so use carefully. Think about rm -Rf when doing this." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary checkout" }, { "role": "assistant", "content": "The action of updating all or part of the working tree with a tree object or blob from the object database , and updating the index and HEAD if the whole working tree has\nbeen pointed at a new branch ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to move the changes from one branch to another branch git?\nHow can I move my work and changes from the master branch to a newly created branch and leave the master branch intact after the move?" }, { "role": "assistant", "content": "If the changes are not commited.\nyou can stash the changes in the master branch .\ngit stash\n\nthen checkout the branch\ngit checkout -b newbranchname\n\nand pop the changes here\ngit stash pop\n\nIf the changes are commited :\nthen create a branch :\ngit checkout -b newbranch\n\ncheckout back to master branch:\ngit checkout master\n\nreset to previous commit :\ngit reset --hard head^1\n\nPS: This only works if no new files have been created and just the existing files are modified" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git - finding the SHA1 of an individual file in the index\nI've added a file to the 'index' with: \ngit add myfile.java\n\nHow do I find out the SHA1 of this file?" }, { "role": "assistant", "content": "It's an old question but one thing needs some clarification:\nThis question and the answers below talk about the Git hash of a file which is not exactly the same as \"the SHA1 of this file\" as asked in the question.\nIn short:\nIf you want to get the Git hash of the file in index - see\nthe answer by CB Bailey:\ngit ls-files -s $file\n\nIf you want to get the Git hash of any file on your filesystem - see\nthe answer by cnu:\ngit hash-object $file\n\nIf you want to get the Git hash of any file on your filesystem and you don't have Git installed:\n(echo -ne \"blob `wc -c < $file`\\0\"; cat $file) | sha1sum\n\n(The above shows how the Git hash is actually computed - it's not the sha1 sum of the file but a sha1 sum of the string \"blob SIZE\\0CONTENT\" where \"blob\" is literally a string \"blob\" (it is followed by a space), SIZE is the file size in bytes (an ASCII decimal), \"\\0\" is the null character and CONTENT is the actual file's content).\nIf you want to get just \"the SHA1 of this file\" as was literally asked in the question:\nsha1sum < $file\n\nIf you don't have sha1sum you can use shasum -a1 or openssl dgst -sha1 (with a slightly different output format)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs 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": "Change git email for previous commits\nSo I read a lot about how to change previous commit's email address but for some reason mine is not updating.\nI did like 40 commits to my private repo with my local email ([email protected]) which is bad since this email is not associated(and it can't be) with Github.\nI then remembered that I needed to set the git.config before and so I did:\n git config user.email \"[email protected]\"\n\nand did a test commit and it worked perfectly.\nIs there a way I can revert all my previous commits to this new email?\nI read this question on SO How do I change the author and committer name/email for multiple commits? and used this\n git filter-branch -f --env-filter \" \n GIT_AUTHOR_EMAIL='[email protected]'; \n GIT_COMMITTER_EMAIL='[email protected]';\n \" \n HEAD\n\nBut it DID NOT work... I can still see the email of my previous commits with the .patch extension as the .local email address" }, { "role": "assistant", "content": "You can indeed do his for many commits at once like this:\ngit rebase -i HEAD~40 -x \"git commit --amend --author 'Author Name <[email protected]>' --no-edit\"\n\nI worked this out better in this answer." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Escaping git bash after reflog, or commit, etc\nWhen I'm using something like git reflog, I lose my ability to type in commands. I don't know what you look up, because I'm relatively new to bash.\nSo, what's the terminology I can use to go back to running git commands after running a reflog?" }, { "role": "assistant", "content": "Press q for quit and you will be back to the normal shell. CTRL + C would work as well." } ]