messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-patch-id"
},
{
"role": "assistant",
"content": "Compute unique ID for a patch"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-svn - Bidirectional operation between a Subversion repository and Git --show-commit"
},
{
"role": "assistant",
"content": "shows the Git commit sha1, as well"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --default-prefix"
},
{
"role": "assistant",
"content": "Use the default source and destination prefixes (\"a/\" and \"b/\").\nThis overrides configuration variables such as diff.noprefix , diff.srcPrefix , diff.dstPrefix , and diff.mnemonicPrefix (see git-config (1))."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to pull a remote branch locally?\n\nI created a project on Gitlab and cloned it on my computer. So I only have one branch (master) locally (git branch only shows master). A colleague created a new branch. So now there are 2 branches on Gitlab but not on my computer.\nHow do I do to have the branch created by my co-worker on my computer too so as git branch shows both master and new-branch ?\nThank you."
},
{
"role": "assistant",
"content": "First, update your remote-tracking branches (local replicas of the remote branches, with which you can't interact in the same way you do with your own local branches). It's typically done with\ngit fetch\n\n(without any parameters, --all is implied)\nYour local repo will then know every new branch your coworker could have created since you last fetched (or pulled, since a pull does a fetch as a first step).\nThen you'll be able to create a local counterpart for any of these remote branches with\ngit checkout <branchName>\n\nHere, note that <branchName> is meant to be given without the <remote>/ prefix, or else git will attempt to check out the so-named remote-tracking branch, which it can't, by design. At this point it will then resolve the branch ref to the commit which this remote-tracking branch points to, check this commit out directly, resulting in a detached HEAD state. (which is no big deal but can unsettle people starting to use git)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Squash the first two commits in Git? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nCombine the first two commits of a Git repository?\n\n (9 answers)\n \n\nClosed 9 years ago.\n\n\n\nWith git rebase --interactive <commit> you can squash any number of commits together into a single one.\nThat's all great unless you want to squash commits into the initial commit. That seems impossible to do.\nAre there any ways to achieve it?\n\nModerately related:\nIn a related question, I managed to come up with a different approach to the need of squashing against the first commit, which is, well, to make it the second one.\nIf you're interested: git: how to insert a commit as the first, shifting all the others?"
},
{
"role": "assistant",
"content": "Update July 2012 (git 1.7.12+)\nYou now can rebase all commits up to root, and select the second commit Y to be squashed with the first X.\ngit rebase -i --root master\n\npick sha1 X\nsquash sha1 Y\npick sha1 Z\n\n\ngit rebase [-i] --root $tip\n\nThis command can now be used to rewrite all the history leading from \"$tip\" down to the root commit.\n\nSee commit df5df20c13 (rebase -i: support --root without --onto, 2012-06-26) on GitHub from Chris Webb (arachsys).\nAs noted in the comments, a git push --force-with-lease (safer than --force, as Mikko Mantalainen reminds us) would be needed after any rebase operation, if you need to publish that rework in a remote repository.\n\nOriginal answer (February 2009)\nI believe you will find different recipes for that in the SO question \"How do I combine the first two commits of a git repository?\"\nCharles Bailey provided there the most detailed answer, reminding us that a commit is a full tree (not just diffs from a previous states).\nAnd here the old commit (the \"initial commit\") and the new commit (result of the squashing) will have no common ancestor.\nThat mean you can not \"commit --amend\" the initial commit into new one, and then rebase onto the new initial commit the history of the previous initial commit (lots of conflicts)\n(That last sentence is no longer true with git rebase -i --root <aBranch>)\nRather (with A the original \"initial commit\", and B a subsequent commit needed to be squashed into the initial one):\n\nGo back to the last commit that we want to form the initial commit (detach HEAD):\ngit checkout <sha1_for_B>\n\n\nReset the branch pointer to the initial commit, but leaving the index and working tree intact:\ngit reset --soft <sha1_for_A>\n\n\nAmend the initial tree using the tree from 'B':\ngit commit --amend\n\n\nTemporarily tag this new initial commit (or you could remember the new commit sha1 manually):\ngit tag tmp\n\n\nGo back to the original branch (assume master for this example):\ngit checkout master\n\n\nReplay all the commits after B onto the new initial commit:\ngit rebase --onto tmp <sha1_for_B>\n\n\nRemove the temporary tag:\ngit tag -d tmp\n\n\n\nThat way, the \"rebase --onto\" does not introduce conflicts during the merge, since it rebases history made after the last commit (B) to be squashed into the initial one (which was A) to tmp (representing the squashed new initial commit): trivial fast-forward merges only.\nThat works for \"A-B\", but also \"A-...-...-...-B\" (any number of commits can be squashed into the initial one this way)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-send-email - Send a collection of patches as emails sendemail.smtpBatchSize"
},
{
"role": "assistant",
"content": "Number of messages to be sent per connection, after that a relogin\nwill happen. If the value is 0 or undefined, send all messages in\none connection.\nSee also the --batch-size option of git-send-email ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options pushNonFFCurrent"
},
{
"role": "assistant",
"content": "Shown when git-push fails due to a\nnon-fast-forward update to the current branch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission -O<orderfile>"
},
{
"role": "assistant",
"content": "Control the order in which files appear in the output.\nThis overrides the diff.orderFile configuration variable\n(see git-config ). To cancel diff.orderFile ,\nuse -O/dev/null . The output order is determined by the order of glob patterns in\n<orderfile>.\nAll files with pathnames that match the first pattern are output\nfirst, all files with pathnames that match the second pattern (but not\nthe first) are output next, and so on.\nAll files with pathnames that do not match any pattern are output\nlast, as if there was an implicit match-all pattern at the end of the\nfile.\nIf multiple pathnames have the same rank (they match the same pattern\nbut no earlier patterns), their output order relative to each other is\nthe normal order. <orderfile> is parsed as follows: Blank lines are ignored, so they can be used as separators for\nreadability. Lines starting with a hash (\" # \") are ignored, so they can be used\nfor comments. Add a backslash (\" \\ \") to the beginning of the\npattern if it starts with a hash. Each other line contains a single pattern. Patterns have the same syntax and semantics as patterns used for\nfnmatch(3) without the FNM_PATHNAME flag, except a pathname also\nmatches a pattern if removing any number of the final pathname\ncomponents matches the pattern. For example, the pattern \" foo*bar \"\nmatches \" fooasdfbar \" and \" foo/bar/baz/asdf \" but not \" foobarx \"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to print from GitHub\n\nIf I want to print a markdown file from GitHub as it appears on screen, for example:\nhttps://github.com/RestKit/RestKit/blob/master/Docs/Object%20Mapping.md\nThen how can I accomplish that? What code do I need to change in the resulting github html page (that I save) such that the printout will honor the look & feel of the markdown?\nSo far the only clue I have is this one:\nhttps://makandracards.com/makandra/4947-how-to-print-github-wiki-pages\nBut it is more of a utilitarian (non-programmatic) workaround which doesn't really work because the markdown interpreter in use isn't as forgiving as the one running on the GitHub websites so it fumbles."
},
{
"role": "assistant",
"content": "Here is a bookmarklet that works for me:\n\nCopy the contents of the bookmarklet Gist, reproduced below as a backup.\nCreate a new bookmark in the toolbar of your browser, give it a fitting name.\nPut that one line of code in the URL field.\n\nIf you now go to a Markdown page on Github and click the bookmark it will reformat the page and change the CSS so that it looks the same as on screen when you print. It will also automaticaly trigger the printing dialog to pop up.\nBookmarklet contents:\njavascript:document.body.appendChild(document.querySelector(\"#readme\"));document.querySelector(\"header\").remove();document.querySelector(\".application-main\").remove();document.querySelector(\"footer\").remove();window.print();"
}
] |
[
{
"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 blame.ignoreRevsFile"
},
{
"role": "assistant",
"content": "Ignore revisions listed in the file, one unabbreviated object name per\nline, in git-blame . Whitespace and comments beginning with # are ignored. This option may be repeated multiple times. Empty\nfile names will reset the list of ignored revisions. This option will\nbe handled before the command line option --ignore-revs-file ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker <tree>"
},
{
"role": "assistant",
"content": "Indicates a tree object name."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: Merge in only one commit\nUsually, I work with branches in Git, but I don't like to see hundreds of branches in my working tree (Git history). I'm wondering if there is a method in Git to \"join\" all commits in a branch in only one commit (ideally with a clear commit message).\nSomething like this:\ngit checkout -b branch\n<some work>\ngit commit -a -m \"commit 1\"\n<some work>\ngit commit -a -m \"commit 2\"\n<some work>\ngit commit -a -m \"commit 3\"\ngit checkout master\ngit SUPER-JOIN branch -m \"super commit\"\n\nAfter this, only \"super commit\" will exist in the git log."
},
{
"role": "assistant",
"content": "It sounds like you're looking for the --squash option of git-merge:\ngit checkout master\ngit merge --squash branch -m \"super commit\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options branch.autoSetupMerge"
},
{
"role": "assistant",
"content": "Tells git branch , git switch and git checkout to set up new branches\nso that git-pull will appropriately merge from the\nstarting point branch. Note that even if this option is not set,\nthis behavior can be chosen per-branch using the --track and --no-track options. The valid settings are: false — no\nautomatic setup is done; true — automatic setup is done when the\nstarting point is a remote-tracking branch; always — automatic setup is done when the starting point is either a\nlocal branch or remote-tracking branch; inherit — if the starting point\nhas a tracking configuration, it is copied to the new\nbranch; simple — automatic setup is done only when the starting point\nis a remote-tracking branch and the new branch has the same name as the\nremote branch. This option defaults to true."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-repack"
},
{
"role": "assistant",
"content": "Pack unpacked objects in a repository"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-daemon - A really simple server for Git repositories upload-pack"
},
{
"role": "assistant",
"content": "This serves git fetch-pack and git ls-remote clients. It is enabled by default, but a repository can\ndisable it by setting daemon.uploadpack configuration\nitem to false ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Jenkins could not run git\nI've installed Jenkins on my mac (osx lion). But I couldn't get it work. This is the stacktrace I've got:\nStarted by user anonymous\n\nCheckout:workspace / /Users/Shared/Jenkins/Home/jobs/test/workspace - hudson.remoting.LocalChannel@1c0a0847\nUsing strategy: Default\nCheckout:workspace / /Users/Shared/Jenkins/Home/jobs/test/workspace - hudson.remoting.LocalChannel@1c0a0847\nCloning the remote Git repository\nCloning repository origin\nError trying to determine the git version: Error performing command: /usr/local/git/ --version\nCannot run program \"/usr/local/git/\" (in directory \"/Users/Shared/Jenkins/Home/jobs/test/workspace\"): error=13, Permission denied\nAssuming 1.6\nERROR: Error cloning remote repo 'origin' : Could not clone [email protected]:iRest.git\nERROR: Cause: Error performing command: /usr/local/git/ clone -o origin [email protected]:iRest.git /Users/Shared/Jenkins/Home/jobs/test/workspace\nCannot run program \"/usr/local/git/\": error=13, Permission denied\nTrying next repository\nERROR: Could not clone repository\nFATAL: Could not clone\nhudson.plugins.git.GitException: Could not clone\n at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1046)\n at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:972)\n at hudson.FilePath.act(FilePath.java:783)\n at hudson.FilePath.act(FilePath.java:765)\n at hudson.plugins.git.GitSCM.checkout(GitSCM.java:972)\n at hudson.model.AbstractProject.checkout(AbstractProject.java:1195)\n at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:571)\n at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:460)\n at hudson.model.Run.run(Run.java:1404)\n at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)\n at hudson.model.ResourceController.execute(ResourceController.java:88)\n at hudson.model.Executor.run(Executor.java:238)"
},
{
"role": "assistant",
"content": "The solution for me was to set the git path in the Manage Jenkins > Global Tool Configuration settings. In the Git section, I changed the Path to Git executable to /usr/local/bin/git."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-patch-id"
},
{
"role": "assistant",
"content": "Compute unique ID for a patch"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to make git log not prompt to continue?\nI have a couple of git repositories that belong together, and simple batch/bash file to loop over them. I often loop over them with a log command to quickly see what state they are in. This works nicely, except for one thing: if the commit message is longer than the number of characters my console is wide (or has multiple lines), git shows the line, then a newline with (END) and I have to press q to continue (I guess it pipes the output through more or something like that).\nExample:\n> gitloop . \"git log --decorate=short --pretty=oneline -n1\"\n18629ae238e9d5832cb3535ec88274173337a501 (HEAD, origin/master, master) short log\n\n625fb891b9b0b8648459b07ace662ae3b7773c7f (HEAD, origin/master, origin/HEAD, master) short log\n\ndc0838118266ba8570ea338c1faddfe8af0387bb (HEAD, origin/work, origin/master, work, master) oops loooooooooooooong log\n-(END)\n\nThis is rather inconvenient as I have to press q a couple of time, whereas I'd just like to see all those oneliners in one go.\nHow can I disable this behaviour (preferrably while still keeping this log format)?"
},
{
"role": "assistant",
"content": "Git has an option to disable the pager:\ngit --no-pager log --decorate=short --pretty=oneline -n1\n\nIf your pager cuts lines and you want to retain that behaviour, either pipe to cut...\ngit --no-pager log --decorate=short --pretty=oneline -n1 | cut -c 1-$COLUMNS\n\n...or set the environment variable GIT_PAGER before the invocation:\nGIT_PAGER=\"cut -c 1-${COLUMNS-80}\" git log --decorate=short --pretty=oneline -n1"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Delete commit on gitlab\n\nHow can I delete a commit that I made on GitLab? This commit that I made is not the HEAD now. \nIf I can't delete it, can I edit? \nWhen it was the HEAD, I tried:\ngit reset --soft HEAD\n\ngit reset --soft HEAD^1\n\ngit revert HEAD\n\ngit rebase -i HEAD\n\ngit rebase -i HEAD~1\n\ngit reset --hard HEAD\n\ngit reset --hard Id-Code\n\nI already tried to rebase it, but it still stays on the branch. Now I just removed it from the HEAD, but it is still there.\nThere is another command?"
},
{
"role": "assistant",
"content": "git reset --hard CommitId\ngit push -f origin master\n\n1st command will rest your head to commitid and 2nd command will delete all commit after that commit id on master branch.\n\nNote: Don't forget to add -f in push otherwise it will be rejected."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitHub access token with read-only access to private repositories\n\nI have a project with a Node dependency on a private Git repository. I need to be able to run npm install without being prompted to enter a password or allow an SSH connection, so I'm using an access token that I created on GitHub in my package.json:\n \"dependencies\": {\n \"sass-theme\": \"git+https://[token]:[email protected]/MyOrg/sass-theme.git#v1.0.2\",\n \"node-sass\": \"^4.5.0\"\n }\n\nThis project is shared with dozens of other people, so obviously I don't want to keep my token in source control. I know I can create a read-only deployment key on GitHub, but I believe that would require other developers to import the SSH key to build the project locally.\nIs it possible to create an access token that can be shared but that has read-only access to clone the repository?"
},
{
"role": "assistant",
"content": "The most straightforward way I can think of to create a token that provides read-only access to a private repo is to:\n\nHave a user who has read-only access to the given private repo\n(and ideally, not much else)\nAs that user create a Personal Access Token with the \"repo\" scope\n\nIt would be best if they didn't have access to other orgs/repos, since the \"repo\" scope grants the user total control over any repos that user has write access to.\nI know in an Enterprise solution we would do that with a System ID, but on GitHub you can instead create a Machine User."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-add - Add file contents to the index <pathspec>…"
},
{
"role": "assistant",
"content": "Files to add content from. Fileglobs (e.g. *.c ) can\nbe given to add all matching files. Also a\nleading directory name (e.g. dir to add dir/file1 and dir/file2 ) can be given to update the index to\nmatch the current state of the directory as a whole (e.g.\nspecifying dir will record not just a file dir/file1 modified in the working tree, a file dir/file2 added to\nthe working tree, but also a file dir/file3 removed from\nthe working tree). Note that older versions of Git used\nto ignore removed files; use --no-all option if you want\nto add modified or new files but ignore removed ones. For more details about the <pathspec> syntax, see the pathspec entry\nin gitglossary ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git bash questions\ni just downloaded msysgit from http://msysgit.github.com/ and am trying to learn how to use it. i also downloaded a copy of the pro git manual from their wiki. \nIn chapter 2 it talks about typing \"$ git init\" in the project directory to have the system create a .git folder. \ni'm just new at unix / linux so you'll have to excuse the simple questions. \nlets say my project folder is located at : \nc:\\myapp\\abc\nand that's where i want to run the git init command \ni'm not sure how i can change directories into the project folder. \nwhen i do an \"ls\" command from where i'm at, i can tell by the contents in the folder that i'm actually in C:\\Program Files (x86)\\Git. i've tried \"cd /myapp/abc\" but it just gives me the message \" no such file or directory\".\ni feel like i'm missing something really basic here.\nmy prompt when i open git bash is: \n$myname@mypcname /\nmaybe i just need a bash tutorial? \nI've also been playing around with the GIT GUI and i was able to create a new repo in another project folder a but i'd like to be able to follow the manual, which for now, seems to be working the git bash tool \nthanks."
},
{
"role": "assistant",
"content": "The \"Git Bash\" terminal will put the root of each drive in /<drive-letter>, so drive C:\\ will be at /c/, drive E:\\ will be at /e/, etc. Try cd /c/myapp/abc."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options maintenance.loose-objects.auto"
},
{
"role": "assistant",
"content": "This integer config option controls how often the loose-objects task\nshould be run as part of git maintenance run --auto . If zero, then\nthe loose-objects task will not run with the --auto option. A\nnegative value will force the task to run every time. Otherwise, a\npositive value implies the command should run when the number of\nloose objects is at least the value of maintenance.loose-objects.auto .\nThe default value is 100."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is Pseudo TTY-Allocation? (SSH and Github)\n\nI was trying to setup an SSH connection with Github following this tutorial:\n\nTesting your SSH connection\n\nI came across the following command:\n$ ssh -T [email protected] \n# Attempts to ssh to github\n\nCurious, I looked at the ssh manual. It said the following:\n -T Disable pseudo-tty allocation.\n\nWhat is tty allocation? What does tty stand for? Why are we disabling it?I earnestly tried to look it up but I was unable to find even a definition."
},
{
"role": "assistant",
"content": "As explained in \"gitolite: PTY allocation request failed on channel 0\", it is important to do ssh test connection with -T, because some server could abort the transaction entirely if a text-terminal (tty) is requested.\n-T avoids requesting said terminal, since GitHub has no intention of giving you an interactive secure shell, where you could type command. \nGitHub only wants to reply to your ssh request, in order to ascertain that the ssh command does work (you have the right public/private keys, and the public one has been registered to your GitHub account)\nPuTTy would be an example of a terminal emulator, serial console and network file transfer application. It supports several network protocols, including SCP, SSH, Telnet and rlogin.\nThe name \"PuTTY\" has no definitive meaning, though \"tty\" is the name for a terminal in the Unix tradition, usually held to be short for Teletype.\n\nOther use-cases for -T (beside testing)\n\nTransferring binary files\nExecute commands on a remote server\nSSH tunneling: ssh -fnT -L port:server:port user@server (-f for background: you don't want to execute command, don't need a TTY and just want to establish a tunnel)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs dense-combined, cc"
},
{
"role": "assistant",
"content": "Further compress output produced by --diff-merges=combined by omitting uninteresting hunks whose contents in the parents\nhave only two variants and the merge result picks one of them\nwithout modification."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker <old|new>-file"
},
{
"role": "assistant",
"content": "are files GIT_EXTERNAL_DIFF can use to read the\ncontents of <old|new>,"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options maintenance.<task>.enabled"
},
{
"role": "assistant",
"content": "This boolean config option controls whether the maintenance task\nwith name <task> is run when no --task option is specified to git maintenance run . These config values are ignored if a --task option exists. By default, only maintenance.gc.enabled is true."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git authentication fails after enabling 2FA\nI just enabled 2FA (I can't think of any other changes I made) and git asked for my username and password. I provided both, but they were \"wrong\". I tried many of the solutions here: Git push requires username and password but that didn't work. In particular, when switching from https to ssh, the ssh key gives \nPermission denied (publickey).\nfatal: Could not read from remote repository.\n$ git push\nwarning: push.default is unset; its implicit value is changing in\nGit 2.0 from 'matching' to 'simple'. To squelch this message\nand maintain the current behavior after the default changes, use:\n\n git config --global push.default matching\n\nTo squelch this message and adopt the new behavior now, use:\n\n git config --global push.default simple\n\nSee 'git help config' and search for 'push.default' for further information.\n(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode\n'current' instead of 'simple' if you sometimes use older versions of Git)\n\nUsername for 'https://github.com': **********\nPassword for 'https://[email protected]': \nremote: Invalid username or password.\nfatal: Authentication failed for 'https://github.com/mlbileschi/scala.git/'\n\nAny tips?"
},
{
"role": "assistant",
"content": "You need to generate an access token. You can create one by going to your settings page.\n\nUse this access token as your password in the command line."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I get content of a file from git index?\nI have a file which has been already added to my local repository. I've modified it in the working tree, so git status shows me the file as modified. I would like to know what is the file content kept in the index before I stage the file.\nI can think of two ways of doing that:\n\nrevert a patch generated by git diff, and apply it on the file in the working tree\nuse git checkout-index, point to a temporary file and read the content from there\n\nIs there an easier way?"
},
{
"role": "assistant",
"content": "Use the : prefix to access objects in the current index (staged but not yet commited).\ngit show :file\n\nSee the gitrevisions manual for more information."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-submodule - Initialize, update or inspect submodules --rebase"
},
{
"role": "assistant",
"content": "This option is only valid for the update command.\nRebase the current branch onto the commit recorded in the\nsuperproject. If this option is given, the submodule’s HEAD will not\nbe detached. If a merge failure prevents this process, you will have\nto resolve these failures with git-rebase .\nIf the key submodule.$name.update is set to rebase , this option is\nimplicit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Finding total contributions of a user from GitHub API\n\nI am trying to extract the below info for any user from GitHub.\n\nIs there a way/API exposed in GitHub REST API where we can get this information directly?"
},
{
"role": "assistant",
"content": "Answers for 2019, Use GitHub API V4.\nFirst go to GitHub to apply for a token: https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line. step 7, scopes select only read:user\ncUrl\ncurl -H \"Authorization: bearer token\" -X POST -d '{\"query\":\"query {\\n user(login: \\\"MeiK2333\\\") {\\n name\\n contributionsCollection {\\n contributionCalendar {\\n colors\\n totalContributions\\n weeks {\\n contributionDays {\\n color\\n contributionCount\\n date\\n weekday\\n }\\n firstDay\\n }\\n }\\n }\\n }\\n}\"}' https://api.github.com/graphql\n\nJavaScript\nasync function getContributions(token, username) {\n const headers = {\n 'Authorization': `bearer ${token}`,\n }\n const body = {\n \"query\": `query {\n user(login: \"${username}\") {\n name\n contributionsCollection {\n contributionCalendar {\n colors\n totalContributions\n weeks {\n contributionDays {\n color\n contributionCount\n date\n weekday\n }\n firstDay\n }\n }\n }\n }\n }`\n }\n const response = await fetch('https://api.github.com/graphql', { method: 'POST', body: JSON.stringify(body), headers: headers })\n const data = await response.json()\n return data\n}\n\nconst data = await getContributions('token', 'MeiK2333')\nconsole.log(data)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to clone seed/kick-start project without the whole history?\nNote that using --depth=1 parameter prevents you from pushing the project to a new repository."
},
{
"role": "assistant",
"content": "You can do a\ngit clone <git_url>\n\ndelete the .git repository from your folder. Which will delete all your history.\nThe you can do a\ngit init \n\nwhich will create an entirely new git project for you.\nThis may not be the best way. But this will work. Hope it helps."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --name-status"
},
{
"role": "assistant",
"content": "Show only names and status of changed files. See the description\nof the --diff-filter option on what the status letters mean.\nJust like --name-only the file names are often encoded in UTF-8."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-init - Create an empty Git repository or reinitialize an existing one init.defaultBranch"
},
{
"role": "assistant",
"content": "Allows overriding the default branch name e.g. when initializing\na new repository."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How Do I 'git fetch' and 'git merge' from a Remote Tracking Branch (like 'git pull')\nI have set up some remote tracking branches in git, but I never seem to be able to merge them into the local branch once I have updated them with 'git fetch'.\nFor example, suppose I have remote branch called 'an-other-branch'. I set that up locally as a tracking branch using\ngit branch --track an-other-branch origin/an-other-branch\n\nSo far, so good. But if that branch gets updated (usually by me moving machine and commiting from that machine), and I want to update it on the original machine, I'm running into trouble with fetch/merge:\ngit fetch origin an-other-branch\ngit merge origin/an-other-branch\n\nWhenever I do this, I get an 'Already up-to-date' message and nothing merges.\nHowever, a\ngit pull origin an-other-branch\n\nalways updates it like you would expect.\nAlso, running git diff\ngit diff origin/an-other-branch\n\nshows that there are differences, so I think I have my syntax wrong.\nWhat am I doing wrong?\nEDIT [2010-04-09]: I have checked a couple of times, and I'm definitely not on a different branch. Should my 'git fetch' followed by a 'git merge' (as shown above) do the exact same thing as a git pull? I will get some workflow showing the results of a git status etc."
},
{
"role": "assistant",
"content": "You don't fetch a branch, you fetch an entire remote:\ngit fetch origin\ngit merge origin/an-other-branch"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options pack.deltaCacheLimit"
},
{
"role": "assistant",
"content": "The maximum size of a delta, that is cached in git-pack-objects . This cache is used to speed up the\nwriting object phase by not having to recompute the final delta\nresult once the best match for all objects is found.\nDefaults to 1000. Maximum value is 65535."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-help - Display help information about Git -i --info"
},
{
"role": "assistant",
"content": "Display manual page for the command in the info format. The info program will be used for that purpose."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to cancel previous runs in the PR when you push new commits(update the current) in github-actions\nWhen I push my commits to a PR my tests are triggered for this commit. After that, if I push additional commits to this PR, tests in Github Actions runs on both commits.\nI need to cancel the previous run and run only on the most recent pushed commit.\nHow can I configure my yaml file to achieve that?"
},
{
"role": "assistant",
"content": "To cancel a currently running workflow from the same PR, branch or tag when a new workflow is triggered you can use:\nname: Workflow X\n\non: # ...\n\nconcurrency:\n group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}\n cancel-in-progress: true\n\njobs: # ...\n\nExplanation:\n\n${{ github.workflow }}: the workflow name is used to generate the concurrency group (e.g. Workflow 1). That allows you to have more than one different workflow (eg. workflow1.yaml and workflow2.yaml) triggered on the same event (e.g. a PR). Otherwise, workflow1.yaml would cancel workflow2.yaml or viceversa.\n${{ github.event.pull_request.number: when the trigger event is a PR, it will use the PR number to generate the concurrency group (e.g. workflow1-33).\n|| github.ref }}: when the trigger is not a PR but a push, it will use the branch or tag name to generate the concurrency group (e.g. workflow1-branch1).\ncancel-in-progress: true: if cancel-in-progress is omitted or set to false, when a new workflow is triggered, the currently running workflow won't be cancelled, and the new workflow will be queued pending until the previous one is done.\n\nRef: https://docs.github.com/en/actions/using-jobs/using-concurrency"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I get the current branch name in Git?\nHow do I get the name of the current branch in Git?"
},
{
"role": "assistant",
"content": "To display only the name of the current branch you're on:\ngit rev-parse --abbrev-ref HEAD\n\nReference: Show just the current branch in Git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary tag object"
},
{
"role": "assistant",
"content": "An object containing a ref pointing to\nanother object, which can contain a message just like a commit object . It can also contain a (PGP)\nsignature, in which case it is called a \"signed tag object\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-submodule - Initialize, update or inspect submodules set-branch (-b|--branch) <branch> [--] <path> set-branch (-d|--default) [--] <path>"
},
{
"role": "assistant",
"content": "Sets the default remote tracking branch for the submodule. The --branch option allows the remote branch to be specified. The --default option removes the submodule.<name>.branch configuration\nkey, which causes the tracking branch to default to the remote HEAD ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.mnemonicPrefix"
},
{
"role": "assistant",
"content": "If set, git diff uses a prefix pair that is different from the\nstandard \"a/\" and \"b/\" depending on what is being compared. When\nthis configuration is in effect, reverse diff output also swaps\nthe order of the prefixes: git diff compares the (i)ndex and the (w)ork tree; git diff HEAD compares a (c)ommit and the (w)ork tree; git diff --cached compares a (c)ommit and the (i)ndex; git diff HEAD:file1 file2 compares an (o)bject and a (w)ork tree entity; git diff --no-index a b compares two non-git things (1) and (2)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "autosetuprebase vs autosetupmerge\nI was just knocking around in my global .gitconfig file and I noticed that I've managed to end up with this:\n[branch]\n autosetupmerge = always\n autosetuprebase = always\n\nThat seemed more than a little counterintuitive, but after doing some reading, I still have no idea whether I need both or whether it's sufficient to remove autosetupmerge and just retain autosetuprebase. Most projects that I'm working have a straight downstream->upstream flow, so rebasing is generally preferred when dealing with branches."
},
{
"role": "assistant",
"content": "What is counterintuitive here is the naming of these preferences. They do look like they refer to the same functionality, but in fact they don't:\n\nautosetupmerge controls whether git branch and git checkout -b imply the --track option, i.e. with your setting of always,\n\ngit checkout branchname, if branchname exists on a remote but not locally, will create branchname tracking its remote counterpart\ngit checkout -b newbranch will create a new branch newbranch tracking whichever branch you had checked out before issuing this command\n\nautosetuprebase controls whether new branches should be set up to be rebased upon git pull, i.e. your setting of always will result in branches being set up such that git pull always performs a rebase, not a merge. (Be aware that existing branches retain their configuration when you change this option.)\n\nSo it makes perfect sense to have both autosetupmerge = always and autosetuprebase = always; in fact, that's also what I have."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Error : 'upstream' does not appear to be a git repository\n\nI'm very new to Git, so facing some issues with it correct usage.\nHere is my scenario.\nI have a fork of my master repository and cloned it into my local.\nIn that, I have 2 branches for different fixes.\nWhen I commit, I saw a statement in the git-we saying that I'm 3 commits ahead and around 20 commits behind.\nI understand that my fork is not in sync with master. Also I need to merge the two branches too (or should i do it?)\nI used the windows client to syncing. But seems I'm not following the Git way. So, I tried to follow the steps described in https://help.github.com/articles/syncing-a-fork/ which is giving me an error as follows (I'm using windows).\n $>git fetch upstream\n fatal: 'upstream' does not appear to be a git repository\n fatal: Could not read from remote repository.\n\n Please make sure you have the correct access rights\n and the repository exists.\n\nI'm a bit confused.\nPlease help me with steps I should follow in this scenario.\n@HuStmpHrrr\nSorry for adding the details in comments\nI'll modify the question for readability\nBy executing the command:\n $>git remote returning two values\n acme-development (which the name of my actual/main repository, from where I forked) and\n origin\n\n\nAdding some more info.\n\nAfter making a fetch, I tried a origin/master merge on to my master\nPlease see the screenshot\n\nBut, if I login to my Github online account, it is saying a different story.\n\nMy git client says that the local repo is up to date.\nBut the online git says that we are 42 commits behind and 7 commits ahead."
},
{
"role": "assistant",
"content": "The article you link to (though it may have changed since you asked) starts with a reference to https://help.github.com/articles/configuring-a-remote-for-a-fork/. If you complete this you will have a new remote repository named upstream pointing to the original repository which you forked, and git fetch upstream will work."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs git log -3"
},
{
"role": "assistant",
"content": "Limits the number of commits to show to 3."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to prevent Dockerfile caching git clone\nI have a Dockerfile trying to package and deploy a web app to a container. The code of app fetches from git repository during Docker image building.\nHere's the Dockerfile snapshot:\n........\nRUN git clone --depth=1 git-repository-url $GIT_HOME/\nRUN mvn package -Dmaven.test.skip\n........\n\nI want the docker do not cache the step of RUN git clone --depth=1 git-repository-url $GIT_HOME/ so that the on-going updated on the the repository can be reflected on the Docker image building. Is it possible to a achieve that?"
},
{
"role": "assistant",
"content": "Another workaround:\nIf you use GitHub (or gitlab or bitbucket too most likely) you can ADD the GitHub API's representation of your repo to a dummy location.\nADD https://api.github.com/repos/$USER/$REPO/git/refs/heads/$BRANCH version.json\nRUN git clone -b $BRANCH https://github.com/$USER/$REPO.git $GIT_HOME/\n\nThe API call will return different results when the head changes, invalidating the docker cache.\nIf you're dealing with private repos you can use github's x-oauth-basic authentication scheme with a personal access token like so:\nADD https://$ACCESS_TOKEN:[email protected]/repos/$USER/$REPO/git/refs/heads/$BRANCH version.json\n\n(thx @captnolimar for a suggested edit to clarify authentication)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitlab issue types and how to create new ones\n\nOk, i'm using Giltab and noticed this\n\nthen found and read this docs about issue types.\nWhat it looks like is that i can use real issue types instead labels to identify an issue as a (e.g.) bug, a proposal, a enhancement, a new feature request, etc, but i connot understand if i can create new issue types.\nIs there anyone who managed to used this feature?"
},
{
"role": "assistant",
"content": "Good question, I too was interested in taking this approach.\nFrom doing some digging, it appears that the Type was just introduced so that Incidents can also be tracked alongside Issues. So it is not currently possible to create a Type such as \"Bug\", \"Feature\", etc like you might do in other tools like Jira. You still need to use labels for categorizing your issues."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options include.path includeIf.<condition>.path"
},
{
"role": "assistant",
"content": "Special variables to include other configuration files. See\nthe \"CONFIGURATION FILE\" section in the main git-config documentation,\nspecifically the \"Includes\" and \"Conditional Includes\" subsections."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git diff -w ignore whitespace only at start & end of lines\nI love to use git diff -w to ignore whitespace differences. But, I just noticed that it ignores even whitespace differences in the middle of lines. How could I only ignore whitespace differences that come at the start (^) or end ($) of lines?"
},
{
"role": "assistant",
"content": "For end of line use:\ngit diff --ignore-space-at-eol\n\nInstead of what are you using currently:\ngit diff -w (--ignore-all-space)\n\nFor start of line... you are out of luck if you want a built in solution.\nHowever, if you don't mind getting your hands dirty there's a rather old patch floating out there somewhere that adds support for \"--ignore-space-at-sol\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary cherry-picking"
},
{
"role": "assistant",
"content": "In SCM jargon, \"cherry pick\" means to choose a subset of\nchanges out of a series of changes (typically commits) and record them\nas a new series of changes on top of a different codebase. In Git, this is\nperformed by the \"git cherry-pick\" command to extract the change introduced\nby an existing commit and to record it based on the tip\nof the current branch as a new commit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --stat[=<width>[,<name-width>[,<count>]]]"
},
{
"role": "assistant",
"content": "Generate a diffstat. By default, as much space as necessary\nwill be used for the filename part, and the rest for the graph\npart. Maximum width defaults to terminal width, or 80 columns\nif not connected to a terminal, and can be overridden by <width> . The width of the filename part can be limited by\ngiving another width <name-width> after a comma or by setting diff.statNameWidth=<width> . The width of the graph part can be\nlimited by using --stat-graph-width=<width> or by setting diff.statGraphWidth=<width> . Using --stat or --stat-graph-width affects all commands generating a stat graph,\nwhile setting diff.statNameWidth or diff.statGraphWidth does not affect git format-patch .\nBy giving a third parameter <count> , you can limit the output to\nthe first <count> lines, followed by ... if there are more. These parameters can also be set individually with --stat-width=<width> , --stat-name-width=<name-width> and --stat-count=<count> ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-filter-branch - Rewrite branches"
},
{
"role": "assistant",
"content": "SAFETY git-filter-branch is riddled with gotchas resulting in various ways to\neasily corrupt repos or end up with a mess worse than what you started\nwith: Someone can have a set of \"working and tested filters\" which they\ndocument or provide to a coworker, who then runs them on a different\nOS where the same commands are not working/tested (some examples in\nthe git-filter-branch manpage are also affected by this).\nBSD vs. GNU userland differences can really bite. If lucky, error\nmessages are spewed. But just as likely, the commands either don’t\ndo the filtering requested, or silently corrupt by making some\nunwanted change. The unwanted change may only affect a few commits,\nso it’s not necessarily obvious either. (The fact that problems\nwon’t necessarily be obvious means they are likely to go unnoticed\nuntil the rewritten history is in use for quite a while, at which\npoint it’s really hard to justify another flag-day for another\nrewrite.) Filenames with spaces are often mishandled by shell snippets since\nthey cause problems for shell pipelines. Not everyone is familiar\nwith find -print0, xargs -0, git-ls-files -z, etc. Even people who\nare familiar with these may assume such flags are not relevant\nbecause someone else renamed any such files in their repo back\nbefore the person doing the filtering joined the project. And\noften, even those familiar with handling arguments with spaces may\nnot do so just because they aren’t in the mindset of thinking about\neverything that could possibly go wrong. Non-ascii filenames can be silently removed despite being in a\ndesired directory. Keeping only wanted paths is often done using\npipelines like git ls-files | grep -v ^WANTED_DIR/ | xargs git rm .\nls-files will only quote filenames if needed, so folks may not\nnotice that one of the files didn’t match the regex (at least not\nuntil it’s much too late). Yes, someone who knows about\ncore.quotePath can avoid this (unless they have other special\ncharacters like \\t, \\n, or \"), and people who use ls-files -z with\nsomething other than grep can avoid this, but that doesn’t mean they\nwill. Similarly, when moving files around, one can find that filenames\nwith non-ascii or special characters end up in a different\ndirectory, one that includes a double quote character. (This is\ntechnically the same issue as above with quoting, but perhaps an\ninteresting different way that it can and has manifested as a\nproblem.) It’s far too easy to accidentally mix up old and new history. It’s\nstill possible with any tool, but git-filter-branch almost\ninvites it. If lucky, the only downside is users getting frustrated\nthat they don’t know how to shrink their repo and remove the old\nstuff. If unlucky, they merge old and new history and end up with\nmultiple \"copies\" of each commit, some of which have unwanted or\nsensitive files and others which don’t. This comes about in\nmultiple different ways: the default to only doing a partial history rewrite ( --all is not\nthe default and few examples show it) the fact that there’s no automatic post-run cleanup the fact that --tag-name-filter (when used to rename tags) doesn’t\nremove the old tags but just adds new ones with the new name the fact that little educational information is provided to inform\nusers of the ramifications of a rewrite and how to avoid mixing old\nand new history. For example, this man page discusses how users\nneed to understand that they need to rebase their changes for all\ntheir branches on top of new history (or delete and reclone), but\nthat’s only one of multiple concerns to consider. See the\n\"DISCUSSION\" section of the git filter-repo manual page for more\ndetails. Annotated tags can be accidentally converted to lightweight tags,\ndue to either of two issues: Someone can do a history rewrite, realize they messed up, restore\nfrom the backups in refs/original/, and then redo their\ngit-filter-branch command. (The backup in refs/original/ is not a\nreal backup; it dereferences tags first.) Running git-filter-branch with either --tags or --all in your\n<rev-list-options>. In order to retain annotated tags as\nannotated, you must use --tag-name-filter (and must not have\nrestored from refs/original/ in a previously botched rewrite). Any commit messages that specify an encoding will become corrupted\nby the rewrite; git-filter-branch ignores the encoding, takes the\noriginal bytes, and feeds it to commit-tree without telling it the\nproper encoding. (This happens whether or not --msg-filter is\nused.) Commit messages (even if they are all UTF-8) by default become\ncorrupted due to not being updated — any references to other commit\nhashes in commit messages will now refer to no-longer-extant\ncommits. There are no facilities for helping users find what unwanted crud\nthey should delete, which means they are much more likely to have\nincomplete or partial cleanups that sometimes result in confusion\nand people wasting time trying to understand. (For example, folks\ntend to just look for big files to delete instead of big directories\nor extensions, and once they do so, then sometime later folks using\nthe new repository who are going through history will notice a build\nartifact directory that has some files but not others, or a cache of\ndependencies (node_modules or similar) which couldn’t have ever been\nfunctional since it’s missing some files.) If --prune-empty isn’t specified, then the filtering process can\ncreate hoards of confusing empty commits If --prune-empty is specified, then intentionally placed empty\ncommits from before the filtering operation are also pruned instead\nof just pruning commits that became empty due to filtering rules. If --prune-empty is specified, sometimes empty commits are missed\nand left around anyway (a somewhat rare bug, but it happens…) A minor issue, but users who have a goal to update all names and\nemails in a repository may be led to --env-filter which will only\nupdate authors and committers, missing taggers. If the user provides a --tag-name-filter that maps multiple tags to\nthe same name, no warning or error is provided; git-filter-branch\nsimply overwrites each tag in some undocumented pre-defined order\nresulting in only one tag at the end. (A git-filter-branch\nregression test requires this surprising behavior.) Also, the poor performance of git-filter-branch often leads to safety\nissues: Coming up with the correct shell snippet to do the filtering you\nwant is sometimes difficult unless you’re just doing a trivial\nmodification such as deleting a couple files. Unfortunately, people\noften learn if the snippet is right or wrong by trying it out, but\nthe rightness or wrongness can vary depending on special\ncircumstances (spaces in filenames, non-ascii filenames, funny\nauthor names or emails, invalid timezones, presence of grafts or\nreplace objects, etc.), meaning they may have to wait a long time,\nhit an error, then restart. The performance of git-filter-branch is\nso bad that this cycle is painful, reducing the time available to\ncarefully re-check (to say nothing about what it does to the\npatience of the person doing the rewrite even if they do technically\nhave more time available). This problem is extra compounded because\nerrors from broken filters may not be shown for a long time and/or\nget lost in a sea of output. Even worse, broken filters often just\nresult in silent incorrect rewrites. To top it all off, even when users finally find working commands,\nthey naturally want to share them. But they may be unaware that\ntheir repo didn’t have some special cases that someone else’s does.\nSo, when someone else with a different repository runs the same\ncommands, they get hit by the problems above. Or, the user just\nruns commands that really were vetted for special cases, but they\nrun it on a different OS where it doesn’t work, as noted above."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker --attr-source=<tree-ish>"
},
{
"role": "assistant",
"content": "Read gitattributes from <tree-ish> instead of the worktree. See gitattributes . This is equivalent to setting the GIT_ATTR_SOURCE environment variable."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitignore binary files that have no extension\nHow can binary files be ignored in git using the .gitignore file? \nExample: \n$ g++ hello.c -o hello\n\nThe \"hello\" file is a binary file. Can git ignore this file ?"
},
{
"role": "assistant",
"content": "# Ignore all\n*\n\n# Unignore all with extensions\n!*.*\n\n# Unignore all dirs\n!*/\n\n### Above combination will ignore all files without extension ###\n\n# Ignore files with extension `.class` & `.sm`\n*.class\n*.sm\n\n# Ignore `bin` dir\nbin/\n# or\n*/bin/*\n\n# Unignore all `.jar` in `bin` dir\n!*/bin/*.jar\n\n# Ignore all `library.jar` in `bin` dir\n*/bin/library.jar\n\n# Ignore a file with extension\nrelative/path/to/dir/filename.extension\n\n# Ignore a file without extension\nrelative/path/to/dir/anotherfile"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database zeroPaddedDate"
},
{
"role": "assistant",
"content": "(ERROR) Found a zero padded date in an author/committer line."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Unable to push nuGet packages to GitLab with dotnet CLI due to Unauthorized error\n\nGitLab now supports nuget public and private feed repository.\nI've got a public project (e.g: https://gitlab.com/sunnyatticsoftware/sasw-test-support)\nI create an access token for my user with api and write_repository (e.g: AAABBBCCCDDD)\nI create a group variable in my CI/CD: SASW_API_ACCESS_TOKEN: AAABBBCCCDDD. All normal.\nThen I create the multi stage CI/CD script to build, pack and publish.\nWhen attempting to publish the nuGet package with the following:\ndotnet nuget push **/*.nupkg --source https://gitlab.com/api/v4/projects/17141695/packages/nuget/index.json --api-key AAABBBCCCDDD --skip-duplicate\nI get the error:\ninfo : Pushing Sasw.TestSupport.2.0.2.nupkg to 'https://gitlab.com/api/v4/projects/17141695/packages/nuget'...\ninfo : PUT https://gitlab.com/api/v4/projects/17141695/packages/nuget/\ninfo : Unauthorized https://gitlab.com/api/v4/projects/17141695/packages/nuget/ 397ms\nerror: Response status code does not indicate success: 401 (Unauthorized).\nERROR: Job failed: exit code 1\n\nThe documentation doesn't mention anything special, but I notice that when using the (legacy?) nuget CLI it passes a username. Dotnet CLI, however, doesn't support username, just API KEY.\nAny idea why this is not working?\nThis is my CI/CD script:\nvariables:\n GITLAB_RUNNER_DOTNET_CORE: mcr.microsoft.com/dotnet/core/sdk:3.1\n NUGET_REPOSITORY: https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/nuget/index.json\n NUGET_API_KEY: $SASW_API_ACCESS_TOKEN\n NUGET_FOLDER_NAME: nupkgs\n NUGET_VERSION_SUFFIX: $SASW_PRERELEASE_SUFFIX\n\nstages:\n - build\n - pack\n - release\n \n#Docker image\nimage: $GITLAB_RUNNER_DOTNET_CORE\n\n#Jobs\nci:\n stage: build\n script:\n - dotnet restore --no-cache --force\n - dotnet build --configuration Release --no-restore\n #- dotnet vstest test/*UnitTests/bin/Release/**/*UnitTests.dll\n #- dotnet vstest test/*IntegrationTests/bin/Release/**/*IntegrationTests.dll\n \npack-prerelease:\n stage: pack\n script:\n - dotnet pack *.sln --configuration Release --output $NUGET_FOLDER_NAME --version-suffix $NUGET_VERSION_SUFFIX --include-symbols -p:SymbolPackageFormat=snupkg\n artifacts:\n paths:\n - $NUGET_FOLDER_NAME\n expire_in: 1 week\n except:\n - master\n\npack-release:\n stage: pack\n script:\n - dotnet pack *.sln --configuration Release --output $NUGET_FOLDER_NAME\n artifacts:\n paths:\n - $NUGET_FOLDER_NAME\n expire_in: 1 week\n only:\n - master\n\npublish-nuget:\n stage: release\n script:\n - dotnet nuget push **/*.nupkg --source $NUGET_REPOSITORY --api-key $NUGET_API_KEY --skip-duplicate\n\nPS: The project is public, so in case it's needed have a look at: https://gitlab.com/sunnyatticsoftware/sasw-test-support/-/jobs/451080235\n\nUPDATE 1: Further verbosity from my local linux console\n$ dotnet nuget -v Debug push **/*.nupkg --source https://gitlab.com/api/v4/projects/17141695/packages/nuget/index.json --api-key cBwt5_hidden_ --skip-duplicate\ntrace: NuGet Command Line Version: 5.4.0.2\ninfo : Pushing Sasw.TestSupport.2.0.2.nupkg to 'https://gitlab.com/api/v4/projects/17141695/packages/nuget'...\ninfo : PUT https://gitlab.com/api/v4/projects/17141695/packages/nuget/\ninfo : Unauthorized https://gitlab.com/api/v4/projects/17141695/packages/nuget/ 1159ms\nerror: Response status code does not indicate success: 401 (Unauthorized).\ntrace: System.AggregateException: One or more errors occurred. (Response status code does not indicate success: 401 (Unauthorized).)\ntrace: ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).\ntrace: at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()\ntrace: at NuGet.Protocol.Core.Types.PackageUpdateResource.EnsureSuccessStatusCode(HttpResponseMessage response, Nullable`1 codeNotToThrow, ILogger logger)\ntrace: at NuGet.Protocol.Core.Types.PackageUpdateResource.<>c__DisplayClass23_0.<PushPackageToServer>b__0(HttpResponseMessage response)\ntrace: at NuGet.Protocol.HttpSource.ProcessResponseAsync[T](HttpSourceRequest request, Func`2 processAsync, SourceCacheContext cacheContext, ILogger log, CancellationToken token)\ntrace: at NuGet.Protocol.Core.Types.PackageUpdateResource.PushPackageToServer(String source, String apiKey, String pathToPackage, Int64 packageSize, Boolean noServiceEndpoint, Boolean skipDuplicate, TimeSpan requestTimeout, ILogger logger, CancellationToken token)\ntrace: at NuGet.Protocol.Core.Types.PackageUpdateResource.PushPackageCore(String source, String apiKey, String packageToPush, Boolean noServiceEndpoint, Boolean skipDuplicate, TimeSpan requestTimeout, ILogger log, CancellationToken token)\ntrace: at NuGet.Protocol.Core.Types.PackageUpdateResource.PushPackage(String packagePath, String source, String apiKey, Boolean noServiceEndpoint, Boolean skipDuplicate, TimeSpan requestTimeout, ILogger log, CancellationToken token, Boolean isSnupkgPush)\ntrace: at NuGet.Protocol.Core.Types.PackageUpdateResource.Push(String packagePath, String symbolSource, Int32 timeoutInSecond, Boolean disableBuffering, Func`2 getApiKey, Func`2 getSymbolApiKey, Boolean noServiceEndpoint, Boolean skipDuplicate, SymbolPackageUpdateResourceV3 symbolPackageUpdateResource, ILogger log)\ntrace: at NuGet.Commands.PushRunner.Run(ISettings settings, IPackageSourceProvider sourceProvider, String packagePath, String source, String apiKey, String symbolSource, String symbolApiKey, Int32 timeoutSeconds, Boolean disableBuffering, Boolean noSymbols, Boolean noServiceEndpoint, Boolean skipDuplicate, ILogger logger)\ntrace: at NuGet.CommandLine.XPlat.PushCommand.<>c__DisplayClass0_1.<<Register>b__1>d.MoveNext()\ntrace: --- End of inner exception stack trace ---\ntrace: at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\ntrace: at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)\ntrace: at System.Threading.Tasks.Task`1.get_Result()\ntrace: at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass56_0.<OnExecute>b__0()\ntrace: at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)\ntrace: at NuGet.CommandLine.XPlat.Program.MainInternal(String[] args, CommandOutputLogger log)\n\n\nUPDATE 2: Alexey's answer is the proper one and up to date as per April 2021. GitLab has improved Nuget support in the last year and now it's possible to easily push packages to the repo package registry and have readacces on Nuget feed at project level or group level using deploy tokens."
},
{
"role": "assistant",
"content": "Pushing NuGet packages built from the current repository is quite easy, following the documentation. You do not need a NuGet.config file to push packages, as the credentials can be specified for the dotnet push command. You also don't need to keep the credentials in the CI file, as the CI variables contain all the necessary temporary credentials to push packages to the project package registry.\nThis is a fragment from my working .gitlab-ci.yml file, which I literally copy-pasted from the docs. All the necessary information comes from CI variables, so this snippet is totally reusable.\nnuget:\n stage: deploy\n image: mcr.microsoft.com/dotnet/sdk:5.0-buster-slim\n script:\n - dotnet pack -c Release -o $PWD/nuget\n - dotnet nuget add source \"$CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/packages/nuget/index.json\" --name gitlab --username gitlab-ci-token --password $CI_JOB_TOKEN --store-password-in-clear-text\n - dotnet nuget push \"$PWD/nuget/*.nupkg\" --source gitlab\n only:\n - master\n - tags\n\nConcerning the question about installing the package, you would, indeed, need a token. But it is not your personal access token. All you need really to let people install and restore from your feed is the repository deploy token. It doesn't have to be defined on the project level if you have multiple projects in a group, which contains several projects that have NuGet packages published. You can also create a deploy token for the whole group. The deploy token you create for this purpose only needs to have the read_package_registry permissions and it doesn't give any other rights to the users who get this token.\nAfter creating a deploy token, the token name is used as the username, and the token itself is the password. You put both of those to the NuGet.config file, where you have your project or group feed listed.\nFor example:\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<configuration>\n <packageSources>\n <clear />\n <add key=\"nuget.org\" value=\"https://api.nuget.org/v3/index.json\" protocolVersion=\"3\" />\n <add key=\"myfeed\" value=\"https://gitlab.mydomain.dev/api/v4/groups/19/-/packages/nuget/index.json\" />\n </packageSources>\n <packageSourceCredentials>\n <myfeed>\n <add key=\"Username\" value=\"gitlab+deploy-token-14\" />\n <add key=\"ClearTextPassword\" value=\"thetokenvalue\" />\n </myfeed>\n </packageSourceCredentials>\n</configuration>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Change the location of the ~ directory in a Windows install of Git Bash\nI am not even sure I am asking the right question. Let me explain my situation:\nThis is about Git on Windows 7.\nMy company sets up the Windows user directory on a network drive, not on the local hard drive (for backup and other purposes beyond the scope of this question). I cannot change that policy.\nI CAN have local files outside of that scheme however and that is how my Apache server is set up. Entirely local.\nI installed Git. It installs Bash. When I fire up Bash and cd ~ (change to the root directory) I find that it (the Bash root) points to my network user directory. I want it not to do that. I want ~ to be elsewhere on my hard drive. I want it so that when I perform other operations such as installing a certificate, an SSH key, etc. its defaults will not automatically use that network directory.\nI have searched in vain everywhere, and all I can find refers to answers that involve aliases, redirection, and the location $HOME points to. But that is not what I want at all.\nThe question is: Can I change that directory? And if so: How?\nUPDATE: So, $HOME is what I need to modify. However I have been unable to find where this mythical $HOME variable is set so I assumed it was a Linux system version of PATH or something. Anyway...\nI do have a \"profile\" file under git/etc. Here are the contents (notice no $HOME):\n # To the extent possible under law, the author(s) have dedicated all\n # copyright and related and neighboring rights to this software to the\n # public domain worldwide. This software is distributed without any warranty.\n # You should have received a copy of the CC0 Public Domain Dedication along\n # with this software.\n # If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.\n\n\n # System-wide profile file\n\n # Some resources...\n # Customizing Your Shell: http://www.dsl.org/cookbook/cookbook_5.html#SEC69\n # Consistent BackSpace and Delete Configuration:\n # http://www.ibb.net/~anne/keyboard.html\n # The Linux Documentation Project: http://www.tldp.org/\n # The Linux Cookbook: http://www.tldp.org/LDP/linuxcookbook/html/\n # Greg's Wiki http://mywiki.wooledge.org/\n\n # Setup some default paths. Note that this order will allow user installed\n # software to override 'system' software.\n # Modifying these default path settings can be done in different ways.\n # To learn more about startup files, refer to your shell's man page.\n\n MSYS2_PATH=\"/usr/local/bin:/usr/bin:/bin\"\n MANPATH=\"/usr/local/man:/usr/share/man:/usr/man:/share/man:${MANPATH}\"\n INFOPATH=\"/usr/local/info:/usr/share/info:/usr/info:/share/info:${INFOPATH}\"\n MINGW_MOUNT_POINT=\n if [ -n \"$MSYSTEM\" ]\n then\n case \"$MSYSTEM\" in\n MINGW32)\n MINGW_MOUNT_POINT=/mingw32\n PATH=\"${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}:${PATH}\"\n PKG_CONFIG_PATH=\"${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig\"\n ACLOCAL_PATH=\"${MINGW_MOUNT_POINT}/share/aclocal:/usr/share/aclocal\"\n MANPATH=\"${MINGW_MOUNT_POINT}/share/man:${MANPATH}\"\n ;;\n MINGW64)\n MINGW_MOUNT_POINT=/mingw64\n PATH=\"${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}:${PATH}\"\n PKG_CONFIG_PATH=\"${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig\"\n ACLOCAL_PATH=\"${MINGW_MOUNT_POINT}/share/aclocal:/usr/share/aclocal\"\n MANPATH=\"${MINGW_MOUNT_POINT}/share/man:${MANPATH}\"\n ;;\n MSYS)\n PATH=\"${MSYS2_PATH}:/opt/bin:${PATH}\"\n PKG_CONFIG_PATH=\"/usr/lib/pkgconfig:/usr/share/pkgconfig:/lib/pkgconfig\"\n ;;\n *)\n PATH=\"${MSYS2_PATH}:${PATH}\"\n ;;\n esac\n else\n PATH=\"${MSYS2_PATH}:${PATH}\"\n fi\n\n MAYBE_FIRST_START=false\n SYSCONFDIR=\"${SYSCONFDIR:=/etc}\"\n\n # TMP and TEMP as defined in the Windows environment must be kept\n # for windows apps, even if started from msys2. However, leaving\n # them set to the default Windows temporary directory or unset\n # can have unexpected consequences for msys2 apps, so we define\n # our own to match GNU/Linux behaviour.\n ORIGINAL_TMP=$TMP\n ORIGINAL_TEMP=$TEMP\n #unset TMP TEMP\n #tmp=$(cygpath -w \"$ORIGINAL_TMP\" 2> /dev/null)\n #temp=$(cygpath -w \"$ORIGINAL_TEMP\" 2> /dev/null)\n #TMP=\"/tmp\"\n #TEMP=\"/tmp\"\n case \"$TMP\" in *\\\\*) TMP=\"$(cygpath -m \"$TMP\")\";; esac\n case \"$TEMP\" in *\\\\*) TEMP=\"$(cygpath -m \"$TEMP\")\";; esac\n test -d \"$TMPDIR\" || test ! -d \"$TMP\" || {\n TMPDIR=\"$TMP\"\n export TMPDIR\n }\n\n\n # Define default printer\n p='/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows NT/CurrentVersion/Windows/Device'\n if [ -e \"${p}\" ] ; then\n read -r PRINTER < \"${p}\"\n PRINTER=${PRINTER%%,*}\n fi\n unset p\n\n print_flags ()\n {\n (( $1 & 0x0002 )) && echo -n \"binary\" || echo -n \"text\"\n (( $1 & 0x0010 )) && echo -n \",exec\"\n (( $1 & 0x0040 )) && echo -n \",cygexec\"\n (( $1 & 0x0100 )) && echo -n \",notexec\"\n }\n\n # Shell dependent settings\n profile_d ()\n {\n local file=\n for file in $(export LC_COLLATE=C; echo /etc/profile.d/*.$1); do\n [ -e \"${file}\" ] && . \"${file}\"\n done\n\n if [ -n ${MINGW_MOUNT_POINT} ]; then\n for file in $(export LC_COLLATE=C; echo ${MINGW_MOUNT_POINT}/etc/profile.d/*.$1); do\n [ -e \"${file}\" ] && . \"${file}\"\n done\n fi\n }\n\n for postinst in $(export LC_COLLATE=C; echo /etc/post-install/*.post); do\n [ -e \"${postinst}\" ] && . \"${postinst}\"\n done\n\n if [ ! \"x${BASH_VERSION}\" = \"x\" ]; then\n HOSTNAME=\"$(/usr/bin/hostname)\"\n profile_d sh\n [ -f \"/etc/bash.bashrc\" ] && . \"/etc/bash.bashrc\"\n elif [ ! \"x${KSH_VERSION}\" = \"x\" ]; then\n typeset -l HOSTNAME=\"$(/usr/bin/hostname)\"\n profile_d sh\n PS1=$(print '\\033]0;${PWD}\\n\\033[32m${USER}@${HOSTNAME} \\033[33m${PWD/${HOME}/~}\\033[0m\\n$ ')\n elif [ ! \"x${ZSH_VERSION}\" = \"x\" ]; then\n HOSTNAME=\"$(/usr/bin/hostname)\"\n profile_d zsh\n PS1='(%n@%m)[%h] %~ %% '\n elif [ ! \"x${POSH_VERSION}\" = \"x\" ]; then\n HOSTNAME=\"$(/usr/bin/hostname)\"\n PS1=\"$ \"\n else\n HOSTNAME=\"$(/usr/bin/hostname)\"\n profile_d sh\n PS1=\"$ \"\n fi\n\n if [ -n \"$ACLOCAL_PATH\" ]\n then\n export ACLOCAL_PATH\n fi\n\n export PATH MANPATH INFOPATH PKG_CONFIG_PATH USER TMP TEMP PRINTER HOSTNAME PS1 SHELL tmp temp\n test -n \"$TERM\" || export TERM=xterm-256color\n\n if [ \"$MAYBE_FIRST_START\" = \"true\" ]; then\n sh /usr/bin/regen-info.sh\n\n if [ -f \"/usr/bin/update-ca-trust\" ]\n then\n sh /usr/bin/update-ca-trust\n fi\n\n clear\n echo\n echo\n echo \"###################################################################\"\n echo \"# #\"\n echo \"# #\"\n echo \"# C A U T I O N #\"\n echo \"# #\"\n echo \"# This is first start of MSYS2. #\"\n echo \"# You MUST restart shell to apply necessary actions. #\"\n echo \"# #\"\n echo \"# #\"\n echo \"###################################################################\"\n echo\n echo\n fi\n unset MAYBE_FIRST_START"
},
{
"role": "assistant",
"content": "I don't understand, why you don't want to set the $HOME environment variable since that solves exactly what you're asking for.\ncd ~ doesn't mean change to the root directory, but change to the user's home directory, which is set by the $HOME environment variable.\nQuick'n'dirty solution\nEdit C:\\Program Files (x86)\\Git\\etc\\profile and set $HOME variable to whatever you want (add it if it's not there). A good place could be for example right after a condition commented by # Set up USER's home directory. It must be in the MinGW format, for example:\nHOME=/c/my/custom/home\n\nSave it, open Git Bash and execute cd ~. You should be in a directory /c/my/custom/home now.\nEverything that accesses the user's profile should go into this directory instead of your Windows' profile on a network drive.\nNote: C:\\Program Files (x86)\\Git\\etc\\profile is shared by all users, so if the machine is used by multiple users, it's a good idea to set the $HOME dynamically:\nHOME=/c/Users/$USERNAME\n\nCleaner solution\nSet the environment variable HOME in Windows to whatever directory you want. In this case, you have to set it in Windows path format (with backslashes, e.g. c:\\my\\custom\\home), Git Bash will load it and convert it to its format.\nIf you want to change the home directory for all users on your machine, set it as a system environment variable, where you can use for example %USERNAME% variable so every user will have his own home directory, for example:\nHOME=c:\\custom\\home\\%USERNAME%\n\nIf you want to change the home directory just for yourself, set it as a user environment variable, so other users won't be affected. In this case, you can simply hard-code the whole path:\nHOME=c:\\my\\custom\\home"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to make vi redraw screen?\nWhen I use \ngit commit --amend\n\nIt will enter into a vi window to let me input comments for commit, the problem is the vi windows will show some dirty characters from former shell background. So I wonder how can I let vi to reload or redraw the screen to make the screen normal.\nSo far, I try reset terminal and Ctrl+L, it works, but I wonder is there best answer for such situation?"
},
{
"role": "assistant",
"content": "To force a screen refresh\n:redraw!"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "List all the files that ever existed in a Git repository\nDo you have a clean way to list all the files that ever existed in specified branch?"
},
{
"role": "assistant",
"content": "This is a simplified variation of Strager's solution:\ngit log --pretty=format: --name-status | cut -f2- | sort -u\n\nEdit: Thanks to Jakub for teaching me a bit more in the comments, this version has a shorter pipeline and gives git more opportunity to get things right.\ngit log --pretty=format: --name-only --diff-filter=A | sort -u"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitmodules - Defining submodule properties none"
},
{
"role": "assistant",
"content": "No modifications to submodules are ignored, all of committed\ndifferences, and modifications to tracked and untracked files are\nshown. This is the default option."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Are Git forks actually Git clones?\nI keep hearing people say they're forking code in Git. Git \"fork\" sounds suspiciously like Git \"clone\" plus some (meaningless) psychological willingness to forgo future merges. There is no fork command in Git, right?\nGitHub makes forks a little more real by stapling correspondence onto it. That is, you press the fork button and later, when you press the pull request button, the system is smart enough to email the owner. Hence, it's a little bit of a dance around repository ownership and permissions.\nYes/No? Any angst over GitHub extending Git in this direction? Or any rumors of Git absorbing the functionality?"
},
{
"role": "assistant",
"content": "Fork, in the GitHub context, doesn't extend Git. \nIt only allows clone on the server side.\nWhen you clone a GitHub repository on your local workstation, you cannot contribute back to the upstream repository unless you are explicitly declared as \"contributor\". That's because your clone is a separate instance of that project. If you want to contribute to the project, you can use forking to do it, in the following way:\n\nclone that GitHub repository on your GitHub account (that is the \"fork\" part, a clone on the server side)\ncontribute commits to that GitHub repository (it is in your own GitHub account, so you have every right to push to it)\nsignal any interesting contribution back to the original GitHub repository (that is the \"pull request\" part by way of the changes you made on your own GitHub repository)\n\nCheck also \"Collaborative GitHub Workflow\".\nIf you want to keep a link with the original repository (also called upstream), you need to add a remote referring that original repository. \nSee \"What is the difference between origin and upstream on GitHub?\"\n\nAnd with Git 2.20 (Q4 2018) and more, fetching from fork is more efficient, with delta islands."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to undo \"git commit --amend\" done instead of \"git commit\"\nI accidentally amended my previous commit. The commit should have been separate to keep history of the changes I made to a particular file.\nIs there a way to undo that last commit? If I do something like git reset --hard HEAD^, the first commit also is undone.\n(I have not yet pushed to any remote directories)"
},
{
"role": "assistant",
"content": "What you need to do is to create a new commit with the same details as the current HEAD commit, but with the parent as the previous version of HEAD. git reset --soft will move the branch pointer so that the next commit happens on top of a different commit from where the current branch head is now.\n# Move the current head so that it's pointing at the old commit\n# Leave the index intact for redoing the commit.\n# HEAD@{1} gives you \"the commit that HEAD pointed at before \n# it was moved to where it currently points at\". Note that this is\n# different from HEAD~1, which gives you \"the commit that is the\n# parent node of the commit that HEAD is currently pointing to.\"\ngit reset --soft HEAD@{1}\n\n# commit the current tree using the commit details of the previous\n# HEAD commit. (Note that HEAD@{1} is pointing somewhere different from the\n# previous command. It's now pointing at the erroneously amended commit.)\n# The -C option takes the given commit and reuses the log message and\n# authorship information.\ngit commit -C HEAD@{1}"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Embed JavaScript in GitHub README.md\n\nI want to embed a tweet in a GitHub README file. Markdown should support this, however when I add the code that is copied from the tweet the JavaScript doesn't get rendered.\nExample:\n<blockquote>...</blockquote>\n<script async src=\"//platform.twitter.com/widgets.js\" charset=\"utf-8\"></script>\n\nAny ideas?"
},
{
"role": "assistant",
"content": "Allowing javascript from third parties directly on a website has huge XSS attacks implications. Someone could use javascript code for example to grab the cookies associated to any visitor's github accounts and forward them to a malicious entity.\nThere's also the nuisance potential, as having access to javascript means having access to the CPU of the visitor and being able to do things like pop-ups or blinking text.\nAs such it's natural that javascript isn't supported in READMEs. Markdown may have a way of doing it, but it'll never be allowed on a website like GitHub.\nHowever, you can do it on your project's github page, if you have one, since it doesn't belong to the main github website and the domain is not the same."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker scalar"
},
{
"role": "assistant",
"content": "A tool for managing large Git repositories"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-mergetool - Run merge conflict resolution tools to resolve merge conflicts mergetool.keepBackup"
},
{
"role": "assistant",
"content": "After performing a merge, the original file with conflict markers\ncan be saved as a file with a .orig extension. If this variable\nis set to false then this file is not preserved. Defaults to true (i.e. keep the backup files)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-gc - Cleanup unnecessary files and optimize the local repository --aggressive"
},
{
"role": "assistant",
"content": "Usually git gc runs very quickly while providing good disk\nspace utilization and performance. This option will cause git gc to more aggressively optimize the repository at the expense\nof taking much more time. The effects of this optimization are\nmostly persistent. See the \"AGGRESSIVE\" section below for details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs -L<start>,<end>:<file> -L:<funcname>:<file>"
},
{
"role": "assistant",
"content": "Trace the evolution of the line range given by <start>,<end> ,\nor by the function name regex <funcname> , within the <file> . You may\nnot give any pathspec limiters. This is currently limited to\na walk starting from a single revision, i.e., you may only\ngive zero or one positive revision arguments, and <start> and <end> (or <funcname> ) must exist in the starting revision.\nYou can specify this option more than once. Implies --patch .\nPatch output can be suppressed using --no-patch , but other diff formats\n(namely --raw , --numstat , --shortstat , --dirstat , --summary , --name-only , --name-status , --check ) are not currently implemented. <start> and <end> can take one of these forms: number If <start> or <end> is a number, it specifies an\nabsolute line number (lines count from 1). /regex/ This form will use the first line matching the given\nPOSIX regex. If <start> is a regex, it will search from the end of\nthe previous -L range, if any, otherwise from the start of file.\nIf <start> is ^/regex/ , it will search from the start of file.\nIf <end> is a regex, it will search\nstarting at the line given by <start> . +offset or -offset This is only valid for <end> and will specify a number\nof lines before or after the line given by <start> . If :<funcname> is given in place of <start> and <end> , it is a\nregular expression that denotes the range from the first funcname line\nthat matches <funcname> , up to the next funcname line. :<funcname> searches from the end of the previous -L range, if any, otherwise\nfrom the start of file. ^:<funcname> searches from the start of\nfile. The function names are determined in the same way as git diff works out patch hunk headers (see Defining a custom hunk-header in gitattributes )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-remote - Manage set of tracked repositories remove rm"
},
{
"role": "assistant",
"content": "Remove the remote named <name>. All remote-tracking branches and\nconfiguration settings for the remote are removed."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-describe - Give an object a human readable name based on an available ref --always"
},
{
"role": "assistant",
"content": "Show uniquely abbreviated commit object as fallback."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git commits are not getting linked with my GitHub account\n\nI'm having problems trying to link my commits to my GitHub account. Commits are being reported on GitHub the way my picture shows. The values user.name and user.email are correct, any other ideas to check?\nThanks in advance"
},
{
"role": "assistant",
"content": "Even though your settings might look correct, this error implies that something in the user.email field is incorrect, which gives Github the wrong information about who the committer is. A small typo could throw the whole thing off. The fix is in the third step, and the first two steps help identify what the problem is.\nFirst, run git config -l to check your settings and make sure that you don't have something unexpected in there. Run git log and take note of how the Author field looks. It should be in the format of Author: Your-Name <[email protected]>. The part within the brackets is the important part as far as Github is concerned.\nSecond, if you've been able to commit something successfully in the past, open that repo and run git log to find the commit where everything worked properly. Check that Author field against the one that isn't working and see if there is a difference.\nThird, if there is a difference, switch back to the repo at issue and run git config --global user.email [email protected].\nIf the problem persists, check your Github email settings and make sure that the email address that you are using is added to your account.\nSee this help article for more information."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs git log -p -m --first-parent"
},
{
"role": "assistant",
"content": "Shows the history including change diffs, but only from the\n“main branch” perspective, skipping commits that come from merged\nbranches, and showing full diffs of changes introduced by the merges.\nThis makes sense only when following a strict policy of merging all\ntopic branches when staying on a single integration branch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %ai"
},
{
"role": "assistant",
"content": "author date, ISO 8601-like format"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order --objects-edge-aggressive"
},
{
"role": "assistant",
"content": "Similar to --objects-edge , but it tries harder to find excluded\ncommits at the cost of increased time. This is used instead of --objects-edge to build “thin” packs for shallow repositories."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Remote: Error: fatal: protocol error: bad line length character: Unab\nI set up a git server and want now to push initially my repo from the client.\nI used git push origin master and get this error message:\nfatal: protocol error: bad line length character: Unab\n\nI don't know what's wrong. I don't know what \"Unab\" is. I tried to resize the shell but it is still \"Unab\".\nI cannot find a solution for this error message.\nI setup the server with \"authorized_keys\" and SSH. (I can connect to it, using SSH.)\nIt seems to be a git problem?\nBTW: The server is set up in a Windows 7 VM"
},
{
"role": "assistant",
"content": "This error message is a bit obtuse, but what it's actually trying to tell you is that the remote server didn't reply with a proper git response. Ultimately, there was a problem on the server running the git-receive-pack process.\nIn the Git protocol, the first four bytes should be the line length. Instead, they were the characters Unab... which is probably the beginning an error message of some kind. (ie, it's probably \"Unable to...\" do something).\nWhat happens when you run ssh <host> git-receive-pack <path-to-git-repository>? You should see the error message that your git client is barfing on and you may be able to correct it."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-clone - Clone a repository into a new directory -b <name> --branch <name>"
},
{
"role": "assistant",
"content": "Instead of pointing the newly created HEAD to the branch pointed\nto by the cloned repository’s HEAD, point to <name> branch\ninstead. In a non-bare repository, this is the branch that will\nbe checked out. --branch can also take tags and detaches the HEAD at that commit\nin the resulting repository."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to pull a new submodule\nTried looking for answers on this site and others:\nStackOverflow - Easy way pull latest of all submodules\nThey all seem to want to talk about if you are controlling them, not if someone else added one, and I just want to pull the additional one into my project without having to stash or backup my changes if I need to delete the folder.\nShould I delete the .gitmodules file, and/or the submodule directories that I have already pulled down with git clone --recursive?\n(StackOverflow - How to git clone including submodules?)\nThese commands do not seem to help either:\n\ngit submodule update --init --recursive seems like it did nothing.\ngit submodule update --recursive nothing.\ngit fetch --recurse-submodules output Fetching submodule ... several times.\ngit pull --recurse-submodules output the same thing, and then said Already up-to-date. after the fetch trial. Strange since in either case my submodules were already downloaded.\ngit clone --recursive ... Not tried yet. I feel like would overwrite any changes I have made, in the Stash or otherwise.\ngit submodule update --recursive --remote checked out a new commit SHA for one of the submodules.\ngit submodule update --recursive checked out a new commit SHA for one of the submodules. Could be the older, original commit level.\ngit submodule status gives the appropriate SHA, version, and name information for each, while still lacking the one that I want.\ngit submodule foreach git pull origin master\ngit submodule update does nothing.\n\nI have been double-checking the library directory manually each time to make sure whether the additional submodule appeared or not.\nI want to avoid performing certain actions, unless they are not destructive to my current repository state containing code changes, and solves my problem, in case it is a command I have mentioned but did not run, or anyone else has another to try.\nI could try some of these with more effort, but I think I want to stop messing with them for now, and since I have not found the answer to this issue after doing some online searching, maybe the hopeful and eventual answer would help others anyway.\nAm I suffering from the con mentioned here at all?\nSoftware Engineering - Git submodule vs Git clone\nMore links:\n\nStackOverflow - Update Git submodule to latest commit on origin"
},
{
"role": "assistant",
"content": "When you want to pull a specific new module, you can use the following command:\ngit submodule update --init local/path/to/submodule/folder\n\nIf you wish to initialize all new submodules however. you can omit the path to the folder like so:\ngit submodule update --init"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git reset --hard origin/master failing\nTrying to discard changes on server, and make it exactly the same as origin/master:\ngit fetch --all\ngit reset --hard origin/master\n\nI've done this before on same repo without problems, but this time it fails with the following:\nfatal: Could not reset index file to revision 'origin/master'\n\nHave tried the following:\n\nremove index and reset as suggested here:\nrm .git/index\ngit reset\n\nalso suggested here that some process could have a lock on .git\\index. That killing process and then executing git reset could fix it, but not sure how to check if something has a lock on file remotely. Also seems that removing index file and reset would have had same effect.\n\nLoosing my mind. Would really appreciate any help."
},
{
"role": "assistant",
"content": "Had the same issue, which quite crazy cause reset --hard should always work, but it seems the working tree had a lot of differences to my target branch.\nI had no time to dig this down, but found this by accident:\n\nRun git gc to do some garbage collection. It will remove unnecessary files and optimize the local repository (more info about git gc can be found here).\n\nSimply reset and finally reset --hard to desired branch.\n$ git gc\n\n$ git reset\n\n$ git reset --hard <target_branch>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker --exec-path[=<path>]"
},
{
"role": "assistant",
"content": "Path to wherever your core Git programs are installed.\nThis can also be controlled by setting the GIT_EXEC_PATH\nenvironment variable. If no path is given, git will print\nthe current setting and then exit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "OSX 10.10 yosemite beta on git pull: git-sh-setup: No such file or directory\nAfter upgrading to OSX 10.10 Yosemite Beta, running git pull is returning the following error:\n\n/Library/Developer/CommandLineTools/usr/libexec/git-core/git-pull: line 11: git-sh-setup: No such file or directory\n\nI've checked the referenced git-core directory and the git-sh-setup.sh is there.\nOther git commands are working exactly as expected"
},
{
"role": "assistant",
"content": "I think the cleanest solution for this for now is to change the initial command in your iTerm session to be\n/usr/bin/login -f <your user name>\n\nThis fixes the issue for me.\nA further data point for analysis of the issue: It seems that in 10.10, multiple copies of the PATH environment variable exist and subshells seem to prefer the second copy. \nYou can reproduce this by launching any cocoa application on the console as launched by iTerm. You'll get a warning that looks like this:\n2014-06-04 19:23:09.859 gitx[14676:362580] *** -[NSProcessInfo environment]: Warning: duplicate definition for key 'PATH' found in environment -- subsequent definitions are ignored. The first definition was '(the path I have configured in my shell)', the ignored definition is '/usr/bin:/bin:/usr/sbin:/sbin'.\n\nI believe this to be a problem in 10.10 and not iTerm, but something iTerm is doing is causing it to manifest itself (this doesn't happen in Terminal.app)\nUpdate: This is caused by iTerm doing \"interesting\" stuff to the environment. Update to the official release of iTerm 2.0 to make this problem go away."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Remove a file from a Git Pull Request\n\nI have added a local changes to an existing file into my PR by mistake.\nI want to revert only this file without deleting this file locally.\nI just want that it doesn't show up in the Pull Request.\nI don't want to create new branch as many people have commented on other files in this PR."
},
{
"role": "assistant",
"content": "If you updated a file that already existed and want to remove it from the PR:\nAssume you're working on a branch off of staging, and you PR'd a file named validate_model.py.\nTo remove this file from the PR and revert its changes, simply do:\ngit checkout staging -- validate_model.py"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to update a file in remote repo, without cloning that repo first?\nIs there a way to push a commit to a remote git repo, without first making a local clone of that repo?\nI have a valid URL for the remote repo, I know the path of the file, and all I want to do is push an updated version of the file onto the master. Ideally I'd like this to work with any valid remote repo URL, but it would still be helpful if it worked only with https-based git URLs.\nI'm guessing this is impossible, since it does not seem to be possible even to retrieve a single file without cloning in the general case, according to the answer How to \"git show\" on a remote repo? . But I'm hoping there's a workaround that uses some of the lower level git commands."
},
{
"role": "assistant",
"content": "Impossible. But since a prospective commit would just need to have one single commit as its parent it's possible to employ the so-called \"shallow cloning\" and fetch just the tip commit of the branch you need. This will bring only a minimum amount of objects from the remote. Look for the --depth command-line option of git clone."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I rename a Git repository created with gitolite?\nI created a Git repository using gitolite. Now I would like to rename that repository.\nHow can I do this? \nIn gitolite's readme is says that I should not work directly on the server. But I guess I have to do some work on the server in this case, right?"
},
{
"role": "assistant",
"content": "As stated in the gitolite basic-admin manual:\nrenaming a repo\nThis is similar; there's no code to do this in gitolite. What you do is:\n\nlog on to the server, cd $REPO_BASE (default: cd ~/repositories), and\nmv old-name.git new-name.git\nback on your gitolite-admin clone, edit conf/gitolite.conf and replace all occurrences of old-name with new-name. Then add, commit, and push as usual. \n\nThe order of these 2 steps is important; do not reverse them :-)\nA third step is necessary on gitolite3:\n\nedit file gl-conf in the repo and change the repository name to the new name\n\nAnd of course, every user should update his clone configuration to point to the new repo name."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to state in requirements.txt a direct github source\n\nI've installed a library using the command\npip install git+git://github.com/mozilla/elasticutils.git\n\nwhich installs it directly from a Github repository. This works fine and I want to have that dependency in my requirements.txt. I've looked at other tickets like this but that didn't solve my problem. If I put something like\n-f git+git://github.com/mozilla/elasticutils.git\nelasticutils==0.7.dev\n\nin the requirements.txt file, a pip install -r requirements.txt results in the following output:\nDownloading/unpacking elasticutils==0.7.dev (from -r requirements.txt (line 20))\n Could not find a version that satisfies the requirement elasticutils==0.7.dev (from -r requirements.txt (line 20)) (from versions: )\nNo distributions matching the version for elasticutils==0.7.dev (from -r requirements.txt (line 20))\n\nThe documentation of the requirements file does not mention links using the git+git protocol specifier, so maybe this is just not supported.\nDoes anybody have a solution for my problem?"
},
{
"role": "assistant",
"content": "Normally your requirements.txt file would look something like this:\npackage-one==1.9.4\npackage-two==3.7.1\npackage-three==1.0.1\n...\n\nTo specify a Github repo, you do not need the package-name== convention.\nThe examples below update package-two using a GitHub repo. The text after @ denotes the specifics of the package.\nSpecify commit hash (41b95ec in the context of updated requirements.txt):\npackage-one==1.9.4\npackage-two @ git+https://github.com/owner/repo@41b95ec\npackage-three==1.0.1\n\nSpecify branch name (main):\npackage-two @ git+https://github.com/owner/repo@main\n\nSpecify tag (0.1):\npackage-two @ git+https://github.com/owner/[email protected]\n\nSpecify release (3.7.1):\npackage-two @ git+https://github.com/owner/repo@releases/tag/v3.7.1\n\nNote that in certain versions of pip you will need to update the package version in the package's setup.py, or pip will assume the requirement is already satisfied and not install the new version. For instance, if you have 1.2.1 installed, and want to fork this package with your own version, you could use the above technique in your requirements.txt and then update setup.py to 1.2.1.1.\nSee also the pip documentation on VCS support."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab CI runner job failed exit status 1 when changing directory\n\nI am using my personal machine as a runner for an iOS project using Fastlane. This is mainly due to the fact that shared runners aren't setup for iOS as they don't have Xcode installed.\nMy jobs fail immediately when changing directory.\nIt's a shell runner, no other custom config at all.\nAny suggestions?\n\nThis is the output when running gitlab-runner --debug run and starting a job.\nChecking for jobs... received job=59131527 repo_url=https://gitlab.com/nickfarrant/aqualog-asset-collection.git runner=159b2b59\nFailed to requeue the runner: builds=1 runner=159b2b59\nRunning with gitlab-ci-multi-runner 9.0.2 (fa8b86d)\n on Nicks-Bink-iMac (159b2b59) job=59131527 project=5134442 runner=159b2b59\nShell configuration: environment: []\ndockercommand:\n- sh\n- -c\n- \"if [ -x /usr/local/bin/bash ]; then\\n\\texec /usr/local/bin/bash --login\\nelif [\n -x /usr/bin/bash ]; then\\n\\texec /usr/bin/bash --login\\nelif [ -x /bin/bash ]; then\\n\\texec\n /bin/bash --login\\nelif [ -x /usr/local/bin/sh ]; then\\n\\texec /usr/local/bin/sh\n --login\\nelif [ -x /usr/bin/sh ]; then\\n\\texec /usr/bin/sh --login\\nelif [ -x /bin/sh\n ]; then\\n\\texec /bin/sh --login\\nelse\\n\\techo shell not found\\n\\texit 1\\nfi\\n\\n\"\ncommand: bash\narguments:\n- --login\npassfile: false\nextension: \"\"\n job=59131527 project=5134442 runner=159b2b59\nUsing Shell executor... job=59131527 project=5134442 runner=159b2b59\nWaiting for signals... job=59131527 project=5134442 runner=159b2b59\nWARNING: Job failed: exit status 1 job=59131527 project=5134442 runner=159b2b59"
},
{
"role": "assistant",
"content": "I hit the same situation, and I solve it.\nI guess you used rvm.\nPlease follow below:\n\nOpen terminal\necho 'unset cd'>>~/.bash_profile; source ~/.bash_profile\nretry pipeline.\n\nRefer to: https://juejin.im/post/5a65977bf265da3e4e25bfb8"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fast-import - Backend for fast Git data importers"
},
{
"role": "assistant",
"content": "NAME git-fast-import - Backend for fast Git data importers"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitattributes - Defining attributes per path Set to a value"
},
{
"role": "assistant",
"content": "The path has the attribute with specified string value;\nthis is specified by listing the name of the attribute\nfollowed by an equal sign = and its value in the\nattribute list."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-update-index - Register file contents in the working tree to the index --refresh"
},
{
"role": "assistant",
"content": "Looks at the current index and checks to see if merges or\nupdates are needed by checking stat() information."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-cherry-pick - Apply the changes introduced by some existing commits git rev-list --reverse master -- README | git cherry-pick -n --stdin"
},
{
"role": "assistant",
"content": "Apply the changes introduced by all commits on the master\nbranch that touched README to the working tree and index,\nso the result can be inspected and made into a single new\ncommit if suitable."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "unable to get SSH keys working between sourcetree and github\n\nI was able to create a key and connect to github following these instructions via the command prompt successfully:\nhttps://help.github.com/articles/generating-ssh-keys\nHowever, when I try to connect via Sourcetree and putty I cannot. I've tried:\n\ngenerating a new key with the putty key generator (SSH-2 RSA) \nentering a passphrase\nsaving the private key\nsaving the public key and adding a .pub extension\ncopying/pasting the key from the putty key generator window into github\nattemping to refresh branches on a pull from my private github repository from my local repo using the SSH clone URL I got from github\n\nI also tried opening the key generated from the github command line instructions and it wanted me to convert it to a putty-type key which I did and saved off, tried with that one. Also no luck.\nWhat am I doing wrong?"
},
{
"role": "assistant",
"content": "In order to get it worked I ended up going to Tools -> Options -> SSH Client and changing it to OpenSSH. I generated and uploaded several different types of keys trying to get it work as well but I think this is what finally did it."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fetch - Download objects and refs from another repository --multiple"
},
{
"role": "assistant",
"content": "Allow several <repository> and <group> arguments to be\nspecified. No <refspec>s may be specified."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to \"pull request\" a specific commit\n\nI've got a specific commit which I would like to contribute to a repository I have forked on github.\nI assume the mechanism to do so is a \"pull request\".\nHowever when I try this I can only pull request my whole branch.\nI do not wish to pull request the other commits as they are not relevant.\nAny idea how I can do this.\n\nThe last commit b50b2e7 is the only commit I wish to pull request.\nAnyway I can do this or are all commits dependent on each other?"
},
{
"role": "assistant",
"content": "Create a new branch with just that change:\n# If you haven't set up your remote yet, run this line:\n# git remote add upstream https://github.com/konradjk/exac_browser.git\ngit fetch --all # Get the latest code\ngit checkout -b my-single-change upstream/master # Create new branch based on upstream/master\ngit cherry-pick b50b2e7 # Cherry pick the commit you want\ngit push -u origin my-single-change # Push your changes to the remote branch\n\nThen create the PR from that branch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker <tree>"
},
{
"role": "assistant",
"content": "Indicates a tree object name."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Transfer git repositories from GitLab to GitHub - can we, how to and pitfalls (if any)?\n\nCan one transfer repositories from GitLab to GitHub if the need be. If so, how exactly can I go about doing the same?\nAlso, are there any pitfalls in doing so or precautionary measures that I need to keep in mind before doing so given that I may decide to eventually move them to GitHub (as it has more features at the moment that I might find handy for my project)."
},
{
"role": "assistant",
"content": "You can transfer those (simply by adding a remote to a GitHub repo and pushing them)\n\ncreate an empty repo on GitHub\ngit remote add github https://[email protected]/yourLogin/yourRepoName.git\ngit push --mirror github\n\nThe history will be the same.\nBut you will lose the access control (teams defined in GitLab with specific access rights on your repo)\nIf you face any issue with the https URL of the GitHub repo:\nThe requested URL returned an error: 403\n\nAll you need to do is to enter your GitHub password, but the OP suggests:\n\nThen you might need to push it the ssh way. You can read more on how to do it here.\n\nSee \"Pushing to Git returning Error Code 403 fatal: HTTP request failed\".\n\nNote that mike also adds in the comments:\n\nGitLab can also be set to push mirror to downstream repositories, and there are specific instructions for push mirroring to GitHub.\nThis can use a GitHub Personal Access Token and also be set to periodically push.\nYou might use this option to share on GitHub, but keep your main development activity in your GitLab instance.\n\n\ntswaehn suggests in the comments the tool piceaTech/node-gitlab-2-github\n\nIt is possible to migrate issues, labels, ... with this tool github.com/piceaTech/node-gitlab-2-github: I tested it, not bad.\nBut had issues when transferring attachments of the issues itself.\nStill worth a try, maybe.\n\nFrotz notes in the comments that:\n\nI've since discovered that there's a wait option available to use in the user-editable settings.ts file that's not documented anywhere.\nI discovered it while implementing my own quick-and-dirty delay, which did work in stopping the \"Abuse detected\" slowdowns\n\n\n\nDoes this mean that when I want to push new changes I would have to do git push github [branch_name] instead of using origin?\n\nNo, you can:\n\ndelete origin, (git remote remove origin),\nrename github remote as origin (git remote rename github origin), and\ngo on git push (to origin, which is now GitHub): the transfer from GitLab to GitHub is complete."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Cherry-Picking few commits from another branch\nI have a scenario where I don't want to cherry-pick a specific commit but a range of git commits from remote.\nI can do force pull with hard option but that will get all the commits including latest changes from remote.\nPlease suggest how can I pick range of commits from remote.\n\nFor instance, this is what I am trying:\ngit checkout -b newbranch 62ecb3\n\ngit rebase --onto master 76cada, 56qwqw, 46erer"
},
{
"role": "assistant",
"content": "Let's say the history is A-B-C-D-E-F-G, and you'd like to cherry-pick C-D-E-F.\ngit cherry-pick B..F\n\nor\ngit cherry-pick C^..F\n\nor\ngit cherry-pick C D E F"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitglossary"
},
{
"role": "assistant",
"content": "A Git Glossary"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I avoid typing \"git\" at the begining of every Git command?\nI'm wondering if there's a way to avoid having to type the word git at the beginning of every Git command.\nIt would be nice if there was a way to use the git command only once in the beginning after opening a command prompt to get into \"Git mode\".\nFor example:\ngit>\n\nAfter which every command we type is by default interpreted as a Git command. \nIn a way similar to how we use the MySQL shell to write database commands:\nmysql>\n\nThis will save me from having to type git hundreds of times a day.\nNOTE: I'm using git-bash, on Windows."
},
{
"role": "assistant",
"content": "You might want to try gitsh. From their readme:\n\nThe gitsh program is an interactive shell for git. From within gitsh you can issue any git command, even using your local aliases and configuration.\n\nGit commands tend to come in groups. Avoid typing git over and over and over by running them in a dedicated git shell:\n\nsh$ gitsh\ngitsh% status\ngitsh% add .\ngitsh% commit -m \"Ship it!\"\ngitsh% push\ngitsh% ctrl-d\nsh$\n\n\nOr have a look at the other projects linked there:\n\n\ngit-sh - A customised bash shell with a Git prompt, aliases, and completion.\ngitsh - A simple Git shell written in Perl.\nrepl - Wraps any program with subcommands in a REPL.\n\n\nNote: Haven't used this myself."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What does a grey icon in remote GitHub mean\n\nCan anyone please tell me why i have the grey icon when i push my files to github ? In side the app directory, there should be models, views , and controllers but in the remote GitHub I can't click in."
},
{
"role": "assistant",
"content": "git rm --cached <folder_name>\n\nThen go to the parent directory and do:\ngit add .\ngit commit -m \"<your_message>\"\ngit push --all"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Trying to fix line-endings with git filter-branch, but having no luck\nI have been bitten by the Windows/Linux line-ending issue with git. It seems, via GitHub, MSysGit, and other sources, that the best solution is to have your local repos set to use linux-style line endings, but set core.autocrlf to true. Unfortunately, I didn't do this early enough, so now every time I pull changes the line endings are borked.\nI thought I had found an answer here but I can't get it to work for me. My Linux command line knowledge is limited at best, so i am not even sure what the \"xargs fromdos\" line does in his script. I keep getting messages about no such file or directory existing, and when I manage to point it to an existing directory, it tells me I don't have permissions. \nI've tried this with MSysGit on Windows and via the Mac OS X terminal."
},
{
"role": "assistant",
"content": "The easiest way to fix this is to make one commit that fixes all the line endings. Assuming that you don't have any modified files, then you can do this as follows.\n# From the root of your repository remove everything from the index\ngit rm --cached -r .\n\n# Change the autocrlf setting of the repository (you may want \n# to use true on windows):\ngit config core.autocrlf input\n\n# Re-add all the deleted files to the index\n# (You should get lots of messages like:\n# warning: CRLF will be replaced by LF in <file>.)\ngit diff --cached --name-only -z | xargs -0 git add\n\n# Commit\ngit commit -m \"Fixed crlf issue\"\n\n# If you're doing this on a Unix/Mac OSX clone then optionally remove\n# the working tree and re-check everything out with the correct line endings.\ngit ls-files -z | xargs -0 rm\ngit checkout ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-add - Add file contents to the index add untracked"
},
{
"role": "assistant",
"content": "This has a very similar UI to update and revert , and lets you add untracked paths to the index."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Creating a GitHub repository with only a subset of a local repository's history\n\nThe background: I'm moving closer to open sourcing a personal research code I've been working on for more than two years. It started life as an SVN repository, but I moved to Git about a year ago, and I'd like to share the code on GitHub. However, it accumulated a lot of cruft over the years, and I'd prefer that the public version begin its life at its current status. However, I'd still like to contribute to it and incorporate other people's potential contributions.\nThe question: is there a way to \"fork\" a Git repository such that no history is retained on the fork (which lives on GitHub), but that my local repository still has a complete history, and I can pull/push to GitHub?\nI don't have any experience in the administrating end of large repositories, so detail is very much appreciated."
},
{
"role": "assistant",
"content": "You can create a new, fresh history quite easily in Git. Let’s say you want your master branch to be the one that you will push to GitHub, and your full history to be stored in old-master. You can just move your master branch to old-master, and then start a fresh new branch with no history using git checkout --orphan:\ngit branch -m master old-master\ngit checkout --orphan master\ngit commit -m \"Import clean version of my code\"\n\nNow you have a new master branch with no history, which you can push to GitHub. But, as you say, you would like to be able to see all of the old history in your local repository; and would probably like for it to not be disconnected.\nYou can do this using git replace. A replacement ref is a way of specifying an alternate commit any time Git looks at a given commit. So you can tell Git to look at the last commit of your old branch, instead of the first commit of your new branch, when looking at history. In order to do this, you need to bring in the disconnected history from the old repository.\ngit replace master old-master\n\nNow you have your new branch, in which you can see all of your history, but the actual commit objects are disconnected from the old history, and so you can push the new commits to GitHub without the old commits coming along. Push your master branch to GitHub, and only the new commits will go to GitHub. But take a look at the history in gitk or git log, and you'll see the full history.\ngit push github master:master\ngitk --all\n\nGotchas\nIf you ever base any new branches on the old commits, you will have to be careful to keep the history separate; otherwise, new commits on those branches will really have the old commits in their history, and so you'll pull the whole history along if you push it up to GitHub. As long as you keep all of your new commits based on your new master, though, you'll be fine.\nIf you ever run git push --tags github, that will push all of your tags, including old ones, which will cause all of your old history to be pulled along with it. You could deal with this by deleting all of your old tags (git tag -d $(git tag -l)), or by never using git push --tags but only ever pushing tags manually, or by using two repositories as described below.\nThe basic problem underlying both of these gotchas is that if you ever push any ref which connects to any of the old history (other than via the replaced commits), you will push up all of the old history. Probably the best way of avoiding this is by using two repositories, one which contains only the new commits, and one which contains both the old and new history, for the purpose of inspecting the full history. You do all of your work, your committing, your pushing and pulling from GitHub, in the repository with just the new commits; that way, you can't possibly accidentally push your old commits up.\nYou then pull all of your new commits into your repository that has the full history, whenever you need to look at the entire thing. You can either pull from GitHub or your other local repository, whichever is more convenient. It will be your archive, but to avoid accidentally publishing your old history, you don't ever push to GitHub from it. Here's how you can set it up:\n\n~$ mkdir newrepo\n~$ cd newrepo\nnewrepo$ git init\nnewrepo$ git pull ~/oldrepo master\n# Now newrepo has just the new history; we can set up oldrepo to pull from it\nnewrepo$ cd ~/oldrepo\noldrepo$ git remote add newrepo ~/newrepo\noldrepo$ git remote update\noldrepo$ git branch --set-upstream master newrepo/master\n# ... do work in newrepo, commit, push to GitHub, etc.\n# Now if we want to look at the full history in oldrepo:\noldrepo$ git pull\n\nIf you're on Git older than 1.7.2\nYou don't have git checkout --orphan, so you'll have to do it manually by creating a fresh repository from the current revision of your existing repository, and then pulling in your old disconnected history. You can do this with, for example:\n\noldrepo$ mkdir ~/newrepo\noldrepo$ cp $(git ls-files) ~/newrepo\noldrepo$ cd ~/newrepo\nnewrepo$ git init\nnewrepo$ git add .\nnewrepo$ git commit -m \"Import clean version of my code\"\nnewrepo$ git fetch ~/oldrepo master:old-master\n\nIf you're on Git older than 1.6.5\ngit replace and replace refs were added in 1.6.5, so you'll have to use an older, somewhat less flexible mechanism known as grafts, which allow you to specify alternate parents for a given commit. Instead of the git replace command, run:\necho $(git rev-parse master) $(git rev-parse old-master) >> .git/info/grafts\n\nThis will make it look, locally, as if the master commit has the old-master commit as its parent, so you will see one more commit than you would with git replace."
}
] |