messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-send-email - Send a collection of patches as emails --no-identity"
},
{
"role": "assistant",
"content": "Clears the previously read value of sendemail.identity set\nvia config, if any."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-verify-commit"
},
{
"role": "assistant",
"content": "Check the GPG signature of commits"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to get Git diff of the first commit?\nI created a repo, created a file inside it, put some content in the file, and committed the file. Now, I'd like to see a diff of that commit, which should ideally show the file that was added and the lines that were added to it.\nHowever, git diff HEAD^ HEAD returns fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree., probably because this was the first commit to the repo.\nHow can this be resolved? Is there still a way to view a diff of the files that were added in the first commit?"
},
{
"role": "assistant",
"content": "You can do:\ngit diff 4b825dc642cb6eb9a060e54bf8d69288fbee4904 HEAD\n\n4b825dc642cb6eb9a060e54bf8d69288fbee4904 is the id of the \"empty tree\" in Git and it's always available in every repository."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-shortlog - Summarize git log output --reflog"
},
{
"role": "assistant",
"content": "Pretend as if all objects mentioned by reflogs are listed on the\ncommand line as <commit> ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitrevisions - Specifying revisions and ranges for Git"
},
{
"role": "assistant",
"content": "NAME gitrevisions - Specifying revisions and ranges for Git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I push different branches to different heroku apps?\nI've been working on a web-app that gets pushed to heroku. The source is hosted on GitHub.\nSo git push pushes the master branch to GutHub.\nMy git branch 'master' is connected to Heroku app 'my-app-staging'\nSo git push heroku pushes the app to my-app-staging.herokuapp.com\nI've created a new Heroku app which will be the 'production' app, let's call it 'my-app-prod'.\nI have created a branch now called 'production' (ie git checkout -b production) and I've run git push -u origin production to make it a managed branch at GitHub.\nI now want to link the production branch to my-app-prod.herokuapp.com such that, when switched to the production branch I can simply type git push heroku (or perhaps git push prod-heroku production or similar) and voila - the production branch is pushed to the production app.\nWhat's the recommended way to link my production branch to my-app-prod on Heroku?\nI've wallowed through Heroku's own docs on this but they all assume I've set up my apps using the heroku create CLI, not set up my apps via Heroku's website, however the following paragraph just makes my head spin:\n\nIt’s simple to type git push staging master and git push production master when\n you’ve followed the steps above. Many developers like to take advantage of git’s\n branches to separate in-progress and production-ready code, however. In this sort\n of setup, you might deploy to production from your master branch, merging in changes\n from a development branch once they’ve been reviewed on the staging app. With this\n setup, pushing is a littler trickier:\n\nWhere I want to end up is as follows:\n\nIn branch master: (a) git push pushes code to GitHub, and (b) git push heroku pushes code to my-app-staging on Heroku\nIn branch production: (c) git push pushes code to the production branch on GitHub, and (d) git push heroku pushes the production code to my-app-prod on Heroku.\n\nGiven step 1 above is already in place and step 2 (c) is in place, how do I achieve step 2 (d)?"
},
{
"role": "assistant",
"content": "You should add another remote for my-app-prod named prod-heroku (replace GIT_URL with the Git URL that you can find in the settings page of my-app-prod in heroku):\ngit remote add prod-heroku GIT_URL\ngit push prod-heroku production:master\n\nThis will push your local branch production to the remote branch master in prod-heroku so my-app-prod will get deployed with the code in production branch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-update-index - Register file contents in the working tree to the index"
},
{
"role": "assistant",
"content": "USING --CACHEINFO OR --INFO-ONLY --cacheinfo is used to register a file that is not in the\ncurrent working directory. This is useful for minimum-checkout\nmerging. To pretend you have a file at path with mode and sha1, say: $ git update-index --add --cacheinfo <mode>,<sha1>,<path> --info-only is used to register files without placing them in the object\ndatabase. This is useful for status-only repositories. Both --cacheinfo and --info-only behave similarly: the index is updated\nbut the object database isn’t. --cacheinfo is useful when the object is\nin the database but the file isn’t available locally. --info-only is\nuseful when the file is available, but you do not wish to update the\nobject database."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why does GitHub call foreign submissions, a \"Pull Request\"?\nI'm curious why GitHub calls submissions to merge, \"Pull requests.\"\nFrom my understanding, git pull will pull all changes, from a remote repository, into a current working branch. Then merge those changes with FETCH_HEAD. (Git Pull)\nSo taking a look at git push... a push would actually push committed changes to a repository. And isn't that what you are doing with a Git repo? Submitting a \"request\" to merge your code? So why isn't it called a \"Push request\"?"
},
{
"role": "assistant",
"content": "The term “pull requests” comes from the distributed nature of how many open source projects organize themselves. Instead of just pushing your changes into the repository (like you would do with a centralized repository, e.g. with Subversion), you are publishing your changes separately and ask the maintainer to pull in your changes. The maintainer then can look over the changes and do said pull."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to find the created date of a repository project on GitHub?\n\nHow can I find the created date of a project on GitHub? \nBasically, I have to find the first commit to see the created date, however, some projects have 500 commits, which wastes a lot of time trying to get to the first commit page.\nIs there a quicker way to get the created date?"
},
{
"role": "assistant",
"content": "How can I find the created date of a project on GitHub?\n\nUse the Repos GitHub API to retrieve this information\n\nSyntax: https://api.github.com/repos/{:owner}/{:repository}\nExample: https://api.github.com/repos/libgit2/libgit2sharp\n\nThe JSON payload will expose a created_at member with the UTC date the repository was created.\nConsidering the LibGit2Sharp repository above, one can see that it's been created on Feb, 2nd 2011 at 16:44:49 UTC.\nNote: The created_at won't necessarily reflect the date of the first commit. It's the date the repository has been created on GitHub. For instance, the xunit/resharper-xunit project was recently moved from codeplex to GitHub. The created_at date is 2014-05-01T11:17:56Z, but the most of the commits date back much more farther than that."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "More than one value for the key user.name Git\nFor some reason I'm getting the error that \"More than one value for the key user.name\" when I try to set the user.name for my git account. How can I set it to a single name?"
},
{
"role": "assistant",
"content": "If you just want to reset all of them:\ngit config --global --replace-all user.email \"[email protected]\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-archive - Create an archive of files from a named tree <tree-ish>"
},
{
"role": "assistant",
"content": "The tree or commit to produce an archive for."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Explain gitignore pattern matching\nI have the following directory tree:\n> #pwd is the repo \n> tree -a\n.\n├── .git\n│ |.....\n├── .gitignore\n├── README.md\n├── f1.html\n├── f2.html ... and some more html\n├── images\n│ └── river.jpg\n>\n\nI also have the following in my .gitignore:\n> cat .gitignore\n*\n!*.html\n!images/*.*\n>\n\nI would like all files in the images directory to be included in the repo. But that is not happening. I got it to work using the following in gitignore:\n*\n!*.html\n!images*\n!*.jp*g\n\nWhat is happening here? Is there a foolproof way to test gitignore. I checked the documentation. Here is the point it don't understand (this is under pattern format heading):\n\nOtherwise, Git treats the pattern as a shell glob suitable for\n consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the\n pattern will not match a / in the pathname. For example,\n \"Documentation/*.html\" matches \"Documentation/git.html\" but not\n \"Documentation/ppc/ppc.html\" or \"tools/perf/Documentation/perf.html\"."
},
{
"role": "assistant",
"content": "Firstly the tricky part in your question is the first line in the .gitignore file:\n* // Says exclude each and every file in the repository,\n // unless I specify with ! pattern explicitly to consider it\n\nFirst we will consider the first version of your .gitignore. \n\n* exclude every file in the repository.\n!*.html allow all html files.\n!images/*.* consider all types of file in images folder.\n\nTo include all JPG/JPEG you could have simply added !*.jp*g at 3rd line, which would have made git to consider all jpg and jpeg irrespective of any folder where that file is. But you specifically wanted only from images folder and not only jpg, any type of file in the images folder. Let's read some documentation related to it and in 3rd section we will go to solution part.\n\nGit ignore pattern regarding the folder consideration:\n\nPattern ending only with slash: If a pattern ends with <dir-name>/ then git will ignore the files contained in that directory and all other sub-directories. As example given in the docs \n\nfoo/ will match a directory foo and paths underneath it, but will not\n match a regular file or a symbolic link foo\n\nbut also note, if any pattern matches a file in the excluded directory, git doesn’t consider it.\nPattern does not have slash: If you are specifying the dir name in the ignore list which does not end with a slash, git will consider it as just a pattern, which can match any file having that pathname. \n\nIf the pattern does not contain a slash /, Git treats it as a shell\n glob pattern and checks for a match against the pathname relative to\n the location\n\nPattern with slash and special character (*/?) : If the pattern ends like the 1st example you gave, images/*.* It works as specified in the documentation \n\nExample: \"Documentation/*.html\" matches \"Documentation/git.html\" but not\n \"Documentation/ppc/ppc.html\" or \"tools/perf/Documentation/perf.html\".\n\n\n\nSolution\nConsidering 3rd point git should consider all the files in the images directory for !images/*.* pattern. But it is not doing that because the documentation says one more important point \n\nGit doesn’t list excluded directories \n\nBecause of the first line * the \"images\" directory itself is ignored. So first we should tell the git to consider images directory and later additional lines explicitly to say consider the other types (if needed).\n*\n!*.html\n!images/ // <- consider images folder\n!images/*.*\n\nNote : the last line considers all types of files only from images directory not from any of its sub-directories. (3rd point in section 2)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GIT - How to make a branch be the same as master\nI have a website using git\nThe setup has the master branch as the live site and a develop branch as the dev domain which is used for testing features before they go live\nNo work is ever done directly on master or develop, it's always done on feature branches and then merged in to develop for testing, followed by master to go live\nMy issue is that I have one site which has had a lot of work merged in to the develop branch which is never going to go live\nI've been asked to make the develop branch match the master branch to ensure the work that's never going live doesn't affect the testing of other new features that get merged in to develop\nI've done a bit of research and from my understanding, I can't use rebase as that's more for updating a branch with commits made since you branched off\nThe only option that seems to do what I need is to rename the develop branch and then recreate it from master and force a push to update it remotely\nIs this my best option? Or is there another way I don't know about? Or maybe rebase is correct but I'm not quite understanding its purpose?\nThanks in advance"
},
{
"role": "assistant",
"content": "If you don't care about preserving develop just checkout develop and reset it to master or main or whatever you/ your team named your default branch.\n# make sure the default branch is up to date before you do this\ngit checkout develop\ngit reset --hard master # replace with your name if it differs\ngit push -f # force push the branch\n\nThis is often done for an integration branch every morning, so that the nightly integration is always based on master."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-commit - Record changes to the repository --porcelain"
},
{
"role": "assistant",
"content": "When doing a dry-run, give the output in a porcelain-ready\nformat. See git-status for details. Implies --dry-run ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Set up a default directory structure on git init\nI would like to optimise my git workflow by automating creation of .gitignore, README, LICENSE and other files on git init command.\nTo do that I RTFM of git init at http://git-scm.com/docs/git-init and it tells me to do one of the following:\n\nUse git init --template=<template_directory>, but it's bothersome.\nAlter the contents of the $GIT_TEMPLATE_DIR environment variable, but I would rather not.\nSet the init.templatedir configuration variable. Now we're talking!\n\nSo I sudo mkdir /usr/share/git-core/templates/my_template and touch some files in it, then I vim ~/.gitconfig and append:\n[init]\n templatedir = /usr/share/git-core/templates/my_template\n\nAnd git config -l tells me:\n\n...\n init.templatedir=/usr/share/git-core/templates/my_template\n ...\n\nHappy with myself, I go to my development playground directory and:\n$ git init\nInitialized empty Git repository in /the/current/directory\n$ ls -a\n. .. .git\n\nBummer... where are the files? :(\nQuick check:\n$ ls -a /usr/share/git-core/templates/my_template\n. .. .gitignore LICENSE README.md\n$ git --version\ngit version 1.8.2.1\n\nIt seems that $ git init --template=/usr/share/git-core/templates/my_template doesn't work either.\nSo what is it that I'm doing wrong here? Incorrect configuration directive? Bad template or its location (I'm on OSX)? Should template be a git repo? A bare one?"
},
{
"role": "assistant",
"content": "The behavior you're seeing is the expected git behavior:\nIf you read the manual correctly about the template directory:\n\nTEMPLATE DIRECTORY\nThe template directory contains files and\n directories that will be copied to the $GIT_DIR after it is created.\n\nThe files which are copied from the template directory are placed in your GIT_DIR which defaults to the .git directory under your repo's root directory.\ngit init does not support templates for the work-tree as far as I know. If this behavior is required, you should be able to get away with writing some simple bash aliases or functions to do this for you."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why is Git not considered a \"block chain\"?\nGit's internal data structure is a tree of data objects, wherein each objects only points to its predecessor. Each data block is hashed. Modifying (bit error or attack) an intermediate block will be noticed when the saved hash and the actual hash deviate.\nHow is this concept different from block chain?\nGit is not listed as an example of block chains, but at least in summaries, both data structure descriptions look alike: data block, single direction reverse linking, hashes, ...).\nSo where is the difference, that Git isn't called a block chain?"
},
{
"role": "assistant",
"content": "The reason why Git and blockchains appear similar is because they are both using merkle trees as their underlying data structure. A merkle tree is a tree where each node is labeled with the cryptographic hash value of their contents, which includes the labels of its children.\nGit’s directed acyclic graph is exactly that, a merkle tree where each node (tag, commit, tree, or blob object) is labeled with the hash of its content and the label of its “child”. Note that for commits, the “child” term conflicts a bit with Git’s understanding of parents: Parent commits are the children of commits, you just need to look at the graph as a tree that keeps growing by re-rooting it.\nBlockchains are very similar to this, since they also keep growing that way, and they are also using its merkle tree property to ensure data integrity. But usually, blockchains are understood as way more than just merkle trees which is where they are separating from the “stupid content tracker” Git. For example, blockchains usually also means having a highly decentralized system on a block level (not all blocks need to be in the same place).\nUnderstanding blockchains is kind of difficult (personally, I’m still far away from understanding everything about it), but I consider understanding Git internals as a good way to understand merkle trees which definitely helps understanding a fundamental part about blockchains."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git flow command error: 'flow' is not a git command\n\nI am very new to Git and am starting to learn the command line version. I believe my git flow is not installed correctly. I am running this from a pc. \nWhen i run following command:\ngit flow feature start JamesTest\n\nI get the following error:\n\ngit: 'flow' is not a git command. See 'git --help'\n Did you mean any of these?\n\nLooks like the git flow command is not being recognized from all paths? How do I fix this?"
},
{
"role": "assistant",
"content": "The git flow is not installed in your machine. Just run this command,\nmacOS:\n$ brew install git-flow-avh\n\nLinux:\n$ apt-get install git-flow\n\nWindows:\n$ wget -q -O - --no-check-certificate https://raw.github.com/petervanderdoes/gitflow-avh/develop/contrib/gitflow-installer.sh install stable | bash\n\n\nSource git-flow cheatsheet by Daniel Kummer\n\nAfter successful installation run git flow init in your project and then follow the instructions to configure the git flow."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Working with README.md on github.com [closed]\n\nClosed. This question is seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. It does not meet Stack Overflow guidelines. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\n We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.\n\n\nClosed 6 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI am not too familiar with the lightweight markup language used by github when updating README files.\nWhere are the resources which I can read up on how to write the appropriate markup syntax for my open source library's README/wiki files?\nAnd is there a tool which I can \"review my docs locally in my browser\" before pushing the updated README to my github repository?"
},
{
"role": "assistant",
"content": "The markup in question is coincidentally called Markdown, created by John Gruber, author of the Daring Fireball blog. The original source of Markdown can be found at Daring Fireball - Markdown. \nThere are many Markdown dialects, the documentation for Github's can be found on the Github Flavored Markdown page.\nnice tip from that page:\npress M on any Github page with a Markdown editor to reveal the cheatsheet.\nYou can also use the Github Markdown Live Preview page to test your Markdown documents.\nUpdate 2012-11-08: Efforts are underway to standardize the Markdown syntax. See The Future of Markdown - Jeff Atwood, Coding Horror and W3C Markdown Community Group.\nUpdate 2014-09-09: CommonMark a markdown standard and spec has been released."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I download a tarball from GitHub using cURL?\n\nI am trying to download a tarball from GitHub using cURL, but it does not seem to be redirecting:\n$ curl --insecure https://github.com/pinard/Pymacs/tarball/v0.24-beta2\n<html><body>You are being <a href=\"https://nodeload.github.com/pinard/Pymacs/tarball/v0.24-beta2\">redirected</a>.</body></html>\n\nNote: wget works for me:\n$ wget --no-check-certificate https://github.com/pinard/Pymacs/tarball/v0.24-beta2\n\nHowever I want to use cURL because ultimately I want to untar it inline with something like:\n$ curl --insecure https://github.com/pinard/Pymacs/tarball/v0.24-beta2 | tar zx\n\nI found that the URL after redirecting turned out to be https://download.github.com/pinard-Pymacs-v0.24-beta1-0-gcebc80b.tar.gz, but I would like cURL to be smart enough to figure this out."
},
{
"role": "assistant",
"content": "Use the -L option to follow redirects:\ncurl -L https://github.com/pinard/Pymacs/tarball/v0.24-beta2 | tar zx"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission --cover-from-description=<mode>"
},
{
"role": "assistant",
"content": "Controls which parts of the cover letter will be automatically\npopulated using the branch’s description. If <mode> is message or default , the cover letter subject will be\npopulated with placeholder text. The body of the cover letter will be\npopulated with the branch’s description. This is the default mode when\nno configuration nor command line option is specified. If <mode> is subject , the first paragraph of the branch description will\npopulate the cover letter subject. The remainder of the description will\npopulate the body of the cover letter. If <mode> is auto , if the first paragraph of the branch description\nis greater than 100 bytes, then the mode will be message , otherwise subject will be used. If <mode> is none , both the cover letter subject and body will be\npopulated with placeholder text."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to do a fast-forward merge on GitHub?\n\nSo one of my colleagues attempted to merge a branch using GitHub's \"merge via fast-forward\" option in the web-interface, to keep the history clean from bogus merge commits (the master branch into which they merged, had not progressed since the to-be merged feature-branch was started).\nFunnily enough, this didn't work as expected: all the commits got new commit-hashes.\nOn closer inspection, it seems that merge-option is actually called \"Rebase and Merge\" and it really seems to do the equivalent of git rebase --force, changing the Committer information (both the person who did the merge, and the time when the merge happened).\nIt took me quite a while to confirm my suspicion that this is indeed the case, as I couldn't make the cmdline tools to show me the difference between the original commits on the feature branch and the seemingly-identical commits (with different hashes) on the master branch.\n(In the end, I found that gitk shows both Committer and Author of a commit; in the very end I found that I can also get this information via git log --pretty=raw)\nSo:\n\nIs there a way to do a \"proper\" fast-forward merge (git rebase without the --force option) via GitHub's web-interface?\nIf not: why? (I can see merits in accountability; e.g. it answers the question who is responsible that a given piece of code ended up in master)"
},
{
"role": "assistant",
"content": "Looks like GitHub does not support this – and this is a TERRIBLE affair.\nYou basically CANNOT run an atomic, linear commit strategy (the best there is) using the GitHub UI.\nNote that Bitbucket DOES support this, and has much more fine-grained options for setting up the PR landing/integration strategy. Namely the 'Rebase, fast-forward' option which does a --ff-only update of the target/mainline branch. It also has a 'Rebase, merge' option which lets you run a rebase on target (so that your commits are linear) but integrates using a merge commit (if you want to track that the commits are all part of one logical unit/PR).\nBoth of these options seem superior to GitHub's limited options of either using non-linear merge commits (GitHub's 'Merge pull request' option) or linear rebase ('Rebase and merge' option), which does achieve linearity but creates duplicate commits on the source branch, thus always requiring manual Hard Resets locally if you want to keep things clean and in sync.\nSo... time to switch your repo provider it seems!"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Difference between GitLab CI and GitHub Actions Beta\n\nWhat is the difference between GitLab CI and GitHub Actions Beta?\nBoth talk about devops/automation from Git repo"
},
{
"role": "assistant",
"content": "GitHub copied a lot of Gitlab`s features, including CI (similar configuration and price). Actions looks like GitLab CI/CD but there are some differences between them.\nGitLab CI/CD has integration with Pages, issues, packages registry, it has environments dashboard, review support, manual pipelines, multi-project pipelines, support a lot of different reports (such as Container scanning report), good API, ability to use your own runner, and a lot of other features. Also, it is open source.\nYou can see more full comparsion here\nGitHub Actions - simple CI; GitLab CI/CD - configurable and powerful open-source CI/CD with integrations with different software and unique features."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-tag - Create, list, delete or verify a tag object signed with GPG"
},
{
"role": "assistant",
"content": "SYNOPSIS git tag [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] [-e]\n\t<tagname> [<commit> | <object>] git tag -d <tagname>… git tag [-n[<num>]] -l [--contains <commit>] [--no-contains <commit>]\n\t[--points-at <object>] [--column[=<options>] | --no-column]\n\t[--create-reflog] [--sort=<key>] [--format=<format>]\n\t[--merged <commit>] [--no-merged <commit>] [<pattern>…] git tag -v [--format=<format>] <tagname>…"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can I host my wordpress blog on github pages as a static webpage\n\nI would like to make my WordPress blog installed on Localhost to push into GitHub and run that on GitHub as a static page. Can I do it, and if yes please give me a detailed answer with the steps and problems involved?\nI don't care if my page is static, but will I be able to host it on GitHub pages?"
},
{
"role": "assistant",
"content": "This website gives a good answer on how to do this: https://www.hywel.me/static/site/wordpress/2016/07/17/fast-free-static-website-with-wordpress-and-github-pages.html\nIn short:\n\nSet-up GitHub pages.\nInstall Simply static plugin into WordPress.\nPush the export from the plug-in back to your git repository and you are done!"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to use Swift Package Manager with private repos?\nHow to use the Swift Package Manager with dependencies stored in private repositories?\nAdding a username and password can functionally work:\nlet package = Package(\n name: \"MyPackage\",\n dependencies: [\n .package(url: \"https://username:[email protected]/me/MyPackage.git\", .branch(\"develop\")) \n ]\n)\n\nHowever, the username:password approach has issues including (but not limited to) making the Package.swift username specified, and putting plain text credentials in the repository.\nIdeally, a solution would:\n\nnot store any plain text or token credentials in the repository. \nallow each team member to have their own credentials."
},
{
"role": "assistant",
"content": "A solution, for Unix-like systems, is to use SSH git URLs and add Host configurations to ~/.ssh/config. This approach works for both macOS/Linux command line and Xcode.\nUse a ssh form for the dependency url in Package.swift.\n// swift-tools-version:4.0\nimport PackageDescription\n \nlet package = Package(\n name: \"Example\",\n dependencies: [\n .package(url: \"[email protected]:abc/private-repo.git\", .branch(\"develop\") ),\n ],\n)\n\nIn the above example, gitlab.com.myteam corresponds to a Host in ~/.ssh/config\n### GITLAB WorkTeamOne\nHost gitlab.com.workteam\n HostName gitlab.com\n User git\n IdentityFile ~/.ssh/my_work_key_rsa\n UseKeychain yes # for macOS keychain\n AddKeysToAgent yes # for macOS keychain\n PreferredAuthentications publickey\n \n### GITLAB Hobby\nHost gitlab.com.hobby\n HostName gitlab.com\n User git\n IdentityFile ~/.ssh/my_hobby_key_rsa\n UseKeychain yes # for macOS keychain\n AddKeysToAgent yes # for macOS keychain\n PreferredAuthentications publickey\n\nGenerate and apply SSH key pairs, as needed, for an individual's online git service account.\nssh-keygen \\\n -b 4096 \\\n -t rsa \\\n -C \"[email protected]\" \\\n -f ~/.ssh/my_work_key_rsa\n\nEach team member could setup an individual, corresponding Host ssh configuration. The Host would be the same, however, the actual public/private key pairs (a) are specific to the user, (b) can be managed separately from any of the code development and (c) can be used automatically after the setup."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "View differences of branches with meld?\nI know that I can view the difference between HEAD and current state with meld .. But how can I view the differences between branches, for example master and devel with meld?\nAt the moment I do the following steps:\n\nRename folder of working copy\n For example mv /projectA /projectA_master)\nClone the project again \ngit clone url\nSwitch to devel branch \ncd projectA && git -b devel origin/devel \nView differences with meld \nmeld /projectA_Master projectA\n\nIsn't there an easier way to get the same result in meld? I only need it to review the changes and not primarily for merging."
},
{
"role": "assistant",
"content": "Short & sweet:\ngit config --global diff.tool meld\n\nThis configures Git to use meld as the diff tool. (You don't need to specify the command line arguments, support for meld is built into Git.)\nThen, if you want a graphical diff instead of a textual one, you simply invoke git difftool instead of git diff (they both take the same arguments). In your case:\ngit difftool master..devel\n\n\nUpdate: If you don't want the one-file-at-a-time diff, but instead want to use meld's \"subdirectory\" view with all the changes between the two branches, note the -d or --dir-diff option for git difftool. For example, when I'm on branch XYZ and I want to see what is different between this and branch ABC, I run this:\ngit difftool -d ABC"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitLab run pipeline only manually and not automatically\n\nMy GitLab pipelines execute automatically on every push, I want to manually run pipeline and not on every push.\nPipeline docs: https://docs.gitlab.com/ee/ci/yaml/#workflowrules\nI tried this in\n.gitlab-ci.yml\nworkflow:\n rules:\n - when: manual # Error: workflow:rules:rule when unknown value: manual"
},
{
"role": "assistant",
"content": "You should specify a condition that tells Gitlab to not run the pipeline specifically on push events like so:\nworkflow:\n rules:\n - if: '$CI_PIPELINE_SOURCE == \"push\"'\n when: never # Prevent pipeline run for push event\n - when: always # Run pipeline for all other cases"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I merge a pull request on someone else's project in git?\nI cloned this repo on my computer: https://github.com/derobins/wmd.git\nThere are several bugs with it though, and it looks like another user has fixed them and issued \"Pull requests\" (I assume these are requests for their changes to be committed?)\nIs it possible to merge those changes into my local version?\nEDIT: just to be clear, this is not my repository. I am using the WMD editor from derobins, but it has several bugs which those pull requests purport to fix. I have cloned the repo on Ubuntu (not in github) and was hoping to merge those changes in if possible."
},
{
"role": "assistant",
"content": "(GitHub has very thorough documentation on how to deal with pull requests.)\nEssentially, you'll want to add a remote for the repository of the person who made the pull requests, e.g.:\ngit remote add helpful git://github.com/helpful-person/whatever.git\n\n... then fetch their changes into remote-tracking branches:\ngit fetch helpful\n\n... so that now you have all the commits from that person's GitHub repository in your clone of the upstream repository. If you look at the additional commits within that pull request you could:\n\nmerge the latest one, e.g. git merge 75708aeab5\ncherry pick each of those changes, e.g. git cherry-pick 2142db89, git cherry-pick 75708aeab5\ncreate a local branch to work on them further, e.g. git checkout -b fix-for-issue3 75708aeab5\netc. etc.\n\nAn alternative is to just clone the repository of the contributor who made the pull requests instead, if that's the same but for those fixes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I delete a local repository in git? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow to fully delete a git repository created with init?\n\n (17 answers)\n \n\nClosed 10 years ago.\n\n\n\nI can't find the command. I tried Googling \"git 'delete a repository'\"."
},
{
"role": "assistant",
"content": "Delete the .git directory in the root-directory of your repository if you only want to delete the git-related information (branches, versions).\nIf you want to delete everything (git-data, code, etc), just delete the whole directory.\n.git directories are hidden by default, so you'll need to be able to view hidden files to delete it."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-parse - Pick out and massage parameters --output-object-format=(sha1|sha256|storage)"
},
{
"role": "assistant",
"content": "Allow oids to be input from any object format that the current\nrepository supports. Specifying \"sha1\" translates if necessary and returns a sha1 oid. Specifying \"sha256\" translates if necessary and returns a sha256 oid. Specifying \"storage\" translates if necessary and returns an oid in\nencoded in the storage hash algorithm."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-stash"
},
{
"role": "assistant",
"content": "Stash the changes in a dirty working directory away"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How much space can your BitBucket account have?\nI created a BitBucket account today, and I love the fact that they allow you to have unlimited public/private repositories. However, I didn't find the size limit of your account? Does anyone know where to find it?"
},
{
"role": "assistant",
"content": "EDIT #2 (Over three years later, as pointed out by matchew)\nAs of 30 May 2014 There is now a 1gb (soft 2gb hard) limit. read this for more information\nHere is a link to their FAQ which address this question\n\nAccording to the banner on their homepage: Unlimited disk space. I\ncan highly recommend it. ;-)\n* EDIT (ALMOST TWO YEARS LATER) *\nI can still highly recommend it ;-)\nAnd in the meantime they have addressed this question in their FAQ\n\nWe don't place any limits on the size of your repositories, file\n uploads, or the number of public repositories you can have. Not on the\n paid plan or on the free plan. We do expect that you are polite and\n respect fair use. read more...."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc -M[<n>] --find-renames[=<n>]"
},
{
"role": "assistant",
"content": "Detect renames.\nIf n is specified, it is a threshold on the similarity\nindex (i.e. amount of addition/deletions compared to the\nfile’s size). For example, -M90% means Git should consider a\ndelete/add pair to be a rename if more than 90% of the file\nhasn’t changed. Without a % sign, the number is to be read as\na fraction, with a decimal point before it. I.e., -M5 becomes\n0.5, and is thus the same as -M50% . Similarly, -M05 is\nthe same as -M5% . To limit detection to exact renames, use -M100% . The default similarity index is 50%."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Switch branch names in git\nThere may be more than one way to ask this question, so here's a desciption of the problem. I was working on master and committed some stuff and then decided I wanted to put that work on hold. I backed up a few commits and then branched from before I started my crap work. Practically this works fine, I just now have a different branch as my main development branch. I'm wondering how I could change things around so I'm working on master again but it doesn't have my junk work and said work is on a different branch.\nSome ways this could be asked/solved:\nHow do I rename my master branch to something else and then rename something else to master?\nHow do I back up master and then cause all commits I've backed up past to be on a different branch?\nThanks for all the (quick) answers! They're all good."
},
{
"role": "assistant",
"content": "In addition to the other comments, you may find the -m (move) switch to git-branch helpful. You could rename your old master to something else, then rename your new branch to master:\ngit branch -m master crap_work\ngit branch -m previous_master master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --summary"
},
{
"role": "assistant",
"content": "Output a condensed summary of extended header information\nsuch as creations, renames and mode changes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Heroku - Display hash of current commit in browser\nI want to display the hash of the current git commit in the browser so that testing team (which does not have an access to run heruko commands) will be able to include the corresponding commit hash in bug reports.\nFirst I tried grit, but something is broken and it doesn't work on Heroku (on local it works great, I don't know why it fails on Heroku).\nSo I found out that there are two environment variables on Heroku:\nENV[\"COMMIT_HASH\"]\nENV[\"LAST_COMMIT_BY\"]\n\nBut neither of them is available (both are nil).\nI also checked with:\nheroku config\n\nBut again, neither is set.\nIs there a way to retrieve the hash information? Is there any way to have more git information, such as date for example?"
},
{
"role": "assistant",
"content": "It's now possible to try the Heroku feature Roberto wrote about in his answer, without contacting Heroku. It's called Heroku Labs: Dyno Metadata and you can enable it by\nheroku labs:enable runtime-dyno-metadata -a <app name>\n\nand then the information is available (on the next deploy) as environment variables:\n~ $ env\nHEROKU_APP_ID: 9daa2797-e49b-4624-932f-ec3f9688e3da\nHEROKU_APP_NAME: example-app\nHEROKU_DYNO_ID: 1vac4117-c29f-4312-521e-ba4d8638c1ac\nHEROKU_RELEASE_VERSION: v42\nHEROKU_SLUG_COMMIT: 2c3a0b24069af49b3de35b8e8c26765c1dba9ff0\nHEROKU_SLUG_DESCRIPTION: Deploy 2c3a0b2\n..."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-parse - Pick out and massage parameters --show-superproject-working-tree"
},
{
"role": "assistant",
"content": "Show the absolute path of the root of the superproject’s\nworking tree (if exists) that uses the current repository as\nits submodule. Outputs nothing if the current repository is\nnot used as a submodule by any project."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "With GitHub how do I push all branches when adding an existing repo?\nI created a new GitHub repo - I want to put my existing repo there.\nI followed the instructions:\ncd existing_git_repo\ngit remote add origin [email protected]:acme-org/myprj.git\ngit push origin master\n\nThis only pushes the master branch to GitHub.\nHow do I push everything (including all branches) in my existing repo to my new GitHub repo?"
},
{
"role": "assistant",
"content": "Note: git push --all won't push your tags, only your branches.\ngit push --all\ngit push --tags\n\nwould really push everything. See also \"Set up git to pull and push all branches\".\nDon't forget the --dry-run option to make some test before actually pushing everything.\nSee also GitHub help \"Working with remotes\" to set your origin to your GitHub remote repo.\n\nAs mentioned in \"How to make “git push” include tags within a branch?\", git 1.8.3+ (May 2013) introduced:\ngit push --follow-tags\n\n\nThis won't push all the tags, but only the ones accessible from the branch(es) HEAD(s) you are pushing.\n\nThat can help keeping that operation (pushing commits and tags) done with one command instead of two.\nGit 2.4.1+ (Q2 2015) will introduce the option push.followTags."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab CI/CD ssh add return enter passphrase\n\nWhen triggered, pipeline runs and return the following error, \n$ ssh-add <(echo \"$SSH_PRIVATE_KEY\")\nEnter passphrase for /dev/fd/63: ERROR: Job failed: exit code 1\n\nmy SSH_PRIVATE_KEY variable exist with a valid private key."
},
{
"role": "assistant",
"content": "In my case, I had set the SSH_PRIVATE_KEY variable to \"protected\", so this worked when building from a protected branch. If your SSH_PRIVATE_KEY variable is Protected ensure your branch is also protected. Information on how to protect your gitlab branch"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Should I commit .lock file changes separately? What should I write for the commit message?\nI'm using poetry for my Python package manager but I believe this would apply to any programming practices. \nI've been doing this without knowing exactly what I'm doing, or how I should be doing. \nWhen you use a package manager and install a new package, there's usually a .lock file change to keep your build deterministic. \nUsually, I would commit these changes like:\n$ git add poetry.lock pyproject.toml \n$ git commit -m \"Install packages: beautifulsoup4\"\n\ni.e, I make a commit every time I install/remove a package. I do it because I FEEL like this is what I should do, but I have 0 clue if this is actually a correct way to handle this. \nAm I doing great? or is there any other specific convention & rules I should abide by to make it follow the best practices as close as possible?"
},
{
"role": "assistant",
"content": "Disclaimer\nPlease refer to this answer for the official stance and justification on the topic, which should be the top post in this thread. Below is my original answer, which I'll leave as it was.\n\nThe official recommendation of the poetry maintainers is to commit the lockfile if you develop a deployable application (as opposed to a library).\nThat being said, my personal experience has been that it isn't necessary to commit lockfiles to VCS. The pyproject.toml file is the reference for correct build instructions, and the lockfile is the reference for a single successful deployment. Now, I don't know what the spec for poetry.lock is, but I had them backfire on me often enough during collaboration with colleagues in ways where only deleting them would fix the problem.\nA usual problem was that using different operation systems or python versions would lead to different lockfiles, and that just doesn't fly. I'll gladly let our CI build and persist an authoritative reference-lockfile to enable re-builds, but it still wouldn't be committed to the repository.\nIf maintaining a shared lockfile is viable given your workflow - great! You avoid a step in your pipeline, have one less artifact to worry about, and cut down dramatically on build time (even a medium-size project can take minutes to do a full dependency-resolution).\nBut as far as best practices go, I'd consider adding poetry.lock to the .gitignore a better practice than what you do, and only commit pyproject.toml changes when you add dependencies."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Another Git process seems to be running in this repository\nI'm trying to learn how to use Git and have created a small project with an HTML, CSS, and JavaScript file. I made a branch from my basically empty project and then made some changes to my code. I tried staging the changes, but I get the following error message:\nAnother git process seems to be running in this repository, e.g.\nan editor opened by 'git commit'. Please make sure all processes\nare terminated then try again. If it still fails, a git process\nmay have crashed in this repository earlier:\nremove the file manually to continue.\n\nGranted, I did run into problems trying to commit my empty project earlier and just quit Git Bash since I didn't know how to get out of where I somehow had gotten.\nIs there a way for me to fix this or should I just start a new repository?"
},
{
"role": "assistant",
"content": "Try deleting index.lock file in your .git directory or in one of your worktrees .git/worktrees/*/index.lock if you are in a worktree.\nrm -f .git/index.lock\n\nSuch problems generally occur when you execute two git commands simultaneously; maybe one from the command prompt and one from an IDE."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitLab remote: HTTP Basic: Access denied and fatal Authentication\nUnlike this post, I am on macOS.\nI have the password configured in GitLab. I also have an SSL key created after the project was made on GitLab.\nWhen I use an existing folder for a new project and follow the steps below, I am prompted to enter my GitLab username and password.\nExisting folder\ncd existing_folder\ngit init\ngit remote add origin https://gitlab.com/sobopla/Geronimod.git\ngit add .\ngit commit -m \"Initial commit\"\ngit push -u origin master\n\nAfter the password is entered I get the following error.\n\nremote: HTTP Basic: Access denied\nfatal: Authentication failed for 'https://gitlab.com/myname/myproject'"
},
{
"role": "assistant",
"content": "It happens every time I'm forced to change the Windows password and none of the above answers helped me.\nTry the below solution which works for me:\n\nGo to Windows Credential Manager. This is done in an EN-US Windows by pressing the Windows Key and typing 'credential'. In other\nlocalized Windows variants you need to use the localized term (See\ncomments for some examples).\nalternatively you can use the shortcut\ncontrol /name Microsoft.CredentialManager in the run dialog\n(WIN+R)\n\nEdit the git entry under Windows Credentials, replacing old\npassword with the new one."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Reverting specific commits from git\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": "How to prefer files from one branch during a merge?\nSome time ago I created a branch from my master branch. Let's call it new_feature. While I was working on new_feature, the master branch followed its normal evolution. Now that new_feature is ready to be merged into master I see some conflicts, all of them are into files that are totally unrelated to the actual new feature (like some config files and the likes that have changed on master). I'm going to solve the conflicts manually but I was wondering, since it's a situation that happens quite often, how I could just merge the new_feature branch into master while always keeping the master version of the files in case of conflict?\nI'm sure it's easy and is related to something like 'keep version' but since it's a pretty sensitive subject I'd rather ask than be sorry."
},
{
"role": "assistant",
"content": "As mention in the comment there are several strategies in the documentation. You can also find them here: http://git-scm.com/docs/git-merge\nYou are looking for either git merge -s recursive -X ours or git merge -s recursive -X theirs depending on the branch that you are on. Be careful with these as you can accidentally miss changes to your files from the other branch and these would be overwritten.\nAnother method, which I prefer due to more control, is to git checkout <other-branch> -- <list of files>. This way I don't accidentally overwrite a file with the wrong changes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab CI/CD cannot git push from .gitlab-ci.yml\n\nI'm writing GitLab CI/CD pipeline script in .gitlab-ci.yml\nI want to check if a specific file changed in another repo and if so I would like to copy the file, commit and push to the current repo.\neverything works until I get to the 'git push' part\nI tried several ways to fixed it:\nstages:\n - build\n\nbuild:\n stage: build\n script:\n - echo \"Building\"\n - git checkout -b try\n - git remote add -f b https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.{otherRepo}.git\n - git remote update\n - CHANGED=$(git diff try:mobile_map.conf b/master:mobile_map.conf)\n - if [ -n \"${CHANGED}\" ]; then\n echo 'changed';\n FILE=$(git show b/master:mobile_map.conf > mobile_map.conf);\n git add mobile_map.conf;\n git commit -m \"updating conf file\";\n git push;\n else\n echo 'not changed';\n fi\n - git remote rm b\n\nfor this code I get :\nfatal: unable to access 'https://gitlab-ci-token:[MASKED]@gitlab.{curr_repo}.git/': The requested URL returned error: 403\n\nalso I tried to add this line in the beginning :\ngit remote set-url origin 'https://{MY_USER_NAME}:\"\\\"${PASSWORD}\\\"\"@gitlab.{curr_repo}.git'\n\nand I get this error message:\nfatal: Authentication failed for 'https://{MY_USER_NAME}:\"\\\"${PASSWORD}\\\"\"@{curr_repo}.git/'\n\nalso I added:\n - git config --global user.name {MY_USER_NAME}\n - git config --global user.email {MY_EMAIL}\n\nplease help me,\nThanks"
},
{
"role": "assistant",
"content": "Job-tokens only have read-permission to your repository.\n\nA unique job token is generated for each job and provides the user read access all projects that would be normally accessible to the user creating that job. The unique job token does not have any write permissions, but there is a proposal to add support.\n\nYou can't use deploy-tokens because they can't have write-access to a repository (possible tokens).\nYou could use a project-access-token with read-write-access to your repository.\n\nYou can use project access tokens:\n\nOn GitLab SaaS if you have the Premium license tier or higher. Project\naccess tokens are not available with a trial license.\n\nOn self-managed instances of GitLab, with any license tier. If you\nhave the Free tier: [...]\n\n\n\n\nThen you can use your project-access-token as an environment variable in the url.\ngit push \"https://gitlab-ci-token:$PROJECT_ACCESS_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git\"\n\nAt least that's how we use it in our pipelines.\nI hope this helps you further."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why does git pull hang?\nWhen I do a git pull, from the git bash, the terminal usually runs the pull, updates my local, and then hangs. I'm not sure if it's waiting for me to do something, but I usually exit out of this with CTRL-C. After that, I get that an index.lock is preventing me from doing other things to which I have to delete it. Am I misunderstanding how git pull works?"
},
{
"role": "assistant",
"content": "You may need to remove unnecessary git objects such as dangling commits & blobs:\ngit fsck && git gc --prune=now\n\n\ngit-fsck : Verifies the connectivity and validity of the objects in the database\ngit-gc : Cleanup unnecessary files and optimize the local repository\n\nYou can refer here about dangling commits & blobs."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: Where exactly is the \"working directory\"?\nI am going through some Git tutorials. The concept of a \"working directory\" keeps being mentioned, however, none of the tutorials or documents I read points out where or what this \"working directory\" is.\nI have thought that it was actually the .git's parent directory, a.k.a the directory I run git init in. But the video tutorial I am watching talks about the state of nothing to commit and \"working directory clean\":\n\nIn fact you can actually make a copy of the repository, and make that\n copy so that it does not have a working directory, this is actually\n called the bare clone. This is actually what GitHub uses.\n\nIf my understanding of the \"working directory\" is correct, how can a repository not have a \"working directory\"? And what does it mean, when it says that GitHub uses a \"bare clone\"?"
},
{
"role": "assistant",
"content": "This should hopefully clear things up for us:\n\nWhat is the difference between a repository created using the git init\n command and the git init --bare command?\nRepositories created with the git init command are called working\n directories. In the top level folder of the repository you will find\n two things:\nA .git subfolder with all the git related revision history of your repo\nA working tree, or checked out copies of your project files.\n\nRepositories created with git init --bare are called bare repos. They\n are structured a bit differently from working directories. First off,\n they contain no working or checked out copy of your source files. And\n second, bare repos store git revision history of your repo in the root\n folder of your repository instead of in a .git subfolder. Note… bare\n repositories are customarily given a .git extension.\n\nTaken from John Saints - What is a bare git repository?\nA bare git clone does not contain a working directory of checked out code, in other words.\nThink of it as just the .git directory (the Git database) without anything else."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to use gitignore command in git\n\nI'm working first time on git. I have pushed my branch on github and it pushed all the library and documents into the github. Now what can I do and how can I use gitignore command to avoid the same mistake again."
},
{
"role": "assistant",
"content": "So based on what you said, these files are libraries/documentation you don't want to delete but also don't want to push to github. Let say you have your project in folder your_project and a doc directory: your_project/doc.\n\nRemove it from the project directory (without actually deleting it):\ngit rm --cached doc/* \nIf you don't already have a .gitignore, you can make one right inside of your project folder: project/.gitignore. \nPut doc/* in the .gitignore \nStage the file to commit: git add project/.gitignore\nCommit: git commit -m \"message\". \nPush your change to github."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is it better to use git grep than plain grep if we want to search in versioned source code?\nIn a git repository, is there any difference/benefit using git grep over good old grep?\nAn example would be?"
},
{
"role": "assistant",
"content": "The two are very similar. The main difference is that git grep defaults to searching in the files that are tracked by git.\nExamples\nIf I want to find foo within my project I can use git grep or good ol' stand-alone grep:\ngit grep foo\ngrep -R foo .\n\nThe git grep version will only search in files tracked by git, whereas the grep version will search everything in the directory. So far so similar; either one could be better depending on what you want to achieve.\nWhat if we want to limit the search to only .rb files?\ngit grep foo -- *.rb\ngrep -R --include=*.rb foo .\n\nThe plain old grep version is getting a bit more wordy, but if you're used to using grep that may not be a problem. They're still not going to search exactly the same files, but again it depends on what you want to achieve.\nWhat about searching in the previous version of the project?\ngit grep foo HEAD^\ngit checkout HEAD^; grep -R foo .; git checkout -\n\nThis is where git grep makes a real difference: You can search in another revision of the project without checking it out first. This isn't a situation that comes up too often for me though; I usually want to search in the version of the project I have checked out.\nConfiguring git grep\nThere are some git config variables that modify the behaviour of git grep and avoid the need to pass a couple of command line arguments:\n\ngrep.lineNumber: Always show line numbers of matches (you can pass -n to both grep and git grep to get this behaviour)\ngrep.extendedRegexp: Always use extended regular expressions (you can pass -E to both grep and git grep to get this behaviour)\n\nIn practice\nIn practice I have gg aliased to git grep -En, and this almost always does what I want."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why is the Python calculated \"hashlib.sha1\" different from \"git hash-object\" for a file?\nI'm trying to calculate the SHA-1 value of a file. \nI've fabricated this script:\ndef hashfile(filepath):\n sha1 = hashlib.sha1()\n f = open(filepath, 'rb')\n try:\n sha1.update(f.read())\n finally:\n f.close()\n return sha1.hexdigest()\n\nFor a specific file I get this hash value:\n8c3e109ff260f7b11087974ef7bcdbdc69a0a3b9\nBut when i calculate the value with git hash_object, then I get this value: d339346ca154f6ed9e92205c3c5c38112e761eb7\nHow come they differ? Am I doing something wrong, or can I just ignore the difference?"
},
{
"role": "assistant",
"content": "git calculates hashes like this: \nsha1(\"blob \" + filesize + \"\\0\" + data)\n\nReference"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects %<( <N> [,trunc|ltrunc|mtrunc])"
},
{
"role": "assistant",
"content": "make the next placeholder take at\nleast N column widths, padding spaces on\nthe right if necessary. Optionally\ntruncate (with ellipsis .. ) at the left (ltrunc) ..ft ,\nthe middle (mtrunc) mi..le , or the end\n(trunc) rig.. , if the output is longer than\nN columns.\nNote 1: that truncating\nonly works correctly with N >= 2.\nNote 2: spaces around the N and M (see below)\nvalues are optional.\nNote 3: Emojis and other wide characters\nwill take two display columns, which may\nover-run column boundaries.\nNote 4: decomposed character combining marks\nmay be misplaced at padding boundaries."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to use GitLab CI with a custom Docker image?\n\nI made a simple Dockerfile:\nFROM openjdk\nEXPOSE 8080\n\nand built an image using:\ndocker build -t test .\n\nI installed and configured a docker GitLab CI runner and now I would like to use this runner with my test image. So I wrote the following .gitlab-ci.yml file:\nimage: test\n\nrun:\n script:\n - echo \"Hello world!\"\n\nBut to my disappointment, the local test image that I can use on my machine was not found.\nRunning with gitlab-ci-multi-runner 9.4.2 (6d06f2e)\n on martin-docker-rawip (70747a61)\nUsing Docker executor with image test ...\nUsing docker image sha256:fa91c6ea64ce4b9b44672c6e56eed8312d0ec2afc80730cbee7754bc448ea22b for predefined container...\nPulling docker image test ...\nERROR: Job failed: Error response from daemon: repository test not found: does not exist or no pull access\n\nI do not even know what is going on anymore. How can I make the runner aware of this image that I made?"
},
{
"role": "assistant",
"content": "I had the same question. And I found the answer here: https://forum.gitlab.com/t/runner-cant-use-local-docker-images/5507/6\nAdd the following in the /etc/gitlab-runner/config.toml\n[runners.docker]\n# more config for the runner here...\npull_policy = \"if-not-present\"\n\nMore info here: https://docs.gitlab.com/runner/executors/docker.html#how-pull-policies-work\nMy Dockerfile\nFROM node:latest\nRUN apt-get update -y && apt-get install openssh-client rsync -y\n\nOn the runner I build the image:\ndocker build -t node_rsync .\n\nThe .gitlab-ci.yml in the project using this runner.\nimage: node_rsync\n\njob:\n stage: deploy\n before_script:\n # now in the custom docker image\n #- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'\n - mkdir -p ~/.ssh\n - eval $(ssh-agent -s)\n - '[[ -f /.dockerenv ]] && echo -e \"Host *\\n\\tStrictHostKeyChecking no\\n\\n\" > ~/.ssh/config'\n - ssh-add <(tr '@' '\\n' <<< \"$STAGING_PRIVATE_KEY\" | base64 --decode)\n # now in the custom docker image\n #- apt-get install -y rsync\n script:\n - rsync -rav -e ssh --exclude='.git/' --exclude='.gitlab-ci.yml' --delete-excluded ./ $STAGING_USER@$STAGING_SERVER:./deploy/\n only:\n - master\n tags:\n - ssh"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "create version.txt file in project dir via build.gradle task\nApologies in advance for my ignorance. I'm very new to gradle.\nMy is goal is to have some task in my build.gradle file, wherein a file 'version.txt' is created in my project directory whenever I run the gradle terminal command in my project root. This 'version.txt' file needs to contain version metadata of the build, such as:\nVersion: 1.0\nRevision: 1z7g30jFHYjl42L9fh0pqzmsQkF\nBuildtime: 2016-06-14 07:16:37 EST\nApplication-name: foobarbaz app\n(^Revision would be the git commit hash of the HEAD)\nI've tried to reuse snippets from the following resources, but to no avail, possibly because these resources are out of date:\nhttp://mrhaki.blogspot.com/2015/04/gradle-goodness-use-git-commit-id-in.html\nhttp://mrhaki.blogspot.com/2010/10/gradle-goodness-add-incremental-build.html\nI'm using gradle version 2.14 (which is the latest version).\nAny help and/or insight would be very much appreciated. Thanks!"
},
{
"role": "assistant",
"content": "The example you're referring to is almost correct. With a couple of minor tweaks it works as expected:\nimport java.text.SimpleDateFormat\nimport org.ajoberstar.grgit.Grgit\n\nplugins {\n id \"org.ajoberstar.grgit\" version \"1.7.2\"\n}\n\nversion = 1.0\n\ntask versionTxt() {\n doLast {\n new File(projectDir, \"version.txt\").text = \"\"\"\nVersion: $version\nRevision: ${grgit.head().abbreviatedId}\nBuildtime: ${new SimpleDateFormat(\"dd-MM-yyyy HH:mm:ss\").format(new Date())}\nApplication-name: foobarbaz app\n\"\"\"\n }\n}\n\nRun gradle versionTxt to get the desired output."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Find where code was deleted in a Git repository\nHow do I find code that was deleted?\nI ended up finding where it was created with this:\n$ git log --pretty=oneline -S'some code'\n\nAnd that's good enough, but I was also curious to find where it got deleted, and so far, no dice.\nFirst, I tried git diff HEAD..HEAD^ | grep 'some code', expanding the range each time, until I found the lines where it was removed. Nice, so suppose I found it on range HEAD^^..HEAD^^^, then I do git show HEAD^^^ and git show HEAD^^ with grep, but the code is nowhere to be found!\nThen I read up a bit on git bisect, and sure enough, it gives me a single revision where the culprit is supposed to be... Again, git show rev | grep 'some code' comes up empty...\nWhat am I doing wrong?"
},
{
"role": "assistant",
"content": "git log -S<string> does the job, but if you need to make more complex searches you can use git log -G<regex>.\nFrom the man:\n\n-G<regex>\nLook for differences whose patch text contains added/removed lines\n that match <regex>."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to reset / clean a GitLab repository\n\nI want to reset one of my repositories on gitlab, but without deleting the whole project.\nI've read on Gitlab Forums (on the post https://forum.gitlab.com/t/how-can-i-delete-a-repository-and-push-a-new-one/690) two different options:\nFirst: Deleting the physical repository from disk. I've tried renaming the folder (repo.git) but then, gitlab gives me a 404 error trying to access to it.\nSecond: Deleting all branches. This solution do not work too, because, I cannot delete the main branch (on my case master), and when I create a new one, the new branch requires to specify a \"original\" branch. I cannot create a clean branch without any data and change the main to it.\nSomeone know how to do it?\nThanks,"
},
{
"role": "assistant",
"content": "Delete all branches except master, unprotect master in settings -> repository -> protected branches and execute:\ngit push -f master origin ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-describe - Give an object a human readable name based on an available ref"
},
{
"role": "assistant",
"content": "EXAMPLES With something like git.git current tree, I get: [torvalds@g5 git]$ git describe parent\nv1.0.4-14-g2414721 i.e. the current head of my \"parent\" branch is based on v1.0.4,\nbut since it has a few commits on top of that,\ndescribe has added the number of additional commits (\"14\") and\nan abbreviated object name for the commit itself (\"2414721\")\nat the end. The number of additional commits is the number\nof commits which would be displayed by \"git log v1.0.4..parent\".\nThe hash suffix is \"-g\" + an unambiguous abbreviation for the tip commit\nof parent (which was 2414721b194453f058079d897d13c4e377f92dc6 ). The\nlength of the abbreviation scales as the repository grows, using the\napproximate number of objects in the repository and a bit of math\naround the birthday paradox, and defaults to a minimum of 7.\nThe \"g\" prefix stands for \"git\" and is used to allow describing the version of\na software depending on the SCM the software is managed with. This is useful\nin an environment where people may use different SCMs. Doing a git describe on a tag-name will just show the tag name: [torvalds@g5 git]$ git describe v1.0.4\nv1.0.4 With --all, the command can use branch heads as references, so\nthe output shows the reference path as well: [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2\ntags/v1.0.0-21-g975b [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^\nheads/lt/describe-7-g975b With --abbrev set to 0, the command can be used to find the\nclosest tagname without any suffix: [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2\ntags/v1.0.0 Note that the suffix you get if you type these commands today may be\nlonger than what Linus saw above when he ran these commands, as your\nGit repository may have new commits whose object names begin with\n975b that did not exist back then, and \"-g975b\" suffix alone may not\nbe sufficient to disambiguate these commits."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What does ^{} mean in git?\nI stumbled upon two odd characters at the end of a git ls-remote command and I wonder what this means?\n0e4c39557ccb6789173c refs/tags/2011-11-04\n966f8df553f18c486820 refs/tags/2011-11-04^{}\n\nDo you happen to know what this ^{} means? Also, why does this git tag seems duplicated?"
},
{
"role": "assistant",
"content": "The ^{} notation is explained in the gitrevisions manual:\n<rev>^{}, e.g. v0.99.8^{} \n\n\nA suffix ^ followed by an empty brace pair means the object could be a tag, and dereference the tag recursively until a non-tag object is found.\n\nIn this case - refs/tags/2011-11-04 is the tag that points to the tag object 0e4c39557ccb6789173c. By doing refs/tags/2011-11-04^{} we can dereference the tag to the final non-tag object, which in this case is - 966f8df553f18c486820 (a commit). Note that ^{} is a noop when applied to non-tag objects.\nThe git show-ref command can be use to see tags as well as the final dereferenced non-tag objects:\n$ git show-ref --tags\n3521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0.99.9c\n423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1.0rc4^{}\n\n$ git show-ref --tags --dereference\n3521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0.99.9c\n6ddc0964034342519a87fe013781abf31c6db6ad refs/tags/v0.99.9c^{}\n055e4ae3ae6eb344cbabf2a5256a49ea66040131 refs/tags/v1.0rc4\n423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1.0rc4^{}\n\nFrom the git show-ref manual:\n-d \n--dereference \n\n\nDereference tags into object IDs as well. They will be shown with \"^{}\" appended."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Property to prevent gitlab from protecting default branches\n\nWith version 7.4 gitlab changed the behaviour of protected branches in new projects.\nIn every new project the default branch e.g. master is a protected branch, meaning developers are not able to push to it. In my company a lot of developers work on the default/master branch and are now struggeling when starting a new project.\nMy Question: Is there a property in the ui or in the gitlab.rb to restore the pre 7.4 behaviour and to not protect the default branch?"
},
{
"role": "assistant",
"content": "I'm not Sure if the is a default param, but per project you can change master as unprotected , in your project, go to settings -> protected branches and unprotect master\n\nUpdate\nThe gilt team published a post related to your question!!\nhttps://about.gitlab.com/2014/11/26/keeping-your-code-protected/"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-apply - Apply a patch to files and/or to the index --unidiff-zero"
},
{
"role": "assistant",
"content": "By default, git apply expects that the patch being\napplied is a unified diff with at least one line of context.\nThis provides good safety measures, but breaks down when\napplying a diff generated with --unified=0 . To bypass these\nchecks use --unidiff-zero . Note, for the reasons stated above, the usage of context-free patches is\ndiscouraged."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout - Switch branches or restore working tree files --no-track"
},
{
"role": "assistant",
"content": "Do not set up \"upstream\" configuration, even if the branch.autoSetupMerge configuration variable is true."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Should Gemfile.lock be included in .gitignore?\nI'm sort of new to bundler and the files it generates. I have a copy of a git repo from GitHub that is being contributed to by many people so I was surprised to find that bundler created a file that didn't exist in the repo and wasn't in the .gitignore list.\nSince I have forked it, I know adding it to the repo won't break anything for the main repo, but if I do a pull request, will it cause a problem?\nShould Gemfile.lock be included in the repository?"
},
{
"role": "assistant",
"content": "Update for 2022 from TrinitronX\n\n\nFast-forward to 2021 and now Bundler docs [web archive] now say to commit the Gemfile.lock inside a gem... ¯_(ツ)_/¯ I guess it makes sense for developers and ease of use when starting on a project. However, now CI jobs need to be sure to remove any stray Gemfile.lock files to test against other versions.\n\nLegacy answer ~2010\nAssuming you're not writing a rubygem, Gemfile.lock should be in your repository. It's used as a snapshot of all your required gems and their dependencies. This way bundler doesn't have to recalculate all the gem dependencies each time you deploy, etc.\nFrom cowboycoded's comment below:\n\nIf you are working on a gem, then DO NOT check in your Gemfile.lock. If you are working on a Rails app, then DO check in your Gemfile.lock.\n\nHere's a nice article explaining what the lock file is."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-mergetool - Run merge conflict resolution tools to resolve merge conflicts mergetool.keepTemporaries"
},
{
"role": "assistant",
"content": "When invoking a custom merge tool, Git uses a set of temporary\nfiles to pass to the tool. If the tool returns an error and this\nvariable is set to true , then these temporary files will be\npreserved; otherwise, they will be removed after the tool has\nexited. Defaults to false ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Install specific git commit with pip\nI'm developing a django app and I'm using pip to manage my requirements. How can I do to install a specific git's commit?\nIn my case I need to install this commit:\nhttps://github.com/aladagemre/django-notification/commit/2927346f4c513a217ac8ad076e494dd1adbf70e1"
},
{
"role": "assistant",
"content": "You can specify commit hash, branch name, tag.\nFor the branch name and the tag, you can also install a compressed distribution. This is faster and more efficient, as it does not require cloning the entire repository. GitHub creates those bundles automatically.\nhash:\n$ pip install git+https://github.com/aladagemre/django-notification.git@2927346f4c513a217ac8ad076e494dd1adbf70e1\n\nbranch-name\nWith git\n$ pip install git+https://github.com/aladagemre/django-notification.git@cool-feature-branch\n\nor from source bundle\n$ pip install https://github.com/aladagemre/django-notification/archive/cool-feature-branch.tar.gz\n\ntag\nwith git\n$ pip install git+https://github.com/aladagemre/[email protected]\n\nor from source bundle\n$ pip install https://github.com/aladagemre/django-notification/archive/v2.1.0.tar.gz\n\nIt is a not well-documented feature, but you can find more information at https://pip.pypa.io/en/latest/topics/vcs-support/"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --all-match"
},
{
"role": "assistant",
"content": "Limit the commits output to ones that match all given --grep ,\ninstead of ones that match at least one."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-prune"
},
{
"role": "assistant",
"content": "Prune all unreachable objects from the object database"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-check-ignore - Debug gitignore / exclude files 0"
},
{
"role": "assistant",
"content": "One or more of the provided paths is ignored."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Practical uses of git reset --soft?\nI have been working with git for just over a month. Indeed I have used reset for the first time only yesterday, but the soft reset still doesn't make much sense to me.\nI understand I can use the soft reset to edit a commit without altering the index or the working directory, as I would with git commit --amend. \nAre these two commands really the same (reset --soft vs commit --amend)? Any reason to use one or the other in practical terms? And more importantly, are there any other uses for reset --soft apart from amending a commit?"
},
{
"role": "assistant",
"content": "git reset is all about moving HEAD, and generally the branch ref.\nQuestion: what about the working tree and index?\nWhen employed with --soft, moves HEAD, most often updating the branch ref, and only the HEAD.\nThis differs from commit --amend as:\n\nit doesn't create a new commit.\nit can actually move HEAD to any commit (as commit --amend is only about not moving HEAD, while allowing to redo the current commit)\n\n\nJust found this example of combining:\n\na classic merge\na subtree merge\n\nAll into one (octopus, since there are more than two branches merged) commit merge.\nTomas \"wereHamster\" Carnecky explains in his \"Subtree Octopus merge\" article:\n\n\nThe subtree merge strategy can be used if you want to merge one project into a subdirectory of another project, and the subsequently keep the subproject up to date. It is an alternative to git submodules.\n\n\n\nThe octopus merge strategy can be used to merge three or more branches. The normal strategy can merge only two branches and if you try to merge more than that, git automatically falls back to the octopus strategy.\n\n\nThe problem is that you can choose only one strategy. But I wanted to combine the two in order to get a clean history in which the whole repository is atomically updated to a new version.\nI have a superproject, let's call it projectA, and a subproject, projectB, that I merged into a subdirectory of projectA.\n\n(that's the subtree merge part)\n\nI'm also maintaining a few local commits.\nProjectA is regularly updated, projectB has a new version every couple days or weeks and usually depends on a particular version of projectA.\nWhen I decide to update both projects, I don't simply pull from projectA and projectB as that would create two commits for what should be an atomic update of the whole project.\nInstead, I create a single merge commit which combines projectA, projectB and my local commits.\nThe tricky part here is that this is an octopus merge (three heads), but projectB needs to be merged with the subtree strategy. So this is what I do:\n# Merge projectA with the default strategy:\ngit merge projectA/master\n\n# Merge projectB with the subtree strategy:\ngit merge -s subtree projectB/master\n\n\nHere the author used a reset --hard, and then read-tree to restore what the first two merges had done to the working tree and index, but that is where reset --soft can help:\nHow do I redo those two merges, which have worked, i.e. my working tree and index are fine, but without having to record those two commits?\n# Move the HEAD, and just the HEAD, two commits back!\ngit reset --soft HEAD@{2}\n\nNow, we can resume Tomas's solution:\n# Pretend that we just did an octopus merge with three heads:\necho $(git rev-parse projectA/master) > .git/MERGE_HEAD\necho $(git rev-parse projectB/master) >> .git/MERGE_HEAD\n\n# And finally do the commit:\ngit commit\n\n\nSo, each time:\n\nyou are satisfied with what you end up with (in terms of working tree and index)\nyou are not satisfied with all the commits that took you to get there:\n\ngit reset --soft is the answer.\n\nNote that --no-soft does not make sense, and Git 2.42 (Q3 2023) tells you so now.\nSee commit 3821eb6 (19 Jul 2023) by Junio C Hamano (gitster).\n(Merged by Junio C Hamano -- gitster -- in commit e672bc4, 27 Jul 2023)\n\ne672bc4f76:Merge branch 'jc/parse-options-reset'\n\n\nCommand line parser fix. * jc/parse-options-reset: reset: reject --no-(mixed|soft|hard|merge|keep) option\n\nYou would get an \"unknown option\" error."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I Remove .DS_Store files from a Git repository?\nHow can I remove those annoying Mac OS X .DS_Store files from a Git repository?"
},
{
"role": "assistant",
"content": "Remove existing .DS_Store files from the repository:\nfind . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch\n\nAdd this line:\n.DS_Store\n\nto the file .gitignore, which can be found at the top level of your repository (or create the file if it isn't there already). You can do this easily with this command in the top directory:\necho .DS_Store >> .gitignore\n\nThen commit the file to the repo:\ngit add .gitignore\ngit commit -m '.DS_Store banished!'"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is git stash stack pushed to the remote repo?\nIs my stash stack pushed to the remote repo? Or is it completely ignored? \nI'm just curious if I should tend to it every once in a while to drop some of it to save space on the server."
},
{
"role": "assistant",
"content": "No. Stashes are local. \n$ man git stash:\n\nUse git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away reverts the working directory to match the HEAD commit.\n\nI wouldn't keep too many of them around locally though. You'll lose track of them over time and they'll become somewhat useless."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Google Code + SVN or GitHub + Git [closed]\n\nClosed. This question is opinion-based. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it can be answered with facts and citations by editing this post.\n\n\nClosed 9 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nLet me start by telling you that I never used anything besides SVN and I'm also a Windows user.\nI have a couple of simple projects that are open-source, others are on their way when I'm happy enough to release their source code. Either way, I was thinking of using Google Code and SVN to share the source code of my projects instead of providing a link to the source on my website. This has always been a pain because I had to update the binaries and the code every time I released a new version. This would also help me to have a backup of my code some where instead of just my local machine (I used to have a local Subversion server running).\nWhat I want from a service like this is very simple... I just want a place to store my source code that people can download if they want, that allows me to control revisions and provide a simple and easy issue/bug system so people can submit bugs and stuff like that. I guess both of them have this.\nBut I don't want to host any binaries in their websites. I want this to be hosted on my website so I can control download statistics with my own scripts. I also don't have a need for wiki pages as I prefer to have all the documentation on my own website. Do any of these services provide a way to \"disable\" features like wiki and downloads and not show them at all for my project(s)?\nNow, I'm sure there are lots of pros and cons about using Google Code with SVN and GitHub with Git (of course) but here's what's important for me on each one, and why I like them:\nGoogle Code:\n\nAs with any Google page, the complexity is almost non-existent\nEveryone (or almost everyone) has a Google account, whcih is nice if people want to report problems using the issues system\n\nGitHub:\n\nMay (or may not) be a little more complex (not a problem for me though) than Google's pages but...\n...has a much prettier interface than Google's service\nIt needs people to be registered on GitHub to post about issues\nI like the fact that with Git, you have your own revisions locally (can I use TortoiseGit for this or?)\n\nBasically that's it. Not much, I know...\nWhat other common pros and cons can you tell me about each site/software? Keep in mind that my projects are simple, I'm probably the only one who will ever develop these projects on these repositories (or maybe not, but for now I am)."
},
{
"role": "assistant",
"content": "Google Code is supporting Mercurial now. Mercurial should give you most of the benefits of Git, but you get the maturity of Google Code. You also have the option to go with subversion there as well should you want to."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker"
},
{
"role": "assistant",
"content": "Reporting Bugs Report bugs to the Git mailing list < [email protected] > where the\ndevelopment and maintenance is primarily done. You do not have to be\nsubscribed to the list to send a message there. See the list archive\nat https://lore.kernel.org/git for previous bug reports and other\ndiscussions. Issues which are security relevant should be disclosed privately to\nthe Git Security mailing list < [email protected] >."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I call 'git pull' from within Python?\nUsing the github webhooks, I would like to be able to pull any changes to a remote development server. At the moment, when in the appropriate directory, git pull gets any changes that need to be made. However, I can't figure out how to call that function from within Python. I have tried the following:\nimport subprocess\nprocess = subprocess.Popen(\"git pull\", stdout=subprocess.PIPE)\noutput = process.communicate()[0]\n\nBut this results in the following error\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\n File \"/usr/lib/python2.7/subprocess.py\", line 679, in __init__\n errread, errwrite)\n File \"/usr/lib/python2.7/subprocess.py\", line 1249, in _execute_child\n raise child_exception\nOSError: [Errno 2] No such file or directory\n\nIs there a way that I can call this bash command from within Python?"
},
{
"role": "assistant",
"content": "Have you considered using GitPython? It's designed to handle all this nonsense for you.\nimport git # pip install gitpython\n\n\ng = git.cmd.Git(git_dir)\ng.pull()\n\nTo install the module use pip install GitPython\nProject can be found here, GitPython"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission --src-prefix=<prefix>"
},
{
"role": "assistant",
"content": "Show the given source prefix instead of \"a/\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitmodules"
},
{
"role": "assistant",
"content": "Defining submodule properties"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git with IntelliJ IDEA: Could not read from remote repository\nSince a few weeks, I'm not able to pull or push from or to the remote repository. I thought it happend when upgrading to IntelliJ IDEA 14, but I can reproduce the problem with IDEA 13.1.5 as well.\nThe tooltip says\n\"Fetch failed\nfatal: Could not read from remote repository.\"\nand the exception in the Version Control tab reads\n14:02:37.737: cd C:\\dev\\project\n14:02:37.737: git -c core.quotepath=false fetch origin --progress --prune\njava.io.IOException: Padding in RSA public key!\n at com.trilead.ssh2.signature.RSASHA1Verify.decodeSSHRSAPublicKey(RSASHA1Verify.java:37)\n at com.trilead.ssh2.KnownHosts.addHostkey(KnownHosts.java:98)\n at com.trilead.ssh2.KnownHosts.initialize(KnownHosts.java:414)\n at com.trilead.ssh2.KnownHosts.initialize(KnownHosts.java:440)\n at com.trilead.ssh2.KnownHosts.addHostkeys(KnownHosts.java:137)\n at org.jetbrains.git4idea.ssh.SSHMain.configureKnownHosts(SSHMain.java:462)\n at org.jetbrains.git4idea.ssh.SSHMain.start(SSHMain.java:155)\n at org.jetbrains.git4idea.ssh.SSHMain.main(SSHMain.java:137)\nfatal: Could not read from remote repository.\nPlease make sure you have the correct access rights\nand the repository exists.\n\nUsing the built-in terminal of IntelliJ, executing git -c core.quotepath=false fetch origin --progress --prune, it works just as it should.\nAccording to the stacktrace, there seems to be a problem with my KnownHosts, so I deleted our git server from ~/.ssh/known_hosts, hoping IntelliJ would insert it again. But the problem still appears when updating via the UI, and there is no new entry written in known_hosts; thinking about some caching of the file, I restarted IntelliJ, without success.\nWhen doing another git fetch from the terminal, now I'm getting asked if I want to permanently add the server. After that, it has been written to known_hosts again, but IntelliJ still won't let me update my project.\nI haven't found anything about this behavior online, so I guess it's not a known bug with the new IntelliJ version. Nevertheless, I updated to 14.0.2, but the problem still exists.\nIntelliJ is configured to use the built-in SSH executable.\nDoes anybody have a clue what could be the problem here?"
},
{
"role": "assistant",
"content": "Settings --> Version Control --> Git, and then, in the SSH executable dropdown, choose Native\n\nIf this doesn't help, ensure that your native ssh and git clients are of a sufficiently recent version."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git clone hangs forever on github\nWhen I follow point 5 (Test everything out) in the github guide, the ssh command also hangs forever. According to the guide, I should be presented with a message that \"Github does not provide shell access\". Below is my output from ssh -vT [email protected]\ndebug1: Authentication succeeded (publickey).\nAuthenticated to github.com ([207.97.227.239]:22).\ndebug1: channel 0: new [client-session]\ndebug1: Requesting [email protected]\ndebug1: Entering interactive session.\ndebug1: Sending environment.\ndebug1: Sending env LC_MESSAGES = en_US.UTF-8\ndebug1: Sending env LC_COLLATE = en_US.UTF-8\ndebug1: Sending env LANG = da_DK.UTF-8\ndebug1: Sending env LC_CTYPE = en_US.UTF-8"
},
{
"role": "assistant",
"content": "In my case port 22 was being blocked by a firewall, cloning via https may not work if you have 2-factor authentication enabled. Instead edit your .ssh config to use another port. In your terminal:\nnano ~/.ssh/config\n\nthen add this:\nHost github.com\n Hostname ssh.github.com\n Port 443"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options format.encodeEmailHeaders"
},
{
"role": "assistant",
"content": "Encode email headers that have non-ASCII characters with\n\"Q-encoding\" (described in RFC 2047) for email transmission.\nDefaults to true."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-push - Update remote refs along with associated objects git push origin HEAD"
},
{
"role": "assistant",
"content": "A handy way to push the current branch to the same name on the\nremote."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-apply - Apply a patch to files and/or to the index"
},
{
"role": "assistant",
"content": "SUBMODULES If the patch contains any changes to submodules then git apply treats these changes as follows. If --index is specified (explicitly or implicitly), then the submodule\ncommits must match the index exactly for the patch to apply. If any\nof the submodules are checked-out, then these check-outs are completely\nignored, i.e., they are not required to be up to date or clean and they\nare not updated. If --index is not specified, then the submodule commits in the patch\nare ignored and only the absence or presence of the corresponding\nsubdirectory is checked and (if possible) updated."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "No refs in common and none specified; doing nothing\nI had a local git project that I wanted to add to gitolite. Apparently this is hard so I abandoned the idea. I created a new gitolite repo by adding it to gitolite-admin/conf/gitolite.conf and committing and pushing the changes. Then I cloned the new repo with git clone git-noah:project-name successfully. I then copied all files and folders except .git to the project-name folder. I did,\ngit add -A\ngit commit -a -m \"Moved to new repo.\"\ngit push\n\nI get this error:\nwarning: push.default is unset; its implicit value is changing in\nGit 2.0 from 'matching' to 'simple'. To squelch this message\nand maintain the current behavior after the default changes, use:\n\n git config --global push.default matching\n\nTo squelch this message and adopt the new behavior now, use:\n\n git config --global push.default simple\n\nSee 'git help config' and search for 'push.default' for further information.\n(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode\n'current' instead of 'simple' if you sometimes use older versions of Git)\n\nNo refs in common and none specified; doing nothing.\nPerhaps you should specify a branch such as 'master'.\nfatal: The remote end hung up unexpectedly\nerror: failed to push some refs to 'git-noah:project-name'"
},
{
"role": "assistant",
"content": "No \"main\" exists yet on the remote (origin) repository.\ngit push origin main\n\nAfter this first push you can use the simpler\ngit push\n\nEdit:\nWith the recent trends my answer has been update to replace \"master\" with \"main\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why does git hash-object return a different hash than openssl sha1?\nContext: I downloaded a file (Audirvana 0.7.1.zip) from code.google to my Macbook Pro (Mac OS X 10.6.6).\nI wanted to verify the checksum, which for that particular file is posted as 862456662a11e2f386ff0b24fdabcb4f6c1c446a (SHA-1). git hash-object gave me a different hash, but openssl sha1 returned the expected 862456662a11e2f386ff0b24fdabcb4f6c1c446a.\nThe following experiment seems to rule out any possible download corruption or newline differences and to indicate that there are actually two different algorithms at play:\n$ echo A > foo.txt\n$ cat foo.txt\nA\n$ git hash-object foo.txt \nf70f10e4db19068f79bc43844b49f3eece45c4e8\n$ openssl sha1 foo.txt \nSHA1(foo.txt)= 7d157d7c000ae27db146575c08ce30df893d3a64\n\nWhat's going on?"
},
{
"role": "assistant",
"content": "You see a difference because git hash-object doesn't just take a hash of the bytes in the file - it prepends the string \"blob \" followed by the file size and a NUL to the file's contents before hashing. There are more details in this other answer on Stack Overflow:\n\nHow to assign a Git SHA1's to a file without Git?\n\nOr, to convince yourself, try something like:\n$ echo -n hello | git hash-object --stdin\nb6fc4c620b67d95f953a5c1c1230aaab5db5a1b0\n\n$ printf 'blob 5\\0hello' > test.txt\n$ openssl sha1 test.txt\nSHA1(test.txt)= b6fc4c620b67d95f953a5c1c1230aaab5db5a1b0"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-pull - Fetch from and integrate with another repository or a local branch"
},
{
"role": "assistant",
"content": "BUGS Using --recurse-submodules can only fetch new commits in already checked\nout submodules right now. When e.g. upstream added a new submodule in the\njust fetched commits of the superproject the submodule itself cannot be\nfetched, making it impossible to check out that submodule later without\nhaving to do a fetch again. This is expected to be fixed in a future Git\nversion."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to re-authorize the OAuth Application 'Git Credential Manager'\nI am part of an organization that uses SSO in Github. I don't have problem to access the repository through the web, it redirects me to SSO login and that's all.\nThe problem started when I logged-in first to my personal repository on GitHub through Git-Bash, I did some changes and then I wanted to do changes in a repository from my organization. When I run the below command, it wrote me that I need to re-authorize the OAuth Application, but I don't understand how:\n$ git push --delete origin v0.1.3\nremote: The `<my_company>' organization has enabled or enforced SAML SSO. To access\nremote: this repository, you must re-authorize the OAuth Application `Git Credential Manager`.\nfatal: unable to access 'https://github.com/<my_company>/myproj.git/': The requested URL returned error: 403\n\nHow can I re-authorize the login?\nI tried to re-open Git-Bash but it wrote me the same error."
},
{
"role": "assistant",
"content": "My company just enabled SSO for my Github Org overnight so was getting the same error running git pull. I fixed this with the following steps.\n\nOpen Credential Manager in Windows and delete the existing credential for github.com\nRe-initialise the cred manager in git bash: git config --global credential.helper manager-core\nRe-run git pull and follow the pop-up instructions to authenticate in a browser (which happened automatically for me with SSO).\n\nAfter those steps git commands worked for me again."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options core.restrictinheritedhandles"
},
{
"role": "assistant",
"content": "Windows-only: override whether spawned processes inherit only standard\nfile handles ( stdin , stdout and stderr ) or all handles. Can be auto , true or false . Defaults to auto , which means true on\nWindows 7 and later, and false on older Windows versions."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I use PowerShell with Gitlab CI in Gitlab Pages?\n\nHow do I use PowerShell commands/scripts with Gitlab CI in a .gitlab-ci.yml file which is used to deploy to gitlab pages?\nI am trying to execute the build.ps1 file from .gitlab-ci.yml, but when it reaches the build.ps1 line, it gives an error saying\n/bin/bash: line 5: .build.ps1: command not found\nI am trying to use the PowerShell script to convert a file in my repo and have the converted file deployed to gitlab pages using .gitlab-ci.yml\nHere is my code:\n.gitlab.yml\npages:\n stage: deploy\n script:\n - mkdir .public\n - .\\build.ps1\n - cp -r * .public\n - mv .public public\n artifacts:\n paths:\n - public\n only:\n - master"
},
{
"role": "assistant",
"content": "I have been able to figure out a solution to my own question.\nSolution\nTo Run PowerShell Command/Script from a .gitlab-ci.yml file on a gitlab.com using the Gitlab CI, you need to make sure that the contents of your .gitlab-ci.yml file is as shown below. \nNote: The .gitlab-ci.yml below works without having to install a Gitlab Runner on your own machine and has been tested on the http://gitlab.com website.\nimage: philippheuer/docker-gitlab-powershell\n\npages:\n stage: deploy\n script:\n - mkdir .public\n # run PowerShell Script\n - powershell -File build.ps1\n # run PowerShell Command\n - powershell -Command \"Get-Date\"\n - cp -r * .public\n - mv .public public\n artifacts:\n paths:\n - public\n only:\n - master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-filter-branch - Rewrite branches"
},
{
"role": "assistant",
"content": "WARNING git filter-branch has a plethora of pitfalls that can produce non-obvious\nmanglings of the intended history rewrite (and can leave you with little\ntime to investigate such problems since it has such abysmal performance).\nThese safety and performance issues cannot be backward compatibly fixed and\nas such, its use is not recommended. Please use an alternative history\nfiltering tool such as git\nfilter-repo . If you still need to use git filter-branch , please\ncarefully read SAFETY (and PERFORMANCE ) to learn about the land\nmines of filter-branch, and then vigilantly avoid as many of the hazards\nlisted there as reasonably possible."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can I specify multiple users for myself in .gitconfig?\nIn my ~/.gitconfig, I list my personal email address under [user], since that's what I want to use for Github repos.\nBut, I've recently started using git for work, too. My company's git repo allows me to commit, but when it sends out announcements of new changesets, it says they are from Anonymous because it doesn't recognize the email address in my .gitconfig - at least, that's my theory.\nIs it possible to specify multiple [user] definitions in .gitconfig? Or is there some other way to override the default .gitconfig for a certain directory? In my case, I check out all work code in ~/worksrc/ - is there a way to specify a .gitconfig for only that directory (and its subdirectories)?"
},
{
"role": "assistant",
"content": "You can configure an individual repo to use a specific user / email address which overrides the global configuration. From the root of the repo, run\ngit config user.name \"Your Name Here\"\ngit config user.email [email protected]\n\nwhereas the default user / email is configured in your ~/.gitconfig\ngit config --global user.name \"Your Name Here\"\ngit config --global user.email [email protected]"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gittutorial-2"
},
{
"role": "assistant",
"content": "A tutorial introduction to Git: part two"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to resolve a Git \"CONFLICT (modify/delete)\"?\nI run into a Git merge conflict which I have seen before. \n>git pull origin dev\nFrom https://scm.starbucks.com/roastery-milan/choreographer\n * branch dev -> FETCH_HEAD\nCONFLICT (modify/delete): <file name omitted> deleted in HEAD and modified in 01b734b9ae8594f03f5e481b123d80e41fb54d7c. Version 01b734b9ae8594f03f5e481b123d80e41fb54d7c of <file name omitted> left in tree.\n...\nAutomatic merge failed; fix conflicts and then commit the result.\n\nWhen I look at those conflicted files, I don't see any indication of conflicts. I guess that I need to change the Git HEAD. But, how to do so?\nBTW, our GitHub has some changes recently and there are more branches for staging.\nUpdate:\nThanks everyone for your inputs. Now, I know how to deal this problem."
},
{
"role": "assistant",
"content": "The message says that you deleted a file in your current branch and someone else modified it in the branch you are pulling. You need to decide what to do with the file.\nIf you want to keep the file\n$ git checkout <filename>\n$ git add <filename>\n$ git commit\n\nIf you want to discard the file\n$ git rm <filename>\n$ git commit\n\nIf the file was moved, you need to copy the changes over to the new location."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-svn - Bidirectional operation between a Subversion repository and Git show-externals"
},
{
"role": "assistant",
"content": "Shows the Subversion externals. Use -r/--revision to specify a\nspecific revision."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-pull - Fetch from and integrate with another repository or a local branch --squash --no-squash"
},
{
"role": "assistant",
"content": "Produce the working tree and index state as if a real merge\nhappened (except for the merge information), but do not actually\nmake a commit, move the HEAD , or record $GIT_DIR/MERGE_HEAD (to cause the next git commit command to create a merge\ncommit). This allows you to create a single commit on top of\nthe current branch whose effect is the same as merging another\nbranch (or more in case of an octopus). With --no-squash perform the merge and commit the result. This\noption can be used to override --squash. With --squash, --commit is not allowed, and will fail. Only useful when merging."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects off, none"
},
{
"role": "assistant",
"content": "Disable output of diffs for merge commits. Useful to override\nimplied value."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "This repository is configured for Git LFS but 'git-lfs' was not found on your path\nPlease help me understand what the below error message means and how to comply with its request.\nI want to copy an existing local git repo; then push that copy to a newly created remote.\nBut I get the following error:\n\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/pre-push.\n\nThe code I used immediately prior to getting this message is:\n# create new git repo at https://github.com/username/foo-bar.git\ncp -r OldProject/ NewProject/\ncd NewProject/\ngit remote remove origin # Remove prior origin from copy operation\ngit init\ngit remote add origin https://github.com/username/foo-bar.git\ngit add -A\ngit commit -m \"first commit\"\ngit push -u origin master\n\nWhat am I doing wrong and how can I fix it? Please help me understand what the above error message means and how to comply with its request."
},
{
"role": "assistant",
"content": "This repository is configured for Git LFS but 'git-lfs' was not found on your path\n\nLFS is \"Large File Storage\" an extension for git that keeps large files outside of the actual repository so it doesn't become slow. When the error says \"not found on your path\" it means git was looking for a program that you don't have installed. You can install it using the instructions on https://git-lfs.github.com/.\nA hook, by the way, is a bit of code git runs when you do some action. They are stored in the repository, in the hidden directory .git/hooks."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitlab-ci build asp.net core docker\n\nI am working on a gitlab CI/CD project to build an asp.net core application into a docker.\nCurrently I have 2 possible implementations in mind. The first one have the full logic in the Dockerfile, but I can't visualize the stages in Gitlab this way (build, test, publish). So I thought about moving the main logic to the gitlab-ci.yml file. But what bothers me now is that I have to manage the image docker dotnet versions on 2 places (sdk:3.1, aspnet:3.1.1-alpine3.10). Is it a good idea to deliver the version via build-arg or is there a more elegant solution?\n.gitlab-ci.yml\nstages:\n - build\n - test\n - docker\n\nbuild:\n stage: build\n image: mcr.microsoft.com/dotnet/core/sdk:3.1\n only:\n - master\n script:\n - cd src\n - dotnet restore --interactive\n - dotnet build --configuration Release\n - dotnet publish --configuration Release --output ../publish/\n artifacts:\n paths:\n - ./publish/*.*\n expire_in: 1 week\n tags:\n - docker\n\ntest:\n stage: test\n image: mcr.microsoft.com/dotnet/core/sdk:3.1\n only:\n - master\n script:\n - cd src\n - dotnet test --test-adapter-path:. --logger:\"junit;LogFilePath=../../MyProject.xml\"\n artifacts:\n paths:\n - ./MyProject.xml\n reports:\n junit: ./MyProject.xml\n tags:\n - docker\n\ndocker:\n stage: docker\n image: docker:stable\n services:\n - docker:dind\n variables:\n DOCKER_DRIVER: overlay2\n DOCKER_TLS_CERTDIR: \"\"\n only:\n - master\n script:\n - docker login -u \"gitlab-ci-token\" -p \"$CI_JOB_TOKEN\" $CI_REGISTRY\n - docker build --tag \"$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA\" --tag \"$CI_REGISTRY_IMAGE:latest\" --build-arg EXECUTABLE=Test.WebApi.dll .\n - docker push \"$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA\"\n - docker push \"$CI_REGISTRY_IMAGE:latest\"\n tags:\n - docker\n\nDockerfile\nFROM mcr.microsoft.com/dotnet/core/aspnet:3.1.1-alpine3.10\nARG EXECUTABLE\n\nWORKDIR /app\nCOPY /publish .\n\nENV ASPNETCORE_URLS \"http://*:5000\"\nENV ASPNETCORE_ENVIRONMENT \"Staging\"\nCMD [\"dotnet\", \"$EXECUTABLE\"]"
},
{
"role": "assistant",
"content": "Here is my solution, I have defined the variables above and replace them in the docker file with sed\nMy Solution have this two Projects\n\nTest.WebApi (WebApi Project)\nTest.WebApi.UnitTest (Unit Test Project)\n\n@ThomasBrüggemann thanks for the Inspiration.\n.gitlab-ci.yml\nvariables:\n PROJECT_NAME: \"Test.WebApi\"\n BUILD_IMAGE: \"mcr.microsoft.com/dotnet/core/sdk:3.1\"\n RUNTIME_IMAGE: \"mcr.microsoft.com/dotnet/core/aspnet:3.1.1-alpine3.10\"\n\nstages:\n - build\n - test\n - docker\n\nbuild:\n stage: build\n image: $BUILD_IMAGE\n only:\n - master\n script:\n - cd src/$PROJECT_NAME\n - dotnet restore --interactive\n - dotnet build --configuration Release\n - dotnet publish --configuration Release --output ../../publish/\n artifacts:\n paths:\n - ./publish/*\n expire_in: 1 week\n tags:\n - docker\n \ntest:\n stage: test\n image: $BUILD_IMAGE\n only:\n - master\n script:\n - cd src/$PROJECT_NAME.UnitTest\n - dotnet test --test-adapter-path:. --logger:\"junit;LogFilePath=../../UnitTestResult.xml\"\n artifacts:\n paths:\n - ./UnitTestResult.xml\n reports:\n junit: ./UnitTestResult.xml\n tags:\n - docker\n\ndocker:\n stage: docker\n image: docker:stable\n services:\n - docker:18.09.7-dind\n variables:\n DOCKER_DRIVER: overlay2\n DOCKER_TLS_CERTDIR: \"\"\n only:\n - master\n script:\n # Prepare Dockerfile\n - sed -i \"s~\\$DOCKERIMAGE~$RUNTIME_IMAGE~g\" Dockerfile\n - sed -i 's/$ENVIRONMENT/Staging/g' Dockerfile\n - sed -i \"s/\\$ENTRYPOINT/$PROJECT_NAME.dll/g\" Dockerfile\n\n # Process Dockerfile\n - docker login -u \"gitlab-ci-token\" -p \"$CI_JOB_TOKEN\" $CI_REGISTRY\n - docker build --tag \"$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA\" --tag \"$CI_REGISTRY_IMAGE:latest\" .\n - docker push \"$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA\"\n - docker push \"$CI_REGISTRY_IMAGE:latest\"\n tags:\n - docker\n\nDockerfile\nFROM $DOCKERIMAGE\n\nWORKDIR /app\nCOPY /publish .\n\nEXPOSE 5000/tcp\n\nENV ASPNETCORE_URLS \"http://*:5000\"\nENV ASPNETCORE_ENVIRONMENT \"$ENVIRONMENT\"\nCMD [\"dotnet\", \"$ENTRYPOINT\"]"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Force my local master to be origin/master\nI've let master and origin/master get stuck in the sidelines, and am no longer interested in the changes on that branch.\nI followed these instructions to get my local master pointing to the right place\nMake the current git branch a master branch\n git checkout better_branch\n git merge --strategy=ours master # keep the content of this branch, but record a merge\n git checkout master\n git merge better_branch # fast-forward master up to the merge\n\nwhich worked fine except git status gives\nC:\\data\\localprojects\\Beko2011Azure [master]> git status\n\n# On branch master\n# Your branch and 'origin/master' have diverged,\n# and have 395 and 2 different commits each, respectively.\n#\nnothing to commit, working directory clean\n\nso how do I now persuade origin/master (github) to reflect my master. Anything orphaned on origin/master can be safely abandoned."
},
{
"role": "assistant",
"content": "To have origin/master the same as master:\ngit push -f origin master:master\n\nDiscussion on the parameters: \n\n-f is the force flag. Normally, some checks are being applied before it's allowed to push to a branch. The -f flag turns off all checks.\norigin is the name of the remote where to push (you could have several remotes in one repo)\nmaster:master means: push my local branch master to the remote branch master. The general form is localbranch:remotebranch. Knowing this is especially handy when you want to delete a branch on the remote: in that case, you push an empty local branch to the remote, thus deleting it: git push origin :remote_branch_to_be_deleted\n\nA more elaborate description of the parameters could be found with man git-push\n\nOpposite direction: If you want to throw away all your changes on master and want to have it exactly the same as origin/master:\ngit checkout master\ngit reset --hard origin/master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I add a remote Git repository to an Ubuntu Server?\nI have created a Git repository on my Desktop machine (Windows 7) with:\ngit init\ngit add <all my files>\ngit commit -m \"added my files\"\n\nNow I have installed a new Ubuntu Server 10.10 on a machine on my LAN and installed OpenSSH. My home directory is /home/jonas and I created a directory ~/code/ to contain my projects. I can log in to the Ubuntu Server from Windows 7 with Putty.\nI installed Git on the server with sudo apt-get install git\nAdding a remote repository\nNow I want to add my Git repository on my Desktop to the Server. I tried to follow the instructions from Pragmatic Version Control Using Git.\nFrom my Desktop I run these commands:\ngit remote add origin [email protected]/home/jonas/code/myproject.git\ngit push origin master\n\nBut I got this error message:\nfatal: '[email protected]/home/jonas/code/myproject.git' does not appear to be\n a git repository\nfatal: The remote end hung up unexpectedly\n\nWhat is the problem? How do I create the remote repository?\n\nAs PerfectlyNormal suggested, I added a : in the address. Now it worked better, and I had to type my password to the server, but then I got a similar error message:\nfatal: '/home/jonas/code/myproject.git' does not appear to be a git repository\nfatal: The remote end hung up unexpectedly\n\nDo I have to initialize a Git repository on the server before I can git push to it?"
},
{
"role": "assistant",
"content": "git remote add origin [email protected]/home/jonas/code/myproject.git\n\nWhen using SSH, remote repository addresses can be expressed in two ways. One using absolute paths and one using relative paths from the users home directory. You've mixed them up.\nThe corrected command would be one of the following.\ngit remote add origin [email protected]:code/myproject.git\ngit remote add origin ssh://[email protected]/home/jonas/code/myproject.git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is there a difference between \"git reset --hard hash\" and \"git checkout hash\"?\nWhile reset and checkout have different usages most of the time, I can't see what difference there is between these two.\nThere probably is one or nobody would have bothered adding a --hard option to do something the basic checkout can do.\nMaybe there is a difference is the way you will see the history?"
},
{
"role": "assistant",
"content": "This answer is mostly quoted from my answer to a previous question: git reset in plain english.\nThe two are very different. They result in the same state for your index and work tree, but the resulting history and current branch aren't the same.\nSuppose your history looks like this, with the master branch currently checked out:\n- A - B - C (HEAD, master)\n\nand you run git reset --hard B. You'll get this:\n- A - B (HEAD, master) # - C is still here, but there's no\n # branch pointing to it anymore\n\nYou'd actually get that effect if you use --mixed or --soft too - the only difference is what happens to your work tree and index. In the --hard case, the work tree and index match B.\nNow, suppose you'd run git checkout B instead. You'd get this:\n- A - B (HEAD) - C (master)\n\nYou've ended up in a detached HEAD state. HEAD, work tree, index all match B, same as with the hard reset, but the master branch was left behind at C. If you make a new commit D at this point, you'll get this, which is probably not what you want:\n- A - B - C (master)\n \\\n D (HEAD)\n\nSo, you use checkout to, well, check out that commit. You can fiddle with it, do what you like, but you've left your branch behind. If you want the branch moved too, you use reset."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-shell"
},
{
"role": "assistant",
"content": "Restricted login shell for Git-only SSH access"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "pushing to git remote branch\n\nI could use a hand with learning how to push a local branch to a remote branch. Please see below. Help much appreciated!\nThe local branch was created after cloning the repo then doing\n$ git checkout -b mybranch remotes/origin/mybranch\n\n$ git branch -a\n master\n* mybranch\n remotes/origin/HEAD -> origin/master\n remotes/origin/master\n remotes/origin/mybranch\n\nBut when trying to push changes back up:\n$ git push mybranch mybranch\nfatal: 'mybranch' does not appear to be a git repository\nfatal: The remote end hung up unexpectedly\n\n$ git push remotes/origin/mybranch mybranch\nfatal: 'mybranch' does not appear to be a git repository\nfatal: The remote end hung up unexpectedly\n\n$ git push origin/mybranch mybranch\nfatal: 'mybranch' does not appear to be a git repository\nfatal: The remote end hung up unexpectedly"
},
{
"role": "assistant",
"content": "As Abizern says, this works:\ngit push origin mybranch\n\nBut, to explain further, the mybranch part is a refspec. This specifies the remote ref which should be updated with the given local commit.\nSo, the command above is equivalent to:\ngit push origin mybranch:mybranch\n\nor even:\ngit push origin mybranch:refs/heads/mybranch\n\nand, indeed, since you're on the local mybranch, you could have done:\ngit push origin HEAD:mybranch\n\nThis is good to understand, because I often find myself doing things like:\ngit push origin HEAD^:mybranch\n\nwhere you want to push all but the topmost patch to the remote branch.\nFinally, if you want to delete the remote mybranch, you do:\ngit push origin :mybranch"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git force push tag when the tag already exists on remote\nI have a tag already pushed onto the remote. When another user creates the same tag and tries to push, the push will fail because the tag already exists on the remote.\nBut I thought if I did --f force tag push, it should work. But that is not what I see.\nI think I have to do this.\n Create tag\n Push tag -> If push fails -> Delete tag on remote\n -> push tag again.\n\nIs this correct? Isn`t force pushing a tag supposed to take care of this?\nI am using annotated tags with\n git -a v1.0 -f -m \"message\""
},
{
"role": "assistant",
"content": "This will force push all the tags and overwrite the existing ones.\ngit push -f --tags"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.