messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary pseudoref" }, { "role": "assistant", "content": "Pseudorefs are a class of files under $GIT_DIR which behave\nlike refs for the purposes of rev-parse, but which are treated\nspecially by git. Pseudorefs both have names that are all-caps,\nand always start with a line consisting of a SHA-1 followed by whitespace. So, HEAD is not a\npseudoref, because it is sometimes a symbolic ref. They might\noptionally contain some additional data. MERGE_HEAD and CHERRY_PICK_HEAD are examples. Unlike per-worktree refs , these files cannot\nbe symbolic refs, and never have reflogs. They also cannot be\nupdated through the normal ref update machinery. Instead,\nthey are updated by directly writing to the files. However,\nthey can be read as if they were refs, so git rev-parse\nMERGE_HEAD will work." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the priority regarding git configuration? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nWhere do the settings in my Git configuration come from?\n\n (10 answers)\n \n\nClosed 8 years ago.\n\n\n\nIf I set configuration on my ~/.gitconfig file, which config would override it?\n\nproject level config : .git/config\nsystem level config : /etc/gitconfig" }, { "role": "assistant", "content": "Lowest to highest priority:\n\n/etc/gitconfig: system wide, edited when --system parameter is used\n~/.gitconfig: user specific configuration, edited when --global parameter is used\n.git/config: repository specific configuration" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the difference between pull and clone in git?\nWhat is the difference between doing (after mkdir repo and cd repo):\ngit init\ngit remote add origin git://github.com/cmcculloh/repo.git\ngit fetch --all\ngit pull origin master\n\nand\ngit clone git://github.com/cmcculloh/repo.git\n\nI mean, obviously one is shorter, but other than that are they basically doing the same thing?" }, { "role": "assistant", "content": "git clone is how you get a local copy of an existing repository to work on. It's usually only used once for a given repository, unless you want to have multiple working copies of it around. (Or want to get a clean copy after messing up your local one...)\ngit pull (or git fetch + git merge) is how you update that local copy with new commits from the remote repository. If you are collaborating with others, it is a command that you will run frequently.\nAs your first example shows, it is possible to emulate git clone with an assortment of other git commands, but it's not really the case that git pull is doing \"basically the same thing\" as git clone (or vice-versa)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to change the remote repository for a git submodule?\nI've created a git repository with a submodule in it. I'm able to tell the submodule itself to change its remote repository path, but I'm not sure how to tell the parent repository how to change the remote repository path for the submodule.\nI wouldn't be surprised if I'm somewhat out of luck and have to do things manually, as even deleting submodules isn't easy." }, { "role": "assistant", "content": "You should just be able to edit the .gitmodules file to update the URL and then run git submodule sync --recursive to reflect that change to the superproject and your working copy.\nThen you need to go to the .git/modules/path_to_submodule dir and change its config file to update git path.\nIf repo history is different then you need to checkout new branch manually:\ngit submodule sync --recursive\ncd <submodule_dir> \n\ngit fetch\ngit checkout origin/master\ngit branch master -f\ngit checkout master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to resolve \"git did not exit cleanly (exit code 128)\" error on TortoiseGit?\nI've run into this serious error while committing, and created a bug report.\nI keep getting this error on TortoiseGit operations:\n\ngit did not exit cleanly (exit code 128)\n\nI've reinstalled the program, rebooted, and tried to clone a fresh repo from github - nothing seems to work. I also deleted %appdata%\\Tortoise git folder ... I'm at a loss now. Any advice on how to proceed?" }, { "role": "assistant", "content": "It's probably because your SSH key has been removed/revoked. Make a new one and add it to your GitHub account." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to add screenshot to READMEs in github repository?\n\nIs it possible to place a screenshot in README file in a GitHub repository? What's the syntax?" }, { "role": "assistant", "content": "If you use Markdown (README.md):\nProvided that you have the image in your repo, you can use a relative URL: \n![Alt text](/relative/path/to/img.jpg?raw=true \"Optional Title\")\n\nIf you need to embed an image that's hosted elsewhere, you can use a full URL\n![Alt text](http://full/path/to/img.jpg \"Optional title\")\n\nGitHub recommend that you use relative links with the ?raw=true parameter to ensure forked repos point correctly.\nThe raw=true parameter is there in order to ensure the image you link to, will be rendered as is. That means that only the image will be linked to, not the whole GitHub interface for that respective file. See this comment for more details.\nCheck out an example: https://raw.github.com/altercation/solarized/master/README.md\nIf you use SVGs then you'll need to set the sanitize attribute to true as well: ?raw=true&sanitize=true. (Thanks @EliSherer)\nAlso, the documentation on relative links in README files: https://help.github.com/articles/relative-links-in-readmes\nAnd of course the markdown docs: http://daringfireball.net/projects/markdown/syntax\nAdditionally, if you create a new branch screenshots to store the images you can avoid them being in the master working tree\nYou can then embed them using:\n![Alt text](/../<branch name>/path/to/image.png?raw=true \"Optional Title\")" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs git log --branches --not --remotes=origin" }, { "role": "assistant", "content": "Shows all commits that are in any of local branches but not in\nany of remote-tracking branches for origin (what you have that\norigin doesn’t)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": ".gitignore for PhoneGap/Cordova 3.0 projects - what should I commit?\nI just tried to create a new phonegap 3.0 project... Note: I'm new to phonegap.\nAnyways, I see the project folder contains:\n\n.cordova\nmerges\nplatforms\nplugins\nwww\n\nAnd having tried phonegap local run android I see a lot of binary/generated files in platforms/android.\nThis leaves me wondering, what parts of this folder structure should I add to my git repository.\nNormally, I would consider it extremely poor practice to commit binary files.\nHence, I would normally add patterns like bin/, obj/, *.o, *.pyc etc. to .gitignore to avoid polluting my git repository with things that only serves to create merge conflicts.\nSurely, www should be added to git, but what about the other parts of the project. To what extend are they products of the source code, and to what extend are they project configuration?\nWhat do you do? Granted I'm new so I barely understand what makes sense here..." }, { "role": "assistant", "content": "Expanding on @Jake Moshenko answer:\nI like the idea of omitting the platforms directory. In fact, I am am able to exclude both the plugins and platforms directories. A good starting point for the .gitignore:\nplatforms/\nplugins/\n\nThe problem with this is that clean copy of the repo must be initialized before you can actually work with it. It may make sense to create an init script such as:\n#!/bin/bash\ntextReset=$(tput sgr0)\ntextGreen=$(tput setaf 2)\nmessage_info () {\n echo \"${textGreen}[my-app]${textReset} $1\"\n}\n\nmessage_info \"Creating necessary directories...\"\nmkdir plugins\nmkdir platforms\n\nmessage_info \"Adding platforms...\"\n# If using cordova, change to: cordova platform add android\nphonegap build android\nphonegap build ios\n\nmessage_info \"Adding plugins...\"\n# If using cordova, change to: cordova plugin add\nphonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git\n\nA caveat to this approach is that it makes it a little more challenging to customize the platform specific app code/config outside of what's supported by phonegap/cordova (i.e. screen orientation support). \nUpdate: Bash Gist\nThis gist contains a more complete script for handling a project that does not commit the plugins and platforms directories. It provides a mechanism for copying the icons and splashscreen images from www to the platform directories (for iOS and Android), installing plugins, and handling platform specific files that should be added to version control.\nUpdate: Grunt Gist\nHere is another gist which is a Grunt port of the above mentioned bash script. (Thanks to @obie for suggesting grunt)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What security issue is caused by changing the visibility of a fork on Github?\n\nOn Github, say I forked a project but did not want to display it on my profile because the project relates to something that I am not allowed to work on for non-compete reasons.\nWhen I try to set the fork to private, I receive this error message on Github:\n\n\"For security reasons, you cannot change the visibility of a fork.\"\n\nWhat are the potential security implications of changing the visibility of a fork?" }, { "role": "assistant", "content": "When you perform a push on GitHub, the data is pushed into the repository for you fork. Then, if there are multiple forks, those objects are moved into an alternate that is shared by all repositories in that network, forks included. This saves a lot of space when there are many forks, and it makes pull requests much easier, since the objects are already present in the main repository.\nHowever, it means practically that all objects in all forks in the network are visible through any fork. As a result, if your fork were private, then someone who knew an object ID could view it through the main repository and see that data. This would be a security problem, so GitHub doesn't allow it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --name-status" }, { "role": "assistant", "content": "Show only names and status of changed files. See the description\nof the --diff-filter option on what the status letters mean.\nJust like --name-only the file names are often encoded in UTF-8." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --no-indent-heuristic" }, { "role": "assistant", "content": "Disable the indent heuristic." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-tag - Create, list, delete or verify a tag object signed with GPG --cleanup=<mode>" }, { "role": "assistant", "content": "This option sets how the tag message is cleaned up.\nThe <mode> can be one of verbatim , whitespace and strip . The strip mode is default. The verbatim mode does not change message at\nall, whitespace removes just leading/trailing whitespace lines and strip removes both whitespace and commentary." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-shortlog - Summarize git log output --exclude-first-parent-only" }, { "role": "assistant", "content": "When finding commits to exclude (with a ^ ), follow only\nthe first parent commit upon seeing a merge commit.\nThis can be used to find the set of changes in a topic branch\nfrom the point where it diverged from the remote branch, given\nthat arbitrary merges can be valid topic branch changes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Difference between `go get` and `git clone`?\n\nI had a problem with go-modbus in an issue in Github.\nAuthor suggested me to use: \n$ go get github.com/goburrow/modbus \n\ninstead of \n$ git clone https://github.com/goburrow/modbus.git\n\nWhat is the difference between that two commands?" }, { "role": "assistant", "content": "The git clone command will clone a repo into a newly created directory, while go get downloads and installs the packages named by the import paths, along with their dependencies." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why doesn't Git ignore my specified file?\nI added the following line to .gitignore:\nsites/default/settings.php\n\nbut when I type git status it shows the file as unstaged file.\nWhat's the problem? All other patterns work well." }, { "role": "assistant", "content": "Make sure that your .gitignore is in the root of the working directory, and in that directory run git status and copy the path to the file from the status output and paste it into the .gitignore.\nIf that doesn’t work, then it’s likely that your file is already tracked by Git. You can confirm this through the output of git status. If the file is not listed in the “Untracked files” section, then it is already tracked by Git and it will ignore the rule from the .gitignore file.\nThe reason to ignore files in Git is so that they won't be added to the repository. If you previously added a file you want to be ignored, then it will be tracked by Git and the ignore rules matching it will be skipped. Git does this since the file is already part of the repository.\nIn order to actually ignore the file, you have to untrack it and remove it from the repository. You can do that by using git rm --cached sites/default/settings.php. This removes the file from the repository without physically deleting the file (that’s what the --cached does). After committing that change, the file will be removed from the repository, and ignoring it should work properly.\nAs pointed out by @display-name below, sometimes it's neccessary to do a git add . after the git rm --cached to properly rebuild the index." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-init - Create an empty Git repository or reinitialize an existing one -b <branch-name> --initial-branch= <branch-name>" }, { "role": "assistant", "content": "Use <branch-name> for the initial branch in the newly created\nrepository. If not specified, fall back to the default name (currently master , but this is subject to change in the future; the name can be\ncustomized via the init.defaultBranch configuration variable)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Visual studio 2019 \"Error encountered while pushing to the remote repository: Failed to push to the remote repository...\"\nIn Visual Studio 2019 I have \"Unpushed Commits\" as seen below:\n\nWhen I try to push them I get the error and this is what it looks like on the GUI:\n\nnote: the yellow label with \"Failed to push...\" is not clickable.\nThe Output from Source Control - Git is as follows:\n\nThe output window doesn't show me any useful details. Am I looking in the wrong place? Is there a better place to see the actual error?\nThe answer in this case is that the policy on the branch 'develop' does not allow direct pushes. I was kinda hoping that the error in the output would state something like 'Failed to push due to a policy constraint on the branch'" }, { "role": "assistant", "content": "Have few reasons for this case:\n\nTry pull, then push.\nCheck permission (you maybe haven't permission to push, after a change). You maybe push to just protected branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-reset - Reset current HEAD to the specified state -q --quiet" }, { "role": "assistant", "content": "Be quiet, only report errors." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_TERMINAL_PROMPT" }, { "role": "assistant", "content": "If this Boolean environment variable is set to false, git will not prompt\non the terminal (e.g., when asking for HTTP authentication)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git push fails with deny updating hidden ref\n\nI've a repository for my dotfiles and went to push changes from a branch only to encounter...\n$ git push\nEnumerating objects: 46, done.\nCounting objects: 100% (46/46), done.\nWriting objects: 100% (46/46), 3.20 MiB | 1.52 MiB/s, done.\nTotal 46 (delta 0), reused 0 (delta 0)\nTo gitlab.com:auser/dotfiles.git\n ! [remote rejected] kimura -> origin/kimura (deny updating a hidden ref)\n ! [remote rejected] master -> origin/master (deny updating a hidden ref)\nerror: failed to push some refs to '[email protected]:auser/dotfiles.git'\n\nThis thread suggests its because pull requests made on origin and links to a blog post with solution of how to skip this, although I do not explicitly have refs/pull in the path thats being rejected so it may be a different issue but I couldn't find much info on this so figured I try the proposed solution and updated my config to...\n[core]\n repositoryformatversion = 0\n filemode = true\n bare = false\n logallrefupdates = true\n[remote \"origin\"]\n url = [email protected]:auser/dotfiles.git\n fetch = +refs/heads/*:refs/heads/*\n fetch = +refs/tags/*:refs/tags/*\n fetch = +refs/change/*:refs/change/*\n pushurl = [email protected]:auser/dotfiles.git\n push = +refs/heads/*:refs/remotes/origin/*\n[submodule \"oh-my-zsh/.oh-my-zsh\"]\n url = https://github.com/robbyrussell/oh-my-zsh\n active = true\n[branch \"master\"]\n remote = origin\n merge = refs/heads/master\n pushRemote = origin\n[branch \"kimura\"]\n remote = origin\n merge = refs/heads/kimura\n fetch = +refs/heads/*:refs/heads/*\n fetch = +refs/tags/*:refs/tags/*\n fetch = +refs/change/*:refs/change/*\n\nBut the problem persists. My branches are...\n$ git branch -a\n* kimura\n master\n remotes/origin/kimura\n remotes/origin/master\n\nThe host I'm trying to push from is where I started the repo before mirroring to Gitlab." }, { "role": "assistant", "content": "I had the same error\n[remote rejected] origin/myBranch (deny updating a hidden ref)\n\nThe problem was:\nI cloned a remote repo mobile into a folder, then, I made modifications on the code, and when I tried to push, instead of pushing the local repo mobile to the remote one, I was trying to push its parent\n\nThe right way was to open git bash inside the local repo you have cloned and execute the right commands, this may be your problem too." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I easily fixup a past commit?\nI just read amending a single file in a past commit in git but unfortunately the accepted solution 'reorders' the commits, which is not what I want. So here's my question:\nEvery now and then, I notice a bug in my code while working on an (unrelated) feature. A quick git blame then reveals that the bug has been introduced a few commits ago (I commit quite a lot, so usually it's not the most recent commit which introduced the bug). At this point, I usually do this:\ngit stash # temporarily put my work aside\ngit rebase -i <bad_commit>~1 # rebase one step before the bad commit\n # mark broken commit for editing\nvim <affected_sources> # fix the bug\ngit add <affected_sources> # stage fixes\ngit commit -C <bad_commit> # commit fixes using same log message as before\ngit rebase --continue # base all later changes onto this\n\nHowever, this happens so often that the above sequence is getting annoying. Especially the 'interactive rebase' is boring. Is there any shortcut to the above sequence, which lets me amend an arbitrary commit in the past with the staged changes? I'm perfectly aware that this changes the history, but I'm doing mistakes so often that I'd really love to have something like\nvim <affected_sources> # fix bug\ngit add -p <affected_sources> # Mark my 'fixup' hungs for staging\ngit fixup <bad_commit> # amend the specified commit with staged changes,\n # rebase any successors of bad commit on rewritten \n # commit.\n\nMaybe a smart script which can rewrite commits using plumbing tools or so?" }, { "role": "assistant", "content": "UPDATED ANSWER\nA while ago, a new --fixup argument was added to git commit which can be used to construct a commit with a log message suitable for git rebase --interactive --autosquash. So the simplest way to fixup a past commit is now:\n$ git add ... # Stage a fix\n$ git commit --fixup=a0b1c2d3 # Perform the commit to fix broken a0b1c2d3\n$ git rebase -i --autosquash a0b1c2d3~1 # Now merge fixup commit into broken commit\n\nORIGINAL ANSWER\nHere's a little Python script I wrote a while ago which implements this git fixup logic I hoped for in my original question. The script assumes that you staged some changes and then applies those changes to the given commit.\nNOTE: This script is Windows-specific; it looks for git.exe and sets the GIT_EDITOR environment variable using set. Adjust this as needed for other operating systems.\nUsing this script I can implement precisely the 'fix broken sources, stage fixes, run git fixup ' workflow I asked for:\n#!/usr/bin/env python\nfrom subprocess import call\nimport sys\n\n# Taken from http://stackoverflow.com/questions/377017/test-if-executable-exists-in python\ndef which(program):\n import os\n def is_exe(fpath):\n return os.path.exists(fpath) and os.access(fpath, os.X_OK)\n\n fpath, fname = os.path.split(program)\n if fpath:\n if is_exe(program):\n return program\n else:\n for path in os.environ[\"PATH\"].split(os.pathsep):\n exe_file = os.path.join(path, program)\n if is_exe(exe_file):\n return exe_file\n\n return None\n\nif len(sys.argv) != 2:\n print \"Usage: git fixup <commit>\"\n sys.exit(1)\n\ngit = which(\"git.exe\")\nif not git:\n print \"git-fixup: failed to locate git executable\"\n sys.exit(2)\n\nbroken_commit = sys.argv[1]\nif call([git, \"rev-parse\", \"--verify\", \"--quiet\", broken_commit]) != 0:\n print \"git-fixup: %s is not a valid commit\" % broken_commit\n sys.exit(3)\n\nif call([git, \"diff\", \"--staged\", \"--quiet\"]) == 0:\n print \"git-fixup: cannot fixup past commit; no fix staged.\"\n sys.exit(4)\n\nif call([git, \"diff\", \"--quiet\"]) != 0:\n print \"git-fixup: cannot fixup past commit; working directory must be clean.\"\n sys.exit(5)\n\ncall([git, \"commit\", \"--fixup=\" + broken_commit])\ncall([\"set\", \"GIT_EDITOR=true\", \"&&\", git, \"rebase\", \"-i\", \"--autosquash\", broken_commit + \"~1\"], shell=True)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git get short hash from regular hash\nI have a regular long SHA-1 hash string. I would like to get the shortest unambiguous SHA-1 hash string version of it. That is, the one I would get by using git log -1 --pretty=format:%h, assuming the long hash refers to the last commit." }, { "role": "assistant", "content": "The shortest SHA1 you can get has a length of 4. Rev parse will give you a SHA1 of 7 digits by default with the short option :\ngit rev-parse --short 921103db8259eb9de72f42db8b939895f5651489\n921103d\n\nYou have to specify 4 to the short option to have the shortest unambiguous SHA1 :\ngit rev-parse --short=4 921103db8259eb9de72f42db8b939895f5651489\n92110\n\nYou can also set it in the core.abbrev configuration variable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options sequence.editor" }, { "role": "assistant", "content": "Text editor used by git rebase -i for editing the rebase instruction file.\nThe value is meant to be interpreted by the shell when it is used.\nIt can be overridden by the GIT_SEQUENCE_EDITOR environment variable.\nWhen not configured, the default commit message editor is used instead." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git push heroku master says \"Everything up-to-date\", but the app is not current\nI have an app on Heroku that is running old code. I've made a small change and committed the change. I then ran\ngit push heroku master\n\nIt'll say\nFetching repository, done.\nEverything up-to-date\n\nBut if I go and look at the app, it's all old code. I did revert the site back to another version in Heroku about 15 days ago, but pushed updates to it since then and they worked.\nWhy is heroku not getting the most current files from my github repository? Is there a way to just reset the app and push the files from github again? I have production data in the database so I do NOT want to touch it." }, { "role": "assistant", "content": "Kindly confirm your current branch is master. \n git branch \n\nIf the pointer is not pointing the master, then check out to master branch\ngit checkout master\n\nCommit your changes and try to push to heroku\ngit commit -am \"xxxyyzzz\" \ngit push heroku master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub Copilot - please login to github and try again\n\nFor Intellij plugin, GitHub Copilot shows error please login to github and try again.\nI have already done the following:\n\nAuthenticated GitHub Copilot with my GitHub user and password.\nAllowed GitHub Copilot in GitHub account profile.\nRestarted the IDE multiple times after the plugin installation.\nI have license for Github Copilot.\n\nWhat should I do to resolve this error?" }, { "role": "assistant", "content": "I have to restart my IDE, then go to tools->GitHub copilot:\n1- restart IDE\n2- got to \"tools\" -> \"GitHub copilot\" -> \"login to GitHub\"\n3- it will show you a popup with code, click on copy and open to add and trust your device." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-diff-index" }, { "role": "assistant", "content": "Compare a tree to the working tree or index" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Local executing hook after a git push? (post-push)\nI've looked at the githooks manpage but unless I'm missing something I don't see an option for local, post-push git hooks. I'd like to have one that updates the api docs on my web server (for which I already have a script) after I push the master branch to the GitHub repo. Of course I could just write my own script that combines the git push and the api docs run, but that feels somewhat inelegant." }, { "role": "assistant", "content": "Another solution to this problem is to have a wrapper for git push that executes .git/hooks/pre-push and .git/hooks/post-push scripts before and after the git push call. A possible wrapper could look like this:\n#!/bin/sh\n\nGIT_DIR_=\"$(git rev-parse --git-dir)\"\nBRANCH=\"$(git rev-parse --symbolic --abbrev-ref $(git symbolic-ref HEAD))\"\n\nPRE_PUSH=\"$GIT_DIR_/hooks/pre-push\"\nPOST_PUSH=\"$GIT_DIR_/hooks/post-push\"\n\ntest -x \"$PRE_PUSH\" &&\n exec \"$PRE_PUSH\" \"$BRANCH\" \"$@\"\n\ngit push \"$@\"\n\ntest $? -eq 0 && test -x \"$POST_PUSH\" &&\n exec \"$POST_PUSH\" \"$BRANCH\" \"$@\"\n\nSaved as git-push-wh somewhere in your PATH, it can then be called as git push-wh if you want to push with hooks." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker" }, { "role": "assistant", "content": "GIT COMMANDS We divide Git into high level (\"porcelain\") commands and low level\n(\"plumbing\") commands." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-worktree - Manage multiple working trees move" }, { "role": "assistant", "content": "Move a worktree to a new location. Note that the main worktree or linked\nworktrees containing submodules cannot be moved with this command. (The git worktree repair command, however, can reestablish the connection\nwith linked worktrees if you move the main worktree manually.)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission" }, { "role": "assistant", "content": "CONFIGURATION You can specify extra mail header lines to be added to each message,\ndefaults for the subject prefix and file suffix, number patches when\noutputting more than one patch, add \"To:\" or \"Cc:\" headers, configure\nattachments, change the patch output directory, and sign off patches\nwith configuration variables. [format]\n\theaders = \"Organization: git-foo\\n\"\n\tsubjectPrefix = CHANGE\n\tsuffix = .txt\n\tnumbered = auto\n\tto = <email>\n\tcc = <email>\n\tattach [ = mime-boundary-string ]\n\tsignOff = true\n\toutputDirectory = <directory>\n\tcoverLetter = auto\n\tcoverFromDescription = auto" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Browse and display files in a git repo without cloning\nIs there a way to browse and display files in a git repo without cloning it first? I can do those in svn using the commands:\n\nsvn ls /path/to/repo \nsvn cat /path/to/repo/file-in-repo\n\nI can supposedly use git show but doing:\n\ngit show /path/to/repo\ngit show HEAD:/path/to/repo\n\nresult to \n\nfatal: Not a git repository" }, { "role": "assistant", "content": "The command you want is git ls-remote which allows you to get some information about remote repositories, but you cant show history or list directories or anything of that level: essentially it only lets you see the remote objects at a very high-level (you can see the current HEADs and tags for example).\nThe only real way to do what you want (if I understand correctly) would be to use ssh to run a remote command and return the results, for example:\nssh me@otherhost \"cd repo && git log -n 10\"\n\nWhat you want would be lovely functionality if they could add it, but from what I read it's not very easy since getting history etc needs a lot of information to be local to git, and at that point you may as well have done a git fetch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I show just the names and commit titles since a tag in Git?\nI'm trying to use tags for release management in Git—I create a tag for each release. I'd like to be able to create release notes by listing the comment titles for every commit since a tag, or between 2 tags. I can't seem to find any way to do this." }, { "role": "assistant", "content": "If your tags are named LastRelease and NextRelease then do\ngit log --pretty=format:%s LastRelease..NextRelease\n." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git, adding files to repository gives fatal error for LF ->CRLF\nI'm new to git and I need some help. I'm using msysgit on windows.\nWhen I execute the command git add [folderName] I get the response:\nfatal: LF would be replaced by CRLF in [.css file or .js file]\n\nand then if you try to do a commit nothing happens.\n$ git commit\n# On branch master\n#\n# Initial commit\n#\n# Untracked files:\n# (use \"git add <file>...\" to include in what will be committed)\n#\n# so01/\nnothing added to commit but untracked files present (use \"git add\" to track)\n\nSome of these css/js files were downloaded from the net so I guess that's why the have LF.\nIf I open the file and cut/paste the content, then I get the error on the next file and so on.\nAny help will be much appreciated.\nEdit\nSetting core.autocrlf to false seems to solve the problem, but I read on many posts not to set this option to false.\nCan somebody point me where can I find out what problems may arise in this situation?" }, { "role": "assistant", "content": "very new to this so setting core.autocrlf to false didn't make too much sense to me. So for other newbies, go to the config file in you .git folder and add:\n[core]\n autocrlf = false\n\nunder the [core] heading." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-ls-files - Show information about files in the index and the working tree -c --cached" }, { "role": "assistant", "content": "Show all files cached in Git’s index, i.e. all tracked files.\n(This is the default if no -c/-s/-d/-o/-u/-k/-m/--resolve-undo\noptions are specified.)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to delete the last n commits on Github and locally?\nI'm trying to delete the last 2 commits from one of my GitHub repositories. I've tried as suggested here : git push -f origin HEAD^^:master. It seems that it works, as the last two commits are removed.\nThen I deleted them from my local repository with git rebase -i HEAD~2. I remove the lines that are related to those commits, and check with git log that they are correctly removed.\nAfter that, I make some changes in my local repository, make a new commit, and push to GitHub. The problem is that, in my GitHub account, I have the previous two commits that I've tried to delete.\nI think the problem is in my local repository, because if I clone my Github repository to my local and make some changes here, when I push a new commit those old commits aren't pushed to GitHub." }, { "role": "assistant", "content": "To remove the last two commits locally I'd suggest using:\ngit reset --hard HEAD^^\n\nRebase is a completely different operation that won't help you here." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options fetch.unpackLimit" }, { "role": "assistant", "content": "If the number of objects fetched over the Git native\ntransfer is below this\nlimit, then the objects will be unpacked into loose object\nfiles. However if the number of received objects equals or\nexceeds this limit then the received pack will be stored as\na pack, after adding any missing delta bases. Storing the\npack from a push can make the push operation complete faster,\nespecially on slow filesystems. If not set, the value of transfer.unpackLimit is used instead." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --skip-to=<file> --rotate-to=<file>" }, { "role": "assistant", "content": "Discard the files before the named <file> from the output\n(i.e. skip to ), or move them to the end of the output\n(i.e. rotate to ). These options were invented primarily for the use\nof the git difftool command, and may not be very useful\notherwise." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-for-each-ref - Output information on each ref --sort=<key>" }, { "role": "assistant", "content": "A field name to sort on. Prefix - to sort in\ndescending order of the value. When unspecified, refname is used. You may use the --sort=<key> option\nmultiple times, in which case the last key becomes the primary\nkey." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -p -u --patch" }, { "role": "assistant", "content": "Generate patch (see Generating patch text with -p ).\nThis is the default." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "View rendered output of a gist?\n\nI'm sure I'm being dim, but is it possible to view the rendered output of a gist?\nThis is the gist I'm interested in: https://gist.github.com/844752/420cc52eb4910fe8fa2bec9e13daab18b6230503\nWhere can I see how it actually renders?" }, { "role": "assistant", "content": "rawgit.com provides this service. To use rawgit.com, simply replace the domain of the raw view of the gist or github file you want to view with rawgit.com. For example:\nhttps://gist.githubusercontent.com/mbostock/844752/raw/index.html\n\nto\nhttps://rawgit.com/mbostock/844752/raw/index.html\n\nor\nhttps://raw.githubusercontent.com/caffinatedmonkey/Hello-World-PSP/master/main.cpp\n\nto\nhttps://rawgit.com/caffinatedmonkey/Hello-World-PSP/master/main.cpp" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rebase - Reapply commits on top of another base tip" }, { "role": "assistant", "content": "BEHAVIORAL DIFFERENCES git rebase has two primary backends: apply and merge . (The apply backend used to be known as the am backend, but the name led to\nconfusion as it looks like a verb instead of a noun. Also, the merge backend used to be known as the interactive backend, but it is now\nused for non-interactive cases as well. Both were renamed based on\nlower-level functionality that underpinned each.) There are some\nsubtle differences in how these two backends behave: Empty commits The apply backend unfortunately drops intentionally empty commits, i.e.\ncommits that started empty, though these are rare in practice. It\nalso drops commits that become empty and has no option for controlling\nthis behavior. The merge backend keeps intentionally empty commits by default (though\nwith -i they are marked as empty in the todo list editor, or they can\nbe dropped automatically with --no-keep-empty ). Similar to the apply backend, by default the merge backend drops\ncommits that become empty unless -i / --interactive is specified (in\nwhich case it stops and asks the user what to do). The merge backend\nalso has an --empty=(drop|keep|stop) option for changing the behavior\nof handling commits that become empty. Directory rename detection Due to the lack of accurate tree information (arising from\nconstructing fake ancestors with the limited information available in\npatches), directory rename detection is disabled in the apply backend.\nDisabled directory rename detection means that if one side of history\nrenames a directory and the other adds new files to the old directory,\nthen the new files will be left behind in the old directory without\nany warning at the time of rebasing that you may want to move these\nfiles into the new directory. Directory rename detection works with the merge backend to provide you\nwarnings in such cases. Context The apply backend works by creating a sequence of patches (by calling format-patch internally), and then applying the patches in sequence\n(calling am internally). Patches are composed of multiple hunks,\neach with line numbers, a context region, and the actual changes. The\nline numbers have to be taken with some fuzz, since the other side\nwill likely have inserted or deleted lines earlier in the file. The\ncontext region is meant to help find how to adjust the line numbers in\norder to apply the changes to the right lines. However, if multiple\nareas of the code have the same surrounding lines of context, the\nwrong one can be picked. There are real-world cases where this has\ncaused commits to be reapplied incorrectly with no conflicts reported.\nSetting diff.context to a larger value may prevent such types of\nproblems, but increases the chance of spurious conflicts (since it\nwill require more lines of matching context to apply). The merge backend works with a full copy of each relevant file,\ninsulating it from these types of problems. Labelling of conflicts markers When there are content conflicts, the merge machinery tries to\nannotate each side’s conflict markers with the commits where the\ncontent came from. Since the apply backend drops the original\ninformation about the rebased commits and their parents (and instead\ngenerates new fake commits based off limited information in the\ngenerated patches), those commits cannot be identified; instead it has\nto fall back to a commit summary. Also, when merge.conflictStyle is\nset to diff3 or zdiff3 , the apply backend will use \"constructed merge\nbase\" to label the content from the merge base, and thus provide no\ninformation about the merge base commit whatsoever. The merge backend works with the full commits on both sides of history\nand thus has no such limitations. Hooks The apply backend has not traditionally called the post-commit hook,\nwhile the merge backend has. Both have called the post-checkout hook,\nthough the merge backend has squelched its output. Further, both\nbackends only call the post-checkout hook with the starting point\ncommit of the rebase, not the intermediate commits nor the final\ncommit. In each case, the calling of these hooks was by accident of\nimplementation rather than by design (both backends were originally\nimplemented as shell scripts and happened to invoke other commands\nlike git checkout or git commit that would call the hooks). Both\nbackends should have the same behavior, though it is not entirely\nclear which, if any, is correct. We will likely make rebase stop\ncalling either of these hooks in the future. Interruptability The apply backend has safety problems with an ill-timed interrupt; if\nthe user presses Ctrl-C at the wrong time to try to abort the rebase,\nthe rebase can enter a state where it cannot be aborted with a\nsubsequent git rebase --abort . The merge backend does not appear to\nsuffer from the same shortcoming. (See https://lore.kernel.org/git/[email protected]/ for\ndetails.) Commit Rewording When a conflict occurs while rebasing, rebase stops and asks the user\nto resolve. Since the user may need to make notable changes while\nresolving conflicts, after conflicts are resolved and the user has run git rebase --continue , the rebase should open an editor and ask the\nuser to update the commit message. The merge backend does this, while\nthe apply backend blindly applies the original commit message. Miscellaneous differences There are a few more behavioral differences that most folks would\nprobably consider inconsequential but which are mentioned for\ncompleteness: Reflog: The two backends will use different wording when describing\nthe changes made in the reflog, though both will make use of the\nword \"rebase\". Progress, informational, and error messages: The two backends\nprovide slightly different progress and informational messages.\nAlso, the apply backend writes error messages (such as \"Your files\nwould be overwritten…​\") to stdout, while the merge backend writes\nthem to stderr. State directories: The two backends keep their state in different\ndirectories under .git/" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to style a JSON block in Github Wiki?\n\nIs there a way to nicely format/style JSON code in Github Wiki (i.e Markdown preferred)?\nSomething like this with few colors (or bold) and correct indentation:\nhttp://www.freeformatter.com/json-formatter.html#ad-output" }, { "role": "assistant", "content": "Some color-syntaxing enrichment can be applied with the following blockcode syntax\n```json\nHere goes your json object definition\n```\n\nNote: This won't prettify the json representation. To do so, one can previously rely on an external service such as jsbeautifier.org and paste the prettified result in the wiki." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can I get git to tell me all the files one user has modified?\nI would like git to give me a list of all the files modified by one user, across all commits.\nMy particular use case is that I've been involved in the i18n of a ruby on rails project, and we want to know what files have already been done and what files still need to be done. The users in question have only done work on the i18n, not on the rest of the code base. So the information should all be in git, but I'm not sure how to get it out." }, { "role": "assistant", "content": "This will give you a simple list of files, nothing else:\ngit log --no-merges --author=\"Pattern\" --name-only --pretty=format:\"\" | sort -u\n\nSwitch --author for --committer as necessary." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Accidentally pushed commit: change git commit message\nIn my local repo I have one commit with an incorrect commit message.\nI've already published the incorrect commit message with git push.\nNow the remote repo (which is GitHub-hosted) has the incorrect commit message, too.\nI've already tried git commit --amend, but found that it will not work for me in this situation because I've made additional commits since the incorrect one.\nHow would you fix this situation?" }, { "role": "assistant", "content": "Easiest solution (but please read this whole answer before doing this):\n\ngit rebase -i <hash-of-commit-preceding-the-incorrect-one>\nIn the editor that opens, change pick to reword on the line for the incorrect commit.\nSave the file and close the editor.\nThe editor will open again with the incorrect commit message. Fix it.\nSave the file and close the editor.\ngit push --force to update GitHub.\n\nThis will mean you will be publishing a modified version of a previously published repository. If anyone pulled or fetched from your repo between when you made the mistake with the incorrect commit message, and when you fixed it, then they will experience some difficulties later. So be sure you can accept this consequence before trying this." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_NO_REPLACE_OBJECTS" }, { "role": "assistant", "content": "Setting and exporting this environment variable tells Git to\nignore replacement refs and do not replace Git objects." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-clone - Clone a repository into a new directory -q --quiet" }, { "role": "assistant", "content": "Operate quietly. Progress is not reported to the standard\nerror stream." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Accept Incoming Change not appearing in VS Code\nI am trying to resolve merge conflicts into a branch using vs code. However the command palette to accept incoming changes is not appearing\n\nUnlike here where the command palette is clearly visible at the top window.\nHow do I get those commands to appear at top of window?" }, { "role": "assistant", "content": "Update (August 2022 - version 1.71):\nDisabled old conflict decorators, caused by automatically enabled git merge editor is no longer an issue. With the new release the merge editor and the old inline experience can now be used together.\nYou can also easily switch between the two with a single click.\nCheck Release Notes - Merge editor improvements to see how.\nIf you still can't see \"Accept Change(s)\" after updating VS Code, refer to answer by Bruno Monteiro.\nLegacy (July 2022 - version 1.70):\nYou may not also be able to see \"Accept Change(s)\" because recently VS Code introduced Git merge editor, which is now enabled by default.\nIt allows you to view and resolve merge conflicts by clicking on a conflicting file in the Source Control view instead. You can turn it off to go back to \"Accept Change(s)\", though I think it's better.\nAdd this line to VS Code user settings.json to turn merge editor off: \"git.mergeEditor\": false\nI'm attaching screenshots for anyone want to compare merge.editor off & on:\nGit merge editor - off\nGit merge editor - on\nNOTE:\nIf you like the new merge editor, you can bring it up from the terminal. Add the following to your .gitconfig, and then run - git mergetool\n[merge]\n tool = vscode\n[mergetool \"vscode\"]\n cmd = code --wait --merge $REMOTE $LOCAL $BASE $MERGED\n[mergetool]\n keepBackup = false" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab: how can I disable email notifications for new commits pushed to merge requests?\n\nIn Gitlab my notification settings are set to \"participate\". I am getting tons of emails from Gitlab.\nI would like to receive emails regarding new comments on merge requests that I'm participating in. But I would not like to receive an email for every time somebody pushes a commit to an MR that is assigned to me. That results in a huge amount of emails that I simply ignore.\nI also wouldn't mind getting an email notification for a commit pushed on a merge request opened by me, but that's just a nice to have.\nLooking in the Gitlab notification settings I haven't found a setting to support this. \"Custom\" settings are simply an extension of \"particiapte\", which means I still get an email for every little thing that happens on an MR I'm participating in (i.e., every commit). Any ideas?" }, { "role": "assistant", "content": "Gitlab -> Preferences -> Notifications\nThis list shows all custom notifications in Gitlab\n\nBut if you force others to mention you in comments, you can use this notification feature:" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-range-diff - Compare two commit ranges (e.g. two versions of a branch) --right-only" }, { "role": "assistant", "content": "Suppress commits that are missing from the second specified range\n(or the \"right range\" when using the <rev1>...<rev2> format)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-push - Update remote refs along with associated objects -6 --ipv6" }, { "role": "assistant", "content": "Use IPv6 addresses only, ignoring IPv4 addresses." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I revert multiple Git commits?\nI have a Git repository that looks like this:\nA <- B <- C <- D <- HEAD\n\nI want the head of the branch to point to A, i.e., I want B, C, D, and HEAD to disappear and I want head to be synonymous with A.\nIt sounds like I can either try to rebase (doesn't apply, since I've pushed changes in between), or revert. But how do I revert multiple commits? Do I revert one at a time? Is the order important?" }, { "role": "assistant", "content": "Expanding what I wrote in a comment\nThe general rule is that you should not rewrite (change) history that you have published, because somebody might have based their work on it. If you rewrite (change) history, you would make problems with merging their changes and with updating for them.\nSo the solution is to create a new commit which reverts changes that you want to get rid of. You can do this using git revert command.\nYou have the following situation:\n\nA <-- B <-- C <-- D <-- master <-- HEAD\n\n(arrows here refers to the direction of the pointer: the \"parent\" reference in the case of commits, the top commit in the case of branch head (branch ref), and the name of branch in the case of HEAD reference).\nWhat you need to create is the following:\n\nA <-- B <-- C <-- D <-- [(BCD)-1] <-- master <-- HEAD\n\nwhere [(BCD)^-1] means the commit that reverts changes in commits B, C, D. Mathematics tells us that (BCD)-1 = D-1 C-1 B-1, so you can get the required situation using the following commands:\n$ git revert --no-commit D\n$ git revert --no-commit C\n$ git revert --no-commit B\n$ git commit -m \"the commit message for all of them\"\n\nWorks for everything except merge commits.\n\nAlternate solution would be to checkout contents of commit A, and commit this state. Also works with merge commits. Added files will not be deleted, however. If you have any local changes git stash them first:\n$ git checkout -f A -- . # checkout that revision over the top of local files\n$ git commit -a\n\nThen you would have the following situation:\n\nA <-- B <-- C <-- D <-- A' <-- master <-- HEAD\n\nThe commit A' has the same contents as commit A, but is a different commit (commit message, parents, commit date).\n\nAlternate solution by Jeff Ferland, modified by Charles Bailey builds upon the same idea, but uses git reset. Here it is slightly modified, this way WORKS FOR EVERYTHING:\n$ git reset --hard A\n$ git reset --soft D # (or ORIG_HEAD or @{1} [previous location of HEAD]), all of which are D\n$ git commit" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options gui.spellingDictionary" }, { "role": "assistant", "content": "Specifies the dictionary used for spell checking commit messages in\nthe git-gui . When set to \"none\" spell checking is turned\noff." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %cs" }, { "role": "assistant", "content": "committer date, short format ( YYYY-MM-DD )" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git ignore exception\nI have a gitignore file that makes git ignore *.dll files, and that is actually the behavior I want. However, if I want an exception ( i.e. to be able to commit foo.dll), how can I achieve this?" }, { "role": "assistant", "content": "Use:\n*.dll #Exclude all dlls\n!foo.dll #Except for foo.dll\n\nFrom gitignore:\n\nAn optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included again. If a negated pattern matches, this will override lower precedence patterns sources." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rebase - Reapply commits on top of another base tip -v --verbose" }, { "role": "assistant", "content": "Be verbose. Implies --stat ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %G?" }, { "role": "assistant", "content": "show \"G\" for a good (valid) signature,\n\"B\" for a bad signature,\n\"U\" for a good signature with unknown validity,\n\"X\" for a good signature that has expired,\n\"Y\" for a good signature made by an expired key,\n\"R\" for a good signature made by a revoked key,\n\"E\" if the signature cannot be checked (e.g. missing key)\nand \"N\" for no signature" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Delete all local git branches\nI follow a development process where I create a new local branch for every new feature or story card. When finished I merge the branch into master and then push.\nWhat tends to happen over time due to a combination of laziness or forgetfulness, is that I end up with a large list of local branches, some of which (such as spikes) may not have been merged.\nI know how to list all my local branches and I know how to remove a single branch but I was wondering if there was a git command that allows me to delete all my local branches?\nBelow is the output of the git branch --merged command.\nuser@machine:~/projects/application[master]$ git branch --merged\n STORY-123-Short-Description\n STORY-456-Another-Description\n STORY-789-Blah-Blah\n* master\n\nAll attempts to delete branches listed with grep -v \\* (as per the answers below) result in errors:\nerror: branch 'STORY-123-Short-Description' not found.\nerror: branch 'STORY-456-Another-Description' not found.\nerror: branch 'STORY-789-Blah-Blah' not found.\n\nI'm using:\ngit 1.7.4.1 \nubuntu 10.04 \nGNU bash, version 4.1.5(1)-release \nGNU grep 2.5.4" }, { "role": "assistant", "content": "The 'git branch -d' subcommand can delete more than one branch. So, simplifying @sblom's answer but adding a critical xargs:\ngit branch -D `git branch --merged | grep -v \\* | xargs`\n\nor, further simplified to:\ngit branch --merged | grep -v \\* | xargs git branch -D \n\nImportantly, as noted by @AndrewC, using git branch for scripting is discouraged. To avoid it use something like:\ngit for-each-ref --format '%(refname:short)' refs/heads | grep -v \"master\\|main\" | xargs git branch -D\n\nCaution warranted on deletes!\n$ mkdir br\n$ cd br; git init\nInitialized empty Git repository in /Users/ebg/test/br/.git/\n$ touch README; git add README; git commit -m 'First commit'\n[master (root-commit) 1d738b5] First commit\n 0 files changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 README\n$ git branch Story-123-a\n$ git branch Story-123-b\n$ git branch Story-123-c\n$ git branch --merged\n Story-123-a\n Story-123-b\n Story-123-c\n* master\n$ git branch --merged | grep -v \\* | xargs\nStory-123-a Story-123-b Story-123-c\n$ git branch --merged | grep -v \\* | xargs git branch -D\nDeleted branch Story-123-a (was 1d738b5).\nDeleted branch Story-123-b (was 1d738b5).\nDeleted branch Story-123-c (was 1d738b5)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git --ignore-paths=<regex>" }, { "role": "assistant", "content": "This allows one to specify a Perl regular expression that will\ncause skipping of all matching paths from checkout from SVN.\nThe --ignore-paths option should match for every fetch (including automatic fetches due to clone , dcommit , rebase , etc) on a given repository. config key: svn-remote.<name>.ignore-paths If the ignore-paths configuration key is set, and the command-line\noption is also given, both regular expressions will be used. Examples: Skip \"doc*\" directory for every fetch --ignore-paths=\"^doc\" Skip \"branches\" and \"tags\" of first level directories --ignore-paths=\"^[^/]+/(?:branches|tags)\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-daemon - A really simple server for Git repositories" }, { "role": "assistant", "content": "DESCRIPTION A really simple TCP Git daemon that normally listens on port \"DEFAULT_GIT_PORT\"\naka 9418. It waits for a connection asking for a service, and will serve\nthat service if it is enabled. It verifies that the directory has the magic file \"git-daemon-export-ok\", and\nit will refuse to export any Git directory that hasn’t explicitly been marked\nfor export this way (unless the --export-all parameter is specified). If you\npass some directory paths as git daemon arguments, the offers are limited to\nrepositories within those directories. By default, only upload-pack service is enabled, which serves git fetch-pack and git ls-remote clients, which are invoked\nfrom git fetch , git pull , and git clone . This is ideally suited for read-only updates, i.e., pulling from\nGit repositories. An upload-archive also exists to serve git archive ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Using syntax highlight from GitHub\n\nWhat syntax highlighting is used on GitHub (for HTML, CSS, JavaScript, C#) when viewing source code-file and is it available for the public to use?\nIt works on the page and it works when embedding on a page (from a Gist), like this:\n<script src=\"https://gist.github.com/1009439.js\"></script>\n\nBut can I just include their JavaScript-library and let it highlight my code?" }, { "role": "assistant", "content": "Github uses pygments to highlight syntax. Pygments is running on the server, instead of a pure Javascript client solution. If you're looking for a Javascript solution check out this review of the various options." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git access to private repository using HTTPS\nTrying to clone a private repository I have access to using HTTPS protocol, as that is only allowed outgoing traffic.\ngit does not ask for passwords, just failed.\nerror: The requested URL returned error: 403 Forbidden while accessing https://github.com/blah/blahblah.git/info/refs\n\nWhat am I missing ?" }, { "role": "assistant", "content": "Did you try inserting the username (and optionally password) in the clone URL?\n git clone https://[email protected]/blah/blahblah.git\n\nor if you accept the consequences of storing your password in plain view:\n git clone https://username:[email protected]/blah/blahblah.git\n\nSee this thread with a lot of good info:\nHow to provide username and password when run \"git clone [email protected]\"?\nEDIT: My original answer was just a quick fix, without understanding the full history of the asker, and it also works unattended, but for best security practices its better to let Git store your password. See @phpguru's answer: https://stackoverflow.com/a/29018371/257090 as well." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs" }, { "role": "assistant", "content": "DISCUSSION Git is to some extent character encoding agnostic. The contents of the blob objects are uninterpreted sequences\nof bytes. There is no encoding translation at the core\nlevel. Path names are encoded in UTF-8 normalization form C. This\napplies to tree objects, the index file, ref names, as well as\npath names in command line arguments, environment variables\nand config files ( .git/config (see git-config ), gitignore , gitattributes and gitmodules ). Note that Git at the core level treats path names simply as\nsequences of non-NUL bytes, there are no path name encoding\nconversions (except on Mac and Windows). Therefore, using\nnon-ASCII path names will mostly work even on platforms and file\nsystems that use legacy extended ASCII encodings. However,\nrepositories created on such systems will not work properly on\nUTF-8-based systems (e.g. Linux, Mac, Windows) and vice versa.\nAdditionally, many Git-based tools simply assume path names to\nbe UTF-8 and will fail to display other encodings correctly. Commit log messages are typically encoded in UTF-8, but other\nextended ASCII encodings are also supported. This includes\nISO-8859-x, CP125x and many others, but not UTF-16/32,\nEBCDIC and CJK multi-byte encodings (GBK, Shift-JIS, Big5,\nEUC-x, CP9xx etc.). Although we encourage that the commit log messages are encoded\nin UTF-8, both the core and Git Porcelain are designed not to\nforce UTF-8 on projects. If all participants of a particular\nproject find it more convenient to use legacy encodings, Git\ndoes not forbid it. However, there are a few things to keep in\nmind. git commit and git commit-tree issue\na warning if the commit log message given to it does not look\nlike a valid UTF-8 string, unless you explicitly say your\nproject uses a legacy encoding. The way to say this is to\nhave i18n.commitEncoding in .git/config file, like this: [i18n]\n\tcommitEncoding = ISO-8859-1 Commit objects created with the above setting record the value\nof i18n.commitEncoding in their encoding header. This is to\nhelp other people who look at them later. Lack of this header\nimplies that the commit log message is encoded in UTF-8. git log , git show , git blame and friends look at the encoding header of a commit object, and try to re-code the\nlog message into UTF-8 unless otherwise specified. You can\nspecify the desired output encoding with i18n.logOutputEncoding in .git/config file, like this: [i18n]\n\tlogOutputEncoding = ISO-8859-1 If you do not have this configuration variable, the value of i18n.commitEncoding is used instead. Note that we deliberately chose not to re-code the commit log\nmessage when a commit is made to force UTF-8 at the commit\nobject level, because re-coding to UTF-8 is not necessarily a\nreversible operation." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %><( <N> ) , %><|( <M> )" }, { "role": "assistant", "content": "similar to %<( <N> ) , %<|( <M> ) respectively, but padding both sides\n(i.e. the text is centered)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitrevisions - Specifying revisions and ranges for Git <rev>^{} , e.g. v0.99.8^{}" }, { "role": "assistant", "content": "A suffix ^ followed by an empty brace pair\nmeans the object could be a tag,\nand dereference the tag recursively until a non-tag object is\nfound." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %GP" }, { "role": "assistant", "content": "show the fingerprint of the primary key whose subkey was used\nto sign a signed commit" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to install R package from private repo using devtools install_github?\n\nI am trying to install a sample package from my github repo:\nhttps://github.com/jpmarindiaz/samplepkg\nI can install it when the repo is public using any of the following commands through the R interpreter:\n\ninstall_github(\"jpmarindiaz/rdali\")\ninstall_github(\"rdali\",user=\"jpmarindiaz\")\ninstall_github(\"jpmarindiaz/rdali\",auth_user=\"jpmarindiaz\")\n\nBut when the git repository is private I get an Error:\nInstalling github repo samplepkg/master from jpmarindiaz\nDownloading samplepkg.zip from \nhttps://github.com/jpmarindiaz/samplepkg/archive/master.zip\nError: client error: (406) Not Acceptable\n\nI haven't figured out how the authentication works when the repo is private, any hints?" }, { "role": "assistant", "content": "Have you tried setting a personal access token (PAT) and passing it along as the value of the auth_token argument of install_github()? \nSee ?install_github way down at the bottom (Package devtools version 1.5.0.99)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to trigger a build only if changes happen on particular set of files\nHow do I tell Jenkins/Hudson to trigger a build only for changes on a particular project in my Git tree?" }, { "role": "assistant", "content": "If you are using a declarative syntax of Jenkinsfile to describe your building pipeline, you can use changeset condition to limit stage execution only to the case when specific files are changed. This is now a standard feature of Jenkins and does not require any additional configruation/software.\nstages {\n stage('Nginx') {\n when { changeset \"nginx/*\"}\n steps {\n sh \"make build-nginx\"\n sh \"make start-nginx\"\n }\n }\n}\n\nYou can combine multiple conditions using anyOf or allOf keywords for OR or AND behaviour accordingly:\nwhen {\n anyOf {\n changeset \"nginx/**\"\n changeset \"fluent-bit/**\"\n }\n}\nsteps {\n sh \"make build-nginx\"\n sh \"make start-nginx\"\n}" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-send-email - Send a collection of patches as emails --confirm=<mode>" }, { "role": "assistant", "content": "Confirm just before sending: always will always confirm before sending never will never confirm before sending cc will confirm before sending when send-email has automatically\nadded addresses from the patch to the Cc list compose will confirm before sending the first message when using --compose. auto is equivalent to cc + compose Default is the value of sendemail.confirm configuration value; if that\nis unspecified, default to auto unless any of the suppress options\nhave been specified, in which case default to compose ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Where does a Git branch start and what is its length?\nEvery now and then I'm asked, on what commit a certain branch on git starts or if a certain commit has been created on a specific branch. The end point of a branch is pretty clear: that's where the branch label sits. But - where did it start? The trivial answer would be: on that commit where we created that branch. But that information is, as far as I know now, and that's why I'm asking the question, lost after the first commits. \nAs long as we know the commit where we branched off, we can draw the graph to make it clear:\nA - B - C - - - - J [master]\n \\\n D - E - F - G [branch-A]\n \\\n H - - I [branch-B]\n\nI've created branch-B at commit E so that's the \"start\". I know that, because I did it. But can others recognize it the same way? We could draw the same graph like that:\nA - B - C - - - - J [master]\n \\\n \\ F - G [branch-A]\n \\ /\n D - E\n \\\n H - I [branch-B]\n\nSo, looking at the graph now, which branch started at E, which one at B? Is commit D a member of both branches or can we clearly decide whether it belongs to branch-A or branch-B?\nThis sounds somewhat philosophical but it really isn't. Supervisors sometimes like to know, when a branch has been started (it usually marks the start of a task) and to which branch some changes belong to (to get the purpose of some change - was it required for the work) and I'd like to know if git offers infos (tools, commands) or definitions to answer those questions correctly." }, { "role": "assistant", "content": "In Git, you could say that every branch starts at the root commit, and that would be quite literally true. But I guess that's not very helpful for you. What you could do instead is to define \"the start of a branch\" in relation to other branches. One way you can do this is to use\ngit show-branch branch1 branch2 ... branchN\n\nand that will show you the common commit between all specified branches at the bottom of the output (if there is, in fact, a common commit).\nHere's an example from the Linux Kernel Git documentation for show-branch\n$ git show-branch master fixes mhf\n* [master] Add 'git show-branch'.\n ! [fixes] Introduce \"reset type\" flag to \"git reset\"\n ! [mhf] Allow \"+remote:local\" refspec to cause --force when fetching.\n---\n + [mhf] Allow \"+remote:local\" refspec to cause --force when fetching.\n + [mhf~1] Use git-octopus when pulling more than one heads.\n + [fixes] Introduce \"reset type\" flag to \"git reset\"\n + [mhf~2] \"git fetch --force\".\n + [mhf~3] Use .git/remote/origin, not .git/branches/origin.\n + [mhf~4] Make \"git pull\" and \"git fetch\" default to origin\n + [mhf~5] Infamous 'octopus merge'\n + [mhf~6] Retire git-parse-remote.\n + [mhf~7] Multi-head fetch.\n + [mhf~8] Start adding the $GIT_DIR/remotes/ support.\n*++ [master] Add 'git show-branch'.\n\nIn that example, master is being compared with the fixes and mhf branches. Think of this output as a table, with each branch represented by its own column, and each commit getting its own row. Branches that contain a commit will have a + or - show up in their column in the row for that commit.\nAt the very bottom of the output, you'll see that all 3 branches share a common ancestor commit, and that it is in fact the head commit of master:\n*++ [master] Add 'git show-branch'.\n\nThis means that both fixes and mhf were branched off of that commit in master.\nAlternative solutions\nOf course that's only 1 possible way to determine a common base commit in Git. Other ways include git merge-base to find common ancestors, and git log --all --decorate --graph --oneline or gitk --all to visualize the branches and see where they diverge (though if there are a lot of commits that becomes difficult very quickly).\nOther questions from original poster\nAs for these questions you had:\n\nIs commit D a member of both branches or can we clearly decide whether it belongs to branch-A or branch-B?\n\nD is a member of both branches, it's an ancestor commit for both of them.\n\nSupervisors sometimes like to know, when a branch has been started (it usually marks the start of a task)...\n\nIn Git, you can rewrite the history of the entire commit tree(s) and their branches, so when a branch \"starts\" is not as set in stone as in something like TFS or SVN. You can rebase branches onto any point in time in a Git tree, even putting it before the root commit! Therefore, you can use it to \"start\" a task at any point in time in the tree that you want.\nThis is a common use case for git rebase, to sync branches up with the latest changes from an upstream branch, to push them \"forward\" in time along the commit graph, as if you had \"just started\" working on the branch, even though you've actually been working on it for a while. You could even push branches back in time along the commit graph, if you wanted to (though you might have to resolve a lot of conflicts, depending on the branch contents...or maybe you won't). You could even insert or delete a branch from right in the middle of your development history (though doing so would probably change the commit shas of a lot of commits). Rewriting history is one of the primary features of Git that makes it so powerful and flexible.\nThis is why commits come with both an authored date (when the commit was originally authored), and a committed date (when the commit was last committed to the commit tree). You can think of them as analogous to create time-date and last-modified time-date.\n\nSupervisors sometimes like to know...to which branch some changes belong to (to get the purpose of some change - was it required for the work).\n\nAgain, because Git allows you to rewrite history, you can (re)base a set of changes on pretty much any branch/commit in the commit graph that you want. git rebase literally allows you to move your entire branch around freely (though you might need to resolve conflicts as you go, depending on where you move the branch to and what it contains).\nThat being said, one of the tools you can use in Git to determine which branches or tags contains a set of changes is the --contains:\n# Which branches contains commit X?\ngit branch --all --contains X\n\n# Which tags contains commit X?\ngit tag --contains X" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-apply - Apply a patch to files and/or to the index --ignore-space-change --ignore-whitespace" }, { "role": "assistant", "content": "When applying a patch, ignore changes in whitespace in context\nlines if necessary.\nContext lines will preserve their whitespace, and they will not\nundergo whitespace fixing regardless of the value of the --whitespace option. New lines will still be fixed, though." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the difference between git push and git pull?\nI just stumbled over something peculiar today. I asked a co-worker at my summer job to help me set up a new remote git repo for my code and there was a lot of confusion about what he did and what I wanted to do. I asked him to send over his config to be able to see the path to his remote and found out that he didn't have a remote. When I asked him about this he explained his workflow like this:\n\nChange something locally\nCommit\nMove to remote dir\ngit pull c:\\localdir\n\nSo instead of pushing to a remote he constantly pulled from his local repo to the one on our server. Sort of working backwards. When I confronted him about this he asked me what the difference was and I could not really answer him, but I think there are something right?\nSo my question to you all is: What is the difference in pushing to a remote and pulling from a remote?" }, { "role": "assistant", "content": "Pushing to a remote : send some commits you have to a another git repo. The git repo is considered as \"remote\", but it can be a repo in another folder of your hard drive.\npulling from a remote : get some commits from a remote repo and merge them in your current HEAD (your current checkout of your repo)\nYour coworker might have use pull instead of push because your repository might not have been available (no git daemon running, or gitweb, or ssh server on), but his was avalaible from your computer. As it is a server, he might not want to expose a git daemon/service which could be a vector of attack.\nBut if your repository was shared/available, he would just have been able to do : \n\nchange something locally\ncommit\npush to your repository" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --dst-prefix=<prefix>" }, { "role": "assistant", "content": "Show the given destination prefix instead of \"b/\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I embed a snippet code at my Linkedin article?\n\nI want to embed a snippet code at my LinkedIn article, like that:\n\nThat image is from Gitlab snippets (https://gitlab.com/snippets/1841785). Is there some way to render its content in the LinkedIn articles? I saw that post at my LinkedIn feed and I got curious how to do this.\nI noticed that Gitlab provides two way to get the snippet: a embed or share content. How should I use?\nThank you." }, { "role": "assistant", "content": "Use https://carbon.now.sh/ for creating beautiful code snippets and download the pic and use it wherever you want" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I connect github to JIRA?\n\nI've been trying to find a way to update JIRA when I commit to github.\nIt doesn't look like there are any service hooks to do it at github, but you never know, someone might have a ninja way, so I thought I'd ask." }, { "role": "assistant", "content": "UPDATE\nFor integrating with Bitbucket, check out the following link:\nLinking Bitbucket and GitHub accounts to JIRA\nORIGINAL POST\nJIRA GitHub Connector is deprecated:\n\nThis plugin has been superseded by the JIRA DVCS Connector, which includes GitHub functionality.\n\nSo to connect Jira to github use JIRA DVCS Connector for Bitbucket and GitHub:\n\nYou can connect Bitbucket or GitHub accounts with JIRA using the free JIRA DVCS Connector plugin. This plugin comes with JIRA OnDemand. For JIRA download users, this is a system plugin that you can install. Using the DVCS connector, you can:\n\nLink all or a subset of your existing repositories (both public and private to JIRA).\nCreate new repositories and have them link automatically to JIRA.\nReference JIRA issues from DVCS commit message and have those commits appear in the issue's Commits tab in JIRA.\nTransition issues through a JIRA OnDemand workflow (for example, Close, Reopen, and so forth) using smart commit messages.\n\n\ncheck out Using the JIRA DVCS Connector Plugin for more information." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What's the correct way to check if it's possible to perform a fast-forward merge with git merge-base?\nI've created a bash script that performs the following tasks:\n\nFetch changes from upstream;\nCheck if a fast-forward merge is possible;\nMerge origin/master into master if #2 is true;\nRebase master on top of origin/master if #2 is false\n\nThe code is as follows:\n#!/bin/sh\n\nlocal_branch=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)\nremote_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u})\nremote=$(git config branch.$local_branch.remote)\n\necho \"Fetching from $remote...\"\ngit fetch $remote\n\nif git merge-base --is-ancestor $local_branch $remote_branch; then\n echo 'Fast-forward is possible. Merging...'\n git merge --ff-only $remote_branch\nelse\n echo 'Fast-forward is not possible. Rebasing...'\n git rebase --preserve-merges $remote_branch\nfi\n\nI tested it a few times and it seems to work, but I'm not very confident about the git merge-base part. I know the theory behind a fast-forward merge, and it seems right to use master and origin/master as arguments to merge-base, but I'm no Git expert. \nSo I ask: is that the correct way to check if a fast-forward merge is possible just after a fetch is performed?" }, { "role": "assistant", "content": "git merge-base --is-ancestor <commit> <commit>\n\n--is-ancestor Checks if the first <commit> is an ancestor of the second <commit>, and exit with status 0 if true, or with status 1 if not. Errors are signaled by a non-zero status that is not 1.\ne.g.\n git merge-base --is-ancestor origin/master master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Should I use past or present tense in git commit messages? [closed]\nClosed. This question is opinion-based. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it can be answered with facts and citations by editing this post.\n\n\nClosed 10 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI read once that git commit messages should be in the imperative present tense, e.g. \"Add tests for x\". I always find myself using the past tense, e.g. \"Added tests for x\" though, which feels a lot more natural to me.\nHere's a recent John Resig commit showing the two in one message:\n\nTweak some more jQuery set results in the manipulation tests. Also fixed the order of the expected test results.\n\nDoes it matter? Which should I use?" }, { "role": "assistant", "content": "The preference for present-tense, imperative-style commit messages comes from Git itself. From Documentation/SubmittingPatches in the Git repo:\n\nDescribe your changes in imperative mood, e.g. \"make xyzzy do frotz\"\ninstead of \"[This patch] makes xyzzy do frotz\" or \"[I] changed xyzzy\nto do frotz\", as if you are giving orders to the codebase to change\nits behavior.\n\nSo you'll see a lot of Git commit messages written in that style. If you're working on a team or on open source software, it is helpful if everyone sticks to that style for consistency. Even if you're working on a private project, and you're the only one who will ever see your git history, it's helpful to use the imperative mood because it establishes good habits that will be appreciated when you're working with others." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Access GitLab repo with project access token\nAccording to the documentation, it should be possible to access GitLab repos with project access tokens:\n\nThe username is set to project_{project_id}_bot, such as project_123_bot.\n\nNever mind that that's a lie -- the actual user is called project_4194_bot1 in my case; apparently they increment a number for subsequent tokens.\nEither way -- and I have tried both with and without the trailing 1 -- I would expect\ngit clone \"https://project_4194_bot1:[email protected]/my-group/my-project.git\"\n\nto succeed, same as with my.username:$PERSONAL_TOKEN (which works perfectly). However, I get\nremote: HTTP Basic: Access denied\nfatal: Authentication failed for '<snip>'\n\nWhat may be going on here? How can I access GitLab repositories using project access tokens?\n\nIt's not as if we'd get that far, but FWIW, the token seems to have sufficient permissions:" }, { "role": "assistant", "content": "It seems that using the project name as username works. In your case replacing project_4194_bot1 with my-project should work:\ngit clone \"https://my-project:[email protected]/my-group/my-project.git\"\n\nEDIT: One can actually use any non-blank value as a username (see docs), as others correctly pointed out." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker" }, { "role": "assistant", "content": "Authors Git was started by Linus Torvalds, and is currently maintained by Junio\nC Hamano. Numerous contributions have come from the Git mailing list\n< [email protected] >. https://openhub.net/p/git/contributors/summary gives you a more complete list of contributors. If you have a clone of git.git itself, the\noutput of git-shortlog and git-blame can show you\nthe authors for specific parts of the project." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to protect \"master\" in github?\n\nI have a few contributors in my github project. I want to allow only one of them to \"push\" to master. And this guy is not me (the owner of the repository). Is it possible to do?" }, { "role": "assistant", "content": "Back then, when this question was posted, GitHub didn't allow you to specify access privileges on a branch level. You can only do it on a repository level. So what you are requesting wasn't possible.\nIf you want to work around this limitation, I personally see two options:\n\nyou could use some kind of commit hooks, etc. to at least inform someone that something wrong happened\nIf you really need this tight control, you could use two repositories, one only holding your \"master\" branch. You would then need to make sure that only your \"guy\" gets write access to the master repository\n\nI think it is easier to solve that with some organisation. In my team, we never push anything directly to master, but instead always create pull requests. That ensures that at least someone takes a look before code gets merged and you could also define a policy that only your \"guy\" is allowed to merge pull requests.\nUpdate\nGitHub now announced that they will roll-out a new feature called protected branches. This feature has been present in other git distributions like Atlassian Stash for years. It will allow you to protect some branches from pushes. However, it still doesn't allow complete ACL-based protection of individual branches. So you might want to check this feature out in case you don't want to rely on an organizational solution as outline above." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.statGraphWidth" }, { "role": "assistant", "content": "Limit the width of the graph part in --stat output. If set, applies\nto all commands generating --stat output except format-patch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker <tree-ish>" }, { "role": "assistant", "content": "Indicates a tree, commit or tag object name. A\ncommand that takes a <tree-ish> argument ultimately wants to\noperate on a <tree> object but automatically dereferences\n<commit> and <tag> objects that point at a <tree>." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": ".gitignore not ignoring web.config\nFor my remote repository, I'm trying to ignore the web.config file of my Umbraco website.\nThe .gitignore is in the root of my website, and the file to ignore, web.config is also in the root of my website.\nso I added this line to my .gitignore file:\nweb.config\n\nBut everytime I push changes to my remote repository, the web.config file is also pushed to the remote repository.\nWhat am I doing wrong?" }, { "role": "assistant", "content": "git will not ignore a file that's already tracked before a rule is added to this file to ignore it. In such a case, the file must be un-tracked with git rm --cached <filename>.\nSo, if you are trying to ignore this file newly, run this: git rm --cached web.config." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-status - Show the working tree status -v --verbose" }, { "role": "assistant", "content": "In addition to the names of files that have been changed, also\nshow the textual changes that are staged to be committed\n(i.e., like the output of git diff --cached ). If -v is specified\ntwice, then also show the changes in the working tree that\nhave not yet been staged (i.e., like the output of git diff )." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab repository mirroring\nIs it possible to have gitlab set up to automatically sync (mirror) a repository hosted at another location?\nAt the moment, the easiest way I know of doing this involves manually pushing to the two (gitlab and the other) repository, but this is time consuming and error prone.\nThe greatest problem is that a mirror can resynchronize if two users concurrently push changes to the two different repositories. The best method I can come up with to prevent this issue is to ensure users can only push to one of the repositories." }, { "role": "assistant", "content": "Update Dec 2016: Mirroring is suported with GitLAb EE 8.2+: see \"Repository mirroring\".\nAs commented by Xiaodong Qi:\n\nThis answer can be simplified without using any command lines (just set it up on Gitlab repo management interface)\n\n\nOriginal answer (January 2013)\nIf your remote mirror repo is a bare repo, then you can add a post-receive hook to your gitlab-managed repo, and push to your remote repo in it.\n#!/bin/bash\ngit push --mirror [email protected]:/path/to/repo.git\n\nAs Gitolite (used by Gitlab) mentions:\n\nif you want to install a hook in only a few specific repositories, do it directly on the server.\n\nwhich would be in:\n~git/repositories/yourRepo.git/hook/post-receive\n\n\nCaveat (Update Ocotober 2014)\nCiro Santilli points out in the comments:\n\nToday (Q4 2014) this will fail because GitLab automatically symlinks github.com/gitlabhq/gitlab-shell/tree/… into every repository it manages.\n So if you make this change, every repository you modify will try to push.\n Not to mention possible conflicts when upgrading gitlab-shell, and that the current script is a ruby script, not bash (and you should not remove it!). \nYou could correct this by reading the current directory name and ensuring bijection between that and the remote, but I recommend people to stay far far away from those things\n\nSee (and vote for) feeadback \"Automatic push to remote mirror repo after push to GitLab Repo\".\n\nUpdate July 2016: I see this kind of feature added for GitLab EE (Enterprise Edition): MR 249\n\nAdd ability to enter remote push URL under Mirror Repository settings\nAdd implementation code to push to remote repository\nAdd new background worker\nShow latest update date and sync errors if they exists.\nSync remote mirror every hour.\n\nNote that the recent Remote Mirror Repository (issues 17940) can be tricky:\n\nI'm currently trying to shift main development of the Open Source npm modules of my company Lossless GmbH (https://www.npmjs.com/~lossless) from GitHub.com to GitLab.com\nI'm importing all the repos from GitHub, however when I try to switch off Mirror Repository and switch on Remote Mirror Repository with the original GitHub URL I get an error saying: \n\nRemote mirrors url is already in use\n\nHere is one of the repos this fails with: https://gitlab.com/pushrocks/npmts\nEdited 2 months ago\n\nturns out, it just requires multiple steps:\n\ndisable the Mirror Repository\npress save\nremove the URl\npress save\nthen add the Remote Mirror" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --invert-grep" }, { "role": "assistant", "content": "Limit the commits output to ones with a log message that do not\nmatch the pattern specified with --grep=<pattern> ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I completely remove Git from an Android Studio project?\nI'm developing my first project with Android Studio and can't quite get Git and GitHub configured properly. I'd like to completely remove my project from Git/Git from my project and start fresh. How can I do this? Also, there is no .git folder in my project folder, so where are my git files stored locally and how can I completely start over with Git and GitHub?\nI've set VCS to 'None' in Settings -> Version Control, but I don't think this removes Git. The directory shows as \"Unregistered roots\". I was also wondering if it is normal to have several directories showing in this view? At times I've had and some directory, and at the moment I have my project directory and as Unregistered root \"app ( [my app directory] )\"...\nAt one point I managed to push stuff onto GitHub, but only some of my project files. Others, which I added to the project after the initial commit, showed up as unversioned, I added them and tried to commit and push, but couldn't. Also, they went back to unversioned every time I built my project. This is why I'd like to completely start over" }, { "role": "assistant", "content": "From Android Studio Preferences,(My Android Studio version 3.6.1)\nSelect Version Control->Select git Path-> Click ' - ' (minus button)->OK\nWindows: File > Settings > Version Control > Select Project > '-' (Minus Button) >Apply > Ok\nUPDATE:\nCurrently google updated this settings.So if you want to delete GitHub connection from your project Open android Studio Settings ->Version Control ->Github -> click ' - ' (minus button) -> Apply -> OK" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-merge - Join two or more development histories together -F <file> --file=<file>" }, { "role": "assistant", "content": "Read the commit message to be used for the merge commit (in\ncase one is created). If --log is specified, a shortlog of the commits being merged\nwill be appended to the specified message." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-describe - Give an object a human readable name based on an available ref" }, { "role": "assistant", "content": "NAME git-describe - Give an object a human readable name based on an available ref" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-ls-files - Show information about files in the index and the working tree ?" }, { "role": "assistant", "content": "untracked file" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs -s --no-patch" }, { "role": "assistant", "content": "Suppress all output from the diff machinery. Useful for\ncommands like git show that show the patch by default to\nsquelch their output, or to cancel the effect of options like --patch , --stat earlier on the command line in an alias." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Configuring user and password with Git Bash\nI am using Git Bash on Windows 7. We are using GitHub as our repository origin.\nEvery time I push or pull I have to provide user and password credentials. I know that my SSH keys are set up correctly, otherwise I would not be able to access the repository. (That is, once I enter my credentials the push/pull works correctly.)\nI have entered\ngit config --global user.name myusername\ngit config --global user.email myemail\ngit config --global github.user myusername\ngit config --global github.token mytoken\n\nBut nonetheless I am being asked for credentials each and every time I push/pull." }, { "role": "assistant", "content": "Make sure you are using the SSH URL for the GitHub repository rather than the HTTPS URL. It will ask for username and password when you are using HTTPS and not SSH. You can check the file .git/config or run git config -e or git remote show origin to verify the URL and change it if needed.\nYou can change the URL with: [1]\ngit remote set-url origin git+ssh://[email protected]/username/reponame.git\n\n[1] This portion incorporates the answer to this question." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database badDate" }, { "role": "assistant", "content": "(ERROR) Invalid date format in an author/committer line." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-am - Apply a series of patches from a mailbox --quit" }, { "role": "assistant", "content": "Abort the patching operation but keep HEAD and the index\nuntouched." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Line history viewer - Git\nI wondered if any of you knew of a tool that would allow me to select a line in my code and then view a list view of the history of that line on a commit-by-commit basis.\nDoes anyone know of such a tool?" }, { "role": "assistant", "content": "Maybe annotations in IntelliJ IDEA is that you are looking for:\n\nShowing and hiding annotations\n\nOpen the desired file in the editor.\nTo show annotations, right-click the left gutter, and select Annotate:\n\nTo hide annotations, right-click the annotations gutter, and choose Close Annotations." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_TRACE_SETUP" }, { "role": "assistant", "content": "Enables trace messages printing the .git, working tree and current\nworking directory after Git has completed its setup phase.\nSee GIT_TRACE for available trace output options." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-switch - Switch branches -t --track [direct|inherit]" }, { "role": "assistant", "content": "When creating a new branch, set up \"upstream\" configuration. -c is implied. See --track in git-branch for\ndetails. If no -c option is given, the name of the new branch will be derived\nfrom the remote-tracking branch, by looking at the local part of the\nrefspec configured for the corresponding remote, and then stripping\nthe initial part up to the \"*\". This would tell us to use hack as\nthe local branch when branching off of origin/hack (or remotes/origin/hack , or even refs/remotes/origin/hack ). If the\ngiven name has no slash, or the above guessing results in an empty\nname, the guessing is aborted. You can explicitly give a name with -c in such a case." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters --symbolic-full-name" }, { "role": "assistant", "content": "This is similar to --symbolic, but it omits input that\nare not refs (i.e. branch or tag names; or more\nexplicitly disambiguating \"heads/master\" form, when you\nwant to name the \"master\" branch when there is an\nunfortunately named tag \"master\"), and shows them as full\nrefnames (e.g. \"refs/heads/master\")." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to set default fork for pull requests?\n\nI have a set of documentation for my company's API, based on the excellent Slate framework from TripIt. Per instructions, I forked their repo and proceeded to customize it. That fork lives here.\nThe obnoxious thing is that when contributors in my organization do a new pull request, the \"base fork\" on the Github \"Comparing Changes\" screen defaults to TripIt's repository, not my fork. They've more than once sent pull requests to the wrong place. Telling people \"don't do that\" isn't a particularly reliable solution. How can I set the default for where PRs are based to my fork?" }, { "role": "assistant", "content": "GitHub keeps track of forks made through their interface and assumes pull requests will be for that original repository. You need to tell GitHub that your copy is not a fork but rather a regular repository that just happens to have identical history. Sadly, GitHub doesn't offer a good way to just uncheck the fork link. I typically solve it this way:\n\nClone the repository, git pull, and ensure your local copy is completely up to date.\nDelete the repository on GitHub.\nCreate the repository on GitHub using the exact same name. Ensure it's an empty repository (don't create a README or LICENSE file.)\ngit push all the content back into the repository. (You may need to switch to each branch and push it, and you also may need to git push --tags.)\n\nFRAGILE: This approach will lose existing GitHub issues and pull request comments. If you're using these heavily, this approach is probably a bad idea, and you should contact GitHub customer support to help you instead." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --merges" }, { "role": "assistant", "content": "Print only merge commits. This is exactly the same as --min-parents=2 ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects -m" }, { "role": "assistant", "content": "Show diffs for merge commits in the default format. This is\nsimilar to --diff-merges=on , except -m will\nproduce no output unless -p is given as well." } ]