messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Undo git update-index --skip-worktree\nA while ago I did this to ignore changes to a file tracked by git:\ngit update-index --skip-worktree <file>\n\nNow I actually want to commit changes to that file to source. How do I undo the effects of skip-worktree?"
},
{
"role": "assistant",
"content": "Aha! I simply want:\ngit update-index --no-skip-worktree <file>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Create a wiki page in gitlab\n\nI'm trying to create a simple wiki page on gitlab. Anyone knows of any good tutorials that could assist me in achieving that? I tried searching google for any tutorials but could not find any that are relevant."
},
{
"role": "assistant",
"content": "You can use http://pad.haroopress.com/ as an editor, to see how it will look like in a wiki gitlab page.\nIn the bottom-left corner is a button, when you hit that button, you will get the markdown help."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects --ws-error-highlight=<kind>"
},
{
"role": "assistant",
"content": "Highlight whitespace errors in the context , old or new lines of the diff. Multiple values are separated by comma, none resets previous values, default reset the list to new and all is a shorthand for old,new,context . When\nthis option is not given, and the configuration variable diff.wsErrorHighlight is not set, only whitespace errors in new lines are highlighted. The whitespace errors are colored\nwith color.diff.whitespace ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-bisect - Use binary search to find the commit that introduced a bug"
},
{
"role": "assistant",
"content": "DESCRIPTION The command takes various subcommands, and different options depending\non the subcommand: git bisect start [--term-(bad|new)=<term-new> --term-(good|old)=<term-old>]\n\t [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<pathspec>...]\ngit bisect (bad|new|<term-new>) [<rev>]\ngit bisect (good|old|<term-old>) [<rev>...]\ngit bisect terms [--term-(good|old) | --term-(bad|new)]\ngit bisect skip [(<rev>|<range>)...]\ngit bisect reset [<commit>]\ngit bisect (visualize|view)\ngit bisect replay <logfile>\ngit bisect log\ngit bisect run <cmd> [<arg>...]\ngit bisect help This command uses a binary search algorithm to find which commit in\nyour project’s history introduced a bug. You use it by first telling\nit a \"bad\" commit that is known to contain the bug, and a \"good\"\ncommit that is known to be before the bug was introduced. Then git\nbisect picks a commit between those two endpoints and asks you\nwhether the selected commit is \"good\" or \"bad\". It continues narrowing\ndown the range until it finds the exact commit that introduced the\nchange. In fact, git bisect can be used to find the commit that changed any property of your project; e.g., the commit that fixed a bug, or\nthe commit that caused a benchmark’s performance to improve. To\nsupport this more general usage, the terms \"old\" and \"new\" can be used\nin place of \"good\" and \"bad\", or you can choose your own terms. See\nsection \"Alternate terms\" below for more information. Basic bisect commands: start, bad, good As an example, suppose you are trying to find the commit that broke a\nfeature that was known to work in version v2.6.13-rc2 of your\nproject. You start a bisect session as follows: $ git bisect start\n$ git bisect bad # Current version is bad\n$ git bisect good v2.6.13-rc2 # v2.6.13-rc2 is known to be good Once you have specified at least one bad and one good commit, git\nbisect selects a commit in the middle of that range of history,\nchecks it out, and outputs something similar to the following: Bisecting: 675 revisions left to test after this (roughly 10 steps) You should now compile the checked-out version and test it. If that\nversion works correctly, type $ git bisect good If that version is broken, type $ git bisect bad Then git bisect will respond with something like Bisecting: 337 revisions left to test after this (roughly 9 steps) Keep repeating the process: compile the tree, test it, and depending\non whether it is good or bad run git bisect good or git bisect bad to ask for the next commit that needs testing. Eventually there will be no more revisions left to inspect, and the\ncommand will print out a description of the first bad commit. The\nreference refs/bisect/bad will be left pointing at that commit. Bisect reset After a bisect session, to clean up the bisection state and return to\nthe original HEAD, issue the following command: $ git bisect reset By default, this will return your tree to the commit that was checked\nout before git bisect start . (A new git bisect start will also do\nthat, as it cleans up the old bisection state.) With an optional argument, you can return to a different commit\ninstead: $ git bisect reset <commit> For example, git bisect reset bisect/bad will check out the first\nbad revision, while git bisect reset HEAD will leave you on the\ncurrent bisection commit and avoid switching commits at all. Alternate terms Sometimes you are not looking for the commit that introduced a\nbreakage, but rather for a commit that caused a change between some\nother \"old\" state and \"new\" state. For example, you might be looking\nfor the commit that introduced a particular fix. Or you might be\nlooking for the first commit in which the source-code filenames were\nfinally all converted to your company’s naming standard. Or whatever. In such cases it can be very confusing to use the terms \"good\" and\n\"bad\" to refer to \"the state before the change\" and \"the state after\nthe change\". So instead, you can use the terms \"old\" and \"new\",\nrespectively, in place of \"good\" and \"bad\". (But note that you cannot\nmix \"good\" and \"bad\" with \"old\" and \"new\" in a single session.) In this more general usage, you provide git bisect with a \"new\"\ncommit that has some property and an \"old\" commit that doesn’t have that\nproperty. Each time git bisect checks out a commit, you test if that\ncommit has the property. If it does, mark the commit as \"new\";\notherwise, mark it as \"old\". When the bisection is done, git bisect will report which commit introduced the property. To use \"old\" and \"new\" instead of \"good\" and bad, you must run git\nbisect start without commits as argument and then run the following\ncommands to add the commits: git bisect old [<rev>] to indicate that a commit was before the sought change, or git bisect new [<rev>...] to indicate that it was after. To get a reminder of the currently used terms, use git bisect terms You can get just the old term with git bisect terms --term-old or git bisect terms --term-good ; git bisect terms --term-new and git bisect terms --term-bad can be used to learn how to call\nthe commits more recent than the sought change. If you would like to use your own terms instead of \"bad\"/\"good\" or\n\"new\"/\"old\", you can choose any names you like (except existing bisect\nsubcommands like reset , start , …) by starting the\nbisection using git bisect start --term-old <term-old> --term-new <term-new> For example, if you are looking for a commit that introduced a\nperformance regression, you might use git bisect start --term-old fast --term-new slow Or if you are looking for the commit that fixed a bug, you might use git bisect start --term-new fixed --term-old broken Then, use git bisect <term-old> and git bisect <term-new> instead\nof git bisect good and git bisect bad to mark commits. Bisect visualize/view To see the currently remaining suspects in gitk , issue the following\ncommand during the bisection process (the subcommand view can be used\nas an alternative to visualize ): $ git bisect visualize Git detects a graphical environment through various environment variables: DISPLAY , which is set in X Window System environments on Unix systems. SESSIONNAME , which is set under Cygwin in interactive desktop sessions. MSYSTEM , which is set under Msys2 and Git for Windows. SECURITYSESSIONID , which may be set on macOS in interactive desktop sessions. If none of these environment variables is set, git log is used instead.\nYou can also give command-line options such as -p and --stat . $ git bisect visualize --stat Bisect log and bisect replay After having marked revisions as good or bad, issue the following\ncommand to show what has been done so far: $ git bisect log If you discover that you made a mistake in specifying the status of a\nrevision, you can save the output of this command to a file, edit it to\nremove the incorrect entries, and then issue the following commands to\nreturn to a corrected state: $ git bisect reset\n$ git bisect replay that-file Avoiding testing a commit If, in the middle of a bisect session, you know that the suggested\nrevision is not a good one to test (e.g. it fails to build and you\nknow that the failure does not have anything to do with the bug you\nare chasing), you can manually select a nearby commit and test that\none instead. For example: $ git bisect good/bad\t\t\t# previous round was good or bad.\nBisecting: 337 revisions left to test after this (roughly 9 steps)\n$ git bisect visualize\t\t\t# oops, that is uninteresting.\n$ git reset --hard HEAD~3\t\t# try 3 revisions before what\n\t\t\t\t\t# was suggested Then compile and test the chosen revision, and afterwards mark\nthe revision as good or bad in the usual manner. Bisect skip Instead of choosing a nearby commit by yourself, you can ask Git to do\nit for you by issuing the command: $ git bisect skip # Current version cannot be tested However, if you skip a commit adjacent to the one you are looking for,\nGit will be unable to tell exactly which of those commits was the\nfirst bad one. You can also skip a range of commits, instead of just one commit,\nusing range notation. For example: $ git bisect skip v2.5..v2.6 This tells the bisect process that no commit after v2.5 , up to and\nincluding v2.6 , should be tested. Note that if you also want to skip the first commit of the range you\nwould issue the command: $ git bisect skip v2.5 v2.5..v2.6 This tells the bisect process that the commits between v2.5 and v2.6 (inclusive) should be skipped. Cutting down bisection by giving more parameters to bisect start You can further cut down the number of trials, if you know what part of\nthe tree is involved in the problem you are tracking down, by specifying\npathspec parameters when issuing the bisect start command: $ git bisect start -- arch/i386 include/asm-i386 If you know beforehand more than one good commit, you can narrow the\nbisect space down by specifying all of the good commits immediately after\nthe bad commit when issuing the bisect start command: $ git bisect start v2.6.20-rc6 v2.6.20-rc4 v2.6.20-rc1 --\n # v2.6.20-rc6 is bad\n # v2.6.20-rc4 and v2.6.20-rc1 are good Bisect run If you have a script that can tell if the current source code is good\nor bad, you can bisect by issuing the command: $ git bisect run my_script arguments Note that the script ( my_script in the above example) should exit\nwith code 0 if the current source code is good/old, and exit with a\ncode between 1 and 127 (inclusive), except 125, if the current source\ncode is bad/new. Any other exit code will abort the bisect process. It should be noted\nthat a program that terminates via exit(-1) leaves $? = 255, (see the\nexit(3) manual page), as the value is chopped with & 0377 . The special exit code 125 should be used when the current source code\ncannot be tested. If the script exits with this code, the current\nrevision will be skipped (see git bisect skip above). 125 was chosen\nas the highest sensible value to use for this purpose, because 126 and 127\nare used by POSIX shells to signal specific error status (127 is for\ncommand not found, 126 is for command found but not executable—these\ndetails do not matter, as they are normal errors in the script, as far as bisect run is concerned). You may often find that during a bisect session you want to have\ntemporary modifications (e.g. s/#define DEBUG 0/#define DEBUG 1/ in a\nheader file, or \"revision that does not have this commit needs this\npatch applied to work around another problem this bisection is not\ninterested in\") applied to the revision being tested. To cope with such a situation, after the inner git bisect finds the\nnext revision to test, the script can apply the patch\nbefore compiling, run the real test, and afterwards decide if the\nrevision (possibly with the needed patch) passed the test and then\nrewind the tree to the pristine state. Finally the script should exit\nwith the status of the real test to let the git bisect run command loop\ndetermine the eventual outcome of the bisect session."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to display images in Markdown files on Github?\n\nI want to display some images in a Markdown file on Github. I found it works this way:\n![Figure 1-1](https://raw.github.com/username/repo/master/images/figure 1-1.png \"Figure 1-1\")\n\nBut i need to collaborate with others so i don't want the username and repo name hard coded .\nI tried to use this:\n![Figure 1-1](images/figure 1-1.png \"Figure 1-1\")\n\nIt works on my local disk but not work on Github.\nIs there anyone knows about this issue?"
},
{
"role": "assistant",
"content": "I found the answer myself.\nJust simply append ?raw=true to the image url will make the trick:\n![](images/table 1-1.png?raw=true)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-push - Update remote refs along with associated objects push.useBitmaps"
},
{
"role": "assistant",
"content": "If set to \"false\", disable use of bitmaps for \"git push\" even if pack.useBitmaps is \"true\", without preventing other git operations\nfrom using bitmaps. Default is true."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %D"
},
{
"role": "assistant",
"content": "ref names without the \" (\", \")\" wrapping."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do you reset the stored credentials in 'git credential-osxkeychain'?\nI've followed the GitHub instructions for setting up my account, and I'm able to clone, but I'm unable to push remotely.\nWhen I do a \"git push\" I get the 403 error. It has the correct URL. I tried a \"git credential-osxkeychain get\" to see what it was giving, and this prints out the wrong credentials.\nI believe what happened is the first time it asked for the credentials, I thought it was another application asking, and it put the wrong ones in.\nI just need to reset it so that it uses the correct keychain item for my GitHub account.\nI've tried:\ngit credential-osxkeychain erase\ngit credential-osxkeychain set\n\nThe program never gives any prompts. Set will say \"bad input\" if I don't do the right thing. I tried putting in \"password=password\", etc., but then when I do a \"get\" I still get the old ones.\nI can't figure out where these are being stored, as they are not in .gitconfigure. Further there are no recent keychain items that could be it. (I have several GitHub accounts in my keychain and it is not using any of them.)"
},
{
"role": "assistant",
"content": "From Terminal:\n(You need to enter the following three lines)\n $ git credential-osxkeychain erase ⏎\n host=github.com ⏎\n protocol=https ⏎\n ⏎\n ⏎\n\nNOTE: after you enter “protocol=https” above you need to press ~~RETURN~~ TWICE (Each '⏎' is equivalent to a 'press enter/return' )"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is there a way to add issues to a github forked repo (without modifying the original)?\n\nI notice there's no \"issues\" tab on my forked github repo. Is there a way to allow me to fork a repo, but still add issues/wiki/etc?"
},
{
"role": "assistant",
"content": "Fork a repo\nGo to the Settings page of your fork.\nClick 'General' tab on the left\nScroll down to the Features subsection\nTick the Issues checkbox"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show-ref - List references in a local repository --heads --tags"
},
{
"role": "assistant",
"content": "Limit to \"refs/heads\" and \"refs/tags\", respectively. These options\nare not mutually exclusive; when given both, references stored in\n\"refs/heads\" and \"refs/tags\" are displayed."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-update-index - Register file contents in the working tree to the index -q"
},
{
"role": "assistant",
"content": "Quiet. If --refresh finds that the index needs an update, the\n default behavior is to error out. This option makes git update-index continue anyway."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to change RGB colors in Git Bash for windows?\nI'm using Git Bash in Windows and for the purposes of my custom git log format, I'd like to modify the terminal's exact RGB color values so I can fine-tune the color outputs. My git log format is as follows in my global .gitconfig:\nlg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset)%x09%C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset) %C(dim white)%an%C(reset) - %C(white)%s%C(reset)' --branches --remotes --tags\n\nI'd like to define in Git Bash what RGB value actually maps to 'blue', for example. Any idea how I can do this? Step by step instructions would be wonderful.\nI setup my .bashrc and it isn't working for some reason. Colors aren't changing :-(. Here is a script I ran to see colors: http://pastebin.com/9EsYmGCj and the result: https://i.sstatic.net/WP9am.png"
},
{
"role": "assistant",
"content": "This works for me to change the text colors used by Git Bash on Windows 7:\n\nClick on the upper left corner of an open Git Bash window (the Git icon in the window frame).\nA menu appears (the same that would appear with a regular DOS cmd Window). Choose the last entry: \"Properties\", UPDATE 2021: \"Options...\" (thanks AlexD!)\nGo to tab \"Colors\"\nChoose radio button \"Screen Text\"\nRemember which color is currently assigned to \"Screen Text\" in the row of small color boxes (it has a black frame).\nThen select the color you want to change by clicking on the corresponding color box. This color is now assigned as \"Screen Text\", which is what Git Bash uses for regular text. But don't worry, this change is only temporary and needed to modify the value of a color.\nNow change the Red/Green/Blue values for the selected color. In my case I wanted to make the fifth color from the left (much) brighter. Let's call it \"Color 5\". This is the color Git Bash uses to show changed files with \"git status\". Whenever Git Bash wants to use \"Color 5\" it will use the new RGB value.\n\"Screen Text\" is now still set to \"Color 5\". So click on the original color that you have remembered.\n\nThe changes made in this way are permanent but only valid for the shortcut you have used to start Git Bash. If you create a new shortcut you are back to the original colors."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order --in-commit-order"
},
{
"role": "assistant",
"content": "Print tree and blob ids in order of the commits. The tree\nand blob ids are printed after they are first referenced\nby a commit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index --merge-base"
},
{
"role": "assistant",
"content": "Instead of comparing <tree-ish> directly, use the merge base\nbetween <tree-ish> and HEAD instead. <tree-ish> must be a\ncommit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to delete a only a specific commit in the middle of the git log\nI want only to delete a specific commit in the middle of a git log. It shouldn't be affected to above commits."
},
{
"role": "assistant",
"content": "It shouldn't be affected to above commits.\n\nIf you remove a commit from the middle of a branch, or really anywhere except possibly the HEAD of a branch, you will rewrite the history of that branch. This is because the tools you would use to effect this, namely git rebase --interactive and git filter-branch, would need to recommit everything which comes after the commit you removed. This is usually not desirable for a public shared branch because it forces everyone to take pretty draconian measures to keep up with that change.\nRather, a safer bet for you would be to use git revert:\ngit revert <SHA-1 of commit to delete>\n\nThis will add a new commit on the top of your branch which effectively undoes everything which the middle commit did.\nBy the way, if you really want to remove that commit, I would recommend doing an interactive rebase."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --color-words[=<regex>]"
},
{
"role": "assistant",
"content": "Equivalent to --word-diff=color plus (if a regex was\nspecified) --word-diff-regex=<regex> ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --word-diff-regex=<regex>"
},
{
"role": "assistant",
"content": "Use <regex> to decide what a word is, instead of considering\nruns of non-whitespace to be a word. Also implies --word-diff unless it was already enabled. Every non-overlapping match of the\n<regex> is considered a word. Anything between these matches is\nconsidered whitespace and ignored(!) for the purposes of finding\ndifferences. You may want to append |[^[:space:]] to your regular\nexpression to make sure that it matches all non-whitespace characters.\nA match that contains a newline is silently truncated(!) at the\nnewline. For example, --word-diff-regex=. will treat each character as a word\nand, correspondingly, show differences character by character. The regex can also be set via a diff driver or configuration option, see gitattributes or git-config . Giving it explicitly\noverrides any diff driver or configuration setting. Diff drivers\noverride configuration settings."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc minimal"
},
{
"role": "assistant",
"content": "Spend extra time to make sure the smallest possible diff is\nproduced."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs log.diffMerges"
},
{
"role": "assistant",
"content": "Set diff format to be used when --diff-merges=on is\nspecified, see --diff-merges in git-log for\ndetails. Defaults to separate ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git best practice for config files etc\n\nI'm still new to all things git and was wondering what is best practice in regards to config files. My local development server needs different config values to my live one so how can I stop it pushing / pulling those files?"
},
{
"role": "assistant",
"content": "Use symbolic links. \nTake an example where you have a config file named \"config.ini\". In the working directory of your git repo, you would do the following:\n\nCreate a version of the config file called \"config-sample.ini\". This is the file you'll do all your work on.\nCreate a symbolic link between \"config.ini\" and \"config-sample.ini\".\nln -s config-sample.ini config.ini\n\nThis let's all your code point to \"config.ini\" even though you're really maintaining \"config-sample.ini\".\nUpdate your .gitignore to prevent the \"config.ini\" from being stored. That is, add a \"config.ini\" line:\necho \"config.ini\" >> .gitignore\n\n(Optional, but highly recommended) Create a .gitattributes file with the line \"config.ini export-ignore\".\necho \"config.ini export-ignore\" >> .gitattributes\n\nDo some coding and deploy....\nAfter deploying your code to production, copy the \"config-sample.ini\" file over to \"config.ini\". You'll need to make any adjustments necessary to setup for production. You'll only need to do this the first time you deploy and any time you change the structure of your config file.\n\nA few benefits of this:\n\nThe structure of your config file is maintained in the repo.\nReasonable defaults can be maintained for any config options that are the same between dev and production. \nYour \"config-sample.ini\" will update whenever you push a new version to production. This makes it a lot easier to spot any changes you need to make in your \"config.ini\" file. \nYou will never overwrite the production version of \"config.ini\". (The optional step 4 with the .gitattributes file adds an extra guarantee that you'll never export your \"config.ini\" file even if you accidentally add it to the repo.)\n\n(This works great for me on Mac and Linux. I'm guessing there is a corresponding solution possible on Windows, but someone else will have to comment on that.)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git fatal: cannot lock ref\nI'm trying to create a branch on the current branch on my Ubuntu guest. \nUnfortunately I keep getting this error: \ngit checkout -b origin/feature/IF-53-change-validation-window/Tommaso\nfatal: cannot lock ref 'refs/heads/origin/feature/IF-53-change-validation-window/Tommaso': \n'refs/heads/origin/branch' exists; \ncannot create 'refs/heads/origin/branch/Tommaso'\n\nI tried git gc --prune=now as suggested here link, but keep getting the same error."
},
{
"role": "assistant",
"content": "It looks like the problem here was a branch X existed locally, and you tried to create a new branch X/Y. This won't work, because git creates a file at .git/refs/heads/X, so it can't create the folder X to contain the file Y.\nHowever, it's worth adding that including \"origin\" in your branch name points to some confusion - origin is usually the name of the remote repository. If you run git branch I expect you will see local branches with origin in the name.\nThe format git checkout X is shorthand for:\n\nlook for a local branch X and check that out if it exists\notherwise look for a remote branch X and check that out locally (git checkout -b X origin/X)\n\nTo fix your current state, you can likely do this (see here):\ngit update-ref -d refs/heads/origin/branch"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-blame - Show what revision and author last modified each line of a file -t"
},
{
"role": "assistant",
"content": "Show raw timestamp (Default: off)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-stash - Stash the changes in a dirty working directory away -k --keep-index --no-keep-index"
},
{
"role": "assistant",
"content": "This option is only valid for push and save commands. All changes already added to the index are left intact."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Configure runner to run multiple jobs at the same time\n\nWhen having one gitlab runner serving multiple projects, it can only run one CI pipeline while the other project pipelines have to queue.\nIs it possible to make a gitlab runner run pipelines from all projects in parallel?\nI don't seem to find anywhere a configuration explanation for this."
},
{
"role": "assistant",
"content": "I believe the configuration options you are looking for is concurrent and limit, which you'd change in the GitLab Runners config.toml file.\nFrom the documentation:\n\nconcurrent: limits how many jobs globally can be run concurrently. The most upper limit of jobs using all defined runners. 0 does not mean unlimited\n\nlimit: limit how many jobs can be handled concurrently by this token.\n\n\nThe location for the config.toml file:\n\n\n/etc/gitlab-runner/config.toml on *nix systems when GitLab Runner is\nexecuted as root (this is also path for service configuration)\n~/.gitlab-runner/config.toml on *nix systems when GitLab Runner is\nexecuted as non-root\n./config.toml on other systems\n\n\nUseful issue as well."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git command to move a folder inside another\nI have created a folder common with a bunch of source files and folders.\nNow I want to move the common folder into the include folder so it looks like include/common\nI tried these:\n\ngit add include\n\ngit mv common/ include/\nbut it fails with this error\n\nfatal: bad source, source=myrepo/common, destination=myrepo/include\n\n\nI tried git mv common/ include/common but I get the same error\n\n\nAny idea how to achieve this?"
},
{
"role": "assistant",
"content": "One of the nicest things about git is that you don't need to track file renames explicitly. Git will figure it out by comparing the contents of the files.\nSo, in your case, don't work so hard: Ref: Git mv docs\n$ mkdir include\n$ git mv common include\n$ git rm -r common\n$ git add include/common\n\nRunning git status should show you something like this:\n$ git status\n# On branch master\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# renamed: common/file.txt -> include/common/file.txt\n#"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git log -p vs. git show vs. git diff\nHow are the commands git log -p, git show, and git diff related and why would one be used over another? \nGiven a repo with the following 4 commits:\n\ncommitd - last commit\n commitc\n commitb\n coomita - initial commit\n\nWhat are the differences between the following git commands?:\ngit log -p commitb commitd \ngit show commitb commitd \ngit diff commitb commitd \n\ngit log -p commitd commitb \ngit show commitd commitb \ngit diff commitd commitb \n\ngit log -p commitb..commitd \ngit show commitb..commitd \ngit diff commitb..commitd\n\ngit log -p commitd..commitb \ngit show commitd..commitb \ngit diff commitd..commitb\n\ngit log -p commitb...commitd \ngit show commitb...commitd \ngit diff commitb...commitd\n\ngit log -p commitd...commitb \ngit show commitd...commitb \ngit diff commitd...commitb"
},
{
"role": "assistant",
"content": "git log A B shows the history of both commits A and B (basically generating a union set of each commits' history). Usually you want git log A..B, which can also be written as git log ^B A (show everything reachable from A, but not (^) from B). This range can also be empty (for instance B..A would be empty, since every commit reachable from B is also reachable from A). Therefore, you also get no output from git log when used with the \"wrong\" arguments.\ngit show is a very versatile command and produces different output depending on its arguments. You can pass one or several commits and it will show you the commit information (authorship, timestamp, commit message, diff from previous commit). Commit ranges such as a..d will be resolved and each commit is shown individually. You can also pass a path and git show will show you the file's contents. You can also specify a file at a certain revision with the syntax commit:path/to/file. If you pass a directory, git show will display the commit information of the last commit changing that directory.\ngit diff generally expects two trees or two files to compare. (It can also take no arguments and compare the index/staging area instead). A commit is automatically unwrapped into its corresponding tree (a tree object describes a certain state of the repository). The syntax A..B is silently resolved to A B for the diff case and will show the changes required to get from commit/tree A to B\nThe range A...B means \"every commit reachable from A or B, but not from both\".\n\nWhen used with git log it will show you those commits and it mostly only makes sense when used with diverged branches, i.e. \"show every that's different between the two, but hide those commits which both branches have in common\".\nFor git diff this syntax is syntactic sugar for git diff $(git merge-base A B) B, i.e. \"changes in B since the history of A diverged.\nWith git show you will simply get commit information for each single commit in that range.\n\nIf anything's still unclear let me know in the comments.\n\nHere's the output the repository you posted in your original question:\n$ git init\n Initialized empty Git repository in ...\n$ cd SO\n$ ls\n$ echo a > a\n$ git add a\n$ git commit\n[master (root-commit) 7b66fe5] initial commit\n 1 file changed, 1 insertion(+)\n create mode 100644 a\n$ git tag a\n$ echo b >> a\n$ echo b > b\n$ git add a b\n$ git commit\n[master ee884fe] commit b\n 2 files changed, 2 insertions(+)\n create mode 100644 b\n$ git tag b\n$ echo c >> a\n$ echo c >> b\n$ echo c > c\n$ git add a b c\n$ git commit\n[master 8abaaff] commit c\n 3 files changed, 3 insertions(+)\n create mode 100644 c\n$ git tag c\n$ echo d >> a\n$ echo d > b\n$ git add a b\n$ git commit\n[master 08adc85] commit d\n 2 files changed, 2 insertions(+), 2 deletions(-)\n$ git tag d\n$ git log -p b d --\ncommit 08adc8512e63588e6f01533b2a0f762342521b05\nAuthor: ...\nDate: Mon Sep 1 17:22:06 2014 +0200\n\n commit d\n\ndiff --git a/a b/a\nindex de98044..d68dd40 100644\n--- a/a\n+++ b/a\n@@ -1,3 +1,4 @@\n a\n b\n c\n+d\ndiff --git a/b b/b\nindex 9ddeb5c..4bcfe98 100644\n--- a/b\n+++ b/b\n@@ -1,2 +1 @@\n-b\n-c\n+d\n\ncommit 8abaaff681be0bcaa16c946feb2989959348c9f4\nAuthor: ...\nDate: Mon Sep 1 17:21:40 2014 +0200\n\n commit c\n\ndiff --git a/a b/a\nindex 422c2b7..de98044 100644\n--- a/a\n+++ b/a\n@@ -1,2 +1,3 @@\n a\n b\n+c\ndiff --git a/b b/b\nindex 6178079..9ddeb5c 100644\n--- a/b\n+++ b/b\n@@ -1 +1,2 @@\n b\n+c\ndiff --git a/c b/c\nnew file mode 100644\nindex 0000000..f2ad6c7\n--- /dev/null\n+++ b/c\n@@ -0,0 +1 @@\n+c\n\ncommit ee884fea5d0266280845348175ac0af5083a9bbf\nAuthor: ...\nDate: Mon Sep 1 17:21:05 2014 +0200\n\n commit b\n\ndiff --git a/a b/a\nindex 7898192..422c2b7 100644\n--- a/a\n+++ b/a\n@@ -1 +1,2 @@\n a\n+b\ndiff --git a/b b/b\nnew file mode 100644\nindex 0000000..6178079\n--- /dev/null\n+++ b/b\n@@ -0,0 +1 @@\n+b\n\ncommit 7b66fe5999039c53ffbe5a5ffe07c13a5c213455\nAuthor: ...\nDate: Mon Sep 1 17:20:39 2014 +0200\n\n initial commit\n\ndiff --git a/a b/a\nnew file mode 100644\nindex 0000000..7898192\n--- /dev/null\n+++ b/a\n@@ -0,0 +1 @@\n+a\n$ git show b d --\ncommit ee884fea5d0266280845348175ac0af5083a9bbf\nAuthor: ...\nDate: Mon Sep 1 17:21:05 2014 +0200\n\n commit b\n\ndiff --git a/a b/a\nindex 7898192..422c2b7 100644\n--- a/a\n+++ b/a\n@@ -1 +1,2 @@\n a\n+b\ndiff --git a/b b/b\nnew file mode 100644\nindex 0000000..6178079\n--- /dev/null\n+++ b/b\n@@ -0,0 +1 @@\n+b\n\ncommit 08adc8512e63588e6f01533b2a0f762342521b05\nAuthor: ...\nDate: Mon Sep 1 17:22:06 2014 +0200\n\n commit d\n\ndiff --git a/a b/a\nindex de98044..d68dd40 100644\n--- a/a\n+++ b/a\n@@ -1,3 +1,4 @@\n a\n b\n c\n+d\ndiff --git a/b b/b\nindex 9ddeb5c..4bcfe98 100644\n--- a/b\n+++ b/b\n@@ -1,2 +1 @@\n-b\n-c\n+d\n$ git diff b d --\ndiff --git a/a b/a\nindex 422c2b7..d68dd40 100644\n--- a/a\n+++ b/a\n@@ -1,2 +1,4 @@\n a\n b\n+c\n+d\ndiff --git a/b b/b\nindex 6178079..4bcfe98 100644\n--- a/b\n+++ b/b\n@@ -1 +1 @@\n-b\n+d\ndiff --git a/c b/c\nnew file mode 100644\nindex 0000000..f2ad6c7\n--- /dev/null\n+++ b/c\n@@ -0,0 +1 @@\n+c\n$ git log -p d b --\ncommit 08adc8512e63588e6f01533b2a0f762342521b05\nAuthor: ...\nDate: Mon Sep 1 17:22:06 2014 +0200\n\n commit d\n\ndiff --git a/a b/a\nindex de98044..d68dd40 100644\n--- a/a\n+++ b/a\n@@ -1,3 +1,4 @@\n a\n b\n c\n+d\ndiff --git a/b b/b\nindex 9ddeb5c..4bcfe98 100644\n--- a/b\n+++ b/b\n@@ -1,2 +1 @@\n-b\n-c\n+d\n\ncommit 8abaaff681be0bcaa16c946feb2989959348c9f4\nAuthor: ...\nDate: Mon Sep 1 17:21:40 2014 +0200\n\n commit c\n\ndiff --git a/a b/a\nindex 422c2b7..de98044 100644\n--- a/a\n+++ b/a\n@@ -1,2 +1,3 @@\n a\n b\n+c\ndiff --git a/b b/b\nindex 6178079..9ddeb5c 100644\n--- a/b\n+++ b/b\n@@ -1 +1,2 @@\n b\n+c\ndiff --git a/c b/c\nnew file mode 100644\nindex 0000000..f2ad6c7\n--- /dev/null\n+++ b/c\n@@ -0,0 +1 @@\n+c\n\ncommit ee884fea5d0266280845348175ac0af5083a9bbf\nAuthor: ...\nDate: Mon Sep 1 17:21:05 2014 +0200\n\n commit b\n\ndiff --git a/a b/a\nindex 7898192..422c2b7 100644\n--- a/a\n+++ b/a\n@@ -1 +1,2 @@\n a\n+b\ndiff --git a/b b/b\nnew file mode 100644\nindex 0000000..6178079\n--- /dev/null\n+++ b/b\n@@ -0,0 +1 @@\n+b\n\ncommit 7b66fe5999039c53ffbe5a5ffe07c13a5c213455\nAuthor: ...\nDate: Mon Sep 1 17:20:39 2014 +0200\n\n initial commit\n\ndiff --git a/a b/a\nnew file mode 100644\nindex 0000000..7898192\n--- /dev/null\n+++ b/a\n@@ -0,0 +1 @@\n+a\n$ git show d b --\ncommit 08adc8512e63588e6f01533b2a0f762342521b05\nAuthor: ...\nDate: Mon Sep 1 17:22:06 2014 +0200\n\n commit d\n\ndiff --git a/a b/a\nindex de98044..d68dd40 100644\n--- a/a\n+++ b/a\n@@ -1,3 +1,4 @@\n a\n b\n c\n+d\ndiff --git a/b b/b\nindex 9ddeb5c..4bcfe98 100644\n--- a/b\n+++ b/b\n@@ -1,2 +1 @@\n-b\n-c\n+d\n\ncommit ee884fea5d0266280845348175ac0af5083a9bbf\nAuthor: ...\nDate: Mon Sep 1 17:21:05 2014 +0200\n\n commit b\n\ndiff --git a/a b/a\nindex 7898192..422c2b7 100644\n--- a/a\n+++ b/a\n@@ -1 +1,2 @@\n a\n+b\ndiff --git a/b b/b\nnew file mode 100644\nindex 0000000..6178079\n--- /dev/null\n+++ b/b\n@@ -0,0 +1 @@\n+b\n$ git diff d b --\ndiff --git a/a b/a\nindex d68dd40..422c2b7 100644\n--- a/a\n+++ b/a\n@@ -1,4 +1,2 @@\n a\n b\n-c\n-d\ndiff --git a/b b/b\nindex 4bcfe98..6178079 100644\n--- a/b\n+++ b/b\n@@ -1 +1 @@\n-d\n+b\ndiff --git a/c b/c\ndeleted file mode 100644\nindex f2ad6c7..0000000\n--- a/c\n+++ /dev/null\n@@ -1 +0,0 @@\n-c\n$ git log -p b..d --\ncommit 08adc8512e63588e6f01533b2a0f762342521b05\nAuthor: ...\nDate: Mon Sep 1 17:22:06 2014 +0200\n\n commit d\n\ndiff --git a/a b/a\nindex de98044..d68dd40 100644\n--- a/a\n+++ b/a\n@@ -1,3 +1,4 @@\n a\n b\n c\n+d\ndiff --git a/b b/b\nindex 9ddeb5c..4bcfe98 100644\n--- a/b\n+++ b/b\n@@ -1,2 +1 @@\n-b\n-c\n+d\n\ncommit 8abaaff681be0bcaa16c946feb2989959348c9f4\nAuthor: ...\nDate: Mon Sep 1 17:21:40 2014 +0200\n\n commit c\n\ndiff --git a/a b/a\nindex 422c2b7..de98044 100644\n--- a/a\n+++ b/a\n@@ -1,2 +1,3 @@\n a\n b\n+c\ndiff --git a/b b/b\nindex 6178079..9ddeb5c 100644\n--- a/b\n+++ b/b\n@@ -1 +1,2 @@\n b\n+c\ndiff --git a/c b/c\nnew file mode 100644\nindex 0000000..f2ad6c7\n--- /dev/null\n+++ b/c\n@@ -0,0 +1 @@\n+c\n$ git show b..d --\ncommit 08adc8512e63588e6f01533b2a0f762342521b05\nAuthor: ...\nDate: Mon Sep 1 17:22:06 2014 +0200\n\n commit d\n\ndiff --git a/a b/a\nindex de98044..d68dd40 100644\n--- a/a\n+++ b/a\n@@ -1,3 +1,4 @@\n a\n b\n c\n+d\ndiff --git a/b b/b\nindex 9ddeb5c..4bcfe98 100644\n--- a/b\n+++ b/b\n@@ -1,2 +1 @@\n-b\n-c\n+d\n\ncommit 8abaaff681be0bcaa16c946feb2989959348c9f4\nAuthor: ...\nDate: Mon Sep 1 17:21:40 2014 +0200\n\n commit c\n\ndiff --git a/a b/a\nindex 422c2b7..de98044 100644\n--- a/a\n+++ b/a\n@@ -1,2 +1,3 @@\n a\n b\n+c\ndiff --git a/b b/b\nindex 6178079..9ddeb5c 100644\n--- a/b\n+++ b/b\n@@ -1 +1,2 @@\n b\n+c\ndiff --git a/c b/c\nnew file mode 100644\nindex 0000000..f2ad6c7\n--- /dev/null\n+++ b/c\n@@ -0,0 +1 @@\n+c\n$ git diff b..d --\ndiff --git a/a b/a\nindex 422c2b7..d68dd40 100644\n--- a/a\n+++ b/a\n@@ -1,2 +1,4 @@\n a\n b\n+c\n+d\ndiff --git a/b b/b\nindex 6178079..4bcfe98 100644\n--- a/b\n+++ b/b\n@@ -1 +1 @@\n-b\n+d\ndiff --git a/c b/c\nnew file mode 100644\nindex 0000000..f2ad6c7\n--- /dev/null\n+++ b/c\n@@ -0,0 +1 @@\n+c\n$ git log -p d..b --\n$ git show d..b --\n$ git diff d..b --\ndiff --git a/a b/a\nindex d68dd40..422c2b7 100644\n--- a/a\n+++ b/a\n@@ -1,4 +1,2 @@\n a\n b\n-c\n-d\ndiff --git a/b b/b\nindex 4bcfe98..6178079 100644\n--- a/b\n+++ b/b\n@@ -1 +1 @@\n-d\n+b\ndiff --git a/c b/c\ndeleted file mode 100644\nindex f2ad6c7..0000000\n--- a/c\n+++ /dev/null\n@@ -1 +0,0 @@\n-c\n$ git log -p b...d --\ncommit 08adc8512e63588e6f01533b2a0f762342521b05\nAuthor: ...\nDate: Mon Sep 1 17:22:06 2014 +0200\n\n commit d\n\ndiff --git a/a b/a\nindex de98044..d68dd40 100644\n--- a/a\n+++ b/a\n@@ -1,3 +1,4 @@\n a\n b\n c\n+d\ndiff --git a/b b/b\nindex 9ddeb5c..4bcfe98 100644\n--- a/b\n+++ b/b\n@@ -1,2 +1 @@\n-b\n-c\n+d\n\ncommit 8abaaff681be0bcaa16c946feb2989959348c9f4\nAuthor: ...\nDate: Mon Sep 1 17:21:40 2014 +0200\n\n commit c\n\ndiff --git a/a b/a\nindex 422c2b7..de98044 100644\n--- a/a\n+++ b/a\n@@ -1,2 +1,3 @@\n a\n b\n+c\ndiff --git a/b b/b\nindex 6178079..9ddeb5c 100644\n--- a/b\n+++ b/b\n@@ -1 +1,2 @@\n b\n+c\ndiff --git a/c b/c\nnew file mode 100644\nindex 0000000..f2ad6c7\n--- /dev/null\n+++ b/c\n@@ -0,0 +1 @@\n+c\n$ git show b...d --\ncommit 08adc8512e63588e6f01533b2a0f762342521b05\nAuthor: ...\nDate: Mon Sep 1 17:22:06 2014 +0200\n\n commit d\n\ndiff --git a/a b/a\nindex de98044..d68dd40 100644\n--- a/a\n+++ b/a\n@@ -1,3 +1,4 @@\n a\n b\n c\n+d\ndiff --git a/b b/b\nindex 9ddeb5c..4bcfe98 100644\n--- a/b\n+++ b/b\n@@ -1,2 +1 @@\n-b\n-c\n+d\n\ncommit 8abaaff681be0bcaa16c946feb2989959348c9f4\nAuthor: ...\nDate: Mon Sep 1 17:21:40 2014 +0200\n\n commit c\n\ndiff --git a/a b/a\nindex 422c2b7..de98044 100644\n--- a/a\n+++ b/a\n@@ -1,2 +1,3 @@\n a\n b\n+c\ndiff --git a/b b/b\nindex 6178079..9ddeb5c 100644\n--- a/b\n+++ b/b\n@@ -1 +1,2 @@\n b\n+c\ndiff --git a/c b/c\nnew file mode 100644\nindex 0000000..f2ad6c7\n--- /dev/null\n+++ b/c\n@@ -0,0 +1 @@\n+c\n$ git diff b...d --\ndiff --git a/a b/a\nindex 422c2b7..d68dd40 100644\n--- a/a\n+++ b/a\n@@ -1,2 +1,4 @@\n a\n b\n+c\n+d\ndiff --git a/b b/b\nindex 6178079..4bcfe98 100644\n--- a/b\n+++ b/b\n@@ -1 +1 @@\n-b\n+d\ndiff --git a/c b/c\nnew file mode 100644\nindex 0000000..f2ad6c7\n--- /dev/null\n+++ b/c\n@@ -0,0 +1 @@\n+c\n$ git log -p d...b --\ncommit 08adc8512e63588e6f01533b2a0f762342521b05\nAuthor: ...\nDate: Mon Sep 1 17:22:06 2014 +0200\n\n commit d\n\ndiff --git a/a b/a\nindex de98044..d68dd40 100644\n--- a/a\n+++ b/a\n@@ -1,3 +1,4 @@\n a\n b\n c\n+d\ndiff --git a/b b/b\nindex 9ddeb5c..4bcfe98 100644\n--- a/b\n+++ b/b\n@@ -1,2 +1 @@\n-b\n-c\n+d\n\ncommit 8abaaff681be0bcaa16c946feb2989959348c9f4\nAuthor: ...\nDate: Mon Sep 1 17:21:40 2014 +0200\n\n commit c\n\ndiff --git a/a b/a\nindex 422c2b7..de98044 100644\n--- a/a\n+++ b/a\n@@ -1,2 +1,3 @@\n a\n b\n+c\ndiff --git a/b b/b\nindex 6178079..9ddeb5c 100644\n--- a/b\n+++ b/b\n@@ -1 +1,2 @@\n b\n+c\ndiff --git a/c b/c\nnew file mode 100644\nindex 0000000..f2ad6c7\n--- /dev/null\n+++ b/c\n@@ -0,0 +1 @@\n+c\n$ git show d...b --\ncommit 08adc8512e63588e6f01533b2a0f762342521b05\nAuthor: ...\nDate: Mon Sep 1 17:22:06 2014 +0200\n\n commit d\n\ndiff --git a/a b/a\nindex de98044..d68dd40 100644\n--- a/a\n+++ b/a\n@@ -1,3 +1,4 @@\n a\n b\n c\n+d\ndiff --git a/b b/b\nindex 9ddeb5c..4bcfe98 100644\n--- a/b\n+++ b/b\n@@ -1,2 +1 @@\n-b\n-c\n+d\n\ncommit 8abaaff681be0bcaa16c946feb2989959348c9f4\nAuthor: ...\nDate: Mon Sep 1 17:21:40 2014 +0200\n\n commit c\n\ndiff --git a/a b/a\nindex 422c2b7..de98044 100644\n--- a/a\n+++ b/a\n@@ -1,2 +1,3 @@\n a\n b\n+c\ndiff --git a/b b/b\nindex 6178079..9ddeb5c 100644\n--- a/b\n+++ b/b\n@@ -1 +1,2 @@\n b\n+c\ndiff --git a/c b/c\nnew file mode 100644\nindex 0000000..f2ad6c7\n--- /dev/null\n+++ b/c\n@@ -0,0 +1 @@\n+c\n$ git diff d...b --\n$"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is there a way to list the commit's author in `git rebase -i` (interactive)?\nWhen I do a git rebase -i on a branch shared with a co-worker, I often want to just rebase my own commits. However, because the interactive rebase tool doesn't add the author information to the rebasing file (all t gives is the commit hash and description), I wind up having to go check commits in another tab to see if they are mine or not.\nIs there any way to give git rebase -i a --format flag (or something like it), to make it include the author?"
},
{
"role": "assistant",
"content": "As of git 2.6, git rebase -i uses rebase.instructionFormat (default %s) to generate the text after pick NNNNN....\nSince this is a git-config item, you can set the value per repository, for yourself in general, or even using the -c option on a one-time basis.\nEDIT:\nAs jdknight suggested in the comments, the specific command for this would be:\ngit config --add rebase.instructionFormat \"(%an <%ae>) %s\" \n\nor, to avoid item repetition, as oalders suggested, you can instead set the config globally:\ngit config --global rebase.instructionFormat \"(%an <%ae>) %s\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I delete a git alias?\nI'm learning to work with git, and I tried to set some aliases like this:\ngit config --global alias.trololo 'status'\n\nSo now when I type git trololo it works like git status. \nNow trololo alias is not needed. How can I correctly delete it?"
},
{
"role": "assistant",
"content": "You can try --unset in git config:\ngit config --global --unset alias.trololo\n\nI find it safer than editing directly the config file (git config --global --edit)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitLab: how can I tell what acess level I have on a project?\n\nI just tried to push to master on a GitLab repo and my push was denied with\n\nremote: GitLab: You are not allowed to push code to protected branches on this project.\n\nLooking at the access level documentation, it seems I'm probably a \"Developer\".\nIs there someplace in the GitLab UI that will tell me my access level and/or full list of permissions on a project?"
},
{
"role": "assistant",
"content": "You can open your user (in current version click on the avatar on the top-right corner) and go to \"Contributed projects\" tab, you'd be able to see your roles for the projects you're contributing to, something like:"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Fork from a branch in github\n\nIs there a way to fork from a specific branch on GitHub? … For example, moodle has many branches (1.9, 2.0 … and so on). Can a clone be performed of just branch 1.9 and not the master branch always? Is it possible to clone a specific branch onto my PC?"
},
{
"role": "assistant",
"content": "I don’t know a native way yet, but you can do it following this recipe:\n\nFork the repository in question (called ‘upstream’) on the GitHub website to your workspace there.\nRun the GitHub desktop application and clone the repository onto your PC.\nUse the GitHub desktop application to open a shell in the repository. (The git commands are not available from the default PowerShell unless you configure that manually.)\nSet the source repository as upstream:\ngit remote add upstream https://github.com/{user}/{source-repo}.git\n\nFetch the full upstream repository. (Right now, you only have a copy of its master branch.)\ngit fetch upstream\n\nMake your file system copy the branch you want and give it any name:\ngit checkout upstream/{branch-in-question}\ngit checkout -b temporary\n\nPublish your repo using the GitHub desktop application.\nOn the GitHub website, open your repository and click ‘settings’.\nChange the “Default branch” to ‘temporary’. (Just change the drop-down menu, you don’t need to click the “Rename” button.)\nGo back to your repository, go to the ‘branches’ tab, now you can delete the “master” branch.\nDelete the master branch on your shell and make a new master branch:\ngit branch -d master\ngit branch master\ngit checkout master\ngit -d temporary\n\nOnce more, publish your repo using the GitHub desktop application.\nOn the GitHub website, open your repository and click ‘settings’.\nChange the “Default branch” back to the (new) ‘master’ branch.\nGo back to your repository, go to the ‘branches’ tab, now you can delete the “temporary” branch.\n\nThis should be what you were looking for. Perhaps GitHub will provide a more convenient way to do this in future (e.g., clicking “Fork” from a project’s branch results in exactly this behaviour)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-mergetool"
},
{
"role": "assistant",
"content": "Run merge conflict resolution tools to resolve merge conflicts"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git - how do I view the change history of a method/function?\nSo I found the question about how to view the change history of a file, but the change history of this particular file is huge and I'm really only interested in the changes of a particular method. So would it be possible to see the change history for just that particular method?\nI know this would require git to analyze the code and that the analysis would be different for different languages, but method/function declarations look very similar in most languages, so I thought maybe someone has implemented this feature.\nThe language I'm currently working with is Objective-C and the SCM I'm currently using is git, but I would be interested to know if this feature exists for any SCM/language."
},
{
"role": "assistant",
"content": "Recent versions of git log learned a special form of the -L parameter:\n\n-L :<funcname>:<file>\nTrace the evolution of the line range given by \"<start>,<end>\" (or the function name regex <funcname>) within the <file>. You may not give any pathspec limiters. This is currently limited to a walk starting from a single revision, i.e., you may only give zero or one positive revision arguments. You can specify this option more than once.\n...\nIf “:<funcname>” is given in place of <start> and <end>, it is a regular expression that denotes the range from the first funcname line that matches <funcname>, up to the next funcname line. “:<funcname>” searches from the end of the previous -L range, if any, otherwise from the start of file. “^:<funcname>” searches from the start of file.\n\nIn other words: if you ask Git to git log -L :myfunction:path/to/myfile.c, it will now happily print the change history of that function."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Keep commits history after a 'git merge'\n\nWhen I work on two different features (on two different branches created from the master) it is quite annoying that I will not have the commit history when I proceed with merging.\nI'll explain better. When I finish work on Branch-A, I merge it into master. And that's fine, if I git log I see all the commits I made on Branch-A.\nInstead, when I finish work on Branch-B and I try to merge it to master (after that Branch-A has been already merged), I have to specify a commit message for the merging (while for the first branch I have not been asked anything).\nAnd after the merging to master, if I type git log, I cannot see the commits of the Branch-B in the history of my master branch\nLet's say I have \n**Branch A**\n\ncommit 09b2unfas9d781n2e\n Add more stuff\n\ncommit 8uj8masd89jas898a\n Add stuff\n\n**Branch B**\n\ncommit 09b2unfas9d781n2e\n Add feature setting\n\ncommit 8uj8masd89jas898a\n Add feature\n\nI finish having\n**Master**\n\ncommit 6hf6h8hd871udjkdn\nMerge: 09b2un 34osd6\n Merge branch 'Branch-B' into master\n\ncommit 09b2unfas9d781n2e\n Add more stuff\n\ncommit 8uj8masd89jas898a\n Add stuff\n\ncommit 34osd62dhc91123j8\n I'm a previous commit from 'master'.\n The last one before branching...\n\nwhile I would like to obtain something like:\n**Master**\n\ncommit 09b2unfas9d781n2e\n Add feature setting\n\ncommit 8uj8masd89jas898a\n Add feature\n\ncommit 09b2unfas9d781n2e\n Add more stuff\n\ncommit 8uj8masd89jas898a\n Add stuff\n\ncommit 34osd62dhc91123j8\n I'm a previous commit from 'master'.\n The last one before branching...\n\n... that would reflect more exactly the history of the performed commits.\nI don't get why I can keep the history from just one of the two branches.\nHow can I keep everything clear without those merge commits that hide/omit the real history of the merged commits?"
},
{
"role": "assistant",
"content": "It looks like the first merge was a fast-forward, and the second one was a three-way merge.\nExplanation\nGit has two versions of merge: fast-forward and three-way. (There are other versions, but that is not what happened here.) The default behavior is to do a fast-forward merge when possible, and otherwise do a three-way merge.\nA fast-forward merge can take place when the commit that is being merged has the current position of the branch in its history (you can force this behavior with the option --ff-only, which will cause the merge to fail when fast-forward is impossible). For example:\nA - B - C - D <-master\n \\\n E - F - G <- branch-a\n\nExecuting git merge (with default settings) will result in\nA - B - C - D - E - F - G <- branch-a <-master\n\nYou will also not get a chance to edit the merge commit because there is none.\nA three-way merge when your other branch diverges from master (not just ahead):\nA - B - C - D - E - F - G <-master\n \\\n E1 - E2 <- branch-b\n\nIn this case, Git cannot just move the pointer of master from G to E2 because that will get rid of the changes that were made in F and G. When a three-way merge happens, it creates a commit that has two parents, and also has a commit message. Now, master can be moved to this commit. (Notice that in this situation, master and branch-b do NOT point to the same commit.\nA - B - C - D - E - F - G - H <-master\n \\ /\n E1 - E2 <- branch-b\n\nIf you want to have a linear history then you need to use rebase, but be forewarned that if anybody else has seen your branch commits this may lead to issues that are beyond the scope of this answer. Using rebase will involve two steps, rebasing and then fast-forward merge. So, instead of merging you first execute the following while on branch-b, git rebase master. This creates new commits that are copies of the old commits, i.e., the same change-set, author information and message, but new committer information and parent history. (I call the commits E1' and E2' in the illustration to indicate that they are just copies.) The old commits will exist until they are garbage collected, but will not be reachable unless you look at the reflog.)\nA - B - C - D - E - F - G <-master\n \\ \\\n E1 - E2 \\ \n E1' - E2' <- branch-b\n\nExecuting git checkout master; git merge --ff-only branch-b will now fast-forward your changes into master, thereby giving you a linear history.\nA - B - C - D - E - F - G - E1' -E2' <-master <- branch-b"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-send-email - Send a collection of patches as emails --sendmail-cmd=<command>"
},
{
"role": "assistant",
"content": "Specify a command to run to send the email. The command should\nbe sendmail-like; specifically, it must support the -i option.\nThe command will be executed in the shell if necessary. Default\nis the value of sendemail.sendmailCmd . If unspecified, and if\n--smtp-server is also unspecified, git-send-email will search\nfor sendmail in /usr/sbin , /usr/lib and $PATH."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "In GitHub, is there a way to see all (recent) commits on all branches?\n\nIn GitHub, is there a way to see all recent commits on all branches. It would be best in reverse chronological order.\nMaybe I'm snoopy, but I'd like to be able to see what my developers have been up to recently, at least in terms of commits to the repository on github. So far the closest I've seen is the network graph, which is certainly very useful."
},
{
"role": "assistant",
"content": "Please note: this is not the right answer, although I hope it continues to be useful. NB it has been made a \"Community\" answer so I don't receive any points from upvotes\nTo see all commits for a specific branch (so this does NOT actually answer the original question, which is to see commits across all branches):\nClick \"Code\" (left-most tab) on the main page for the repository. Under those 4 buttons (\"master\", \"Go to file\", \"Add file\", \"Code\") there is a blue rectangle. At the right end of that is a clock icon and a number. If the viewport of your browser is wide enough it even includes (hurrah) the word \"commits\". This is a link. Click and ENJOY!!!\nNB the URL for this page is like this: https://github.com/myProfile/myRepo/commits/master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options rerere.autoUpdate"
},
{
"role": "assistant",
"content": "When set to true, git-rerere updates the index with the\nresulting contents after it cleanly resolves conflicts using\npreviously recorded resolutions. Defaults to false."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "sbt: Add http headers when fetching private maven repo with credentials\n\nI try to use credentials in my build.sbt config in order to retrieve private artifacts from a gitlab private maven repository.\nBut as sbt documentation states :\n\nThe credentials file is a properties file with keys realm, host, user, and password.\n\nAnd gitab private maven documentation states :\n\nIf a project is private or you want to upload Maven artifacts to GitLab,\n credentials will need to be provided for authorization. Support is available for personal access tokens and CI job tokens only. Deploy tokens and regular username/password credentials do not work.\n\nThe only way to authenticate when fetching or pushing artifacts to gitlab maven private repository is to use a maven settings.xml file with :\n<settings>\n <servers>\n <server>\n <id>gitlab-maven</id>\n <configuration>\n <httpHeaders>\n <property>\n <name>Private-Token</name>\n <value>REPLACE_WITH_YOUR_PERSONAL_ACCESS_TOKEN</value>\n </property>\n </httpHeaders>\n </configuration>\n </server>\n </servers>\n</settings>\n\nI found a workaround to push my private artifacts (intermediate step locally) but I am out of options to use these private artifacts as libraryDependencies in other scala repositories.\n\nIs there anyway to have sbt fetching my private gitlab repository with the required httpHeaders ?\nDo you know any workaround (multi-step fetchs) to have my private artifacts retrieved ?"
},
{
"role": "assistant",
"content": ""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to push to git on EC2\nI am trying to follow this instruction. I have a local git repo and when I do a git push, I need the repo to be pushed to my EC2 instance.\nBut, in the above tutorial, when I do a git push origin master, I get Permission denied (publickey) error because I did not specify the identity file.\nSay, I login to EC2 like this: ssh -i my_key.pem [email protected]\nSo, can I do something similar here to: git -i my_key.pem push origin master or set the identity file in .git/config\nSo, how can I set it up?\nUpdate: Output of git config -l\nuser.name=my name\n[email protected]\ngithub.user=userid\ncore.repositoryformatversion=0\ncore.filemode=true\ncore.bare=false\ncore.logallrefupdates=true\ncore.ignorecase=true\nremote.origin.url=ec2_id@my_e2_ip_address:express_app\nremote.origin.fetch=+refs/heads/*:refs/remotes/origin/*\n\nUpdate (from @Jon's comment):\nIf you have your key in an odd path just run ssh-add /private/key/path. This worked for me."
},
{
"role": "assistant",
"content": "To copy your local ssh key to amazon try this\ncat ~/.ssh/id_?sa.pub | ssh -i amazon-generated-key.pem ec2-user@amazon-instance-public-dns \"cat >> .ssh/authorized_keys\"\n\nreplacing the names of the key and amazon ec2 public dns, of course.\nyou will then be able to setup your remote on amazon"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I undo a `git commit` locally and on a remote after `git push`\nI have performed git commit followed by a git push. How can I revert that change on both local and remote repositories?\n$ git log\ncommit 364705c23011b0fc6a7ca2d80c86cef4a7c4db7ac8\nAuthor: Michael Silver <Michael [email protected]>\nDate: Tue Jun 11 12:24:23 2011 -0700"
},
{
"role": "assistant",
"content": "git reset --hard HEAD~1\ngit push -f <remote> <branch>\n\n(Example push: git push -f origin bugfix/bug123)\nThis will undo the last commit and push the updated history to the remote. You need to pass the -f because you're replacing upstream history in the remote.\nEdit:\nPlease note that --hard will make your commit unreachable (i.e. it will appear to be deleted, but you can still git show <hash> or git log <hash> it if you remember its hash). If you want to keep your changes, run:\ngit reset [--mixed] HEAD~1\n\nAt this point you have unstaged changes because you used --mixed, which is the default.\nYou may first want to update the remote tree first (i.e. remove the commit): git push -f <remote> <branch>\nSince you still have your changes locally you can create another branch and commit them there (and push as you see fit)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-revert"
},
{
"role": "assistant",
"content": "Revert some existing commits"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "When applying a patch is there any way to resolve conflicts?\nI am on windows. \nFor various reasons we have multiple git instances of different svn branches. \nMany times I want to fix an issue in repository A, generate a patch, and apply it to repository B. This works fine except if there are conflicts. \nWhen rebasing I just right click the folder and use tortioseGit and select the resolve option. This brings up a nice gui to let me work through my conflicts. \nIs there any way to accomplish this with rejected patch chunks?\nHere is my current approach to creating/applying the patches\ngit format-patch master --stdout > c:\\\\patch\\\\file.patch\ngit apply --reject --ignore-space-change --ignore-whitespace c:\\\\patch\\\\file.patch"
},
{
"role": "assistant",
"content": "To generate your patch do the following:\ngit format-patch --stdout first_commit^..last_commit > changes.patch\n\nNow when you are ready to apply the patches:\ngit am -3 < changes.patch\n\nthe -3 will do a three-way merge if there are conflicts. At this point you can do a git mergetool if you want to go to a gui or just manually merge the files using vim (the standard <<<<<<, ||||||, >>>>>> conflict resolution)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git : How to delete a remote branch whose name starts with a hashtag '#'?\n\nI've created a remote branch whose name starts with a hashtag mark and I've quickly learnt it's a bad idea as # is considered as a comment mark by git.\nTherefore, I would like to delete that branch now but I can't find a proper way to do so… I've tried :\ngit push origin --delete <#branch_name>\ngit push origin --delete -- <#branch_name>\n\nBut git always returns this error message \n\nfatal: --delete doesn't make sense without any refs.\n\nSo how can I walk around that issue ?"
},
{
"role": "assistant",
"content": "Escape the #:\ngit push origin --delete \\#branch_name\n ↑"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker <head>"
},
{
"role": "assistant",
"content": "a valid head name (i.e. a refs/heads/<head> reference)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Github Comparison View for 2 branches is incorrect?\n\nWhen I do a Github comparison view between master and another branch A, Github seems to be comparing the HEAD version of A with an older, non head version of master.\nI looked into it, and from what I can tell it sounds like Github is comparing branch A against a common ancestor of master. It's not actually comparing it to what's currently at the HEAD of master.\nIs there a way to diff the HEAD of master against the HEAD of Branch A in Github?\nIf not, why not? This seems like a feature every developer would want to be able to do. Or is there some process that should be done that I'm perhaps missing? I'd like to be able to create a Pull Request directly from one of these diffs.\nEDIT: Here's an example repo that shows the problem\nhttps://github.com/bradparks/test_github_diff_view\n\nI created a new repo that contains a single file, README.md\nI set this file to contain a single line v100.\nI then branched master into a new branch A, and changed the line to `v200'\nI then changed the value in the master branch to 'v300', and then compared the 2 branches using the compare link\nhttps://github.com/bradparks/test_github_diff_view/compare/A\nand I see the following unexpected result. Why isn't it diffing against v300 instead of v100?"
},
{
"role": "assistant",
"content": "Is there a way to diff the HEAD of master against the HEAD of Branch A in Github?\n\nSept 2018: yes: GitHub now explicitly supports \"Three-dot and two-dot Git diff comparisons\". See an example here.\nkeisuke mentions in the comments a similar initiative on Bitbucket.\nOriginal answer 2015:\nNo: as mentioned in \"GitHub compare view for current versions of branches\", GitHub only supports the triple dots (...) range shortcut specification.\nThat is:\n\nThis form is to view the changes on the branch containing and up to the second , starting at a common ancestor of both.\n\"git diff A...B\" is equivalent to \"git diff $(git-merge-base A B) B\".\nYou can omit any one of , which has the same effect as using HEAD instead.\n\nThe official GitHub help mentions this feature as:\n\nThe most common use of Compare is to compare branches, such as when you're starting a new Pull Request.\n\nIn that scenario, the PR branch starts from master (or should be rebased on top of master anyway), which means master HEAD is the base between master and the PR branch.\nBut when the two branches have forked, the comparison is no longer between HEADs, but between one common ancestor and one HEAD: git diff $(git-merge-base master B) B.\nNote: even if you were to specify two SHA1 directly, as it is clearly documented in \"Comparing commits\", that would still do a git diff $(git-merge-base A B) B.\nThat would not do a diff directly between the two commits."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Running actions in another directory\n\nI've just started exploring Github actions however I've found myself placing a command in multiple places. \nI have a PHP project where the composer.json is not in the root, my structure looks like:\nmy-project:\n readme.md\n app:\n composer.json\n\nObviously there is more to it and there is a reason why, but my composer.json sits in a subdirectory called 'app'. As a result in my workflow, I have to cd into that folder every time to run a command:\nname: CI\n\non: [push]\n\njobs:\n phpunit:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v1\n - name: Setup Symfony\n run: |\n cd app\n cp .env.dev .env\n - name: Install Composer Dependencies\n run: |\n cd app\n composer install --prefer-dist\n - name: Run Tests\n run: |\n cd app\n php bin/phpunit\n\nHow can I remove the cd app in every stage?"
},
{
"role": "assistant",
"content": "Update: It's now possible to set a working-directory default for a job. See this answer.\nThere is an option to set a working-directory on a step, but not for multiple steps or a whole job. I'm fairly sure this option only works for script steps, not action steps with uses.\nhttps://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsrun\nUsing working-directory, your workflow would look like this. It's still quite verbose but maybe a bit cleaner.\nname: CI\n\non: [push]\n\njobs:\n phpunit:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v1\n - name: Setup Symfony\n working-directory: ./app\n run: cp .env.dev .env\n - name: Install Composer Dependencies\n working-directory: ./app\n run: composer install --prefer-dist\n - name: Run Tests\n working-directory: ./app\n run: php bin/phpunit\n\nAlternatively, you can run it all in one step so that you only need to specify working-directory once.\nname: CI\n\non: [push]\n\njobs:\n phpunit:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v1\n - name: Setup and run tests\n working-directory: ./app\n run: |\n cp .env.dev .env\n composer install --prefer-dist\n php bin/phpunit"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What's the difference between git reset --mixed, --soft, and --hard?\nI'm looking to split a commit up and not sure which reset option to use.\nI was looking at the page In plain English, what does \"git reset\" do?, but I realized I don't really understand what the git index or staging area is and thus the explanations didn't help.\nAlso, the use cases for --mixed and --soft look the same to me in that answer (when you want to fix and recommit). Can someone break it down even more? I realize --mixed is probably the option to go with, but I want to know why. Lastly, what about --hard?\nCan someone give me a workflow example of how selecting the 3 options would happen?"
},
{
"role": "assistant",
"content": "When you modify a file in your repository, the change is initially unstaged. In order to commit it, you must stage it—that is, add it to the index—using git add. When you make a commit, the changes that are committed are those that have been added to the index.1\ngit reset changes, at minimum, where the current branch2 is pointing. The difference between --mixed and --soft is whether or not your index is also modified. So, if we're on branch master with this series of commits:\n- A - B - C (master)\n\nHEAD (the current commit) is C3 and the index matches C (assuming we haven't staged any changes with git add).\nWhen we run git reset --soft B, master (and thus HEAD, indirectly) now points to B, but the index still has the changes from C; git status will show them as staged. So if we run git commit at this point, we'll get a new commit with the same changes as C.\n(If we did have staged changes before the reset, those will still be in the index and git commit would commit those changes in addition to the changes from C.)\n\nOkay, so starting from here again:\n- A - B - C (master)\n\nNow let's do git reset --mixed B. (--mixed is the default option, so this is equivalent to git reset B). Once again, master and HEAD point to B, but this time the index is also modified to match B. If we run git commit at this point, nothing will happen since the index matches HEAD. We still have the changes in the working directory, but since they're not in the index, git status shows them as unstaged. To commit them, you would git add and then commit as usual.\n(This time, if we had staged changes before the reset, those changes will be removed from the index, but the files themselves will still contain any changes that were made.)\n\nAnd finally, --hard is the same as --mixed (it changes your HEAD and index), except that --hard also modifies your working directory. If we're at C and run git reset --hard B, then the changes added in C, as well as any uncommitted changes you've made, will be removed, and the files in your working copy will match commit B. Since you can permanently lose changes this way, you should always run git status before doing a hard reset to make sure your working directory is clean or that you're okay with losing your uncommitted changes.\n\nIn each of the above cases, we specified a commit (B) to reset to. If you don't provide one, it uses HEAD as the default. git reset --soft with no commit specified doesn't do anything (it makes the current branch point to where it was already pointing), but it can be useful for the other two modes. git reset --mixed (or just git reset) updates the index to match the current commit, which has the effect of unstaging any changes that have been added but not committed; git reset --hard does the same, plus it removes any changes in your working directory so that all your files match the latest commit on your current branch. (Again, since those changes are permanently lost, you should be careful when doing a hard reset.)\n\n1 The index is also referred to as the \"staging area\". You can think of it as another copy of all the files in the repository. When a branch is checked out, the index is updated so that all its files match the contents of that branch. When you git add a file, any changes you made to that file are copied to the index, and when you git commit, the contents of the index are turned into a commit and added to the current branch.\n2 HEAD is how Git refers to the commit that is currently checked out. HEAD (in most cases) points to a specific branch, called the current branch, and that branch points to a specific commit.\n3 Because HEAD points to master and master points to C. Whenever we add or remove a commit on the current branch, the commit that HEAD refers to changes not because HEAD itself changed, but because the branch that HEAD points to was updated to point to that commit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to \"git subtree\" only one file or directory?\nI use git subtree like:\ngit subtree add \\\n --prefix=directory_destination_path \\\n --squash [email protected]:kicaj/projectname.git \\\n master\n\nBut in directory_destination_path, it copies the entire repo from projectname.git.\nHow do I copy only a subdirectory or file from projectname.git to directory_destination_path?\nAlso, how do I update (automatic) file changes in both repositories were still the same? It is possible?"
},
{
"role": "assistant",
"content": "If I understand, you seem to want to only merge in a certain directory of a different repository, and you want it to be a subtree in your repository. I am going to call the directory of interest in the project.git path_of_interest_in_project and call the destination in your repo directory_desination_path.\nTry adding the remote project.git as a remote, then checking out one of its branches locally. Then use git-subtree split to split out just the directory of project.git you are interested in. After that merge it into your repo using subtree merge.\ngit remote add project [email protected]:kicaj/projectname.git\ngit branch project_master project/master\n\nThe branch project_master should now store the entire history of your project.git repo.\nThen you'll need to use the git-subtrees-split process.\ngit checkout -f project_master\ngit subtree split --squash --prefix=path_of_interest_in_project -b temp_branch\n\nThere should now be a branch called temp_branch containing just the directory you are interested in. Now you can perform a git-subtree-merge to bring it all into your repo.\ngit checkout -f master\ngit subtree merge --allow-unrelated-histories --prefix=directory_destination_path temp_branch\n\nThis should merge in the temp_branch into your master branch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitLab 7.2.1 with Apache Server instead of Nginx\n\nI have installed GitLab 7.2.1 with the .deb package from GitLab.org for Debian 7 on a virtual server where I have root access.\nOn this virtual server I have already installed Apache, version 2.2.22 and I don't want to use Ngnix for GitLab.\nNow I have no idea where the public folders of GitLab are or what I have to do or on what I have to pay attention. \nSo my question is: How do I have to configure my vhost for apache or what do I have to do also that I can use a subdomain like \"gitlab.example.com\" on my apache web server?"
},
{
"role": "assistant",
"content": "With two things in mind:\n\nUnicorn is listening on 8080 (you can check this with sudo netstat -pant | grep unicorn)\nYour document root is /opt/gitlab/embedded/service/gitlab-rails/public\n\nYou can create a new vhost for gitlab in apache with the following configuration:\n<VirtualHost *:80>\n ServerName gitlab.example.com\n ServerSignature Off\n\n ProxyPreserveHost On\n\n <Location />\n Order deny,allow\n Allow from all\n\n ProxyPassReverse http://127.0.0.1:8080\n ProxyPassReverse http://gitlab.example.com/\n </Location>\n\n RewriteEngine on\n RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f\n RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA]\n\n # needed for downloading attachments\n DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public\n\n</VirtualHost>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --skip-to=<file> --rotate-to=<file>"
},
{
"role": "assistant",
"content": "Discard the files before the named <file> from the output\n(i.e. skip to ), or move them to the end of the output\n(i.e. rotate to ). These options were invented primarily for the use\nof the git difftool command, and may not be very useful\notherwise."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database hash mismatch <object>"
},
{
"role": "assistant",
"content": "The database has an object whose hash doesn’t match the\nobject database value.\nThis indicates a serious data integrity problem."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to trigger a specific job in gitlab\n\nI want to run a specific job in a pipeline. I thought assigning a tag for the job and then specifying this tag again in the post method will fulfill my needs. The problem is when I trigger using the api(post), all the jobs in the pipeline are triggered even though only one of this tagged.\ngitlab-ci.yml:\njob1:\n script:\n - echo \"helloworld!\"\n tags : [myTag]\n\njob2:\n script:\n - echo \"hello gitlab!\"\n\n\nthe api call :\ncurl -X POST -F token=\"xxx\" -F ref=\"myTag\" https://gitlab.com/api/v4/projects/12345678/trigger/pipeline"
},
{
"role": "assistant",
"content": "add a variable to your trigger api call as shown here:\nhttps://docs.gitlab.com/ee/ci/triggers/#making-use-of-trigger-variables\nthen use the only prperty \ninside your gitlab.yml file\nas shown here :\nhttps://docs.gitlab.com/ee/ci/variables/#environment-variables-expressions\nthen only if the variable exists the job will be execute\nfor example\njob1:\n script: echo \"HELLO\"\n only:\n variables:\n - $variables[API_CALL]=true"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to revert to origin's master branch's version of file\nI'm in my local computer's master branch of a cloned master-branch of a repo from a remote server.\nI updated a file, and I want to revert back to the original version from the remote master branch.\nHow can I do this?"
},
{
"role": "assistant",
"content": "Assuming you did not commit the file, or add it to the index, then:\ngit checkout -- filename\n\nAssuming you added it to the index, but did not commit it, then:\ngit reset HEAD filename\ngit checkout -- filename\n\nAssuming you did commit it, then:\ngit checkout origin/master filename\n\nAssuming you want to blow away all commits from your branch (VERY DESTRUCTIVE):\ngit reset --hard origin/master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Poor man's Gitlab CE and Jenkins integration\n\nUPDATE \nThe script in the answer is obsolete now, since Gitlab plugin for Jenkins can now report build status back to Jenkins.\nI'm trying to integrate Gitlab CE 8.4 and Jenkins. I've read that Jenkins CI integration is available in Gitlab EE, but currently its not an option.\nI've already set up Jenkins gitlab plugin and Web hooks, and pushes to my repo trigger builds of Jenkins jobs. \nHowever, these builds are not shown in the 'Builds' tab in the respective Gitlab page. \nIf I commit .gitlab-ci.yml file to the repository, web hooks still work, Jenkins jobs run, but the 'Builds' page shows that the build is stuck, since no runners are defined. \nIndeed, I haven't set up any Gitlab CI runners, since they are not related to Jenkins, as far as I understand.\nI'd like to keep my Jenkins job since some useful information is published there, and I also would like to have its status on the Gitlab page.\nI'm thinking in this regard about a simple script for Gitlab CI runner, that would capture console output from a Jenkins job and translate it to Gitlab. Something like running wget or curl, because Jenkins provides API to see job's output. \nHowever, documentation about Gitlab CI and .gitlab-ci.yml is limited, as well as examples. \nHow could I write that job file?\nAm I right in thinking that Gitlab receives job's stdout?"
},
{
"role": "assistant",
"content": "Yes, Gitlab-CI prints stdout of a job and relates on exit codes.\nMy solution consists of installed Gitlab-CI runner and the python script, called from .gitlab-ci.yml, that gets git commit ID from CI_BUILD_REF environment variable, connects to the Jenkins host, finds respective build console, reads the output via urllib2.urlopen(...).readlines(), and prints it to stdout. \nIt uses bySHA1 url, provided by the Jenkins Git plugin, to find the build console.\nThe script also looks for the line, starting with the word Finished: and exits with the exit code, according to what follows that word: 0 if it is SUCCESS, and 1 if FAILURE, or UNSTABLE.\nScript text:\nimport urllib2\nimport os\nimport sys\nimport time\n\nTIMEOUT = 5\n\ndef get_build_console_for_sha1(url, sha1):\n return '{}/scm/bySHA1/{}/consoleText'.format(url, sha1)\n\n\ndef parse_console(build_con):\n retcode = 0\n\n if build_con:\n total_read_lines = 0\n finished_line = None\n\n while not finished_line:\n current_read_lines = 0\n try:\n for line in urllib2.urlopen(build_con, \n None, TIMEOUT).readlines():\n current_read_lines += 1\n if current_read_lines >= total_read_lines:\n print line,\n total_read_lines += 1\n sys.stdout.flush()\n if line.startswith('Finished: '):\n finished_line = line\n except urllib2.HTTPError as e:\n if e.code == 404:\n time.sleep(2)\n pass\n\n if 'FAILURE' in finished_line or 'UNSTABLE' in finished_line:\n retcode = 1\n\n print \"retcode = \", retcode\n return retcode\n\n\ndef main():\n URL = 'JENKINS_JOB_URL'\n sha1 = os.getenv('CI_BUILD_REF')\n bc = get_build_console_for_sha1(URL, sha1)\n return parse_console(bc)\n\n\nif __name__ == '__main__' :\n sys.exit(main())\n\nAnd in addition, .gitlab-ci.yml:\njenkins-translate:\n script: \n - python jenkins-translate.py\n\nDrawbacks are obvious: pressing cancel button actually cancels the translation, not the Jenkins job, no clickable links to the Jenkins job page. \nAt least it informs about Jenkins job statuses.\nUPDATE. This script does not authorize to Jenkins, it assumes relaxed security setting, when everyone can see job output.\nUPDATE2. Jenkins-Gitlab plugin can now report build status back to Gitlab, which obsoletes this script."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitignore does not ignore folder\nIn the root of my project I have a foo folder. Inside the foo folder I have a bar folder. I would like to ignore all changes to all files inside my bar folder. I have this in my gitignore:\n/foo/bar\n\nThe folder is checked: it exists and it has the files to be ignored. gitignore is committed. However, I have a file where I make a moification and is inside my bar folder. When I type\ngit status\n\ninside my git bash I see the file which should have been ignored. What could be the reason and how can I successfully ignore all files inside my bar folder?\nNote, that the files were previously ignored with the same line, but I had to temporarily remove that line to commit something on the server. After the commit, I put back the line into the gitignore. This was a while ago, but now I have observed that the files will be in git status. I would expect to be able to modify the ignored files without they appearing in the git status."
},
{
"role": "assistant",
"content": "I'm guessing this folder has been checked into git before? \nRun git rm -r --cached <folder> and check again."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to avoid git conflicts in a team?\nWe are some developers who work on same project and we use git for the project. If two or more of us happen to work on same file, we receive git conflicts which are hard to deal with, sometimes changes done by one developer are lost when these conflicts happen.\nHow do they work with git in a team? What should be the proper flow in order to avoid git conflicts ?\nThanks in advance."
},
{
"role": "assistant",
"content": "Before you dig deep into your workflow, before you spend a moment of time or a dollar of money rebuilding your communication processes, ask your team three questions:\n\nDo we enforce whitespace conventions?\nIf we use IDEs, do they all use the same formatting and keyword settings? For example, Eclipse can automatically finalize parameters.\nDo we generate textual build artifacts? For example, do we minify js, generate css rules from .sass or .scss files, or build xml configurations on the fly? Do we check them in?\n\nAfter years of generating conflicts and helping others solve them in centralized workflows, I submit these three things cause the vast majority of our collective conflict pain:\n\nIn the above image, the '!' slice represents legitimate merge conflicts. The vast majority of awful merges come from lazy whitespace conventions or overly aggressive IDEs (or occasionally, overly-refactory developers). Before you do anything else, standardize your IDE settings and whitespace conventions. Then have everyone issue this command in their local repositories:\n# Enable the repository's stock pre-commit hook\nmv .git/hooks/pre-commit.sample .git/hooks/pre-commit\n\nThat pre-commit hook will conduct a series of checks every time you issue git commit, including a version of git diff --check, a command that checks if your committed changes introduce whitespace errors. The commit will be rejected if it does. If you really need to get around it, you can issue git commit --no-verify, but don't: Whitespace errors are like the unexploded ordinance of version control. They're merge conflicts waiting to happen.\nIf you want to clean up whitespace, refactor a file to improve its indentation, or otherwise make a large series of purely formatting changes, do it in isolated commits, and warn the team to check in their conflicting work in progress first.\nIf you conduct code reviews, make these the first questions every reviewer asks: \"Did this change set touch anything it wasn't supposed to? Did it clean up any formatting? Did it unnecessarily refactor a method?\" If it did, fail the review. Or if you can't, make sure those changes are sufficiently isolated from the logical changes (i.e. in different commits) to make your history useful.\nStylesheet languages, RequireJS, and js minifiers also cause conflicts, if their generated targets are checked in. The files created by these technologies are build artifacts. You wouldn't check in a WAR archive; don't check in a SASS-compiled CSS file. Or, if you feel you must, use a .gitattributes file to let git treat them as binaries.\nIf after doing all of these things, you still have merge conflicts, institute workflow improvements. Gary Fixler's answer is absolutely right: Legitimate merge conflicts arise because teams cannot or do not communicate well about the scope of their projects. Just make sure its not poorly enforced formatting rules first."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --abbrev[=<n>]"
},
{
"role": "assistant",
"content": "Instead of showing the full 40-byte hexadecimal object\nname in diff-raw format output and diff-tree header\nlines, show the shortest prefix that is at least <n> hexdigits long that uniquely refers the object.\nIn diff-patch output format, --full-index takes higher\nprecedence, i.e. if --full-index is specified, full blob\nnames will be shown regardless of --abbrev .\nNon default number of digits can be specified with --abbrev=<n> ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options --global"
},
{
"role": "assistant",
"content": "For writing options: write to global ~/.gitconfig file\nrather than the repository .git/config , write to $XDG_CONFIG_HOME/git/config file if this file exists and the ~/.gitconfig file doesn’t. For reading options: read only from global ~/.gitconfig and from $XDG_CONFIG_HOME/git/config rather than from all available files. See also FILES ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I center an image in the README.md file on GitHub?\n\nI've been looking at the Markdown syntax used in GitHub for a while, but except resizing an image to the width of the README.md page, I can't figure out how to center an image in it.\nIs this possible? If so, how can I do it?"
},
{
"role": "assistant",
"content": "This is from GitHub's support:\n\nMarkdown doesn't allow you to tweak alignment directly (see docs here: http://daringfireball.net/projects/markdown/syntax#img), but you can just use a raw HTML 'img' tag and do the alignment with inline css.\n\nSo it is possible to align images! You just have to use inline CSS to solve the problem. You can take an example from my GitHub repository. At the bottom of README.md there is a centered aligned image. For simplicity you can just do as follows:\n<p align=\"center\">\n <img src=\"http://some_place.com/image.png\" />\n</p>\n\nAlthough, as nulltoken said, it would be borderline against the Markdown philosophy!\n\nThis code from my README file:\n<p align=\"center\">\n <img src=\"https://github.com/waldyr/Sublime-Installer/blob/master/sublime_text.png?raw=true\" alt=\"Sublime's custom image\"/>\n</p>\n\nIt produces this image output, except centered when viewed on GitHub:"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --indent-heuristic"
},
{
"role": "assistant",
"content": "Enable the heuristic that shifts diff hunk boundaries to make patches\neasier to read. This is the default."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options integer"
},
{
"role": "assistant",
"content": "The value for many variables that specify various sizes can\nbe suffixed with k , M ,… to mean \"scale the number by\n1024\", \"by 1024x1024\", etc."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.interHunkContext"
},
{
"role": "assistant",
"content": "Show the context between diff hunks, up to the specified number\nof lines, thereby fusing the hunks that are close to each other.\nThis value serves as the default for the --inter-hunk-context command line option."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to Conclude a Git Cherry-Pick?\nYesterday I cherry-picked two commits into my main branch, one of them caused merge conflicts and I resolved them, committed and pushed them to origin. Today I am attempting to pull from the server when I get the following error:\n$ git pull\nfatal: You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).\nPlease, commit your changes before you can merge.\n$\n\nGit status reads:\n$ git status\n# On branch main\n# Your branch is behind 'origin/main' by 2 commits, and can be fast-forwarded.\n#\n$\n\nI have tried the following to no avail:\n$ git cherry-pick --continue\nusage: git cherry-pick [options] <commit-ish>\n$\n\nAny idea on how I could resolve this? Thanks in advance!"
},
{
"role": "assistant",
"content": "Next time try git cherry-pick --abort, otherwise what you did should more or less work."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc"
},
{
"role": "assistant",
"content": "SYNOPSIS git diff [<options>] [<commit>] [--] [<path>…] git diff [<options>] --cached [--merge-base] [<commit>] [--] [<path>…] git diff [<options>] [--merge-base] <commit> [<commit>…] <commit> [--] [<path>…] git diff [<options>] <commit>…<commit> [--] [<path>…] git diff [<options>] <blob> <blob> git diff [<options>] --no-index [--] <path> <path>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitrevisions - Specifying revisions and ranges for Git REVERT_HEAD"
},
{
"role": "assistant",
"content": "records the commit which you are reverting when you run git revert ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to combine group of local commits to single push in IDEA?\nIn IDEA I am trying to push some commits.\nI have a requirement that on remote server it looks like single action.\nI click to push and see following window\n\nI expected to see squash checkbox here but don't see it.\nPlease help me."
},
{
"role": "assistant",
"content": "You can do it using rebase. Go to VCS/Git/Rebase. Then select Interactive option. It will show you a list of commits, where you can pick which ones you want to squash.\nAfter you hit Start rebasing it will prompt you for a commit message for the squashed commit. After that is done you can push your squashed commit using push dialog.\n\nMore information about rebase in IntelliJ is here."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-instaweb - Instantly browse your working repository in gitweb -b --browser"
},
{
"role": "assistant",
"content": "The web browser that should be used to view the gitweb\npage. This will be passed to the git web--browse helper\nscript along with the URL of the gitweb instance. See git-web--browse for more information about this. If\nthe script fails, the URL will be printed to stdout."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Does GitLab permit wiki merge requests?\n\nI know GitLab stores wiki pages in a separate Git repository. How can we create a merge request for the wiki project of my project? Is it possible?\nI found a similar question about GitHub:\nHow can I make a pull request for a wiki page on GitHub?, but nothing about GitLab."
},
{
"role": "assistant",
"content": "2016: Creating a MR (Merge Request) requires the name of a project, not of its wiki.\nThe workaround would then be similar to the one described in your linked answer\n\nhaving a dedicated repo \"project\" being a fork/clone of the wiki\nmaking your MR to this wiki project/fork\npushing from this fork back to the original wiki repo\n\n\n2022: this is followed by Epic 7107, which refers to this workaround:\n\nAccepting merge requests on wikis\nIt's possible to work around the limitation of Wiki permissions\nby creating a mirror of the git wiki backing the wikis.\nThis way more users can suggest changes to the wiki by submitting merge requests.\nIt's not as easy as editing the wiki, but at least provides\na way for outside contributors to participate.\nTo do this, you'll need to create project access tokens in the\nWiki and use the repository mirror feature to replicate the wiki\ninto a separate project.\n\nIn the Wiki project, head for the Settings: Access Tokens page\nand create a new token with write_repository access\n\noptionally, create a new project for the wiki, for example called\nwiki-replica.\nYou can also use the same project as the wiki\nif you do not plan to host other source code specific to that\nproject there.\nWe'll call this the \"wiki replica\" in either case\n\nIn the wiki replica, head for the Settings: Mirroring repositories section and fill in the details for the wiki HTTPS clone URL:\n\nGit repository URL: the HTTPS URL of the Git repository (which\nyou can find in the Clone repository page on the top-right\nof the wiki)\nImportant: Make sure you add a username to\nthe HTTPS URL, otherwise mirroring will fail.\nFor example, this wiki URL:\nhttps://gitlab.torproject.org/tpo/tpa/team.wiki.git\n\nshould actually be:\nhttps://[email protected]/tpo/tpa/team.wiki.git\n\n\nMirror direction: push (only \"free\" option, pull is non-free)\n\nAuthentication method: Password (default)\n\nPassword: the Access token you created in the first\nstep\n\nKeep divergent refs: checked (optional, should make sure\nsync works in some edge cases)\n\nMirror only protected branches: checked (to keep merge\nrequests from being needlessly mirrored to the wiki)\n\n\n\n\nWhen you click the Mirror repository button, a sync will be\ntriggered.\nRefresh the page to see status, you should see the Last successful update column updated.\nWhen you push to the replica, the wiki should be updated.\nNaturally, because of limitations of GitLab, you cannot pull changes\nfrom the wiki to the replica.\nBut considering only a limited set of\nusers have access to the wiki in the first place, this shouldn't be a\nproblem as long as everyone pushes to the replica."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to rebase one Git repository onto another one?\nI had one Git repository (A) which contains the development of a project until a certain point. Then I lost the USB stick this repo A was on. Luckily I had a backup of the latest commit, so I could create a new repository (B) later where I imported the latest project's state and continue development.\nNow I recovered that lost USB stick, so I have two Git repositories.\nI think I just have to rebase repo B onto repo A somehow, but I have no idea how to do that, maybe using fetch/pull and rebase?"
},
{
"role": "assistant",
"content": "If A and B are not the same repo (you created B by using the latest working copy you had), you have to use a graft to pretend that they have common history.\nLet’s assume you’ve added A as a remote for B as per VonC’s answer, and the repo looks like this1:\n~/B$ git tnylog \n* 6506232 (HEAD, master) Latest work on B\n* 799d6ae Imported backup from USB stick\n~/B$ git tnylog A/master\n* 33b5b16 (A/master) Head of A\n* 6092517 Initial commit\n\nCreate a graft telling the root of B that its parent is the head of A:\necho '799d6aeb41095a8469d0a12167de8b45db02459c 33b5b16dde3af6f5592c2ca6a1a51d2e97357060' \\\n >> .git/info/grafts\n\nNow the two histories above will appear as one when you request the history for B. Making the graft permanent is a simple git filter-branch with no arguments. After the filter-branch, though, you aren’t on any branch, so you should git branch -D master; git checkout -b master.\n\n1 git tnylog = git log --oneline --graph --decorate"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index default"
},
{
"role": "assistant",
"content": "Is a synonym for zebra . This may change to a more sensible mode\nin the future."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options fsmonitor.allowRemote"
},
{
"role": "assistant",
"content": "By default, the fsmonitor daemon refuses to work with network-mounted\nrepositories. Setting fsmonitor.allowRemote to true overrides this\nbehavior. Only respected when core.fsmonitor is set to true ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git branch name - case sensitive or insensitive?\n\nI am a new git user and recently been handed with an out of date git repository to look after.\nThis is the original state ( output by git show-branch):\n! [cr232] CR 232 Release\n * [dev] Style Changes\n---------------\n * [dev] Style Changes\n * [dev^] SMS 5.4\n * [dev~2] Logo Change\n * [dev~3] SMS 5.3\n * [dev~4] SMS 5.2\n * [dev~5] SIT R-0.3.3 EDW SMS Layers\n * [dev~6] SIT Release R 0.3.0\n +* [cr232] CR 232 Release\n +* [cr232^] Dashboard Fix\n +* [cr232~2] Release for system testing\n\nNote that there is a branch called ‘dev’ at this point. Note that highlighted there are several references to dev (i.e. dev, dev^, dev~2 etc).\nFor my development purpose, I was trying to come up with a branch called ‘DEV’, all capital.\nSo I went ahead and create new branch (git branch DEV) and now running git show-branch –date-order:\n! [DEV] Style Changes\n ! [cr232] CR 232 Release\n * [dev] Style Changes\n---------------\n * [DEV] Style Changes\n * [DEV^] SMS 5.4\n * [DEV~2] Logo Change\n * [DEV~3] SMS 5.3\n * [DEV~4] SMS 5.2\n * [DEV~5] SIT R-0.3.3 EDW SMS Layers\n * [DEV~6] SIT Release R 0.3.0\n +* [cr232] CR 232 Release\n +* [cr232^] Dashboard Fix\n +* [cr232~2] Release for system testing\n\nNote that both dev and DEV are listed as branch. Note also that on the 5th line the references to dev have now changed to DEV (i.e. DEV, DEV^, DEV~2 etc).\nWhat is the 5th line output referring to? I would expect it to remain “dev” instead of being changed to “DEV” as the descriptions next to it refers to the description of old work during “dev” branch.\nI am trying to return back to how it was by modifying the DEV branch name to DV (running git branch –m DEV DV) and showing the branch now look like:\n! [DV] Style Changes\n ! [cr232] CR 232 Release\n * [dev] Style Changes\n---------------\n * [DV] Style Changes\n * [DV^] SMS 5.4\n * [DV~2] Logo Change\n * [DV~3] SMS 5.3\n * [DV~4] SMS 5.2\n * [DV~5] SIT R-0.3.3 EDW SMS Layers\n * [DV~6] SIT Release R 0.3.0\n +* [cr232] CR 232 Release\n +* [cr232^] Dashboard Fix\n +* [cr232~2] Release for system testing\n\nNote that the branch is now including DV and dev. Note also that the 5th line references to dev have now changed to DV (i.e. DV, DV^, DV~2 etc).\nIs there any way to get back to how it was during original state in term of the DV references? Did the git got confused and renamed my historic information with a branch that is similar and only differs by capital case?\nPlease assist on how I can fix this. Thanks heaps"
},
{
"role": "assistant",
"content": "Answering just the question in the subject line, without addressing anything about git show-branch (like ElpieKay, I never actually use git show-branch; it seems mainly mis-informative):\nGit branch names—and tag names, and all other reference names, as Git calls them—were originally intended to be case-sensitive.\nThis all works perfectly on Linux / Unix machines, where Git's code is case-sensitive to start with. When Git stores branch names in the file system as file names (which it only does sometimes), the file system is also case-sensitive.1\nIt sometimes fails on Windows and some MacOS systems. Specifically, it fails when Git stores references in individual files, whose names are derived from the reference name, and those file names are case-insensitive (e.g., case-preserving, but fold case during name-matching; or even converting everything to uppercase-only, as in the really old FAT 8.3 format, but we can hope no modern file system does this).\nAs noted above, Git does not always store reference names as file names. In fact, on initial clone, all the names are in a single file called .git/packed-refs,2 so at this point they are case sensitive. But they become \"unpacked\" over time,3 and then on some systems they become case-folding.\nBecause it sometimes fails on some systems, it's generally best to avoid using multiple reference names that differ only in case.\n\n1Of course, on modern Unix/Linux systems, you can now get access to case-preserving-but-case-insensitive file systems, and Windows and MacOS can now be told not to do case-folding for some file systems. (But if you change from the defaults, expect software that is intended for your box to fail, because it will. Things like Photoshop internally try to use files named foo and FOO and expect this to refer to the same file!)\n2This packed-references file has been around for quite a while, but not forever, and very early versions of Git may not use it. Internally, Git is acquiring a new \"pluggable reference name interface\" and future versions of Git might use neither this file, nor individual per-reference files.\n3In general, creating or updating a reference causes an unpacked reference file to come into existence. Running git pack-refs --all will replace unpacked references with packed ones, restoring full case-sensitivity. Without --all, git pack-refs only packs already-packed references, which is largely a useless mode of operation (it was intended for a case that is no longer used)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git merge: accept theirs for multiple conflicts\nI'm trying to merge a git branch (test-development) back into master. There are lots of merge conflicts but I want as many as possible to be resolved via --theirs. Is there a way to tell git to merge with --theirs in bulk?"
},
{
"role": "assistant",
"content": "This will do it (does not just resolve the conflicts but takes their version of the files) if you're mid-merge:\ngit merge test-development\n# Automatic merge failed, a bunch of conflicts!\ngit checkout --theirs ./path\ngit add ./path\ngit commit"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitHub - Hiding the Public Activity/My Actions [closed]\n\nClosed. This question is off-topic. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it's on-topic for Stack Overflow.\n\n\nClosed 11 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI have a free account on GitHub. I have noted that there is not any obvious way to switch off or to control the 'Public Activity'. Therefore, every time I commit or do something even trivial it shows up in my Actions and is available as an RSS feed. \nIs there a way to control or to switch off the public activity option?"
},
{
"role": "assistant",
"content": "Sept 2022: confirmed:\n\nPrivate profiles are now generally available (Sep. 2022)\nPrivate profiles (now generally available) enables users to turn their GitHub profile \"private\", which gives users control over features that share user data across the GitHub platform.\nWhen a profile is private, the following content is hidden from the profile page:\n\nAchievements and highlights\nActivity overview and activity feed\nContribution graph\nFollower and following counts\nFollow and Sponsor buttons\nOrganization memberships\nStars, projects, packages, and sponsoring tabs\n\nTo enable this setting, visit https://github.com/settings/profile.\n\nLearn more about private profiles.\nAs we continue to release new privacy control features, please share your feedback.\n\n\nUpdate Apr. 2022, eleven years later: Yes!\n\nPrivate Profiles\nUsers now have the ability to turn their GitHub profile “private”, which gives users controls over features that share user data across the GitHub platform.\nTo enable this setting, visit https://github.com/settings/profile.\n\nPrivate profiles are in public beta.\n\n\n2011: I don't think there is a way to customize what your public activity shows. The social coding network that GitHub represents is founded on that very same \"public\" activity. The only way to restrict it is by paying for private repositories.\n\nNote: since 2011, GitHub was acquired by Microsoft (June 2018), and the current (2021) pricing include unlimited private repositories(!)\nSo using private repositories is a good option, considering you can now easily change a repository's visibility."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects first-parent, 1"
},
{
"role": "assistant",
"content": "Show full diff with respect to first parent. This is the same\nformat as --patch produces for non-merge commits."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do you switch between branches in Visual Studio Code with Git?\nI am trying to workout how branching works in Visual Studio Code and Git. Previously I've worked with TFS which was pretty simple - you create a branch and this is all stored in a separate folder on your disk so you can easily work on one branch or another.\nSo in Visual Studio Code I have created a new branch \"test\" from master. In Visual Studio Code I am looking at the branch icon bottom left to see which branch I'm working in.\n\nIt says I'm working in test, so I make changes to file1, commit and synchronise the changes. I now want to work on the master branch, so I go bottom left, switch to master, but my changes from the test branch are still displayed in the editor.\nIf I look on the hard disk, my changes from the test branch are there, and there is no separate test & master folder. So how do I get to work on the master branch again? I've tried checkout, synchronising on the master branch, but I always have the test changes displayed.\nA typical scenario is, I'm part way through working on a new feature on a branch, and I need to switch to master to do a hotfix, before returning to the feature branch. Switching between those branches is escaping me."
},
{
"role": "assistant",
"content": "When in the Visual Studio Code IDE, do the following:\n\non the bottom left, press on the Git branch which will give a list: Select a ref to checkout\nselect one of the branches of the remote branch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Updating pull request after review changes commit doesn't show up in the pull request\n\nI forked a GitHub repository and made some changes on my fork and submited a pull request but the owners of the original GitHub repository asked for some changes which they asked me for in the pull request. I assumed that adding additional changes to my fork will cause them to show up in the current pull request but to my surprise I can't see my changes in the pull request.\nThis is what I did after generating the original pull request:\n\nmade code changes\nadd the files 1git add -A`\ncommit the files git commit -m \"these are my suggested changes in pull request\"\nsubmit my changes with git push\n\nI can see changes on my own fork but I don't understand why I can't see any changes in the pull request.\nDoes anyone know what I need to do for my changes to show up in the current pull request?\nI'd really appreciate your help."
},
{
"role": "assistant",
"content": "First, make sure that you did push to the right branch and that the commit still doesn't show up in the PR. For me, the commit showed up when I viewed the specific branch in the repo, but didn't show in the PR and didn't trigger CI.\nThis is what fixed the issue for me:\n\nClick on Edit in the top right corner.\nClick on the base selector and choose the same base branch.\nGitHub will ask you whether you want to change base, confirm.\nThe PR should update and the commit should show up."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database --unreachable"
},
{
"role": "assistant",
"content": "Print out objects that exist but that aren’t reachable from any\nof the reference nodes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database gitattributesSymlink"
},
{
"role": "assistant",
"content": "(INFO) .gitattributes is a symlink."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the Difference Between Mercurial and Git?\nLocked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.\n \n \n\n\n\n\n\n\nI've been using git for some time now on Windows (with msysGit) and I like the idea of distributed source control. Just recently I've been looking at Mercurial (hg) and it looks interesting. However, I can't wrap my head around the differences between hg and git.\nHas anyone made a side-by-side comparison between git and hg? I'm interested to know what differs hg and git without having to jump into a fanboy discussion."
},
{
"role": "assistant",
"content": "These articles may help:\n\nGit vs. Mercurial: Please Relax (Git is MacGyver and Mercurial is James Bond)\nThe Differences Between Mercurial and Git\n\nEdit: Comparing Git and Mercurial to celebrities seems to be a trend. Here's one more:\n\nGit is Wesley Snipes, Mercurial is Denzel Washington"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I enable cloning over SSH for a Gitlab runner?\n\nI am having some trouble cloning large repositories over HTTP on my Windows Gitlab runner. I've tried several methods to do shallow clones or disable clone compression. Still no luck.\nCloning the same repository over SSH works great as a temporary solution and I would like to get this working on our Gitlab CI process.\nThe issue now stands where I have no idea how to use SSH as a clone method for the gitlab-multi-runner. It just seems to use HTTP as a default, and my only options regarding cloning is whether it will do a full clone or a fetch.\n\nCan someone explain how I could get that clone/fetch to work on a runner over SSH instead of HTTP?\nGitlab Version: GitLab Community Edition 8.10.7"
},
{
"role": "assistant",
"content": "As a newcomer to gitlab, I've managed to hack a workaround to this issue as I also haven't found a built-in way to change the default cloning process (although here is a recent comment about how it can be done).\nBy disabling the automatic cloning process, you can effectively override its behavior completely by simply writing your own cloning process in a before_script. Only for the purposes of example does the below show how to accomplish this for HTTP cloning but could be adapted for ssh cloning (if you're trying to use HTTP cloning you should use the built-in cloning process and the config.toml):\n\nCreate a new user called \"gitlab-runner\" and generate their user auth token for later use (or in your case, you would generate ssh keys).\n\nDisable cloning process for runner by adding the following variable in either your project or group settings: .../settings/ci_cd\nkey: GIT_STRATEGY\nvalue: none\n\nClone your repo in a before_script such as:\n\n\n\nbefore_script:\n ## clean the working directory\n - BUILD_DIR=/home/gitlab-runner/builds/$RUNNER_TOKEN/0\n - CLONE_DIR=\"$BUILD_DIR/$CI_PROJECT_PATH\"\n - cd $BUILD_DIR\n - rm -rf $CLONE_DIR\n - mkdir -p $CLONE_DIR\n\n ## clone the project each time (inefficient, consider performing fetch instead if it already exists)\n - git clone http://gitlab-runner:$GITLABRUNNER_USER_AUTH_TOKEN@server:8888/${CI_PROJECT_PATH}.git $CLONE_DIR\n - cd $CLONE_DIR\n\nNote: Here are the relevant variables I also configured in step 2 rather than hard coding them in the script:\n\nRUNNER_TOKEN: \"Runner Token\" value listed in the Admin \"Runners\" menu for the particular runner you are trying to run.\nGITLABRUNNER_USER_AUTH_TOKEN: This is the auth token you generated in step 1.\n\nFurther Reading:\nYou can avoid the fake account approach taken above by instead issuing Deploy Keys. Or if security implications of access to any project is a concern, Deploy Tokens are an alternative with more security control. For comparison, see the docs:\n\nDeploy keys are shareable between projects that are not related or don’t even belong to the same group. Deploy tokens belong to either a project or a group.\n\n\nA deploy key is an SSH key you need to generate yourself on your machine. A deploy token is generated by your GitLab instance, and is provided to users only once (at creation time).\n\n\nA deploy key is valid as long as it’s registered and enabled. Deploy tokens can be time-sensitive, as you can control their validity by setting an expiration date to them.\n\n\nYou can’t log in to a registry with deploy keys, or perform read / write operations on it, but this is possible with deploy tokens.\nYou need an SSH key pair to use deploy keys, but not deploy tokens."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can't clone a github repo on Linux via HTTPS\n\nI'm trying to do a simple git clone https://github.com/org/project.git on a CentOS box but get:\n\nerror: The requested URL returned error: 401 while accessing\n https://github.com/org/project.git/info/refs\nfatal: HTTP request failed\n\nIt never prompts me for my username/password, just fails.\nI can make the exact same call on my Mac no problem- what am I missing?"
},
{
"role": "assistant",
"content": "The answer was simple but not obvious:\nInstead of:\ngit clone https://github.com/org/project.git\n\ndo:\ngit clone https://[email protected]/org/project.git\n\nor (insecure)\ngit clone https://username:[email protected]/org/project.git\n\n(Note that in the later case, your password will may be visible by other users on your machine by running ps u -u $you and will appear cleartext in your shell's history by default)\nAll 3 ways work on my Mac, but only the last 2 worked on the remote Linux box. (Thinking back on this, it's probably because I had a global git username set up on my Mac, whereas on the remote box I did not? That might have been the case, but the lack of prompt for a username tripped me up... ) \nHaven't seen this documented anywhere, so here it is."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I make a pull request for a wiki page on GitHub?\n\nI saw a wiki page on GitHub that isn't open for editing. Then I forked the project, edited it on \"my end\" and tried to do a pull request. It turns out, the wiki isn't in the project, and there isn't a way to commit changes to it.\nOther than e-mailing, is there a way to proceed if I want to suggest a change on the wiki in this case?\nAt this point I found out what seems like an alternative under \"Questions with similar titles\", but I couldn't do the pull request with it yet, and so I'm not sure submodules is a good way for this purpose. I now see I could probably branch it somehow... So is this the way to go?"
},
{
"role": "assistant",
"content": "GitHub doesn't support pull requests for the wiki repository, only the main repository (this is a bit of a shame, IMO, but I can understand it).\nHere's an interesting way one project manages community updates to their wiki, while still keeping tight control, as for source code:\n\nMy proposed workflow is this:\n\nManually create a fork of the Taffy wiki on your Github account:\n \n \nCreate a new repository on your github account. Let's call it \"Taffy-Wiki\".\nClone the Taffy wiki repo to your local machine somewhere: git clone [email protected]:atuttle/Taffy.wiki.git\nRemove the original \"origin\" remote and add your github repo as new \"origin\" git remote rm origin and git remote add origin [email protected]:<YOUR_USERNAME>/Taffy-Wiki.git\n\nMake your proposed changes locally, then push them to your github account: git push -u origin master ('-u origin master' only required the first time; afterwards just do git push)\nSubmit a ticket to the official Taffy issue tracker requesting me to review your changes and merge them in. Please be sure to include a link to your repo and describe what you've changed.\nGoto #2\n\n\n(From How you can contribute to Taffy documentation.)\nIf it were me, I'd create an issue in the main repository (that is, the one you forked) suggesting an update to the wiki. If issues aren't enabled, then email's about the only other option I can think of."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %h"
},
{
"role": "assistant",
"content": "abbreviated commit hash"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git log output log file\nI am doing an assignment in a university course and I am using Git as version control for this assignment. The game I have been working on is complete. However, along with the hand in I would like to submit the Git log, effectively showing my progress during the time I have been working on it.\nI have tried this:\ngit log --stat > log.log\n\nBut it more or less just gives me very unreadable stuff. What is a command so that I can get a nice formatting on this?"
},
{
"role": "assistant",
"content": "I would recommend using a different format than the default. My usual choice is a summary with the graph, but a one-line summary alone usually does the trick.\nOption 1: One-line summary with a graph\ngit log --pretty=format:'%h : %s' --graph > log.log\n\nResults in:\n* 2d3acf9 : ignore errors from SIGCHLD on trap\n* 5e3ee11 : Merge branch 'master' of git://github.com/dustin/grit\n|\\\n| * 420eac9 : Added a method for getting the current branch.\n* | 30e367c : timeout code and tests\n* | 5a09431 : add timeout protection to grit\n* | e1193f8 : support for heads with slashes in them\n|/\n* d6016bc : require time for xmlschema\n\nOption 2: One-line summary without a graph\ngit log --pretty=format:'%h was %an, %ar, message: %s' > log.log\n\nResults in:\na6b444f was Scott Chacon, 5 days ago, message: dammit, this is the second time this has re\n49d77f7 was Scott Chacon, 8 days ago, message: modified index to create refs/heads if it i\n9764edd was Hans Engel, 11 days ago, message: Add diff-lcs dependency\ne1ba1e3 was Hans Engel, 11 days ago, message: Add dependency for Open4\n0f87b4d was Scott Chacon, 12 days ago, message: merged recent changes\n\nYou can find more formatting options in the documentation here."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - diff of current changes before committing\nI have changed several files in a git repository, but have not committed them yet.\nI can get a list of the changes by just invoking git status. But how do I get a listing of the lines or the content that I have changed, in addition to the filenames?\nI initially thought about using git diff, but it seems to be useful only for comparing already commited changes.\nUsually I just do meld ., but on this case I'm connected to an external server via ssh."
},
{
"role": "assistant",
"content": "git diff by default shows difference between your working directory and the index (staging area for the next commit).\nIf you have already added (staged) the changes to the staging area, git diff --staged does the job. Staging area is the data from which the next commit will be formed by git commit.\nP. S. Good reading (IMO) for Git beginners:\n\nhttps://git-scm.com/book/en/v2 (most chapters; it explains the model behind Git and answers most of typical questions)\nand then immediately http://gitready.com/ (usage tips)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order %gd"
},
{
"role": "assistant",
"content": "shortened reflog selector; same as %gD , but the refname\nportion is shortened for human readability (so refs/heads/master becomes just master )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is there an overview of what can go into a .github \"dot github\" directory?\n\nI keep finding piecemeal examples of things that can go into a .github directory on a GitHub repository.\nI can see that it is used for GitHub actions and workflow and for Pull request and issue templates, but I can't see a page outlining what you can put in there with ideally some documentation. I also think I've seen a funding example too.\nBasically every time I see something you can do there, I think \"that's neat I should do that\", but other than examples I can't see a way to discover new things other than by example.\nDue to the fact that the directory is called .github it seems to defy Google and SO search as well."
},
{
"role": "assistant",
"content": "On Github, folder .github is just a convention folder used to place Github related stuff inside it. Github handles some of these files even when you place it in root of your project (such as CONTRIBUTING.md, CODE_OF_CONDUCT.md etc). Because Github is constantly bringing in new features, these features are documented on their own, so there is no \"all possible files in .github\" page. Feel free to place anything that is related to Github specifically inside it.\nSome of the most used files in .github folder:\n\nCODE_OF_CONDUCT.md -> How to engage in community and how to behave yourself.\nCONTRIBUTING.md -> How to contribute to repo (making pull request, setting development environment...)\nLICENSE.md - A software license tells others what they can and can't do with your source code (You should place this at the root of your project since GitHub ignores it in .github folder. You can find this file while browsing other Git hosting services such as GitLab, Bitbucket etc.)\nFUNDING.yml -> Supporting a project\nISSUE_TEMPLATE -> Folder that contains a templates of possible issues user can use to open issue (such as if issue is related to documentation, if it's a bug, if user wants new feature etc) P.S. Take a look at tensorflow ISSUE_TEMPLATE\nPULL_REQUEST_TEMPLATE.md -> How to make a pull request to project\nstale.yml -> Probot configuration to close stale issues. There are many other apps on Github Marketplace that place their configurations inside .github folder because they are related to GitHub specifically.\nSECURITY.md -> How to responsibly report a security vulnerability in project\nworkflows -> Configuration folder containing yaml files for GitHub Actions\nCODEOWNERS -> Pull request reviewer rules. More info here.\ndependabot.yml -> Configuration options for dependency updates. More info here.\n\n\nYou don't have to create all these files immediately. If there are lot of bugs reported in your project, create ISSUE_TEMPLATE. If several people wants to support you, create FUNDING.yml . You will create more and more files when the need comes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "To get a prompt which indicates Git-branch in Zsh\nI run the following codes separately as my prompt unsuccessfully in .zshrc. This suggests me that apparently I do not have a program called __git_ps1. It is not in MacPorts.\n#1\nPROMPT=\"$(__git_ps1 \" \\[\\033[1;32m\\] (%s)\\[\\033[0m\\]\")\\$\"$\n\n#2\nPROMPT=\"$(__git_ps1 \" (%s)\")\\$\"$\n\n#3\n# Get the name of the branch we are on\ngit_prompt_info() {\n branch_prompt=$(__git_ps1)\n if [ -n \"$branch_prompt\" ]; then\n status_icon=$(git_status)\n echo $branch_prompt $status_icon\n fi\n}\n\n# Show character if changes are pending\ngit_status() {\n if current_git_status=$(git status | grep 'added to commit' 2> /dev/null); then\n echo \"☠\"\n fi\n}\nautoload -U colors\ncolors\nsetopt prompt_subst\nPROMPT='\n%~%{$fg_bold[black]%}$(git_prompt_info)\n→ %{$reset_color%}'\n\nHow can you get a prompt which shows the name of a Git-branch?"
},
{
"role": "assistant",
"content": "__git_ps1 is from git-completion.bash. In zsh you probably have to provide your own function to determine the current directories git branch. There are quite a few blog posts about a git prompt for zsh.\nYou just need:\n\na function to provide the branch name\nenable prompt (command) substitution\nadd the function to your prompt\n\nFor example\ngit_prompt() {\n ref=$(git symbolic-ref HEAD | cut -d'/' -f3)\n echo $ref\n}\nsetopt prompt_subst\nPS1=$(git_prompt)%#\nautoload -U promptinit\npromptinit\n\nUpdate: use the zsh vcs_info module instead of git_prompt()\nsetopt prompt_subst\nautoload -Uz vcs_info\nzstyle ':vcs_info:*' actionformats \\\n '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '\nzstyle ':vcs_info:*' formats \\\n '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '\nzstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'\n\nzstyle ':vcs_info:*' enable git cvs svn\n\n# or use pre_cmd, see man zshcontrib\nvcs_info_wrapper() {\n vcs_info\n if [ -n \"$vcs_info_msg_0_\" ]; then\n echo \"%{$fg[grey]%}${vcs_info_msg_0_}%{$reset_color%}$del\"\n fi\n}\nRPROMPT=$'$(vcs_info_wrapper)'"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitprotocol-capabilities"
},
{
"role": "assistant",
"content": "Protocol v0 and v1 capabilities"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Branch from a previous commit using Git\nIf I have an n number of commits, how can I create a branch from the n-3 commit?"
},
{
"role": "assistant",
"content": "Create the branch using a commit hash:\ngit branch branch_name <commit-hash>\n\nOr by using a symbolic reference:\ngit branch branch_name HEAD~3\n\nTo checkout the branch while creating it, use:\ngit checkout -b branch_name <commit-hash or HEAD~3>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitrepository-layout"
},
{
"role": "assistant",
"content": "Git Repository Layout"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "unable to click always allow on git-credential-osxkeychain popup\nRecently I've been getting a popup when pushing or pulling from upstream\ngit-credential-osxkeychain wants to use your confidential information stored in \"github.com\" in your keychain.\n\nThe authenticity of \"git-credential-osxkeychain\" cannot be verified. \nDo you want to allow access to this item?\n\nI click Always allow, but it doesn't do anything. The only button that works is Deny, and then I have to enter in my github username and pw. \nI used to be able to do all this automatically without this happening... how do I fix this?"
},
{
"role": "assistant",
"content": "You should enter password of your user(mac login password), but not git password."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I push to my fork from a clone of the original repo?\n\nI created a fork (let's call it myrepo) of another repository (let's call it orirepo) on GitHub. Later, I cloned orirepo.\ngit clone https://github.com/original/orirepo.git\n\nI modified about 20 files, then I staged my change and made a commit\ngit add\ngit commit\n\nHowever, when I tried to push\ngit push\n\nI got this error:\nremote: Permission to original/orirepo.git denied to mylogin.\nfatal: unable to access 'https://github.com/original/orirepo.git/': The requested URL returned error: 403\n\nI know I made a mistake: I should have cloned my fork rather than orirepo, but it's too late for that now.\nHow could I push to my fork rather than to origin/orirepo, which I don't have write access to?"
},
{
"role": "assistant",
"content": "By default, when you clone a repository\n\nthat resides at https://github.com/original/orirepo.git,\nwhose current branch is called master,\n\nthen\n\nthe local config of the resulting clone lists only one remote called origin, which is associated with the URL of the repository you cloned;\nthe local master branch in your clone is set to track origin/master.\n\nTherefore, if you don't modify the config of your clone, Git interprets\ngit push\n\nas\ngit push origin master:origin/master\n\nIn other words, git push attempts to push your local master branch to the master branch that resides on the remote repository (known by your clone as origin). However, you're not allowed to do that, because you don't have write access to that remote repository.\nYou need to\n\neither redefine the origin remote to be associated with your fork, by running\ngit remote set-url origin https://github.com/RemiB/myrepo.git\n\nor, if you want to preserve the original definition of the origin remote, define a new remote (called myrepo, here) that is associated to your fork:\ngit remote add myrepo https://github.com/RemiB/myrepo.git\n\nThen you should be able to push your local master branch to your fork by running\ngit push myrepo master\n\nAnd if you want to tell Git that git push should push to myrepo instead of origin from now on, you should run\ngit push -u myrepo master\n\n\ninstead."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to ask for CLA signature in merge requests on GitLab?\n\nI would like to publish a project under GPL license, but would like to request CLA (Contributor License Agreements) signing before accepting merge requests. \nGitHub has a few solutions which automate this (ClaHub, cla-assistant), however I can't find anything similar for GitLab. There is a long standing issue to add support for it natively, but it's been opened 2 years ago.\nI know Git sign-off can be used for DCO, but I am wondering if it could somehow be (ab)used for signing CLA agreements?\nIn short, how do I make the process of signing CLAs as painless as possible for both contributors and myself, while still making the agreements (somewhat) legally binding?\nEDIT: To the person who cast a vote for closing: I checked the guidelines again and it seems to me that the question falls squarely in software tools commonly used by programmers; and is a practical, answerable problem that is unique to software development. It also doesn't fall into exceptions listed, at least the way I understand them. That said, I would appreciate a comment about the reasons for the vote, so that I can formulate the question better or find a more suitable StackExchange site if needed."
},
{
"role": "assistant",
"content": "There is no official native support for CLA in GitLab for now.\nThe issue you are referencing is linked to issue 48118 (\"Stakeholder approval for merge requests\"), but itself is linked to two GitLab Enterprise issues -issues 1979 \"Multiple blocking merge request approval rules\" and issue 965 \"Upgrading approvals with approval chain\")\nSo for now, relying on a third-party service site remains the \"less painful\" solution.\nThat means, using the services highlighted in the original issue: CLAClub or cla-assistant.io.\nThe last one (cla-assistant) will, for a public registered repo (registered to cla-assistant) will:\n\nComments on each opened pull request to ask the contributor to sign the CLA\nAllows contributors to sign a CLA from within a pull request\nAuthenticates the signee with his or her GitHub account\nUpdates the status of a pull request when the contributor agrees to the CLA\nAutomatically asks users to re-sign the CLA for each new pull request in the event the associated Gist & CLA has changed\n\nNote: you can install and run your own instance of cla-assistant in order to store in your own private dedicated database the CLAs for your project.\nBut: since those services are tied to GitHub accounts, and there is no equivalent for GitLab, DCO should not be dismissed, especially in light of the Nov. 2017 GitLab blog post \"GitLab Transitions Contributor Licensing to Developer Certificate of Origin to Better Support Open Source Projects; Empower Contributors \"\n\nGitLab’s move away from a CLA is meant to modernize its code hosting and collaborative development infrastructure for all open source projects.\nAdditionally, requiring a CLA became problematic for developers who didn’t want to enter into legal terms; they weren’t reviewing the CLA contract and they effectively gave up their rights to own and contribute to open source code.\n\nAnd \"We're switching to a DCO for source code contributions\". When it comes to GitLab projects, a DCO like this one remains the chosen solution.\nSee the analysis comparing CLA and DCO.\n\nGitLab 15.5 (October 2022) prpose for non-free editions of GitLab:\n\nEnforce Developer Certificate of Origin on all contributions\nThe Developer Certificate of Origin (DCO) is a per-commit sign-off made by a contributor stating that they have the right to submit the code to the project. By signing off on a commit, the contributor agrees to the terms published at developercertificate.org.\nNow, you can easily enforce this Developer Certificate via a per-project setting to prevent contributors from contributing code that violates your license. When enabled, all new commits must include such a certificate of origin in the form of a line in the commit message Signed-off-by:.\n\nSee Documentation and Issue."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options protocol.<name>.allow"
},
{
"role": "assistant",
"content": "Set a policy to be used by protocol <name> with clone/fetch/push\ncommands. See protocol.allow above for the available policies. The protocol names currently used by git are: file : any local file-based path (including file:// URLs,\nor local paths) git : the anonymous git protocol over a direct TCP\nconnection (or proxy, if configured) ssh : git over ssh (including host:path syntax, ssh:// , etc). http : git over http, both \"smart http\" and \"dumb http\".\nNote that this does not include https ; if you want to configure\nboth, you must do so individually. any external helpers are named by their protocol (e.g., use hg to allow the git-remote-hg helper)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options i18n.logOutputEncoding"
},
{
"role": "assistant",
"content": "Character encoding the commit messages are converted to when\nrunning git log and friends."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitHub can't rebase my feature branch: \"This branch cannot be rebased due to conflicts\"\n\nEven when my feature branch was branched out from the latest version of main, when I attempt to rebase my PR (from feature X to main), I end up seeing:\nThis branch cannot be rebased due to conflicts\nRebasing the commits of this branch on top of the base branch cannot be performed automatically due to conflicts encountered while reapplying the individual commits from the head branch.\nI understand that this can be resolved by:\ngit checkout main\ngit rebase feature/x\n(resolve conflicts)\n\nHowever, direct pushing to main is locked and I need to go through a PR. What are the steps to successfully be able to rebase a feature/x branch to main through a pull request?"
},
{
"role": "assistant",
"content": "If you created the branch from main but you now need to rebase onto main then main must have been updated since you created your branch. The conflicts come from those changes.\n\nI understand that this can be resolved by:\ngit checkout main\ngit rebase feature/x\n(resolve conflicts)\n\n\nThis isn't correct. This would rebase main onto feature/x; you need to rebase feature/x onto main.\nInstead,\n\nupdate your local main from GitHub before the rebase by pulling it or similar,\ncheck feature/x out,\nrun git rebase main, and\nresolve conflicts.\n\nThen push your feature branch to GitHub (you'll need to use --force-with-lease since this rewrites commit hashes). The pull request will be updated accordingly."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Bash in Git for Windows: Weirdness when running a command with CMD.exe /C with args\nThis is more of an annoyance rather than a problem but I would very much like to understand the semantics here. \nAll I want to do is to run an arbitrary command on a temporary command-prompt session which itself running under a bash session. \nMy success rate is 50/50 as some command works as expected whereas others not so much. \nI think the problem may lie around arguments not lining up properly (i.e. missing or merged arguments)\nI'll try to explain what I mean by weird by a series of commands and responses. (I'm trying to get the word test to be printed on the screen.)\nI'm running these under GNU bash, version 3.1.0(1)-release (i686-pc-msys) Bundled with Git-1.8.4:\nFirst attempt:\n$ cmd /c echo test\nMicrosoft Windows [Version 6.1.7601]\nCopyright (c) 2009 Microsoft Corporation. All rights reserved.\nc:\\>\n\nSecond attempt:\n$ cmd '/c echo test'\ntest\"\n\nThird attempt:\n$ cmd \"/c echo test\"\ntest\"\n\nFourth attempt:\n$ cmd /c\\ echo\\ test\ntest\"\n\nFifth attempt:\n$ cmd \"/c echo\" test\n'echo\" test' is not recognized as an internal or external command,\noperable program or batch file.\n\nI'd really appreciate any pointers or insights into the behaviors above as this is unintuitional to me and driving me crazy!\nEdit:\nThere is another question that appears similar to this, but it really isn't, mainly because it's about running batch files through CMD /C that doesn't require any arguments. \nIt doesn't really answer my question about how to provide arguments properly to windows command line apps, and even though the examples are about CMD /C, the answer here can be applied to many other Windows command line apps as well."
},
{
"role": "assistant",
"content": "This is actually documented in the ReleaseNotes file (in the top level folder of your installed Git for Windows)\n\nAlso, extra care has to be paid to pass Windows programs Windows paths, as they have no clue about MSys style POSIX paths -- You can use something like $(cmd //c echo \"$POSIXPATH\").\n\nIf you use cmd //c echo test it works as expected.\n$ cmd //c echo test\ntest\n\nThe cause is to do with trying to ensure that posix paths end up being passed to the git utilities properly. For this reason, Git for Windows includes a modified MSYS layer that affects command arguments. You should note that it is not intended that the bash shell and tools provided with Git for Windows be used as general purpose unix tools for Windows. If you want a general purpose unix-style toolset then you should install MSYS or cygwin. The Git Bash shell is setup for working with git and sometimes that shows."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-am - Apply a series of patches from a mailbox --[no-]keep-cr"
},
{
"role": "assistant",
"content": "With --keep-cr , call git mailsplit (see git-mailsplit )\nwith the same option, to prevent it from stripping CR at the end of\nlines. am.keepcr configuration variable can be used to specify the\ndefault behaviour. --no-keep-cr is useful to override am.keepcr ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to get total additions and deletions on a given branch for an given author in git\nIs there a way in git to count the total deletions and additions for a given user on a given branch? Something like that is on github, in the graph section there is a chart that shows you the total additions and deletions but only on the master branch... i think if they did it this mus be possible in git also, so, does someone know how to do that?\nThank you in advance."
},
{
"role": "assistant",
"content": "I don't think Git has any built-in command that does this. But with the help of some other standard utilities, it can be done. Here is an example that filters Git's log output through awk to get the summary of total insertions and deletions:\ngit log --author=$USER --shortstat $BRANCH | \\\nawk '/^ [0-9]/ { f += $1; i += $4; d += $6 } \\\nEND { printf(\"%d files changed, %d insertions(+), %d deletions(-)\", f, i, d) }'"
}
] |