messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-am"
},
{
"role": "assistant",
"content": "Apply a series of patches from a mailbox"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options trace2.perfBrief"
},
{
"role": "assistant",
"content": "Boolean. When true time , filename , and line fields are\nomitted from PERF output. May be overridden by the GIT_TRACE2_PERF_BRIEF environment variable. Defaults to false."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --color-moved[=<mode>]"
},
{
"role": "assistant",
"content": "Moved lines of code are colored differently.\nThe <mode> defaults to no if the option is not given\nand to zebra if the option with no mode is given.\nThe mode must be one of: no Moved lines are not highlighted. default Is a synonym for zebra . This may change to a more sensible mode\nin the future. plain Any line that is added in one location and was removed\nin another location will be colored with color.diff.newMoved .\nSimilarly color.diff.oldMoved will be used for removed lines\nthat are added somewhere else in the diff. This mode picks up any\nmoved line, but it is not very useful in a review to determine\nif a block of code was moved without permutation. blocks Blocks of moved text of at least 20 alphanumeric characters\nare detected greedily. The detected blocks are\npainted using either the color.diff.{old,new}Moved color.\nAdjacent blocks cannot be told apart. zebra Blocks of moved text are detected as in blocks mode. The blocks\nare painted using either the color.diff.{old,new}Moved color or color.diff.{old,new}MovedAlternative . The change between\nthe two colors indicates that a new block was detected. dimmed-zebra Similar to zebra , but additional dimming of uninteresting parts\nof moved code is performed. The bordering lines of two adjacent\nblocks are considered interesting, the rest is uninteresting. dimmed_zebra is a deprecated synonym."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_ICASE_PATHSPECS"
},
{
"role": "assistant",
"content": "Setting this Boolean environment variable to true will cause Git to treat all\npathspecs as case-insensitive."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects %aL"
},
{
"role": "assistant",
"content": "author local-part (see %al ) respecting .mailmap, see git-shortlog or git-blame )"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Install specific branch from github using Npm\n\nI would like to install bootstrap-loader from github in my project using npm\nCurrently they are maintaining two version of this project which are comaptible with webpack version 1 and 2.\nI would like to install version 1. What npm command I should use to install this? \nI tried using below one but it is not working.\nnpm install git://github.com/shakacode/bootstrap-loader.git[#v1] --Save"
},
{
"role": "assistant",
"content": "There are extra square brackets in the command you tried.\nTo install the latest version from the brach-name branch, you can use:\nnpm install \"https://github.com/shakacode/bootstrap-loader.git#branch-name\" --save"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_SSH_VARIANT"
},
{
"role": "assistant",
"content": "If this environment variable is set, it overrides Git’s autodetection\nwhether GIT_SSH / GIT_SSH_COMMAND / core.sshCommand refer to OpenSSH,\nplink or tortoiseplink. This variable overrides the config setting ssh.variant that serves the same purpose."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I git rm a file without deleting it from disk? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nRemove a file from a Git repository without deleting it from the local filesystem\n\n (15 answers)\n \n\nClosed 10 years ago.\n\n\n\nThe command removes the file in my system. I meant it to remove only the file from Git-repository.\nHow can I remove the file from a Git repository, without removing the file in my system?"
},
{
"role": "assistant",
"content": "git rm --cached file\n\nshould do what you want.\nYou can read more details at git help rm"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git: timezone and timestamp format\nFrom git I can get the timestamp:\n\"2011-10-04 12:58:36 -0600\"\n\nbut is there any way to show it as:\n\"2011-10-04 06:58:36\"\n\nSo all I want is to get rid of the -0600 timezone offset. How can I do this? Thanks."
},
{
"role": "assistant",
"content": "If you ask about git log, you can try and select most correct form from:\ngit log --date={relative,local,default,iso,rfc}\n\n--date=local seems to be the best candidate.\nTo make this permanent, use git config --global log.date local."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options attr.tree"
},
{
"role": "assistant",
"content": "A reference to a tree in the repository from which to read attributes,\ninstead of the .gitattributes file in the working tree. In a bare\nrepository, this defaults to HEAD:.gitattributes . If the value does\nnot resolve to a valid tree object, an empty tree is used instead.\nWhen the GIT_ATTR_SOURCE environment variable or --attr-source command line option are used, this configuration variable has no effect."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.<driver>.command"
},
{
"role": "assistant",
"content": "The custom diff driver command. See gitattributes for details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I write a batch file which opens the GitBash shell and runs a command in the shell?\nI'm on Windows 7 trying to use a batch file to open the GitBash shell and make a git call.\nThis is the contents of my batch file:\nREM Open GitBash \nC:\\Windows\\SysWOW64\\cmd.exe /c \"\"C:\\Program Files (x86)\\Git\\bin\\sh.exe\" --login -i\"\nREM retrieve archive\ngit archive master | tar -x -C %~1\nREM quit GitBash\nexit\n\nI noticed that the GitBash is logging out before the next command \"git archive...\". Does anybody know if I can pass the command into GitBash and how?\nMike"
},
{
"role": "assistant",
"content": "\"C:\\Program Files (x86)\\Git\\bin\\sh.exe\" --login -i -c \"git archive master | tar -x -C $0\" \"%~1\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout-index - Copy files from the index to the working tree To update and refresh only the files already checked out"
},
{
"role": "assistant",
"content": "$ git checkout-index -n -f -a && git update-index --ignore-missing --refresh"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Search code inside a Github project\n\nIs there a way to grep for something inside a Github project's code?\nI could pull the source and grep it locally, but I was wondering if it's possible through the web interface or a 3rd-party alternative.\nIdeas?"
},
{
"role": "assistant",
"content": "Update May 2023:\n\nThe new code search and code view is now generally available (May. 2023)\n\n(As noted by holydragon in the comments, that does require to sign in to GitHub first)\n\nAt GitHub Universe last year, we announced a total redesign of GitHub's code search and navigation experience, powered by our all-new code search engine that we built from scratch.\nAnd in February, we announced our public beta.\nToday, we are rolling out this feature to all GitHub users.\n\nCheck out our blog post to learn more about how GitHub's new code search and code view can help you search, navigate, and understand your code.\nAnd if you have feedback, please share it with us in our feedback discussion.\n\n\nUpdate Dec. 2021: search has been improved again, with Search for an exact string, with support for substring matches and special characters, or regexps.\n\nBut only on cs.github.com, and still in beta (waitlist applies)\n\nUpdate January 2013: a brand new search has arrived!, based on elasticsearch.org:\nA search for stat within the ruby repo will be expressed as stat repo:ruby/ruby, and will now just workTM.\n(the repo name is not case sensitive: test repo:wordpress/wordpress returns the same as test repo:Wordpress/Wordpress)\n\nWill give:\n\nAnd you have many other examples of search, based on followers, or on forks, or...\n\nUpdate July 2012 (old days of Lucene search and poor code indexing, combined with broken GUI, kept here for archive):\nThe search (based on SolrQuerySyntax) is now more permissive and the dreaded \"Invalid search query. Try quoting it.\" is gone when using the default search selector \"Everything\":)\n(I suppose we can all than Tim Pease, which had in one of his objectives \"hacking on improved search experiences for all GitHub properties\", and I did mention this Stack Overflow question at the time ;) )\nHere is an illustration of a grep within the ruby code: it will looks for repos and users, but also for what I wanted to search in the first place: the code!\n\n\nInitial answer and illustration of the former issue (Sept. 2012 => March 2012)\nYou can use the advanced search GitHub form:\n\nChoose Code, Repositories or Users from the drop-down and\nuse the corresponding prefixes listed for that search type.\n\nFor instance, Use the repo:username/repo-name directive to limit the search to a code repository.\nThe initial \"Advanced Search\" page includes the section:\n\nCode Search:\nThe Code search will look through all of the code publicly hosted on GitHub. You can also filter by :\n\nthe language language:\nthe repository name (including the username) repo:\nthe file path path:\n\n\nSo if you select the \"Code\" search selector, then your query grepping for a text within a repo will work:\n\n\nWhat is incredibly unhelpful from GitHub is that:\n\nif you forget to put the right search selector (here \"Code\"), you will get an error message:\n\"Invalid search query. Try quoting it.\"\n\n\n\nthe error message doesn't help you at all.\nNo amount of \"quoting it\" will get you out of this error.\n\nonce you get that error message, you don't get the sections reminding you of the right association between the search selectors (\"Repositories\", \"Users\" or \"Language\") and the (right) search filters (here \"repo:\").\nAny further attempt you do won't display those associations (selectors-filters) back. Only the error message you see above...\nThe only way to get back those arrays is by clicking the \"Advance Search\" icon:\n\n\n\n\nthe \"Everything\" search selector, which is the default, is actually the wrong one for all of the search filters! Except \"language:\"...\n(You could imagine/assume that \"Everything\" would help you to pick whatever search selector actually works with the search filter \"repo:\", but nope. That would be too easy)\n\nyou cannot specify the search selector you want through the \"Advance Search\" field alone!\n(but you can for \"language:\", even though \"Search Language\" is another combo box just below the \"Search for\" 'type' one...)\n\n\n\n\nSo, the user's experience usually is as follows:\n\nyou click \"Advanced Search\", glance over those sections of filters, and notice one you want to use: \"repo:\"\nyou make a first advanced search \"repo:jruby/jruby stat\", but with the default Search selector \"Everything\"\n=> FAIL! (and the arrays displaying the association \"Selectors-Filters\" is gone)\nyou notice that \"Search for\" selector thingy, select the first choice \"Repositories\" (\"Dah! I want to search within repositories...\")\n=> FAIL!\ndejected, you select the next choice of selectors (here, \"Users\"), without even looking at said selector, just to give it one more try...\n=> FAIL!\n\"Screw this, GitHub search is broken! I'm outta here!\"\n...\n(GitHub advanced search is actually not broken. Only their GUI is...)\n\n\nSo, to recap, if you want to \"grep for something inside a Github project's code\", as the OP Ben Humphreys, don't forget to select the \"Code\" search selector..."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to merge a specific commit in Git\nI have forked a branch from a repository in GitHub and committed something specific to me. Now I found the original repository had a good feature which was at HEAD.\nI want to merge it only without previous commits. What should I do? I know how to merge all commits:\ngit branch -b a-good-feature\ngit pull repository master\ngit checkout master\ngit merge a-good-feature\ngit commit -a\ngit push"
},
{
"role": "assistant",
"content": "git cherry-pick should be your answer here.\n\nApply the change introduced by an existing commit.\n\nDo not forget to read bdonlan's answer about the consequence of cherry-picking in this post:\n\"Pull all commits from a branch, push specified commits to another\", where:\nA-----B------C\n \\\n \\\n D\n\nbecomes:\nA-----B------C\n \\\n \\\n D-----C'\n\n\nThe problem with this commit is that git considers commits to include all history before them\n\n\nWhere C' has a different SHA-1 ID.\nLikewise, cherry picking a commit from one branch to another basically involves generating a patch, then applying it, thus losing history that way as well.\n\n\nThis changing of commit IDs breaks git's merging functionality among other things (though if used sparingly there are heuristics that will paper over this).\nMore importantly though, it ignores functional dependencies - if C actually used a function defined in B, you'll never know."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I collect the logs for all jobs in a gitlab pipeline?\n\nI have some gitlab CI pipelines that consist of dozens of jobs -- sometimes I need to find something that might appear in a job without knowing which one. I can manually select each job in the web interface and review the associated log, but doing that for each job is infeasible.\nIs there some way (ideally as an unprivileged gitlab user) to retrieve/aggregate the output from all the jobs of a given pipeline?\nIn case it matters, I'm using version 12.5.X-ee."
},
{
"role": "assistant",
"content": "You could use the GitLab Jobs API to aggregate all the job traces, and write a script with something along the lines of:\n\nAdd a final stage to your pipeline (aggregate job logs)\nList the current Pipeline ID jobs\nLoop over the JOB_IDs (apart from the aggregate job logs job), and get their job logs\nDump to a file and you can review all the logs in one file\n\nNote, that you will need to create a personal-access-token, and then use it in the CI job to access the API. There's not a great way with storing your access token apart from as a custom environment variable, and then accessing that variable in the .gitlab-ci.yml.\nHTH"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is Gitlab's instance domain?\nI am trying to test to see if my SSH key was added correctly by following the instructions which are found halfway down the page here. \n\nTo test whether your SSH key was added correctly, run the following\n command in your terminal (replacing gitlab.com with your GitLab's\n instance domain):\n\nssh -T [email protected]\n\nHowever, I have no idea what my \"Gitlab's instance domain\" is referring to. I have searched other online but I cannot find anything relevant."
},
{
"role": "assistant",
"content": "If you're using Gitlab on gitlab.com then the domain is gitlab.com, so you should run ssh -T [email protected]"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --diff-merges=<format>"
},
{
"role": "assistant",
"content": "Specify diff format to be used for merge commits. Default is\n`off` unless --first-parent is in use, in\nwhich case first-parent is the default. The following formats are supported: off, none Disable output of diffs for merge commits. Useful to override\nimplied value. on, m Make diff output for merge commits to be shown in the default\nformat. The default format can be changed using log.diffMerges configuration variable, whose default value\nis separate . first-parent, 1 Show full diff with respect to first parent. This is the same\nformat as --patch produces for non-merge commits. separate Show full diff with respect to each of parents.\nSeparate log entry and diff is generated for each parent. combined, c Show differences from each of the parents to the merge\nresult simultaneously instead of showing pairwise diff between\na parent and the result one at a time. Furthermore, it lists\nonly files which were modified from all parents. dense-combined, cc Further compress output produced by --diff-merges=combined by omitting uninteresting hunks whose contents in the parents\nhave only two variants and the merge result picks one of them\nwithout modification. remerge, r Remerge two-parent merge commits to create a temporary tree\nobject—potentially containing files with conflict markers\nand such. A diff is then shown between that temporary tree\nand the actual merge commit. The output emitted when this option is used is subject to change, and\nso is its interaction with other options (unless explicitly\ndocumented)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Best practices for cross platform git config?\nContext\nA number of my application user configuration files are kept in a git repository for easy sharing across multiple machines and multiple platforms. Amongst these configuration files is .gitconfig which contains the following settings for handling the carriage return linefeed characters\n[core]\n autocrlf = true\n safecrlf = false\n\nProblem\nThese settings also gets applied on a GNU/Linux platform which causes obscure errors. \nQuestion\nWhat are some best practices for handling these platform specific differences in configuration files? \nProposed solution\nI realize this problem could be solved by having a branch for each platform and keeping the common stuff in master and merging with the platform branch when master moves forward. I'm wondering if there are any easier solutions to this problem?"
},
{
"role": "assistant",
"content": "Never turn autocrlf on, it causes nothing but headaches and sorrows.\nThere's no excuse to use \\r\\n on windows, all decent editors (by definition) can handle \\n."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can I have my GitHub Pages index.html in a subfolder of the repository?\n\nI'm trying to use GitHub pages to host a Doxygen site. Ideally, I'd like to be able to push the generated files and directories to GitHub without having to tweak them at all.\nThis, however, means that my index.html is in a subfolder of the repository and GitHub Pages isn't picking it up (I get a 404 when I try to access the Pages site). Is there a way to make GitHub recognise that index.html when it's in a subfolder?\nIt is a project site."
},
{
"role": "assistant",
"content": "Create a dummy index.html at the root and put this in your header:\n<meta http-equiv=\"refresh\" content=\"0; url=https://repo.github.io/folder/index.html\">\n\nBe sure to change the destination URL. This will instantly redirect from index.html to your folder/index.html."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index"
},
{
"role": "assistant",
"content": "Generating patch text with -p Running git-diff , git-log , git-show , git-diff-index , git-diff-tree , or git-diff-files with the -p option produces patch text.\nYou can customize the creation of patch text via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables\n(see git ), and the diff attribute (see gitattributes ). What the -p option produces is slightly different from the traditional\ndiff format: It is preceded by a \"git diff\" header that looks like this: diff --git a/file1 b/file2 The a/ and b/ filenames are the same unless rename/copy is\ninvolved. Especially, even for a creation or a deletion, /dev/null is not used in place of the a/ or b/ filenames. When a rename/copy is involved, file1 and file2 show the\nname of the source file of the rename/copy and the name of\nthe file that the rename/copy produces, respectively. It is followed by one or more extended header lines: old mode <mode>\nnew mode <mode>\ndeleted file mode <mode>\nnew file mode <mode>\ncopy from <path>\ncopy to <path>\nrename from <path>\nrename to <path>\nsimilarity index <number>\ndissimilarity index <number>\nindex <hash>..<hash> <mode> File modes are printed as 6-digit octal numbers including the file type\nand file permission bits. Path names in extended headers do not include the a/ and b/ prefixes. The similarity index is the percentage of unchanged lines, and\nthe dissimilarity index is the percentage of changed lines. It\nis a rounded down integer, followed by a percent sign. The\nsimilarity index value of 100% is thus reserved for two equal\nfiles, while 100% dissimilarity means that no line from the old\nfile made it into the new one. The index line includes the blob object names before and after the change.\nThe <mode> is included if the file mode does not change; otherwise,\nseparate lines indicate the old and the new mode. Pathnames with \"unusual\" characters are quoted as explained for\nthe configuration variable core.quotePath (see git-config ). All the file1 files in the output refer to files before the\ncommit, and all the file2 files refer to files after the commit.\nIt is incorrect to apply each change to each file sequentially. For\nexample, this patch will swap a and b: diff --git a/a b/b\nrename from a\nrename to b\ndiff --git a/b b/a\nrename from b\nrename to a Hunk headers mention the name of the function to which the hunk\napplies. See \"Defining a custom hunk-header\" in gitattributes for details of how to tailor this to\nspecific languages."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why might git log not show history for a moved file, and what can I do about it?\nI've renamed a couple of files using git mv, used git stash, had a quick look at HEAD (without changing it) then did git stash pop to get the whole lot back again. My moves had disappeared from the commit list, so I redid them with git rm and the commit message claimed git had spotted the rename was a rename. So I thought no more of it.\nBut now, post-commit, I can't get at the history of the moved files! Here's what git says about the commit in question:\n~/projects% git log --summary\ncommit de6e9fa2179ae17ec35a5c368d246f19da27f93a\nAuthor: brone\nDate: Wed Dec 8 22:37:54 2010 +0000\n\n Moved R_DebugUI into runtime\n\n delete mode 100644 test/R_DebugUI_iOS.h\n delete mode 100644 test/R_DebugUI_iOS.m\n create mode 100644 system/runtime/src/R_DebugUI_iOS.h\n create mode 100644 system/runtime/src/R_DebugUI_iOS.m\n\n <<snip older commits>>\n ~/projects%\n\nI'm now trying to get the history of one of these moved files, so I can look at an old version, but I don't get anything very useful:\n~/projects/system/runtime/src% git log --follow --find-copies-harder -M -C R_DebugUI_iOS.m\ncommit de6e9fa2179ae17ec35a5c368d246f19da27f93a\nAuthor: brone\nDate: Wed Dec 8 22:37:54 2010 +0000\n\n Moved R_DebugUI into runtime\n~/projects/system/runtime/src% \n\n(I've also tried it without -M, -C and --find-copies-harder, but to no avail.)\nI can get its history under its old name, which stops at the point it was deleted from its old location:\n~/projects% git log --summary --follow --find-copies-harder -M -C -- test/R_DebugUI_iOS.m\ncommit de6e9fa2179ae17ec35a5c368d246f19da27f93a\nAuthor: brone\nDate: Wed Dec 8 22:37:54 2010 +0000\n\n Moved R_DebugUI into runtime\n\n delete mode 100644 test/R_DebugUI_iOS.m\n\ncommit 32a22d53c27e260714f759ecb3d3864e38b2e87f\nAuthor: brone\nDate: Tue Dec 7 23:52:51 2010 +0000\n\n Can set debug UI's alpha.\n\n<<snip older commits>>\n~/projects%\n\nSo I'm not completely stuck this time, but I wouldn't fancy having to do this kind of thing all the time. (I anticipate having a fair number of files that will move at least once in their life.)\nAm I doing something wrong? The old copy of the file and the new copy are 98.8% the same (2 lines out of 166 changed). My understanding is that git should be able to track the file in this case, because it infers rename operations rather than storing them explicitly, and the files are similar enough that I believe it should consider them the same.\nIs there anything I can do to fix this?"
},
{
"role": "assistant",
"content": "Try git log --follow on your file.\nIs it possible to move/rename files in Git and maintain their history?"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Bitbucket activity graph\nI would like to know if there is a solution in Bitbucket similar to Github's graphs. For example, here are the ones for Node.js:\nContributions graph\n\nCommits graph\n\nI've done some research and I haven't found anything similar. Does anybody know if this kind of visualisation exists in a hidden place in Bitbucket? Or is there some 3rd party service which provides these kinds of graphs of a git repository?"
},
{
"role": "assistant",
"content": "Take a look at Awesome Graphs for Bitbucket add-on\nFrom http://blog.bitbucket.org/2015/06/10/atlassian-connect-for-bitbucket-a-new-way-to-extend-your-workflow-in-the-cloud\n\nIf you are currently a user of Bitbucket and want to take a sneak peak, click on your avatar, select “Manage Account”, and simply install these new add-ons by selecting “Find new add-ons” from the left menu.\n\nHere is the add-on's release notes page: https://docs.stiltsoft.com/awesome-graphs/cloud/release-notes-cloud"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitignore - Specifies intentionally untracked files to ignore"
},
{
"role": "assistant",
"content": "PATTERN FORMAT A blank line matches no files, so it can serve as a separator\nfor readability. A line starting with # serves as a comment.\nPut a backslash (\" \\ \") in front of the first hash for patterns\nthat begin with a hash. Trailing spaces are ignored unless they are quoted with backslash\n(\" \\ \"). An optional prefix \" ! \" which negates the pattern; any\nmatching file excluded by a previous pattern will become\nincluded again. It is not possible to re-include a file if a parent\ndirectory of that file is excluded. Git doesn’t list excluded\ndirectories for performance reasons, so any patterns on contained\nfiles have no effect, no matter where they are defined.\nPut a backslash (\" \\ \") in front of the first \" ! \" for patterns\nthat begin with a literal \" ! \", for example, \" \\!important!.txt \". The slash \" / \" is used as the directory separator. Separators may\noccur at the beginning, middle or end of the .gitignore search pattern. If there is a separator at the beginning or middle (or both) of the\npattern, then the pattern is relative to the directory level of the\nparticular .gitignore file itself. Otherwise the pattern may also\nmatch at any level below the .gitignore level. If there is a separator at the end of the pattern then the pattern\nwill only match directories, otherwise the pattern can match both\nfiles and directories. For example, a pattern doc/frotz/ matches doc/frotz directory,\nbut not a/doc/frotz directory; however frotz/ matches frotz and a/frotz that is a directory (all paths are relative from\nthe .gitignore file). An asterisk \" * \" matches anything except a slash.\nThe character \" ? \" matches any one character except \" / \".\nThe range notation, e.g. [a-zA-Z] , can be used to match\none of the characters in a range. See fnmatch(3) and the\nFNM_PATHNAME flag for a more detailed description. Two consecutive asterisks (\" ** \") in patterns matched against\nfull pathname may have special meaning: A leading \" ** \" followed by a slash means match in all\ndirectories. For example, \" **/foo \" matches file or directory\n\" foo \" anywhere, the same as pattern \" foo \". \" **/foo/bar \"\nmatches file or directory \" bar \" anywhere that is directly\nunder directory \" foo \". A trailing \" /** \" matches everything inside. For example,\n\" abc/** \" matches all files inside directory \" abc \", relative\nto the location of the .gitignore file, with infinite depth. A slash followed by two consecutive asterisks then a slash\nmatches zero or more directories. For example, \" a/**/b \"\nmatches \" a/b \", \" a/x/b \", \" a/x/y/b \" and so on. Other consecutive asterisks are considered regular asterisks and\nwill match according to the previous rules."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to tell git to ignore individual lines, i.e. gitignore for specific lines of code [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nCan git ignore a specific line?\n\n (9 answers)\n \n\nClosed 9 years ago.\n\n\n\n.gitignore can ignore whole files, but is there a way to ignore specific lines of code while coding?\nI frequently and repeatedly add the same debug lines in a project, only to have to remember to remove them before committing. I'd like to just keep the lines in the code and have git disregard them."
},
{
"role": "assistant",
"content": "This is how you can kind of do it with git filters:\n\nCreate/Open gitattributes file:\n\n\n<project root>/.gitattributes (will be committed into repo)\nOR\n<project root>/.git/info/attributes (won't be committed into repo)\n\nAdd a line defining the files to be filtered:\n\n\n*.rb filter=gitignore, i.e. run filter named gitignore on all *.rb files\n\nDefine the gitignore filter in your gitconfig:\n\n\n$ git config --global filter.gitignore.clean \"sed '/#gitignore$/d'\", i.e. delete these lines\n$ git config --global filter.gitignore.smudge cat, i.e. do nothing when pulling file from repo\n\n\nNotes:\nOf course, this is for ruby files, applied when a line ends with #gitignore, applied globally in ~/.gitconfig. Modify this however you need for your purposes.\nWarning!!\nThis leaves your working file different from the repo (of course). Any checking out or rebasing will mean these lines will be lost! This trick may seem useless since these lines are repeatedly lost on check out, rebase, or pull, but I've a specific use case in order to make use of it.\nJust git stash save \"proj1-debug\" while the filter is inactive (just temporarily disable it in gitconfig or something). This way, my debug code can always be git stash apply'd to my code at any time without fear of these lines ever being accidentally committed.\nI have a possible idea for dealing with these problems, but I'll try implementing it some other time.\nThanks to Rudi and jw013 for mentioning git filters and gitattributes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Exclude a directory from GitLab's merge request diff\n\nis it possible to exclude a directory from displaying a diff of merge request in GitLab?\nWe started to version the bower_components folder (1 - to speed up app build, 2 - because bower has no .lock mechanism), but it makes trouble when doing code review - many changed files appear inside bower_components which makes the diff harder to read.\nThanks in advance"
},
{
"role": "assistant",
"content": "Since gitlab 8.8, gitlab support the .gitattributes.\nSo if your project does not have .gitattributes add it,\nand to exclude files for diff, append:\n*.<whatever> -diff\n\nand to exclude directories from a diff:\n<mydir> -diff"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index -U<n> --unified=<n>"
},
{
"role": "assistant",
"content": "Generate diffs with <n> lines of context instead of\nthe usual three.\nImplies --patch ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-range-diff"
},
{
"role": "assistant",
"content": "Compare two commit ranges (e.g. two versions of a branch)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I tell if a file will be uploaded to git lfs correctly?\nI'm trying to add everything under MyProject/Frameworks/ to git-lfs (large file storage). I'm not sure what the proper format for matching all files and folders recursively under the Frameworks folder is. This answer says the proper format is git lfs track \"MyProject/Frameworks/**\", but Atlassian's help document says I should use git lfs track \"MyProject/Frameworks/\". I tried both and they didn't use git lfs for storage. It tried uploading files directly.\nSure, I'd love to know the proper format, but more importantly, before I attempt to push my changes to github, I'd like to verify that the match and files do indeed work correctly. This'll allow me to iterate and try new things.\nI see two related commands that might help: git lfs status and git lfs ls-files. It's not clear which one I should be using and what output I should be looking for. For example, when I ran git lfs status, it showed me a ton of files under Git LFS objects to be committed, making me think they would be added to Git LFS. However, after attempting to push to GitHub.com, I realized that it was clearly not the case. If it helps, the output for these files always had something like (Git: edee1ad) after each file name.\nWhen I attempt to use git lfs ls-files I'm not sure if I need to run it after git adding the files, after committing them, or after pushing them. Most of the time it's just showing me blank output.\nEssentially the question is: If I configured git lfs correctly, what tool (e.g. git lfs status) should I use, and what output should I look for before I attempt to commit/push?\nNote: Please don't answer the question with only how to match all recursive files as that will help me once (this specific case), rather than allowing me to iterate and try new things (any case)."
},
{
"role": "assistant",
"content": "TL;DR\nIf everything is set up correctly, you can verify that git LFS is going to work properly by:\n\ngit add the file(s) in question.\nDo one of the following:\n\n\nRun git lfs status and ensure the file(s) in question appear under Git LFS objects to be committed, and that they have the LFS value in parenthesis; or\nRun git lfs ls-files and ensure the file(s) in question appear in this output.\n\n\n\n⚠️ Important: After running git lfs track, you must run git add to refresh the state of files before calling git lfs status or git lfs ls-files. Otherwise you'll see irrelevant output from those commands.\n\nAlso, for the record, looks like git lfs track \"MyProject/Frameworks/**\" is the correct one for recursive matching.\n\nSet up and testing methodology:\n\ngit lfs track \"*.lfs\". This generates .gitattributes. Leave it unstaged.\nCreate a file in the root directory, Test.lfs. Leave it unstaged.\nTest:\n\ngit lfs status: no filenames output\n$ git lfs status\nOn branch master\nGit LFS objects to be pushed to origin/master:\n\n\nGit LFS objects to be committed:\n\n\nGit LFS objects not staged for commit:\n\n\n$\n\ngit lfs ls-files: no output\n$ git lfs ls-files\n$\n\n\nAdd git add Test.lfs.\nTest:\n\ngit lfs status: Test.lfs will now be listed with an LFS suffix.\n$ git lfs status\nOn branch master\nGit LFS objects to be pushed to origin/master:\n\n\nGit LFS objects to be committed:\n\n Test.lfs (LFS: 2ab9f1e)\n\nGit LFS objects not staged for commit:\n\n\n$\n\ngit lfs ls-files: Test.lfs will now be listed. \n$ git lfs ls-files\n2ab9f1e447 * Test.lfs\n$\n\n\nCommit changes.\nTest:\n\ngit lfs status: Test.lfs will move to the \"to be pushed\" section. It will have a suffix such with a bunch of numbers/letters.\n$ git lfs status\nOn branch master\nGit LFS objects to be pushed to origin/master:\n\n Test.lfs (2ab9f1e44720efb7a26553e06b667a270320efb3e906553b3f9e0702538a2b3f)\n\nGit LFS objects to be committed:\n\n\nGit LFS objects not staged for commit:\n\n\n$\n\ngit lfs ls-files: Test.lfs will continue to be listed. \n$ git lfs ls-files\n2ab9f1e447 * Test.lfs\n$\n\n\nPush changes. Including adding/committing/pushing .gitattributes.\nTest:\n\ngit lfs status: no filenames output anymore\n$ git lfs status\nOn branch master\nGit LFS objects to be pushed to origin/master:\n\n\nGit LFS objects to be committed:\n\n\nGit LFS objects not staged for commit:\n\n\n$\n\ngit lfs ls-files: Continues to output the tracked file\n$ git lfs ls-files\n2ab9f1e447 * Test.lfs\n$\n\n\n\nConclusions:\n\nThe Git LFS objects not staged for commit section seems misleading as it never displayed any files, even those that should have been tracked by LFS.\nIf you attempt to do the previous experiment with a non git-lfs tracked file, you'll also notice that it appears under the Git LFS objects to be committed incorrectly. It is not a Git LFS object. The way you can tell that it's not actually a Git LFS object though is to look at how it ends. If it ends with (Git: 111111111) it won't be committed to LFS.\nTo avoid the above confusions, you may want to favor git lfs ls-files over git lfs status to determine if something is going to be part of git-lfs or not.\nAnother gotcha: Some applications such as Xcode will git add files in a weird way causing what should have been clear matches to not be considered for Git LFS. The solution is to unstage the files and then re-stage them."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "env: bash\\r: No such file or directory [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nAre shell scripts sensitive to encoding and line endings?\n\n (17 answers)\n \n\nClosed 2 years ago.\n\n\n\nI'm trying to install YouCompleteMe from here.\nWhen I execute:\n./install.sh --clang-completer\n\nI get this error:\nenv: bash\\r: No such file or directory\n\nI don't know what's wrong with environment variables. Here's my bash path:\nwhich bash \n/bin/bash\n\nDo I need to change it to /usr/bash? If yes, then how should I do that? I tried changing ~/.bashrc file, but it didn't work."
},
{
"role": "assistant",
"content": "The error message suggests that the script you're invoking has embedded \\r characters, which in turn suggests that it has Windows-style \\r\\n line endings (newlines) instead of the \\n-only line endings bash expects.\nAs a quick fix, you can remove the \\r chars. as follows:\nsed $'s/\\r$//' ./install.sh > ./install.Unix.sh\n\nNote: The $'...' string is an ANSI-C quoted string supported in bash, ksh, and zsh. It is used to ensure that the \\r expands to an actual CR character before sed sees the script, because not all sed implementations themselves support \\r as an escape sequence.\nand then run\n./install.Unix.sh --clang-completer\n\nHowever, the larger question is why you've ended up with \\r\\n-style files - most likely, other files are affected, too.\nPerhaps you're running Git on Windows, where a typical configuration is to convert Unix-style \\n-only line breaks to Windows-style \\r\\n line breaks on checking files out and re-converting to \\n-only line breaks on committing.\nWhile this somewhat makes sense for development[1] on Windows, it gets in the way of installation scenarios like these.\nTo make Git check out files with Unix-style file endings on Windows - at least temporarily - use:\ngit config --global core.autocrlf false\n\nThen run your installation commands involving git clone again.\nTo restore Git's behavior later, run git config --global core.autocrlf true.\n\n[1] These days, most editors and CLIs on Windows can handle \\r\\n and \\n newlines interchangeably."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What does git push origin HEAD mean?\nI found, in the official guide:\n\ngit push origin HEAD\nA handy way to push the current branch to the\nsame name on the remote.\n\nHowever, the meaning of the command is not clear to me. Why does it have this effect?\nI haven't been able to find an answer (this question seems to treat the problem, but the title is misleading)."
},
{
"role": "assistant",
"content": "HEAD points to the top of the current branch. git can obtain the branch name from that. So it's the same as:\ngit push origin CURRENT_BRANCH_NAME\n\nbut you don't have to remember/type the current branch name. Also it prevents you from pushing to the wrong remote branch by accident.\nIf you want to push a different branch than the current one the command will not work."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Apply git .gitignore rules to an existing repository [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nIgnore files that have already been committed to a Git repository [duplicate]\n\n (21 answers)\n \n\nClosed 10 years ago.\n\n\n\nI started using git with an xcode project and have recently discovered that I can use .gitignore and .gitattributes files to ignore the noise from the compiler and system. Now that I have the .gitignore and .gitattributes files in place, how can I \"apply\" the new ignore rules and get rid of the crud from version control?\nMy .gitignore file is:\n# xcode noise\n*.modelv3\n*.pbxuser\n*.perspective\n*.perspectivev3\n*.pyc\n*~.nib/\nbuild/*\n\n# Textmate - if you build your xcode projects with it\n*.tm_build_errors\n\n# old skool\n.svn\n\n# osx noise\n.DS_Store\nprofile\n\nAnd my .gitattributes file is:\n*.pbxproj -crlf -diff -merge\n\nThanks!"
},
{
"role": "assistant",
"content": "Here is one way to “untrack” any files that are would otherwise be ignored under the current set of exclude patterns:\n(GIT_INDEX_FILE=some-non-existent-file \\\n git ls-files --exclude-standard --others --directory --ignored -z) |\nxargs -0 git rm --cached -r --ignore-unmatch --\n\nThis leaves the files in your working directory but removes them from the index.\nThe trick used here is to provide a non-existent index file to git ls-files so that it thinks there are no tracked files. The shell code above asks for all the files that would be ignored if the index were empty and then removes them from the actual index with git rm.\nAfter the files have been “untracked”, use git status to verify that nothing important was removed (if so adjust your exclude patterns and use git reset -- path to restore the removed index entry). Then make a new commit that leaves out the “crud”.\nThe “crud” will still be in any old commits. You can use git filter-branch to produce clean versions of the old commits if you really need a clean history (n.b. using git filter-branch will “rewrite history”, so it should not be undertaken lightly if you have any collaborators that have pulled any of your historical commits after the “crud” was first introduced)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %P"
},
{
"role": "assistant",
"content": "parent hashes"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary refspec"
},
{
"role": "assistant",
"content": "A \"refspec\" is used by fetch and push to describe the mapping between remote ref and local ref."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Stop git merge from opening text editor\nEvery time I run a git merge command it opens the text editor asking me to add an extra message.\nHow can I stop git from opening the editor & simply merging my branches? Because when it opens the editor it doesn't complete the merge, even if I add an extra message & save the file, the terminal just hangs on my git merge command.\nMerge branch 'my-feature-branch' into main-development\n\n# Please enter a commit message to explain why this merge is necessary,\n# especially if it merges an updated upstream into a topic branch.\n# \n# Lines starting with '#' will be ignored, and an empty message aborts\n# the commit."
},
{
"role": "assistant",
"content": "Use the --no-edit option, you can read about it in the documentation.\nNote that using the default message is discuraged, since it provides no meaningful information about the changes introduced with this merge.\n\nOn a sidenote: To continue merging you probably have to close the editor.\n\nIf you have a git version prior to 1.7.8 there is still a way to achieve what you want by using the env command.\nenv GIT_EDITOR=: git merge <ref-you-want-to-merge>\n\nFor easier usage you could create an alias.\ngit config --global alias.merge-no-edit '!env GIT_EDITOR=: git merge'\n\nWhich then can be used using git merge-no-edit <ref-you-want-to-merge>."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I make Jenkins CI with Git trigger on pushes to master?\nI'm trying to set up Jenkins-ci for a project using GitHub. I've already set up Jenkins with the appropriate plugins. I want Jenkins to run build scripts only whenever someone on the project pushes to master. So far I've been able to set it up so that a build will be triggered anytime anyone pushes to anywhere, but that is too broad. I've done this with post-receive service hooks on Git.\nI've read the Jenkins wiki, and a couple of tutorials, but this particular detail is missing... is it something to do with polling maybe? Or should work be done on the Git side, so that Git only triggers Jenkins when master is changed?"
},
{
"role": "assistant",
"content": "As already noted by gezzed in his comment, meanwhile there is a good solution (described in Polling must die: triggering Jenkins builds from a Git hook):\n\nSet the Jenkins job's build trigger to Poll SCM, but do not specify a schedule.\nCreate a GitHub post-receive trigger to notify the URL\nhttp://yourserver/jenkins/git/notifyCommit?url=<URL of the Git repository>?token=<get token from git to build remotely>\n\nThis will trigger all builds that poll the specified Git repository.\nHowever, polling actually checks whether anything has been pushed to the used branch.\n\nIt works perfectly."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Message \"Support for password authentication was removed.\"\n\nI got this error on my console when I tried to use git pull:\n\nremote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for ...\n\nIt's very weird, because I just followed the documentation and created a token two weeks ago on GitHub. The token expires on Tue, Oct 26, 2021. Why has this been removed today?"
},
{
"role": "assistant",
"content": "From 2021-08-13, GitHub is no longer accepting account passwords when authenticating Git operations. You need to add a PAT (Personal Access Token) instead, and you can follow the below method to add a PAT on your system.\n\nCreate Personal Access Token on GitHub\nFrom your GitHub account, go to Settings → Developer Settings → Personal Access Token → Tokens (classic) → Generate New Token (Give your password) → Fillup the form → click Generate token → Copy the generated Token, it will be something like ghp_sFhFsSHhTzMDreGRLjmks4Tzuzgthdvfsrta\n\nNow follow the below method based on your machine:\n\nFor Windows OS ⤴\nGo to Credential Manager from Control Panel → Windows Credentials → find git:https://github.com → Edit → On Password replace with with your GitHub Personal Access Token → You are Done\n\nIf you don’t find git:https://github.com → Click on Add a generic credential → Internet address will be git:https://github.com and you need to type in your username and password will be your GitHub Personal Access Token → Click Ok and you are done\n\n\n\nFor macOS ⤴\nClick on the Spotlight icon (magnifying glass) on the right side of the menu bar. Type Keychain access then press the Enter key to launch the app → In Keychain Access, search for github.com → Find the internet password entry for github.com → Edit or delete the entry accordingly → You are done\n\n\n\nFor a Linux-based OS ⤴\nFor Linux, you need to configure the local GIT client with a username\nand email address,\n$ git config --global user.name \"your_github_username\"\n$ git config --global user.email \"your_github_email\"\n$ git config -l\n\nOnce GIT is configured, we can begin using it to access GitHub.\nExample:\n$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY\n> Cloning into `YOUR-REPOSITORY`...\nUsername: <type your username>\nPassword: <type your password or personal access token (GitHub)\n\nNow cache the given record in your computer to remembers the token:\n$ git config --global credential.helper cache\n\nIf needed, anytime you can delete the cache record by:\n$ git config --global --unset credential.helper\n$ git config --system --unset credential.helper\n\nNow try to pull with -v to verify\n$ git pull -v\n\n\n\nLinux/Debian\n(Clone as follows):\ngit clone https://<tokenhere>@github.com/<user>/<repo>.git\n\n\n\n\nFor PhpStorm\nIf you are using PhpStorm, go to menu Git → pull and select authentication via Personal Access Token. Enter your PAT it will allow you to pull/push the changes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-reflog - Manage reflog information --single-worktree"
},
{
"role": "assistant",
"content": "By default when --all is specified, reflogs from all working\ntrees are processed. This option limits the processing to reflogs\nfrom the current working tree only."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %Cblue"
},
{
"role": "assistant",
"content": "switch color to blue"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Use GitHub for Windows for both Bitbucket and GitHub\n\nIs it possible to use GitHub for Windows for both Bitbucket and GitHub at once? \nFor example, can I have repo on both sites show up in the program, and when I commit/synch a repo, it push to the respective repo on the respective website?"
},
{
"role": "assistant",
"content": "No, if you mean: having a local repo with two remotes (one GitHub and one Bitbucket).\nYou can define only one remote with that client, and it will be either a GitHub one or a Bitbucket one.\n\nYes, if you limit to one remote, you can use GitHub for Windows with any upstream repo. \nThe process of adding an upstream repo is now easier with the (constantly) updated GitHub for Windows app:\n\nselect the URL and then drag the text from your browser, and drop it into the GitHub for Windows app. It will automatically add the repository.\n\n\n\n(Original answer February 2013)\nIn order for \"GitHub for Windows\" to publish (instead of \"pushing to GitHub\"), you need to define a remote \"origin\" (in the settings of your local repo) using the https address of the Bitbucket repo:\nhttps://[email protected]/user/repo\n\nSo if you create a local repo through \"GitHub for Windows\", you can add, through its settings, the right remote:\n\nNote that the first refresh will trigger a login screen, in order for you to enter your http credential you are using on bitbucket.org: they will be cached (and encrypted) by GitHub for Windows for the duration of your current session.\n\n(See \"Password Caching\" and \"git: 'credential-cache' is not a git command\", for more on that credential caching mechanism, recently introduced with Git 1.7.9+)\nAny modification you are doing locally will be picked up by the GitHub for Windows client (you might need to exit the repo (left arrow in the top left corner of the GitHub for Windows client, and click again on your local Bitbucket repository: that will trigger a refresh):\n\nThe key in the next screenshot is in the word \"publish\" (instead of \"push to GitHub\").\nThat is because the remote \"origin\" is an https one.\n\nClick on \"publish\" and you will see your repo status set to \"in sync\":\n\nRush to bitbucket.org to check if, indeed GitHub for Windows did push to Bitbucket:"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Difference between git merge master and origin/master?\nResult of the command git merge origin/master:\njavanoob@DELL:~/workspace/PROJECT_One$ git merge origin/master \nUpdating d83ef9c..dd520ea\nerror: The following untracked working tree files would be overwritten by merge:\n sample.txt\nPlease move or remove them before you can merge.\nAborting\n\nResult of the command git merge master:\njavanoob@DELL:~/workspace/PROJECT_One$ git merge master\nAlready up-to-date.\n\nWhen I do the command git merge origin/master It shows that there are some files which will be overwritten but if I do the same command without the prefix origin/ it says everything is already up-to-date.\nWhat is wrong in this setup?\nI don't know if it matters but before running these commands, I did run the command git fetch origin"
},
{
"role": "assistant",
"content": "git fetch fetches information on remote branches, but does not make any changes to your local master branch. Because of this, master and origin/master are still diverged. You'd have to merge them by using git pull.\nWhen you make a commit, your local master branch is ahead of origin/master until you push those changes. This case is the opposite, where the origin/master branch is ahead of your local master branch. This is why you are getting different outcomes.\nRead https://stackoverflow.com/a/7104747/2961170 for more information."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can I share my private GitHub repository by link?\nI have a Java application in a private repository on GitHub and I would like to share it with someone who doesn't have an account. I didn't find any option on the site for this.\nIs there a way to do this? Collaborators can be only GitHub users."
},
{
"role": "assistant",
"content": "There is no way to share private repository among non-Github users.\nYou need the Github account and be added as collaborator to the project."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why does Git say my master branch is \"already up to date\" even though it is not?\nBasic Problem\nI just deleted ALL the code from a file in my project and committed the change to my local git (on purpose). I did \ngit pull upstream master\n\nto fetch and merge from upstream (so in theory that deleted code should be back).\nGit tells me everything is up to date.\nEverything is definitely NOT up to date -- all that deleted code is still deleted.\nOther Relevant Info\nI only have one branch called \"master\".\nI recently set up \"master\" to track upstream like so:\n\nBranch master set up to track remote branch master from upstream.\n\nThe command git branch -vv yields:\n* master 7cfcb29 [upstream/master: ahead 9] deletion test\n\nWhy why why is this happening? I'm on the verge of just e-mailing my project manager any changes I make to our code.\nUpdate\nI thought it was obvious, but anyways this is my goal:\nGet the most recent of the code on my system.\nExcuse my anger here, but why does such a simple task as that have to be so hard?"
},
{
"role": "assistant",
"content": "I think your basic issue here is that you're misinterpreting and/or misunderstanding what git does and why it does it.\nWhen you clone some other repository, git makes a copy of whatever is \"over there\". It also takes \"their\" branch labels, such as master, and makes a copy of that label whose \"full name\" in your git tree is (normally) remotes/origin/master (but in your case, remotes/upstream/master). Most of the time you get to omit the remotes/ part too, so you can refer to that original copy as upstream/master.\nIf you now make and commit some change(s) to some file(s), you're the only one with those changes. Meanwhile other people may use the original repository (from which you made your clone) to make other clones and change those clones. They are the only ones with their changes, of course. Eventually though, someone may have changes they send back to the original owner (via \"push\" or patches or whatever).\nThe git pull command is mostly just shorthand for git fetch followed by git merge. This is important because it means you need to understand what those two operations actually do.\nThe git fetch command says to go back to wherever you cloned from (or have otherwise set up as a place to fetch from) and find \"new stuff someone else added or changed or removed\". Those changes are copied over and applied to your copy of what you got from them earlier. They are not applied to your own work, only to theirs.\nThe git merge command is more complicated and is where you are going awry. What it does, oversimplified a bit, is compare \"what you changed in your copy\" to \"changes you fetched from someone-else and thus got added to your-copy-of-the-someone-else's-work\". If your changes and their changes don't seem to conflict, the merge operation mushes them together and gives you a \"merge commit\" that ties your development and their development together (though there is a very common \"easy\" case in which you have no changes and you get a \"fast forward\").\nThe situation you're encountering now is one in which you have made changes and committed them—nine times, in fact, hence the \"ahead 9\"—and they have made no changes. So, fetch dutifully fetches nothing, and then merge takes their lack-of-changes and also does nothing.\nWhat you want is to look at, or maybe even \"reset\" to, \"their\" version of the code.\nIf you merely want to look at it, you can simply check out that version:\ngit checkout upstream/master\n\nThat tells git that you want to move the current directory to the branch whose full name is actually remotes/upstream/master. You'll see their code as of the last time you ran git fetch and got their latest code.\nIf you want to abandon all your own changes, what you need to do is change git's idea of which revision your label, master, should name. Currently it names your most recent commit. If you get back onto that branch:\ngit checkout master\n\nthen the git reset command will allow you to \"move the label\", as it were. The only remaining problem (assuming you're really ready to abandon everything you've don) is finding where the label should point.\ngit log will let you find the numeric names—those things like 7cfcb29—which are permanent (never changing) names, and there are a ridiculous number of other ways to name them, but in this case you just want the name upstream/master.\nTo move the label, wiping out your own changes (any that you have committed are actually recoverable for quite a while but it's a lot harder after this so be very sure):\ngit reset --hard upstream/master\n\nThe --hard tells git to wipe out what you have been doing, move the current branch label, and then check out the given commit.\nIt's not super-common to really want to git reset --hard and wipe out a bunch of work. A safer method (making it a lot easier to recover that work if you decide some of it was worthwhile after all) is to rename your existing branch:\ngit branch -m master bunchofhacks\n\nand then make a new local branch named master that \"tracks\" (I don't really like this term as I think it confuses people but that's the git term :-) ) the origin (or upstream) master:\ngit branch -t master upstream/master\n\nwhich you can then get yourself on with:\ngit checkout master\n\nWhat the last three commands do (there's shortcuts to make it just two commands) is to change the name pasted on the existing label, then make a new label, then switch to it:\nbefore doing anything:\nC0 - \"remotes/upstream/master\"\n \\\n \\- C1 --- C2 --- C3 --- C4 --- C5 --- C6 --- C7 --- C8 --- C9 \"master\"\n\nafter git branch -m:\nC0 - \"remotes/upstream/master\"\n \\\n \\- C1 --- C2 --- C3 --- C4 --- C5 --- C6 --- C7 --- C8 --- C9 \"bunchofhacks\"\n\nafter git branch -t master upstream/master:\nC0 - \"remotes/upstream/master\", \"master\"\n \\\n \\- C1 --- C2 --- C3 --- C4 --- C5 --- C6 --- C7 --- C8 --- C9 \"bunchofhacks\"\n\nHere C0 is the latest commit (a complete source tree) that you got when you first did your git clone. C1 through C9 are your commits.\nNote that if you were to git checkout bunchofhacks and then git reset --hard HEAD^^, this would change the last picture to:\nC0 - \"remotes/upstream/master\", \"master\"\n \\\n \\- C1 --- C2 --- C3 --- C4 --- C5 --- C6 --- C7 - \"bunchofhacks\"\n \\\n \\- C8 --- C9\n\nThe reason is that HEAD^^ names the revision two up from the head of the current branch (which just before the reset would be bunchofhacks), and reset --hard then moves the label. Commits C8 and C9 are now mostly invisible (you can use things like the reflog and git fsck to find them but it's no longer trivial). Your labels are yours to move however you like. The fetch command takes care of the ones that start with remotes/. It's conventional to match \"yours\" with \"theirs\" (so if they have a remotes/origin/mauve you'd name yours mauve too), but you can type in \"theirs\" whenever you want to name/see commits you got \"from them\". (Remember that \"one commit\" is an entire source tree. You can pick out one specific file from one commit, with git show for instance, if and when you want that.)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I publish a private npm package with gitlab ci?\n\nI want to publish a private npm package with Gitlab CI.\nI've created an auth token for my npm user and set it as a variable NPM_TOKEN in my Gitlab CI settings.\nThe job then creates an .npmrc file with the registry and the auth token.\n- npm run build && npm run build:es6\n- echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}'>.npmrc\n- npm publish\n\nThe job fails with this message:\nnpm ERR! code ENEEDAUTH\nnpm ERR! need auth auth required for publishing\nnpm ERR! need auth You need to authorize this machine using `npm adduser`\n\nIs it possible to publish with only an auth token?"
},
{
"role": "assistant",
"content": "As @Amityo said, rather than manually editing the npmrc file,\nnpm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}\n\nis the way to go, because otherwise you may be editing the wrong npmrc file.\nIf you are still getting an authentication error, and are certain that the token is correct, check your registry URL. You can run\nnpm publish --verbose\n\nwhose output will includes lines like\nnpm verb getPublishConfig { registry: 'https://.......' }\nnpm verb mapToRegistry no registry URL found in name for scope @boxine\nnpm verb publish registryBase https://.......\n\nIf you are publishing to npmjs.org, the URL (....... above) should be https://registry.npmjs.org/ .\nIf this registry URL does not fit, look in your npmrc file for a different one. Also make sure you didn't override the registry in your package.json file! You can search for publishConfig in that file."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I change which GitHub project I forked from?\n\nI forked a project, made some changes, and got a pull request accepted. But now, the project I forked moved to another repository and is a fork of that repository.\nThat is:\nOriginal -> MyFork\n\nNow:\nNewOriginal -> Original -> MyFork\n\nHow would I get it to the following?\nNewOriginal -> MyFork"
},
{
"role": "assistant",
"content": "NOTE: The following solution is incomplete as you'll lose all wiki content and issues specific to your fork.\nYou can achieve this using the following steps:\n\nPull down all branches and tags from your existing fork.\nDelete your repository on GitHub.\nFork from the new repository.\nUpdate the remote URL if necessary.\nPush all your local branches and tags to the new repository."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-verify-pack - Validate packed Git archive files -s --stat-only"
},
{
"role": "assistant",
"content": "Do not verify the pack contents; only show the histogram of delta\nchain length. With --verbose , the list of objects is also shown."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --grep-reflog=<pattern>"
},
{
"role": "assistant",
"content": "Limit the commits output to ones with reflog entries that\nmatch the specified pattern (regular expression). With\nmore than one --grep-reflog , commits whose reflog message\nmatches any of the given patterns are chosen. It is an\nerror to use this option unless --walk-reflogs is in use."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-shortlog - Summarize git log output --simplify-merges"
},
{
"role": "assistant",
"content": "First, build a history graph in the same way that --full-history with parent rewriting does (see above). Then simplify each commit C to its replacement C' in the final\nhistory according to the following rules: Set C' to C . Replace each parent P of C' with its simplification P' . In\nthe process, drop parents that are ancestors of other parents or that are\nroot commits TREESAME to an empty tree, and remove duplicates, but take care\nto never drop all parents that we are TREESAME to. If after this parent rewriting, C' is a root or merge commit (has\nzero or >1 parents), a boundary commit, or !TREESAME, it remains.\nOtherwise, it is replaced with its only parent. The effect of this is best shown by way of comparing to --full-history with parent rewriting. The example turns into: .-A---M---N---O\n\t / / /\n\tI B D\n\t \\ / /\n\t `---------' Note the major differences in N , P , and Q over --full-history : N 's parent list had I removed, because it is an ancestor of the\nother parent M . Still, N remained because it is !TREESAME. P 's parent list similarly had I removed. P was then\nremoved completely, because it had one parent and is TREESAME. Q 's parent list had Y simplified to X . X was then removed, because it\nwas a TREESAME root. Q was then removed completely, because it had one\nparent and is TREESAME."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to release a build artifact asset on GitHub with a script?\n\nI am trying to figure out a one-command process for generating a build on GitHub.\nWhat I anticipate doing is running some sort of command- make release, say, and the make release script builds up the release artifact and then uploads it to GitHub in some fashion.\nHowever, I'm fairly confused about how to actually get a release artifact on GitHub. Source code is awesome, but not everyone wants to do their own builds. :-)"
},
{
"role": "assistant",
"content": "Update 2022: The official GitHub CLI comes with gh release upload\n\nUpload asset files to a GitHub Release.\n\nYou can create the release first with gh release create\nUpload all tarballs in a directory as release assets\n$ gh release create v1.2.3 ./dist/*.tgz\n\nUpload a release asset with a display label\n$ gh release create v1.2.3 '/path/to/asset.zip#My display label'\n\n\nUpdate September 2013, you can automate a release (API in preview mode)\nUpdate January 2014, there's an unofficial command-line app, called github-release by Nicolas Hillegeer (aktau), for creating releases and uploading (binary) artifacts.\nIt uses the new github releases API mentioned above. Look at the Makefile of the project to see how to automate it more still.\nExample:\n# create a formal release\n$ github-release release \\\n --user aktau \\\n --repo gofinance \\\n --tag v0.1.0 \\\n --name \"the wolf of source street\" \\\n --description \"Not a movie, contrary to popular opinion. Still, my first release!\" \\\n --pre-release\n\n\n\nThis API is a little different due to the binary assets. We use the Accept header for content negotation when requesting a release asset.\nPass a standard API media type to get the API representation:\n\n$ curl -i -H \"Authorization: token TOKEN\" \\\n -H \"Accept: application/vnd.github.manifold-preview\" \\\n \"https://uploads.github.com/repos/hubot/singularity/releases/assets/123\"\n\nHTTP/1.1 200 OK\n\n{\n \"id\": 123,\n...\n}\n\n\nPass “application/octet-stream” to download the binary content.\n\n$ curl -i -H \"Authorization: token TOKEN\" \\\n -H \"Accept: application/octet-stream\" \\\n \"https://uploads.github.com/repos/hubot/singularity/releases/assets/123\"\n\nHTTP/1.1 302 Found\n\n\nUploads are handled by a single request to a companion “uploads.github.com” service.\n\n$ curl -H \"Authorization: token TOKEN\" \\\n -H \"Accept: application/vnd.github.manifold-preview\" \\\n -H \"Content-Type: application/zip\" \\\n --data-binary @build/mac/package.zip \\\n \"https://uploads.github.com/repos/hubot/singularity/releases/123/assets?name=1.0.0-mac.zip\"\n\n\nUpdate 2d July 2013, you now can define a release.\n\n\nReleases are accompanied by release notes and links to download the software or source code.\nFollowing the conventions of many Git projects, releases are tied to Git tags. You can use an existing tag, or let releases create the tag when it's published.\nYou can also attach binary assets (such as compiled executables, minified scripts, documentation) to a release. Once published, the release details and assets are available to anyone that can view the repository.\n\nThis is what replaces the old binary upload service, which was removed in December 2012!\n\n\nthe make release script builds up the release artifact and then uploads it to github in some fashion.\n\nThat would mean adding it (\"it\" being the delivery made of one or several files, generally including binaries) to a regular local repo, and then pushing that repo to its matching GitHub repo.\nThat being said, the reason GitHub isn't mention in any \"release\" task is because Git is a source control management system, and is ill-suited for binaries.\nIt can have those files (binaries) of course, but isn't made to have them regularly, because of the bloated size of the repo after a while: each cloning would take longer and longer.\nSee What are the Git limits, and also \"git - should source files and repository be on the same machine ?\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Does Git publicly expose my e-mail address?\nThe guides I've read so far on Git say that I should go into the config and specify my name and my e-mail address. They don't elaborate; they just say to do it.\nWhy does Git need my e-mail address? And, more importantly, if I make my repo publicly available, via GitHub for example, will my e-mail address be visible to everyone (including spambots)?"
},
{
"role": "assistant",
"content": "Update April 2017\nSee \"Private emails, now more private\"\n\nGitHub has supported using an alternate \"noreply\" email address to author web-based commits for a while now. Starting today, there's another way to ensure you don't inadvertently publish your email address when pushing commits to GitHub via the command line.\nGit uses your email address to associate your name to any commits you author. Once you push your commits to a public repository on GitHub, the authorship metadata is published as well.\nIf you'd like to ensure you don't accidentally publish your email address, simply check the \"Keep my email address private\" and \"Block command line pushes that expose my email\" options in your email settings.\n\n\nNote: as commented below by orev, Git doesn't expose anything. GitHub, a Git repositories hosting service, might.\nThe place where you are pushing your local Git repo can expose metadata.\n\nNote: Starting August, 9th 2013, you now can keep your email address private!\nThat is for web-based GitHub operations though: the commits still contain an email address, which could or could not be the same than the one used for your GitHub account.\nSee below to \"mask\" that (git commit) email too.\n\nUntil today, all web-based GitHub Flow used your primary email address. This includes creating, editing, and deleting files, as well as merging pull requests.\nBut now you can keep your email address private. To do so, visit your email settings page:\n\n\n\nWith this turned on, web-based operations will use a [email protected] email address.\n\n\nIf you want to hide your email made from your computer, GitHub now allows you to register different email addresses: see this guide.\nYou still need to configure your (fake) email in your local repo before pushing back to GitHub, if you want your commits to reflect \ngit config --global user.email \"[email protected]\" # Set email to slightly changed value\ngit config --global user.email # Verify the setting\n# [email protected]\n\nThen: \n\nGo to the Emails setting menu\nClick \"Add another email address\"\nEnter the fake email (e.g. \"[email protected]\") and click \"Add\"\n\n\nNote that:\n\nThis setting only affects future commits.\n If you want to erase your real email address from your repository's commit history, you will have to rewrite your old commits. The easiest way to do this is to:\nUse git filter-branch to rewrite the repository history and Force-push the new history up."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Github Actions, how to share a calculated value between job steps?\n\nIs there a DRY way to calculate and share a value in multiple job steps with Github Actions?\nIn the below workflow yml file, echo ${GITHUB_REF} | cut -d'/' -f3`-${GITHUB_SHA} is repeated in multiple steps.\nname: Test, Build and Deploy\non:\n push:\n branches:\n - master\njobs:\n build_and_push:\n name: Build and Push\n runs-on: ubuntu-latest\n steps:\n - name: Docker Build\n uses: \"actions/docker/cli@master\"\n with:\n args: build . --file Dockerfile -t cflynnus/blog:`echo ${GITHUB_REF} | cut -d'/' -f3`-${GITHUB_SHA}\n - name: Docker Tag Latest\n uses: \"actions/docker/cli@master\"\n with:\n args: tag cflynnus/blog:`echo ${GITHUB_REF} | cut -d'/' -f3`-${GITHUB_SHA} cflynnus/blog:latest"
},
{
"role": "assistant",
"content": "set-output can be used to define outputs for steps. The outputs can then be used in later steps and evaluated in with and env input sections. Also, the step returning outputs should have an id, which is referred to by the step consuming the outputs.\nThe following is what that would look like for your example.\nname: Test, Build and Deploy\non:\n push:\n branches:\n - master\njobs:\n build_and_push:\n name: Build and Push\n runs-on: ubuntu-latest\n steps:\n - name: Set tag var\n id: vars\n run: echo \"docker_tag=$(echo ${GITHUB_REF} | cut -d'/' -f3)-${GITHUB_SHA}\" >> $GITHUB_OUTPUT\n - name: Docker Build\n uses: \"actions/docker/cli@master\"\n with:\n args: build . --file Dockerfile -t cflynnus/blog:${{ steps.vars.outputs.docker_tag }}\n - name: Docker Tag Latest\n uses: \"actions/docker/cli@master\"\n with:\n args: tag cflynnus/blog:${{ steps.vars.outputs.docker_tag }} cflynnus/blog:latest\n\nHere is another example showing how to dynamically set multiple variables to be used by an action.\n - name: Set output variables\n id: vars\n run: |\n pr_title=\"[Test] Add report file $(date +%d-%m-%Y)\"\n pr_body=\"This PR was auto-generated on $(date +%d-%m-%Y) \\\n by [create-pull-request](https://github.com/peter-evans/create-pull-request).\"\n echo \"pr_title=$pr_title\" >> $GITHUB_OUTPUT\n echo \"pr_body=$pr_body\" >> $GITHUB_OUTPUT\n - name: Create Pull Request\n uses: peter-evans/create-pull-request@v4\n with:\n title: ${{ steps.vars.outputs.pr_title }}\n body: ${{ steps.vars.outputs.pr_body }}\n\nAlternatively you can create environment variables.\n - name: Set environment variables\n run: |\n echo \"PR_TITLE=[Test] Add report file $(date +%d-%m-%Y)\" >> $GITHUB_ENV\n echo \"PR_BODY=This PR was auto-generated on $(date +%d-%m-%Y) by [create-pull-request](https://github.com/peter-evans/create-pull-request).\" >> $GITHUB_ENV\n - name: Create Pull Request\n uses: peter-evans/create-pull-request@v4\n with:\n title: ${{ env.PR_TITLE }}\n body: ${{ env.PR_BODY }}\n\nUpdate: The docker actions in the first example are deprecated. Please see this answer for the latest way to work with docker in GitHub Actions.\nNote: For sharing values between different jobs, see this question."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options imap.pass"
},
{
"role": "assistant",
"content": "The password to use when logging in to the server."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Visual Studio - Remote: HTTP Basic: Access denied Error encountered while cloning the remote repository: Git failed with a fatal error\n\nI'm working with Visual Studio and am trying to clone a online repo from a server where gitlab is running. Let's call the server https://gitlab.example.com\nI get the following error when I try to clone the repo \nRemote: HTTP Basic: Access denied\nError encountered while cloning the remote repository: Git failed with a fatal error.\nAuthentication failed for 'https://gitlab.example.com/username/test.git/'\n\nWhen I try it, I get promted to enter a username and password for the server. I entered the user credentials of the user which created the repo. \nI've found a similar problem with an answer here on stackoverflow, but this didn't work for me.\nI am using Visual Studio 2017 Enterprise 15.7.2"
},
{
"role": "assistant",
"content": "Windows must have saved your git credentials which needs to be updated/remove. Below steps worked for me in VS2017.\nGo to \"Credential Manager\" from Windows \"Start\" and under \"Generic Credentials\" select your git url. Click on the right side arrow, it should expand and you should see two links \"Edit\" & \"Remove from vault\". \nClick on latter link (recommendable), restart VS, open your project & do a sync/pull request, it should ask your credentials to enter and you should be good to go. Thanks"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Closing multiple issues in Github with a commit message\n\nI know you can close issues by putting closes #1 or fixes #1 in the commit message. What is the best way to close multiple issues in the same commit message?\nAlso, it appears that using fixes rather than closes doesn't create a link from the commit message to the issue, but it does close the issue. What's up with that?"
},
{
"role": "assistant",
"content": "Closes #1, closes #2, closes #3; rest of commit message.\nThe closes clauses can be anywhere in the message and fixes is a valid synonym:\nThis fixes a memory leak in foo() that closes #4,\nalso fixes #5 which is a duplicate.\n\n\nThe following used to work, but nowadays only references issues #2 and #3.\nCloses #1, #2, #3"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git how to disable push [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nGit: Set up a fetch-only remote?\n\n (5 answers)\n \n\nClosed 9 years ago.\n\n\n\nI am using git and I am doing my development work, which I don't want to push, even by mistake. Is there a method to disable push in certain local repository. One method is to rename the branch, another is to undo push if one does it by mistake, but I hope there should be a more direct method."
},
{
"role": "assistant",
"content": "The following command will let pulls work, but pushes will try to use the URL no_push and fail:\ngit remote set-url --push origin no_push"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options trace2.envVars"
},
{
"role": "assistant",
"content": "A comma-separated list of \"important\" environment variables that should\nbe recorded in the trace2 output. For example, GIT_HTTP_USER_AGENT,GIT_CONFIG would cause the trace2 output to\ncontain events listing the overrides for HTTP user agent and the\nlocation of the Git configuration file (assuming any are set). May be\noverridden by the GIT_TRACE2_ENV_VARS environment variable. Unset by\ndefault."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rebase - Reapply commits on top of another base tip rebase.updateRefs"
},
{
"role": "assistant",
"content": "If set to true enable --update-refs option by default."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-http-push"
},
{
"role": "assistant",
"content": "Push objects over HTTP/DAV to another repository"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I delete a repository in the new Bitbucket\nThe documentation is out of date\nThe new interface does not have the configuration button:"
},
{
"role": "assistant",
"content": "Log into your Bitbucket account. Navigate to the repository you want to delete. Click the repository's settings icon. Choose Delete Repository from the left-hand navigation. The system displays the deletion dialog."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git update-index --assume-unchanged and git reset\nHere is the scenario:\nIn my working directory, I have a number of files (let's call them A,B,C) that I've edited. I then ran git update-index --assume-unchanged on those files. Now git status returns blank. Good.\nNow, if I do a git reset --hard, the contents of the files A,B, and C, revert back to the contents before I've edited them and \"assume-unchanged\" them. \nIs there a way to stop git from actually reverting files A,B, and C, and simply ignore them? \nThanks,\nKen"
},
{
"role": "assistant",
"content": "You can do:\ngit update-index --skip-worktree A"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rebase - Reapply commits on top of another base tip --ignore-date --reset-author-date"
},
{
"role": "assistant",
"content": "Instead of using the author date of the original commit, use\nthe current time as the\tauthor date of the rebased commit. This\noption implies --force-rebase . See also INCOMPATIBLE OPTIONS below."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git post-push hook? [duplicate]\nThis question already has answers here:\n \n \n\n\n\nClosed 11 years ago.\n\n\n\n\nPossible Duplicate:\nLocal executing hook after a git push? \n\ngit has a number of hooks that can call scripts near certain events.\nIs it possible to setup a git hook in my working repository that executes something locally after I push to a remote branch? If so which hook is it?"
},
{
"role": "assistant",
"content": "The list of hooks in man githooks is complete. There is no post-push hook. There are hooks which run in a repository after someone's pushed into it (i.e. for putting in the central repository), but nothing is triggered in the repository that you pushed from.\nIf there's a common task you need to do after pushing, you could make an alias which pushes then does that."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git, see a list of comments of my last N commits\nIs there a way to see a list of comments and time of my last N commits in Git?\nAfter looking on SO, the only relevant thing I have found is\nGit - get all commits and blobs they created, but it shows all commits from all users, and outputs a lot of other information."
},
{
"role": "assistant",
"content": "If you want to use the command line you can use the --author=<your name>\nFor example: to see your last 5 commits\ngit log -n 5 --author=Salvador\n\nIf you want a simpler one line solution:\ngit log --oneline -n 5 --author=Salvador\n\nEdited to add\nIf you like the single line version, try creating an alias for git log like this (this is what I have for zsh)\nalias glog=\"git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit\"\n\nNow, I can just use:\nglog -n 5\n\nAnd I get a nice output such as:\n\nWhich is colourised, shows the name of the author and also shows the graph and you can still pass in other flags (such as --author) which lets you filter it even more."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I remove a tracked file from merge request\n\nI have committed and pushed some files to remote feature branch and created a merge request. I used\ngit commit -a -m \"blah blah\"\ngit push\n\nSo it pushed all the modified files. One of the files (which is an existing file in in the master) was not supposed to be pushed (like for e.g. executables). How do I remove this file from the merge request, so that when the MR is merged into master, the unwanted file is not merged (as if it was never there in the MR). I found this page mentioning the following commands\ngit rm {filename} --cached\ngit commit -m \"[...]\"\ngit push\n\nI tried the commands, but do not see the file removed in the merge request in Gitlab. Is this the right way to do it?\nUpdate1:\nWith the above commands, I could see the file mentioned as deleted in the above commit. But then when I merge the updated MR into master, the file is deleted from master too.\nUpdate2:\nRemoved sentences causing confusion and updated the title"
},
{
"role": "assistant",
"content": "What version of Gitlab are you using?\nJust tested with latest version (14.5.2):\ngit checkout -b feature-123\ngit add package.json package-lock.json\ngit commit -m 'Commit with extra file.'\ngit push --set-upstream origin feature-123\n\nCreated MR, it shows two files changed\nNow, from the same branch:\ngit rm --cached package-lock.json\ngit commit -m 'Removing extra file.'\ngit push\n\nMR now shows only one modified file.\nBut if this MR is accepted without squash, the git history will contain adding and removing an extra file.\nIf you have committed a very large file, it may be better to ask the maintainer to squash your changes before merging. Or delete MR and create a new one with a single commit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitLab Pages deployment step fails after successfull build\n\nI am trying to host a reveal.js presentation via gitlab pages. The repository can be found here: https://gitlab.com/JanGregor/demo-slides\nMy .gitlab-ci.yml is fairly simple:\nimage: node:4.2.2\n\npages:\n cache:\n paths:\n - node_modules/\n script:\n - npm install\n - node_modules/.bin/gulp\n artifacts:\n paths:\n - build\n only:\n - master\n\nAfter a commit to master though, something goes wrong. The pages task itself is executed and runs just fine. It even shows in the logs that my build directory has been scanned and that the artefacts have been found.\nOddly, the subsequent pages:deploy task fails. It only says :\n\npages failed to extract\n\nAny help would be greatly appreciated, since I have no clue where to look to next. The documentation itself isn't really helpful when trying to implement an deployment flow with npm.\nThanks in advance folks !"
},
{
"role": "assistant",
"content": "Apparently a page can only be published from a folder in under the artifacts that is called \"public\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --left-only --right-only"
},
{
"role": "assistant",
"content": "List only commits on the respective side of a symmetric difference,\ni.e. only those which would be marked < resp. > by --left-right . For example, --cherry-pick --right-only A...B omits those\ncommits from B which are in A or are patch-equivalent to a commit in A . In other words, this lists the + commits from git cherry A B .\nMore precisely, --cherry-pick --right-only --no-merges gives the exact\nlist."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_TRACE_SHALLOW"
},
{
"role": "assistant",
"content": "Enables trace messages that can help debugging fetching /\ncloning of shallow repositories.\nSee GIT_TRACE for available trace output options."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-commit - Record changes to the repository --no-edit"
},
{
"role": "assistant",
"content": "Use the selected commit message without launching an editor.\nFor example, git commit --amend --no-edit amends a commit\nwithout changing its commit message."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to manage the version number in Git?\nLet's imagine the blerp command line tool maintained on git. This tool has the (hidden) --version option which returns its version (let's say 0.1.2) and another --commit which returns the commit number from which it was built.\nBoth the version and the commit number are hard-coded on the code base.\nNow I make a bugfix then commit and rebuild my program. I will still see 0.1.2 although this new version differs from the original 0.1.2. Only the commit will tell me that it is not the same 0.1.2. Is that bugfix worth a different version number?\nOne solution is that each time I make a commit, I increase the hard-coded version number (which implies to always modify a minimum of 2 files for each commit). This is a binding solution and it does not work when the developers are working on different active branches. If Bob works on feature foo from the version 0.1.2 and Alice works on feature bar from the same version, how do they increase their version number? Bob can use the odd and Alice the even. What if Eve works on a third feature?\nAnother solution can be to use Git tags to automatically generate the version number. A script can find the closest tag starting with v such as v0.1.2 and use the tag name as the version number plus the first n digits of the current commit (v0.1.2 (build 4acd21)). This works well if the working directory is clean. One can imagine to add a * before the build number to indicate the working directory is not clean. The main problem with this solution is if somebody exports the sources, it won't be able to build blerp.\nWhat possible alternative can solve this issue?"
},
{
"role": "assistant",
"content": "Alexey Kiselev and Dario already hinted towards the answer, but I will try to explain it in detail.\nVersioning Schemes\nThere are two types of versioning schemes:\n\nInternal version number: This can be incremented many times in a day (e.g. revision control number)\nReleased version: This changes less often (e.g. semantic versioning)\n\nPeople use different schemes as per their need, but semantic versioning is fairly widely used and authored by Tom Preston-Werner, co-founder of GitHub.\nSemantic Versioning\nSemantic versioning follows the pattern of X.Y.Z\nOr more readable would be [major].[minor].[patch]-[build/beta/rc]\nE.g. 1.2.0-beta\nmajor or X can be incremented if there are major changes in software, like backward-incompatible API release.\nminor or Y is incremented if backward compatible APIs are introduced.\npatch or Z is incremented after a bug fix.\nHow do we achieve this using Git?\nBy using tags:\nTags in Git can be used to add a version number.\ngit tag -a \"v1.5.0-beta\" -m \"version v1.5.0-beta\"\n\nadds a version tag of v1.5.0-beta to your current Git repository. Every new commit after this will auto-increment tag by appending commit number and commit hash. This can be viewed using the git describe command.\nv1.5.0-beta-1-g0c4f33f here -1- is the commit number and 0c4f33f the abbreviation of commit's hash. The g prefix stands for \"git\".\nComplete details can be viewed using:\ngit show v1.5.0-beta"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I find the most recent git commit that modified a file?\nI want to find the most recent commit that modified a source file. \nI can use git blame to see all the dates for commits by each line, but it’s difficult to see exactly which commit was the last one to touch the file.\nHow can I find the last commit that touched a given file in my git repository?"
},
{
"role": "assistant",
"content": "git log supports looking at the history of specific files (and directories), so you can call it like this:\ngit log my/file.c\n\nIf you really only want to list the one most recent commit, for example to use it in a script, use the -n 1 option:\ngit log -n 1 --pretty=format:%H -- my/file.c\n\n--pretty=format:%h tells git log to show only the commit hash. The -- separater stops the file name from getting interpreted as a commit name, just in case it's ambiguous."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %p"
},
{
"role": "assistant",
"content": "abbreviated parent hashes"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Invoke GitHub Actions workflow manually and pass parameters\n\nI want to pass some dynamic parameters and invoke my GitHub Actions workflow manually (ideally via some API). Is this possible?"
},
{
"role": "assistant",
"content": "With the workflow_dispatch event trigger, you can do the manual triggers easily.\nFlow:\non: \n workflow_dispatch:\n inputs:\n logLevel:\n description: 'Log level' \n required: true\n default: 'warning'\n tags:\n description: 'Test scenario tags' \n\nManual trigger screenshot:\n\nBlog post announcement reference, https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.<driver>.textconv"
},
{
"role": "assistant",
"content": "The command that the diff driver should call to generate the\ntext-converted version of a file. The result of the\nconversion is used to generate a human-readable diff. See gitattributes for details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitLab CI: Two independent scheduled jobs\n\nConsider the following gilab-ci.yml script:\nstages:\n - build_for_ui_automation\n - independent_job\n\nvariables:\n LC_ALL: \"en_US.UTF-8\"\n LANG: \"en_US.UTF-8\"\n\nbefore_script:\n - gem install bundler\n - bundle install\n\nbuild_for_ui_automation:\n dependencies: []\n stage: build_for_ui_automation\n artifacts:\n paths:\n - fastlane/screenshots\n - fastlane/logs\n - fastlane/test_output\n - fastlane/report.xml\n script:\n - bundle exec fastlane ui_automation\n tags:\n - ios\n only:\n - schedules\n allow_failure: false\n\n# This should be added and trigerred independently from \"build_for_ui_automation\"\nindependent_job:\n dependencies: []\n stage: independent_job\n artifacts:\n paths:\n - fastlane/screenshots\n - fastlane/logs\n - fastlane/test_output\n - fastlane/report.xml\n script:\n - bundle exec fastlane independent_job\n tags:\n - ios\n only:\n - schedules\n allow_failure: false\n\nI'd like to be able to schedule these two jobs independently, but following the rules:\n\nbuild_for_ui_automation runs every day at 5 AM\nindependent_job runs every day at 5 PM\n\nHowever, with the current setup I can only trigger the whole pipeline, which will go through both jobs in sequence.\nHow can I have a schedule triggering only a single job?"
},
{
"role": "assistant",
"content": "Note - This answer used, only-except of GitLab CI to manipulate what job gets added to the schedule. However, as of today, GitLab has stopped active maintenance of the same commands and suggests we use rules instead. Here's the link.\nI have modified the original answer to use rules and tested the working.\nTo build off @Naor Tedgi's answer, you can define a variable in your pipeline schedules. For example, set SCHEDULE_TYPE = \"build_ui\" in the schedule for build_for_ui_automation and SCHEDULE_TYPE = \"independent\" in the schedule for independent_job. Then your .gitlab-ci.yml file could be modified as:\nstages:\n - build_for_ui_automation\n - independent_job\n\nvariables:\n LC_ALL: \"en_US.UTF-8\"\n LANG: \"en_US.UTF-8\"\n\nbefore_script:\n - gem install bundler\n - bundle install\n\nbuild_for_ui_automation:\n dependencies: []\n stage: build_for_ui_automation\n artifacts:\n paths:\n - fastlane/screenshots\n - fastlane/logs\n - fastlane/test_output\n - fastlane/report.xml\n script:\n - bundle exec fastlane ui_automation\n tags:\n - ios\n rules:\n - if: '$CI_PIPELINE_SOURCE == \"schedule\" && $SCHEDULE_TYPE == \"build_ui\"'\n when: always\n variables:\n SCHEDULE_TYPE: \"build_ui\"\n ANOTHER_VARIABLE: \"dummy\"\n allow_failure: false\n\n# This should be added and trigerred independently from \"build_for_ui_automation\"\nindependent_job:\n dependencies: []\n stage: independent_job\n artifacts:\n paths:\n - fastlane/screenshots\n - fastlane/logs\n - fastlane/test_output\n - fastlane/report.xml\n script:\n - bundle exec fastlane independent_job\n tags:\n - ios\n rules:\n - if: '$CI_PIPELINE_SOURCE == \"schedule\" && $SCHEDULE_TYPE == \"independent\"'\n when: always\n variables:\n SCHEDULE_TYPE: \"independent\"\n ANOTHER_VARIABLE: \"dummy123\"\n allow_failure: false\n\nwhere note the syntax change in the only sections to execute the jobs only during schedules and when the schedule variable is matching."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-stash - Stash the changes in a dirty working directory away -a --all"
},
{
"role": "assistant",
"content": "This option is only valid for push and save commands. All ignored and untracked files are also stashed and then cleaned\nup with git clean ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "black as pre-commit hook always fails my commits\nI'm trying to use pre-commit to manage Black as a Git pre-commit hook, but I must be doing it wrong.\nIn my pre-commit config file I have:\n- repo: https://github.com/psf/black\n rev: 19.3b0\n hooks:\n - id: black\n\nWhat I'm expecting to happen is for Black to just modify the staged file, and for the commit to succeed. Because the whole point of Black is that it auto-enforces Python code style rules, no questions asked.\nWhat actually happens when I stage a (non-black-compliant) file and try to commit: Black goes ahead and modifies the file to make it compliant, as intended... But the problem is that it returns a \"fail\". So the commit fails. And then I have to unstage the file, then restage it before committing again... and only then does the commit succeed.\nThis is a huge annoyance and can't possibly be the intended workflow?\nWhat am I doing wrong?"
},
{
"role": "assistant",
"content": "(author of pre-commit here)\nthe framework intentionally does not provide a way to auto-commit modifications. Here's a few issues which have asked for such:\n\npre-commit/pre-commit#806\npre-commit/pre-commit#747\n\nA comment from one of those issues:\n\npre-commit itself will never touch the staging area. These are good ways to silently break commits. In my mind this is one of the worst things that [other frameworks do and suggest] -- hooks are very frequently not perfect and magically changing what's being committed should not be taken lightly.\nThat said, if you would like to foot gun, your hook can call git add -u and pre-commit won't know any better :) a sketch of that (untested, discouraged)\n - id: yapf\n entry: bash -c 'yapf \"$@\"; git add -u' --\n\n(note: using bash will potentially reduce portability)\n\nAnother comment notes\n\nFortunately, git add -u && !! is pretty easy to run if you're ok firing from the hip :)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Add all files to a commit except a single file?\nI have a bunch of files in a changeset, but I want to specifically ignore a single modified file. Looks like this after git status:\n# modified: main/dontcheckmein.txt\n# deleted: main/plzcheckmein.c\n# deleted: main/plzcheckmein2.c\n...\n\nIs there a way I can do git add but just ignore the one text file I don't want to touch? Something like:\ngit add -u -except main/dontcheckmein.txt"
},
{
"role": "assistant",
"content": "git add -u\ngit reset -- main/dontcheckmein.txt\n\nNote: Git has subsequently added special syntax for this, which is explained in other answers."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "In what cases could `git pull` be harmful?\nI have a colleague who claims that git pull is harmful, and gets upset whenever someone uses it.\nThe git pull command seems to be the canonical way to update your local repository. Does using git pull create problems? What problems does it create? Is there a better way to update a git repository?"
},
{
"role": "assistant",
"content": "Summary\nBy default, git pull creates merge commits which add noise and complexity to the code history. In addition, pull makes it easy to not think about how your changes might be affected by incoming changes.\nThe git pull command is safe so long as it only performs fast-forward merges. If git pull is configured to only do fast-forward merges and when a fast-forward merge isn't possible, then Git will exit with an error. This will give you an opportunity to study the incoming commits, think about how they might affect your local commits, and decide the best course of action (merge, rebase, reset, etc.).\nWith Git 2.0 and newer, you can run:\ngit config --global pull.ff only\n\nto alter the default behavior to only fast-forward. With Git versions between 1.6.6 and 1.9.x you'll have to get into the habit of typing:\ngit pull --ff-only\n\nHowever, with all versions of Git, I recommend configuring a git up alias like this:\ngit config --global alias.up '!git remote update -p; git merge --ff-only @{u}'\n\nand using git up instead of git pull. I prefer this alias over git pull --ff-only because:\n\nit works with all (non-ancient) versions of Git,\nit fetches all upstream branches (not just the branch you're currently working on), and\nit cleans out old origin/* branches that no longer exist upstream.\n\nProblems with git pull\ngit pull isn't bad if it is used properly. Several recent changes to Git have made it easier to use git pull properly, but unfortunately the default behavior of a plain git pull has several problems:\n\nit introduces unnecessary nonlinearities in the history\nit makes it easy to accidentally reintroduce commits that were intentionally rebased out upstream\nit modifies your working directory in unpredictable ways\npausing what you are doing to review someone else's work is annoying with git pull\nit makes it hard to correctly rebase onto the remote branch\nit doesn't clean up branches that were deleted in the remote repo\n\nThese problems are described in greater detail below.\nNonlinear History\nBy default, the git pull command is equivalent to running git fetch followed by git merge @{u}. If there are unpushed commits in the local repository, the merge part of git pull creates a merge commit.\nThere is nothing inherently bad about merge commits, but they can be dangerous and should be treated with respect:\n\nMerge commits are inherently difficult to examine. To understand what a merge is doing, you have to understand the differences to all parents. A conventional diff doesn't convey this multi-dimensional information well. In contrast, a series of normal commits is easy to review.\nMerge conflict resolution is tricky, and mistakes often go undetected for a long time because merge commits are difficult to review.\nMerges can quietly supersede the effects of regular commits. The code is no longer the sum of incremental commits, leading to misunderstandings about what actually changed.\nMerge commits may disrupt some continuous integration schemes (e.g., auto-build only the first-parent path under the assumed convention that second parents point to incomplete works in progress).\n\nOf course there is a time and a place for merges, but understanding when merges should and should not be used can improve the usefulness of your repository.\nNote that the purpose of Git is to make it easy to share and consume the evolution of a codebase, not to precisely record history exactly as it unfolded. (If you disagree, consider the rebase command and why it was created.) The merge commits created by git pull do not convey useful semantics to others—they just say that someone else happened to push to the repository before you were done with your changes. Why have those merge commits if they aren't meaningful to others and could be dangerous?\nIt is possible to configure git pull to rebase instead of merge, but this also has problems (discussed later). Instead, git pull should be configured to only do fast-forward merges.\nReintroduction of Rebased-out Commits\nSuppose someone rebases a branch and force pushes it. This generally shouldn't happen, but it's sometimes necessary (e.g., to remove a 50GiB log file that was accidentally comitted and pushed). The merge done by git pull will merge the new version of the upstream branch into the old version that still exists in your local repository. If you push the result, pitch forks and torches will start coming your way.\nSome may argue that the real problem is force updates. Yes, it's generally advisable to avoid force pushes whenever possible, but they are sometimes unavoidable. Developers must be prepared to deal with force updates, because they will happen sometimes. This means not blindly merging in the old commits via an ordinary git pull.\nSurprise Working Directory Modifications\nThere's no way to predict what the working directory or index will look like until git pull is done. There might be merge conflicts that you have to resolve before you can do anything else, it might introduce a 50GiB log file in your working directory because someone accidentally pushed it, it might rename a directory you are working in, etc.\ngit remote update -p (or git fetch --all -p) allows you to look at other people's commits before you decide to merge or rebase, allowing you to form a plan before taking action.\nDifficulty Reviewing Other People's Commits\nSuppose you are in the middle of making some changes and someone else wants you to review some commits they just pushed. git pull's merge (or rebase) operation modifies the working directory and index, which means your working directory and index must be clean.\nYou could use git stash and then git pull, but what do you do when you're done reviewing? To get back to where you were you have to undo the merge created by git pull and apply the stash.\ngit remote update -p (or git fetch --all -p) doesn't modify the working directory or index, so it's safe to run at any time—even if you have staged and/or unstaged changes. You can pause what you're doing and review someone else's commit without worrying about stashing or finishing up the commit you're working on. git pull doesn't give you that flexibility.\nRebasing onto a Remote Branch\nA common Git usage pattern is to do a git pull to bring in the latest changes followed by a git rebase @{u} to eliminate the merge commit that git pull introduced. It's common enough that Git has some configuration options to reduce these two steps to a single step by telling git pull to perform a rebase instead of a merge (see the branch.<branch>.rebase, branch.autosetuprebase, and pull.rebase options).\nUnfortunately, if you have an unpushed merge commit that you want to preserve (e.g., a commit merging a pushed feature branch into master), neither a rebase-pull (git pull with branch.<branch>.rebase set to true) nor a merge-pull (the default git pull behavior) followed by a rebase will work. This is because git rebase eliminates merges (it linearizes the DAG) without the --preserve-merges option. The rebase-pull operation can't be configured to preserve merges, and a merge-pull followed by a git rebase -p @{u} won't eliminate the merge caused by the merge-pull. Update: Git v1.8.5 added git pull --rebase=preserve and git config pull.rebase preserve. These cause git pull to do git rebase --preserve-merges after fetching the upstream commits. (Thanks to funkaster for the heads-up!)\nCleaning Up Deleted Branches\ngit pull doesn't prune remote tracking branches corresponding to branches that were deleted from the remote repository. For example, if someone deletes branch foo from the remote repo, you'll still see origin/foo.\nThis leads to users accidentally resurrecting killed branches because they think they're still active.\nA Better Alternative: Use git up instead of git pull\nInstead of git pull, I recommend creating and using the following git up alias:\ngit config --global alias.up '!git remote update -p; git merge --ff-only @{u}'\n\nThis alias downloads all of the latest commits from all upstream branches (pruning the dead branches) and tries to fast-forward the local branch to the latest commit on the upstream branch. If successful, then there were no local commits, so there was no risk of merge conflict. The fast-forward will fail if there are local (unpushed) commits, giving you an opportunity to review the upstream commits before taking action.\nThis still modifies your working directory in unpredictable ways, but only if you don't have any local changes. Unlike git pull, git up will never drop you to a prompt expecting you to fix a merge conflict.\nAnother Option: git pull --ff-only --all -p\nThe following is an alternative to the above git up alias:\ngit config --global alias.up 'pull --ff-only --all -p'\n\nThis version of git up has the same behavior as the previous git up alias, except:\n\nthe error message is a bit more cryptic if your local branch isn't configured with an upstream branch\nit relies on an undocumented feature (the -p argument, which is passed to fetch) that may change in future versions of Git\n\nIf you are running Git 2.0 or newer\nWith Git 2.0 and newer you can configure git pull to only do fast-forward merges by default:\ngit config --global pull.ff only\n\nThis causes git pull to act like git pull --ff-only, but it still doesn't fetch all upstream commits or clean out old origin/* branches so I still prefer git up."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I assign exe output to a variable in gitlab ci scripts?\n\nWhen running my gitlab ci I need to check whether a specified svn directory exists.\nI was using the script:\nvariables:\n DIR_CHECK: \"default\"\n\nstages:\n - setup\n - test\n - otherDebugJob\n \n.csharp:\n only:\n changes:\n - \"**/*.cs\"\n - \"**/*.js\"\n\nsetup:\n script:\n - $DIR_CHECK = $(svn ls https://server.fsl.local:port/svn/myco/personal/TestNotReal --depth empty)\n - echo $DIR_CHECK\ntest:\n script:\n - echo \"DIR_CHECK is blank\"\n - echo $DIR_CHECK\n rules:\n - if: $DIR_CHECK == ''\n\notherDebugJob:\n script:\n - echo \"DIR_CHECK is not blank\"\n - echo $DIR_CHECK\n rules:\n - if: $DIR_CHECK != ''\n \n\nthe svn command works and echos back the correct reply but $DIR_CHECK does not get set to anything but the original default. It does not store the returned string from the svn command.\nHow do I store the returned string from an exe in a variable in gitlab ci?\nTest run:\n\nExecuting \"step_script\" stage of the job script 00:00 $ $DIR_CHECK =\n$(svn ls https://server.fsl.local:port/svn/myco/personal/TestNotReal\n--depth empty) svn: E170000: Illegal repository URL https://server.fsl.local:port/svn/myco/personal/TestNotReal' $ echo\n$DIR_CHECK Cleaning up file based variables 00:01 Job succeeded"
},
{
"role": "assistant",
"content": "Passing variables between jobs\nUnfortunately, you cannot use DIR_CHECK variable the way you described. List of steps to be executed generates before steps actually runs, that means for all of the steps DIR_CHECK will be equal to default. First of all there are few tips how you can pass variables between jobs:\nFirst way\nYou can add desired command to the before_script section in your .csharp template:\n.csharp:\n before_script:\n - export DIR_CHECK=$(svn ls https://server.fsl.local:port/svn/myco/personal/TestNotReal --depth empty)\n\nand extend other steps with this .csharp.\nSecond way\nYou can pass variables between jobs with job artifacts:\nsetup:\n stage: setup\n script:\n - DIR_CHECK=$(svn ls https://server.fsl.local:port/svn/myco/personal/TestNotReal --depth empty)\n - echo \"DIR_CHECK=$DIR_CHECK\" > dotenv_file\n artifacts:\n reports:\n dotenv: \n - dotenv_file\n\nThirds way\nYou can trigger or use parent/child pipelines to pass variables into pipelines.\nstaging:\n variables:\n DIR_CHECK: \"you are awesome, guys!\"\n stage: deploy\n trigger: my/deployment\n\nIn the triggered pipeline your variable will exists at the very start moment, and all the rules will be applied correctly.\nSolution\nIn your case, if you really don't want to include otherDebugJob step in your pipeline you can do the following:\nFirst approach\nThis is quite easy way and this will work, but looks like not a best practice. So, we are already know how to pass our DIR_CHECK variable from setup step , just add some check in the test step script block:\nscript:\n- |\n if [ -z \"$DIR_CHECK\" ]; then\n exit 0\n fi\n- echo \"DIR_CHECK is blank\"\n- echo $DIR_CHECK\n\nDo the almost same thing for the otherDebugJob but check if DIR_CHECK is not empty with if [ -n \"$DIR_CHECK\" ].\nThis approach is helpful when your pipeline not contains a lot of steps, but after the test and otherDebugJob follows another few steps.\nSecond approach\nYou can fail your setup step and then handle this fail in otherDebugJob step:\nsetup:\n script:\n - DIR_CHECK=$(svn ls https://server.fsl.local:port/svn/myco/personal/TestNotReal --depth empty)\n - |\n if [ -z \"$DIR_CHECK\" ]; then\n exit 1\n fi\n\notherDebugJob:\n script:\n - echo \"DIR_CHECK is not blank\"\n when: on_failure\n\nThis approach is useful if you only want to make some debug stuff after this setup step. After all on_failure jobs, pipeline will be marked as Failed and stopped."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options git diff --cached"
},
{
"role": "assistant",
"content": "compares a (c)ommit and the (i)ndex;"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-status - Show the working tree status -b --branch"
},
{
"role": "assistant",
"content": "Show the branch and tracking info even in short-format."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc color"
},
{
"role": "assistant",
"content": "Highlight changed words using only colors. Implies --color ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I specify a gem to pull from a private github repository?\n\nI have a private repository on Github that I want to use. I deploy my app to Heroku. How can I specify a private repository as the source on my gemfile? I imagine it wouldn't be enough to simply say\ngem \"mygem\", :git=>\"my github address\""
},
{
"role": "assistant",
"content": "The best way I've found to deploy a gem pulled from a private repo is to use GitHub's OAuth access. To do so:\n\nCreate a GitHub user with access to the repo in question (best for teams – if you're okay exposing your personal access tokens, you can simply use your own account).\nCreate an GitHub OAuth token for the user. It's dead simple to do this over the GitHub API just using curl; see the OAuth API for more.\nAdd the token to the git url in your Gemfile. Example:\n\ngem 'mygem', git: 'https://xxx123abc:[email protected]/user_or_team/mygem.git'\n\nI'm currently using this method on Heroku and it works great. The beauty is that you don't have to expose your own personal information, and you can revoke or regenerate the token at any point if something is compromised."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --no-color-moved"
},
{
"role": "assistant",
"content": "Turn off move detection. This can be used to override configuration\nsettings. It is the same as --color-moved=no ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc cumulative"
},
{
"role": "assistant",
"content": "Count changes in a child directory for the parent directory as well.\nNote that when using cumulative , the sum of the percentages\nreported may exceed 100%. The default (non-cumulative) behavior can\nbe specified with the noncumulative parameter."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": ".ssh/config file for windows (git)\nI've been looking for a solution on how I can use multiple ssh keys and I figured out, that it will work with a config file in the .ssh directory, but it doesn't work on windows.\nMy problem is that I'm using a private key to access a git server, so it looks like this:\nssh://[email protected]/directory , it works fine when I'm using TortoiseGit, 'cause there is a possibility to choose the private key.\nBut I want to use the git rep in my IntelliJ IDEA and there is just the option to use the git native shell and it also works, if I put the key, called id_rsa ,into the .ssh folder. Now I want to use multiple ssh keys (so my key will get the name \"id_rsa_test\", so how do I configure the .ssh/config file under Windows, that it works with a usual git server?\nThe most examples I found yet are just for the use with github."
},
{
"role": "assistant",
"content": "If you use \"Git for Windows\"\n>cd c:\\Program Files\\Git\\etc\\ssh\\\n\nadd to ssh_config following:\nAddKeysToAgent yes\nIdentityFile ~/.ssh/id_rsa\nIdentityFile ~/.ssh/id_rsa_test\n\nps. you need ssh version >= 7.2\n(date of release 2016-02-28)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Raspberry Pi and GitLab\n\nIs there a way I can run GitLab (http://gitlab.org/gitlab-ce) and GitLab CI (http://gitlab.org/gitlab-ci) on a Raspberry Pi device running Raspbian?\nI want to have my own internal Git box where I can store code and possibly allow other friends access to upload their code too. Is it possible?\nThanks."
},
{
"role": "assistant",
"content": "Official way for the Pi 2\nThere is a very easy way to install it on the Raspberry Pi 2.\nwget https://s3-eu-west-1.amazonaws.com/downloads-packages/raspberry-pi/gitlab_7.9.0-omnibus.pi-1_armhf.deb\nsudo dpkg -i gitlab_7.9.0-omnibus.pi-1_armhf.deb\n\nYou might prefer to go to the official page in order to get latest version. It's fast and easy, they recommend at least 1Gb swap.\nOn the Pi B and B+ you will hit the memory limit very soon and get degraded performance as you grow, but on the Pi 2 it works nicely, specially if you mount your repos on an external USB hard disk."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-pull"
},
{
"role": "assistant",
"content": "Fetch from and integrate with another repository or a local branch"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Configure git to use IPv4 instead of IPv6 by default\nChecking the environment variables and also HTTP configuration options does not reveal something. Is there a way to do this?"
},
{
"role": "assistant",
"content": "The more generic solution (that also works for BSD) is to edit the global /etc/ssh/ssh_config or per-user ~/.ssh/config and add/replace the entry:\nAddressFamily any \n\nwith the following line (where inet corresponds to ipv4):\nAddressFamily inet\n\nYou can also set this for just a single host:\nHost example.com\n AddressFamily inet"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show-ref - List references in a local repository"
},
{
"role": "assistant",
"content": "DESCRIPTION Displays references available in a local repository along with the associated\ncommit IDs. Results can be filtered using a pattern and tags can be\ndereferenced into object IDs. Additionally, it can be used to test whether a\nparticular ref exists. By default, shows the tags, heads, and remote refs. The --exclude-existing form is a filter that does the inverse. It reads\nrefs from stdin, one ref per line, and shows those that don’t exist in\nthe local repository. The --exists form can be used to check for the existence of a single\nreferences. This form does not verify whether the reference resolves to an\nactual object. Use of this utility is encouraged in favor of directly accessing files under\nthe .git directory."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --grep=<pattern>"
},
{
"role": "assistant",
"content": "Limit the commits output to ones with a log message that\nmatches the specified pattern (regular expression). With\nmore than one --grep=<pattern> , commits whose message\nmatches any of the given patterns are chosen (but see --all-match ). When --notes is in effect, the message from the notes is\nmatched as if it were part of the log message."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git commit symlink as a regular file\nSuppose I have a file fname which is a symlink to a file from some other repository/project, say ../../proj2/fname.\nIs there a way to add/commit fname as a regular file?\nIt seems that, by default, git gives the file mode 120000 and sets the path to the linked file as the blob content.\nI know this because git ls-tree shows mode 120000 for the file, and git cat-file -p shows ../../proj2/fname as the blob's content."
},
{
"role": "assistant",
"content": "If you want the file to appear instead of the link, you should probably use the ln command to create a hard-link instead of a sym-link (ln -s).\nMaking a hard-link, you can make the same file to appear under two different directories, so changing it via any of the links will reflect changes via both links, and the file will live in both directories, so it will be tracked by git.\nI hope Windows' mklink /j command in Bukov's answer does this, but I really don't know at all."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout - Switch branches or restore working tree files <tree-ish>"
},
{
"role": "assistant",
"content": "Tree to checkout from (when paths are given). If not specified,\nthe index will be used. As a special case, you may use \"A...B\" as a shortcut for the\nmerge base of A and B if there is exactly one merge base. You can\nleave out at most one of A and B , in which case it defaults to HEAD ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs -t"
},
{
"role": "assistant",
"content": "Show the tree objects in the diff output."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to auto-reject a pull request if tests are failing (Github actions)\n\nI am doing npm test when pull requests are raised using Github actions.\n\nNow if tests fail,\nI would like to add a message,\nOr at least, reject the PR using actions.\n\nHow can I do this?"
},
{
"role": "assistant",
"content": "I assume you have an on: pull_request workflow that runs npm test. This should automatically create a GitHub Check on the pull request that will fail if your tests fail. The best way to \"reject\" the pull request is to prevent it from being merged unless the tests pass. You can do this by turning on a setting in your repository to \"Require status checks to pass before merging,\" and selecting your workflow as required.\nYou can find this setting under your repository's Settings > Branches.\n\nThere are further details about these settings in the documentation.\nhttps://help.github.com/en/github/administering-a-repository/enabling-required-status-checks"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to remove \"generated from\" tag?\n\nI see this message below my repo name. Is there any way to remove it? I used template for my app for a quick start, but in current form my app doesn't look like this template, because everything changed so much. I don't see any reason why it's still there."
},
{
"role": "assistant",
"content": "I had the same problem and at the time for writing this answer, there is no option of removing this from Github. So removed this tag by deleting the repository from Github and recreating a new one with the same name.\n⚠️ This operation will preserve only the information stored in git, not all other Github features, i.e. issues, PRs, ... If your repository has been used for a while, this might not be the right time to do this anymore.\nSpecific instructions:\n\nMake sure you have cloned your repository and all your non-stale branches are saved locally.\ngit fetch\n\n\nDelete the original repository in the Github web UI.\nCreate a new repository with the same name.\nPush the branches you want back to the remote.\ngit push"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order --use-bitmap-index"
},
{
"role": "assistant",
"content": "Try to speed up the traversal using the pack bitmap index (if\none is available). Note that when traversing with --objects ,\ntrees and blobs will not have their associated path printed."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-diff-files"
},
{
"role": "assistant",
"content": "Compares files in the working tree and the index"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %s"
},
{
"role": "assistant",
"content": "subject"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I deploy/push only a subdirectory of my git repo to Heroku?\nI have a project that uses Serve and is version controlled using Git. Serve creates an output folder with static files that I want to deploy to Heroku.\nI don't want to deploy the Serve project itself since the Heroku Cedar stack doesn't seem too fond of it, but most importantly I want to take advantage of Heroku's great support for static websites.\nIs there a way to deploy a subfolder to a git remote?\nShould I create a Git repo in the output folder (that sounds wrong) and push that to Heroku?"
},
{
"role": "assistant",
"content": "There's an even easier way via git-subtree. Assuming you want to push your folder 'output' as the root to Heroku, you can do:\ngit subtree push --prefix output heroku master\n\nIt appears currently that git-subtree is being included into git-core, but I don't know if that version of git-core has been released yet."
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.