messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I git add only lines matching a pattern?\nI'm tracking with git some configuration files. I usually do an interactive git add -p but I'm looking at a way to automatically add all new/modified/deleted lines that match a pattern. Otherwise it's going to take me ages to do all the interactive split and add. git add has a pattern matching for filenames, but I can't find anything about the content." }, { "role": "assistant", "content": "here's a way:\n\nuse git diff > patch to make a patch of the current diff.\nuse gawk to make a second patch only of +/- lines matching the pattern: remove - from deleted lines not matching the pattern, delete + lines not matching the pattern, modify the hunk header line numbers, output each modified hunk, but don't output any modified hunks that no longer have any changes in them.\nuse git stash save, apply patch, add -u, and stash pop to apply and stage the modified patch and leave the rest of the changes unstaged.\n\nthis worked for several test cases, it works on the entire diff at once (all files), and it's quick.\n#!/bin/sh\n\ndiff=`mktemp`\ngit diff > $diff\n[ -s $diff ] || exit\n\npatch=`mktemp`\n\ngawk -v pat=\"$1\" '\nfunction hh(){\n if(keep && n > 0){\n for(i=0;i<n;i++){\n if(i==hrn){\n printf \"@@ -%d,%d +%d,%d @@\\n\", har[1],har[2],har[3],har[4];\n }\n print out[i];\n }\n }\n}\n{\n if(/^diff --git a\\/.* b\\/.*/){\n hh();\n keep=0;\n dr=NR;\n n=0;\n out[n++]=$0\n }\n else if(NR == dr+1 && /^index [0-9a-f]+\\.\\.[0-9a-f]+ [0-9]+$/){\n ir=NR;\n out[n++]=$0\n }\n else if(NR == ir+1 && /^\\-\\-\\- a\\//){\n mr=NR;\n out[n++]=$0\n }\n else if(NR == mr+1 && /^\\+\\+\\+ b\\//){\n pr=NR;\n out[n++]=$0\n }\n else if(NR == pr+1 && match($0, /^@@ \\-([0-9]+),?([0-9]+)? \\+([0-9]+),?([0-9]+)? @@/, har)){\n hr=NR;\n hrn=n\n }\n else if(NR > hr){\n if(/^\\-/ && $0 !~ pat){\n har[4]++;\n sub(/^\\-/, \" \", $0);\n out[n++] = $0\n }\n else if(/^\\+/ && $0 !~ pat){\n har[4]--;\n }\n else{\n if(/^[+-]/){\n keep=1\n }\n out[n++] = $0\n }\n }\n}\nEND{\n hh()\n}' $diff > $patch\n\ngit stash save &&\n git apply $patch &&\n git add -u &&\n git stash pop\n\nrm $diff\nrm $patch\n\nrefs:\ngit diff apply\nunified diff format\ngawk match groups to array\ngit add -u" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to check for changes on remote (origin) Git repository\nWhat are the Git commands to do the following workflow?\nScenario\nI cloned from a repository and did some commits of my own to my local repository. In the meantime, my colleagues made commits to the remote repository. Now, I want to:\n\nCheck whether there are any new\ncommits from other people on the\nremote repository, i.e. origin?\n\nSay there were three new commits on the\nremote repository since my last\npull, I would like to diff the\nremote repository's commits, i.e.\nHEAD~3 with HEAD~2, HEAD~2 with\nHEAD~1 and HEAD~1 with HEAD.\n\nAfter knowing what changed remotely,\nI want to get the latest commits\nfrom the others.\n\n\nMy findings so far\nFor step 2: I know the caret notation HEAD^, HEAD^^ etc. and the tilde notation HEAD~2, HEAD~3, etc.\nFor step 3: That is, I guess, just a git pull." }, { "role": "assistant", "content": "You could git fetch origin to update the remote branch in your repository to point to the latest version. For a diff against the remote:\ngit diff origin/master\n\nYes, you can use caret notation as well.\nIf you want to accept the remote changes:\ngit merge origin/master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Permission denied (publickey). fatal: The remote end hung up unexpectedly while pushing back to git repository [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\nClosed 11 years ago.\n\n\n\n\nPossible Duplicate:\ngithub: newbie problems -> Permission denied (publickey). fatal: The remote end hung up unexpectedly \n\nplease see the below command ,\n$ git clone git://github.com/{user_name}/{project_name}.git\nInitialized empty Git repository in /home/dengx/rorBlog_demo/rorblog/.git/\n\nChanging the files and committing it, so i need to push back to git repository.\n$ git push [email protected]/{user_name}/{project_name}.git master\nPermission denied (publickey).\nfatal: The remote end hung up unexpectedly\n\nso, i copy the ssh-key of the repository to my file ~/.ssh/id_rsa.pub, and then push again,\n$ git push [email protected]/{user_name}/{project_name}.git master\nAgent admitted failure to sign using the key.\nPermission denied (publickey).\nfatal: The remote end hung up unexpectedly\n\nNow, what should i do , thanks any helps." }, { "role": "assistant", "content": "Googled \"Permission denied (publickey). fatal: The remote end hung up unexpectedly\", first result an exact SO dupe:\nGitHub: Permission denied (publickey). fatal: The remote end hung up unexpectedly which links here in the accepted answer (from the original poster, no less): http://help.github.com/linux-set-up-git/" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git push: Push all commits except the last one\nIs there a way to push all my local commits to the remote repository except the most recent one? I'd like to keep the last one locally just in case I need to do an amend." }, { "role": "assistant", "content": "Try this (assuming you're working with master branch and your remote is called origin):\ngit push origin HEAD^:master\n\nHEAD^ points to the commit before the last one in the current branch (the last commit can be referred as HEAD) so this command pushes this commit (with all previous commits) to remote origin/master branch. \nIn case you're interested you can find more information about specifying revisions in this man page.\nUpdate: I doubt that's the case, but anyway, you should be careful with that command if your last commit is merge. With merge commit in the HEAD HEAD^ refers to the first parent of that commit, HEAD^2 - to its second parent, etc." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository --no-recurse-submodules" }, { "role": "assistant", "content": "Disable recursive fetching of submodules (this has the same effect as\nusing the --recurse-submodules=no option)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-switch - Switch branches" }, { "role": "assistant", "content": "SYNOPSIS git switch [<options>] [--no-guess] <branch> git switch [<options>] --detach [<start-point>] git switch [<options>] (-c|-C) <new-branch> [<start-point>] git switch [<options>] --orphan <new-branch>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Updating pull request after review changes commit doesn't show up in the pull request\n\nI forked a GitHub repository and made some changes on my fork and submited a pull request but the owners of the original GitHub repository asked for some changes which they asked me for in the pull request. I assumed that adding additional changes to my fork will cause them to show up in the current pull request but to my surprise I can't see my changes in the pull request.\nThis is what I did after generating the original pull request:\n\nmade code changes\nadd the files 1git add -A`\ncommit the files git commit -m \"these are my suggested changes in pull request\"\nsubmit my changes with git push\n\nI can see changes on my own fork but I don't understand why I can't see any changes in the pull request.\nDoes anyone know what I need to do for my changes to show up in the current pull request?\nI'd really appreciate your help." }, { "role": "assistant", "content": "First, make sure that you did push to the right branch and that the commit still doesn't show up in the PR. For me, the commit showed up when I viewed the specific branch in the repo, but didn't show in the PR and didn't trigger CI.\nThis is what fixed the issue for me:\n\nClick on Edit in the top right corner.\nClick on the base selector and choose the same base branch.\nGitHub will ask you whether you want to change base, confirm.\nThe PR should update and the commit should show up." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Does Git flow deletes branch on remote server?\nI am using git along with git flow. Here git flow has a develop branch. Whenever i need to start feature i type\ngit flow feature start new\n\na new branch feature/new is created. Then i do the changes and commit them using\ngit push origin feature/new\n\nAfter comitting the changes I finish feature using \ngit flow feature finish new\n\nit deletes feature/new branch locally. Now I am switched to develop branch by git flow and I again type\ngit push origin develop\n\nwhich make changes to remote server develop branch\nIf I type git branch -a, the new branch got deleted from the local but it is there on the server with name remotes/origin/feature/new\nDoes git flow delete branches on remote server which are deleted at my local machine?\nPlease tell me if I am making some mistake." }, { "role": "assistant", "content": "Looking at the source it seems that the remote feature branch is deleted only if you call git flow feature finish with -F.\nHowever, this fetches the remote before finishing the feature. From the docs:\n\n-F fetch from $ORIGIN before performing finish\n\nOtherwise you can delete the remote branch manually with:\ngit push origin :feature/new" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker gitweb" }, { "role": "assistant", "content": "Git web interface (web frontend to Git repositories)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-branch - List, create, or delete branches --show-current" }, { "role": "assistant", "content": "Print the name of the current branch. In detached HEAD state,\nnothing is printed." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-clean - Remove untracked files from the working tree -n --dry-run" }, { "role": "assistant", "content": "Don’t actually remove anything, just show what would be done.\nConfiguration variable clean.requireForce is ignored, as\nnothing will be deleted anyway." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database missingType" }, { "role": "assistant", "content": "(ERROR) Invalid type value on the type line in a tag object." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I make git am / git apply work \"fuzzy\" like the patch command\nI've been using git-format-patch and git-am to apply changes from one repository to another. The file structures are the same but there are some changes in the repository I'm apply to which cause most patches to fail a few hunks. But most of the patch hunks apply with a little but of fuzzyness in the line numbers.\nAs far as I can tell git-am apply a very strict interpretation so rejects all these patches outright. \nSo my workflow has become\n$ git am ../the-patch.patch\n# Fails because the patch doesn't apply cleanly\n$ patch -p1 < ../the-patch.patch\n# Applies most of the hunks, leaves .rej files for the ones that conflict\n# Fix the conflicting hunks manually\n$ git am --continue\n\nIt would be nice if I didn't have to run the command line patch and could just have that happen as part of the am command.\nRunning with the --reject flag seems to create a .rej file with all the hunks in the file if any conflict, which isn't what I want.\nRunning with the --3way flag fails with \nfatal: sha1 information is lacking or useless (the-file.java).\nRepository lacks necessary blobs to fall back on 3-way merge.\nCannot fall back to three-way merge.\n\nWhich I presume is because the change set this was based on is not in the repository I'm merging to.\nIs there any way to make git-am apply the patch with fuzzy matching like the raw patch command does and only create .rej files containing the hunks that failed?" }, { "role": "assistant", "content": "You can do the following:\ngit am /path/to/some.patch\npatch -p1 < /path/to/some.patch\ngit add .\ngit am --continue\n\nThat would apply the patch and keep the commit message, etc." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to view diff of a forked github project\n\nI have forked a project on github and need to have a set of changes I made since I forked, in diff format.\nIf you wonder - I've forked Apache httpd and I'm changing some code in core. Currently I'm not commiting any changes, running git diff, and use its output as a patch against vanilla httpd sources in an RPM building process. It is, of course, wrong, but I don't know how to do it properly. All I know is I need a diff in the end." }, { "role": "assistant", "content": "Online solution:\n\nget /repos/{owner}/{repo}/compare/{base}...{head}\n\n\nThe \"compare two commits\" API does support multiple repositories:\n\nBoth :base and :head must be branch names in :repo.\nTo compare branches across other repositories in the same network as :repo, use the format <USERNAME>:branch.\n\nExample:\nhttps://api.github.com/repos/octocat/hello-world/compare/master...abejpn:master\nOr with a GitHub URL:\nhttps://github.com/octocat/Hello-World/compare/master...abejpn:master\n\nOriginal answer 2010:\n\nAdd the original GitHub repo (the one you have forked) as a remote one on your local repo.\n(git remote add mainRepo github_url)\ngit fetch mainRepo to get the latest changes from that original \"mainRepo\".\ngit log HEAD..mainRepo/master will show you all your changes between the latest on mainRepo master branch and your current branch.\ngit diff HEAD..mainRepo/master would display it in diff format.\n\nIn learn.GitHub:\ngit diff mainRepo/master...HEAD\n\nwould list all your changes since you have forked from mainRepo:\n\nThis will not compare the last ‘master’ branch snapshot and the last ‘dev’ snapshot - it will instead compare the common ancestor of both with ‘dev’. That will tell you what changed since the branch point." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "moving committed (but not pushed) changes to a new branch after pull\nI've done a fair bit of work (\"Your branch is ahead of 'origin/master' by 37 commits.\") which really should have gone into its own branch rather than into master. These commits only exist on my local machine and have not been pushed to origin, but the situation is complicated somewhat in that other devs have been pushing to origin/master and I've pulled those changes.\nHow do I retroactively move my 37 local commits onto a new branch? Based on the docs, it appears that git rebase --onto my-new-branch master or ...origin/master should do this, but both just give me the error \"fatal: Needed a single revision\". man git-rebase says nothing about providing a revision to rebase and its examples do not do so, so I have no idea how to resolve this error.\n(Note that this is not a duplicate of Move existing, uncommited work to a new branch in Git or How to merge my local uncommitted changes into another Git branch? as those questions deal with uncommitted changes in the local working tree, not changes which have been committed locally.)" }, { "role": "assistant", "content": "This should be fine, since you haven't pushed your commits anywhere else yet, and you're free to rewrite the history of your branch after origin/master. First I would run a git fetch origin to make sure that origin/master is up to date. Assuming that you're currently on master, you should be able to do:\ngit rebase origin/master\n\n... which will replay all of your commits that aren't in origin/master onto origin/master. The default action of rebase is to ignore merge commits (e.g. those that your git pulls probably introduced) and it'll just try to apply the patch introduced by each of your commits onto origin/master. (You may have to resolve some conflicts along the way.) Then you can create your new branch based on the result:\ngit branch new-work\n\n... and then reset your master back to origin/master:\n# Use with care - make sure \"git status\" is clean and you're still on master:\ngit reset --hard origin/master\n\nWhen doing this kind of manipulating branches with git branch, git reset, etc. I find it useful to frequently look at the commit graph with gitk --all or a similar tool, just to check that I understand where all the different refs are pointing.\nAlternatively, you could have just created a topic branch based on where your master is at in the first place (git branch new-work-including-merges) and then reset master as above. However, since your topic branch will include merges from origin/master and you've not pushed your changes yet, I'd suggest doing a rebase so that the history is tidier. (Also, when you eventually merge your topic branch back to master, the changes will be more obvious.)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Exit Vim without committing changes in Git [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do I stop a Git commit when VI is on the screen waiting for a commit message?\n\n (3 answers)\n \n\nClosed 2 months ago.\n\n\n\nWhen I use git commit --amend or git rebase -i, vim opens up for me to make changes. If I then change my mind and exit vim without making any changes, a commit is still made which shows up in git reflog.\nHow do I exit the editor without committing anything?" }, { "role": "assistant", "content": ":cq!\n\nThis will force an error to Vim and it will not save any changes. Link to Vim manual.\nYou may want to use cq without ! if you want vim to exit with an error and without saving." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --since-as-filter=<date>" }, { "role": "assistant", "content": "Show all commits more recent than a specific date. This visits\nall commits in the range, rather than stopping at the first commit which\nis older than a specific date." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-pull" }, { "role": "assistant", "content": "Fetch from and integrate with another repository or a local branch" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --subject-prefix=<subject-prefix>" }, { "role": "assistant", "content": "Instead of the standard [PATCH] prefix in the subject\nline, instead use [<subject-prefix>] . This can be used\nto name a patch series, and can be combined with the --numbered option. The configuration variable format.subjectPrefix may also be used\nto configure a subject prefix to apply to a given repository for\nall patches. This is often useful on mailing lists which receive\npatches for several repositories and can be used to disambiguate\nthe patches (with a value of e.g. \"PATCH my-project\")." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --topo-order" }, { "role": "assistant", "content": "Show no parents before all of its children are shown, and\navoid showing commits on multiple lines of history\nintermixed. For example, in a commit history like this: ---1----2----4----7\n\t\\\t \\\n\t 3----5----6----8--- where the numbers denote the order of commit timestamps, git\nrev-list and friends with --date-order show the commits in the\ntimestamp order: 8 7 6 5 4 3 2 1. With --topo-order , they would show 8 6 5 3 7 4 2 1 (or 8 7 4 2 6 5\n3 1); some older commits are shown before newer ones in order to\navoid showing the commits from two parallel development track mixed\ntogether." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --no-indent-heuristic" }, { "role": "assistant", "content": "Disable the indent heuristic." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Graphics in GitHub commit messages\n\nHow to add graphics/image in git commit messages (pushed to Github)?" }, { "role": "assistant", "content": "Here is a list of codes to put in your commit message to get those icons:\nEmoji cheat sheet\nFor instance, to get this commit message:\n\nenter Release 2.0.1 :gem::star2:.\nIf you see an icon on GitHub you want to use, hover your mouse over it, and the tooltip will tell you that icon’s code. Or copy and paste a commit message to convert icons to their codes.\nThat cheat sheet website is open-source – here is its code.\nCaveats: you can’t put an arbitrary image into a commit message – these codes work on GitHub only because GitHub implemented the emoji on that list. And of course, it is up to the Git interface you are using to display emoji or link URLs – Git’s command-line interface will probably not do either of those." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to get changes from another branch\nI am currently working on featurex branch. Our master branch is named our-team. Since I started working on featurex, more changes have been made to branch our-team.\nI have done this locally to get all the latest changes from our-team:\ngit checkout our-team\ngit pull\n\nBefore I push featurex for merging, I would locally like to get all changes from our-team branch into featurex so that I can ensure everything works as expected.\nHow can I do that?" }, { "role": "assistant", "content": "Before following these instructions keep in mind that featurex is the branch where changes are being merged and pushed\n\ngo to your branch featurex\ngit checkout featurex\n\n\nmerge the changes of our-team branch into featurex branch\ngit merge our-team\n\nor\ngit cherry-pick {commit-hash}\n\nif you want to merge specific commits.\n\n\nNote: probably you will have to fix conflicts after merging our-team branch into featurex branch before pushing." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker --noglob-pathspecs" }, { "role": "assistant", "content": "Add \"literal\" magic to all pathspec. This is equivalent to setting\nthe GIT_NOGLOB_PATHSPECS environment variable to 1 . Enabling\nglobbing on individual pathspecs can be done using pathspec\nmagic \":(glob)\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git doesn't show how many commits ahead of origin I am, and I want it to\nThere are plenty of questions here about Git saying people are ahead of a remote branch by X commits, and they want it to stop.\nI have the opposite problem. I want Git to tell me how many commits ahead I am, but it doesn't.\nWhen I created my remote bare repository first, then cloned from it, this worked. In my current case I created the local repository first, then cloned it (bare) to the remote.\nThis set up my local repository as the remote for the bare repository. But I removed that, and manually added the remote repository reference to my local. Pushing works fine. But I don't see the \"You are ahead by X commits\" message. How can I get it?" }, { "role": "assistant", "content": "git branch --set-upstream local origin/remote\nlocal and remote are the names of your local resp. remote branches.\nIn Git version 1.8 and later, it's even easier. Make sure you're on the local branch, and then:\ngit branch --set-upstream-to origin/remote" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What does FETCH_HEAD in Git mean?\ngit pull --help says:\n\nIn its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD.\n\nWhat is this FETCH_HEAD and what is actually merged during git pull?" }, { "role": "assistant", "content": "FETCH_HEAD is a short-lived ref, to keep track of what has just been fetched from the remote repository. git pull first invokes git fetch, in normal cases fetching a branch from the remote; FETCH_HEAD points to the tip of this branch (it stores the SHA1 of the commit, just as branches do). git pull then invokes git merge, merging FETCH_HEAD into the current branch.\nThe result is exactly what you'd expect: the commit at the tip of the appropriate remote branch is merged into the commit at the tip of your current branch.\nThis is a bit like doing git fetch without arguments (or git remote update), updating all your remote branches, then running git merge origin/<branch>, but using FETCH_HEAD internally instead to refer to whatever single ref was fetched, instead of needing to name things." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can I fork another persons repo twice into my own account?\n\nOn GitHub, I can't seem to figure out how I can fork a repo twice into one account.\nSo there is a repo from Bob/CoolFramework\nI fork it to Jeremy/MyShooter and start to build a game\nNow I also want to fork it to Jeremy/MyRPG to build another new game\nWhen I try to fork CoolFramework a second time, it just takes me to MyShooter.\nSo the options I can think of:\nA) I'm not using Git in the right way\nB) It's not possible on Git\nC) I just couldn't see the option on Github" }, { "role": "assistant", "content": "In your case, I would suggest going with submodules. However to answer your exact question, here's how you should proceed.\n\nStart by creating Jeremy/MyShooter and Jeremy/MyRPG on Github. Keep them empty.\nClone your origin project on your system, twice, giving it different names\n$ git clone http://github.com/Bob/CoolFramework MyShooter\n$ git clone http://github.com/Bob/CoolFramework MyRPG\n\nYou now have 2 different local repos pointing to the same origin. You should remove the origin and point to yours as a remote:\n$ cd MyShooter\n$ git remote remove origin\n$ git remote add origin http://github.com/Jeremy/MyShooter.git\n$ git push -u origin master\n\nDon't forget to do the same for MyRPG" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options sendemail.aliasFileType" }, { "role": "assistant", "content": "Format of the file(s) specified in sendemail.aliasesFile. Must be\none of mutt , mailrc , pine , elm , gnus , or sendmail . What an alias file in each format looks like can be found in\nthe documentation of the email program of the same name. The\ndifferences and limitations from the standard formats are\ndescribed below: sendmail Quoted aliases and quoted addresses are not supported: lines that\ncontain a \" symbol are ignored. Redirection to a file ( /path/name ) or pipe ( |command ) is not\nsupported. File inclusion ( :include: /path/name ) is not supported. Warnings are printed on the standard error output for any\nexplicitly unsupported constructs, and any other lines that are not\nrecognized by the parser." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Applying the changes from branch A to B, without merging or adding commits\nMy scenario is that I have one branch in which I've made big improvements to the build process (branch A) and in another I'm working on a unrelated feature (branch B). So now when I'm hacking away at branch B, I want to pull in the stuff I wrote in branch A because I want faster and easier builds. However, I don't want to \"pollute\" my branch B, just add changes from branchA to unstaged changes. \nWhat I've tried (when standing on branchB):\ngit merge --no-commit branchA\n\nDoesn't work because it puts you inside a merge. If it didn't, it would be perfect.\ngit checkout branchA -- .\n\nDoesn't work because it applies changes between branchA..branchB and not the changes master..branchA.\nAnything else?\nEdit: Yes, changes on branch A are committed. In this example there is only one branch with build improvements, but there may be up to N branches with build improvements that I want to apply while working on a feature branch." }, { "role": "assistant", "content": "I just had to do something similar and was able to fix it by adding --squash to the merge command\ngit merge --no-commit --squash branchA\ngit reset HEAD # to unstage the changes" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --ignore-missing" }, { "role": "assistant", "content": "Upon seeing an invalid object name in the input, pretend as if\nthe bad input was not given." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-shortlog - Summarize git log output --dense" }, { "role": "assistant", "content": "Only the selected commits are shown, plus some to have a\nmeaningful history." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Two git repositories in one directory?\nIs it possible to have 2 git repositories in one directory? I'd think not, but thought I'd ask. Basically, I'd like to check in my home directory config files (e.g. .emacs) which should be common across all of the machines I work on, but have a second repository for local files (e.g. .emacs.local), which contains machine-specific configurations. The only way I can think of to do that is to have the local config in a subdirectory and ignore that subdirectory from the main git repository. Any other ideas?" }, { "role": "assistant", "content": "This article covers this relatively well:\nhttps://github.com/rrrene/gitscm-next/blob/master/app/views/blog/progit/2010-04-11-environment.markdown\nBasically if you're working from the command-line this is simpler than you might guess. Suppose you want 2 git repos:\n.gitone\n.gittwo\n\nYou could set them up like so:\ngit init .\nmv .git .gitone\ngit init .\nmv .git .gittwo\n\nYou could add a file and commit it to only one like so:\ngit --git-dir=.gitone add test.txt\ngit --git-dir=.gitone commit -m \"Test\"\n\nSo the options for git come first, then the command, then the git command's options. You could easily enough alias a git command like:\n#!/bin/sh\nalias gitone='git --git-dir=.gitone'\nalias gittwo='git --git-dir=.gittwo'\n\nSo you can commit to one or the other with a bit less typing, like gitone commit -m \"blah\".\nWhat appears to get trickier is ignores. Since .gitignore normally sits in the project root, you'd need to find a way to switch this as well without switching the entire root. Or, you could use .git/info/exclude, but all the ignores you perform then won't be committed or pushed - which could screw up other users. Others using either repo might push a .gitignore, which may cause conflicts. It's not clear to me the best way to resolve these issues.\nIf you prefer GUI tools like TortoiseGit you'd also have some challenges. You could write a small script that renames .gitone or .gittwo to .git temporarily so these tools' assumptions are met.\nAvoiding 2 Repos\nYou can accomplish a similar result by composing your branch, although you're still doing a fair bit of dancing to keep things going.\nSuppose you have local files, like system-specific settings in the original question. You want to keep them out of your commits to other developers, but, you want them committed somewhere, as they're either essential to run, or, could be critical in debugging\nInstead of 2 git repos you can do the following:\ngit checkout main\ngit checkout -b local\ngit add -A .\ngit commit -m \"local changes\"\ngit checkout main\ngit checkout -b chris\ngit checkout -b dev\ngit merge local\n\nSo, you started with local changes, that you put out on a branch called \"local\". You're never going to push this branch to the remote.\nYou set those changes aside, then made another branch off of main named with what you'll be pushing, for example named after you (in my case, \"chris\").\nSo far you have the 2 distinct branches, but, you don't have a way for them to work together. You make a third, Composed Branch - dev here is a composition of chris and local.\nYou do your dev in dev, then when it's time to push, you:\ngit checkout chris\ngit add -A .\ngit commit -m \"My commit message\"\ngit push\n\ngit checkout dev\ngit merge chris\n\nThis pushes the changes, clean out on chris, then comes back to dev and recomposes the branch. chris continues to remain squeaky clean, your meaningful changes are pushed, and the stuff you wanted to preserve locally stays safe on the local branch.\nMore special scenarios:\nPushing your local branch\nSuppose you wanted to push your \"local\" branch afterall, for example if there's no important secrets in it and you're using git partly as a backup. Easy fix, just name the branch something long and very clear so no dev pulls it and expects it to work for them, like chris-local-settings. If you dislike typing that long name over and over (and tab completion isn't enough), branching the branch is super cheap:\ngit checkout chris-local-settings\ngit checkout -b local\n\nGenerated files\nSuppose your local branch is more complex, and there are generated files that keep creating clutter. You need them to debug, but you never want to push them to your clean branch filled with just your, non-generated changes.\nYour generated files probably follow a pattern, or if they don't, you probably have some say in where they generate when so they do follow a pattern. For example, if all you generated files appear in a folder named \"bin\" and you've just finished some important coding:\ngit checkout local\ncd bin\ngit add -A .\ngit commit -m \"Generated files\"\ncd ..\ngit checkout chris\ngit commit -m \"Commit message about my clean handwritten changes\"\ngit push\ngit checkout dev\ngit merge local\ngit merge chris\n\nBecause you know all your generated files are in the bin folder, you can just cd over and git add there. You cleanly dump them off in local, then back out to root and commit the rest to your clean branch. You then recompose your dev branch.\nIf in the future you need to know what your build looked like for a given day and time, you can recompose another branch, or, step back in time on the dev branch. That said, I usually throw out and recompose the dev branch often in my build, so, it has no history unfortunately:\nImagine some changes happened on main, and I need to verify they work before potentially poisoning my build:\ngit checkout main\ngit pull\ngit checkout dev\ngit checkout -b test\ngit merge main\n\nNow I'd run tests to verify the build. If they go poorly:\ngit checkout dev\ngit branch -D test\n\nAnd off I go to tell whoever last pushed to main, they broke it. Now I'm safe in dev away from the broken main branch. Or, if the tests go well:\ngit checkout chris\ngit merge main\ngit push\ngit branch -D dev\ngit checkout -b dev\ngit merge local\n\nThat turns dev into a clean merge of chris, which has the latest on main merged in, so those pulling the chris branch get what's latest on main plus my changes and nothing more - meaning I'm not throwing extra merge conflicts at them. But it does mean I keep losing history on dev." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Repository access denied. access via a deployment key is read-only\nAfter successfully cloning my repo from heroku and added another remote\n1/ git clone [email protected]:[APP].git\n2/ git remote add bitbucket ssh://[email protected]/[ACCOUNT]/[REPO].git\n3/ git push bitbucket master\n\nI am still getting this error after running line (3) or using SourceTree\nconq: repository access denied. access via a deployment key is read-only.\n\nFirst I don't understand what this message means in practice. And that's shame.\nI did create ssh key pair and added to heroku :\nssh-keygen -t rsa \nheroku keys:add ./id_rsa.pub \n\nI also added my key in deployment keys section in BitBucket. But I must be missing something. This question is not out of laziness, I have been reading various docs including BitBuckets guides. But it still don't get around this issue.\nThis post is related to Can I import my heroku git repo into bitbuket? and how? \nADDITIONAL FACTS:\nssh -T [email protected]\nconq: authenticated via a deploy key.\n\nYou can use git or hg to connect to Bitbucket. Shell access is disabled.\n\n\n$ ssh -v [email protected]\nOpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011\ndebug1: Reading configuration data /Users/joel/.ssh/config\ndebug1: Applying options for bitbucket.org\ndebug1: Reading configuration data /etc/ssh_config\ndebug1: Applying options for *\ndebug1: Connecting to bitbucket.org [207.223.240.181] port 22.\ndebug1: Connection established.\ndebug1: identity file /Users/joel/.ssh/id_rsa type 1\ndebug1: identity file /Users/joel/.ssh/id_rsa-cert type -1\ndebug1: Remote protocol version 2.0, remote software version OpenSSH_5.3\ndebug1: match: OpenSSH_5.3 pat OpenSSH*\ndebug1: Enabling compatibility mode for protocol 2.0\ndebug1: Local version string SSH-2.0-OpenSSH_5.6\ndebug1: SSH2_MSG_KEXINIT sent\ndebug1: SSH2_MSG_KEXINIT received\ndebug1: kex: server->client aes128-ctr hmac-md5 none\ndebug1: kex: client->server aes128-ctr hmac-md5 none\ndebug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent\ndebug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP\ndebug1: SSH2_MSG_KEX_DH_GEX_INIT sent\ndebug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY\ndebug1: Host 'bitbucket.org' is known and matches the RSA host key.\ndebug1: Found key in /Users/joel/.ssh/known_hosts:5\ndebug1: ssh_rsa_verify: signature correct\ndebug1: SSH2_MSG_NEWKEYS sent\ndebug1: expecting SSH2_MSG_NEWKEYS\ndebug1: SSH2_MSG_NEWKEYS received\ndebug1: Roaming not allowed by server\ndebug1: SSH2_MSG_SERVICE_REQUEST sent\ndebug1: SSH2_MSG_SERVICE_ACCEPT received\ndebug1: Authentications that can continue: publickey\ndebug1: Next authentication method: publickey\ndebug1: Offering RSA public key: /Users/joel/.ssh/id_rsa\ndebug1: Remote: Forced command: conq deploykey:13907\ndebug1: Remote: Port forwarding disabled.\ndebug1: Remote: X11 forwarding disabled.\ndebug1: Remote: Agent forwarding disabled.\ndebug1: Remote: Pty allocation disabled.\ndebug1: Server accepts key: pkalg ssh-rsa blen 279\ndebug1: read PEM private key done: type RSA\ndebug1: Remote: Forced command: conq deploykey:13907\ndebug1: Remote: Port forwarding disabled.\ndebug1: Remote: X11 forwarding disabled.\ndebug1: Remote: Agent forwarding disabled.\ndebug1: Remote: Pty allocation disabled.\ndebug1: Authentication succeeded (publickey).\nAuthenticated to bitbucket.org ([207.223.240.181]:22).\ndebug1: channel 0: new [client-session]\ndebug1: Requesting [email protected]\ndebug1: Entering interactive session.\ndebug1: Sending environment.\ndebug1: Sending env LC_CTYPE = UTF-8\nPTY allocation request failed on channel 0\n\nLooks like all is fine." }, { "role": "assistant", "content": "First confusion on my side was about where exactly to set SSH Keys in BitBucket.\nI am new to BitBucket and I was setting a Deployment Key which gives read-access only.\nSo make sure you are setting your rsa pub key in your BitBucket Account Settings. \nClick your BitBucket avatar and select Bitbucket Settings(Manage account). There you'll be able to set SSH Keys.\nI simply deleted the Deployment Key, I don't need any for now. And it worked" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-commit-tree" }, { "role": "assistant", "content": "Create a new commit object" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --numstat" }, { "role": "assistant", "content": "Similar to --stat , but shows number of added and\ndeleted lines in decimal notation and pathname without\nabbreviation, to make it more machine friendly. For\nbinary files, outputs two - instead of saying 0 0 ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --ignore-blank-lines" }, { "role": "assistant", "content": "Ignore changes whose lines are all blank." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I generate a git commit log for the last month, and export it as CSV?\nIs there a way to generate a git commit log for the last month, and export it as a CSV file? I'm looking for something I can run from the command line, or a 3rd party app. I'd like the following columns: author, date of commit, subject, file edited and hash." }, { "role": "assistant", "content": "You can use the --since and --pretty option of git log, for instance:\ngit log --since=\"last month\" --pretty=format:'%h,%an,%ar,%s' > log.csv\n\nRefer to the PRETTY FORMATS section of the Git log man page for more options." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Reverting an interactive git rebase\nAfter completing a feature branch, during a git rebase -i I accidentally removed all my commits. I'm not completely sure but I suspect that instead of squashing my commits, I replaced the entire entry with a commit message.\nhttp://shafiulazam.com/gitbook/4_interactive_rebasing.html says:\n\nThe last useful thing that interactive\n rebase can do is drop commits for you.\n If instead of choosing 'pick',\n 'squash' or 'edit' for the commit\n line, you simply remove the line, it\n will remove the commit from the\n history.\n\nMy question is: is there a way to revert/undo this?" }, { "role": "assistant", "content": "If you have just done the rebase, you can try as mentioned here:\ngit reset --hard ORIG_HEAD\n\nas Jakub Narębski details:\n\nORIG_HEAD is previous state of HEAD, set by commands that have possibly dangerous behavior, to be easy to revert them.\n It is less useful now that Git has reflog: HEAD@{1} is roughly equivalent to ORIG_HEAD (HEAD@{1} is always last value of HEAD, ORIG_HEAD is last value of HEAD before dangerous operation).\n\nIf you have executed some operations since the rebase, the reflog can still help." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --no-color" }, { "role": "assistant", "content": "Turn off colored diff.\nIt is the same as --color=never ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to checkout merge request locally, and create new local branch?\n\nI have GitLab repository there and I need to test every merge request locally, before merging to the target branch. \nHow can I pull/fetch merge request as a new branch?" }, { "role": "assistant", "content": "Pull merge request to new branch \ngit fetch origin merge-requests/REQUESTID/head:BRANCHNAME\ni.e \ngit fetch origin merge-requests/10/head:file_upload\nCheckout to newly created branch\ngit checkout BRANCHNAME\ni.e (git checkout file_upload)\n\nOR with single command \ngit fetch origin merge-requests/REQUESTID/head:BRANCHNAME && git checkout BRANCHNAME\ni.e \ngit fetch origin merge-requests/18/head:file_upload && git checkout file_upload" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-blame - Show what revision and author last modified each line of a file --line-porcelain" }, { "role": "assistant", "content": "Show the porcelain format, but output commit information for\neach line, not just the first time a commit is referenced.\nImplies --porcelain." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I check out a remote Git branch?\nSomebody pushed a branch called test with git push origin test to a shared repository. I can see the branch with git branch -r. How do I check out the remote test branch? I've tried:\n\ngit checkout test, which does nothing\ngit checkout origin/test gives * (no branch)" }, { "role": "assistant", "content": "The answer has been split depending on whether there is one remote repository configured or multiple. The reason for this is that for the single remote case, some of the commands can be simplified as there is less ambiguity.\nUpdated for Git 2.23: For older versions, see the section at the end.\nWith One Remote\nIn both cases, start by fetching from the remote repository to make sure you have all the latest changes downloaded.\n$ git fetch\n\nThis will fetch all of the remote branches for you. You can see the branches available for checkout with:\n$ git branch -v -a\n\n...\nremotes/origin/test\n\nThe branches that start with remotes/* can be thought of as read only copies of the remote branches. To work on a branch you need to create a local branch from it. This is done with the Git command switch (since Git 2.23) by giving it the name of the remote branch (minus the remote name):\n$ git switch test\n\nIn this case Git is guessing (can be disabled with --no-guess) that you are trying to checkout and track the remote branch with the same name.\nWith Multiple Remotes\nIn the case where multiple remote repositories exist, the remote repository needs to be explicitly named.\nAs before, start by fetching the latest remote changes:\n$ git fetch origin\n\nThis will fetch all of the remote branches for you. You can see the branches available for checkout with:\n$ git branch -v -a\n\nWith the remote branches in hand, you now need to check out the branch you are interested in with -c to create a new local branch:\n$ git switch -c test origin/test\n\nFor more information about using git switch:\n$ man git-switch\n\nPrior to Git 2.23\ngit switch was added in Git 2.23, prior to this git checkout was used to switch branches.\nTo checkout out with only a single remote repository:\ngit checkout test\n\nif there are multiple remote repositories configured then it becomes a bit longer\ngit checkout -b test <name of remote>/test" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-citool" }, { "role": "assistant", "content": "Graphical alternative to git-commit" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Connecting to GitLab repositories on Android Studio\n\nI'm trying to connect to a GitLab repository using the I/O preview of Android Studio. Does anyone know how to do this/if it is possible yet?" }, { "role": "assistant", "content": "How to add an Android Studio project to GitLab\nThis answer shows how to do it using the Android Studio GUI.\n1. Create a new project on GitLab\nChose the + button on the menu bar. Add a project name and then click \"Create project\".\n\nThis will give you a new project address. Choose the https version.\n\nIt will look something like this:\nhttps://gitlab.com/MyUserName/my-project.git\n\n2. Create a Git repository in Android Studio\nIn the Android Studio menu go to VCS > Import into Version Control > Create Git Repository...\n\nSelect the root directory of your project. (It will be automatically selected if you already have it highlighted in the Project view. Otherwise you will have to browse up to find it.)\n3. Add remote\nGo to VCS > Git > Remotes.... Then paste in the https address you got from GitLab in step one.\n\nYou may need to log in with your GitLab username and password.\n4. Add, commit, and push your files\nMake sure you have the top level of the project selected. If you are in the Android view you can switch it to the Project view.\n\n\nAdd: Go to VCS > Git > Add.\nCommit: After adding, do VCS > Git > Commit Directory. (You will need to write a commit message, something like initial commit.)\nPush: Finally, go to VCS > Git > Push.\n\nFinished!\nYou should be able to view your files in GitLab now.\nSee also\nThere is a plugin that would probably streamline the process. Check it out here." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Undo git rm -r --cached\nMy .gitignore file wasn't working, so I followed this question.\nAnd now I have bunch of files that I need to commit, in order to proceed.\nI made a mistake and committed those, because I couldn't find a way to get rid of those. \nIs there any way that I can revert all these actions? I can't do reset cause I now I get error:\nerror: The following untracked working tree files would be overwritten by checkout.\nStupid stupid mistake, and I can find solution for this." }, { "role": "assistant", "content": "If you've run only git rm -r --cached, try doing a git reset HEAD . from within your repo root.\nIf you did a git commit -m \"msg\" after doing a git rm -r --cached, i.e., you committed the changes, then do git reset HEAD~1 to undo your last commit." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch --show-forced-updates" }, { "role": "assistant", "content": "By default, git checks if a branch is force-updated during\nfetch. This can be disabled through fetch.showForcedUpdates, but\nthe --show-forced-updates option guarantees this check occurs.\nSee git-config ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --color-moved[=<mode>]" }, { "role": "assistant", "content": "Moved lines of code are colored differently.\nThe <mode> defaults to no if the option is not given\nand to zebra if the option with no mode is given.\nThe mode must be one of: no Moved lines are not highlighted. default Is a synonym for zebra . This may change to a more sensible mode\nin the future. plain Any line that is added in one location and was removed\nin another location will be colored with color.diff.newMoved .\nSimilarly color.diff.oldMoved will be used for removed lines\nthat are added somewhere else in the diff. This mode picks up any\nmoved line, but it is not very useful in a review to determine\nif a block of code was moved without permutation. blocks Blocks of moved text of at least 20 alphanumeric characters\nare detected greedily. The detected blocks are\npainted using either the color.diff.{old,new}Moved color.\nAdjacent blocks cannot be told apart. zebra Blocks of moved text are detected as in blocks mode. The blocks\nare painted using either the color.diff.{old,new}Moved color or color.diff.{old,new}MovedAlternative . The change between\nthe two colors indicates that a new block was detected. dimmed-zebra Similar to zebra , but additional dimming of uninteresting parts\nof moved code is performed. The bordering lines of two adjacent\nblocks are considered interesting, the rest is uninteresting. dimmed_zebra is a deprecated synonym." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Pull remote branch into local repo with different name?\nAlright I did a little bit of research on this but I couldn't find an exact answer, so I have to ask.\nI have 2 remotes: origin and repo2.\nI'd like to do something like\ngit pull repo2 master\n\nBut this would pull the master branch of the repo2 into my master. Can I specify a different branch to pull into, for my local branch ?" }, { "role": "assistant", "content": "git checkout -b myBranchName repo2/master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "(Mac) -bash: __git_ps1: command not found\nI'm trying to change my command promt in terminal. I keep getting the error:\n-bash: __git_ps1: command not found\nI've tried it just by typing it into the terminal as is: __git_ps1. I've also tried it out in the .bash_profile\nif [ -f ~/.git-completion.bash ]; then\n source ~/.git-completion.bash\n export PS1='[\\W]$(__git_ps1 \"(%s)\"): '\nfi\n\nAs you might be able to see/tell, yes, I do have the auto-completion installed and it does work great!\nI came across this question: \" PS1 env variable does not work on mac \" which gives the code\nalias __git_ps1=\"git branch 2>/dev/null | grep '*' | sed 's/* \\(.*\\)/(\\1)/'\"\nSo I add it to my .bash_profile hoping that it will change something. Well, it did. It just changed the error output.\nHere's the .bash_profile with the addition:\nalias __git_ps1=\"git branch 2>/dev/null | grep '*' | sed 's/* \\(.*\\)/(\\1)/'\"\n\nif [ -f ~/.git-completion.bash ]; then\n source ~/.git-completion.bash\n export PS1='[\\W]$(__git_ps1 \"(%s)\"): '\nfi\n\nAnd now here's the changed error output:\nsed: (%s): No such file or directory\nNote: I've also moved the alias below the source with no difference. I have git version 1.7.12.1\nThis should be a simple change. Can someone please help me?\nEdit 10/13/12\nNo, I definitely do not want to define __git_ps1 myself but was just trying to see if it would be recognized by doing so. Yes, I have the .git-completion.bash file installed. Here's how I got auto completion on my machine.\ncd ~\ncurl -OL https://github.com/git/git/raw/master/contrib/completion/git-completion.bash\nmv ~/git.completion.bash ~/.git-completion.bash\n\nA ls -la then lists the .git-completion.bash file." }, { "role": "assistant", "content": "You've installed the version of git-completion.bash from master - in git's development history this is after a commit that split out the __git_ps1 function from the completion functionality into a new file (git-prompt.sh). The commit that introduced this change, which explains the rationale, is af31a456.\nI would still suggest that you just source the version of git-completion.bash (or git-prompt.sh) that is bundled with your installation of git.\nHowever, if for some reason you still want to use this functionality by using scripts separately downloaded from master, you should download git-prompt.sh similarly:\ncurl -o ~/.git-prompt.sh \\\n https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh\n\n... and add the following line to your ~/.bash_profile:\nsource ~/.git-prompt.sh\n\nThen your PS1 variable that includes __git_ps1 '%s' should work fine.\nGeoff reported 10/13/12 adding the following to their .bash_profile worked while others did not:\nif [ -f ~/.git-prompt.sh ]; then\n source ~/.git-prompt.sh\n export PS1='Geoff[\\W]$(__git_ps1 \"(%s)\"): '\nfi" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git and nasty \"error: cannot lock existing info/refs fatal\"\nAfter cloning from remote git repository (at bettercodes)\nI made some changes, commited\nand tried to push:\ngit push origin master\n\nErrors with:\n\nerror: cannot lock existing info/refs\nfatal: git-http-push failed\n\nThis case regards already existing repository.\nWhat I did before, was:\n\ngit config --global http.sslVerify false\ngit init\ngit remote add [url]\ngit clone\nchange data\ngit commit\n\nAt 'bettercodes' I have no access to git log.\nI'm using Windows.\nThe detailed error was:\nC:\\MyWorkStuff\\Projects\\Ruby\\MyProject\\>git push origin master\nUnable to create branch path https://user:[email protected]/myproject/info/\nerror: cannot lock existing info/refs\nfatal: git-http-push failed\n\nI cloned before, then changed the code and committed." }, { "role": "assistant", "content": "For me this worked (won't change in remote):\ngit remote prune origin\nSince this answer seems to help a lot of people, I dug a little bit into what actually happens here. What this will do is remove references to remote branches in the folder .git/refs/remotes/origin.\nSo this will not affect your local branches and it will not change anything remote, but it will update the local references you have to remote branches. It seems in some cases these references can contain data Git cannot handle correctly." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Merge changes from remote github repository to your local repository\nI have forked a repository on github some time ago, made a small change and pushed the change back to my github fork. The original repository has changed since. I would like to merge the changes from the original repository to my fork.\nI am new to both git and github, and I need specific commands how to do it." }, { "role": "assistant", "content": "git remote add {name} {Public Clone URL}\ngit pull {name} master\ngit push\n\nExample:\ngit remote add bret git://github.com/bret/watir.git\ngit pull bret master\ngit push" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is GIT_WORK_TREE, why have I never needed to set this ENV var, why now?\nI'm using Git under Ubuntu Linux to sync and deploy my projects.\nI have a Repo on my local Linux working machine and two repos on my server, one bare repo and the one as a deployed app.\nIt always worked fine, but now I've created another repo for my other website I get this error:\nroot@vserver5:/var/www/ninethsky# git pull origin master\nfatal: /usr/lib/git-core/git-pull cannot be used without a working tree.\n\nSo I have to set a GIT_WORKING_TREE ENV-Var, but what is this exactly, where to set it?\nThis is my repo's .git/config:\n[core]\n repositoryformatversion = 0\n filemode = true\n bare = false\n logallrefupdates = true\n[remote \"origin\"]\n url = /home/git/ninethsky/.git\n fetch = +refs/heads/*:refs/remotes/origin/*\n\nThere is another repo with bare = true and a repo on my local working machine.\nThen I removed all the repos but the initial one, and now I get:\nroot@vserver5:/var/www/ninethsky# git init\nfatal: GIT_WORK_TREE (or --work-tree=<directory>) not allowed without specifying GIT_DIR (or --git-dir=<directory>)\nroot@vserver5:/var/www/ninethsky# git init --git-dir=/var/www/ninethsky\nerror: unknown option `git-dir=/var/www/ninethsky'\n\nI solved the git init problem by unsetting GIT_WORK_TREE, which was set to blank.\nGIT_WORK_TREE and GIT_DIR are unset. git init works again, still there is a problem with git add . and so on when it comes to git actions in the cloned repo, which was set to bare.\nThanks,\nJoern." }, { "role": "assistant", "content": "If you have a non-bare git repository, there are two parts to it:\n\nthe working tree.\nThe working tree has your checked out source code, with any changes you might have made.\n\nthe git directory.\nThe git directory is normally called .git, and is in the top level of your working tree - this contains all the history of your project, configuration settings, pointers to branches, the index (staging area) and so on.\nYour git directory is the one that contains files and directories that look like a bit like this:\nbranches description HEAD index logs ORIG_HEAD refs config FETCH_HEAD hooks info objects packed-refs\n\n\n\nWhile what I've described above is the default layout of a git repository, you can actually set any directories in the filesystem to be your git directory and working tree.\nYou can change these directories from their defaults\n\neither with the --work-tree and --git-dir options to git\nor by using the GIT_DIR and GIT_WORK_TREE environment variables. Usually, however, you shouldn't need to set these.\n\n\nThe error that you see is from one of the first checks that git pull does - it must be run from a working tree. I assume that this is due to you having set the GIT_DIR or GIT_WORK_TREE environment variables.\nOtherwise, my best guess is that your .git directory is not accessible or corrupted in some way.\n\nIf you list the contents of /var/www/ninethsky/.git, does it look like the listing I quoted above?\nAre all of those files and directories readable and writable by the user you're running the command as, or might they have had their permissions changed?\n\n\nUpdate: In answer to the points in the additional information you updated your question with:\n\ngit init presumably fails because you still have the GIT_WORK_TREE environment variable set, and, as the error message says, if you're specifying the work tree, you also have to specify the git directory.\nThe second variant (git init --git-dir=/var/www/ninethsky) fails because the --git-dir should come before the init.\n\nHowever, in this situation, you don't need to specify the work tree at all 1, so I would make sure that you unset the GIT_WORK_TREE and GIT_DIR environment variables.\n1 That said, it could be considered a bad idea to keep your .git directory under /var/www in case you accidentally set the permissions such that it is web accessible.\nSo this might be an instance where you want to keep the git directory elsewhere.\nHowever, since these options are clearly already causing confusion for you, perhaps it's better to keep the git part simple and deny access to the .git directory with other means." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": ".gitignore after commit [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\n\nHow do I make Git forget about a file that was tracked, but is now in .gitignore?\n\n (35 answers)\n \n\nClosed 3 years ago.\n\n\n\nI have a git repository hosted on Github. After committing many files, I am realizing that I need to create .gitignore and exclude .exe, .obj files.\nHowever, will it automatically remove these committed files from the repository? Is there any way to force that?" }, { "role": "assistant", "content": "No you cannot force a file that is already committed in the repo to be removed just because it is added to the .gitignore \nYou have to git rm --cached to remove the files that you don't want in the repo. ( --cached since you probably want to keep the local copy but remove from the repo. ) So if you want to remove all the exe's from your repo do\ngit rm --cached /\\*.exe\n\n(Note that the asterisk * is quoted from the shell - this lets git, and not the shell, expand the pathnames of files and subdirectories)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why can't I go to sign in page to Gitlab.com from Browser?\n\nI went to about.gitlab.com. from there I clicked on sign in. The browser keeps showing: \"Checking your browser before accessing gitlab.com.\". This has been going on for 10 hours. I have Already tried clearing my cookies and restarting my pc. This did not yield any result. My firewall is turned off so it isn't a firewall issue." }, { "role": "assistant", "content": "This is so extremely frustrating and makes me want to move everything back from GitLab to GitHub.\nIn my case, the addon that GitLab (actually cloudflare) didn't like was the Chameleon (Random Agent Spoofer) plugin, which I use to prevent tracking/fingerprinting across websites.\n\nhttps://addons.mozilla.org/en-US/firefox/addon/chameleon-ext/\n\nThanks Cloudflare for depending on fingerprinting and effectively issuing a DOS attack on GitLab customers that use tools to protect themselves." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the difference between Git Bash and the GitHub for Windows shell?\nI'm referring to the shell that comes with GitHub for Windows (Github CLI), and Git Bash (which has a stand alone installer)." }, { "role": "assistant", "content": "Well, for one thing, the default shell that comes with GitHub for Windows is PoshGit, which is a Windows Power Shell environment for Git. On the other hand, Git Bash/msysGit uses the Bash shell (Bourne Again Shell) and MinGW, which is a port of a Linux style environment and command line tools.\nPoshGit will let you use Windows and Power Shell commands with Git at the command line, while Git Bash will let you use MinGW/Linux tools with Git at the command line." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can't ignore .suo file\nI'm trying to work using Git with a colleague, in an application written in C#.\nWe have added the entry \"project1.suo\" to the .gitignore file but every time one of us has to commit the project, Git seems to tell us to commit the file \"project1.suo\" as well.\nWe have tried many methods to add the file in .gitignore like that:\n*.suo\nproject1.suo\nc:\\project\\project1.suo\n\nHow can we ignore the SUO file during the commit?" }, { "role": "assistant", "content": "git doesn't ignore files that have been added to the repository. If you want to get it ignored, you have to delete the file from the repository:\ngit rm --cached project1.suo\ngit commit -m \"Delete suo file from repository\"\n\nThis will delete the file from the repository, while it's still on your harddrive." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Reverting part of a commit with git\nI want to revert a particular commit in git. Unfortunately, our organization still uses CVS as a standard, so when I commit back to CVS multiple git commits are rolled into one. In this case I would love to single out the original git commit, but that is impossible.\nIs there an approach similar to git add --patch that would allow me to selectively edit diffs to decide which parts of a commit to revert?" }, { "role": "assistant", "content": "Use the --no-commit (-n) option to git revert, then unstage the changes, then use git add --patch:\n$ git revert -n $bad_commit # Revert the commit, but don't commit the changes\n$ git reset HEAD . # Unstage the changes\n$ git add --patch . # Add whatever changes you want\n$ git commit # Commit those changes\n\nNote: The files you add using git add --patch are the files you want to revert, not the files you want to keep." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-daemon - A really simple server for Git repositories --access-hook=<path>" }, { "role": "assistant", "content": "Every time a client connects, first run an external command\nspecified by the <path> with service name (e.g. \"upload-pack\"),\npath to the repository, hostname (%H), canonical hostname\n(%CH), IP address (%IP), and TCP port (%P) as its command-line\narguments. The external command can decide to decline the\nservice by exiting with a non-zero status (or to allow it by\nexiting with a zero status). It can also look at the $REMOTE_ADDR\nand $REMOTE_PORT environment variables to learn about the\nrequestor when making this decision. The external command can optionally write a single line to its\nstandard output to be sent to the requestor as an error message when\nit declines the service." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository fetch.writeCommitGraph" }, { "role": "assistant", "content": "Set to true to write a commit-graph after every git fetch command\nthat downloads a pack-file from a remote. Using the --split option,\nmost executions will create a very small commit-graph file on top of\nthe existing commit-graph file(s). Occasionally, these files will\nmerge and the write may take longer. Having an updated commit-graph\nfile helps performance of many Git commands, including git merge-base , git push -f , and git log --graph . Defaults to false." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Piping output from Git Bash to clipboard\nI often need to relay my Git output to others. The best way I know how is by doing this:\nRight-click Git Bash title bar > Edit > Mark > Select lines > Enter\n\nNow everything I selected is in my clipboard. But I'd like to do it on the command line.\nIn Windows, you can pipe console output to your clipboard like so:\nC:\\> dir | clip\n\nBut when you try to do that in Git Bash, here's what happens:\n> git branch | clip\nsh.exe\": clip: command not found\n\nIs there a way to pipe Git Bash output to my clipboard in Windows?" }, { "role": "assistant", "content": "Well, actualy git branch | clip works fine for me. clip command just calls clip.exe from C:\\Windows\\System32\\. Make sure you have clip.exe installed somewhere in your PATH." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Should server/database config files, including passwords, be stored in source control?\nI'm looking to hear some best practices...\nAssuming a web application that interacts with a few different production servers (databases, etc.)... should the configuration files that include database passwords be stored in source control (e.g., git, svn)?\nIf not, what's the best way to keep track of server database (or other related) passwords that your application needs access to?\nEdit: added a bounty to encourage more discussion and to hear what more people consider best practice." }, { "role": "assistant", "content": "There's no single \"silver bullet\" answer here and it would all greatly depend on details.\nFirst of all, I consider best practice to separate all source code from configuration in separate repository. So, source code remains source code, but it's installation or deployment (with configuration, passwords, etc) is the whole other thing. This way you'll firmly separate developers' tasks from sysadmins' tasks and can ultimately build 2 distinct teams doing what's they're good at.\nWhen you have separate source code repository + deployment repository, your best next bet is considering deployment options. Best way I see here is using deployment procedures typical for a chosen OS (i.e. building autonomous packages for a chosen OS the way that OS's maintainers do).\nFor example, Red Hat or Debian packaging procedures usually mean grabbing a tarball of software from external site (that would be exporting sources from your source code VCS), unpacking it, compiling and preparing packages ready for deployment. Deployment itself should ideally mean just doing a quick & simple command that would install the packages, such as rpm -U package.rpm, dpkg --install package.deb or apt-get dist-upgrade (given that your built packages go to a repository where apt-get would be able to find them).\nObviously, to get it working this way, you'll have to supply all configuration files for all components of a system in a fully working state, including all addresses and credentials.\nTo get more concise, let's consider a typical \"small service\" situation: one PHP application deployed across n application servers running apache / mod_php, accessing m MySQL servers. All these servers (or virtual containers, that doesn't really matter) reside in a protected private network. To make this example easier, let's assume that all real internet connectivity is fronted by a cluster of k http accelerators / reverse proxies (such as nginx / lighttpd / apache) which have very easy configuration (just internal IPs to forward to).\nWhat do we have for them to be connected and fully working?\n\nMySQL servers: set up IPs/hostnames, set up databases, provide logins & passwords\nPHP application: set up IPs/hostnames, create configuration file that will mention MySQL servers IPs, logins, passwords & databases\n\nNote that there are 2 different \"types\" of information here: IPs/hostnames is something fixed, you'd likely want to assign them once and for all. Logins & passwords (and even database names), on the other hand, are purely for connectivity purposes here - to make sure for MySQL that it's really our PHP application connecting to it. So, my recommendations here would be splitting these 2 \"types\":\n\n\"Permanent\" information, such as IPs, should be stored in some VCS (different from source code VCS)\n\"Transient\" information, such as passwords between 2 applications, should be never stored, but generated during generation of deployment packages.\n\nThe last and the toughest question remains here: how to create deployment packages? There are multiple techniques available, 2 main ways are:\n\nExported source code from VCS1 + \"permanent\" configuration from VCS2 + building script from VCS3 = packages\nSource code is in VCS1; VCS2 is a distributed version control (like git or hg) which essentially contains \"forks\" of VCS1 + configuration information + building scripts which can generate . I personally like this approach better, it's much shorter and ultimately easier to use, but learning curve may be a bit steeper, especially for admin guys who'll have to master git or hg for it.\n\nFor an example above, I'd create packages like:\n\nmy-application-php - which would depend on mod_php, apache and would include generated file like /etc/my-php-application/config.inc.php that will include MySQL database IPs/hostnames and login / password generated as md5(current source code revision + salt). This package would be installed on every of n application servers. Ideally, it should be able install on a cleanly installed OS and make a fully working application cluster node without any manual activity.\nmy-application-mysql - which would depend on MySQL-server and would include post-install script that:\n\nstarts MySQL server and makes sure it will start automatically on OS start\nconnects to MySQL server\nchecks if required database exists\nif no - creates the database, bootstraps it with contents and creates login with password (the same logins & passwords as generated in /etc/my-php-application/config.inc.php, using md5 algorithm)\nif yes - connects to the database, applies migrations to bring it up to the new version, kills all older logins / passwords and recreates the new login/password pair (again, generated using md5(revision + salt) method)\n\n\nUltimately, it should bring the benefit of upgrading your deployment using single command like generate-packages && ssh-all apt-get dist-upgrade. Also, you do not store inter-applications passwords anywhere and they get regenerated on every update.\nThis fairly simple example illustrates a lot of methods you can employ here - but, ultimately, it's up to you to decide which solution is better here and which one is overkill. If you'll put more details here or as a separate question, I'll gladly try to get into details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-interpret-trailers" }, { "role": "assistant", "content": "Add or parse structured information in commit messages" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options http.noEPSV" }, { "role": "assistant", "content": "A boolean which disables using of EPSV ftp command by curl.\nThis can be helpful with some \"poor\" ftp servers which don’t\nsupport EPSV mode. Can be overridden by the GIT_CURL_FTP_NO_EPSV environment variable. Default is false (curl will use EPSV)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub access token with read-only access to private repositories\nI have a project with a Node dependency on a private Git repository. I need to be able to run npm install without being prompted to enter a password or allow an SSH connection, so I'm using an access token that I created on GitHub in my package.json:\n \"dependencies\": {\n \"sass-theme\": \"git+https://[token]:[email protected]/MyOrg/sass-theme.git#v1.0.2\",\n \"node-sass\": \"^4.5.0\"\n }\n\nThis project is shared with dozens of other people, so obviously I don't want to keep my token in source control. I know I can create a read-only deployment key on GitHub, but I believe that would require other developers to import the SSH key to build the project locally.\nIs it possible to create an access token that can be shared but that has read-only access to clone the repository?" }, { "role": "assistant", "content": "The most straightforward way I can think of to create a token that provides read-only access to a private repo is to:\n\nHave a user who has read-only access to the given private repo\n(and ideally, not much else)\nAs that user create a Personal Access Token with the \"repo\" scope\n\nIt would be best if they didn't have access to other orgs/repos, since the \"repo\" scope grants the user total control over any repos that user has write access to.\nI know in an Enterprise solution we would do that with a System ID, but on GitHub you can instead create a Machine User." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Ignore .classpath and .project from Git\nI keep myself telling me and others not to commit .classpath and\n .project files and use Maven.\n\nSomehow, Junior developers always ignore certain rules and commits those files and it's much better to have such files for newbies who can jump and start using the code.\nNow from myside, I would like to try/do something. When I clone the repo, I will get .classpath and .project files and certainly they get modified in my system. \n\nBut I want them not to be committed and should always be ignored while\n synchronizing with Git. So that my changes in local system doesn't\n mess up with Git and Git changes of those files doesn't mess up my\n local files.\n\nHow do I achieve this? Anyway to mark those files to be ignored in such a way?" }, { "role": "assistant", "content": "If the .project and .classpath are already committed, then they need to be removed from the index (but not the disk)\ngit rm --cached .project\ngit rm --cached .classpath\n\nThen the .gitignore would work (and that file can be added and shared through clones).\nFor instance, this gitignore.io/api/eclipse file will then work, which does include:\n# Eclipse Core \n.project\n\n# JDT-specific (Eclipse Java Development Tools) \n.classpath\n\nNote that you could use a \"Template Directory\" when cloning (make sure your users have an environment variable $GIT_TEMPLATE_DIR set to a shared folder accessible by all).\nThat template folder can contain an info/exclude file, with ignore rules that you want enforced for all repos, including the new ones (git init) that any user would use.\n\nAs commented by Abdollah\n\nWhen you change the index, you need to commit the change and push it.\n Then the file is removed from the repository. So the newbies cannot checkout the files .classpath and .project from the repo." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-blame - Show what revision and author last modified each line of a file -f --show-name" }, { "role": "assistant", "content": "Show the filename in the original commit. By default\nthe filename is shown if there is any line that came from a\nfile with a different name, due to rename detection." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do you remove a specific revision in the git history?\nSuppose your git history looks like this:\n1\n2\n3\n4\n5\n1–5 are separate revisions. You need to remove 3 while still keeping 1, 2, 4 and 5. How can this be done?\nIs there an efficient method when there are hundreds of revisions after the one to be deleted?" }, { "role": "assistant", "content": "Per this comment (and I checked that this is true), rado's answer is very close but leaves git in a detached head state. Instead, remove HEAD and use this to remove <commit-id> from the branch you're on:\ngit rebase --onto <commit-id>^ <commit-id>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to update my working Git branch from another branch (develop)?\nI made a new branch called feature1 from the main develop branch a month ago.\n⇒ git branch \n develop\n* feature1\n\nI've been working on feature1 for a month now and a lot of changes have been pushed to develop.\nHow can I update my current branch feature1 with the latest commits from develop?\nI DO NOT want to checkout master and merge my feature1 branch into it. Neither do I want to use git cherry-pick to manually move commits from develop to feature1.\nHow would I go about doing this?" }, { "role": "assistant", "content": "You just merge develop to feature1:\ngit checkout feature1\ngit merge develop\n\nThere is no need to involve another branch such as master." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Add GitLab Web hook for all projects in group\n\nI would like all my projects in a GitLab group to have shared configuration for a webhook:\n<MY_JENKINS_INSTANCE>/git/notifyCommit?url=$CHANGED_REPOSITORY\n\nGitLab webhook documentation suggests it should be possible:\n\nIf you have a big set of projects in the one group then it will be convenient for you to configure web hooks globally for the whole group. You can add the group level web hooks on the group settings page.\n\nThat sound exactly like what I am after though I see no such thing on group settings page in my gitlab 7.0.0. I was not able to find out if this feature is not newer than that in the changelog.\nDoes the feature exist? How do I use it?" }, { "role": "assistant", "content": "That's possible in the enterprise version only:\n\nIn GitLab Enterprise Edition you can configure web hooks globally for the whole group. You can add the group level web hooks on the group settings page Settings > Web Hooks." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary tree" }, { "role": "assistant", "content": "Either a working tree , or a tree\nobject together with the dependent blob and tree objects\n(i.e. a stored representation of a working tree)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %GF" }, { "role": "assistant", "content": "show the fingerprint of the key used to sign a signed commit" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-apply - Apply a patch to files and/or to the index --numstat" }, { "role": "assistant", "content": "Similar to --stat , but shows the number of added and\ndeleted lines in decimal notation and the pathname without\nabbreviation, to make it more machine friendly. For\nbinary files, outputs two - instead of saying 0 0 . Turns off \"apply\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Removing missing LFS objects from git repository\n\nI am missing a bunch of LFS objects in my git repository*, both on the clients and the server. I am aware that those objects are lost and that's okay. Unfortunately this means that git lfs fetch --all or even git lfs push --all origin will fail.\nI would like to purge the \"broken pointers\" from the repository, either by replacing the binary with a dummy text file or by removing the pointer altogether. I am also aware that this involves rewriting history and that's also fine.\nWhat would be the best way to proceed?\n*To clarify, I am missing some LFS files on the server but not all of them and not for all revisions of those files.\nFor example, I have foo.png that has been modified in 3 commits:\n\nfoo.png (Version 1, LFS Sha: 03cfd743)\nfoo.png (Version 2, LFS Sha: 661f0797)\nfoo.png (Version 3, LFS Sha: 5fa2f122)\n\nThe LFS server no longer has foo.png version 2, so I would like to remove that commit from history. Unfortunately git lfs does not tell me which commit is broken, it simply tells me that 661f0797 is missing.\n(For the record, I have found the missing files so I no longer have this issue but the solution should still be interesting!)" }, { "role": "assistant", "content": "This script worked for me - it removes all blobs that look like LFS files.\ngit filter-repo --force --blob-callback \"\nif blob.data.split(b'\\n', 1)[0] == b'version https://git-lfs.github.com/spec/v1':\n blob.skip()\n\"\n\nExplanation:\n\ngit filter-repo rewrites git history\n--force is needed to skip safety checks\nif blob.data.split(b'\\n', 1)[0] == b'version https://git-lfs.github.com/spec/v1': blob.skip()\nThis script checks if the first line of the file contains an LFS signature and skips adding this file in such a case." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to add missing origin/HEAD in git repo\nI have a working git repo. However, I miss the remotes/origin/HEAD -> origin/master when typing git branch -a. Why is the HEAD missing and how can I add the missing HEAD to my repo?" }, { "role": "assistant", "content": "Original Answer:\nThe origin's HEAD is only fetched when you clone the repo. If you otherwise add the remote (e.g. by using git remote add or by renaming another existing remote), this ref will not exist, because there is not reason to have it.\nRemote repos should be bare repos in most cases, and in bare repos HEAD merely points to the \"default\" branch. This is only relevant at one time: when cloning. Therefore, after cloning, any remote HEADs are no longer important to your clone and Git will not fetch that ref from any remote.\n\nAs user lesmana requested, I looked into this again to find some more information:\n\"How to remove origin/HEAD?\"\nYou do not have to do this.\nThe ref has no influence on the way your repo operates, and a ref is literally just a small text file on your file system, so it takes up nearly no space (just a few bytes).\nIf you still want to remove it, you can use\ngit update-ref -d refs/remotes/origin/HEAD\n\n(if you want to remove a remote HEAD that is not on origin, use the respective remote's name instead).\n\"How to create origin/HEAD?\"\nAs pointed out earlier, a remote HEAD ref is only used for cloning, and never required by Git at a later time. Unless you manually use it (which does not seem very useful, you can just use the branch it points to), there is no reason to manually create it.\nNevertheless, if you absolutely must, you can use\ngit symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/master\n\n\"Why is a remote HEAD not removed automatically by clone if it really is useless?\"\nThere is no specific reason, from what I can tell, other than maybe inform the user explicitly of which branch is considered the default branch in the cloned remote repo. However, as I mentioned above, its existence causes no problems and uses up almost no space, so there is no real reason to remove it.\nFor more details, feel free to ask the Git devs directly at the Git mailing list :)\n\"What is the exact reason why clone needs it?\"\nNone of the man pages explain directly that git clone always uses this, but it finds sidelong mentions in some places.\nFor example, man git clone says:\n\n--branch <name>\n-b <name>\nInstead of pointing the newly created HEAD to the branch pointed to by the cloned repository’s HEAD, point to <name> branch instead. [...]\n\nand\n\n--[no-]single-branch\nClone only the history leading to the tip of a single branch, either specified by the --branch option or the primary branch remote’s HEAD points at. [...]\n\nFurthermore, man gitrepository-layout says:\n\nHEAD\n[...] It does not mean much if the repository is not associated with any working tree (i.e. a bare repository), but a valid Git repository must have the HEAD file; some porcelains may use it to guess the designated \"default\" branch of the repository (usually master).\n\nThis means that\n\na) the remote repo itself must have the HEAD ref (to be valid), even though it is not semantically important (other than to point out the default branch)\nb) git clone uses the remote repo's HEAD ref to determine where to point the local HEAD (unless you specify an override with --branch). To work with that ref, it must locally create it (therefore origin/HEAD). As mentioned above, it is then simply not deleted." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-mv - Move or rename a file, a directory, or a symlink" }, { "role": "assistant", "content": "NAME git-mv - Move or rename a file, a directory, or a symlink" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Visual studio 2017 with bitbucket, terminal prompts disabled\nThe visual studio stopped sending my commits to the bitbucket and this error appears \n\nError encountered while cloning the remote repository: Git failed with a fatal error.\n HttpRequestException encountered.\n There was an error submitting the request.\n can not spawn \nC / Program Files (x86) / Microsoft Visual Studio / 2017 / Community /\n Common7 / IDE / CommonExtensions / Microsoft / TeamFoundation / Team\n Explorer / Git / mingw32 / libexec / git-core / git-askpass.exe: No\n such file or directory\ncould not read Password for 'https: //[email protected]': terminal prompts disabled\n The error occurs when I try to clone my repository or commit" }, { "role": "assistant", "content": "I had the same issue, I found an answer that worked for me here:\nhttps://github.com/github/VisualStudio/issues/949\nBelow are the steps mentioned to fix:\nIt seems that the bundled Git-Credential-Manager-for-Windows/ in VIsual Studio 2017 is not the latest release. Downloading the latest release and putting it on top of the files in Visual Studio 2017 worked for me.\n\ndownload the zip file gcmw-v1.17.0.zip from https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/tag/v1.17.0\nnavigate to C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\Git\\mingw32\\libexec\\ (or wherever your 'missing' git-askpass.exe resides).\nmake a copy of the git-core folder and rename it backup or something like that\nput the files from the zip file on top of the contents of your new git-core folder and overwrite where prompted" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-checkout - Switch branches or restore working tree files -p --patch" }, { "role": "assistant", "content": "Interactively select hunks in the difference between the <tree-ish> (or the index, if unspecified) and the working\ntree. The chosen hunks are then applied in reverse to the\nworking tree (and if a <tree-ish> was specified, the index). This means that you can use git checkout -p to selectively discard\nedits from your current working tree. See the “Interactive Mode”\nsection of git-add to learn how to operate the --patch mode. Note that this option uses the no overlay mode by default (see also --overlay ), and currently doesn’t support overlay mode." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to do \"go get\" on a specific tag of a github repository\n\nI am trying to compile the InfluxDB database (version v0.8.8) using go get github.com/influxdb/influxdb\nBut this pulls the master branch, and I need the v0.8.8 tag.\nI have tried to do: go get github.com/influxdb/influxdb/releases/tag/v0.8.8 but this fails saying unable to find.\nI also tried to do a regular go get of the master branch, and then manually checking out the tag using git in GOPATH/src/github... in order to set the corret version.\nThe problem using the last approach is that when I try to pull the dependencies with go get -u -f ./... it tries to find them in the master branch, and some of them do not exist on the master branch...\nTL;DR: perform go get on a specific github tag, and pull the correct dependencies." }, { "role": "assistant", "content": "It is not possible using the go get tool. Instead you need to use a third party go package management tool or create your own forks for the packages that you wish to manage more fine grained.\nSpoke to a guy that works at Google and he acknowledged this problem/requirement, he said that vendoring which his team used was bulky and they will probably solve it with the official tools soon.\nRead more:\n\nReference of third party package management tools\nBlog post by golang team discussing the approach for implementing vendoring\n\nVendoring in Go 1.6\nVendoring has been released from experimental in go 1.6 (after this post was initially written) that makes the process of using specific tags / versions of packages using third party tools easier. go get does still not have the functionality to fetch specific tags or versions.\nMore about how vendoring works: Understanding and using the vendor folder\nModules in Go 1.11\nGo 1.11 has released an experimental features called modules to improve dependency management, they hope to release it as stable in Go 1.12: Information about modules in Go 1.11" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %cl" }, { "role": "assistant", "content": "committer email local-part (the part before the @ sign)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-difftool" }, { "role": "assistant", "content": "Show changes using common diff tools" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do negated patterns work in .gitignore?\nI am attempting to use a .gitignore file with negated patterns (lines starting with !), but it's not working the way I expect.\nAs a minimal example, I have the folllowing directory structure:\nC:/gittest\n -- .gitignore\n -- aaa/\n -- bbb/\n -- file.txt\n -- ccc/\n -- otherfile.txt\n\nand in my gitignore file, I have this:\naaa/\n!aaa/ccc/\n\nMy understanding (based on this doc page) is that the file aaa/ccc/otherfile.txt should not be ignored, but in fact git is ignoring everything under aaa.\nAm I misunderstanding this sentence: \"An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included again.\"?\nBTW, this is on Windows with msysgit 1.7.0.2." }, { "role": "assistant", "content": "I think that what you actually want to do is:\naaa/*\n!aaa/ccc\n\nYou're telling it \"don't look in aaa\" so it never even examines the path aaa/ccc. If you use the wildcard, it still reads the contents of aaa, then each entry matches the wildcard and is ignored, except aaa/ccc which gets put back in." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Escape @ character in git proxy password\nI have git proxy config as 'http.proxy=http://userId:pwd@123@ipaddress:port' but while cloning a remote project, I'm getting error as \nCloning into git...\nerror: Couldn't resolve proxy '123@ipaddress' while accessing http://git.kernel.org/pub/scm/git/git.git/info/refs\n\nfatal: HTTP request failed\n\nHow to escape the '@' character in password? \nPls note: I cannot change the password." }, { "role": "assistant", "content": "I'd try using the URL Encoded value of the @ symbol (%40) if you're passing the password in the proxy url:\nhttp.proxy=http://userId:pwd%40123@ipaddress:port" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gittutorial - A tutorial introduction to Git" }, { "role": "assistant", "content": "Using Git for collaboration Suppose that Alice has started a new project with a Git repository in /home/alice/project , and that Bob, who has a home directory on the\nsame machine, wants to contribute. Bob begins with: bob$ git clone /home/alice/project myrepo This creates a new directory myrepo containing a clone of Alice’s\nrepository. The clone is on an equal footing with the original\nproject, possessing its own copy of the original project’s history. Bob then makes some changes and commits them: (edit files)\nbob$ git commit -a\n(repeat as necessary) When he’s ready, he tells Alice to pull changes from the repository\nat /home/bob/myrepo . She does this with: alice$ cd /home/alice/project\nalice$ git pull /home/bob/myrepo master This merges the changes from Bob’s master branch into Alice’s\ncurrent branch. If Alice has made her own changes in the meantime,\nthen she may need to manually fix any conflicts. The pull command thus performs two operations: it fetches changes\nfrom a remote branch, then merges them into the current branch. Note that in general, Alice would want her local changes committed before\ninitiating this pull . If Bob’s work conflicts with what Alice did since\ntheir histories forked, Alice will use her working tree and the index to\nresolve conflicts, and existing local changes will interfere with the\nconflict resolution process (Git will still perform the fetch but will\nrefuse to merge — Alice will have to get rid of her local changes in\nsome way and pull again when this happens). Alice can peek at what Bob did without merging first, using the fetch command; this allows Alice to inspect what Bob did, using a special\nsymbol FETCH_HEAD , in order to determine if he has anything worth\npulling, like this: alice$ git fetch /home/bob/myrepo master\nalice$ git log -p HEAD..FETCH_HEAD This operation is safe even if Alice has uncommitted local changes.\nThe range notation HEAD..FETCH_HEAD means \"show everything that is reachable\nfrom the FETCH_HEAD but exclude anything that is reachable from HEAD \".\nAlice already knows everything that leads to her current state ( HEAD ),\nand reviews what Bob has in his state ( FETCH_HEAD ) that she has not\nseen with this command. If Alice wants to visualize what Bob did since their histories forked\nshe can issue the following command: $ gitk HEAD..FETCH_HEAD This uses the same two-dot range notation we saw earlier with git log . Alice may want to view what both of them did since they forked.\nShe can use three-dot form instead of the two-dot form: $ gitk HEAD...FETCH_HEAD This means \"show everything that is reachable from either one, but\nexclude anything that is reachable from both of them\". Please note that these range notation can be used with both gitk and git log . After inspecting what Bob did, if there is nothing urgent, Alice may\ndecide to continue working without pulling from Bob. If Bob’s history\ndoes have something Alice would immediately need, Alice may choose to\nstash her work-in-progress first, do a pull , and then finally unstash\nher work-in-progress on top of the resulting history. When you are working in a small closely knit group, it is not\nunusual to interact with the same repository over and over\nagain. By defining remote repository shorthand, you can make\nit easier: alice$ git remote add bob /home/bob/myrepo With this, Alice can perform the first part of the pull operation\nalone using the git fetch command without merging them with her own\nbranch, using: alice$ git fetch bob Unlike the longhand form, when Alice fetches from Bob using a\nremote repository shorthand set up with git remote , what was\nfetched is stored in a remote-tracking branch, in this case bob/master . So after this: alice$ git log -p master..bob/master shows a list of all the changes that Bob made since he branched from\nAlice’s master branch. After examining those changes, Alice\ncould merge the changes into her master branch: alice$ git merge bob/master This merge can also be done by pulling from her own remote-tracking\nbranch , like this: alice$ git pull . remotes/bob/master Note that git pull always merges into the current branch,\nregardless of what else is given on the command line. Later, Bob can update his repo with Alice’s latest changes using bob$ git pull Note that he doesn’t need to give the path to Alice’s repository;\nwhen Bob cloned Alice’s repository, Git stored the location of her\nrepository in the repository configuration, and that location is\nused for pulls: bob$ git config --get remote.origin.url\n/home/alice/project (The complete configuration created by git clone is visible using git config -l , and the git-config man page\nexplains the meaning of each option.) Git also keeps a pristine copy of Alice’s master branch under the\nname origin/master : bob$ git branch -r\n origin/master If Bob later decides to work from a different host, he can still\nperform clones and pulls using the ssh protocol: bob$ git clone alice.org:/home/alice/project myrepo Alternatively, Git has a native protocol, or can use http;\nsee git-pull for details. Git can also be used in a CVS-like mode, with a central repository\nthat various users push changes to; see git-push and gitcvs-migration ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Should I commit release key store for Android app to team repository?\nWe are developing android app in team. To create signed release apk you should set key store path, password, key alias and key password. If I want me and any my team member could create signed apk with same signature should I commit key store file to source control?" }, { "role": "assistant", "content": "You should not.\nRelease keystore is the most sensitive data.\nIn my team, there is only one people can sign the release package. (And may be one for backing up).\nAll sensitive info MUST be ignored and we make a reference to these info.\nIn my team, we config like that:\nOn Android Studio:\n/local.properties file:\nstoreFile=[path/to/keystore/file]\nkeyAlias=[alias's key]\nkeyPassword=[alias's password]\nstorePassword=[key's password]\n\n/app/build.gradle, config scope:\nsigningConfigs {\n release {\n Properties properties = new Properties()\n properties.load(project.rootProject.file('local.properties').newDataInputStream())\n storeFile file(properties.getProperty('storeFile'))\n keyAlias properties.getProperty('keyAlias')\n storePassword properties.getProperty('storePassword')\n keyPassword properties.getProperty('keyPassword')\n }\n}\n\nbuildTypes {\n release {\n minifyEnabled false\n proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n signingConfig signingConfigs.release\n }\n .\n .\n .\n}\n\nSee my complete demo config:\napply plugin: 'com.android.application'\n\nandroid {\n compileSdkVersion 21\n buildToolsVersion \"22.0.1\"\n\n defaultConfig {\n multiDexEnabled = true\n\n applicationId \"com.appconus.demoapp\"\n minSdkVersion 16\n targetSdkVersion 21\n multiDexEnabled = true\n versionCode 18\n versionName \"1.3\"\n }\n\n signingConfigs {\n release {\n Properties properties = new Properties()\n properties.load(project.rootProject.file('local.properties').newDataInputStream())\n storeFile file(properties.getProperty('storeFile'))\n keyAlias properties.getProperty('keyAlias')\n storePassword properties.getProperty('storePassword')\n keyPassword properties.getProperty('keyPassword')\n }\n }\n\n buildTypes {\n release {\n minifyEnabled false\n proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n signingConfig signingConfigs.release\n }\n debug {\n minifyEnabled false\n proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n }\n applicationVariants.all { variant ->\n appendVersionNameVersionCode(variant, defaultConfig)\n }\n }\n}\ndependencies {\n compile 'com.google.android.gms:play-services:8.1.0'\n}" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can I add issues to github from the command line?\n\nI'm new to git and I'd like to be able to map plans and progress for my project through github.\nThe problem is, that requires lots of clicking around with a browser on github.com, and I'd like to be able to automate the task somewhat by using a command line program.\nIs there a command line interface for github?" }, { "role": "assistant", "content": "There's a ghi gem that you can use to manage issues.\n\nThe most commonly used ghi commands are:\n list List your issues (or a repository's)\n show Show an issue's details\n open Open (or reopen) an issue\n close Close an issue\n edit Modify an existing issue\n comment Leave a comment on an issue\n label Create, list, modify, or delete labels\n assign Assign an issue to yourself (or someone else)\n milestone Manage project milestones" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters <rev>^-<n> , e.g. HEAD^-, HEAD^-2" }, { "role": "assistant", "content": "Equivalent to <rev>^<n>..<rev> , with <n> = 1 if not\ngiven." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-gc - Cleanup unnecessary files and optimize the local repository gc.packRefs" }, { "role": "assistant", "content": "Running git pack-refs in a repository renders it\nunclonable by Git versions prior to 1.5.1.2 over dumb\ntransports such as HTTP. This variable determines whether git gc runs git pack-refs . This can be set to notbare to enable it within all non-bare repos or it can be set to a\nboolean value. The default is true ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Remove a folder from git tracking\nI need to exclude a folder (name uploads) from tracking. I tried to run\ngit rm -r --cached wordpress/wp-content/uploads\n\nand after that I added the path to .gitignore\n/wordpress/wp-content/uploads\n\nbut when I ran git status they show up as deleted. If I try to commit the changes, the files will be deleted, not only removed from tracking.\nWhat am I doing wrong? \nI have also tried\ngit update-index --assume-unchanged <file>\n\nbut this seems to untrack only files. But I need to remove an entire folder (including subfolders) from tracking." }, { "role": "assistant", "content": "I came across this question while Googling for \"git remove folder from tracking\". The OP's question lead me to the answer. I am summarizing it here for future generations.\nQuestion\nHow do I remove a folder from my git repository without deleting it from my local machine (i.e., development environment)?\nAnswer\nStep 1. Add the folder path to your repo's root .gitignore file.\npath_to_your_folder/\n\nStep 2. Remove the folder from your local git tracking, but keep it on your disk.\ngit rm -r --cached path_to_your_folder/\n\nStep 3. Push your changes to your git repo.\nThe folder will be considered \"deleted\" from Git's point of view (i.e. they are in past history, but not in the latest commit, and people pulling from this repo will get the files removed from their trees), but stay on your working directory because you've used --cached." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How stable is the git plugin for eclipse?\nI was intending to have a play with git, and was wondering if anyone had used the git plugin for eclipse\nI see it's at version 0.3.1, and was wondering if anyone knew how stable it was / any gotchas?\n\nUpdate:\nIf you are using a recent version of Eclipse, your Help menu has an 'Eclipse Marketplace...' link. \nEnter 'git' in the Find field. This shows me EGit. \nThis is also very high in the Popular plugins list.\nClick install. Much easier than having to add update site locations by hand." }, { "role": "assistant", "content": "Github blog spoke yesterday about Egit plugin:\nhttp://freshmeat.net/projects/jgit/" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-cat-file - Provide contents or details of repository objects --follow-symlinks" }, { "role": "assistant", "content": "With --batch or --batch-check , follow symlinks inside the\nrepository when requesting objects with extended SHA-1\nexpressions of the form tree-ish:path-in-tree. Instead of\nproviding output about the link itself, provide output about\nthe linked-to object. If a symlink points outside the\ntree-ish (e.g. a link to /foo or a root-level link to ../foo ),\nthe portion of the link which is outside the tree will be\nprinted. This option does not (currently) work correctly when an object in the\nindex is specified (e.g. :link instead of HEAD:link ) rather than\none in the tree. This option cannot (currently) be used unless --batch or --batch-check is used. For example, consider a git repository containing: f: a file containing \"hello\\n\"\nlink: a symlink to f\ndir/link: a symlink to ../f\nplink: a symlink to ../f\nalink: a symlink to /etc/passwd For a regular file f , echo HEAD:f | git cat-file --batch would print ce013625030ba8dba906f756967f9e9ca394464a blob 6 And echo HEAD:link | git cat-file --batch --follow-symlinks would\nprint the same thing, as would HEAD:dir/link , as they both point at HEAD:f . Without --follow-symlinks , these would print data about the symlink\nitself. In the case of HEAD:link , you would see 4d1ae35ba2c8ec712fa2a379db44ad639ca277bd blob 1 Both plink and alink point outside the tree, so they would\nrespectively print: symlink 4\n../f symlink 11\n/etc/passwd" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database mailmapSymlink" }, { "role": "assistant", "content": "(INFO) .mailmap is a symlink." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker <file>" }, { "role": "assistant", "content": "Indicates a filename - almost always relative to the\nroot of the tree structure GIT_INDEX_FILE describes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-update-ref - Update the object name stored in a ref safely verify" }, { "role": "assistant", "content": "Verify <ref> against <old-oid> but do not change it. If\n<old-oid> is zero or missing, the ref must not exist." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-update-index - Register file contents in the working tree to the index -z" }, { "role": "assistant", "content": "Only meaningful with --stdin or --index-info ; paths are\nseparated with NUL character instead of LF." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc no" }, { "role": "assistant", "content": "Do not ignore whitespace when performing move detection." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitrevisions - Specifying revisions and ranges for Git <sha1> , e.g. dae86e1950b1277e545cee180551750029cfe735 , dae86e" }, { "role": "assistant", "content": "The full SHA-1 object name (40-byte hexadecimal string), or\na leading substring that is unique within the repository.\nE.g. dae86e1950b1277e545cee180551750029cfe735 and dae86e both\nname the same commit object if there is no other object in\nyour repository whose object name starts with dae86e." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository to" }, { "role": "assistant", "content": "The name of the local ref being updated, minus its refs/<type>/ prefix." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How does Git compute file hashes?\nThe SHA1 hashes stored in the tree objects (as returned by git ls-tree) do not match the SHA1 hashes of the file content (as returned by sha1sum):\n$ git cat-file blob 4716ca912495c805b94a88ef6dc3fb4aff46bf3c | sha1sum\nde20247992af0f949ae8df4fa9a37e4a03d7063e -\n\nHow does Git compute file hashes? Does it compress the content before computing the hash?" }, { "role": "assistant", "content": "Git prefixes the object with \"blob \", followed by the length (as a\n human-readable integer), followed by a NUL character\n\n$ echo -e 'blob 14\\0Hello, World!' | shasum\n8ab686eafeb1f44702738c8b0f24f2567c36da6d\nSource: http://alblue.bandlem.com/2011/08/git-tip-of-week-objects.html" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "fatal: ambiguous argument 'origin': unknown revision or path not in the working tree\nI used git diff origin often in the past.\nIn a different environment it does not work. I have no clue why.\nuser@host> git diff origin\nfatal: ambiguous argument 'origin': unknown revision or path \n not in the working tree.\nUse '--' to separate paths from revisions, like this:\n'git <command> [<revision>...] -- [<file>...]'\n\nStatus:\nuser@host> git status\nOn branch master\nnothing to commit, working directory clean\n\nRemotes:\nuser@host> git remote -v\norigin https://example.com/repos/djangotools (fetch)\norigin https://example.com/repos/djangotools (push)\n\nVersion:\nuser@host> git --version\ngit version 2.7.4\n\nWith \"git version 1.8.1.4\" git diff origin works. \nBTW I see the same err msg if I use \"git diff origin/master\"\nBTW2, I think the \"/master\" is redundant. The sane default is to compare the local branch with the same branch on the remote site." }, { "role": "assistant", "content": "The git diff command typically expects one or more commit hashes to generate your diff. You seem to be supplying the name of a remote.\nIf you had a branch named origin, the commit hash at tip of the branch would have been used if you supplied origin to the diff command, but currently (with no corresponding branch) the command will produce the error you're seeing. It may be the case that you were previously working with a branch named origin.\nAn alternative, if you're trying to view the difference between your local branch, and a branch on a remote would be something along the lines of:\ngit diff origin/<branchname>\ngit diff <branchname> origin/<branchname>\nOr other documented variants.\nEdit: Having read further, I realise I'm slightly wrong, git diff origin is shorthand for diffing against the head of the specified remote, so git diff origin = git diff origin/HEAD (compare local git branch with remote branch?, Why is \"origin/HEAD\" shown when running \"git branch -r\"?)\nIt sounds like your origin does not have a HEAD, in my case this is because my remote is a bare repository that has never had a HEAD set.\nRunning git branch -r will show you if origin/HEAD is set, and if so, which branch it points at (e.g. origin/HEAD -> origin/<branchname>)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I move a tag on a git branch to a different commit?\nI created a tag on the master branch called v0.1 like this:\ngit tag -a v0.1\n\nBut then I realized there were still some changes I needed to merge into master for release 0.1, so I did that. But now my v0.1 tag is stuck on (to invoke the post-it note analogy) the wrong commit. I want it to be stuck on the most recent commit on master, but instead it is stuck on the second most recent commit on master.\nHow can I move it to the most recent commit on master?" }, { "role": "assistant", "content": "Use the -f option to git tag:\n-f\n--force\n\n Replace an existing tag with the given name (instead of failing)\n\nYou probably want to use -f in conjunction with -a to force-create an annotated tag instead of a non-annotated one.\nExample\n\nDelete the tag on any remote before you push\ngit push origin :refs/tags/<tagname>\n\n\nReplace the tag to reference the most recent commit\ngit tag -fa <tagname>\n\n\nPush the tag to the remote origin\ngit push origin --tags" } ]