messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc default"
},
{
"role": "assistant",
"content": "Is a synonym for zebra . This may change to a more sensible mode\nin the future."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --dst-prefix=<prefix>"
},
{
"role": "assistant",
"content": "Show the given destination prefix instead of \"b/\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git push master fatal: You are not currently on a branch\nMaster is it at say commit #10. However, I ended up realizing I broke something along the way that wasn't caught by tests.\nI ended up going to commit #5, and then slowly re-did the dev of each commit and adjusted it continually to ensure it didn't re-cause the bug. Now I'm essentially back to commit #10, but with a number of changes that prevent the bug from happening.\nI now want to create commit #11 using my changes. But when I try to push to master I get \nfatal: You are not currently on a branch.\nTo push the history leading to the current (detached HEAD)\nstate now, use\n\n git push master HEAD:<name-of-remote-branch>\n\nWhich is to be expected. But how do I actually get that to push up to my remote branch?\nI tried git push origin HEAD:master but then got this:\n! [rejected] HEAD -> master (non-fast-forward)\nerror: failed to push some refs to 'https://github.com/tomhammond/sample.git'\nhint: Updates were rejected because a pushed branch tip is behind its remote\nhint: counterpart. Check out this branch and integrate the remote changes\nhint: (e.g. 'git pull ...') before pushing again.\nhint: See the 'Note about fast-forwards' in 'git push --help' for details.\n\nWhen I do a git status I see HEAD detached from 4a74ac3"
},
{
"role": "assistant",
"content": "But when I try to push to master I get\n\nfatal: You are not currently on a branch.\nTo push the history leading to the current (detached HEAD)\n\nWhich is to be expected\n\nWorking in a detached state is not to be expected, unless you deliberately want to be doing this, which I doubt is the case for you. Instead of checking out commit #5, you should have either reverted the master branch to that commit, or do a git rebase in interactive mode where you can rehash the commits as you want.\nThat being said, if you are certain that the version of master in the detached state is what you really want to keep, then you can get around the non-fast-forward error, by force pushing the branch to the remote:\ngit push origin HEAD:master --force\n\nHowever, if you force push you run the risk of causing problems for all other users who have that branch checked out. A less risky solution would be to create a temporary branch from the detached HEAD, and then merge that branch into master:\ngit branch temp-branch\ngit checkout master\ngit merge temp-branch\ngit push origin master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "private repo - go 1.13 - `go mod ..` failed: ping \"sum.golang.org/lookup\" .. verifying package .. 410 gone\n\nI am using golang 1.13 . \nI have a project that depends on a private gitlab project. \nI have the ssh keys for the same. \nWhen I try to retrieve the dependencies for a newly created module, I am getting the following error: \n$ go version\ngo version go1.13 linux/amd64\n\n$ go mod why\ngo: downloading gitlab.com/mycompany/myproject v0.0.145\nverifying gitlab.com/mycompany/[email protected]: gitlab.com/mycompany/[email protected]: reading https://sum.golang.org/lookup/gitlab.com/mycompany/[email protected]: 410 Gone\n\nI have no idea why it is trying to ping sum.golang.org/lookup since it is a private gitlab project. \nMy ~/.gitconfig contains the following (based on my looking up in google search for similar errors)\n# Enforce SSH\n[url \"ssh://[email protected]/\"]\n insteadOf = https://github.com/\n[url \"ssh://[email protected]/\"]\n insteadOf = https://gitlab.com/\n[url \"ssh://[email protected]/\"]\n insteadOf = https://bitbucket.org/\n[url \"[email protected]:\"]\n insteadOf = https://gitlab.com/\n\nThe error still persists. \nI would expect the package to be downloaded from my private gitlab project repository to the current project. \nIs there anything I need to do in my private gitlab project repository to make it ready for 'go get' ? \nThe private gitlab project repository already contains the go.sum and go.mod for the project as well. \nAnything that I am missing ?\nedit: 1) The private repo name and the company name contains no asterisks or any other special characters. only alphabets and not even numeric characters."
},
{
"role": "assistant",
"content": "Answering my own question after looking up, \nSetting the GOPRIVATE variable seems to help.\nGOPRIVATE=gitlab.com/mycompany/* go mod why\n\n\"\nThe new GOPRIVATE environment variable indicates module paths that are not publicly available. It serves as the default value for the lower-level GONOPROXY and GONOSUMDB variables, which provide finer-grained control over which modules are fetched via proxy and verified using the checksum database.\n\" from https://golang.org/doc/go1.13 \nAliter:\nSetting the env variable GONOSUMDB also seems to work. \nSpecifically, invoking the following command seems to help.\n GONOSUMDB=gitlab.com/mycompany/* go mod why\n\nThe above env variable prevents the ping to sum.golang.org/lookup for a checksum match. It also prevents leaking the names of private repos to a public checksum db. [ Source - https://docs.gomods.io/configuration/sumdb/ ]\nAlso - here at\n * GONOSUMDB=prefix1,prefix2,prefix3 sets a list of module path prefixes, again possibly containing globs, that should not be looked up using the database.\n\nsource: https://go.googlesource.com/proposal/+/master/design/25530-sumdb.md\nRelated Issues:\n\nhttps://github.com/golang/go/issues/32291 \nhttps://github.com/golang/go/issues/33985 \n[\"Go 1.13 has been released, and this issue was filed well after the freeze window. The proposed changes will not happen in 1.13, but don't assume they will necessarily happen in 1.14 either.\" from issue 33985 above. ]"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Deploy Code from GitLab Repository to Azure Web App using PowerShell\n\nI would like to setup continuous deployment from a GitLab repository to an Azure App using a PowerShell script. I'm aware that you can do this manually as per:\nhttps://christianliebel.com/2016/05/auto-deploying-to-azure-app-services-from-gitlab/\nHowever, I'm trying to automate this with Powershell. I've looked at this sample script for GitHub:\nhttps://learn.microsoft.com/en-us/azure/app-service/scripts/app-service-powershell-continuous-deployment-github\nBut as there is no provider for GitLab, and none of the existing providers accept a GitLab URL, I'm unsure of how to proceed. I've looked at setting up a manual deployment with GitLab in the Azure Portal (using the External Repository option) and exporting the resource group template to get details of how the repository is connected to the App, but I get the error:\nCould not get resources of the type 'Microsoft.Web/sites/sourcecontrols'. \nResources of this type will not be exported. (Code: ExportTemplateProviderError, Target: Microsoft.Web/sites/sourcecontrols)\n\nAt the minute, I'm working around this by mirroring my GitLab repository in GitHub, and using the continuous deployment pipeline from there to Azure. Note, this is for a repository hosted in GitLab.com, not in a self-hosted GitLab server. There is no Windows Runner setup for the project.\nHow can I use a PowerShell script to setup a Continuous Deployment directly from GitLab to Azure? Once the setup script is run, each subsequent commit/merge to the GitLab repository should then automatically be deployed to Azure. Preferably, this PowerShell script should use the AzureRM modules, but I'm willing to accept a solution that uses PowerShell Core and the new Az module (based on the Azure CLI). The specific test repository I'm using is public (https://gitlab.com/MagicAndi/geekscode.net), but it isn't a specific requirement for the solution to work with private repositories (but if it does, even better!).\nUpdate 17/12/2018\nI've awarded the bounty to the-fish as his answer best met my specific needs. However, given that Windows Powershell and the Azure RM module are being deprecated in favour of PowerShell Core and the new Az module (using the Azure CLI), I've created a new question asking specificially for a canonical answer using the Azure CLI and Powershell Core. I plan on offering a bounty for this question when it is open to me in 2 days. Thanks."
},
{
"role": "assistant",
"content": "It sounds like you are looking for a direct deploy from GitLab to Azure Apps, however I'd suggest using a deployment pipeline tool to give you far more options.\nAzure DevOps Services Pipelines would likely be a safe option and has a free tier and here's a very brief getting started guide for Web Apps deploys.\nHowever it doesn't have built in support for GitLab, but there appears to be a marketplace tool for integrations with GitLab.\nThis doesn't appear to have the capability of release triggers, but could be triggered manually. Someone else has the question about release triggers in the marketplace Q&A so perhaps it will be in the roadmap."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Given a git refname, can I detect whether it's a hash, tag, or branch?\nI'm writing a script that will take in a specification used as the base for creating a branch. Thus, it will have something like this:\ngit checkout -b $newbranch $startingpoint\n\nNow, startingpoint can be specified either as a branch name, a tag, or a SHA1.\nLater in the script, I need to do different things based on what startingpoint actually is. Is had thought git rev-parse would give me this information, but I cannot seem to bend it to my whim.\nIs there a git way, preferably a porcelain, to get the information I seek?\nUpdate\nI used the show-ref information to craft the following shell function:\ngit_ref_type() {\n [ -n \"$1\" ] || die \"Missing ref name\"\n\n if git show-ref -q --verify \"refs/heads/$1\" 2>/dev/null; then\n echo \"branch\"\n elif git show-ref -q --verify \"refs/tags/$1\" 2>/dev/null; then\n echo \"tag\"\n elif git show-ref -q --verify \"refs/remote/$1\" 2>/dev/null; then\n echo \"remote\"\n elif git rev-parse --verify \"$1^{commit}\" >/dev/null 2>&1; then\n echo \"hash\"\n else\n echo \"unknown\"\n fi\n return 0\n}\n\nThis seems to work well for now, though it's been only very lightly tested."
},
{
"role": "assistant",
"content": "You can probably use the show-ref command to do (mostly) what you want. Given some string, if it refers to a tag then...\ngit show-ref --verify refs/tags/$thestring\n\n...will be true. If it's a branch name, then...\ngit show-ref --verify refs/heads/$thestring\n\n...will be true. If the string fails both of those tests, then...\ngit rev-parse --verify \"$thestring^{commit}\"\n\n...will tell you if it otherwise refers to a commit (which could be a complete SHA1, a partial SHA1, HEAD, or possibly something else that doesn't fall into the previous two categories."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What are the differences between these git diff commands?\nWhat are the differences between the following git commands?\n\ngit diff HEAD\ngit diff HEAD^\ngit diff --cached or the synonym git diff --staged\ngit diff"
},
{
"role": "assistant",
"content": "git diff HEAD - Shows what has changed since the last commit.\ngit diff HEAD^ - Shows what has changed since the commit before the latest commit.\ngit diff --cached - Show what has been added to the index via git add but not yet committed.\ngit diff - Show what has changed but hasn't been added to the index yet via git add.\n\nIt looks like this:\n Working\n Directory <----+--------+------+\n | | | | \n | | | |\n V | | | \n \"git add\" | | | \n | diff | | \n | | | | \n V | | | \n Index <----+ diff HEAD | \n | | | | \n | | | |\n V | | | \n \"git commit\" | | |\n | diff --cached | |\n | diff --staged | |\n V | | |\n HEAD <----+--------+ |\n | |\n | diff HEAD^\n V |\nprevious \"git commit\" |\n | |\n | |\n V |\n HEAD^ <--------------------+"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --reverse"
},
{
"role": "assistant",
"content": "Output the commits chosen to be shown (see Commit Limiting\nsection above) in reverse order. Cannot be combined with --walk-reflogs ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options 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": "How to hide .env file from Github\nI'm using dotenv for my rails project to store API keys. I have the dotenv gem in my gemfile, created a .env in the root of my app and have my API keys listed in there. However, when I push up to github, I notice that the .env file is still there. Am I missing a step? How can I hide the .env file from being uploaded to github. \nThank you!"
},
{
"role": "assistant",
"content": "Create a file called .gitignore in the root directory of your project (it's possible one is already there) and add .env on its own line in the file.\nAlso, if you have already added it to your repository, then you will have to add the file to .gitignore as stated above and then clear Git's cache. You can find information on that in the following answer on StackOverflow."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database gitattributesMissing"
},
{
"role": "assistant",
"content": "(ERROR) Unable to read .gitattributes blob."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary special ref"
},
{
"role": "assistant",
"content": "A ref that has different semantics than normal refs. These refs can be\naccessed via normal Git commands but may not behave the same as a\nnormal ref in some cases. The following special refs are known to Git: \" FETCH_HEAD \" is written by git-fetch or git-pull . It\nmay refer to multiple object IDs. Each object ID is annotated with metadata\nindicating where it was fetched from and its fetch status. \" MERGE_HEAD \" is written by git-merge when resolving merge\nconflicts. It contains all commit IDs which are being merged."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-am - Apply a series of patches from a mailbox --no-scissors"
},
{
"role": "assistant",
"content": "Ignore scissors lines (see git-mailinfo )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Issue with SourceTree while cloning a GitHub repository\n\nI know that similar questions have already been posted here. However, I think my scenario is a bit different. Here is what I have.\nI downloaded and installed the latest official version of the SourceTree software. Also, I have a GitHub account with permissions to clone and push the repository. In order to manage a local copy, I need to clone the online version. Here are the steps that I take:\n\nStart the SourceTree and navigate to File -> Clone / New ...\n\nIn the opened window I paste the HTTPS clone URL. I copied it from the browser after I logged in to my GitHub account so the link is correct.\n\nThe nest step is to specify a local folder where the repository will be copied. However, when I click to enter Destination Path, the window shows an error:\nThis is not a valid source path / URL\n\nClicking the error may give the following details:\nremote: Repository not found.\nfatal: repository 'https://github.com/org/repo.git/' not found\nremote: Repository not found.\nfatal: repository 'https://github.com/org/repo.git/' not found\n\nOr the details may be empty. SourceTree does not tell me the reason for the error or anything else.\n\n\nI tried to re-install SourceTree but the error still exists. I asked the Administration of the GitHub repository for any other permissions but my account has all of them. I am able to push changes to the online repository using the Terminal console but I would like to use a UI (that SourceTree provides) to manage and compare changes in the code.\nOne think I did not try is to clone the repository using another GtHub account. However, I don't want to do that because I need to commit any changes to the repository on my behalf.\nDoes anybody know how can this error be fixed or worked around?"
},
{
"role": "assistant",
"content": "Lastly on Mac I went to\nSourcetree->Preferences->Git->Git version->Use System Git\nand it works... puf!"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - Your branch is ahead of 'origin/master' by 1 commit\nI am newbie in git and I am working on git. \nI added some files in git : \ngit add <file1>\ngit add <file2>\n\nthen I wanted to push that for review, but mistakenly I did\ngit commit\n\nso the files which I have changed don't go for reviews.\nNow if I enter the command :\ngit status\n\nit says \n# On branch master\n# Your branch is ahead of 'origin/master' by 1 commit.\n#\nnothing to commit (working directory clean)\n\nI want to revert that commit and I want to push those files for review rather than commit.\nCan anyone let me know how I can do that?"
},
{
"role": "assistant",
"content": "You cannot push anything that hasn't been committed yet. The order of operations is:\n\nMake your change.\ngit add - this stages your changes for committing\ngit commit - this commits your staged changes locally\ngit push - this pushes your committed changes to a remote\n\nIf you push without committing, nothing gets pushed. If you commit without adding, nothing gets committed. If you add without committing, nothing at all happens, git merely remembers that the changes you added should be considered for the following commit.\nThe message you're seeing (your branch is ahead by 1 commit) means that your local repository has one commit that hasn't been pushed yet.\nIn other words: add and commit are local operations, push, pull and fetch are operations that interact with a remote.\nSince there seems to be an official source control workflow in place where you work, you should ask internally how this should be handled."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.context"
},
{
"role": "assistant",
"content": "Generate diffs with <n> lines of context instead of the default\nof 3. This value is overridden by the -U option."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I delete all Git branches which have been merged?\nHow do I delete branches which have already been merged? Can I delete them all at once, instead of deleting each branch one-by-one?"
},
{
"role": "assistant",
"content": "NOTE: You can add other branches to exclude like master and dev if your workflow has those as a possible ancestor. Usually I branch off of a \"sprint-start\" tag and master, dev and qa are not ancestors.\n\nFirst, list locally-tracking branches that were merged in remote (consider using -r flag to list all remote-tracking branches).\ngit branch --merged\n\nYou might see few branches you don't want to remove. We can add few arguments to skip important branches that we don't want to delete like master or a develop. The following command will skip master branch and anything that has dev in it.\ngit branch --merged| grep -Ev \"(^\\*|master|main|dev)\"\n\nIf you want to skip, you can add it to the egrep command like the following. The branch skip_branch_name will not be deleted.\ngit branch --merged| grep -Ev \"(^\\*|master|main|dev|skip_branch_name)\"\n\nTo delete all local branches that are already merged into the currently checked out branch:\ngit branch --merged | grep -Ev \"(^\\*|master|main|dev)\" | xargs git branch -d\n\nYou can see that master and dev are excluded in case they are an ancestor.\n\nYou can delete a merged local branch with:\ngit branch -d branchname\n\nIf it's not merged, use:\ngit branch -D branchname\n\nTo delete it from the remote use:\ngit push --delete origin branchname\n\ngit push origin :branchname # for really old git\n\nOnce you delete the branch from the remote, you can prune to get rid of remote tracking branches with:\ngit remote prune origin\n\nor prune individual remote tracking branches, as the other answer suggests, with:\ngit branch -dr branchname"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Merging without whitespace conflicts\nI've got a problem, where a large commit which changes about a thousand lines of code, removing whitespace from the end of lines and removing spaces before tabs.\nThere are also about 50 pull requests for this project, in which all will get conflicts, when my commit is merged. Is there any way that git can be set up so that when merging future commits, it ignores conflicts where one of them is just a whitespace change?\nModifying git itself or using a third party tool isn't possible, but using a hook is fine."
},
{
"role": "assistant",
"content": "git merge -Xignore-all-space\n\nOr (more precise)\n git merge -Xignore-space-change\n\nshould be enough to ignore all space related conflicts during the merge.\nSee git diff:\n--ignore-space-change\n\n\nIgnore changes in amount of whitespace.\n This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent. \n\n--ignore-all-space\n\n\nIgnore whitespace when comparing lines.\n This ignores differences even if one line has whitespace where the other line has none. \n\nks1322 adds in the comments a good advice:\n\nIt is worth to merge with --no-commit and review the merge before actual commit. \n\n\nThe OP Callum Macrae reports that, in that case, the merge proceed uninterrupted, and the trailing spaces contained in the pull request patches are applied to the local files.\nHowever, the OP uses a pre-commit hook which takes care of said trailing spaces.\n(I suppose a bit similar to this one, also referenced here).\n\nThe OP's pre-commit hook is referenced here:\n\nIn addition to removing trailing whitespace, it removes one to three spaces before tabs (I have tab width set to 4), and adds EOLs.\n I've had reports that the code that adds the EOL deletes the file in windows, but haven't been able to replicate it."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I delete a local branch on Github Desktop?\n\nLast week I upgraded my Windows Github to Github Desktop.\nIt is certainly a lot faster than that last update they made for Github Windows. It also has a nice little visual timeline of commits and maybe I am being dumb, but the ability to delete local branches seems to be gone. \nBefore it was under “manage branches” (also gone). Any idea?\nUpdate: \nIn v3.0.5 they have added the option to delete local branches from the gear menu."
},
{
"role": "assistant",
"content": "On Mac OSX:\nfor everyone having this problem with the latest version:\nSelect the branch that you want to delete, go to \"Branch\" -> \"Delete Branch\"\n\nOn Windows:"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Multiple GitHub Accounts & SSH Config\n\nI'm having some trouble getting two different SSH keys/GitHub accounts to play well together. I have the following setup:\nRepos accessible from one account using [email protected]:accountname\nRepos accessible from another account using [email protected]:anotheraccount\nEach account has its own SSH key. Both SSH keys have been added and I have created a config file. I don't believe the config file is correct though. I'm not quite sure how to specify that repos accessed using [email protected]:accountname should use id_rsa and [email protected]:anotheraccount should use id_rsa_anotheraccount."
},
{
"role": "assistant",
"content": "Andy Lester's response is accurate but I found an important extra step I needed to make to get this to work. In trying to get two profiles set up, one for personal and one for work, my ~/.ssh/config was roughly as follows:\nHost me.github.com\n HostName github.com\n PreferredAuthentications publickey\n IdentityFile ~/.ssh/me_rsa\n\nHost work.github.com\n HostName github.com\n PreferredAuthentications publickey\n IdentityFile ~/.ssh/work_rsa\n\nMy work profile didn't take until I did a ssh-add ~/.ssh/work_rsa. After that connections to github used the correct profile. Previously they defaulted to the first public key.\nFor Could not open a connection to your authentication agent when using ssh-add,check:\nhttps://stackoverflow.com/a/17695338/1760313"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What names are valid git tags?\nI have got a error message while creating tag containing [ character:\n\nfatal: '[' is not a valid tag name.\n\nQuestion: are there any rules for tags in the git?"
},
{
"role": "assistant",
"content": "You can check if the name is valid with\ngit check-ref-format\n\nThis page contains the constraints on a valid name. Quoted from the page (possibly outdated in the future):\n\n\nThey can include slash / for hierarchical (directory) grouping, but no slash-separated component can begin with a dot . or end with the sequence .lock.\nThey must contain at least one /. This enforces the presence of a category like heads/, tags/ etc. but the actual names are not restricted. If the --allow-onelevel option is used, this rule is waived.\nThey cannot have two consecutive dots .. anywhere.\nThey cannot have ASCII control characters (i.e. bytes whose values are lower than \\040, or \\177 DEL), space, tilde ~, caret ^, or colon : anywhere.\nThey cannot have question-mark ?, asterisk *, or open bracket [ anywhere. See the --refspec-pattern option below for an exception to this rule.\nThey cannot begin or end with a slash / or contain multiple consecutive slashes (see the --normalize option below for an exception to this rule)\nThey cannot end with a dot ..\nThey cannot contain a sequence @{.\nThey cannot be the single character @.\nThey cannot contain a \\.\n\n\nAs you can see, in your case you violated rule (5).\nYou can use the --normalize flag to normalize tags with respect to slashes (removing leading slashes as well as consecutive ones):\ngit check-ref-format --normalize \"tags/weird//tag\"\n\nThe tags/ part species that you are validating a tag.\nAfter some discussion with @NikosAlexandris, you can write the following one liner to check the tag <some-tag> with textual feedback:\ngit check-ref-format \"tags/<some-tag>\" && echo \"Valid tag\" || echo \"Invalid tag\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Show list of files changed in recent commits in a specific directory\nIn Subversion, svn log displays commit log messages (reference).\nHow can I do the following in git?\nsvn log -v -l 10 ./"
},
{
"role": "assistant",
"content": "This one is more similar to the svn command as it shows the file status: Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), and others.\ngit log --name-status -10 path/to/dir\n\nIt is worth looking at the full documentation page for git log. There you will learn that -10 refers to the past 10 commits, and -p will give you the full patch, among a variety of other goodies."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the purpose of `text=auto` in `.gitattributes` file?\nMostly .gitattributes file has * text=auto. What is the purpose of text=auto in that file?"
},
{
"role": "assistant",
"content": "From the docs:\n\nEach line in .gitattributes (or .git/info/attributes) file is of form:\n\n\npattern attr1 attr2 ...\n\n\nSo here, the pattern is *, which means all files, and the attribute is text=auto.\nWhat does text=auto do? From the documentation:\n\nWhen text is set to \"auto\", the path is marked for automatic end-of-line normalization. If Git decides that the content is text, its line endings are normalized to LF on checkin.\n\nWhat's the default behaviour if it's not enabled?\n\nUnspecified\nIf the text attribute is unspecified, Git uses the core.autocrlf configuration variable to determine if the file should be converted.\n\nWhat does core.autocrlf do? From the docs:\n\n core.autocrlf\n\nSetting this variable to \"true\" is almost the same as setting the text attribute to \"auto\" on all files except that text files are not guaranteed to be\nnormalized: files that contain CRLF in the repository will not be touched. Use this setting if you want to have CRLF line endings in your working\ndirectory even though the repository does not have normalized line endings.\nThis variable can be set to input, in which case no output conversion is performed.\n\nIf you think this all as clear as mud, you're not alone.\nHere's what * text=auto does in my words: when someone commits a file, Git guesses whether that file is a text file or not, and if it is, it will commit a version of the file where all CR + LF bytes are replaced with LF bytes. It doesn't directly affect what files look like in the working tree, there are other settings that will convert LF bytes to CR + LF bytes when checking out a file.\nRecommendation:\nI would not recommend putting * text=auto in the .gitattributes file. Instead, I would recommend something like this:\n*.txt text\n*.html text\n*.css text\n*.js text\n\nThis explicitly designates which files are text files, which get CRLF converted to LF in the object database (but not necessarily in the working tree). We had a repo with * text=auto, and Git guessed wrong for an image file that it was a text file, causing it to corrupt it as it replaced CR + LF bytes with LF bytes in the object database. That was not a fun one to debug.\nIf you must use * text=auto, put it as the first line in .gitattributes, so that the later lines can override it. This seems to be becoming an increasingly popular practise."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-mktree"
},
{
"role": "assistant",
"content": "Build a tree-object from ls-tree formatted text"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why there are two ways to unstage a file in Git?\nSometimes git suggests git rm --cached to unstage a file, sometimes git reset HEAD file. When should I use which?\nD:\\code\\gt2>git init\nInitialized empty Git repository in D:/code/gt2/.git/\nD:\\code\\gt2>touch a\n\nD:\\code\\gt2>git status\n# On branch master\n#\n# Initial commit\n#\n# Untracked files:\n# (use \"git add <file>...\" to include in what will be committed)\n#\n# a\nnothing added to commit but untracked files present (use \"git add\" to track)\n\nD:\\code\\gt2>git add a\n\nD:\\code\\gt2>git status\n# On branch master\n#\n# Initial commit\n#\n# Changes to be committed:\n# (use \"git rm --cached <file>...\" to unstage)\n#\n# new file: a\n#\nD:\\code\\gt2>git commit -m a\n[master (root-commit) c271e05] a\n 0 files changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 a\n\nD:\\code\\gt2>touch b\n\nD:\\code\\gt2>git status\n# On branch master\n# Untracked files:\n# (use \"git add <file>...\" to include in what will be committed)\n#\n# b\nnothing added to commit but untracked files present (use \"git add\" to track)\n\nD:\\code\\gt2>git add b\n\nD:\\code\\gt2>git status\n# On branch master\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# new file: b\n#"
},
{
"role": "assistant",
"content": "git rm --cached <filePath> does not unstage a file, it actually stages the removal of the file(s) from the repo (assuming it was already committed before) but leaves the file in your working tree (leaving you with an untracked file).\ngit reset -- <filePath> will unstage any staged changes for the given file(s).\nThat said, if you used git rm --cached on a new file that is staged, it would basically look like you had just unstaged it since it had never been committed before.\nUpdate git 2.24\nIn this newer version of git you can use git restore --staged instead of git reset.\nSee git docs."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Display last git commit comment\nOften during a commit ($ git -commit -m \"\"), I wish to read my last comment to remember what progress I have made. Is there an easy way to directly access the last commit message through command-line? (I'm using Windows.)"
},
{
"role": "assistant",
"content": "git show\n\nis the fastest to type, but shows you the diff as well.\ngit log -1\n\nis fast and simple.\ngit log -1 --pretty=%B\n\nif you need just the commit message and nothing else."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to push changes to github without pull\n\nI developed a project that was been developed by another developers. I sent my code to the previous developers to make changes in their code but they said that they have never worked with git, so they added changes to the project and it is now the actual version but not under version control.\nSo, I already have commits in github and I need to push this new version.\nWhat I did:\n\ngit init\ngit remote add origin\ngit add .\ngit push origin master\n\nBut there is an problem: I can't push new changes before updating the local repo. If I update my repo it will return all the files that the previous developers have deleted.\nHow do I push the current version without pulling data from git?"
},
{
"role": "assistant",
"content": "You can do a forced push.\ngit push -f origin branch_name\n\nThe forced push will erase all commit history of the remote repository's branch, and replace it to your branch.\nCheck the answers for doing forced pushes in \"How do I properly force a Git push?\". Forced push can have unintended consequences as mentioned in \"Git: How to ignore fast forward and revert origin [branch] to earlier commit?\", so check for the same.\nThe forced push will be an incorrect way to push stuff in your case, since you already have previous commits on GitHub, and this will erase the commit history for previous commits.\nHence, to preserve your commit history, you can do the following things:\nRemove all the files from the git repository, and then add the new files here, and then commit the updated files:\ngit rm -rf .\ncp -r path/to/updated/code/* .\ngit add .\n\nDoing a git status now will tell you which files the other developers modified, and a git diff will show what modifications are there. \nIf a file has remain unchanged, then git rm and git add will nullify the effect of each other.\nThe files which those developers deleted remain deleted since you ran the git rm for them but no git add.\nOnce you are satisfied that these indeed are the changes, you can commit using\ngit commit -m \"Merged new code\"\n\nPotential gotchas:\n\nOnly the file mode has changed (755 <=> 644) - depending on what code the other developers sent you.\nYou will lose your .gitignore file with git rm -rf . (and similarly .gitattributes and other such files). Reset HEAD for each such files using git reset HEAD .gitignore before the commit.\nDifferent line terminating characters (in case different development environments are being used), So check for them appropriately."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-patch-id"
},
{
"role": "assistant",
"content": "Compute unique ID for a patch"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to set environmental variables properly Gitlab CI/CD and Docker\n\nI am new to Docker and CI/CD with Gitlab CI/CD. I have .env file in the root directory of my Django project which contains my environmental variable e.g SECRET_KEY=198191891. The .env file is included in .gitignore. I have set up these variables in Gitlab settings for CI/CD. However, the environment variables set in Gitlab CI/CD settings seem to be unavailable\nAlso, how should the Gitlab CI/CD automation process create a user and DB to connect to and run the tests? When creating the DB and user for the DB on my local machine, I logged into the container docker exec -it <postgres_container_name> /bin/sh and created Postgres user and DB. \nHere are my relevant files.\ndocker-compose.yml\nversion: \"3\"\nservices:\n postgres:\n image: postgres\n ports:\n - \"5432:5432\"\n volumes:\n - pgdata:/var/lib/postgresql/data/\n web:\n build: .\n command: /usr/local/bin/gunicorn writer.wsgi:application -w 2 -b :8000\n environment:\n DEBUG: ${DEBUG}\n DB_HOST: ${DB_HOST}\n DB_NAME: ${DB_NAME}\n DB_USER: ${DB_USER}\n DB_PORT: ${DB_PORT}\n DB_PASSWORD: ${DB_PASSWORD}\n SENDGRID_API_KEY: ${SENDGRID_API_KEY}\n AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}\n AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}\n AWS_STORAGE_BUCKET_NAME: ${AWS_STORAGE_BUCKET_NAME}\n depends_on:\n - postgres\n - redis\n expose:\n - \"8000\"\n volumes:\n - .:/writer-api\n redis:\n image: \"redis:alpine\"\n celery:\n build: .\n command: celery -A writer worker -l info\n volumes:\n - .:/writer-api\n depends_on:\n - postgres\n - redis\n celery-beat:\n build: .\n command: celery -A writer beat -l info\n volumes:\n - .:/writer-api\n depends_on:\n - postgres\n - redis\n nginx:\n restart: always\n build: ./nginx/\n ports:\n - \"80:80\"\n depends_on:\n - web\nvolumes:\n pgdata:\n\n.gitlab-ci.yml\nimage: tmaier/docker-compose:latest\n\nservices:\n - docker:dind\n\nbefore_script:\n - docker info\n - docker-compose --version\n\nstages:\n - build\n - test\n - deploy\n\nbuild:\n stage: build\n script:\n - echo \"Building the app\"\n - docker-compose build\n\ntest:\n stage: test\n variables:\n script:\n - echo \"Testing\"\n - docker-compose run web coverage run manage.py test\n\ndeploy-staging:\n stage: deploy\n only:\n - develop\n script:\n - echo \"Deploying staging\"\n - docker-compose up -d\n\ndeploy-production:\n stage: deploy\n only:\n - master\n script:\n - echo \"Deploying production\"\n - docker-compose up -d\n\nHere are my settings for my variables\n\nHere is my failed pipeline job"
},
{
"role": "assistant",
"content": "The SECRET_KEY variable will be available to all your CI jobs, as configured. However, I don't see any references to it in your Docker Compose file to pass it to one or more of your services. For the web service to use it, you'd map it in like the other variables you already have.\n web:\n build: .\n command: /usr/local/bin/gunicorn writer.wsgi:application -w 2 -b :8000\n environment:\n SECRET_KEY: ${SECRET_KEY}\n DEBUG: ${DEBUG}\n …\n\nAs for creating the database, you should wrap up whatever you currently run interactively in the postgres container in a SQL file or shell script, and then bind-mount it into the container's initialization scripts directory under /docker-entrypoint-initdb.d. See the Initialization scripts section of the postgres image's description for more details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Using the same deploy key for multiple github projects\nGithub does not allow the same ssh deploy key to be used for more than one project, which would be very useful in some cases (e.g. CI server dealing with project with private sub-modules). I've seen various threads that seem to say that this limitation is there for 'security reasons', but I'm yet to see a convincing explanation about exactly what risk that would raise.\nNote that the fact that Github doesn't allow Account Level keys to be reused makes sense (two users shouldn't share keys). It is only the restriction on Deploy Keys that I'm questioning.\nAnd to be clear, I'm not looking for workarounds (create a dummy user, use multiple keys, ...), but only for a plausible explanation for this limitation on Deploy Keys.\nRelated threads:\n\nOne showing a workaround\nOne discussing the issue but not really going anywhere"
},
{
"role": "assistant",
"content": "Unfortunately, this is a scenario where github just misinterprets the distinction between a key pair and an account or project.\nSince a key pair is used for authentication and authorization, it is effectively an identity. Github accounts are another identity. Connecting github accounts to key pairs effecticely establishes a 1:N mapping between github account based identities and key pair identities.\nConversely, github enforces a 1:N mapping of projects to key pair based identities. The real world analogue is that there is a door granting access to the project that can be unlocked by many different people. But once any of them gets a key to the door, they cannot get any other keys for any other doors, ever again.\nIt makes sense not to re-use keys often from the perspective of containing breaches if a key gets compromised. But that's just a good administration policy. It doesn't make much sense to prevent a key from being used more than once on principle. That there are some keys for some doors that are never re-used, well, again that's down to policy.\n\nA slightly more complex view is to illustrate key pairs as roles. You can possess many key pairs, and therefore inhabit many roles. The private key authenticates you for the role.\nGithub's deploy key mapping to projects states that a role can never encompass more than one task. That's rarely realistic.\nNone of which changes what github allows, of course."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-add - Add file contents to the index -i --interactive"
},
{
"role": "assistant",
"content": "Add modified contents in the working tree interactively to\nthe index. Optional path arguments may be supplied to limit\noperation to a subset of the working tree. See “Interactive\nmode” for details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker <tree-ish>"
},
{
"role": "assistant",
"content": "Indicates a tree, commit or tag object name. A\ncommand that takes a <tree-ish> argument ultimately wants to\noperate on a <tree> object but automatically dereferences\n<commit> and <tag> objects that point at a <tree>."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-worktree - Manage multiple working trees remove"
},
{
"role": "assistant",
"content": "Remove a worktree. Only clean worktrees (no untracked files and no\nmodification in tracked files) can be removed. Unclean worktrees or ones\nwith submodules can be removed with --force . The main worktree cannot be\nremoved."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-send-email - Send a collection of patches as emails --smtp-pass[=<password>]"
},
{
"role": "assistant",
"content": "Password for SMTP-AUTH. The argument is optional: If no\nargument is specified, then the empty string is used as\nthe password. Default is the value of sendemail.smtpPass ,\nhowever --smtp-pass always overrides this value. Furthermore, passwords need not be specified in configuration files\nor on the command line. If a username has been specified (with --smtp-user or a sendemail.smtpUser ), but no password has been\nspecified (with --smtp-pass or sendemail.smtpPass ), then\na password is obtained using git-credential ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitLab CI with r testthat package\n\nCan anyone run testthat tests for a minimal R package using GitLab.com continuous integration tools? \nMy attempt:\nhttps://gitlab.com/djchapman/CI_example\nThis is the .gitlab-CI.yml text I am using, \nimage: rocker/rstudio\ntest:\n script:\n - R -e 'install.packages(c(\"devtools\", \"testthat\"))'\n - R CMD build . --no-build-vignettes --no-manual\n - PKG_FILE_NAME=$(ls -1t *.tar.gz | head -n 1)\n - R CMD check \"${PKG_FILE_NAME}\" --no-build-vignettes --no-manual\n - R -e 'devtools::test()'\n\nIt is adapted from this website. I realize that devtools has dependencies which may need to be included as packages are installed, and I tried that, but the libraries for git2r didn't seem to install correctly, and now I wonder if I'm going about it wrong. Thanks."
},
{
"role": "assistant",
"content": "You do not need to run the tests via devtools since R CMD check does that already. The following should work:\nimage: rocker/rstudio\ntest:\n script:\n - R -e 'install.packages(c(\"testthat\"))'\n - R CMD build . --no-build-vignettes --no-manual\n - PKG_FILE_NAME=$(ls -1t *.tar.gz | head -n 1)\n - R CMD check \"${PKG_FILE_NAME}\" --no-build-vignettes --no-manual\n\nAlternatively you could use an image that allows for binary installs:\nimage: rocker/r-base\ntest:\n script:\n - apt-get update\n - apt-get install --yes --no-install-recommends r-cran-testthat r-cran-devtools\n - R -e \"devtools::install_deps()\"\n - R CMD build . --no-build-vignettes --no-manual\n - PKG_FILE_NAME=$(ls -1t *.tar.gz | head -n 1)\n - R CMD check \"${PKG_FILE_NAME}\" --no-build-vignettes --no-manual\n\nThis is useful if you have dependencies that have not been packaged for Debian, or if you don't want to update your CI script when you add a new dependency."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Forgot to create new branch. How to transfer changes to new branch\n\nthis happens to every developer time-to-time. You start coding a new feature and forget to branch first locally.\nSo if that happens is there a way I can say hey, transfer these uncommitted (or committed - yea I know those are both two scenarios which I'd like to cover with this) to a new branch for me locally so I don't have to back them out and copy my changes to a new branch to be able to carry on my way?"
},
{
"role": "assistant",
"content": "If you haven't commited your changes yet, you can switch to a new branch prior to committing.\ngit checkout -b my-new-branch\n\nThis will create a new branch called my-new-branch and immediately check it out."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to show date and time of a commit by hash\nI used git reflog to identify a hash for when I created a particular branch. I got the hash of fe1ddcdef. I haven't pushed this branch to the remote yet. I'm now trying to find the date and time for when fe1ddcdef took place. git reflog only shows me:\nfe1ddcdef HEAD@{11}: checkout: moving from master to handoff\nwhich does not have a date or time.\ngit log is far too verbose, since it contains commits from all of my colleagues and I can't easily find the needle of fe1ddcdef in that haystack.\nHow can I simply find the date and time of commit fe1ddcdef?"
},
{
"role": "assistant",
"content": "Simply use :\ngit show fe1ddcdef\n\n… to display the content of the commit. Actually, once you have any expression that identifies a commit object, you can use it in all places that require a revision. These expressions can be an hexadecimal hash (even partial), a branch name or a tag name. It can also be one of these, associated to one or many operators such as \"^\", or \"~\", or \"@\".\nThis means that you can also use git log fe1ddcdef to get the full history of the branch starting from this point.\nIf you want to get only date and time of it and nothing else, you can type :\ngit show --no-patch --no-notes --pretty='%cd' fe1ddcdef\n\nReplace '%cd' by '%h %cd %s' to add hash summary and commit's subject message."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git count files in the staged index\nI'm trying to figure out how to easily count the files in my uncommitted index.\nI've tried:\ngit status | grep '#' | wc -l\n\nbut there are a few lines that start with # that don't represent changed files. Anyone got anything better? Figured there had to be a flag for git status to do this.\nEven tools like GitX don't easily allow you to select the staged files/directories and see how many of them there are."
},
{
"role": "assistant",
"content": "If you want something a script can use:\ngit diff --cached --numstat | wc -l\nIf you want something human readable:\ngit diff --cached --stat"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I create a table of content in GitLab wiki?\n\nI am a big fan of the __TOC__ that creates a table of content on a Wikimedia page.\nWhenever you write things like this on a Wikimedia page:\nThis is a page for my project\n\n## Credits ##\n\nbla bla\n\n## License ##\n\nbla bla\n\n__TOC_ automagically creates a table of content that allows you to navigate through inner links of the page.\nI noticed that this is somehow possible in GitHub wiki pages: How do I create some kind of table of content in GitHub wiki? by using different tricks.\nHowever, I miss this feature in GitLab wiki pages. Does it provide such functionality?"
},
{
"role": "assistant",
"content": "So this exists! I finally found a Merge Request in in the GitLab Community Edition: Replace Gollum [[_TOC_]] tag with result of TableOfContentsFilter\nAs its name describes, to have a table of contents you need to write the following:\n[[_TOC_]]\n\nAll together, you can write something like:\nThis is a page for my project\n\n[[_TOC_]]\n\n## Credits\n\nbla bla\n\n## License\n\nbla bla\n\nand will show like this:\n\n\n\nThis is available from the GitLab 8.6 release as described in its milestone."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "\"openssl/ssl.h: No such file or directory\" during Installation of Git\nTrying to install git on the Unix and Linux machines based on the instructions on Installing Git blog, and it is failing with the below error \nmake prefix=/usr/local all\nGIT_VERSION = 1.8.3.4\n * new build flags\n CC credential-store.o\nIn file included from cache.h:4,\n from credential-store.c:1:\ngit-compat-util.h:221:25: warning: openssl/ssl.h: No such file or directory\ngit-compat-util.h:222:25: warning: openssl/err.h: No such file or directory\nIn file included from credential-store.c:1:\ncache.h:11:21: warning: openssl/sha.h: No such file or directory\ncache.h:19:18: warning: zlib.h: No such file or directory\nIn file included from credential-store.c:1:\ncache.h:21: syntax error before \"z_stream\"\ncache.h:21: warning: no semicolon at end of struct or union\ncache.h:28: syntax error before '}' token\ncache.h:28: warning: type defaults to `int' in declaration of `git_zstream'\ncache.h:28: warning: data definition has no type or storage class\ncache.h:30: syntax error before '*' token\ncache.h:31: syntax error before '*' token\ncache.h:32: syntax error before '*' token\ncache.h:33: syntax error before '*' token\ncache.h:35: syntax error before '*' token\ncache.h:36: syntax error before '*' token\ncache.h:37: syntax error before '*' token\ncache.h:38: syntax error before '*' token\ncache.h:39: syntax error before '*' token\ncache.h:40: syntax error before '*' token\ncache.h:41: syntax error before '*' token\ncache.h:42: syntax error before '*' token\ncache.h:769: syntax error before '*' token\nmake: *** [credential-store.o] Error 1\n\nI know this is because of the missing libraries for openssl, but I am unable to get these libraries.\nI do not have yum/apt-get on my machines to run the below commands as suggested:\n$ yum install curl-devel expat-devel gettext-devel \\\n openssl-devel zlib-devel\n\n$ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext \\\n libz-dev libssl-dev\n\nWhat do I do get these libraries on these machines. These machines do not have internet access, I can do a scp if required. Any suggestions."
},
{
"role": "assistant",
"content": "this answer worked just fine for me\nhttps://stackoverflow.com/a/3016986/5837509\njust do sudo apt-get install libssl-dev"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I tell if one commit is a descendant of another commit?\nWith Git, how can I tell if one commit in my branch is a descendant of another commit?"
},
{
"role": "assistant",
"content": "From Git 1.8.0, this is supported as an option to merge-base:\ngit merge-base --is-ancestor <maybe-ancestor-commit> <descendant-commit>\n\nFrom the man page: \n\n--is-ancestor\nCheck if the first is an ancestor of the second ,\n and exit with status 0 if true, or with status 1 if not. Errors are\n signaled by a non-zero status that is not 1.\n\nFor example:\ngit merge-base --is-ancestor origin/master master; echo $?"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-bundle - Move objects and refs by archive list-heads <file>"
},
{
"role": "assistant",
"content": "Lists the references defined in the bundle. If followed by a\nlist of references, only references matching those given are\nprinted out. If file is - , the bundle is read from stdin."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-shortlog - Summarize git log output -n --numbered"
},
{
"role": "assistant",
"content": "Sort output according to the number of commits per author instead\nof author alphabetic order."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options format.suffix"
},
{
"role": "assistant",
"content": "The default for format-patch is to output files with the suffix .patch . Use this variable to change that suffix (make sure to\ninclude the dot if you want it)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rm - Remove files from the working tree and from the index -n --dry-run"
},
{
"role": "assistant",
"content": "Don’t actually remove any file(s). Instead, just show\nif they exist in the index and would otherwise be removed\nby the command."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-archive - Create an archive of files from a named tree --remote=<repo>"
},
{
"role": "assistant",
"content": "Instead of making a tar archive from the local repository,\nretrieve a tar archive from a remote repository. Note that the\nremote repository may place restrictions on which sha1\nexpressions may be allowed in <tree-ish> . See git-upload-archive for details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge-base - Find as good common ancestors as possible for a merge --independent"
},
{
"role": "assistant",
"content": "Instead of printing merge bases, print a minimal subset of\nthe supplied commits with the same ancestors. In other words,\namong the commits given, list those which cannot be reached\nfrom any other. This mimics the behavior of git show-branch\n--independent ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-submodule - Initialize, update or inspect submodules"
},
{
"role": "assistant",
"content": "DESCRIPTION Inspects, updates and manages submodules. For more information about submodules, see gitsubmodules ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-svn - Bidirectional operation between a Subversion repository and Git"
},
{
"role": "assistant",
"content": "DESCRIPTION git svn is a simple conduit for changesets between Subversion and Git.\nIt provides a bidirectional flow of changes between a Subversion and a Git\nrepository. git svn can track a standard Subversion repository,\nfollowing the common \"trunk/branches/tags\" layout, with the --stdlayout option.\nIt can also follow branches and tags in any layout with the -T/-t/-b options\n(see options to init below, and also the clone command). Once tracking a Subversion repository (with any of the above methods), the Git\nrepository can be updated from Subversion by the fetch command and\nSubversion updated from Git by the dcommit command."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Including js from raw.github.com\nI have a github.com demo page that is linking to https://raw.github.com/.../master/.../file.js so that I don't need to always copy the .js file over to the gh-pages branch every time it's changed. This works in every browser except IE which complains:\n\nSEC7112: Script from https://raw.github.com/cwolves/jQuery-iMask/master/dist/jquery-imask-min.js was blocked due to mime type mismatch\n\nThis complaint is coming from the fact that the file is transferred with:\nX-Content-Type-Options: nosniff\nContent-Type: text/plain\n\nwhich I can't change.\nAnyone have any ideas how to accomplish this same thing? Somehow allowing me to link to the file in the master branch without having to always push it to the gh-pages branch?\nActual page: http://cwolves.github.com/jQuery-iMask/\n(Minor update -- I changed the gh-pages in this exact instance to include the .js file, so IE is no longer broken, but would still like any feedback :))"
},
{
"role": "assistant",
"content": "You can try using https://rawgit.com/ service.\nJust replace raw.github.com with rawgit.com\nUPDATE \nThe Rawgit service (former Rawgithub) has been shutdown. \n\nRawGit has reached the end of its useful life\n October 8, 2018\nGitHub repositories that served content through RawGit within the last month will continue to be served until at least October of 2019. URLs for other repositories are no longer being served.\nIf you're currently using RawGit, please stop using it as soon as you can."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options difftool.trustExitCode"
},
{
"role": "assistant",
"content": "Exit difftool if the invoked diff tool returns a non-zero exit status. See the --trust-exit-code option in git-difftool for more details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git subtree pull says that the working tree has modifications, but git status says it doesn't. What gives?\nIf I do this in one of my repositories:\ngit subtree pull --prefix=frameworks/AquaticPrime --squash AquaticPrime\n\nI get this:\nWorking tree has modifications. Cannot add.\n\nIf I do this (in the same place, of course):\ngit status\n\nI get this:\n# On branch master\nnothing to commit (working directory clean)\n\nI'm not quite sure what's going on here. The git status command implies that I don't have modifications, so I'm assuming that the git subtree pull is referring to modifications in a different branch related to the subtree, but it's not entirely clear.\nCan anyone provide enlightenment?"
},
{
"role": "assistant",
"content": "I just had the same problem.\nFrom GIT source, error is thrown when command git diff-index HEAD returns result, even if git status says working tree is clean.\nTo avoid this error, in my case, I re-checkout the current branch of working tree , and everything seems OK : git checkout <branch>\nIt's a bit confused, but if someone can explain why ..."
}
] |
[
{
"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": "git-grep - Print lines matching a pattern --textconv"
},
{
"role": "assistant",
"content": "Honor textconv filter settings."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git lfs clone vs git clone\nIf I have git lfs installed on the client and I run:\ngit clone\n\nis this equivalent to \ngit lfs clone\n\nor will different results occur?\nThank you!\nThe answer to this question: \nCan one clone a Git LFS repo without installing Git LFS?\nseems to imply that git clone will work if you have git lfs installed. It isn't clear if this means that the two commands will work the same. Unfortunately my reputation is too low to comment and ask."
},
{
"role": "assistant",
"content": "I updated the git client from 2.10.0 to 2.16.1 and it now says:\nWARNING: 'git lfs clone' is deprecated and will not be updated\nwith new flags from 'git clone'\n\n'git clone' has been updated in upstream Git to have comparable\nspeeds to 'git lfs clone'.\n\nI suppose the answer is that git lfs clone is now pretty much the same thing as git clone and the separate command will disappear."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How does Git deal with binary files?\nDo I have to do something to tell Git whether some files are binary (like in Subversion)? Or, can Git handle binary data automatically?\nIf I change the binary file, so that I have 100 binary revisions, will git just store all 100 versions individually in the repository?\nWhat are submodules for with git?"
},
{
"role": "assistant",
"content": "Git can usually detect binary files automatically.\nNo, Git will attempt to store delta-based changesets if it's less expensive to (not always the case).\nSubmodules are used if you want to reference other Git repositories within your project."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-instaweb"
},
{
"role": "assistant",
"content": "Instantly browse your working repository in gitweb"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git - Ignore files during merge\nI have a repo called myrepo on the remote beanstalk server.\nI cloned it to my local machine. Created two additional branches: staging and dev.\nPushed these branches to remote as well.\nNow:\n local remote server\n -------------------------------------------------------- \n master ==> Pushes to `master` ==> deployed to `prod`\n staging ==> Pushes to `staging` ==> deployed to `staging`\n dev ==> Pushes to `dev` ==> deployed to `dev`\n\nI have a file called config.xml which is different on each branch.\nI want to ignore this file only during merges. But I want this to be included when I checkout or commit from/to the repo branch.\nThe reason I want this is, we have a deploy script that pulls (checkout) the specific branch and deploys on the respective servers. So we need config.xml file of that specific branch go into the specific server as indicated above when deployed.\nI guess .gitignore wont work. What are the other options? Note that the ignored file should be part of checkout and commit, which is important. it should be ignored only during merges.\nThanks!"
},
{
"role": "assistant",
"content": "I got over this issue by using git merge command with the --no-commit option and then explicitly removed the staged file and ignore the changes to the file.\nE.g.: say I want to ignore any changes to myfile.txt I proceed as follows:\ngit merge --no-ff --no-commit <merge-branch>\ngit reset HEAD myfile.txt\ngit checkout -- myfile.txt\ngit commit -m \"merged <merge-branch>\"\n\nYou can put statements 2 & 3 in a for loop, if you have a list of files to skip."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I get notifications for commits to a GitHub repository?\n\nI'd like to know what kind of commits are being made to the Lithium framework so I can update (or rollback) when there is something major. \nI'm already watching the repository, but from what I've been able to find, that only shows updates on the github dashboard."
},
{
"role": "assistant",
"content": "Subscribe to Github's RSS feed!\nChoose your news feed (all watched repos), or only Lithium's commit history.\nRSS are made for that ;-)\nPS: I don't see how can you find that useful since there is a couple of commits made each day on various branches, some small typo fixes, others fix bugs, and others introduce new things..."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git clone verbose output?\nI have to clone a couple of big repos in my Dockerfile. It really can take an hour to clone a single repo and I want to see standard Git progress output to understand what's going on.\nHowever, when Git is started from the Dockerfile, I see no git clone output whatsoever. The only thing printed to console is:\nCloning into '/root/lib/opencv'...\nPOST git-upload-pack (gzip 2052 to 1062 bytes)\n\nand then just a silence. While, usually, I expect something like this:\nCloning into 'opencv'...\nPOST git-upload-pack (gzip 2040 to 1052 bytes)\nremote: Counting objects: 158365, done.\nReceiving objects: 8% (12670/158365), 2.32 MiB | 255.00 KiB/s\n... and so on ...\n\nHow to enable git verbose output in docker build? Maybe I have to start some interactive mode?"
},
{
"role": "assistant",
"content": "As far as I understand it's not the issue of Docker, but the issue of git. By default, git shows progress if you are in an interactive console.\nIf you are not, you could specify additional parameters to git clone to output progress to stdout:\ngit clone --progress --verbose ....."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission --zero-commit"
},
{
"role": "assistant",
"content": "Output an all-zero hash in each patch’s From header instead\nof the hash of the commit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Diff - How do I revert selected lines or chunks\nIn Git GUI I can select parts of a diff and stage just those lines or chunks. How would I do the opposite, as in roll back changed lines in a file. Usually these are accidental white space changes I just want to revert out but still stage/commit other parts of the same file."
},
{
"role": "assistant",
"content": "Stage the parts you want with git add -p, then discard (git checkout -- filename) the unstaged changes.\nUpdate for Git 1.6.5+\nIn version 1.6.5, Git learned to checkout with a -p/--patch flag. You can discard chunks in one step with git checkout -p -- filename.\nFrom the docs:\n\nInteractively select hunks in the difference between the <tree-ish> (or the index, if unspecified) and the working tree. The chosen hunks are then applied in reverse to the working tree (and if a <tree-ish> was specified, the index).\nThis means that you can use git checkout -p to selectively discard edits from your current working tree."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-cat-file - Provide contents or details of repository objects --batch --batch=<format>"
},
{
"role": "assistant",
"content": "Print object information and contents for each object provided\non stdin. May not be combined with any other options or arguments\nexcept --textconv , --filters , or --use-mailmap . When used with --textconv or --filters , the input lines\nmust specify the path, separated by whitespace. See the section BATCH OUTPUT below for details. When used with --use-mailmap , for commit and tag objects, the\ncontents part of the output shows the identities replaced using the\nmailmap mechanism, while the information part of the output shows\nthe size of the object as if it actually recorded the replacement\nidentities."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-am - Apply a series of patches from a mailbox -S[<keyid>] --gpg-sign[=<keyid>] --no-gpg-sign"
},
{
"role": "assistant",
"content": "GPG-sign commits. The keyid argument is optional and\ndefaults to the committer identity; if specified, it must be\nstuck to the option without a space. --no-gpg-sign is useful to\ncountermand both commit.gpgSign configuration variable, and\nearlier --gpg-sign ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitHub Api download zip or tarball link\nThere was a good link here about how the zip/tarball string is created\nWhen I download a zip from github, what is the hex string at the end of the file name represent?\nBut I'm looking at the GitHub APIv3 and I was curious if I'm missing something.\n\nIs there a way to get the zip/tarball link via an API call?\nIf not, is there a way I can build that string without using the git binary or library? Meaning, can I use various API calls to pull out th data a need and assemble to URL I need?\n\nI know the second question is a little unreasonable for stackoverflow and this is a bit of a fun project for me, so I would prefer on the second question if you just kind of nudged me in the right direction as opposed to throwing down a code snippet. Or just told me if it was possible."
},
{
"role": "assistant",
"content": "You can wget your way out of the GitHub repo to get a tar file (archive):\nwget --no-check-certificate https://github.com/User/repo/archive/master.tar.gz\n\n# better, if the certificate authorities are present:\nwget https://github.com/User/repo/archive/master.tar.gz\n\nwill get you a file named 'master' from the user 'User''s repo 'repo'.\nThe updated V3 API url is:\nhttps://api.github.com/repos/User/repo/:archive_format/:ref\n#\n# two possibilities for fomat:\nhttps://api.github.com/repos/User/repo/tarball/master\nhttps://api.github.com/repos/User/repo/zipball/master\n\n# from github example:\n$curl -L https://api.github.com/repos/octokit/octokit.rb/tarball > octokit.tar.gz\n\nYou can then tar xpvf master, getting the full archive. It will create a directory following the naming convention described in the question you mentioned.\nNo Git binary is needed to get an archive from GitHub, thanks to their download service \"Nodeload\".\n\nligemer proposed in an edit the following example:\nEdit 2016-08-25 - Shell Example With Wget, Variables, and Untar:\n#!/bin/bash -ex\n\n# arguments:\n# token = $1\n# organization = $2\n# repo name = $3\n# branch = $4\n\nwget --header=\"Authorization: token ${1}\" --header=\"Accept:application/vnd.github.v3.raw\" -O - https://api.github.com/repos/${2}/${3}/tarball/${4} | tar xz\n\nCall via:\n$ scriptName.sh token my-organization site.example master\n\nThe command above will download and extract the GitHub folder to the same directory as the script.\n\nDiogo Quintela suggests in the comments:\n\nThe following example allow the download, extract and cut the top level directory\n\ncurl -L https://api.github.com/repos/octokit/octokit.rb/tarball | tar xz --strip=1"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "No such keg: /usr/local/Cellar/git\nI have been struggling with this for a few hours. I am on a Mac using Yosemite. I had homebrew installed, and was using git just fine. I tried doing $git add -i and I got this error:\n\nCan't locate Git.pm in @INC (@INC contains:\n\nSo I followed the instructions here:\nCan't locate Git.pm in @INC\n$brew uninstall git worked fine, but after I tried to $brew install git I've been stuck in a terrible cycle.\n% brew install git\n\nError: git-git already installed\nTo install this version, first `brew unlink git'\n% brew unlink git\nError: No such keg: /usr/local/Cellar/git\n% brew link git\nError: No such keg: /usr/local/Cellar/git\n% git --version\ngit version 1.9.3 (Apple Git-50)\n% brew upgrade git\n==> Upgrading 1 outdated package, with result:\ngit 2.2.2\nError: /usr/local/Library/LinkedKegs/git is not a valid keg\n% brew install git\nError: git-git already installed\nTo install this version, first `brew unlink git'\n%\n\nI just want to get homebrew & git back to normal and linked to the correct repo again. I'm really rough around the edges at this stuff, so any help would be greatly appreciated!"
},
{
"role": "assistant",
"content": "Give another go at force removing the brewed version of git\nbrew uninstall --force git\n\nThen cleanup any older versions and clear the brew cache\nbrew cleanup -s git\n\nRemove any dead symlinks\nbrew cleanup --prune-prefix\n\nThen try reinstalling git\nbrew install git\n\nIf that doesn't work, I'd remove that installation of Homebrew altogether and reinstall it. If you haven't placed anything else in your brew --prefix directory (/usr/local by default), you can simply rm -rf $(brew --prefix). Otherwise the Homebrew wiki recommends using a script at https://gist.github.com/mxcl/1173223#file-uninstall_homebrew-sh"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitfaq - Frequently asked questions about using Git What does http.postBuffer really do?"
},
{
"role": "assistant",
"content": "This option changes the size of the buffer that Git uses when pushing\ndata to a remote over HTTP or HTTPS. If the data is larger than this\nsize, libcurl, which handles the HTTP support for Git, will use chunked\ntransfer encoding since it isn’t known ahead of time what the size of\nthe pushed data will be. Leaving this value at the default size is fine unless you know that either the\nremote server or a proxy in the middle doesn’t support HTTP/1.1 (which\nintroduced the chunked transfer encoding) or is known to be broken with chunked\ndata. This is often (erroneously) suggested as a solution for generic push\nproblems, but since almost every server and proxy supports at least HTTP/1.1,\nraising this value usually doesn’t solve most push problems. A server or proxy\nthat didn’t correctly support HTTP/1.1 and chunked transfer encoding wouldn’t be\nthat useful on the Internet today, since it would break lots of traffic. Note that increasing this value will increase the memory used on every relevant\npush that Git does over HTTP or HTTPS, since the entire buffer is allocated\nregardless of whether or not it is all used. Thus, it’s best to leave it at the\ndefault unless you are sure you need a different value."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-stash - Stash the changes in a dirty working directory away save [-p|--patch] [-S|--staged] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [<message>]"
},
{
"role": "assistant",
"content": "This option is deprecated in favour of git stash push . It\ndiffers from \"stash push\" in that it cannot take pathspec.\nInstead, all non-option arguments are concatenated to form the stash\nmessage."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-apply - Apply a patch to files and/or to the index --cached"
},
{
"role": "assistant",
"content": "Apply the patch to just the index, without touching the working\ntree. If --check is in effect, merely check that it would\napply cleanly to the index entry."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options mergetool.meld.useAutoMerge"
},
{
"role": "assistant",
"content": "When the --auto-merge is given, meld will merge all non-conflicting\nparts automatically, highlight the conflicting parts, and wait for\nuser decision. Setting mergetool.meld.useAutoMerge to true tells\nGit to unconditionally use the --auto-merge option with meld .\nSetting this value to auto makes git detect whether --auto-merge is supported and will only use --auto-merge when available. A\nvalue of false avoids using --auto-merge altogether, and is the\ndefault value."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Does github allow pre-receive hooks?\n\nDoes GitHub allow for pre-receive or update hooks? \nWhat I would be looking to do is to prevent the primary branches from being pushed to (i.e. master, hotfix, develop) and require that they be merged via a GitHub pull request. This is a private repo so GitHub style forking is not an option. \nAny advice on how to accomplish this would be of great help."
},
{
"role": "assistant",
"content": "Only people that you have listed a 'collaborators' can push to a Github hosted repository. See the repository's 'admin' page to add collaborators. Everybody else needs to submit a 'pull request' to get their additions accepted by the repository's administrator. See Github Access Permissions. (There aren't per-branch access permissions.) So, in order to accomplish your goal, you don't need hooks; what you need is already built in. \nTwo Notes: \n\nprivate Github repositories can have multiple contributors \nit would be unusual for Github to support pre-receive hooks (or any other server hooks) given that hooks contains arbitrary code."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options submodule.fetchJobs"
},
{
"role": "assistant",
"content": "Specifies how many submodules are fetched/cloned at the same time.\nA positive integer allows up to that number of submodules fetched\nin parallel. A value of 0 will give some reasonable default.\nIf unset, it defaults to 1."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to rename main branch to master on a Github repository\nI'd like to create a github repository and rename the main branch to master.\nIf I create a new repository on github and do\ngit init\ngit add README.md\ngit commit -m \"first commit\"\ngit branch -M master\n\nI get\nerror: refname refs/heads/master not found\nfatal: Branch rename failed\n\nso I seem to somehow not understand git well enough. What's the issue here?\n\nI must have gotten confused when I was playing around with the above. The following happens:\ngit init create the repository\ngit add README.md adds the file\ngit commit -m \"first commit\" adds the file to the master branch since that still default for git\nso I never have to rename it in the first place. Now Github uses the default main, which can be changed in settings -> repositories on github.com"
},
{
"role": "assistant",
"content": "Using the -m option (move/rename) instead of -M with the name of the branch you're renaming from, here main, will work. Then you can push your renamed branch and maintain your reflog as well.\ngit branch -m main master\ngit push -u origin master\n\nI also wrote a blog post with more details which can in case the repo was cloned by someone else before renaming the branch. You can check it out here."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "merge one local branch into another local branch\nI have multiple branches which are branched off the master (each in a separate subdirectory).\n\nnewdevBranch: new development, not yet completely finished\nhotFixBranch: hotfix for a problem, but still under test\nmessAroundBranch: mess around branch, which I will not restore\n\nBefore testing of the hotfix is finished I would like to have the code already available in newdevBranch, so I can continue developing with the fix in place.\n(But since my experience with git is not that much I first started to play around with merge in a messAroundBranch, especially created to mess around in, before I mess up either newdevBranch or hotFixBranch)\nIn my messAroundBranch I first tried the following:\ngit merge feature/newdevBranch\n\nbut this gave the following error:\nfatal: 'feature/newdevBranch' does not point to a commit\n\nI next did a commit -a in my newdevBranch and tried again, but it keeps giving the same error.\nWhat am I doing wrong? What should I do to merge the code from - in this case - newdevBranch with messAroundBranch?"
},
{
"role": "assistant",
"content": "newdevBranch: new development, not yet completely finished\nhotFixBranch: hotfix for a problem, but still under test\nmessAroundBranch: mess around branch, which I will not restore\nFirst, checkout to your messAroundBranch:\ngit checkout messAroundBranch\n\nThen merge the newdevBranch into messAroundBranch:\ngit merge newdevBranch\n\nAnd if you want the updated commits of newdevBranch on hotFixBranch, you are probably looking for git rebase\ngit checkout hotFixBranch\ngit rebase newdevBranch\n\nThis will update your hotFixBranch with the latest updates of newDevBranch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-ls-files - Show information about files in the index and the working tree -k --killed"
},
{
"role": "assistant",
"content": "Show untracked files on the filesystem that need to be removed\ndue to file/directory conflicts for tracked files to be able to\nbe written to the filesystem."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Unable to authenticate with Git Bash to Visual Studio Team Services\nI am unable to run any commands against my remote repository at Visual Studio Team Services (VSTS) because authentication fails.\nI am able to do pulls, etc. through Visual Studio. But only through Visual Studio. Not through Git Bash, or any other tool like SourceTree."
},
{
"role": "assistant",
"content": "You need to enable Alternate Authentication Credentials if you want to use other Git clients outside of Visual Studio...\nTo set up alternate creds in Visual Studio Team Services (VSTS), click on your name/icon on the top right -> Security -> Alternate Authentication Credentials \nEdit: Add more details about this from VSTS (taken from the alternate credentials screen)...\n\nALTERNATE AUTHENTICATION CREDENTIALS\nSome applications that work outside the browser (including Team\n Explorer Everywhere command line client and the git-tf utility)\n require basic authentication credentials. Other applications do not\n properly handle using an e-mail address for the user name during\n authentication.\nTo work with these applications, you need to enable alternate\n credentials, set a password, and optionally set a secondary user name\n not in the form of an e-mail address. Please note that alternate\n credentials cannot be used to sign in to the service from a web\n browser or outside of these applications."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git push --force-with-lease vs. --force\nI am trying to understand the difference between\ngit push --force\n\nand\ngit push --force-with-lease\n\nMy guess is that the latter only pushes to the remote if the remote has commits that the local branch doesn't have?"
},
{
"role": "assistant",
"content": "force overwrites a remote branch with your local branch.\n--force-with-lease is a safer option that will not overwrite any work on the remote branch if more commits were added to the remote branch (by another team-member or coworker or what have you). It ensures you do not overwrite someone elses work by force pushing.\nI think your general idea surrounding the command is correct. If the remote branch has the same value as the remote branch on your local machine- you will overwrite remote. If it doesn't have the same value- it indicates a change that someone else made to the remote branch while you were working on your code and thus will not overwrite any code. Obviously if there are additional commits in remote then the values won't be the same.\nI just think of --force-with-lease as the option to use when I want to make sure I don't overwrite any teammates code. A lot of teams at my company use --force-with-lease as the default option for a fail-safe. Its unnecessary in most circumstances but will save you lots of headache if you happen to overwrite something that another person contributed to remote.\nI'm sure you looked at the docs but there might be some more wordy explanation contained in here:\nhttps://git-scm.com/docs/git-push"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_COMMITTER_EMAIL"
},
{
"role": "assistant",
"content": "The email address used in the author identity when creating commit or\ntag objects, or when writing reflogs. Overrides the user.email and committer.email configuration settings."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to reference the initial commit?\nI've got a script that needs to reference the initial commit in a repository. git has the special reference HEAD, but doesn't have the corresponding TAIL. I cannot find anything in git help rev-parse that would seem to help me.\nHere's what I'd like to do:\ngit show TAIL\n\nHere's one option I have:\ngit show `git log --reverse | if read a commit ; then echo $commit ; fi`\n\nThat's pretty hacky and depends on the output of git log not changing.\nRight now I just tag the initial commit and use that as my refspec. However, I'd like to release a general tool, so that's not a great option."
},
{
"role": "assistant",
"content": "Do not use git-log for scripting: use either git-rev-list, or git-log with specified custom format (--format=*<sth>* option).\nThere is additional problem with your question: there can exist more than one such TAIL root commit (parentless commit) in a repository (even if we discount disconnected branches, such as 'html', 'man' and 'todo' in git.git repository). This is usually result of joining separate projects in one, or using subtree merge of separately developed subproject. \nFor example git repository has 6 root commits: git-gui, gitk (subtree-merged), gitweb (merged in, no longer developed separately), git mail tools (merged very early in project history), and p4-fast-export (perhaps accidental). That is not counting roots of 'html and 'man' branches, \"convenience\" branches which contains pre-generated documentation, and 'todo' branch with TODO list and scripts.\n\nIf you have git 1.7.4.2 or newer, you can use the --max-parents option:\n$ git rev-list --max-parents=0 HEAD\n\nOtherwise, you can get list of all parentless (root) commits accessible from current branch using:\n$ git rev-list --parents HEAD | egrep \"^[a-f0-9]{40}$\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to deploy node app to remote host from Jenkins?\n\nThis is Jenkins file in the root of node app directory:\npipeline {\n agent any\n triggers {\n pollSCM('* * * * *')\n }\n stages {\n stage(\"deploy\") {\n steps {\n sh \"scp\"\n }\n }\n } \n}\n\nI configured Jenkins to connect to remote gitlab node proj repo to checkout node project along with Jenkinsfile and run the project's Jenkinsfile. This part works fine but what to do now to perform (note that Jenkins server and the server on which node js is running as well as gitlab repo are all remote to each other):\nrun these commands on remote server on which node app is running\n\ncd ~/mynodeproj \n\npm2 stop mynodeproj \n\ncopy project source files from Jenkins server to remote server where \nnode app is running \n\nnpm install \n\nexport NODE_ENV=production \n\npm2 start mynodeproj\n\nHow to achieve this?\nDo I need to setup private/public keypair on server running jenkins so that jenkins server can do scp to copy file to remote server running node app?"
},
{
"role": "assistant",
"content": "I'm suggest we can use Rocketeer for this case.\nHere is Rocketeer tree on my Jenkins Server for NodeJS App\n$ tree .rocketeer/\n.rocketeer/\n├── config.php\n├── hooks.php\n├── logs\n│ ├── develop--20170613.log\n│ ├── develop--20170614.log\n│ ├── develop--20170616.log\n│ ├── staging--20180323.log\n│ ├── staging--20180324.log\n│ ├── staging--20180326.log\n│ ├── production--20180223.log\n│ ├── production--20180226.log\n│ ├── production--20180227.log\n│ ├── production--20180227.log\n│ └── custom-environment--20180328.log\n├── paths.php\n├── remote.php\n├── scm.php\n├── stages.php\n└── strategies.php\n\n\nYou can manage remote environment of NodeJS App: Develop, Staging, Production (at config.php file)\nIt's will pull newest source code on your Gitlab and keep releases version like Capistrano (at remote.php file)\nIt's can run your pm2 command line after deployed newest source code (at hooks.php file)\nIt's already help run npm install NodeJS packages.\n\n\nSo here is my Jenkins Job setting:\nSource Code Management\n\nBuild Triggers\n\nBuild\n\n#!/bin/bash -el\ncd $JENKINS_HOME/app-deploy/app-socketio\nrocketeer deploy --on=\"develop\"\n\ndevelop mean connect to Develop Remote Server (at .rocketeer\\config.php file)\n'connections' => [\n 'develop' => [\n 'host' => '35.xx.xx.xx',\n 'username' => 'ec2-user',\n 'password' => '',\n 'key' => '/var/lib/jenkins/.ssh/foo.pem',\n 'keyphrase' => '',\n 'agent' => '',\n 'db_role' => true,\n ],\n 'staging' => [\n 'host' => '34.xx.xx.xx',\n 'username' => 'ec2-user',\n 'password' => '',\n 'key' => '/var/lib/jenkins/.ssh/bar.pem',\n 'keyphrase' => '',\n 'agent' => '',\n 'db_role' => true,\n\n ],\n 'production' => [\n 'host' => '18.xx.xx.xx:63612',\n 'username' => 'ec2-user',\n 'password' => '',\n 'key' => '/var/lib/jenkins/.ssh/woot.pem',\n 'keyphrase' => '',\n 'agent' => '',\n 'db_role' => true,\n ],\n 'custom-environment' => [\n 'host' => '13.xx.xx.xx:63612',\n 'username' => 'ec2-user',\n 'password' => '',\n 'key' => '/var/lib/jenkins/.ssh/test.pem',\n 'keyphrase' => '',\n 'agent' => '',\n 'db_role' => true,\n ],\n],\n\nAnd run pm2 command line configure at hooks.php file\n'after' => [\n 'setup' => [],\n 'deploy' => [\n \"pm2 delete mynodeproj\", //Delete old pm2 task\n \"pm2 start src/mynodeproj.js\", //Start new mynodeproj\n ],\n 'cleanup' => [],\n],\n\nHope this can help you!!"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Reverting specific commits from git\n\nI have a git tree with a lot of commits and a lot of files. Now, I want to revert specific commits that touch a file only. To explain:\n> git init\nInitialized empty Git repository in /home/psankar/specific/.git/\n> echo \"File a\" > a\n> git add a ; git commit -m \"File a\"\n[master (root-commit) 5267c21] File a\n 1 file changed, 1 insertion(+)\n create mode 100644 a\n> echo \"File b\" > b\n> git add b; git commit -m \"File b\"\n[master 7b560ae] File b\n 1 file changed, 1 insertion(+)\n create mode 100644 b\n> echo \"File c\" > c\n> git add c; git commit -m \"File c\"\n[master fd6c132] File c\n 1 file changed, 1 insertion(+)\n create mode 100644 c\n> echo \"b and c modified\" > b ; cp b c\n> git commit -a -m \"b and c modified\"\n[master 1d8b062] b and c modified\n 2 files changed, 2 insertions(+), 2 deletions(-)\n> echo \"a modified\" > a\n> git commit -a -m \"a modified\"\n[master 5b7e0cd] a modified\n 1 file changed, 1 insertion(+), 1 deletion(-)\n> echo \"c modified\" > c\n> git commit -a -m \"c modified\"\n[master b49eb8e] c modified\n 1 file changed, 1 insertion(+), 1 deletion(-)\n> git log --pretty=oneline c\n> git log --pretty=oneline c | cat\nb49eb8e03af331bddf90342af7d076f831282bc9 c modified\n1d8b062748f23d5b75a77f120930af6610b8ff98 b and c modified\nfd6c13282ae887598d39bcd894c050878c53ccf1 File c\n\nNow I want to revert just the two commits b49eb8 and 1d8b06 without reverting the changes to a. IOW revert only the commits in a file (without reverting other intermediate commits (which may be thousands in number) in different files) How is this possible ?"
},
{
"role": "assistant",
"content": "You can use git revert with the --no-commit option. In your example:\n$ git revert --no-commit b49eb8e 1d8b062\n# Files that were modified in those 2 commits will be changed in your working directory\n# If any of those 2 commits had changed the file 'a' then you could discard the revert for it:\n$ git checkout a\n$ git commit -a -m \"Revert commits b49eb8e and 1d8b062\"\n\n--no-commit option will not do auto commit, it allows you to edit and add your own commit message\nNote that with unlike git reset with git revert all the reverted commits will still be there in the commit history"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hotfix on GitLab\n\nI'm trying to understand GitLab's suggested flow on http://docs.gitlab.com/ee/workflow/gitlab_flow.html. But, I'm not really sure about this statement:\n\nIf you need to cherry-pick a commit with a hotfix it is common to\n develop it on a feature branch and merge it into master with a merge\n request, do not delete the feature branch. If master is good to go (it\n should be if you a practicing continuous delivery) you then merge it\n to the other branches.\n\nDoes it mean, there will be more than 1 commit in the master? For example, the first commit (actually merge request) is to test whether the fix is working, the second commit is when the first commit fails.\nThe other thing is, (given that we have a production branch) if we merge the hotfix into master, I think we have to deploy the other features on the master, isn't it? Otherwise, we do cherry pick the hotfix commits in the master into the production branch.\nActually the suggested flow is not as detail as another flow in http://nvie.com/posts/a-successful-git-branching-model/. So, it's a bit confusing."
},
{
"role": "assistant",
"content": "I experimented with the hotfix process in a test-hotfix repo available at https://github.com/oldsj/test-hotfix/commits/master\nBasically as long as the hotfix branch is created from the prod branch it the process seems fairly straightforward, even if master is ahead of imp/prod.\nNote: imp is what we refer to as \"pre-production\"\nmaster (dev branch)\ngit init\necho \"Hello wolrd\" > hello.txt\ngit add -A .\ngit commit -m \"add hello.txt\"\ngit log\ncommit 66b1a08080f0db548da85471b4673c5a9f6d703f (HEAD -> master)\n\ncat hello.txt\nHello wolrd\n\ngit checkout -b imp\ngit checkout -b prod\n\nProd shows typo\ncat hello.txt\nHello wolrd\n\ngit log\ncommit 66b1a08080f0db548da85471b4673c5a9f6d703f (HEAD -> prod, master, imp)\n\nLet's add some commits to master, ahead of prod\ngit checkout master\ngit log\ncommit 66b1a08080f0db548da85471b4673c5a9f6d703f (HEAD -> master, prod, imp)\n\necho \"new stuff\" >> newstuff.txt\ngit add -A .\ngit commit -m \"add newstuff.txt\"\ngit log\ncommit df1ca012262c26ab3a29d81b5cb6d46f6c1fc3cc (HEAD -> master)\ncommit 66b1a08080f0db548da85471b4673c5a9f6d703f (prod, imp)\n\nA user reported the typo in prod, let's hotfix by creating a new branch off of the prod branch:\ngit checkout prod\ngit log\ncommit 66b1a08080f0db548da85471b4673c5a9f6d703f (HEAD -> prod, imp)\n\ngit checkout -b hotfix\nSwitched to a new branch 'hotfix'\ngit log\ncommit 66b1a08080f0db548da85471b4673c5a9f6d703f (HEAD -> hotfix, prod, imp)\n\necho \"Hello world\" > hello.txt\ngit add -A .\ngit commit -m \"fix typo\"\ngit log\ncommit 1243123edc75e0abf349e1bb154d39c9f25dab2d (HEAD -> hotfix)\n\ncat hello.txt\nHello world\n\nCool our typo is fixed in the hotfix branch, lets merge to master and test in dev\ngit checkout master\ngit merge hotfix\ngit log\ncommit 2672d5059a55472132f02178c7f51d8b1af0f8ea (HEAD -> master)\n\n> cat hello.txt\nHello world\n\nLooks good in dev! Lets merge to imp and prod\ngit checkout imp\ngit merge hotfix\ngit log\ncommit 1243123edc75e0abf349e1bb154d39c9f25dab2d (HEAD -> imp, hotfix)\ncat hello.txt\nHello world\n\ngit checkout prod\ngit merge hotfix\ngit log\ncommit 1243123edc75e0abf349e1bb154d39c9f25dab2d (HEAD -> imp, hotfix)\ncat hello.txt\nHello world\n\ngit branch -D hotfix\n\nTypo's fixed in prod after testing in lower environments by merging the \"PR\" to those environment branches\nNow let's promote dev changes up (commit df1ca012262c26ab3a29d81b5cb6d46f6c1fc3cc)\ngit checkout master\ngit log\ncommit 2672d5059a55472132f02178c7f51d8b1af0f8ea (HEAD -> master, imp)\ncommit 1243123edc75e0abf349e1bb154d39c9f25dab2d (prod)\ncommit df1ca012262c26ab3a29d81b5cb6d46f6c1fc3cc\ncommit 66b1a08080f0db548da85471b4673c5a9f6d703f\n\ngit checkout imp\ngit merge master\ngit log\ncommit 2672d5059a55472132f02178c7f51d8b1af0f8ea (HEAD -> imp, master)\ncommit 1243123edc75e0abf349e1bb154d39c9f25dab2d (prod)\ncommit df1ca012262c26ab3a29d81b5cb6d46f6c1fc3cc\ncommit 66b1a08080f0db548da85471b4673c5a9f6d703f\n\ncat newstuff.txt\nnew stuff\ncat hello.txt\nHello world\n\ngit checkout prod\ngit merge imp\ngit log\ncommit 2672d5059a55472132f02178c7f51d8b1af0f8ea (HEAD -> prod, master, imp)\ncommit 1243123edc75e0abf349e1bb154d39c9f25dab2d\ncommit df1ca012262c26ab3a29d81b5cb6d46f6c1fc3cc\ncommit 66b1a08080f0db548da85471b4673c5a9f6d703f\n\ndev changes are now in imp and prod, along with the hotfix\ncat hello.txt\nHello world\ncat newstuff.txt\nnew stuff"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database missingSpaceBeforeEmail"
},
{
"role": "assistant",
"content": "(ERROR) Missing space before the email in an author/committer line."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options commit.status"
},
{
"role": "assistant",
"content": "A boolean to enable/disable inclusion of status information in the\ncommit message template when using an editor to prepare the commit\nmessage. Defaults to true."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Pushing from local repository to GitHub hosted remote\n\nI created a local repository of my Visual Studio 2010 solution folder using Git GUI on my dev machine. I then created a remote repository in my GitHub account. Now, I am looking for how to push my local repository to the remote repository.\nIn SVN I can just commit using TortoiseSVN and changes are pushed to the remote repository. I don't see any tool like that available for Git. \nHow do I push my local repo to my remote repo on GitHub?"
},
{
"role": "assistant",
"content": "You push your local repository to the remote repository using the git push command after first establishing a relationship between the two with the git remote add [alias] [url] command. If you visit your Github repository, it will show you the URL to use for pushing. You'll first enter something like:\ngit remote add origin [email protected]:username/reponame.git\n\nUnless you started by running git clone against the remote repository, in which case this step has been done for you already.\nAnd after that, you'll type:\ngit push origin master\n\nAfter your first push, you can simply type:\ngit push\n\nwhen you want to update the remote repository in the future."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-submodule - Initialize, update or inspect submodules --name"
},
{
"role": "assistant",
"content": "This option is only valid for the add command. It sets the submodule’s\nname to the given string instead of defaulting to its path. The name\nmust be valid as a directory name and may not end with a / ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects %G?"
},
{
"role": "assistant",
"content": "show \"G\" for a good (valid) signature,\n\"B\" for a bad signature,\n\"U\" for a good signature with unknown validity,\n\"X\" for a good signature that has expired,\n\"Y\" for a good signature made by an expired key,\n\"R\" for a good signature made by a revoked key,\n\"E\" if the signature cannot be checked (e.g. missing key)\nand \"N\" for no signature"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-clean - Remove untracked files from the working tree help"
},
{
"role": "assistant",
"content": "Show brief usage of interactive git-clean."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "When do you use Git rebase instead of Git merge?\nWhen is it recommended to use Git rebase vs. Git merge?\nDo I still need to merge after a successful rebase?"
},
{
"role": "assistant",
"content": "Short Version\n\nMerge takes all the changes in one branch and merges them into another branch in one commit.\nRebase says I want the point at which I branched to move to a new starting point\n\nSo when do you use either one?\nMerge\n\nLet's say you have created a branch for the purpose of developing a single feature. When you want to bring those changes back to master, you probably want merge.\n\nRebase\n\nA second scenario would be if you started doing some development and then another developer made an unrelated change. You probably want to pull and then rebase to base your changes from the current version from the repository.\n\nSquashing: All commits are preserved in both cases (for example: \"add feature\", then \"typo\", then \"oops typo again\"...). Commits can be combined into a single commits by squashing. Squashing can be done as part of a merge or rebase operation (--squash flag), in which case it's often called a squash-merge or a squash-rebase.\nPull Requests: Popular git servers (Bitbucket, GitLab, GitHub, etc...) allow to configure how pull requests are merged on a per-repo basis. the UI may show a \"Merge\" button by convention but the button can do any operations with any flags (keywords: merge, rebase, squash, fast-forward)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-parse - Pick out and massage parameters --is-shallow-repository"
},
{
"role": "assistant",
"content": "When the repository is shallow print \"true\", otherwise \"false\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-parse - Pick out and massage parameters"
},
{
"role": "assistant",
"content": "SQ-QUOTE In --sq-quote mode, git rev-parse echoes on the standard output a\nsingle line suitable for sh(1) eval . This line is made by\nnormalizing the arguments following --sq-quote . Nothing other than\nquoting the arguments is done. If you want command input to still be interpreted as usual by git rev-parse before the output is shell quoted, see the --sq option. Example $ cat >your-git-script.sh <<\\EOF\n#!/bin/sh\nargs=$(git rev-parse --sq-quote \"$@\") # quote user-supplied arguments\ncommand=\"git frotz -n24 $args\" # and use it inside a handcrafted\n\t\t\t\t\t# command line\neval \"$command\"\nEOF\n\n$ sh your-git-script.sh \"a b'c\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --minimal"
},
{
"role": "assistant",
"content": "Spend extra time to make sure the smallest possible\ndiff is produced."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc git diff"
},
{
"role": "assistant",
"content": "compares the (i)ndex and the (w)ork tree;"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-submodule - Initialize, update or inspect submodules --progress"
},
{
"role": "assistant",
"content": "This option is only valid for add and update commands.\nProgress status is reported on the standard error stream\nby default when it is attached to a terminal, unless -q\nis specified. This flag forces progress status even if the\nstandard error stream is not directed to a terminal."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options merge.stat"
},
{
"role": "assistant",
"content": "Whether to print the diffstat between ORIG_HEAD and the merge result\nat the end of the merge. True by default."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fast-import - Backend for fast Git data importers External data format"
},
{
"role": "assistant",
"content": "The data content for the note was already supplied by a prior blob command. The frontend just needs to connect it to the\ncommit that is to be annotated. 'N' SP <dataref> SP <commit-ish> LF Here <dataref> can be either a mark reference ( :<idnum> )\nset by a prior blob command, or a full 40-byte SHA-1 of an\nexisting Git blob object."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is there a way to see git diff from origin/master using Visual Studio Code?\nUsing Visual Studio Code (version 1.11.2), I can see a side-by-side graphical diff of my current changes very easily by clicking the Source Control button in the left panel. But once I commit those changes to my local repository, I am unable to find a way to see the same side-by-side diff from origin/master.\nIn other words, is there a way to the spawn comparison tool of Visual Studio Code (version 1.11.2) to show me what I see when I do git diff origin/master, but in the side-by-side graphical diff too?"
},
{
"role": "assistant",
"content": "You can use an extension for this.\nTwo good options:\nGitlens: https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens\nWith this one, you can use the >GitLens: Open Changes with... action to compare with any branch (local or remote).\nYou also can use Git History: https://marketplace.visualstudio.com/items?itemName=donjayamanne.githistory\nYou can see the entire file history and compare with the current version with the >Git: View File History action."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git how to clone with SSH key, username\nI have the following and i need to clone the repository in either windows terminal command prompt or linux.\n\nURL: [email protected]:xxx/xxx/git\nusername: [email protected]\nSSH key: ssh-rsa [email protected]\n\nI tried as :\ngit clone [email protected]:xxx/xxx/git\n\nI get\nPermission denied(public key)\nCouldn't read from remote repository\n\nAlso tried to change the URL as:\ngit clone https://xxxxx.com:xxx/xxx/git"
},
{
"role": "assistant",
"content": "Always coming late to answer anything, it may be possible that you have more than one ssh keys and if not specified git will try to use id_rsa but if you need a different one you could use\ngit clone [email protected]:userName/projectName.git --config core.sshCommand=\"ssh -i ~/location/to/private_ssh_key\"\n\nThis way it will apply this config and use a key different than id_rsa before actually fetching any data from the git repository.\nsubsequent fetch or push will use the specified key to authenticate for the cloned repository.\nHope this is helpful to anyone."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "VS 2017 Git Local Commit DB.lock error on every commit\nWe are getting this error on every local commit:\n\nGit failed with a fatal error.error:\n open(\".vs/XXXXXX.Dev.Library/v15/Server/sqlite3/db.lock\"): Permission\n deniedfatal: Unable to process path\n .vs/XXXXXX.Dev.Library/v15/Server/sqlite3/db.lock\n\nThis is a brand new installation of VS 2017 using the local git repository before it can sync to Azure DevOps GIT.\nWe can manually delete the lock file and then sync fine, but it seriously slows down the development process (having to close, delete, open, commit every time).\nDoes anyone know a better long-term fix for this issue?"
},
{
"role": "assistant",
"content": "Just add the .vs folder to the .gitignore file.\nHere is the template for Visual Studio from GitHub's collection of .gitignore templates, as an example:\nhttps://github.com/github/gitignore/blob/master/VisualStudio.gitignore\n\nIf you have any trouble adding the .gitignore file, just follow these steps:\n\nOn the Team Explorer's window, go to Settings.\n\n\n\nThen access Repository Settings.\n\n\n\nFinally, click Add in the Ignore File section.\n\n\nDone. ;)\nThis default file already includes the .vs folder."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to check the validity of a remote git repository URL?\n\nWithin a bash script, what would be the simplest way to verify that a git URL points to a valid git repo and that the script has access to read from it?\nProtocols that should be supported are git@, https://, and git://. Curl fails on the git:// protocol.\n[email protected]:UserName/Example.git\nhttps://[email protected]/UserName/Example.git\ngit://github.com/UserName/Example.git\n\nNote: I'm not asking to check to see if a URL is syntactically correct, I need to verify that a repo exists at the URL location entered from within a bash script."
},
{
"role": "assistant",
"content": "As seen in this issue, you can use git ls-remote to test your address.\n\nIf you need to debug the git calls set GIT_TRACE=1. eg:\n\nenv GIT_PROXY_COMMAND=myproxy.sh GIT_TRACE=1 git ls-remote https://...\n\n\n\"git ls-remote\" is the quickest way I know to test communications with a\nremote repository without actually cloning it. Hence its utility as a test for this\nissue.\n\nYou can see it used for detecting an address issue in \"git ls-remote returns 128 on any repo\"."
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.