messages
listlengths
3
3
[ { "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 -u --unmerged" }, { "role": "assistant", "content": "Show information about unmerged files in the output, but do\nnot show any other tracked files (forces --stage, overrides\n--cached)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Automatic tagging of releases\nHow do you tag your release versions in git?\nNow I have each release identified by build number, but they increment even if there are no changes in the repo. My idea is to have it generated automatically on successful deployment on staging server. E.g.\n\nrun Hudson build\nwhen successful, add new tag, i.e. 1.0-1\non next successful build add next tag, 1.0-2\nversion tag is displayed then in site footer\n\nThis would require:\n\nHudson to manage next version numbers\nor script to store last tag in some file\nor parse git tags to determine last\n\nAny tips?" }, { "role": "assistant", "content": "I wrote this to help with updating tags incrementally e.g. 1.0.1 to 1.0.2 etc.\n2020 update: I have posted an improved version beneath/here. (Also worth seeing @Geoffrey's answer below for some comments on branching).\n#!/bin/bash\n\n#get highest tag number\nVERSION=`git describe --abbrev=0 --tags`\n\n#replace . with space so can split into an array\nVERSION_BITS=(${VERSION//./ })\n\n#get number parts and increase last one by 1\nVNUM1=${VERSION_BITS[0]}\nVNUM2=${VERSION_BITS[1]}\nVNUM3=${VERSION_BITS[2]}\nVNUM3=$((VNUM3+1))\n\n#create new tag\nNEW_TAG=\"$VNUM1.$VNUM2.$VNUM3\"\n\necho \"Updating $VERSION to $NEW_TAG\"\n\n#get current hash and see if it already has a tag\nGIT_COMMIT=`git rev-parse HEAD`\nNEEDS_TAG=`git describe --contains $GIT_COMMIT 2>/dev/null`\n\n#only tag if no tag already\nif [ -z \"$NEEDS_TAG\" ]; then\n git tag $NEW_TAG\n echo \"Tagged with $NEW_TAG\"\n git push --tags\nelse\n echo \"Already a tag on this commit\"\nfi\n\n\nI revisit this 6 years later needing to write a similar script for uploading to npm. Code below or here, comments and suggestions appreciated and welcome:\n#!/bin/bash\n\n# https://github.com/unegma/bash-functions/blob/main/update.sh\n\nVERSION=\"\"\n\n#get parameters\nwhile getopts v: flag\ndo\n case \"${flag}\" in\n v) VERSION=${OPTARG};;\n esac\ndone\n\n#get highest tag number, and add 1.0.0 if doesn't exist\nCURRENT_VERSION=`git describe --abbrev=0 --tags 2>/dev/null`\n\nif [[ $CURRENT_VERSION == '' ]]\nthen\n CURRENT_VERSION='1.0.0'\nfi\necho \"Current Version: $CURRENT_VERSION\"\n\n\n#replace . with space so can split into an array\nCURRENT_VERSION_PARTS=(${CURRENT_VERSION//./ })\n\n#get number parts\nVNUM1=${CURRENT_VERSION_PARTS[0]}\nVNUM2=${CURRENT_VERSION_PARTS[1]}\nVNUM3=${CURRENT_VERSION_PARTS[2]}\n\nif [[ $VERSION == 'major' ]]\nthen\n VNUM1=$((VNUM1+1))\nelif [[ $VERSION == 'minor' ]]\nthen\n VNUM2=$((VNUM2+1))\nelif [[ $VERSION == 'patch' ]]\nthen\n VNUM3=$((VNUM3+1))\nelse\n echo \"No version type (https://semver.org/) or incorrect type specified, try: -v [major, minor, patch]\"\n exit 1\nfi\n\n\n#create new tag\nNEW_TAG=\"$VNUM1.$VNUM2.$VNUM3\"\necho \"($VERSION) updating $CURRENT_VERSION to $NEW_TAG\"\n\n#get current hash and see if it already has a tag\nGIT_COMMIT=`git rev-parse HEAD`\nNEEDS_TAG=`git describe --contains $GIT_COMMIT 2>/dev/null`\n\n#only tag if no tag already\n#to publish, need to be logged in to npm, and with clean working directory: `npm login; git stash`\nif [ -z \"$NEEDS_TAG\" ]; then\n npm version $NEW_TAG\n npm publish --access public\n echo \"Tagged with $NEW_TAG\"\n git push --tags\n git push\nelse\n echo \"Already a tag on this commit\"\nfi\n\nexit 0\n\n\nSubnote: this won't work with zsh as (for one), zsh doesn't use 0 indexed arrays." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git push rejected: error: failed to push some refs\nI know people have asked similar questions, but I believe the causes of their problems to be different. I did a hard reset because I had messed up my code pretty bad\n git reset --hard 41651df8fc9\n\nI've made quite some changes, I've made some commits and now that I'm trying to push all these commits into the server I get the following error:\n ! [rejected] master -> master (non-fast-forward)\nerror: failed to push some refs to '[email protected]'\n\nGit suggests to do a git pull and that's what other people have suggested to other users. However, I believe that a git pull will merge my current code with the code that I don't want anymore (head revision).\nHow can I do a push and forget about the version/revisions ahead of me?" }, { "role": "assistant", "content": "git push -f if you have permission, but that will screw up anyone else who pulls from that repo, so be careful.\nIf that is denied, and you have access to the server, as canzar says below, you can allow this on the server with\ngit config receive.denyNonFastForwards false" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "githooks - Hooks used by Git" }, { "role": "assistant", "content": "DESCRIPTION Hooks are programs you can place in a hooks directory to trigger\nactions at certain points in git’s execution. Hooks that don’t have\nthe executable bit set are ignored. By default the hooks directory is $GIT_DIR/hooks , but that can be\nchanged via the core.hooksPath configuration variable (see git-config ). Before Git invokes a hook, it changes its working directory to either\n$GIT_DIR in a bare repository or the root of the working tree in a non-bare\nrepository. An exception are hooks triggered during a push ( pre-receive , update , post-receive , post-update , push-to-checkout ) which are always\nexecuted in $GIT_DIR. Environment variables, such as GIT_DIR , GIT_WORK_TREE , etc., are exported\nso that Git commands run by the hook can correctly locate the repository. If\nyour hook needs to invoke Git commands in a foreign repository or in a\ndifferent working tree of the same repository, then it should clear these\nenvironment variables so they do not interfere with Git operations at the\nforeign location. For example: local_desc=$(git describe)\nforeign_desc=$(unset $(git rev-parse --local-env-vars); git -C ../foreign-repo describe) Hooks can get their arguments via the environment, command-line\narguments, and stdin. See the documentation for each hook below for\ndetails. git init may copy hooks to the new repository, depending on its\nconfiguration. See the \"TEMPLATE DIRECTORY\" section in git-init for details. When the rest of this document refers\nto \"default hooks\" it’s talking about the default template shipped\nwith Git. The currently supported hooks are described below." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch --edit -e --no-edit" }, { "role": "assistant", "content": "Invoke an editor before committing successful mechanical merge to\nfurther edit the auto-generated merge message, so that the user\ncan explain and justify the merge. The --no-edit option can be\nused to accept the auto-generated message (this is generally\ndiscouraged). Older scripts may depend on the historical behaviour of not allowing the\nuser to edit the merge log message. They will see an editor opened when\nthey run git merge . To make it easier to adjust such scripts to the\nupdated behaviour, the environment variable GIT_MERGE_AUTOEDIT can be\nset to no at the beginning of them." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Where is the global git config data stored?\nWhen using git config --global to set things up, to which file will it write?\nExample:\ngit config --global core.editor \"blah\"\n\nI can't find it at these places:\nC:\\Program Files\\Git\\etc\\gitconfig\n\nC:\\myapp\\.git\\config\n\nI have not set an ENV?\nMy Git version: 1.6.5.1.1367.gcd48 –\non Windows 7" }, { "role": "assistant", "content": "Update 2016: with git 2.8 (March 2016), you can simply use:\ngit config --list --show-origin\n\nAnd with Git 2.26 (Q1 2020), you can add a --show-scope option\ngit config --list --show-origin --show-scope\n\nYou will see which config is set where.\nSee \"Where do the settings in my Git configuration come from?\"\nAs Stevoisiak points out in the comments,\n\nit will work with non-standard install locations. (i.e. Git Portable)\n\n(like the latest PortableGit-2.14.2-64-bit.7z.exe, which can be uncompressed anywhere you want)\n\nOriginal answer (2010)\nFrom the docs:\n\n--global\nFor writing options: write to global ~/.gitconfig file rather than the repository .git/config.\n\nSince you're using Git for Windows, it may not be clear what location this corresponds to. But if you look at etc/profile (in C:\\Program Files\\Git), you'll see:\nHOME=\"$HOMEDRIVE$HOMEPATH\"\n\nMeaning:\nC:\\Users\\MyLogin\n\n(on Windows 7)\nThat means the file is in C:\\Users\\MyLogin\\.gitconfig for Git in Windows 7." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I remove an entry in global configuration with git config?\nI ran a global configuration command in git to exclude certain files using a .gitignore_global file:\ngit config --global core.excludesfile ~/.gitignore_global\n\nIs there a way to undo the creation of this setting globally?" }, { "role": "assistant", "content": "I'm not sure what you mean by \"undo\" the change. You can remove the core.excludesfile setting like this:\ngit config --global --unset core.excludesfile\n\nAnd of course you can simply edit the config file:\ngit config --global --edit\n\n...and then remove the setting by hand." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Moving an existing GitLab project into a new subgroup\n\nJust started out using self hosted GitLab... it looks like it's going to be really useful moving towards a DevOps workflow.\nAnyway, after migrating about 20 local Git repositories to the new GitLab server, neatly arranged into 4 groups. I then noticed you can actually have sub-groups within the groups. This would help organisation even further, but I'm struggling to work out how to move the existing projects I've spent a day importing and configuring into a newly created sub-group. Sure I could just create a new project and copy the files over and commit them into the new project, and spend the time reconfiguring the project.\nIs there an easy way of moving the existing configured Project from the group into the new subgroup?" }, { "role": "assistant", "content": "Turns out the \"slug\" for a project... the part of the URL after the GitLab server domain name is made up of the \"namespace\" and the project name. The name space is the group/subgroup path, so I was looking to transfer project to new namespace.\nSo for example if the group is \"important-group\" and project is called \"project\". Then the slug will be something like /important-group/project. To then move that to /important-group/sub-group/project, we need to create the new subgroup (down arrow next to the \"New project\" button). Then change the project namespace.\nTo do this, go to the project page, click the settings button (cog bottom left). Go to the Advanced settings section. And it's just below the rename project option.\nnote: you need to have \"owner\" privileges on the project otherwise the settings don't appear... maintainer or developer is not enough.\n\nJust select the new subgroup and your done!\nHere is the GitLab docs link with more info on managing projects in GitLab, in case that is useful to anyone." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to link a folder with an existing Heroku app\nI have an existing Rails app on GitHub and deployed on Heroku. I'm trying to set up a new development machine and have cloned the project from my GitHub repository. However, I'm confused as to how to link this folder up to Heroku. Originally, I used the heroku create command, but obviously I don't want to do that this time since it will create another Heroku instance." }, { "role": "assistant", "content": "Heroku links your projects based on the heroku git remote (and a few other options, see the update below). To add your Heroku remote as a remote in your current repository, use the following command:\ngit remote add heroku [email protected]:project.git\n\nwhere project is the name of your Heroku project (the same as the project.heroku.com subdomain). Once you've done so, you can use the heroku xxxx commands (assuming you have the Heroku Toolbelt installed), and can push to Heroku as usual via git push heroku master. As a shortcut, if you're using the command line tool, you can type:\nheroku git:remote -a project\n\nwhere, again, project is the name of your Heroku project (thanks, Colonel Panic). You can name the Git remote anything you want by passing -r remote_name.\n[Update]\nAs mentioned by Ben in the comments, the remote doesn't need to be named heroku for the gem commands to work. I checked the source, and it appears it works like this:\n\nIf you specify an app name via the --app option (e.g. heroku info --app myapp), it will use that app.\nIf you specify a Git remote name via the --remote option (e.g. heroku info --remote production), it will use the app associated with that Git remote.\nIf you specify no option and you have heroku.remote set in your Git config file, it will use the app associated with that remote (for example, to set the default remote to \"production\" use git config heroku.remote production in your repository, and Heroku will run git config heroku.remote to read the value of this setting)\nIf you specify no option, the gem finds no configuration in your .git/config file, and the gem only finds one remote in your Git remotes that has \"heroku.com\" in the URL, it will use that remote.\nIf none of these work, it raises an error instructing you to pass --app to your command." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git diff between cloned and original remote repository\nI have cloned a github repository and made no changes locally. Github repository moved forward with commits on the same branch.\n\nHow do I find a diff between my local repository and the original github repository?\nHow do I find a diff between my working copy and the original github repository?\nHow do I find a diff between my local repository and another github repository of the same project?" }, { "role": "assistant", "content": "1) Add any remote repositories you want to compare:\ngit remote add foobar git://github.com/user/foobar.git\n\n2) Update your local copy of a remote:\ngit fetch foobar\n\nFetch won't change your working copy.\n3) Compare any branch from your local repository to any remote you've added:\ngit diff master foobar/master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why is 'Updating the Git index failed' displayed\nI am using Windows. When staging files I get this error.\nUpdating the Git index failed. A rescan will be automatically started to resynchronize git-gui.\nfollowed by a list of files which have been converted from LF to CRLF\nAfter a lot of reading up on the CRLF / LF issue with Git usage cross platform, I more or less understand what is going on, and I am trying to determine which autocrlf setting is best for me, but I cant understand why Git says that Updating the index failed. My understanding is that it has converted the EOF's so what is the problem with that and why is it telling me that updating the index has failed. Do I need to fix something ( other than picking an appropriate autocrlf setting) or can I just proceed\nI then have two options Continue and Unlock Index, what do these mean and what is the best course of action." }, { "role": "assistant", "content": "git config --global core.autocrlf false\n\nHas always been my recommendation (see \"Git 1.6.4 beta on Windows (msysgit) - Unix or DOS line termination\").\nHowever, in your case, you can \"Continue\", but this warning is there to mention the conversion of certain files might not be reversible:\ncore.safecrlf\n\n\nIf true, makes git check if converting CRLF is reversible when end-of-line conversion is active. Git will verify if a command modifies a file in the work tree either directly or indirectly. For example, committing a file followed by checking out the same file should yield the original file in the work tree. If this is not the case for the current setting of core.autocrlf, git will reject the file.\n The variable can be set to \"warn\", in which case git will only warn about an irreversible conversion but continue the operation. \n\nIf you don't want to see this warning, as explained in this thread, you can set core.safecrlf to false.\nYou could also stash your files through the tools menu of git gui, and add some options to those tools with, for instance, this git config file.\nThe interest is that, for each tool, you can add:\nguitool.<name>.norescan\n\n\nDon’t rescan the working directory for changes after the tool finishes execution.\n\n\n\nCould you please elaborate a bit on Unlock Index\n\nyou can see that message in the index.tcl git-gui script: it removes the index.lock file the git-gui creates when manipulating the index.\nYou can see more at the \"lockfile API\" documentation page:\n\nMutual exclusion.\n When we write out a new index file, first we create a new file $GIT_DIR/index.lock, write the new contents into it, and rename it to the final destination $GIT_DIR/index.\n We try to create the $GIT_DIR/index.lock file with O_EXCL so that we can notice and fail when somebody else is already trying to update the index file." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Pushing from local repository to GitHub hosted remote\nI created a local repository of my Visual Studio 2010 solution folder using Git GUI on my dev machine. I then created a remote repository in my GitHub account. Now, I am looking for how to push my local repository to the remote repository.\nIn SVN I can just commit using TortoiseSVN and changes are pushed to the remote repository. I don't see any tool like that available for Git. \nHow do I push my local repo to my remote repo on GitHub?" }, { "role": "assistant", "content": "You push your local repository to the remote repository using the git push command after first establishing a relationship between the two with the git remote add [alias] [url] command. If you visit your Github repository, it will show you the URL to use for pushing. You'll first enter something like:\ngit remote add origin [email protected]:username/reponame.git\n\nUnless you started by running git clone against the remote repository, in which case this step has been done for you already.\nAnd after that, you'll type:\ngit push origin master\n\nAfter your first push, you can simply type:\ngit push\n\nwhen you want to update the remote repository in the future." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options core.symlinks" }, { "role": "assistant", "content": "If false, symbolic links are checked out as small plain files that\ncontain the link text. git-update-index and git-add will not change the recorded type to regular\nfile. Useful on filesystems like FAT that do not support\nsymbolic links. The default is true, except git-clone or git-init will probe and set core.symlinks false if appropriate when the repository\nis created." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-whatchanged" }, { "role": "assistant", "content": "Show logs with differences each commit introduces" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options gc.maxCruftSize" }, { "role": "assistant", "content": "Limit the size of new cruft packs when repacking. When\nspecified in addition to --max-cruft-size , the command line\noption takes priority. See the --max-cruft-size option of git-repack ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "SourceTree App says uncommitted changes even for newly-cloned repository - what could be wrong?\nA remote git repository is just cloned to a local box using Atlassian SourceTree. Even no files have really been modified in the work tree, Atlassian lists a bunch of files right away under \"Uncommitted changes\". Each file shows same line count both as removed and added, and this count equals to the total count of lines in the file. This would somehow give a hint that we're hitting some kind of line ending problem.\nHowever, the repository's .gitattribute contains\n# Set default behaviour, in case users don't have core.autocrlf set.\n* text=auto\n\nthat per GitHub article Dealing with Line Endings should make explicitly core.autocrlf true for the repository. However also ~/.gitconfig contains autocrlf = true.\nIf the modified files are tried to be \"reverted\" back to previous commit, there is no effect. Same files are still seen as uncommitted.\nThe repository has been cloned into multiple locations and ensured that no files have been in the same path, to make sure that SourceTree or git do not remember old files.\nThe repository is collaborated with Windows, Linux and OSX boxes. This problem appears only in OSX.\nWhat could still be wrong in the SourceTree/repository/git setup?\n\nUpdate #1, 20. Apr 2013\nAs there is still something wrong, here are partial outputs of git config --list.\nFrom SourceTree console (OSX)\ncore.excludesfile=/Users/User/.gitignore_global\ncore.autocrlf=input\ndifftool.sourcetree.cmd=opendiff \"$LOCAL\" \"$REMOTE\"\ndifftool.sourcetree.path=\nmergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"\nmergetool.sourcetree.trustexitcode=true\ncore.repositoryformatversion=0\ncore.filemode=true\ncore.bare=false\ncore.logallrefupdates=true\ncore.ignorecase=true\ncore.autocrlf=true\n\nHere is corresponding output from Windows side:\ncore.symlinks=false\ncore.autocrlf=false\ncolor.diff=auto\ncolor.status=auto\ncolor.branch=auto\ncolor.interactive=true\npack.packsizelimit=2g\nhelp.format=html\nhttp.sslcainfo=/bin/curl-ca-bundle.crt\nsendemail.smtpserver=/bin/msmtp.exe\ndiff.astextplain.textconv=astextplain\nrebase.autosquash=true\nhttp.proxy=\ncore.autocrlf=true\ncore.repositoryformatversion=0\ncore.filemode=false\ncore.bare=false\ncore.logallrefupdates=true\ncore.symlinks=false\ncore.ignorecase=true\ncore.hidedotfiles=dotGitOnly\ncore.eol=native\ncore.autocrlf=true\n\nAnd full .gitattributes for the repository in question\n# Set default behaviour, in case users don't have core.autocrlf set.\n* text=auto\n\n*.php text\n*.twig text\n*.js text\n*.html text diff=html\n*.css text\n*.xml text\n*.txt text\n*.sh text eol=lf\nconsole text\n\n*.png binary\n*.jpg binary\n*.gif binary\n*.ico binary\n*.xslx binary" }, { "role": "assistant", "content": "I'm one of the SourceTree developers (I develop the Mac version of the product, actually), so hopefully I can be of some help.\nWindows machines convert CRLF to LF when committing and LF to CRLF when checking out. autocrlf makes sure everything is LF within the repository. The option text = auto is the one we're interested in though as it says in the docs:\n\nWhen text is set to \"auto\", the path is marked for automatic end-of-line normalization. If git decides that the content is text, its line endings are normalized to LF on checkin.\n\nSo you see on checkin it will say \"Hey, I need to normalise these line-endings because they're not in LF format, but in CRLF.\" and thus modifies your working copy to do the work it's expected to do. Usually on Mac/Linux you wouldn't need to normalise because everything is in LF, but Git will do a check because you might've checked out from a repository that was previously developed on Windows, or perhaps in an editor that was using CRLF instead of LF.\nSo in short, you'd probably want to re-commit all of those files as they should be in LF format, but also make sure autocrlf = true (edit, always to true!) in your Windows repository as it says in the docs:\n\nIf you simply want to have CRLF line endings in your working directory regardless of the repository you are working with, you can set the config variable \"core.autocrlf\" without changing any attributes.\n\nAlthough imagine that previous quote was when setting autocrlf for a specific repository as well as globally.\nHopefully that's of some help, if not, feel free to ask more questions!\n\nHere's a good SO post re: line endings: Why should I use core.autocrlf=true in Git?\n\nEDIT\nBased on the above answer we need to make sure of a few things here.\n\nThat you've set the relevant git options in your .git/config\nIf you want to keep CRLF line endings then set autocrlf=true\nIf, when checking out your repository, you don't want your line endings to be automatically converted (causing all your files to be in the \"modified\" state immediately) then set the text option to unset. Add this option if a global git config has it set to a value you don't want.\nIf you're working on both Windows and Mac for a project then it's best you have text=auto and make sure LF is used across the board. This is why problems like this creep in; because your git config's differ or because the initial project/git setup on Windows assumes CRLF when your Mac assumes LF." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-show-branch" }, { "role": "assistant", "content": "Show branches and their commits" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-grep - Print lines matching a pattern" }, { "role": "assistant", "content": "SYNOPSIS git grep [-a | --text] [-I] [--textconv] [-i | --ignore-case] [-w | --word-regexp]\n\t [-v | --invert-match] [-h|-H] [--full-name]\n\t [-E | --extended-regexp] [-G | --basic-regexp]\n\t [-P | --perl-regexp]\n\t [-F | --fixed-strings] [-n | --line-number] [--column]\n\t [-l | --files-with-matches] [-L | --files-without-match]\n\t [(-O | --open-files-in-pager) [<pager>]]\n\t [-z | --null]\n\t [ -o | --only-matching ] [-c | --count] [--all-match] [-q | --quiet]\n\t [--max-depth <depth>] [--[no-]recursive]\n\t [--color[=<when>] | --no-color]\n\t [--break] [--heading] [-p | --show-function]\n\t [-A <post-context>] [-B <pre-context>] [-C <context>]\n\t [-W | --function-context]\n\t [(-m | --max-count) <num>]\n\t [--threads <num>]\n\t [-f <file>] [-e] <pattern>\n\t [--and|--or|--not|(|)|-e <pattern>…​]\n\t [--recurse-submodules] [--parent-basename <basename>]\n\t [ [--[no-]exclude-standard] [--cached | --untracked | --no-index] | <tree>…​]\n\t [--] [<pathspec>…​]" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Remove file from the repository but keep it locally\nI have a folder which I'd like to remove in my remote repository. I'd like to delete it, but keep the folder in my computer" }, { "role": "assistant", "content": "git rm --cached -r somedir\n\nWill stage the deletion of the directory, but doesn't touch anything on disk. This works also for a file, like: \ngit rm --cached somefile.ext\n\nAfterwards you may want to add somedir/ or somefile.ext to your .gitignore file so that git doesn't try to add it back." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Using docker-compose in a GitLab CI pipeline\n\nI'm trying to implement a GitLab continuous integration (CI) pipeline with the following .gitlab-ci.yml file:\nimage: docker:latest\n\n# When using dind, it's wise to use the overlayfs driver for\n# improved performance.\nvariables:\n DOCKER_DRIVER: overlay\n\nservices:\n - docker:dind\n\nbefore_script:\n - docker info\n - curl -L \"https://github.com/docker/compose/releases/download/1.10.0/docker-compose-$(uname -s)-$(uname -m)\" -o /usr/local/bin/docker-compose\n - chmod +x /usr/local/bin/docker-compose\n - export PATH=/usr/local/bin:$PATH\n - echo $PATH\n\nstages:\n - build\n - test\n\nbuild:\n stage: build\n script:\n - docker-compose build\n - docker-compose up -d\n\ntest:\n stage: test\n script:\n - cd tests/tester\n - pytest test_run_tester.py\n except:\n - /^.*skip_tests$/\n\nHowever, in GitLab I'm getting the following error message:\nRunning with gitlab-ci-multi-runner 1.10.4 (b32125f)\nUsing Docker executor with image docker:latest ...\nStarting service docker:dind ...\nPulling docker image docker:dind ...\nWaiting for services to be up and running...\nPulling docker image docker:latest ...\nRunning on runner-2e54fd37-project-13-concurrent-0 via scw-de9c9c...\nFetching changes...\nHEAD is now at 2504a08 Update CI config\nFrom https://lab.iperlane.com/gio/ipercron-compose\n 2504a08..5c2f23f CI -> origin/CI\nChecking out 5c2f23f1 as CI...\nSkipping Git submodules setup\n$ docker info\nContainers: 0\n Running: 0\n Paused: 0\n Stopped: 0\nImages: 0\nServer Version: 1.13.1\nStorage Driver: overlay\n Backing Filesystem: extfs\n Supports d_type: true\nLogging Driver: json-file\nCgroup Driver: cgroupfs\nPlugins: \n Volume: local\n Network: bridge host macvlan null overlay\nSwarm: inactive\nRuntimes: runc\nDefault Runtime: runc\nInit Binary: docker-init\ncontainerd version: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1\nrunc version: 9df8b306d01f59d3a8029be411de015b7304dd8f\ninit version: 949e6fa\nSecurity Options:\n seccomp\n Profile: default\nKernel Version: 4.8.14-docker-2\nOperating System: Alpine Linux v3.5 (containerized)\nOSType: linux\nArchitecture: x86_64\nCPUs: 4\nTotal Memory: 7.751 GiB\nName: 90395a030c02\nID: 7TKR:5PQN:XLFM:EJST:NF2V:NLQC:I2IZ:6OZG:TR4U:ZEAK:EVXE:HIF7\nDocker Root Dir: /var/lib/docker\nDebug Mode (client): false\nDebug Mode (server): false\nRegistry: https://index.docker.io/v1/\nExperimental: false\nInsecure Registries:\n 127.0.0.0/8\nLive Restore Enabled: false\nWARNING: bridge-nf-call-iptables is disabled\nWARNING: bridge-nf-call-ip6tables is disabled\n$ curl -L \"https://github.com/docker/compose/releases/download/1.10.0/docker-compose-$(uname -s)-$(uname -m)\" -o /usr/local/bin/docker-compose\n % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n\n 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\n 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\n100 600 0 600 0 0 1175 0 --:--:-- --:--:-- --:--:-- 1176\n\n 0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0\n 3 7929k 3 254k 0 0 116k 0 0:01:08 0:00:02 0:01:06 258k\n 17 7929k 17 1358k 0 0 433k 0 0:00:18 0:00:03 0:00:15 704k\n 61 7929k 61 4861k 0 0 1164k 0 0:00:06 0:00:04 0:00:02 1636k\n100 7929k 100 7929k 0 0 1703k 0 0:00:04 0:00:04 --:--:-- 2300k\n$ chmod +x /usr/local/bin/docker-compose\n$ export PATH=/usr/local/bin:$PATH\n$ docker-compose build\n/bin/sh: eval: line 51: docker-compose: not found\nERROR: Build failed: exit code 127\n\nThe system seems not to be able to find docker-compose, even after installing it and adding it to the path. Is there perhaps another image such that docker-compose commands can be made, or a different way to install it in the .gitlab-ci.yml?" }, { "role": "assistant", "content": "The problem\nThis is complex problem.\nThe docker:latest image is based on alpine (Alpine Linux), which is built using musl-libc. This system is very barebones, and as such doesn't have everything a full-fledged desktop Linux might have. In fact, dynamic executables need to be compiled specifically for this system.\ndocker-compose is a Python application, bundled into a Linux executable using PyInstaller. These executables are really only expected to be able to run on the system which they were built. If you run an alpine container, and apk add file, you can see that the (dynamically-linked) executable you downloaded is expecting a specific interpreter.\n# file /usr/local/bin/docker-compose\n/usr/local/bin/docker-compose.pyinstaller: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=00747fe5bcde089bb4c2f1ba7ab5348bc02ac5bf, stripped\n\nThe problem is /lib64/ld-linux-x86-64.so.2 doesn't exist in alpine. In fact, /lib64 doesn't even exist.\nThe solution\nBecause docker-compose is a Python application, it can also be installed using pip:\nTesting this inside an alpine container:\n$ docker run --rm -it alpine /bin/bash\n\nHere are the commands you can run manually, or add to your .gitlab-ci.yml before_script:\n# apk add --no-cache python py2-pip\n...\n# pip install --no-cache-dir docker-compose\n...\n# docker-compose -v\ndocker-compose version 1.11.1, build 7c5d5e4\n\n\nIt turns out there is actually an open issue for this:\n\nhttps://github.com/docker/compose/issues/3465" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why does git commit --amend change the hash even if I don't make any changes?\nWhy does the SHA-1 hash of my latest commit change even if I don't make any changes to the commit (message, files) after running git commit --amend?\nSay I run the following at the command line.\ncd ~/Desktop\nmkdir test_amend\ncd test_amend\ngit init\necho 'foo' > test.txt\ngit add test.txt\ngit commit -m 'initial commit'\n\nThen, invoking\ngit log --pretty=oneline --abbrev-commit\n\nprints the following message:\nb96a901 initial commit\n\nI then do\ngit commit --amend\n\nbut I change my mind and decide not to change anything in the last commit. In other words, I leave the files, directories, and message of the last commit untouched (I just save the message file and close my editor).\nThen, I do\ngit log --pretty=oneline --abbrev-commit\n\none more time, I see that the hash of the commit has changed:\n3ce92dc initial commit\n\nWhat causes the hash to change? Does it have to do with the time stamp of the commit?" }, { "role": "assistant", "content": "Yes, it's the commit timestamp. Inspecting the contents of the two commits reveals:\n$ git cat-file commit 82c7363bcfd727fe2d6b0a98412f71a10c8849c9\ntree d87cbcba0e2ede0752bdafc5938da35546803ba5\nauthor Thomas <xxx> 1400700200 +0200\ncommitter Thomas <xxx> 1400700200 +0200\n\nhello\n\n$ git cat-file commit 7432fcf82b65d9d757efd73ef7d6bff4707f99bd\ntree d87cbcba0e2ede0752bdafc5938da35546803ba5\nauthor Thomas <xxx> 1400700200 +0200\ncommitter Thomas <xxx> 1400700214 +0200\n\nhello\n\nIf you amended in the same second as the original commit, presumably you'd get the same hash." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options transfer.unpackLimit" }, { "role": "assistant", "content": "When fetch.unpackLimit or receive.unpackLimit are\nnot set, the value of this variable is used instead.\nThe default value is 100." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gist: How are images uploaded to a gist?\n\nHere is the image file:\nhttps://gist.github.com/mbostock/5503544#file-thumbnail-png\nI tried to drag-and-drop the image file in the edit mode of a gist. That didn't seem to work in Chrome and FireFox.\nUpdate: After back and forth emails with GitHub, this feature (drag-and-drop binary files, including images) isn't supported." }, { "role": "assistant", "content": "With a little creativity you can achieve this faster than cloning. To drag/drop:\n\nCreate the Gist\nDrag an image into the comment field below. This will auto-upload your image file to https://user-images.githubusercontent.com and insert markdown code in the comment field to display the image.\nCopy this markdown code to your gist\n\nNote: It is not required that you submit the comment.\nLive example" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc cumulative" }, { "role": "assistant", "content": "Count changes in a child directory for the parent directory as well.\nNote that when using cumulative , the sum of the percentages\nreported may exceed 100%. The default (non-cumulative) behavior can\nbe specified with the noncumulative parameter." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options" }, { "role": "assistant", "content": "SYNOPSIS git config [<file-option>] [--type=<type>] [--comment=<message>] [--fixed-value] [--show-origin] [--show-scope] [-z|--null] <name> [<value> [<value-pattern>]] git config [<file-option>] [--type=<type>] [--comment=<message>] --add <name> <value> git config [<file-option>] [--type=<type>] [--comment=<message>] [--fixed-value] --replace-all <name> <value> [<value-pattern>] git config [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] --get <name> [<value-pattern>] git config [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] --get-all <name> [<value-pattern>] git config [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] [--name-only] --get-regexp <name-regex> [<value-pattern>] git config [<file-option>] [--type=<type>] [-z|--null] --get-urlmatch <name> <URL> git config [<file-option>] [--fixed-value] --unset <name> [<value-pattern>] git config [<file-option>] [--fixed-value] --unset-all <name> [<value-pattern>] git config [<file-option>] --rename-section <old-name> <new-name> git config [<file-option>] --remove-section <name> git config [<file-option>] [--show-origin] [--show-scope] [-z|--null] [--name-only] -l | --list git config [<file-option>] --get-color <name> [<default>] git config [<file-option>] --get-colorbool <name> [<stdout-is-tty>] git config [<file-option>] -e | --edit" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.external" }, { "role": "assistant", "content": "If this config variable is set, diff generation is not\nperformed using the internal diff machinery, but using the\ngiven command. Can be overridden with the ‘GIT_EXTERNAL_DIFF’\nenvironment variable. The command is called with parameters\nas described under \"git Diffs\" in git . Note: if\nyou want to use an external diff program only on a subset of\nyour files, you might want to use gitattributes instead." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git merge: Removing files I want to keep!\nHow can you merge two branches in git, retaining necessary files from a branch?\nWhen merging two branches, if a file was deleted in one branch and not in another, the file is ultimately deleted.\nFor example:\n\nA file exists in master when you make a new branch\nyou remove the file from master since we don't need it (yet)\nyou make changes in the branch to add a feature, which relies on the file existing\nyou make bug fixes in master (cannot be discarded)\nyou merge some day, and the file is gone!\n\n\nHow to Reproduce:\n\nCreate a git repo with one file.\ngit init\necho \"test\" > test.txt\ngit add .\ngit commit -m \"initial commit\"\n\nCreate a branch\ngit branch branchA\n\nDelete the file in master\ngit rm test.txt\ngit commit -m \"removed file from master\"\n\nMake ANY changes in branchA that don't touch the deleted file (it has to be unchanged to avoid Conflict)\ngit checkout branchA\ntouch something.txt\ngit add .\ngit commit -m \"some branch changes\"\n\n\nFrom here, any way I've found to merge these two branches, the test.txt file is deleted. Assuming we were relying on the file for branchA, this is a big problem.\n\nFailing examples:\nMerge 1\ngit checkout branchA\ngit merge master\nls test.txt\n\nMerge 2\ngit checkout master\ngit merge branchA\nls test.txt\n\nRebase 1\ngit checkout branchA\ngit rebase master\nls test.txt" }, { "role": "assistant", "content": "This is an interesting issue. Because you deleted the file after BranchA was created, and then are merging master into BranchA, I'm not sure how Git would be able to realize there is a conflict.\nAfter the bad merge you can undo, and then re-merge, but add back the file:\ngit checkout HEAD@{1} .\ngit merge --no-commit master\ngit checkout master test.txt\ngit add test.txt\ngit commit" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options sendemail.smtpSSLCertPath" }, { "role": "assistant", "content": "Path to ca-certificates (either a directory or a single file).\nSet it to an empty string to disable certificate verification." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I \"move\" my commits from \"no branch\" to an actual branch?\nI made a mistake, and started making commits \"to the last tag\", which lands my commits in \"no branch\". They should have been applied at the head of an already existing branch. I have not pushed my changes yet. I've found a few other question for when commits are in the wrong branch, but now I have no branch, so I don't know how to handle this.\nPreferably, I would like to erase my mistake entirely, and \"move\" my changes to the end of the right branch. If I must leave my mistake in the history, I need to merge them in atleast." }, { "role": "assistant", "content": "You are currently in a detached HEAD state. To resolve that, all you need to do is create a new branch with git branch <branchname> or git checkout -b <branchname>. That will leave you with a local branch you can play with, and even delete when you're done with it.\nBranches in git are just pointers to commits, so if you create a new branch where you are the new branch will point to your current commit, and then you can merge it or whatnot.\nYour \"mistake\" need not be erased, you simply created new commits on top of previous ones. You did not modify history or anything like that.\nEDIT: In response to your comment, what you need to do is:\ngit branch temp\ngit checkout master # or any other branch\ngit merge temp\ngit branch -d temp" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects %aI" }, { "role": "assistant", "content": "author date, strict ISO 8601 format" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git Skip \"doc*\" directory for every fetch" }, { "role": "assistant", "content": "--ignore-paths=\"^doc\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to retrieve a single file from a specific revision in Git?\nI have a Git repository and I'd like to see how some files looked a few months ago. I found the revision at that date; it's 27cf8e84bb88e24ae4b4b3df2b77aab91a3735d8. I need to see what one file looks like, and also save it as a (\"new\") file.\nI managed to see the file using gitk, but it doesn't have an option to save it. I tried with command-line tools, the closest I got was:\ngit-show 27cf8e84bb88e24ae4b4b3df2b77aab91a3735d8 my_file.txt\n\nHowever, this command shows a diff, and not the file contents. I know I can later use something like PAGER=cat and redirect output to a file, but I don't know how to get to the actual file content.\nBasically, I'm looking for something like svn cat." }, { "role": "assistant", "content": "Using git show\nTo complete your own answer, the syntax is indeed\ngit show object\ngit show $REV:$FILE\ngit show somebranch:from/the/root/myfile.txt\ngit show HEAD^^^:test/test.py\n\nThe command takes the usual style of revision, meaning you can use any of the following:\n\nbranch name (as suggested by ash)\nHEAD + x number of ^ characters\nThe SHA1 hash of a given revision\nThe first few (maybe 5) characters of a given SHA1 hash\n\nTip It's important to remember that when using \"git show\", always specify a path from the root of the repository, not your current directory position.\n(Although Mike Morearty mentions that, at least with git 1.7.5.4, you can specify a relative path by putting \"./\" at the beginning of the path. For example:\ngit show HEAD^^:./test.py\n\n)\nUsing git restore\nWith Git 2.23+ (August 2019), you can also use git restore which replaces the confusing git checkout command\ngit restore -s <SHA1> -- afile\ngit restore -s somebranch -- afile\n\nThat would restore on the working tree only the file as present in the \"source\" (-s) commit SHA1 or branch somebranch.\nTo restore also the index:\ngit restore -s <SHA1> -SW -- afile\n\n(-SW: short for --staged --worktree)\n\nAs noted in the comments by starwarswii\n\nIt lets you pipe the contents into a file, which is great if you want to just quickly compare files from a commit.\nE.g. you can do:\ngit show 1234:path/to/file.txt > new.txt \ngit show 1234~:path/to/file.txt > old.txt\n\nthen compare them.\n\n\nUsing low-level git plumbing commands\nBefore git1.5.x, this was done with some plumbing:\ngit ls-tree <rev>\nshow a list of one or more 'blob' objects within a commit\ngit cat-file blob <file-SHA1>\ncat a file as it has been committed within a specific revision (similar to svn\ncat).\nuse git ls-tree to retrieve the value of a given file-sha1\ngit cat-file -p $(git-ls-tree $REV $file | cut -d \" \" -f 3 | cut -f 1)::\n\ngit-ls-tree lists the object ID for $file in revision $REV, this is cut out of the output and used as an argument to git-cat-file, which should really be called git-cat-object, and simply dumps that object to stdout.\n\nNote: since Git 2.11 (Q4 2016), you can apply a content filter to the git cat-file output.\nSee\ncommit 3214594,\ncommit 7bcf341 (09 Sep 2016),\ncommit 7bcf341 (09 Sep 2016), and\ncommit b9e62f6,\ncommit 16dcc29 (24 Aug 2016) by Johannes Schindelin (dscho).\n(Merged by Junio C Hamano -- gitster -- in commit 7889ed2, 21 Sep 2016)\ngit config diff.txt.textconv \"tr A-Za-z N-ZA-Mn-za-m <\"\ngit cat-file --textconv --batch\n\nNote: \"git cat-file --textconv\" started segfaulting recently (2017), which has been corrected in Git 2.15 (Q4 2017)\nSee commit cc0ea7c (21 Sep 2017) by Jeff King (peff).\n(Merged by Junio C Hamano -- gitster -- in commit bfbc2fc, 28 Sep 2017)\n\nAs noted by Kira in the comments:\n\nIf you are using LFS files, you need to run the output of show through smudge:\ngit show master:blends/bigfile.blend | git lfs smudge > blends/bigfile.blend" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What effect does the `--no-ff` flag have for `git merge`?\nUsing gitk log, I could not spot a difference between the effect of git merge and git merge --no-ff. How can I observe the difference (with a git command or some tool)?" }, { "role": "assistant", "content": "The --no-ff flag prevents git merge from executing a \"fast-forward\" if it detects that your current HEAD is an ancestor of the commit you're trying to merge. A fast-forward is when, instead of constructing a merge commit, git just moves your branch pointer to point at the incoming commit. This commonly occurs when doing a git pull without any local changes.\nHowever, occasionally you want to prevent this behavior from happening, typically because you want to maintain a specific branch topology (e.g. you're merging in a topic branch and you want to ensure it looks that way when reading history). In order to do that, you can pass the --no-ff flag and git merge will always construct a merge instead of fast-forwarding.\nSimilarly, if you want to execute a git pull or use git merge in order to explicitly fast-forward, and you want to bail out if it can't fast-forward, then you can use the --ff-only flag. This way you can regularly do something like git pull --ff-only without thinking, and then if it errors out you can go back and decide if you want to merge or rebase." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %at" }, { "role": "assistant", "content": "author date, UNIX timestamp" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Visual Studio Code is always asking for Git credentials\nI started using Visual Studio Code, and I was trying to save my test project into GitHub, but Visual Studio Code is always asking for my GitHub credentials.\nI have installed in my PC GitHub Desktop and also Git. I already ran:\n git config --global credential.helper wincred\n\nbut still Visual Studio Code is asking for the credentials.\nHow can I fix this?\nHere is my .gitconfig file located in the user profile folfer:\n [filter \"lfs\"]\n clean = git-lfs clean %f\n smudge = git-lfs smudge %f\n required = true\n[user]\n name = ddieppa\n[user]\n email = [email protected]\n[credential]\n helper = wincred\n\nHere is the popup windows asking for the credentials:\n\nI enter my GitHub credentials in the popup, but still getting this error in the Git output window in Visual Studio Code:\nremote: Anonymous access to ddieppa/LineOfBizApp.git denied.\nfatal: Authentication failed for 'https://github.com/ddieppa/LineOfBizApp.git/'" }, { "role": "assistant", "content": "Why does Visual Studio Code ask for a password? Because Visual Studio Code runs the auto-fetch feature, while the Git server doesn't have any information to authorize your identity. It happens when:\n\nYour Git repository has a https remote URL. Yes! This kind of remote will absolutely ask you every time. No exceptions here! (You can do a temporary trick to cache the authorization as the solution below, but this is not recommended.)\nYour Git repository has ssh remote URL, but you've not copied your ssh public key onto the Git server. Use ssh-keygen to generate your key and copy it to Git server. Done! This solution also helps you never retype password on terminal again. See a good instruction by @Fnatical here for the answer.\n\nThe updated part at the end of this answer doesn't really help you at all. (It actually makes you stagnant in your workflow.) It only stops things happening in Visual Studio Code and moves these happenings to the terminal.\nSorry if this bad answer has affected you for a long, long time.\n\nThe original answer (bad)\nI found the solution on Visual Studio Code document:\n\nTip: You should set up a credential helper to avoid getting asked\nfor credentials every time VS Code talks to your Git remotes. If you\ndon't do this, you may want to consider Disabling Autofetch in the ...\nmenu to reduce the number of prompts you get.\n\nSo, turn on the credential helper so that Git will save your password in memory for some time. By default, Git will cache your password for 15 minutes.\nIn Terminal, enter the following:\ngit config --global credential.helper cache\n# Set Git to use the credential memory cache\n\nTo change the default password cache timeout, enter the following:\ngit config --global credential.helper 'cache --timeout=3600'\n# Set the cache to timeout after 1 hour (setting is in seconds)\n\nIf the original answer doesn't work\nI installed Visual Studio Code and configuration same above, but as @ddieppa said, It didn't work for me too. So I tried to find an option in User Setting, and I saw \"git.autofetch\" = true, now set it's false! Visual Studio Code is no longer required to enter password repeatedly again!\nIn menu File → Preferences → User Setting:\nType these:\nPlace your settings in this file to overwrite the default settings:\n{\n \"git.autofetch\": false\n}" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-for-each-ref - Output information on each ref --contains[=<object>]" }, { "role": "assistant", "content": "Only list refs which contain the specified commit (HEAD if not\nspecified)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to add symlink file to a gitlab repo\n\nHow can I add symlink to file to gitlab repository?\nEvery time I run a pipeline from gitlab, the local symlink gets destroyed.\nAny suggestions on how to create a symlink for a folder which resides inside of gitlab repo would be great." }, { "role": "assistant", "content": "You can store in a Git repo a symlink (special entry 12000), but, as seen in this test, that would make the GitLab pipeline fail.\nSee gitlab-ce issue 27542 (though it is for the particular case of .gitlab-ci.yml being a symlink).\nIt is best if the pipeline first recreate the symlink, then process in its subsequent steps, with the normal build: regenerating it seems better than storing it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-worktree - Manage multiple working trees --[no-]checkout" }, { "role": "assistant", "content": "By default, add checks out <commit-ish> , however, --no-checkout can\nbe used to suppress checkout in order to make customizations,\nsuch as configuring sparse-checkout. See \"Sparse checkout\"\nin git-read-tree ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git keyword substitution like those in Subversion?\nI used to work under Subversion/SVN and was instantly using nice feature called keyword substitution. Just putting in source files smth like:\n/*\n * $Author: ivanovpv $\n * $Rev: 42 $\n * $LastChangedDate: 2012-05-25 21:47:42 +0200 (Fri, 25 May 2012) $\n */\n\nAnd each time Subversion was substituting keywords (Author, Rev, LastChangedDate) with actual ones.\nSome time ago I was forced to move to Git and just wondering is there's something similar to Subversion's keyword substitution in Git?" }, { "role": "assistant", "content": "Git doesn't ship with this functionality out of the box. However, there is a chapter in the Git Book on Customizing Git and one of the examples is how to use git attributes to implement a similar result.\n\nIt turns out that you can write your own filters for doing\n substitutions in files on commit/checkout. These are called “clean”\n and “smudge” filters. In the .gitattributes file, you can set a filter\n for particular paths and then set up scripts that will process files\n just before they’re checked out (“smudge”) and just before they’re\n staged (“clean”). These filters can be set to do all sorts of fun\n things.\n\nThere is even an example for $LastChangedDate: $:\n\nAnother interesting example gets $Date$ keyword expansion, RCS style.\n To do this properly, you need a small script that takes a filename,\n figures out the last commit date for this project, and inserts the\n date into the file. Here is a small Ruby script that does that:\n#! /usr/bin/env ruby\ndata = STDIN.read\nlast_date = `git log --pretty=format:\"%ad\" -1`\nputs data.gsub('$Date$', '$Date: ' + last_date.to_s + '$')\n\nAll the script does is get the latest commit\n date from the git log command, stick that into any $Date$ strings it\n sees in stdin, and print the results – it should be simple to do in\n whatever language you’re most comfortable in. You can name this file\n expand_date and put it in your path. Now, you need to set up a filter\n in Git (call it dater) and tell it to use your expand_date filter to\n smudge the files on checkout. You’ll use a Perl expression to clean\n that up on commit:\n$ git config filter.dater.smudge expand_date\n$ git config filter.dater.clean 'perl -pe \"s/\\\\\\$Date[^\\\\\\$]*\\\\\\$/\\\\\\$Date\\\\\\$/\"'\n\nThis Perl snippet strips out anything it sees in a $Date$ string, to\n get back to where you started. Now that your filter is ready, you can\n test it by setting up a Git attribute for that file that engages the\n new filter and creating a file with your $Date$ keyword:\ndate*.txt filter=dater\n$ echo '# $Date$' > date_test.txt If you commit\n\nthose changes and check out the file again, you see the keyword\n properly substituted:\n$ git add date_test.txt .gitattributes\n$ git commit -m \"Testing date expansion in Git\"\n$ rm date_test.txt\n$ git checkout date_test.txt\n$ cat date_test.txt\n# $Date: Tue Apr 21 07:26:52 2009 -0700$\n\nYou can see how powerful this technique can be for customized applications. You have to be careful,\n though, because the .gitattributes file is committed and passed around\n with the project, but the driver (in this case, dater) isn’t, so it\n won’t work everywhere. When you design these filters, they should be\n able to fail gracefully and have the project still work properly." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to add private github repository as Composer dependency\n\nI have the following in my Laravel 5.1 projects composer.json to add a public github repository as a dependency.\n... \n\"repositories\": [\n {\n \"type\": \"package\",\n \"package\": {\n \"name\": \"myVendorName/my_private_repo\",\n \"version\": \"1.2.3\",\n \"source\": {\n \"type\" : \"git\",\n \"url\" : \"git://github.com/myVendorName/my_private_repo.git\",\n \"reference\" : \"master\"\n },\n \"dist\": {\n \"url\": \"https://github.com/myVendorName/my_private_repo/archive/master.zip\",\n \"type\": \"zip\"\n }\n }\n }\n],\n\"require\": {\n ....\n \"myVendorName/my_private_repo\": \"*\",\n},\n...\n\nThis works as long as the repository is public. Now I've set this repository to private. The git credentials I use for pulling/pushing to 'my_private_repo' are the one of a colaborator of the project. How can I achieve that composer pulls from that private repository when I run composer update or composer install?" }, { "role": "assistant", "content": "Work with private repositories at GitHub and BitBucket:\nJSON\n{\n \"require\": {\n \"vendor/my-private-repo\": \"dev-master\"\n },\n \"repositories\": [\n {\n \"type\": \"vcs\",\n \"url\": \"[email protected]:vendor/my-private-repo.git\"\n }\n ]\n}\n\nThe only requirement is the installation of SSH keys for a git client.\nDocs" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Github: Find PRs where user is a reviewer\n\nGithub added reviewers.\nIs there a way to find PRs (e.g. on the Pull Requests page) where the user is a reviewer? Things I have already tried:\n\nChecked https://help.github.com/articles/searching-issues/ for a filter: \nNone found\nTested potential filters reviewer:{{user}}, review:{{user}}\nNo PRs returned\nTested the involved:{{user}} filter\nPRs with the user as only a reviewer are not shown in results." }, { "role": "assistant", "content": "As of 2017-01-23, Github have added this functionality.\nSearch\n\nYou can filter pull requests based their review status (none,\nrequired, approved, changes requested, or required), by reviewer, and\nby requested reviewer. For example:\ntype:pr review:none\nMatches pull requests that have not been reviewed.\ntype:pr review:required\nMatches pull requests that require a review before they can be merged.\ntype:pr review:approved\nMatches pull requests that a reviewer has approved.\ntype:pr review:changes_requested\nMatches pull requests in which a reviewer has asked for changes.\ntype:pr reviewed-by:gjtorikian\nMatches pull requests reviewed by a particular person.\ntype:pr review-requested:benbalter\nMatches pull requests a particular person has been asked to review.\n\nPersonal PRs\nA new tab can be seen on personal PR page https://github.com/pulls\nProject PRs (e.g. Symfony)\nA new filter can be seen on the project PR page e.g. https://github.com/symfony/symfony/pulls" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-restore - Restore working tree files --progress --no-progress" }, { "role": "assistant", "content": "Progress status is reported on the standard error stream\nby default when it is attached to a terminal, unless --quiet is specified. This flag enables progress reporting even if not\nattached to a terminal, regardless of --quiet ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to find a deleted file in the project commit history?\nOnce upon a time, there was a file in my project that I would now like to be able to get.\nThe problem is: I have no idea of when have I deleted it and on which path it was.\nHow can I locate the commits of this file when it existed?" }, { "role": "assistant", "content": "If you do not know the exact path you may use\ngit log --all --full-history -- \"**/thefile.*\"\n\nIf you know the path the file was at, you can do this:\ngit log --all --full-history -- <path-to-file>\n\nThis should show a list of commits in all branches which touched that file. Then, you can find the version of the file you want, and display it with...\ngit show <SHA> -- <path-to-file>\n\nOr restore it into your working copy with:\ngit checkout <SHA>^ -- <path-to-file>\nNote the caret symbol (^), which gets the checkout prior to the one identified, because at the moment of <SHA> commit the file is deleted, we need to look at the previous commit to get the deleted file's contents" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to find out which release(s) contain a given GIT commit?\n\nSomeone fixed a bug in HHVM in this commit:\nhttps://github.com/facebook/hhvm/commit/796f986aba300b3f00b9ece0bf654c452ee217be\nI want to know if this commit is already part of the official releases.\nIs there a way to list the releases/tags that contain this commit, either on GitHub, or in a local clone of the GIT repository on my machine?" }, { "role": "assistant", "content": "GitHub now shows you the tags containing a commit automatically when you open a commit (click on the ... to show all tags):" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc git diff [<options>] --cached [--merge-base] [<commit>] [--] [<path>…​]" }, { "role": "assistant", "content": "This form is to view the changes you staged for the next\ncommit relative to the named <commit>. Typically you\nwould want comparison with the latest commit, so if you\ndo not give <commit>, it defaults to HEAD.\nIf HEAD does not exist (e.g. unborn branches) and\n<commit> is not given, it shows all staged changes.\n--staged is a synonym of --cached. If --merge-base is given, instead of using <commit>, use the merge base\nof <commit> and HEAD. git diff --cached --merge-base A is equivalent to git diff --cached $(git merge-base A HEAD) ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Unable to Connect to GitHub.com For Cloning\nI am trying to clone the angular-phonecat git repository, but I am getting the following message when I enter the command in my Git Bash:\n$ git clone git://github.com/angular/angular-phonecat.git \nCloning into 'angular-phonecat'... \nfatal: unable to connect to github.com: \ngithub.com[0: 204.232.175.90]: errno=No error" }, { "role": "assistant", "content": "You are probably behind a firewall. Try cloning via https – that has a higher chance of not being blocked:\ngit clone https://github.com/angular/angular-phonecat.git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Leaving Github, how to change the origin of a Git repo?\n\nI'm hosting a project in Github, but now I purchased a plan with Dreamhost that includes shell access and Git.\n Github [Origin]\n / \\\n pull/ \\pull\n /push push\\\n / \\ \nLaptop Dreamhost\n(cloned) (cloned)\n\nI would like to delete my repo from Github, and starting push directly to DH.\nHow do I change origin in my Laptop, and should I delete the origin in Dreamhost?" }, { "role": "assistant", "content": "git remote rename origin github\ngit remote add origin <DreamHost-git-URL>\n# test and make sure the DreamHost origin works properly for fetch and push\ngit remote rm github\n\nI prefer using the 'git remote' command instead of screwing about with the .git/config file by hand." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Command to get latest Git commit hash from a branch\nHow can I check with the command line the latest commit hash of a particular Git branch?" }, { "role": "assistant", "content": "git log -n 1 [branch_name]\n\nbranch_name (may be remote or local branch) is optional. Without branch_name, it will show the latest commit on the current branch.\nFor example:\ngit log -n 1\ngit log -n 1 origin/master\ngit log -n 1 some_local_branch\n\ngit log -n 1 --pretty=format:\"%H\" #To get only hash value of commit" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to work with multiple ssh keys [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\n\nMultiple GitHub Accounts & SSH Config\n\n (15 answers)\n \n\nClosed 11 years ago.\n\n\n\nGitHub Users,\nI am newbie on github and have some issue with git setup.\nI have 2 account with different users on github and i have setup git on my system 2 times\n\nFirst /.ssh folder (as usual) (contain id_rsa which copied in first\n account) Second /.ssh/new folder (contain id_rsa which copied in\n second account)\n\nnow at the time of push how can i switch between ssh key?\nBecause if i would like to push for second account it will use .ssh key instead of .ssh/new and gives me error.\nPlease make me correct if i am understood something wrong here.\nThanks." }, { "role": "assistant", "content": "(I've voted to close this as a possible duplicate, but I might as well add a similar answer anyway.)\nWhen using the SSH transport, GitHub identifies you as a user based on the SSH key that you use to authenticate. So, you need to make sure that git is using one SSH key for one repository and another for the other.\nI'm going to assume that:\n\nYou have a GitHub account called user1, and you've added to that account the public key corresponding to your local private key /home/whoever/.ssh/id_rsa. Let's say that the repository you're interested in accessing as user1 is user1/whatever on GitHub.\nYou have a second GitHub account called user2 and you've added to that account the public key corresponding to your local private key /home/whoever/.ssh/new/id_rsa. Let's say that the repository you're interested in accessing as user2 is user2/whatever on GitHub.\n\nThe simplest way to do deal with this is to create a new \"remote\" (i.e. a nickname for a remote repository) for each repository, where the hostname is in each remote's URL is actually an alias that you've set up in ~/.ssh/config. (If that config file doesn't exist, you'll have to create it.)\nFor example, one entry in the ~/.ssh/config file might look like:\nHost github-as-user1\n HostName github.com\n User git\n IdentityFile /home/whoever/.ssh/id_rsa\n\nThen you can add a remote called gh-user1, say, with:\ngit remote add gh-user1 git@github-as-user1:user1/whatever.git\n\n... and then if you want to push your master branch to the repository user1/whatever on GitHub using the ~/.ssh/id_rsa key, you can just do:\ngit push gh-user1 master\n\nIn order to push as the other user (user2) to the second repository, you need to add a second alias to you ~/.ssh/config file. For example:\nHost gh-as-user2\n HostName github.com\n User git\n IdentityFile /home/whoever/.ssh/new/id_rsa\n\nThen to push to that second repository as the different user, you can just do:\ngit push gh-user2 master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-credential-store" }, { "role": "assistant", "content": "Helper to store credentials on disk" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show-ref - List references in a local repository --exists" }, { "role": "assistant", "content": "Check whether the given reference exists. Returns an exit code of 0 if\nit does, 2 if it is missing, and 1 in case looking up the reference\nfailed with an error other than the reference being missing." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitfaq - Frequently asked questions about using Git How do I read a password or token from an environment variable?" }, { "role": "assistant", "content": "The credential.helper configuration option can also take an arbitrary\nshell command that produces the credential protocol on standard output.\nThis is useful when passing credentials into a container, for example. Such a shell command can be specified by starting the option value with an\nexclamation point. If your password or token were stored in the GIT_TOKEN ,\nyou could run the following command to set your credential helper: $ git config credential.helper \\\n\t'!f() { echo username=author; echo \"password=$GIT_TOKEN\"; };f'" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Want to setup a hook that copies committed files to a particular folder\n\nBackground: Developing a Facebook app using PHP Laravel framework & MySQL for database.\nI have setup Gitlab on our development server and created a repository on it where the team has been added and is committing & pushing code.\nWhat I would like to do is, when I push code to a particular branch on GitLab (for example Master) I would like it to be available at /var/www/productname so that I can test it within the Facebook canvas as well (certain things happen there that can't be tested on your local machine).\nHowever, I don't want the hook to copy all the files over every time a push happens on master, just the files that were modified.\nCan anyone help out with such a hook?\nThank you." }, { "role": "assistant", "content": "You would need to add to the bare repo (managed by GitLab) a post-receive hook which would:\n\nmaintain a working tree (git checkout -f master)\ncopy the files you want from that working\n\nThat would be:\ncd ~git/repositories/yourRepo.git/hooks\ntouch post-receive\nchmod +x post-receive\n\nYou can make sure that hook will only be active if someone pushes on branch master:\n#!/bin/bash\nwhile read oldrev newrev refname\ndo\n branch=$(git rev-parse --symbolic --abbrev-ref $refname)\n if [ \"master\" == \"$branch\" ]; then\n # Do something\n fi\ndone\n\nFor the checkout done by that hook, see \"GIT post-receive checkout without root folder\", that is:\nmake sure you specify --git-dir and --git-work-tree:\ngit --git-dir=/path/to/project_root.git --work-tree=/path/to/your/workingtree checkout -f\n\nAgain, /path/to/your/workingtree can be:\n\nonly an intermediate working tree for you to extract from it the relevant files you want to copy.\nor the path to your app, if you want all the files from master to be updated in the destination directory of your wab app." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: How to return from 'detached HEAD' state\nIf one would checkout a branch:\ngit checkout 760ac7e\n\nfrom e.g. b9ac70b, how can one go back to the last known head b9ac70b without knowing its SHA1?" }, { "role": "assistant", "content": "If you remember which branch was checked out before (e.g. master) you could simply\ngit checkout master\n\nto get out of detached HEAD state.\nGenerally speaking: git checkout <branchname> will get you out of that.\nIf you don't remember the last branch name, try\ngit checkout -\n\nThis also tries to check out your last checked out branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database --[no-]progress" }, { "role": "assistant", "content": "Progress status is reported on the standard error stream by\ndefault when it is attached to a terminal, unless\n--no-progress or --verbose is specified. --progress forces\nprogress status even if the standard error stream is not\ndirected to a terminal." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git restore last detached HEAD\nI have a big problem in my project: this is the scenario.\nI have an xcode project under Git. Today I realized that the last commit broke some tests, so i checked out the previous commit.\nI used SourceTree and this is the warning\n\nDoing so will make your working copy a 'detached HEAD', which means you won't be on a branch anymore. If you want to commit after this you'll probably want to either checkout a branch again, or create a new branch. Is this ok?\n\nI worked for an entire day and at the end I committed everything.\nSo I needed to merge my work on develop branch so I checkout the develop branch and... my work instantly disappeared :(\nI know it was wrong to detach my HEAD and Sourcetree warned me... but there is a way to restore my work?" }, { "role": "assistant", "content": "If you type git reflog, it will show you the history of what revisions HEAD pointed to. Your detached head should be in there. Once you find it, do git checkout -b my-new-branch abc123 or git branch my-new-branch abc123 (where abc123 is the SHA-1 of the detached HEAD) to create a new branch that points to your detached head. Now you can merge that branch at your leisure.\nGenerally, if you check out a branch after working on a detached head, Git should tell you the commit from the detached head you had been on, so you can recover it if you need. I've never used SourceTree, so I don't know if it relays that message. But if it did display that message, then you should be able to use that to find the commit, and again use git checkout -b or git branch to create a branch from that commit." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I embed a single file from a GitHub gist with the new gist interface?\n\nThe new GitHub Gist interface has one embed snippet for the entire gist which embeds all files in the gist. The old interface had embed code for each file in the gist. Anyone know if there's a trick to embed a single file?" }, { "role": "assistant", "content": "Take the gist URL from the left-hand side and after the .js add a query string like ?file=myFile.blah, e.g.\n<script src=\"https://gist.github.com/4505639.js?file=macroBuild.scala\" type=\"text/javascript\"></script>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Where can I report a GitHub bug?\n\nI have a perfectly valid repository which doesn't display correctly on GitHub. How do I report this to GitHub to get them to fix it?\nThis also affects the git command line tool, unfortunately.\nIf you want to know what's going on, look at the 'encoding' attribute of the commit." }, { "role": "assistant", "content": "If someone encounters a bug with one of GitHub's products, they can submit it to the below URL. It creates a ticket to track the correctness of a bug.\nhttps://support.github.com/contact/bug-report" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options pull.twohead" }, { "role": "assistant", "content": "The default merge strategy to use when pulling a single branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I delete a file from a Git repository?\nHow can I delete \"file1.txt\" from my repository?" }, { "role": "assistant", "content": "Use git rm.\nIf you want to remove the file from the Git repository and the filesystem, use:\ngit rm file1.txt\ngit commit -m \"remove file1.txt\"\n\nBut if you want to remove the file only from the Git repository and not remove it from the filesystem, use: \ngit rm --cached file1.txt\ngit commit -m \"remove file1.txt\"\n\nAnd to push changes to remote repo\ngit push origin branch_name" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub pages are not updating\n\nI'm running into a weird issue with GitHub pages. I pushed a new commit to my personal pages page maltzj.github.io, but the new article isn't showing up there. When I execute the server locally, a post lives at localhost:4000/posts/the-price-of-inconsistent-code/. However, when I go to http://maltzj.github.io/posts/the-price-of-inconsistent-code I get a 404. I also added a new file which should live at http://maltz.github.io/test.html, but that also throws a 404.\nEverything builds and runs locally. My Git repository is up to date, and there is nothing on the GitHub status page about problems with builds, so I'm at a little bit of a loss about where to go with this. How can I get my page to update with new content that I add?\nFor reference, the location of the repository which backs my page is http://github.com/maltzj/maltzj.github.io" }, { "role": "assistant", "content": "None of these solutions solved it for me. The solution was to edit the index.html file in the GitHub website.\nThe website then updates on the web as expected." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-branch - List, create, or delete branches -M" }, { "role": "assistant", "content": "Shortcut for --move --force ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to delete branches whose name matches a certain pattern\n\nHow can I delete branches in git starting with the letter 'o'?\nSuppose, I have a list of branches like the following:\norigin_alpha\norigin_beta\norigin_gamma\nalpha\nbeta\ngamma\n\nI wan't to delete the branches origin_alpha, origin_beta and origin_gamma." }, { "role": "assistant", "content": "Update: The -r option to xargs is a GNU addon. Unless you use xargs from GNU findutils it might not work. You can omit it but that leads to an error if the input piped to xargs is empty.\n\nYou can use git branch --list <pattern> and pipe it's output to xargs git branch -d:\ngit branch --list 'o*' | xargs -r git branch -d\n\nBtw, there is a minor issue with the code above. If you've currently checked out one of the branches that begins with o the output of git branch --list 'o*' would look like this:\n* origin_master\norigin_test\no_what_a_branch\n\nNote the asterisk * in front of the current branch name.\nWhile you cannot delete the current branch anyway, it leads to the fact that xargs also passes * to git branch delete.\nAs I say it is just a cosmetic error, but if you want to avoid it use:\ngit branch --list 'o*' | sed 's/^* //' | xargs -r git branch -d" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-bugreport - Collect information for user to file a bug report" }, { "role": "assistant", "content": "NAME git-bugreport - Collect information for user to file a bug report" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-notes - Add or inspect object notes merge" }, { "role": "assistant", "content": "Merge the given notes ref into the current notes ref.\nThis will try to merge the changes made by the given\nnotes ref (called \"remote\") since the merge-base (if\nany) into the current notes ref (called \"local\"). If conflicts arise and a strategy for automatically resolving\nconflicting notes (see the \"NOTES MERGE STRATEGIES\" section) is not given,\nthe \"manual\" resolver is used. This resolver checks out the\nconflicting notes in a special worktree ( .git/NOTES_MERGE_WORKTREE ),\nand instructs the user to manually resolve the conflicts there.\nWhen done, the user can either finalize the merge with git notes merge --commit , or abort the merge with git notes merge --abort ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Send a pull request on GitHub for only latest commit\n\nI forked a project on github and am successfully making changes to my local master and pushing to origin on github. I want to send a pull request, but only want to include the last commit. The pull request UI on github.com shows the last 9 commits and I don't know how to filter that down.\nI was trying to understand if I should create a new local branch, check that out and somehow reset or rebase to upstream? Then apply my last commit from my master by id to the new local branch and use that for the pull request?\nI'm trying to get the concepts right and figure out the right command lines to do what I need." }, { "role": "assistant", "content": "You need to basically create a new branch & cherry-pick the commits you want to add to it.\n\nNote: you might need these before the checkout/cherry-pick commands\ngit remote add upstream <git repository>\ngit remote update\n\ngit checkout -b <new-branch-name> upstream/master\n\ngit cherry-pick <SHA hash of commit>\n\ngit push origin <new-branch-name>\n\nAfterwards, you will see <new-branch-name> branch on github, switch to it and can submit the pull request with the changes you want." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GIT_DISCOVERY_ACROSS_FILESYSTEM not set\nI have searched and read few post but my problem is not the same as described. So here's the issue: using git clone into folder under external partition of the disk works fine but all git commands fails. can't execute git status or git log... I always get error\nfatal: Not a git repository (or any parent up to mount parent /home/kozi)\nStopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\n\nPlease help me out..\n\n.\n├── abi\n├── bionic\n├── bootable\n├── build\n├── cts\n├── dalvik\n├── development\n├── device\n├── docs\n├── external\n├── frameworks\n├── gdk\n├── hardware\n├── libcore\n├── libnativehelper\n├── ndk\n├── packages\n├── pdk\n├── prebuilts\n├── .repo\n├── sdk\n├── system\n└── tools" }, { "role": "assistant", "content": "Just type git init into your command line and press enter. Then run your command again, you probably were running git remote add origin [your-repository].\nThat should work, if it doesn't, just let me know." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Change Folder Name During Clone\nWhen I clone something, it creates a folder with the same name as the app on my computer.\nFor example, doing this clone creates a long \"sign-in-with-twitter\" folder:\ngit clone https://github.com/sferik/sign-in-with-twitter.git\n\nIs there a way to specify a custom name?" }, { "role": "assistant", "content": "You can do this:\ngit clone https://github.com/sferik/sign-in-with-twitter.git signin\n\n# or\n\ngit clone [email protected]:sferik/sign-in-with-twitter.git signin\n\nrefer to the manual here" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Cannot push to Git repository on Bitbucket\nI created a new repository and I'm running into a strange error. I've used Git before on Bitbucket but I just reformatted and now I can't seem to get Git to work. After doing a commit, I had to add my email and name to the globals, but then it committed just fine. \nWhen I try to use the command\ngit push origin master\n\nit doesn't work. I get this message:\n$ git push origin master\nPermission denied (publickey).\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\nI'm at a loss here. My friend whom I'm sharing this repository with, accessed it fine and pushed to it just fine, but I can't seem to get it to work." }, { "role": "assistant", "content": "Writing this for those just getting started with Git and BitBucket on Windows & who are not as familiar with Bash (since this is both a common issue and a high ranking Google result when searching for the error message within the question).\nFor those who don't mind HTTPS and who are looking for a quick fix, scroll to the bottom of this answer for instructions under FOR THE LAZY\nFor those looking to solve the actual problem, follow the instructions below:\nFixing the SSH issue as fast as possible\nThis is a set of instructions derived from the URL linked to by VonC. It was modified to be as resilient and succinct as possible.\n\nDon't type the $ or any lines that do not begin with $ (the $ means this is something you type into GitBash).\nOpen GitBash\n\nSet your global info if you haven't already:\n$ git config --global user.name \"Your Name\"\n$ git config --global user.email \"[email protected]\"\n\nCheck for OpenSSH:\n$ ssh -v localhost\nOpenSSH_4.6p1, OpenSSL...\n\nSee something like that?\n\nYes: Continue.\nNo: Skip to the FOR THE LAZY section or follow the linked article from VonC.\n\nSee if you have generated the keys already:\n$ ls -a ~/.ssh/id_*\n\nIf there are two files, you can skip the next step.\n$ ssh-keygen\n\nLeave everything as the defaults, enter a passphrase. You should now see results with this command:\n$ ls -a ~/.ssh/id_*\n\nCheck for an existing config file:\n$ ls -a ~/.ssh/config\n\nIf you get a result, check this file for erroneous information. If no file exists, do the following:\n$ echo \"Host bitbucket.org\" >> ~/.ssh/config\n$ echo \" IdentityFile ~/.ssh/id_rsa\" >> ~/.ssh/config\n\nConfirm the contents:\n$ cat ~/.ssh/config\n\nHost bitbucket.org\n IdentityFile ~/.ssh/id_rsa\n\n\nThe single space before \"IdentityFile\" is required.\n\nCheck you are starting the SSH agent every time you run GitBash:\n$ cat ~/.bashrc\n\n\nIf you see a function called start_agent, this step has already been completed.\nIf no file, continue.\nIf there is a file that does not contain this function, you're in a sticky situation. It's probably safe to append to it (using the instructions below) but it may not be! If unsure, make a backup of your .bashrc before following the instructions below or skip ahead to FOR THE LAZY section.\n\nEnter the following into GitBash to create your .bashrc file:\n$ echo \"SSH_ENV=$HOME/.ssh/environment\" >> ~/.bashrc\n$ echo \"\" >> ~/.bashrc\n$ echo \"# start the ssh-agent\" >> ~/.bashrc\n$ echo \"function start_agent {\" >> ~/.bashrc\n$ echo \" echo \\\"Initializing new SSH agent...\\\"\" >> ~/.bashrc\n$ echo \" # spawn ssh-agent\" >> ~/.bashrc\n$ echo \" /usr/bin/ssh-agent | sed 's/^echo/#echo/' > \\\"\\${SSH_ENV}\\\"\" >> ~/.bashrc\n$ echo \" echo succeeded\" >> ~/.bashrc\n$ echo \" chmod 600 \\\"\\${SSH_ENV}\\\"\" >> ~/.bashrc\n$ echo \" . \\\"\\${SSH_ENV}\\\" > /dev/null\" >> ~/.bashrc\n$ echo \" /usr/bin/ssh-add\" >> ~/.bashrc\n$ echo \"}\" >> ~/.bashrc\n$ echo \"\" >> ~/.bashrc\n$ echo \"if [ -f \\\"\\${SSH_ENV}\\\" ]; then\" >> ~/.bashrc\n$ echo \" . \\\"\\${SSH_ENV}\\\" > /dev/null\" >> ~/.bashrc\n$ echo \" ps -ef | grep \\${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {\" >> ~/.bashrc\n$ echo \" start_agent;\" >> ~/.bashrc\n$ echo \" }\" >> ~/.bashrc\n$ echo \"else\" >> ~/.bashrc\n$ echo \" start_agent;\" >> ~/.bashrc\n$ echo \"fi\" >> ~/.bashrc\n\nVerify the file was created successfully (yours should only differ where \"yourusername\" appears):\n$ cat ~/.bashrc\nSSH_ENV=/c/Users/yourusername/.ssh/environment\n\n# start the ssh-agent\nfunction start_agent {\n echo \"Initializing new SSH agent...\"\n # spawn ssh-agent\n /usr/bin/ssh-agent | sed 's/^echo/#echo/' > \"${SSH_ENV}\"\n echo succeeded\n chmod 600 \"${SSH_ENV}\"\n . \"${SSH_ENV}\" > /dev/null\n /usr/bin/ssh-add\n}\n\nif [ -f \"${SSH_ENV}\" ]; then\n . \"${SSH_ENV}\" > /dev/null\n ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {\n start_agent;\n }\nelse\n start_agent;\nfi\n\n\nClose GitBash and re-open it.\nYou should be asked for your passphrase (for the SSH file you generated earlier).\nIf no prompt, you either did not set a passphrase or GitBash isn't running the .bashrc script (which would be odd so consider reviewing the contents of it!). If you are running this on a Mac(OS X), .bashrc isn't executed by default - .bash_profile is. To fix this, put this snippet in your .bash_profile: [[ -s ~/.bashrc ]] && source ~/.bashrc\n\nIf you didn't enter a passphrase, you would have seen something like this when starting GitBash:\nInitializing new SSH agent...\nsucceeded\nIdentity added: /c/Users/yourusername/.ssh/id_rsa (/c/Users/yourusername/.ssh/id_rsa)\n\nAnd the following should return results:\n$ ssh-add -l\n\nHowever, if you get the following from ssh-add -l:\nCould not open a connection to your authentication agent.\n\nIt didn't spawn the SSH agent and your .bashrc is likely the cause.\nIf, when starting GitBash, you see this:\nInitializing new SSH agent...\nsh.exe\": : No such file or directory\n\nThat means you forgot to escape the $ with a \\ when echoing to the file (ie. the variables were expanded). Re-create your .bashrc to resolve this.\nVerify the agent is running and your keys have been added:\n$ ssh-add -l\n\nShould return something similar to this:\n2048 0f:37:21:af:1b:31:d5:cd:65:58:b2:68:4a:ba:a2:46 /Users/yourusername/.ssh/id_rsa (RSA)\n\nRun the following command to get your public key:\n$ cat ~/.ssh/id_rsa.pub\n\n(it should return something starting with \"ssh-rsa ......\"\n\nClick the GitBash window icon\nClick Edit\nClick Mark\nHighlight the public key using your mouse (including the leading ssh-rsa bit and the trailing == [email protected] bit)\nRight-click the window (performs a copy)\nPaste your public key into Notepad.\nDelete all the newlines such that it is only a single line.\nPress CTRL+A then CTRL+C to copy the public key again to your clipboard.\n\nConfigure your private key with BitBucket by performing the following steps:\n\nOpen your browser and navigate to the BitBucket.org site\nLogin to BitBucket.org\nClick your avatar (top-right)\nClick Manage Account\nClick SSH Keys (under Security on the left-hand menu)\nClick Add Key\nEnter Global Public Key for the Label\nPaste the public key you copied from Notepad\n\nA Global Public Key entry should now be visible in your list of keys.\n\nReturn to GitBash\ncd into the directory containing your project\nChange your origin to the SSH variation (it will not be if you ran the FOR THE LAZY steps)\n\nCheck your remotes:\n$ git remote -v\n\nSwitch to the SSH url:\n$ git remote set-url origin [email protected]:youraccount/yourproject.git\n\nCheck things are in working order:\n$ git remote show origin\n\nYou should see something like this:\nWarning: Permanently added the RSA host key for IP address '...' to the list of known hosts.\n* remote origin\n Fetch URL: [email protected]:youruser/yourproject.git\n Push URL: [email protected]:youruser/yourproject.git\n HEAD branch: master\n Remote branch:\n master tracked\n Local ref configured for 'git push':\n master pushes to master (fast-forwardable)\n\nDONE!\nYou can opt to use HTTPS instead of SSH. It will require you to type your password during remote operations (it's cached temporarily after you type it once). Here is how you can configure HTTPS:\nFOR THE LAZY\nYou should fix the SSH issue as described by VonC; however, if you're in a rush to commit and don't have the tools/time/knowledge to generate a new public key right now, set your origin to the HTTPS alternative:\n> https://[email protected]/accountname/reponame.git\n\nUsing a GUI tool such as TortoiseGit or command line tools.\nHere is the documentation of this alternative origin URL.\nCommand line to add an origin if one does not exist:\ngit remote add origin https://[email protected]/accountname/reponame.git\n\nCommand line to change an existing origin:\ngit remote set-url origin https://[email protected]/accountname/reponame.git\n\nNOTE: your account name is not your email.\nYou may also want to set your global info:\ngit config --global user.name \"Your Name\"\ngit config --global user.email \"[email protected]\"\n\nThen try your push again (no need to commit again)\ngit push origin master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Dynamically retrieve GitHub Actions secret\n\nI'm trying to dynamically pull back a GitHub secret using GitHub Actions at runtime:\nLet's say I have two GitHub Secrets:\n\nSECRET_ORANGES : \"This is an orange secret\"\nSECRET_APPLES : \"This is an apple secret\"\n\nIn my GitHub Action, I have another env variable which will differ between branches\nenv:\n FRUIT_NAME: APPLES\n\nEssentially I want to find a way to do some sort of variable substitution to get the correct secret. So in one of my child jobs, I want to do something like:\nenv:\n FRUIT_SECRET: {{ 'SECRET_' + env.FRUIT_NAME }}\n\nI've tried the following approaches with no luck:\nsecrets['SECRET_$FRUIT_NAME'] }}\n\nI even tried a simpler approach without concatenation just to try and get it working\nsecrets['$FRUIT_NAME'] }}\n\nand\n{{ secrets.$FRUIT_NAME }}\n\n\nNone of the above worked.\nApologies if I have not explained this very well. I tried to keep my example as simple as possible.\nAnyone have any idea of how to achieve this?\nAlternatively, what I am trying to do is to store secrets on a per-branch basis\nFor example:\nIn customer1 code branch:\nSECRET_CREDENTIAL=\"abc123\"\nIn customer2 code branch:\nSECRET_CREDENTIAL=\"def456\"\nThen I can access the correct value for SECRET_CREDENTIAL depending on which branch I am in.\nThanks!\nUpdate: I'm getting a bit closer to what I am trying to achieve:\nname: Test\n\nenv:\n CUSTOMER: CUSTOMER1\n\njobs:\n build:\n runs-on: ubuntu-latest\n env:\n AWS_ACCESS_KEY_ID: ${{ env.CUSTOMER }}_AWS_ACCESS_KEY_ID\n steps:\n - uses: actions/checkout@v2\n - run: |\n AWS_ACCESS_KEY_ID=${{ secrets[env.AWS_ACCESS_KEY_ID] }}\n echo \"AWS_ACCESS_KEY_ID = $AWS_ACCESS_KEY_ID\"" }, { "role": "assistant", "content": "There is a much cleaner option to achieve this using the format function.\nGiven set secrets DEV_A and TEST_A, the following two jobs will use those two secrets:\nname: Secrets\n\non: [push]\n\njobs:\n\n dev:\n name: dev\n runs-on: ubuntu-18.04\n env:\n ENVIRONMENT: DEV\n steps:\n - run: echo ${{ secrets[format('{0}_A', env.ENVIRONMENT)] }}\n\n test:\n name: test\n runs-on: ubuntu-18.04\n env:\n ENVIRONMENT: TEST\n steps:\n - run: echo ${{ secrets[format('{0}_A', env.ENVIRONMENT)] }}\n\nThis also works with input provided through manual workflows (the workflow_dispatch event):\nname: Secrets\n\non:\n workflow_dispatch:\n inputs:\n env:\n description: \"Environment to deploy to\"\n required: true\n\njobs:\n secrets:\n name: secrets\n runs-on: ubuntu-18.04\n steps:\n - run: echo ${{ secrets[format('{0}_A', github.event.inputs.env)] }}" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GIT: change commit date to author date\nIs it possible to change the commit date from my commit to the author date?\nI adapted some commits and now the dates are all the same. I want to set it back to the old dates (or the author dates). Is this possible?\nI am using Sourcetree so I have the git command line but I am not a pro at that. My external repository is bitbucket." }, { "role": "assistant", "content": "Short Answer:\ngit filter-branch --env-filter 'export GIT_COMMITTER_DATE=\"$GIT_AUTHOR_DATE\"'\n\n\nExplanation:\nfilter-branch lets you rewrite your git history. It can apply transformations to each commit or filter out commits based on certain criteria. See git filter-branch --help for a comprehensive description and usage instructions.\n--env-filter allows you to set the environment variables that are present during the creation of the new history. It is evaluated for each commit separately." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Resolve merge conflicts on pull using my changes\nI want to pull a project and resolve merge conflicts using my changes. How can I do this?" }, { "role": "assistant", "content": "Use the recursive merge strategy with the ours option:\ngit merge -s recursive -X ours branch_to_merge\n\nor \ngit pull -s recursive -X ours\n\nFor any conflicts, it will use the hunk that comes from your branch. See the git merge man page for more details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-annotate" }, { "role": "assistant", "content": "Annotate file lines with commit information" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc git diff --no-index a b" }, { "role": "assistant", "content": "compares two non-git things (1) and (2)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --abbrev-commit" }, { "role": "assistant", "content": "Instead of showing the full 40-byte hexadecimal commit object\nname, show a prefix that names the object uniquely.\n\"--abbrev=<n>\" (which also modifies diff output, if it is displayed)\noption can be used to specify the minimum length of the prefix. This should make \"--pretty=oneline\" a whole lot more readable for\npeople using 80-column terminals." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-cat-file - Provide contents or details of repository objects <type>" }, { "role": "assistant", "content": "Typically this matches the real type of <object> but asking\nfor a type that can trivially be dereferenced from the given <object> is also permitted. An example is to ask for a\n\"tree\" with <object> being a commit object that contains it,\nor to ask for a \"blob\" with <object> being a tag object that\npoints at it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitk error: autorelease pool page corrupted\nSince this morning when I try to use gitk on a project with a git instance it gives me the below error. This never happened to me since today and I have used gitk for months now.\nThe only difference I can point out is that this morning, during an attempt of installation of iStat to monitor my mac mini temperatures, I ran the command sudo gem update --system and I tried also to install rubygems-update. I don't know if there is any correlation.\nThe specific error is this:\nobjc[1253]: autorelease pool page 0x7fe20e945000 corrupted\n magic 0x00000000 0x00000000 0x00000000 0x00000000\n should be 0xa1a1a1a1 0x4f545541 0x454c4552 0x21455341\n pthread 0x10f3ecdc0\n should be 0x10f3ecdc0\n\n[1] 1253 abort gitk\n\nSince I've downloaded it and git through home brew, I've tried to use brew doctor, brew cleanup [-d] [-v], brew unlink and relink, and updated both git and gitk.\nI'm using the following command line tool: 12.0.32.28" }, { "role": "assistant", "content": "I solved the issue by resetting gitk configurations with:\nrm ~/.config/git/gitk" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs" }, { "role": "assistant", "content": "DESCRIPTION Shows the commit logs. List commits that are reachable by following the parent links from the\ngiven commit(s), but exclude commits that are reachable from the one(s)\ngiven with a ^ in front of them. The output is given in reverse\nchronological order by default. You can think of this as a set operation. Commits reachable from any of\nthe commits given on the command line form a set, and then commits reachable\nfrom any of the ones given with ^ in front are subtracted from that\nset. The remaining commits are what comes out in the command’s output.\nVarious other options and paths parameters can be used to further limit the\nresult. Thus, the following command: $ git log foo bar ^baz means \"list all the commits which are reachable from foo or bar , but\nnot from baz \". A special notation \" <commit1> .. <commit2> \" can be used as a\nshort-hand for \"^ <commit1> <commit2> \". For example, either of\nthe following may be used interchangeably: $ git log origin..HEAD\n$ git log HEAD ^origin Another special notation is \" <commit1> …​ <commit2> \" which is useful\nfor merges. The resulting set of commits is the symmetric difference\nbetween the two operands. The following two commands are equivalent: $ git log A B --not $(git merge-base --all A B)\n$ git log A...B The command takes options applicable to the git-rev-list command to control what is shown and how, and options applicable to\nthe git-diff command to control how the changes\neach commit introduces are shown." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to make git stash include new files that have not been staged?\nI'm no great expert at git but I've been using it for a couple of years. Lately I've noticed some strange behaviour relating to stashing. It seems to be only partially working for me. \nFor example today I tried to stash 4 uncommitted changes. 1 file was added to the stash, the remaining 3 stayed as uncommitted changes. Tried it a couple of times and after the first attempt I was just getting \"No local changes to save\", yet the status still showed the 3 uncommitted changes. \nHowever, by coincidence I found that when I first stage the previously unstashable changes, they will be stashed normally. I've played around and this is repeatable: If all changes are uncommitted, only the one change is stashed. If the \"problem\" changes are staged then all changes are stashed (doesn't matter whether the \"good\" change is staged or not, it will always stash).\nIs this a bug or am I doing something wrong?\nI'm using Git for Windows 2.8.2 and Git Extensions 2.48.05.\nIt doesn't matter whether I try to stash the changes via the Git Extensions GUI or via the console.\nEDIT: If I stage all 4 changes before stashing, when I do a stash pop the 3 problem changes are staged, as before, but the good change, which always stashes, is uncommitted. So the stash pop does not round trip the status to the way it was before the stash. This is repeatable as well." }, { "role": "assistant", "content": "The problem seems to be that by default the stash command will not include untracked files.\nTo include untracked files, use the -u (--include-untracked) flag:\ngit stash -u\n\n\nIf the --include-untracked option is used, all untracked files are\n also stashed and then cleaned up with git clean, leaving the working\n directory in a very clean state." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission" }, { "role": "assistant", "content": "EXAMPLES Extract commits between revisions R1 and R2, and apply them on top of\nthe current branch using git am to cherry-pick them: $ git format-patch -k --stdout R1..R2 | git am -3 -k Extract all commits which are in the current branch but not in the\norigin branch: $ git format-patch origin For each commit a separate file is created in the current directory. Extract all commits that lead to origin since the inception of the\nproject: $ git format-patch --root origin The same as the previous one: $ git format-patch -M -B origin Additionally, it detects and handles renames and complete rewrites\nintelligently to produce a renaming patch. A renaming patch reduces\nthe amount of text output, and generally makes it easier to review.\nNote that non-Git \"patch\" programs won’t understand renaming patches, so\nuse it only when you know the recipient uses Git to apply your patch. Extract three topmost commits from the current branch and format them\nas e-mailable patches: $ git format-patch -3" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is there a command to undo git-flow feature start?\nI'm inexperienced with git-flow.\nIs there a command to undo git-flow feature start?" }, { "role": "assistant", "content": "Since git-flow just wraps regular git functionality, how about simply deleting the new branch (assuming you have no changes in there you want saved)?\n$ git checkout master\nSwitched to branch 'master'\n$ git branch -d feature/your-feature-name-here" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub Pull Request to a new Upstream Branch\nMy workflow: I have a fork (origin) of a remote project (upstream). I have created a branch, topic/TICKET. I want to create a pull request of my origin branch to the upstream project in a same-named, brand new \"topic/TICKET\" branch. In other words, I don't want my pull request toward the master branch or any existing branch.\nWhen using BitBucket I have this option. When I create my PR, I select my origin branch and then the remote branch selection allows \"Create new branch (topic/TICKET)\".\nIn GitHub I don't appear to have this option. I can type in the new branch name; but then the option to continue greys out until I select a valid, existing branch upstream.\nThe annoying work-around is creating the branches upstream before I perform the PR; but it requires asking someone who can commit upstream -- it seems to me like there must be an easier way to do this. \nSo, is there any way with GitHub to create a pull request to create a new upstream branch, or is this just a known limitation?" }, { "role": "assistant", "content": "I was trying a similar thing, and the only solution I got is to have an user with push permission to upstream.\nThat way you could do a first push to upstream. Right after that, you also do a push to origin; and afterwards you can make your pull requests from branch to branch as you wish in first place.\nJust be careful when you create the pull request, because the default selected branch for upstream is always \"master\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I run git log to see changes only for a specific branch?\nI have a local branch tracking the remote/master branch. After running git-pull and git-log, the log will show all commits in the remote tracking branch as well as the current branch. However, because there were so many changes made to the remote branch, I need to see just the commits made to the current local branch.\nWhat would be the Git command to use to only show commits for a specific branch?\nNotes:\nConfiguration information:\n[branch \"my-branch\"]\n remote = origin\n merge = refs/heads/master" }, { "role": "assistant", "content": "Using git log\nAssuming that your branch was created off of master, then while in the branch (that is, you have the branch checked out):\ngit log master..\n\nIf you are not in the branch, then you can add the branch name to the \"git log\" command, like this:\ngit log master..branchname\n\nIf your branch was made off of origin/master, then say origin/master instead of master.\nGoofy alternative using \"cherry\"\nYou can make the \"cherry\" command do this as well, although the output is not as useful. While in a branch, do this to find out what commits are in the branch that are not in master:\ngit cherry -v master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GIT clone repo across local file system in windows\nI am a complete Noob when it comes to GIT. I have been just taking my first steps over the last few days. I setup a repo on my laptop, pulled down the Trunk from an SVN project (had some issues with branches, not got them working), but all seems ok there.\nI now want to be able to pull or push from the laptop to my main desktop. The reason being the laptop is handy on the train as I spend 2 hours a day travelling and can get some good work done. But my main machine at home is great for development. So I want to be able to push / pull from the laptop to the main computer when I get home. I thought the most simple way of doing this would be to just have the code folder shared out across the LAN and do:\ngit clone file://192.168.10.51/code\n\nunfortunately this doesn't seem to be working for me:\nso I open a git bash cmd and type the above command, I am in C:\\code (the shared folder for both machines) this is what I get back:\nInitialized empty Git repository in C:/code/code/.git/\nfatal: 'C:/Program Files (x86)/Git/code' does not appear to be a git repository\nfatal: The remote end hung up unexpectedly\n\nHow can I share the repository between the two machines in the most simple of ways.\nThere will be other locations that will be official storage points and places where the other devs and CI server etc will pull from, this is just so that I can work on the same repo across two machines.\nAs per Sebastian's suggestion I get the following:\nC:\\code>git clone --no-hardlinks file://192.168.10.51/code\nInitialized empty Git repository in C:/code/code/.git/\nfatal: 'C:/Program Files (x86)/Git/code' does not appear to be a git repository\nfatal: The remote end hung up unexpectedly\n\n**EDIT - ANSWER **\nThanks to all that helped. I tried the mapping a drive and that worked so thought I would go back and retry without mapping. The final result was:\ngit clone file://\\\\\\\\192.168.0.51\\code\n\nThis worked great.\nThanks" }, { "role": "assistant", "content": "You can specify the remote’s URL by applying the UNC path to the file protocol. This requires you to use four slashes:\ngit clone file:////<host>/<share>/<path>\n\nFor example, if your main machine has the IP 192.168.10.51 and the computer name main, and it has a share named code which itself is a git repository, then both of the following commands should work equally:\ngit clone file:////main/code\ngit clone file:////192.168.10.51/code\n\nIf the Git repository is in a subdirectory, simply append the path:\ngit clone file:////main/code/project-repository\ngit clone file:////192.168.10.51/code/project-repository" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git - how delete file from remote repository\nHow can I delete a file from a remote git repository?\nI have a file that I just deleted from a local repository, and I want to delete it from its corresponding remote repository." }, { "role": "assistant", "content": "If you deleted a file from the working tree, then commit the deletion:\ngit commit -a -m \"A file was deleted\"\n\nAnd push your commit upstream:\ngit push" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to quickly undo staged and unstaged changes in git?\nWhat's the quickest way to undo changes (staged and unstaged) in Git?\nBoth files unstaged.\n$ git status -s\n M file1.txt # unstaged\n?? oops.txt # unstaged\n\nOne file staged, one file unstaged.\n$ git status -s\nM file1.txt # staged\n?? oops.txt # unstaged\n\nI can add all to index and then stash save and drop. \n$ git add .\n$ git stash save\n$ git stash drop\n$ git status\nnothing to commit, working directory clean\n\nIs there a quicker way?" }, { "role": "assistant", "content": "git reset HEAD\ngit checkout .\n\ngit reset HEAD will unstage all changes and git checkout . discards all the changes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-hash-object - Compute object ID and optionally create an object from a file -w" }, { "role": "assistant", "content": "Actually write the object into the object database." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How safe is it to host sensitive data on repository sites like github, bitbucket, etc.? [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\n\nHow secure would github hosting be for private repositories? [closed]\n\n (4 answers)\n \n\nClosed 5 years ago.\n\n\n\nThis is just a question out of curiosity. I am wondering how safe it is generally considered to host sensitive data on repository websites like Github, Bitbucket, etc.? Is it safe enough to get rid of all code on local machines and just store it all on there? How about safety in the sense of keeping company secrets? I notice these sites tout big companies like Google and Yahoo use their services, but do these big companies actually store their trade secrets and important company code on websites like this?\nGithub has a page (http://help.github.com/security), which has some interesting information, that shows they are marketing it as something fool proof like I described. But in practice, do big companies like Google really find that their proprietary secrets and massive amounts of code are really safe from prying eyes and disastrous occurrences on sites like these?" }, { "role": "assistant", "content": "As always, it depends :-)\nThere can be two different meanings of \"safety\":\n\nCan I trust the hoster to keep my stuff (intellectual property, company secrets...) private?\nWhat happens to my code if the hoster suddenly goes out of service?\n\nFor 1., there is no 100% guarantee.\nOf course, the big hosters like GitHub and Bitbucket won't share your code intentionally with third parties, but there is always the possibility that some hacker manages to get the content of your private repositories.\n(this could happen to you as well if you host your code internally in your company, but this is unlikely, because unless your company is as known as, say, Google, the chance of someone trying to attack your company is much smaller than the chance of someone trying to attack a well-known public hoster).\nPlus, you have to consider the laws of the country where the hoster resides.\nA few weeks ago I read somewhere that if your hoster is in the USA, they can be forced by law to give your data to the US government under certain circumstances, and they are not even allowed to tell you about that (I don't remember the name of the law, but maybe someone else knows).\nI guess that all this causes most \"big\" companies to not host their code on a public service (my company is mid-sized, and we host our code private as well).\nBy the way, as you mentioned Google:\nI'm sure that especially Google does not use Bitbucket or GitHub. They have the complete infrastructure for project hosting themselves, so I guess they are using it internally, too. Why should they use an external service? It's in the cloud, yes...but it's their cloud.\nConcerning 2.: it's unlikely that GitHub or Bitbucket will go bankrupt tomorrow, but you never know.\nIMO it's your responsibility to take backups of your code yourself.\nThe nature of DVCS makes sure that you have some local copies of your code anyway, but it might be difficult to search lots of developer machines for the newest versions of all of your projects.\nI do this by pulling all my repositories to my local machine regularly (I wrote a tool that can do this for Bitbucket, which I use for my private projects)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_ATTR_SOURCE" }, { "role": "assistant", "content": "Sets the treeish that gitattributes will be read from." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "brew update: The following untracked working tree files would be overwritten by merge:\nI tried to run brew update and I get an error about my local changes would be lost if I merged. I tried committing my local changes (don't remember making any, but it's been awhile), and that made things worse.\nHere's the output:\nMBP:Library User$ sudo brew update\nerror: The following untracked working tree files would be overwritten by merge:\n Library/Aliases/fastcgi\n Library/Aliases/htop\n Library/Aliases/nodejs\n Library/Aliases/ocio\n Library/Aliases/oiio\n Library/Aliases/pgrep\n Library/Aliases/pkill\n Library/Contributions/cmds/brew-beer.rb\n Library/Contributions/cmds/brew-dirty.rb\n Library/Contributions/cmds/brew-graph\n Library/Contributions/cmds/brew-grep\n Library/Contributions/cmds/brew-leaves.rb\n Library/Contributions/cmds/brew-linkapps.rb\n Library/Contributions/cmds/brew-man\n Library/Contributions/cmds/brew-mirror-check.rb\n Library/Contributions/cmds/brew-missing.rb\n Library/Contributions/cmds/brew-pull.rb\n Library/Contributions/cmds/brew-readall.rb\n Library/Contributions/cmds/brew-server\n Library/Contributions/cmds/brew-services.rb\n Library/Contributions/cmds/brew-switch.rb\n Library/Contributions/cmds/brew-test-bot.commit.html.erb\n Library/Contributions/cmds/brew-test-bot.css\n Library/Contributions/cmds/brew-test-bot.index.html.erb\n Library/Contributions/cmds/brew-test-bot.rb\n Library/Contributions/cmds/brew-tests.rb\n Library/Contributions/cmds/brew-unpack.rb\n Library/Contributions/cmds/brew-which.rb\n Library/Contributions/install_homebrew.rb\n Library/Formula/abcl.rb\n Library/Formula/abyss.rb\n Library/Formula/akka.rb\n Library/Formula/apollo.rb\n Library/Formula/appledoc.rb\n Library/Formula/arangodb.rb\n Library/Formula/autoconf.rb\n Library/Formula/automake.rb\n Library/Formula/avidemux.rb\n Library/Formula/bind.rb\n Library/Formula/bsdconv.rb\n Library/Formula/bsdmake.rb\n Library/Formula/camellia.rb\n Library/Formula/cbmbasic.rb\n Library/Formula/cdo.rb\n Library/Formula/checkstyle.rb\n Library/Formula/cifer.rb\n Library/Formula/clhep.rb\n Library/Formula/collada-dom.rb\n Library/Formula/crash.rb\n Library/Formula/crossroads.rb\n Library/Formula/css-crush.rb\n Library/Formula/curlftpfs.rb\n Library/Formula/dart.rb\n Library/Formula/dasm.rb\n Library/Formula/dfc.rb\n Library/Formula/di.rb\n Library/Formula/dsniff.rb\n Library/Formula/dupx.rb\n Library/Formula/dwatch.rb\n Library/Formula/eprover.rb\n Library/Formula/ext2fuse.rb\n Library/Formula/ezlupdate.rb\n Library/Formula/f3.rb\n Library/Formula/fastx_toolkit.rb\n Library/Formula/fceux.rb\n Library/Formula/findbugs.rb\n Library/Formula/freerdp.rb\n Library/Formula/funcoeszz.rb\n Library/Formula/fwknop.rb\n Library/Formula/gabedit.rb\n Library/Formula/gbdfed.rb\n Library/Formula/gconf.rb\n Library/Formula/git-encrypt.rb\n Library/Formula/glm.rb\n Library/Formula/gmap-gsnap.rb\n Library/Formula/gnu-arch.rb\n Library/Formula/gnunet.rb\n Library/Formula/gobby.rb\n Library/Formula/gptfdisk.rb\n Library/Formula/griffon.rb\n Library/Formula/grok.rb\n Library/Formula/gtk-chtheme.rb\n Library/Formula/gtkglextmm.rb\n Library/Formula/gtmess.rb\n Library/Formula/hg-flow.rb\n Library/Formula/hqx.rb\n Library/Formula/htop-osx.rb\n Library/Formula/htpdate.rb\n Library/Formula/imap-uw.rb\n Library/Formula/iozone.rb\n Library/Formula/ipbt.rb\n Library/Formula/ipe.rb\n Library/Formula/ispc.rb\n Library/Formula/ispell.rb\n Library/Formula/jigdo.rb\n Library/Formula/jing.rb\n Library/Formula/jless.rb\n Library/Formula/jpeginfo.rb\n Library/Formula/konoha.rb\n Library/Formula/legit.rb\n Library/Formula/libcouchbase.rb\n Library/Formula/libcuefile.rb\n Library/Formula/libextractor.rb\n Library/Formula/libglademm.rb\n Library/Formula/libgtextutils.rb\n Library/Formula/libinfinity.rb\n Library/Formula/libkate.rb\n Library/Formula/libqalculate.rb\n Library/Formula/libqglviewer.rb\n Library/Formula/libreplaygain.rb\n Library/Formula/libtool.rb\n Library/Formula/libvbucket.rb\n Library/Formula/libvo-aacenc.rb\n Library/Formula/libxmi.rb\n Library/Formula/lifelines.rb\n Library/Formula/makeicns.rb\n Library/Formula/mathgl.rb\n Library/Formula/meld.rb\n Library/Formula/mesalib-glw.rb\n Library/Formula/minisat.rb\n Library/Formula/minuit2.rb\n Library/Formula/mobile-shell.rb\n Library/Formula/movgrab.rb\n Library/Formula/mp3cat.rb\n Library/Formula/mpich2.rb\n Library/Formula/mrfast.rb\n Library/Formula/musepack.rb\n Library/Formula/ndiff.rb\n Library/Formula/net6.rb\n Library/Formula/nrpe.rb\n Library/Formula/nuttcp.rb\n Library/Formula/oath-toolkit.\nUpdating aa07533..3f070ef\nAborting\nError: Failed while executing git pull origin refs/heads/master:refs/remotes/origin/master" }, { "role": "assistant", "content": "Don't forget to fetch the origin:\ncd /usr/local/Homebrew\ngit fetch origin\ngit reset --hard origin/master\n\nWhat happens is that you are trying to update brew, but brew itself is either not up to date (likely), there is a permissions change via some OS update (also likely), or brew is slightly corrupt (unlikely). Since brew itself is a git repo, you have to update or reset brew to the master branch version. brew [by default] is located in the /usr/local/Homebrew folder, so you\n\nGo to that folder [first command] which also should update permissions (if not see below)\nFetch the origin [second command] which means to update your LOCAL version of the remote branch of brew\nHard reset [3rd command] based on the REMOTE master branch (which also uses your current permissions).\n\nYou can also chown the first command if you are in a non sudo or admin profile\nsudo chown -R `whoami` /usr/local/Homebrew\ncd /usr/local/Homebrew\ngit reset --hard origin/master\n\nTo understand git reset, take a look at this article." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-bundle - Move objects and refs by archive" }, { "role": "assistant", "content": "SYNOPSIS git bundle create [-q | --quiet | --progress]\n\t\t [--version=<version>] <file> <git-rev-list-args> git bundle verify [-q | --quiet] <file> git bundle list-heads <file> [<refname>…​] git bundle unbundle [--progress] <file> [<refname>…​]" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker <object>" }, { "role": "assistant", "content": "Indicates the object name for any type of object." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-revert - Revert some existing commits -X<option> --strategy-option=<option>" }, { "role": "assistant", "content": "Pass the merge strategy-specific option through to the\nmerge strategy. See git-merge for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to fast-forward a branch to head\nI switched to master after developing on a branch for a long time. The log shows:\n\nYour branch is behind 'origin/master' by 167 commits, and can be fast-forwarded.\n\nI tried:\ngit checkout HEAD\n\nIt doesn't have any effect. This is because I have checked out an intermediate commit on master.\nHow can I make master stay on head?" }, { "role": "assistant", "content": "Try git merge origin/master. If you want to be sure that it only does a fast-forward, you can say git merge --ff-only origin/master." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "remote: GitLab: You are not allowed to push code to protected branches on this project\n\nI am trying to push to master branch of a repo and I am failing to do so, since it is protected.\nI tried to look into the project settings and do not see any option for protected branches. The only option I could see is members. \nremote: GitLab: You are not allowed to push code to protected branches on this project.\nTo [email protected]:cmd/release.git\n ! [remote rejected] master -> master (pre-receive hook declined)\nerror: failed to push some refs to '[email protected]:cmd/release.git'\n\nMy repo has only one branch, with no contents in it so far.\nI do see protected branches options of my other Repos but not for this specific one.\nIt is a new repo with no contents and with only default branch.\nI have the master permission.\nUnfortunately I am not able to upload the image here somehow. \nPlease suggest how to push code to master branch." }, { "role": "assistant", "content": "12/17/2018\n1. git push: \"error: failed to push some refs to\"\n\ngit push -f: \"remote rejected\"\n\n2. the branch is in a protected state and cannot be forced to operate.\nGitlab - Repository - Branches\n\n3. temporarily remove branch protection.\nGitlab - Settings - Repository - Protected Branches - Unprotect\n\n4. try pushing again\ngit push -f\n\n5. may add protection" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options color.push" }, { "role": "assistant", "content": "A boolean to enable/disable color in push errors. May be set to always , false (or never ) or auto (or true ), in which\ncase colors are used only when the error output goes to a terminal.\nIf unset, then the value of color.ui is used ( auto by default)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-clone - Clone a repository into a new directory init.templateDir" }, { "role": "assistant", "content": "Specify the directory from which templates will be copied. (See the \"TEMPLATE DIRECTORY\" section of git-init .)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-clone - Clone a repository into a new directory" }, { "role": "assistant", "content": "NAME git-clone - Clone a repository into a new directory" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git checkout error: unable to read askpass response in Windows 10\nError occurred while cloning repository in Android Studio\nerror: unable to read askpass response from 'C:\\Users\\User\\AppData\\Local\\Google\\AndroidStudio2021.1\\tmp\\intellij-git-askpass-local.sh'\nbash: /dev/tty: No such device or address\nerror: failed to execute prompt script (exit code 1)\nfatal: could not read Username" }, { "role": "assistant", "content": "Resolved above issue with below steps:\n\nClick on the File Menu of Android Studio -> Settings -> Expand Version Control\nInside Version Control, select Git & Check Use Credential Helper" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git status - is there a way to show changes only in a specific directory?\nI would like to see a list of files modified since the last commit, as git status shows, but I care only about files located in a single directory. Is there a way to do this? I tried git status <directory>, but it seems this does something completely different (lists all changed files, as they would be if I wrote git add <directory> first). \nThe documentation for git-status doesn't tell much, apart from the fact that it accepts the same options that git-commit does (but git-commit's purpose isn't to show lists of changed files)." }, { "role": "assistant", "content": "From within the directory:\ngit status .\n\n\nYou can use any path really, use this syntax:\ngit status <directoryPath>\n\nFor instance for directory with path \"my/cool/path/here\"\ngit status my/cool/path/here" } ]