messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs files"
},
{
"role": "assistant",
"content": "Compute the dirstat numbers by counting the number of files changed.\nEach changed file counts equally in the dirstat analysis. This is\nthe computationally cheapest --dirstat behavior, since it does\nnot have to look at the file contents at all."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "npm install package from github repo subfolder\nIs it possible to install npm package from github when the package located inside subfolder?\nFor example, we have Microsoft BotBuilder repository:\nhttps://github.com/Microsoft/BotBuilder\nBut I need to install package inside subfolder \"Node/core/\":\nhttps://github.com/Microsoft/BotBuilder/tree/master/Node/core/\nSo how can I install it with npm?"
},
{
"role": "assistant",
"content": "Add to package.json:\n...\n\"scripts\": {\n \"postinstall\": \"mkdir BotBuilder; cd BotBuilder; git init; git remote add -f origin https://github.com/Microsoft/BotBuilder.git; git config core.sparseCheckout true; echo \\\"Node/core\\\" >> .git/info/sparse-checkout; git pull --depth=1 origin master; cd ..; npm i ./BotBuilder/Node/core/\"\n ...\n},\n...\n\npostinstall script is running after the package is installed.\nAnd step by step:\n\nMake folder to clone repo: mkdir BotBuilder\nenter to the folder: cd BotBuilder\ninit git repo: git init\nset git origin to Microsoft/BotBuilder repo: git remote add -f origin https://github.com/Microsoft/BotBuilder.git\nenable sparse checkout: git config core.sparseCheckout true\nadd Node/core to checkout list: echo \"Node/core\" >> .git/info/sparse-checkout\npull part of repo: git pull --depth=1 origin master\nenter to Your app folder: cd ..\ninstall BotBuilder: npm i ./BotBuilder/Node/core/"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-ls-tree - List the contents of a tree object -z"
},
{
"role": "assistant",
"content": "\\0 line termination on output and do not quote filenames.\nSee OUTPUT FORMAT below for more information."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why is the GnuPG-sign checkbox disabled in SourceTree?\nUsing Mac OS X Yosemite (10.10), I cannot active GnuPG-signing of commits in SourceTree, as the checkbox is disabled. How can I enable commit-signing?"
},
{
"role": "assistant",
"content": "You likely aren't pointing the GPG Program setting (found in SourceTree -> Preferences -> Advanced) at the right bin. If you're using GPGTools on OS X, it should be /usr/local/MacGPG2/bin. To navigate to the /usr/bin directory in the Open File dialog, click shift + command + g\n\nIf you installed gnupg with Homebrew, see @chakming`s answer in the comments below."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_SEQUENCE_EDITOR"
},
{
"role": "assistant",
"content": "This environment variable overrides the configured Git editor\nwhen editing the todo list of an interactive rebase. See also git-rebase and the sequence.editor option in git-config ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-push - Update remote refs along with associated objects push.pushOption"
},
{
"role": "assistant",
"content": "When no --push-option=<option> argument is given from the\ncommand line, git push behaves as if each <value> of\nthis variable is given as --push-option=<value> . This is a multi-valued variable, and an empty value can be used in a\nhigher priority configuration file (e.g. .git/config in a\nrepository) to clear the values inherited from a lower priority\nconfiguration files (e.g. $HOME/.gitconfig ). Example:\n\n/etc/gitconfig\n push.pushoption = a\n push.pushoption = b\n\n~/.gitconfig\n push.pushoption = c\n\nrepo/.git/config\n push.pushoption =\n push.pushoption = b\n\nThis will result in only b (a and c are cleared)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Heroku and GitHub: \"Items could not be retrieved, Internal server error\"\n\nThis post relates to a rapidly changing event.\n \n \n\n\n\n\n\n\nI simply want to connect to my GitHub account. When I do it, I get this error message as a small red pop up on the upper right side of the page:\n\nItems could not be retrieved, Internal server error."
},
{
"role": "assistant",
"content": "As of May 25, 2022, at 19:52 UTC, GitHub integration has been re-enabled:\n\nWe are happy to report that the GitHub integration is re-enabled! You can now reconnect with GitHub and restore your Heroku pipeline functionality, including Review Apps, with newly generated tokens.\nYou can connect to GitHub immediately or wait for the enhanced integration as described in this blog post. To re-establish your GitHub connection now, please follow these instructions.\n\nHere is what the referenced blog post says about \"enhanced integration\":\n\nIn an effort to improve the security model of the integration, we are exploring additional enhancements in partnership with GitHub, which include moving to GitHub Apps for more granular permissions and enabling RFC8705 for better protection of OAuth tokens. As these enhancements require changes by both Heroku and GitHub, we will post more information as the engagement evolves.\n\nNo timeline is mentioned for availability of the enhanced integration.\n\nBetween April 15 and May 25, 2022, Heroku's GitHub integration feature was disabled while Heroku investigated a security breach. During that time, deploying was still possible via other means, most notably via git push.\n\nTo mitigate impact from potentially compromised OAuth tokens, we will revoke over the next several hours all existing tokens from the Heroku GitHub integration. We are also preventing new OAuth tokens from being created until further notice. Your GitHub repositories will not be affected in any way by this action.\n\n\nWhich Heroku features have become non-operative due to the removal of the Heroku-GitHub integration?\n\nEnabling review apps\nCreating (automatic and manual) review apps\nDeploying (automatic and manual) review apps\nDeploying an app from GitHub (either manual or automatic)\nHeroku CI cannot create new runs (automatically or manually) or see GitHub branch list\nHeroku Button: unable to create button apps from private repositories\nChatOps: unable to deploy or get deploy notifications\nAny app with a GitHub integration may be affected by this issue. To address specific integration issues, please open a case with Heroku Support\n\n\nMigrating from GitHub deployment to Git deployment\nAt 2022-04-21 23:53 UTC, Heroku provided extended instructions for migrating from GitHub-based deployment to Git-based deployment:\n\nWhile our customers remain unable to reconnect to GitHub via the Heroku dashboard, we wanted to share a supplement to the code deployment methods previously provided. For instructions on how to change your deployment method from GitHub to Heroku Git, please refer to the following Help article: How to switch deployment method from GitHub to Heroku Git with all the changes/app code available in a GitHub repo."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to replace a variable in yml file with a gitlab ci pipeline variable using sed\n\nI want to replace a variable in my .yml file with a variable from the gitlab ci pipeline.\ngitlab-ci.yml\ndeploy_test:\n stage: deploy\n script:\n - sed -i 's/$TAG/$CI_COMMIT_REF_NAME/g' deploy/test.yml\n - kubectl apply -f deploy/test.yml\n when: manual\n only:\n - master\n - tags\n\nThis says within the deploy/test.yml file it should replace $TAG with the value of $CI_COMMIT_REF_NAME?\ndeploy/test.yml\nimage: git.<removed>.com:5005/eng/my-group/my-image:$TAG"
},
{
"role": "assistant",
"content": "Use double quotes(\") instead of single quotes (') in sed and also take note that forward slashes (/) need to be escaped too (like \\/).\nso given the following (assuming you are using docker hub)\n$CI_COMMIT_REF_NAME=docker_user/repo:v1\n\nYou will firstly need to escape the '/' character first, like so\n$CI_COMMIT_REF_NAME=docker_user\\/repo:v1\n\nThen finally use double quotes in the sed command\nsed -i \"s/$TAG/$CI_COMMIT_REF_NAME/g\" deploy/test.yml\n\nNote: In addition to this you can also prefer using | instead of / if there's too many escapes.\nLike:\nsed -i \"s|$TAG|$CI_COMMIT_REF_NAME|g\" deploy/test.yml"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-commit - Record changes to the repository"
},
{
"role": "assistant",
"content": "HOOKS This command can run commit-msg , prepare-commit-msg , pre-commit , post-commit and post-rewrite hooks. See githooks for more\ninformation."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-merge-index"
},
{
"role": "assistant",
"content": "Run a merge for files needing merging"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I make Sublime Text the default editor for Git?\nI have a problem setting Sublime Text 2 as the core.editor with git.\nI've read through every post I could find addressing the problem, but still nothing is working for me. I am running Windows.\nI have done:\ngit config --global core.editor \"'C:/Program Files/Sublime Text 2/sublime_text.exe'\"\n\nand tried that with various arguments like -m. When I open my .gitconfig, this is what is in there:\n[user]\n name = Spencer Moran\n email = [email protected]\n[core]\n editor = 'C:/Program Files/Sublime Text 2/sublime_text.exe'\n\nIf I go to Git and type:\nREADME.markdown --edit\n\nthe README file opens in Notepad, not Sublime Text.\nDoes anyone have any idea what I'm doing wrong or how I could fix this?"
},
{
"role": "assistant",
"content": "Windows\nSublime Text 2 (Build 2181)\nThe latest Build 2181 just added support for the -w (wait) command line argument. The following configuration will allow ST2 to work as your default git editor on Windows. This will allow git to open ST2 for commit messages and such.\ngit config --global core.editor \"'c:/program files/sublime text 2/sublime_text.exe' -w\"\n\nSublime Text 3 (Build 3065)\nSublime Text 3 (Build 3065) added the subl.exe command line helper. Use subl.exe -h for the options available to you. I have hot_exit: true and remember_open_files: true set in my Sublime Text user settings. I have found the following to git config to work well for me.\ngit config --global core.editor \"'c:/program files/sublime text 3/subl.exe' -w\"\n\n\nMac and Linux\nSet Sublime as your editor for Git by typing the following command in the terminal:\ngit config --global core.editor \"subl -n -w\"\n\nWith this Git config, the new tab is opened in my editor. I edit my commit message, save the tab (Ctrl+S) and close it (Ctrl+W).\nGit will wait until the tab is closed to continue its work."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What's the difference between \"Submit review\" and \"Add comment now\" in GitLab's merge request discussions?\n\nFirst time GitLab user and I'm a bit confused when reviewing someone's merge request. Whenever I add a comment I get prompted with two options: Submit review and Add comment now.\n\nWhat's the difference between the two? Why is there a need for two options?"
},
{
"role": "assistant",
"content": "Just heard this from my colleagues, so not sure if this is 100% accurate:\nAdd comment now: instantly adds the comment to the review and notifies the reviewer that a comment has been added. So if you choose this option X times, the reviewer receives X notifications.\nSubmit review: You can add as many comments as you want in as many files as you want. If you choose this option at the end of your review, the reviewer will receive only 1 notification containing all of your comments."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --basic-regexp"
},
{
"role": "assistant",
"content": "Consider the limiting patterns to be basic regular expressions;\nthis is the default."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-switch"
},
{
"role": "assistant",
"content": "Switch branches"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Github file change notification\n\nIs there a way to notify people on change of some certain files? Specifically, I would like to track change of *.sql files and and notify our developers on a change. How can I configure post commit hooks to notify?"
},
{
"role": "assistant",
"content": "If you want folks to get notified via email, and you want them to manage their own notifications, then https://app.github-file-watcher.com/ should do the trick - it monitors any public repo, and will notify you via email of changes to any file, a specific file, or some files that match your criteria."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitfaq - Frequently asked questions about using Git What kinds of problems can occur when merging long-lived branches with squash merges?"
},
{
"role": "assistant",
"content": "In general, there are a variety of problems that can occur when using squash\nmerges to merge two branches multiple times. These can include seeing extra\ncommits in git log output, with a GUI, or when using the ... notation to\nexpress a range, as well as the possibility of needing to re-resolve conflicts\nagain and again. When Git does a normal merge between two branches, it considers exactly three\npoints: the two branches and a third commit, called the merge base , which is\nusually the common ancestor of the commits. The result of the merge is the sum\nof the changes between the merge base and each head. When you merge two\nbranches with a regular merge commit, this results in a new commit which will\nend up as a merge base when they’re merged again, because there is now a new\ncommon ancestor. Git doesn’t have to consider changes that occurred before the\nmerge base, so you don’t have to re-resolve any conflicts you resolved before. When you perform a squash merge, a merge commit isn’t created; instead, the\nchanges from one side are applied as a regular commit to the other side. This\nmeans that the merge base for these branches won’t have changed, and so when Git\ngoes to perform its next merge, it considers all of the changes that it\nconsidered the last time plus the new changes. That means any conflicts may\nneed to be re-resolved. Similarly, anything using the ... notation in git\ndiff , git log , or a GUI will result in showing all of the changes since the\noriginal merge base. As a consequence, if you want to merge two long-lived branches repeatedly, it’s\nbest to always use a regular merge commit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab, in markdown, how can I use anchors other than headers?\n\nI would like to use links in markdown that points to an element in a list or a table (or text) and not specially a header.\nThe only solution I found for markdown is to use HTML anchors :\nThis is a list of actions:\n- <a id=\"action-one\">action one</a>`: blablanla\n- <a id=\"action-two\">action two</a>`: patata\n\nLater, in text, [action one](#action-one) is mandatory...\n\nThis works well in VScode (for example) but not in Gitlab.\nFYI:\n\nUsing name instead of id as explained here would not work for vscode.\nIn the official documentation, there's only mention of header anchors.\n\nAny idea or solution is welcome. Thanks."
},
{
"role": "assistant",
"content": "I found a workaround for the limitations of bmaupin's solution, which is to add an empty link to the <a> tag with the id and name:\n<a id=\"link-ref\" name=\"link-ref\"></a>\n<a href=\"#link-ref\"></a>\n\nIn particular, I used this for headings like this:\n## 2.3 ▸ some section <a id=\"2.3\" name=\"2.3\"></a><a href=\"#2.3\"></a>\n\nwhich renders the heading's text to \"2.3 ▸ some section\"\nThe link is needed because gitlab's markdown engine is too smart for our own good and \"guesses\" that the <a> tag is not needed if there's no link pointing to it."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to get git to show commits in a specified date range for author date?\nApparently this:\ngit log --all --after=\"<date> 00:00\" --before=\"<date> 23:59\" --author=\"<author>\"\n\nfilters commits based on the committer date. How can I make it show commits for a specified author date range ?"
},
{
"role": "assistant",
"content": "Maybe I'm missing something, but wouldn't this be enough?\ngit log --pretty=format:\"%ad - %an: %s\" --after=\"2016-01-31\" --until=\"2017-03-10\" --author=\"John Doe\"\n\nSee also here"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to get \"their\" changes in the middle of conflicting Git rebase?\nI have conflicting branches, feature_x branched from main.\nLet's say when rebasing feature_x on current main, while resolving conflicts, I decide to take some (not all) of \"their\" (i.e. main) files as-is.\nHow do I do that?\nI tried:\ngit checkout main:foo/bar.java\nfatal: reference is not a tree: TS-modules-tmp:foo/bar.java\n \ngit checkout refs/heads/main:foo/bar.java\nfatal: reference is not a tree: refs/heads/TS-modules-tmp:foo/bar.java"
},
{
"role": "assistant",
"content": "You want to use:\ngit checkout --ours foo/bar.java\ngit add foo/bar.java\n\nIf you rebase a branch feature_x against main (i.e. running git rebase main while on branch feature_x), during rebasing ours refers to main and theirs to feature_x.\nAs pointed out in the git-rebase docs:\n\nNote that a rebase merge works by replaying each commit from the\nworking branch on top of the branch. Because of this, when\na merge conflict happens, the side reported as ours is the so-far\nrebased series, starting with <upstream>, and theirs is the working\nbranch. In other words, the sides are swapped.\n\nFor further details read this thread."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitHub clone from pull request?\nI would like to clone a repository from GitHub. The problem is I don't want the main branch; I want the version in this unapproved pull request.\nIs it possible for me to clone the pull request version instead of the main repository?"
},
{
"role": "assistant",
"content": "The easiest way to do that is like this:\ngit fetch origin pull/<pr_number>/head:<local_branch_name>\ngit switch <local_branch_name>\n\nYou will now be on a new branch that is on the state of the pull request.\nYou might want to set up an alias by running\ngit config --global alias.pr '!f() { git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f'\n\nNow you can checkout any PR by running git pr <pr_number>, or git pr <pr_number> <remote> if your github remote is not named origin."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-parse - Pick out and massage parameters --git-dir"
},
{
"role": "assistant",
"content": "Show $GIT_DIR if defined. Otherwise show the path to\nthe .git directory. The path shown, when relative, is\nrelative to the current working directory. If $GIT_DIR is not defined and the current directory\nis not detected to lie in a Git repository or work tree\nprint a message to stderr and exit with nonzero status."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Move commits from master onto a branch using git\nI'm trying to learn how to use Git effectively and I'm wondering how I should (good practice/bad practice?) solve the following case:\nSay I have the following chain of commits in master:\n\nInitial commit\nCommit 1\nCommit 2\nCommit 3\n\nThen I realize that what's done in the last two commits is completely wrong and I need to start from Commit 1 again. Questions:\n\nHow should I do that?\nCan I move Commit 2 and 3 to a separate branch to keep for future reference (say they weren't that bad after all) and continue working from Commit 1 on master?"
},
{
"role": "assistant",
"content": "git branch tmp # mark the current commit with a tmp branch\ngit reset --hard Commit1 # revert to Commit1\n\nThe SO answer \"What's the difference between 'git reset' and 'git checkout' in git?\" is quite instructive for that kind of operation\n\nA git reset --hard HEAD~2 would do the same thing (without needing to get back the SHA1 for Commit1 first). \nSince Commit2 and Commit3 are still reference by a Git ref (here a branch), you can still revert to them anytime you want (git checkout tmp).\n\nActually, Darien mentions in the comments (regarding moving Commit2 and Commit3 to another branch):\n\nAccidentally committed to the wrong branch, this let me move it, did:\n\ngit checkout correctbranch\ngit rebase tmp\ngit branch -d tmp\n\nThis works here since the initial branch has been reset to Commit1, which means the git rebase tmp will replay every commit after Commit1 (so here Commit2 and Commit3) to the new 'correctbranch'."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %ge"
},
{
"role": "assistant",
"content": "reflog identity email"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I clone a private GitLab repository?\n\nWhen I do this:\ngit clone https://example.com/root/test.git\n\nI am getting this error:\n\nfatal: HTTP request failed\n\nWhen I use SSH:\ngit clone username [email protected]:root/test.git\n\nI am getting this error:\n\nInitialized empty Git repository in /server/user/[email protected]:root/test.git/.git/ \n fatal: 'user' does not appear to be a git repository \n fatal: The remote end hung up unexpectedly\n\nIt's a private repository, and I have added my SSH keys."
},
{
"role": "assistant",
"content": "It looks like there's not a straightforward solution for HTTPS-based cloning regarding GitLab. Therefore if you want a SSH-based cloning, you should take account these three forthcoming steps:\n\nCreate properly an SSH key using your email used to sign up. I would use the default filename to key for Windows. Don't forget to introduce a password! (tip: you can skip this step if you already have one ssh key here)\n $ ssh-keygen -t rsa -C \"[email protected]\" -b 4096\n\n Generating public/private rsa key pair.\n Enter file in which to save the key ($PWD/.ssh/id_rsa): [\\n]\n Enter passphrase (empty for no passphrase):[your password]\n Enter same passphrase again: [your password]\n Your identification has been saved in $PWD/.ssh/id_rsa.\n Your public key has been saved in $PWD/.ssh/id_rsa.pub.\n\n\nCopy and paste all content from the recently id_rsa.pub generated into Setting>SSH keys>Key from your GitLab profile.\n # Copy to clipboard\n pbcopy < ~/.ssh/id_rsa.pub\n\n\nGet locally connected:\n $ ssh -i $PWD/.ssh/id_rsa [email protected]\n\n Enter passphrase for key \"$PWD/.ssh/id_rsa\": [your password]\n PTY allocation request failed on channel 0\n Welcome to GitLab, you!\n Connection to gitlab.com closed.\n\n\n\nFinally, clone any private or internal GitLab repository!\n$ git clone https://git.metabarcoding.org/obitools/ROBIBarcodes.git\n\nCloning into 'ROBIBarcodes'...\nremote: Counting objects: 69, done.\nremote: Compressing objects: 100% (65/65), done.\nremote: Total 69 (delta 14), reused 0 (delta 0)\nUnpacking objects: 100% (69/69), done."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects --color[=<when>]"
},
{
"role": "assistant",
"content": "Show colored diff. --color (i.e. without =<when> ) is the same as --color=always . <when> can be one of always , never , or auto ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git log output to XML, JSON, or YAML?\nThis is a pretty simple question: as a Git newbie I was wondering if there's a way for me to output my git log to a file, preferably in some kind of serialized format like XML, JSON, or YAML. Any suggestions?"
},
{
"role": "assistant",
"content": "to output to a file:\ngit log > filename.log\n\nTo specify a format, like you want everything on one line\ngit log --pretty=oneline >filename.log\n\nor you want it a format to be emailed via a program like sendmail\ngit log --pretty=email |email-sending-script.sh\n\nto generate JSON, YAML or XML it looks like you need to do something like:\ngit log --pretty=format:\"%h%x09%an%x09%ad%x09%s\"\n\nThis gist (not mine) perfectly formats output in JSON:\nhttps://gist.github.com/1306223\nSee also:\n\nhttp://git-scm.com/book/en/Git-Basics-Viewing-the-Commit-History\nGit how to save a preset git log --format\nHow to parse the output of git log"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Delete branches in Bitbucket\nI've created lots of branches in one of our repositories. Those branches are for testing before it will be pulled to the master. Now I see lots of them on the list and they we will never use it again. How to delete those branches directly to Bitbucket?"
},
{
"role": "assistant",
"content": "If the branches are only local, you can use -d if the branch has been merged, like\ngit branch -d branch-name\n\nIf the branch contains code you never plan on merging, use -D instead.\nIf the branch is in the upstream repo (on Bitbucket) you can remove the remote reference by \ngit push origin :branch-name\n\nAlso, if you're on the Bitbucket website, you can remove branches you've pushed by going to the Feature branches tab under Commits on the site. There you'll find an ellipsis icon. Click that, then choose Delete branch. Just be sure you want to drop all the changes there!"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-grep - Print lines matching a pattern -p --show-function"
},
{
"role": "assistant",
"content": "Show the preceding line that contains the function name of\nthe match, unless the matching line is a function name itself.\nThe name is determined in the same way as git diff works out\npatch hunk headers (see Defining a custom hunk-header in gitattributes )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-ls-files - Show information about files in the index and the working tree --resolve-undo"
},
{
"role": "assistant",
"content": "Show files having resolve-undo information in the index\ntogether with their resolve-undo information. (resolve-undo\ninformation is what is used to implement \"git checkout -m\n$PATH\", i.e. to recreate merge conflicts that were\naccidentally resolved)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects -D --irreversible-delete"
},
{
"role": "assistant",
"content": "Omit the preimage for deletes, i.e. print only the header but not\nthe diff between the preimage and /dev/null . The resulting patch\nis not meant to be applied with patch or git apply ; this is\nsolely for people who want to just concentrate on reviewing the\ntext after the change. In addition, the output obviously lacks\nenough information to apply such a patch in reverse, even manually,\nhence the name of the option. When used together with -B , omit also the preimage in the deletion part\nof a delete/create pair."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can deleted .git be restored?\n\nThis happened when working with git on Ruby on Rails.\nseveral commits and branches were done and created.\ngit version 1.7.3.4\n\nI accidentally deleted the .git folder using\ngit -rf .git\n\nbut I have all the files and updates done on online git-hub repository.\nI want the .git folder restored. Questions ?\n\nAm I totally screwed up ? OR \nIf theres a way to restore .git from my online git-hub repository, how can\nthat be done ?"
},
{
"role": "assistant",
"content": "The only way you can restore a deleted .git folder is by:\n\nCloning it again from somewhere\nChecking your recycling bin or backup (if no remote repository exists)\n\nSince your files are from the online github repository, then its simple. Just clone it again from the directory where you deleted the .git folder:\ngit init\ngit remote add origin <repo_address>\ngit pull origin master\n\nwhere repo_address can be [email protected]:yourname/yourproject.git\nYour local checkout will be back to normal. \nIf you have uncommitted changes in your working copy you would want to keep, instead of using git pull use git fetch and then git reset --soft your local branch to the remote branch it should be at. The soft reset will not change your working copy"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --raw"
},
{
"role": "assistant",
"content": "Generate the diff in raw format."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --diff-algorithm={patience|minimal|histogram|myers}"
},
{
"role": "assistant",
"content": "Choose a diff algorithm. The variants are as follows: default , myers The basic greedy diff algorithm. Currently, this is the default. minimal Spend extra time to make sure the smallest possible diff is\nproduced. patience Use \"patience diff\" algorithm when generating patches. histogram This algorithm extends the patience algorithm to \"support\nlow-occurrence common elements\". For instance, if you configured the diff.algorithm variable to a\nnon-default value and want to use the default one, then you\nhave to use --diff-algorithm=default option."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rebase - Reapply commits on top of another base tip subtree"
},
{
"role": "assistant",
"content": "This is a modified ort strategy. When merging trees A and\nB, if B corresponds to a subtree of A, B is first adjusted to\nmatch the tree structure of A, instead of reading the trees at\nthe same level. This adjustment is also done to the common\nancestor tree."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to manage multiple versions of a project? [closed]\nClosed. This question is opinion-based. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it can be answered with facts and citations by editing this post.\n\n\nClosed 4 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI have a project that is open sourced using git for revision control. Soon, I am going to release a premium hosted version of the project as well, but there will be changes made to the code specifically for the premium hosted version (performance, etc.), that should not exist in the open source version.\nI want to avoid having two separate directories/projects, because if I fix a bug in the open source version, that bug is most likely in the premium hosted version as well. I don't want to make changes in two places.\nWhat is the best way to manage this? Simply branching in git won't work right, because some files need to have 2 versions: an open source version and a premium hosted version."
},
{
"role": "assistant",
"content": "And yet, branching should work, and will allow you to maintain two separate versions.\nIf you have a bug which applies to the premium version, fix it on master, and merge it on premium branch.\nGit will only merge what has changed since you branched between master and premium, ie your bug fix.\nOn another way to publish an hotfix both in master and premium would be to do it from the common ancestor: see \"Git merging hotfix to multiple branches\".\n\nUpdate 2015: git 2.5 (July 2015) has replaced git-new-workdir presented below by the new command git worktree add <path> [<branch>].\nFor more, see \"Multiple working directories with Git?\".\n\nOriginal answer 2012:\nme-and mentions in the comments the command git-new-workdir.\nSee:\n\nWorking with a branch using git-new-workdir\"\n\"The Nuclear Squid git-new-workdir\"\n\n\nOne solution to this is to simply create another local clone of your repository. Git automatically uses hard links when you clone locally, so cloning is very fast.\n But there is one problem with this: You now have another, separate repository you need to keep up to date.\nThis is where git-new-workdir comes in.\n Instead of doing a full-blown clone of your repository, it simply sets up a new working directory (with its own index) for you.\n The actual repository itself is shared between the original and the new working directory. This means: \n\nIf you update one repository, the new commits are instantly visible in all other working directories as well. \nCreate a new commit or branch in one of your working directories, they’re instantly available in all working directories.\n\nNote: Even though the commits are automatically there, Git won’t update the working copy if you’ve got the same branch checked out. You’ll have to do that for yourself."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitprotocol-pack"
},
{
"role": "assistant",
"content": "How packs are transferred over-the-wire"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can you track or be notified of changes to GitHub wikis?\n\nAre there service hooks for GitHub wiki repositories? Is there some other mechanism that GitHub provides for me to track wiki edits?"
},
{
"role": "assistant",
"content": "Push approach: Within the GitHub API documentation, you can find documentation about setting up service hooks which can be triggered for one or more events. The gollum event is especially raised any time a wiki page is updated.\nJSON-based pull approach: You can also leverage the Events HTTP API to retrieve a JSON formated output of what happens on GitHub, then apply some filtering in order to isolate the events of type GollumEvent.\nBelow a quick jQuery-based sample\n<html>\n <head>\n <title>Gollum events</title>\n <script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js\"></script>\n <script type=\"text/javascript\">\n $(function() {\n $.getJSON('https://api.github.com/repos/holman/spark/events?callback=?', function(data) {\n\n var list = $('#gollum-events');\n\n $.each(data.data, function(key, val) {\n if (val.type == \"GollumEvent\") {\n $.each(val.payload.pages, function(key2, val2) {\n list.append('<li id=\"' + key + '.' + key2 + '\"><a href=\"' + val2.html_url + '\">' + val2.page_name + '</a> [' + val.actor.login + ' @ ' + val.created_at + ']</li>');\n });\n }\n });\n });\n });\n </script>\n </head>\n <body>\n <ul id=\"gollum-events\"/>\n </body>\n</html>\n\nAtom based pull approach: Last but not least, you can subscribe to the wiki changes atom feed. Go to the GitHub Wiki section of the repository, select the Pages sub tab, hover onto the orange icon, copy the link and paste into your favorite RSS reader.\n\nUpdate:\nIt looks like the RSS feed icon is no longer displayed for a wiki.\nHowever, you can still build the URL by yourself\n\nSyntax: https://github.com/:user/:repository/wiki.atom\nExample: https://github.com/holman/spark/wiki.atom"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to get default Git branch?\n\nMy team alternates between usage of dev and master as default branch for several repos and I would like to write a script that checks for the default branch when entering a directory.\nWhen pull requests are opened in some of these repos, they either default to 'dev' or 'master' as the merge target.\nI understand how to set this information but not retrieve it: \nhttps://help.github.com/articles/setting-the-default-branch/\nIs there a git command available to determine default branch for remote repository?"
},
{
"role": "assistant",
"content": "I found a way to detect the default-branch if it is not master.\ngit remote show [your_remote] | sed -n '/HEAD branch/s/.*: //p'\n\nI tested it with multiple repo from gitlab, and it worked fine.\n(for the most situations [your_remote] will be origin, run git remote to check the name of your remote)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc git diff [<options>] [--merge-base] <commit> <commit> [--] [<path>…]"
},
{
"role": "assistant",
"content": "This is to view the changes between two arbitrary\n<commit>. If --merge-base is given, use the merge base of the two commits for the\n\"before\" side. git diff --merge-base A B is equivalent to git diff $(git merge-base A B) B ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %(decorate[:<options>])"
},
{
"role": "assistant",
"content": "ref names with custom decorations. The decorate string may be followed by a\ncolon and zero or more comma-separated options. Option values may contain\nliteral formatting codes. These must be used for commas ( %x2C ) and closing\nparentheses ( %x29 ), due to their role in the option syntax. prefix=<value> : Shown before the list of ref names. Defaults to \" ( \". suffix=<value> : Shown after the list of ref names. Defaults to \" ) \". separator=<value> : Shown between ref names. Defaults to \" , \". pointer=<value> : Shown between HEAD and the branch it points to, if any.\nDefaults to \" -> \". tag=<value> : Shown before tag names. Defaults to \" tag: \"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I push a specific branch of Git to my server?\nI'm working to deploy a Django app.\nThe app built on a Github OS project. I have this stored locally as the Master branch.\n$ git branch \n* master \n customized - customized with local dev settings \n webfaction_customized - with production server settings \n\nThe customizations for this project are stored in 2 separate branches. \nMy plan was to perform my customization locally in 'customized', then merge those changes into 'webfaction_customized'\nThen push these changes to a bare repository on the production_server:\nI would then clone this bare repository on the production_server, change the settings in the cloned repository and restart the fcgi process.\nThe first problem was that I found this if I tried to push a branch to the server that wasn't master, I could not clone from the bare repository.\nSo I tried to push the master branch to the server.\ngit push webfaction_server master\n\nBut now I'm finding that none of my branches are uploaded. \nIs there some way to push a specific branch to a bare repository and be able to clone that branch? \nOR \nDo I need to restructure my project so that Master branch is my customizations and the Github project would be in a github branch?"
},
{
"role": "assistant",
"content": "You would simply do:\ngit push origin webfaction_customized\n\nWhere origin is your remote name and webfaction_customized is your custom branch.\nHence, when you work on the master branch, you are pushing via:\ngit push origin master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fast-import - Backend for fast Git data importers done"
},
{
"role": "assistant",
"content": "Marks the end of the stream. This command is optional\nunless the done feature was requested using the --done command-line option or feature done command."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git fetch origin vs git fetch --all\nWhat is the difference between the following git commands?\ngit fetch origin\n\nand\ngit fetch --all\n\nRunning them from the command line looks like they do the same thing."
},
{
"role": "assistant",
"content": "git fetch origin fetch data only from origin, and git fetch --all fetch data from all remotes (origin is one of them)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to Configure Capistrano to Deploy from Local Git Repository?\nWhat changes do I need to make to the deploy.rb file below to make it deploy my app from a local git repo? If I can't deploy from a local repo, can I have capistrano use the working copying instead?\nset :application, \"my_app\"\nset :repository, \".\"\nset :local_repository, \"file:///path/to/application/.git\"\nset :deploy_to, \"/data/www/apps/#{application}\"\nset :deploy_via, :copy\nset :copy_cache, true\nset :user, \"dane\"\nset :use_sudo, false\n\nset :scm, :git # Should I change this to :none\nset :branch, \"master\""
},
{
"role": "assistant",
"content": "That's easy:\nset :scm, :none\nset :repository, \".\"\nset :deploy_via, :copy\n\nSimply run Capistrano from the root of your project."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "giteveryday - A useful minimum set of commands for Everyday Git Create a topic branch and develop."
},
{
"role": "assistant",
"content": "$ git switch -c alsa-audio (1) $ edit/compile/test\n$ git restore curses/ux_audio_oss.c (2) $ git add curses/ux_audio_alsa.c (3) $ edit/compile/test\n$ git diff HEAD (4) $ git commit -a -s (5) $ edit/compile/test\n$ git diff HEAD^ (6) $ git commit -a --amend (7) $ git switch master (8) $ git merge alsa-audio (9) $ git log --since='3 days ago' (10) $ git log v2.43.. curses/ (11) create a new topic branch. revert your botched changes in curses/ux_audio_oss.c . you need to tell Git if you added a new file; removal and\nmodification will be caught if you do git commit -a later. to see what changes you are committing. commit everything, as you have tested, with your sign-off. look at all your changes including the previous commit. amend the previous commit, adding all your new changes,\nusing your original message. switch to the master branch. merge a topic branch into your master branch. review commit logs; other forms to limit output can be\ncombined and include -10 (to show up to 10 commits), --until=2005-12-10 , etc. view only the changes that touch what’s in curses/ directory, since v2.43 tag."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Scheduled pipeline in gitlab using .gitlab-ci.yaml file\n\nI was trying to schedule a ci/cd pipeline in gitlab using .gitlab-ci.yaml file. I did't find a right documentation to implement the schedule using the ci/cd yaml file.\nIs it possible to configure a pipeline run schedule (say everyday 08:00 AM) in .gitlab-ci.yaml file?\nThanks\nArun"
},
{
"role": "assistant",
"content": "Unfortunately, Scheduled pipeline is realized through GUI rather than .gitlab-ci.yml file in GitLab\nYou may find this document useful if you want to use GUI for schedule pipeline. Configuring in GUI is simpler than yaml coding.\nIf you really want it to be configured in yaml file, you may create an issue in GitLab repo. Actually, there's already an issue on this topic. It should not be a very difficult technically since it is only about keywords and parsing. Whether GitLab will do it or not is another story; so you'd better prepare a good scenario to persuade the GitLab team why you want this to be done."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --ignore-submodules[=<when>]"
},
{
"role": "assistant",
"content": "Ignore changes to submodules in the diff generation. <when> can be\neither \"none\", \"untracked\", \"dirty\" or \"all\", which is the default.\nUsing \"none\" will consider the submodule modified when it either contains\nuntracked or modified files or its HEAD differs from the commit recorded\nin the superproject and can be used to override any settings of the ignore option in git-config or gitmodules . When\n\"untracked\" is used submodules are not considered dirty when they only\ncontain untracked content (but they are still scanned for modified\ncontent). Using \"dirty\" ignores all changes to the work tree of submodules,\nonly changes to the commits stored in the superproject are shown (this was\nthe behavior until 1.7.0). Using \"all\" hides all changes to submodules."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker <file>"
},
{
"role": "assistant",
"content": "Indicates a filename - almost always relative to the\nroot of the tree structure GIT_INDEX_FILE describes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Github Commit Syntax to Link a Pull Request/ Issue\n\nI've seen commit messages that refer to a specific issue / pull request. What is the syntax to include a specific repository's issue or pull request?"
},
{
"role": "assistant",
"content": "Use the documented auto-linking format for issues across repositories.\n\nSyntax: {owner}/{repository}#{issue_number}\nExample: mojombo/jekyll#1\n\nWhen such formatted text is present in a commit message, it's automatically transformed into a clickable link which will redirect one to https://github.com/{owner}/{repository}/issues/{issue_number}"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_CEILING_DIRECTORIES"
},
{
"role": "assistant",
"content": "This should be a colon-separated list of absolute paths. If\nset, it is a list of directories that Git should not chdir up\ninto while looking for a repository directory (useful for\nexcluding slow-loading network directories). It will not\nexclude the current working directory or a GIT_DIR set on the\ncommand line or in the environment. Normally, Git has to read\nthe entries in this list and resolve any symlink that\nmight be present in order to compare them with the current\ndirectory. However, if even this access is slow, you\ncan add an empty entry to the list to tell Git that the\nsubsequent entries are not symlinks and needn’t be resolved;\ne.g., GIT_CEILING_DIRECTORIES=/maybe/symlink::/very/slow/non/symlink ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options diff.colorMoved"
},
{
"role": "assistant",
"content": "If set to either a valid <mode> or a true value, moved lines\nin a diff are colored differently, for details of valid modes\nsee --color-moved in git-diff . If simply set to\ntrue the default color mode will be used. When set to false,\nmoved lines are not colored."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Overwrite master with branch\nI want to overrite master with a particular branch after making changes to it, what I done to do it is:\nStep 1: Checkout brranch from Git, using command :\ngit checkout branch_name\n\nStep 2: I done some changes in code, now I want to make this branch as master, for that I first run the command:\ngit status\n\nAbove command list me all the modified files.\nNow my question, what all I need to do overrite master with this particular branch \"my_branch\"?"
},
{
"role": "assistant",
"content": "git branch -f master dev_branch will rewrite local master branch.\ngit push remote +dev_branch:master will rewrite remote branch.\n\nNOTE: If the above doesn't work, the name remote could be origin for you (i.e. git push origin +dev_branch:master)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc -s --no-patch"
},
{
"role": "assistant",
"content": "Suppress all output from the diff machinery. Useful for\ncommands like git show that show the patch by default to\nsquelch their output, or to cancel the effect of options like --patch , --stat earlier on the command line in an alias."
}
] |
[
{
"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": "How to alias 'git checkout' to 'git co'\nI'd like the command git co to be the same as typing git checkout.\nA normal Bash alias (alias co='checkout') doesn't work."
},
{
"role": "assistant",
"content": "The command:\ngit config --global alias.co checkout\nwill create a git alias to do that. It will add the following entry into your global ~/.gitconfig file:\n[alias]\n co = checkout"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-tag - Create, list, delete or verify a tag object signed with GPG --no-sign"
},
{
"role": "assistant",
"content": "Override tag.gpgSign configuration variable that is\nset to force each and every tag to be signed."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can GitHub automatically merge branches?\n\nWe want to automatically merge out from master to another long-lived branch whenever any changes are committed to master (at the moment, this is a manual process and people forget)\nI appreciate that it may not always be possible, owing to merge conflicts, but if it is possible, we'd like it to happen automatically.\nIs this possible?"
},
{
"role": "assistant",
"content": "You can use GitHub Actions since Aug 13, 2019\nThis method will merge your branch with the master without the requirement to create pull requests manually.\nJust create .github/workflows/automerge.yml file in your repo with this content:\nname: Automerge\n\non:\n workflow_dispatch:\n schedule:\n # You can setup schedule here\n - cron: '0 0 * * *'\n\nenv:\n # replace \"github_username\" with your GitHub username\n # replace \"github.com/username/repo.git\" with your GitHub repo path\n # do NOT replace ${{secrets.GITHUB_TOKEN}}, GitHub will take care of it\n MY_REPO: https://github_username:${{secrets.GITHUB_TOKEN}}@github.com/username/repo.git\n\n # replace \"long-lived_branch_name\" with your branch name\n MY_BRANCH: long-lived_branch_name\n\n # replace it with the path to master repo\n MASTER_REPO: https://github.com/username/master_repo.git\n\n # replace \"master\" with your master branch name\n MASTER_BRANCH: master\n\njobs:\n merge:\n runs-on: ubuntu-latest\n\n steps:\n - name: Merge with master\n run: |\n git clone ${{env.MY_REPO}} -b ${{env.MY_BRANCH}} tmp\n cd tmp\n git config user.name \"Automerge Bot\"\n git config user.email \"[email protected]\"\n git config pull.rebase false\n git pull ${{env.MASTER_REPO}} ${{env.MASTER_BRANCH}}\n git push\n\n\n\nreplace \"github_username\" with your GitHub username\nreplace \"github.com/username/repo.git\" with your GitHub repo path\nreplace \"long-lived_branch_name\" with your branch name\nreplace \"master\" with your master branch name\nedit \"cron\" line to adjust the schedule\n\nAlso, don't forget to enable this workflow on the \"Actions\" page of your repo. You can run it manually too. You'll receive an e-mail from GitHub if merge was failed."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-notes - Add or inspect object notes --[no-]stripspace"
},
{
"role": "assistant",
"content": "Strip leading and trailing whitespace from the note message.\nAlso strip out empty lines other than a single line between\nparagraphs. Lines starting with # will be stripped out\nin non-editor cases like -m , -F and -C , but not in\neditor case like git notes edit , -c , etc."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I pull files from remote without overwriting local files?\n\nI am trying to set up a new git repo to a pre-existing remote repo.\nI want my local files to overwrite the remote repo, but git says that I first have to pull those remote files in and merge them.\nIs there any way to pull but make sure that the local files are not overwritten by the remote?"
},
{
"role": "assistant",
"content": "Well, yes, and no...\nI understand that you want your local copies to \"override\" what's in the remote, but, oh, man, if someone has modified the files in the remote repo in some different way, and you just ignore their changes and try to \"force\" your own changes without even looking at possible conflicts, well, I weep for you (and your coworkers) ;-)\nThat said, though, it's really easy to do the \"right thing...\"\nStep 1:\ngit stash\n\nin your local repo. That will save away your local updates into the stash, then revert your modified files back to their pre-edit state.\nStep 2:\ngit pull\n\nto get any modified versions. Now, hopefully, that won't get any new versions of the files you're worried about. If it doesn't, then the next step will work smoothly. If it does, then you've got some work to do, and you'll be glad you did.\nStep 3:\ngit stash pop\n\nThat will merge your modified versions that you stashed away in Step 1 with the versions you just pulled in Step 2. If everything goes smoothly, then you'll be all set!\nIf, on the other hand, there were real conflicts between what you pulled in Step 2 and your modifications (due to someone else editing in the interim), you'll find out and be told to resolve them. Do it.\nThings will work out much better this way - it will probably keep your changes without any real work on your part, while alerting you to serious, serious issues."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs -E --extended-regexp"
},
{
"role": "assistant",
"content": "Consider the limiting patterns to be extended regular expressions\ninstead of the default basic regular expressions."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Configure Git to use Plink\nI'm trying to configure Git to use Plink. It worked for me many times before. Now, for some reason, this option isn't available to me (it is disabled):\n\nI tried uninstalling and reinstalling Git a hundred times. Nothing. I can't get to this option enabled."
},
{
"role": "assistant",
"content": "I just had this problem (with a newer version of Git, 1.7.9). I used the answer from VonC, but only a couple of steps were needed:\n\nSet the environment variable GIT_SSH to the location of plink.exe\nRun pageant.exe and load your private key\n\nOn 64 bit Windows, the default location for plink is C:\\Program Files (x86)\\GitExtensions\\PuTTY\\plink.exe\nThe spaces in the path no longer seem to be a problem."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary object name"
},
{
"role": "assistant",
"content": "The unique identifier of an object . The\nobject name is usually represented by a 40 character\nhexadecimal string. Also colloquially called SHA-1 ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.wordRegex"
},
{
"role": "assistant",
"content": "A POSIX Extended Regular Expression used to determine what is a \"word\"\nwhen performing word-by-word difference calculations. Character\nsequences that match the regular expression are \"words\", all other\ncharacters are ignorable whitespace."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Find a Pull Request on GitHub where a commit was originally created\n\nPull Requests are great for understanding the larger thinking around a change or set of changes made to a repo. Reading pull requests are a great way to quickly \"grok\" a project as, instead of small atomic changes to the source, you get larger groupings of logical changes. Analogous to organizing the lines in your code into related \"stanzas\" to make it easier to read.\nI find myself looking at a file or a commit, and I wonder if there is a way to backtrack the commit to the Pull Request that originally created it. That Pull Request would have been merged eventually, but not necessary with a merge-commit."
},
{
"role": "assistant",
"content": "You can just go to GitHub and enter the SHA into the search bar, make sure you select the \"Issues\" link on the left.\nUPDATED 13 July 2017\nVia the GitHub UI there is a now a really easy way to do this. If you are looking at a commit in the list of commits in a branch in the UI, click on the link to the commit itself. If there is a PR for that commit and it wasn't added directly to the branch, a link to the PR listing the PR number and the branch it went into will be directly under the commit message at the top of the page.\n\n\n\nIf you have the commit SHA and nothing else and don't want to go digging around for it, just add /commit/[commit SHA] to the repo url, and you will see the commit page, with the PR link if it exists.\nFor example, if the SHA is 52797a7a3b087231e4e391e11ea861569205aaf4 and the repo is https://github.com/glimmerjs/glimmer-vm , then go to https://github.com/glimmerjs/glimmer-vm/commit/52797a7a3b087231e4e391e11ea861569205aaf4"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Max file size and max repository size in Git?\nI'm looking to have Git as the primary source control for my employer (250 people) company. Before proceeding further I would like to have answers to the following questions.\n\nDoes Git have any specific max file size limit that it can handle? If so, what is it?\nWhat is the max repository size recommended by Git? This would help me determine the housekeeping I should set on the repository."
},
{
"role": "assistant",
"content": "As mentioned in Git limits, Git has no file size or file number limit per se.\nBut it:\n\nWon't manage large files too well (which is why a project like Git-BigFiles exists)\nTag every file within its repository, which is why, if you have many different sets of files which each have their own development life-cycle, it is better to use several Git repositories anyway (see true nature of submodules).\nThat approach is more suited to a component-driven development, and is quite different from the SVN external."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git SVN error: a Git process crashed in the repository earlier\nI was just trying to commit changes to the Git master. From what I have read, it seems that the idea is to delete the lock file. The message says:\n\nmake sure no other Git processes are running and remove the file manually\n\nPerhaps someone knows, which file to remove and how to remove?"
},
{
"role": "assistant",
"content": "The file in question is likely .git/index.lock and it should be safe to just remove it if you have no other git processes running. Make sure a git-svn command isn't hanging.\nPS My usual approach to fixing git-svn problems is to make a fresh pull of the repository. Time consuming, but you can do it in parallel with trying to fix the problem. Have a little race between you and git. Of course, this only works if you didn't have unpushed commits."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I merge many commits, but leave one out?\nSuppose I have this feature branch \"foo\". Now I want to merge it back into master, but I've added some debugging code that I don't want in master. \nThe debug code is in it's own commit, so I could use git cherry-pick on each commit and leave out this commit. But that's gonna be quite tiresome. \nIs there some \"inverse cherry-pick\" that does this, or an interactive merge?"
},
{
"role": "assistant",
"content": "Despite what other SCMs use it to mean, in git, git revert is an inverse cherry-pick."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git stash changes apply to new branch?\nI was working on master branch, made some changes and then stashed them. Now, my master is at HEAD.\nBut now, I want to retrieve these changes but to a new branch which branches from the HEAD version of the master branch. \nHow do i do this ?"
},
{
"role": "assistant",
"content": "The usual, standard procedure is:\n\nmake changes\ngit stash save\ngit branch xxx HEAD\ngit checkout xxx\ngit stash pop\n\nShorter:\n\nmake changes\ngit stash\ngit checkout -b xxx\ngit stash pop"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Keep ignored files out of git status\nI would like to stop Git from showing ignored files in git status, because having tons of documentation and config files in the list of Changed but not updated files, renders the list half-useless.\nIs it normal for Git to show these files? \nI put the ignore information in a .gitignore file in the root directory of the Git repository and they are not added when using git add . but it seems that they are not fully ignored either, as they show up in the aforementioned list and do not show up in the list printed by git ls-files --others -i --exclude-standard. Only files matched by the patterns in ~/.gitignore show up there.\nCould it be because at an earlier stage I didn't ignore them and they were thus committed at least once?"
},
{
"role": "assistant",
"content": "As I found in this post, .gitignore only works for untracked files. If you added files to repository, you can:\ngit update-index --assume-unchanged <file>\n\nor remove them from repository by\ngit rm --cached <file>\n\nEdit\nThis article explains that too"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to deploy private jar to gitlab Maven repository\n\nI would like to know if it is possible to deploy a custom jar file into an existing maven repository. By custom, I mean, my own existing jar from my local machine.\nSo, I have a project test-project on gitlab (https://gitlab.com/group/test-project), and it is a java application that I build and deploy using gitlab pipelines. In the build stage, I am doing mvn deploy and the package test-project.jar is pushed to a gitlab maven repository (https://gitlab.com/group/test-project/-/packages). \nNow, I have a dependency.jar file which is listed as a dependency in my pom.xml. I would like to push that file into the same maven repository as my test-project.jar. There is nothing about that in the documentation here. https://docs.gitlab.com/ee/user/packages/maven_repository\nI tried to push it with maven-deploy-plugin in a way described here http://maven.apache.org/guides/mini/guide-3rd-party-jars-remote.html\nI am getting an error Failed to deploy artifacts: Could not find artifact... which is strange because I am trying to push new artifact, of course, it does not exist.\nI am not sure if this is an issue with GitLab (I doubt that) or I am doing something wrong, or what I want is just not possible.\n\nEdit\nI was able to push the package but the thing is I needed to run deploy:deploy-file from the build, not from my local. \nThis would be the pipeline configuration\n\nstages:\n - build\n\nmaven-repo-push:\n stage: build\n image: maven:3.6.2\n variables:\n GROUP: \"com.example\"\n ARTIFACT: \"myproject\"\n VERSION: \"1.1.1\"\n REPO_PROJECT_ID: \"12345678\" #gitlab project ID\n script:\n - mvn deploy:deploy-file\n -DgroupId=$GROUP\n -DartifactId=$ARTIFACT\n -Dversion=$VERSION\n -Dpackaging=jar\n -Dfile=$ARTIFACT-$VERSION.jar\n -DgeneratePom=false\n -DpomFile=$ARTIFACT-$VERSION.pom\n -Dfiles=$ARTIFACT-$VERSION-tests.zip\n -Dtypes=zip\n -Dclassifiers=tests\n -DrepositoryId=gitlab-maven\n -Durl=https://gitlab.com/api/v4/projects/$REPO_PROJECT_ID/packages/maven\n -s settings.xml\n when: manual\n\n\nMake sure you have pushed with this configuration the files you want to push in format $ARTIFACT-$VERSION.jar and \nThe default settings.xml needed for authentication\nhttps://docs.gitlab.com/ee/user/packages/maven_repository/#authenticating-with-a-ci-job-token \nStill, my question remains, is it possible to do this from local"
},
{
"role": "assistant",
"content": "You can publish a library/jar from local file system as well, just have a settings.xml something like\n<settings>\n <servers>\n <server>\n <id>gitlab-maven</id>\n <configuration>\n <httpHeaders>\n <property>\n <name>Private-Token</name>\n <value>PUT-YOUR-PRIVATE-TOKEN-HERE</value>\n </property>\n </httpHeaders>\n </configuration>\n </server>\n </servers>\n</settings>\n\nOr if you wan to use a group token or deploy token , make sure you update the property name above , documented here https://docs.gitlab.com/ee/user/packages/maven_repository/#authenticate-with-a-deploy-token-in-maven\nAnd then use this to publish your jar on GitLab's package registry, keep in mind that you can only publish to project api endpoints , but you can use group endpoints to download/install artifacts locally\nmvn -s settings.xml deploy:deploy-file \\\n-Durl=https://gitlab.com/api/v4/projects/<PUT-PROJECT-ID-HERE>/packages/maven \\\n-DrepositoryId=REPOSITORY-ID # has to match the settings.xml server:id \\\n-Dfile=your-lib.jar \\\n-DgroupId=your.group.id \\\n-DartifactId=artifact-name \\\n-Dversion=1.0 \\\n-Dpackaging=jar \\\n-DgeneratePom=false"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-apply - Apply a patch to files and/or to the index --summary"
},
{
"role": "assistant",
"content": "Instead of applying the patch, output a condensed\nsummary of information obtained from git diff extended\nheaders, such as creations, renames, and mode changes.\nTurns off \"apply\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-commit - Record changes to the repository -F <file> --file=<file>"
},
{
"role": "assistant",
"content": "Take the commit message from the given file. Use - to\nread the message from the standard input."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to disable pull requests in GitHub?\n\nI am trying to understand how will I be able to disable \"pull requests\" in github.\nQuestion 1: \nWe are trying to use the rebase workflow and that means using pull requests can be harmful if that isn't a fast forward push.\nOne Solution: Setup branch permissions for the branches where I want to disable pull request. Or add me as the reviewer to anything that goes into master. \nQuestion 2:\nSo that begs the question, can I setup branch permissions in github ?? Can I add myself as a reviewer for any change that wants to get into master ?\nQuestion 3:\nGithub has definitely removed pre-receive hooks, so how can I do any enforcements before the source hits the server ? pre-commit hooks can be done, but at the same time can be pain. \nI had asked a similar question here: Commit message hook on github\nIt seems github could be useful for the merge workflow or even git-flow, but it can be hard to maintain for the rebase workflow, is that a fair assumption ? \nCan I consider atlassian Stash as a better tool for the rebase workflow ?"
},
{
"role": "assistant",
"content": "It is not possible according to GitHub support\nI asked support [email protected] on February 2018 if it was possible to remove the Pull Requests tab, and the reply from @nickcannariato was:\n\nThanks for writing in! We've definitely heard some users requesting this feature over the last couple of years, and it's currently on our feature request list. I can't make any promises about if or when we may add this ability in the future, but I'll add your +1 to that feature request so the team can see it.\n\nconfirming that it is not possible.\nRequest on the de-facto trackers:\n\nhttps://github.com/isaacs/github/issues/1191\nhttps://github.com/dear-github/dear-github/issues/84"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git - Ignore node_modules folder everywhere\nI have a project containing multiple other projects : \n\nMain project\n\nMini project 1\nMini project 2\n\n\nAll containing node_modules folder. I want git to ignore the folder no matter where it is starting from the root folder. Something like this to add in .gitignore : \n*node_modules/*"
},
{
"role": "assistant",
"content": "Add node_modules/\nor node_modules\nto the .gitignore file to ignore all directories called node_modules in the current folder and any subfolders like the below image."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --ancestry-path[=<commit>]"
},
{
"role": "assistant",
"content": "When given a range of commits to display (e.g. commit1..commit2 or commit2 ^commit1 ), only display commits in that range\nthat are ancestors of <commit>, descendants of <commit>, or\n<commit> itself. If no commit is specified, use commit1 (the\nexcluded part of the range) as <commit>. Can be passed multiple\ntimes; if so, a commit is included if it is any of the commits\ngiven or if it is an ancestor or descendant of one of them."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-parse - Pick out and massage parameters --no-revs"
},
{
"role": "assistant",
"content": "Do not output flags and parameters meant for git rev-list command."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the difference between Git Bash and the GitHub for Windows shell?\n\nI'm referring to the shell that comes with GitHub for Windows (Github CLI), and Git Bash (which has a stand alone installer)."
},
{
"role": "assistant",
"content": "Well, for one thing, the default shell that comes with GitHub for Windows is PoshGit, which is a Windows Power Shell environment for Git. On the other hand, Git Bash/msysGit uses the Bash shell (Bourne Again Shell) and MinGW, which is a port of a Linux style environment and command line tools.\nPoshGit will let you use Windows and Power Shell commands with Git at the command line, while Git Bash will let you use MinGW/Linux tools with Git at the command line."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-ls-files - Show information about files in the index and the working tree -i --ignored"
},
{
"role": "assistant",
"content": "Show only ignored files in the output. Must be used with\neither an explicit -c or -o . When showing files in the\nindex (i.e. when used with -c ), print only those files\nmatching an exclude pattern. When showing \"other\" files\n(i.e. when used with -o ), show only those matched by an\nexclude pattern. Standard ignore rules are not automatically\nactivated; therefore, at least one of the --exclude* options\nis required."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to create file execute mode permissions in Git on Windows?\nI use Git in Windows, and want to push the executable shell script into git repo by one commit.\nUsually I need to do two steps (git commit).\n$ vi install.sh\n$ git add install.sh \n$ git commit -am \"add new file for installation\" # first commit\n[master f2e92da] add support for install.sh\n 1 files changed, 18 insertions(+), 3 deletions(-)\n create mode 100644 install.sh\n$ git update-index --chmod=+x install.sh\n$ git commit -am \"update file permission\" # second commit\n[master 317ba0c] update file permission\n 0 files changed\n mode change 100644 => 100755 install.sh\n\nHow can I combine these two steps into one step? git configuration? windows command?\nReference: see question in Git file permissions on Windows for second commit"
},
{
"role": "assistant",
"content": "There's no need to do this in two commits, you can add the file and mark it executable in a single commit:\nC:\\Temp\\TestRepo>touch foo.sh\n\nC:\\Temp\\TestRepo>git add foo.sh\n\nC:\\Temp\\TestRepo>git ls-files --stage\n100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 foo.sh\n\nAs you note, after adding, the mode is 0644 (ie, not executable). However, we can mark it as executable before committing:\nC:\\Temp\\TestRepo>git update-index --chmod=+x foo.sh\n\nC:\\Temp\\TestRepo>git ls-files --stage\n100755 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 foo.sh\n\nAnd now the file is mode 0755 (executable).\nC:\\Temp\\TestRepo>git commit -m\"Executable!\"\n[master (root-commit) 1f7a57a] Executable!\n 1 file changed, 0 insertions(+), 0 deletions(-)\n create mode 100755 foo.sh\n\nAnd now we have a single commit with a single executable file."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Bitbucket git credentials if signed up with Google\nI have an account on bitbucket.org that I created by signing up with my Google account. Now everytime I log in I just click \"Log in with Google\" and that's fine.\nHow can I access my repos from git command line? It requests me username and password. I have a username, but no password.\nHow do I log in then?"
},
{
"role": "assistant",
"content": "You should do a one-time setup of creating an \"App password\" in Bitbucket web UI with permissions to at least read your repositories and then use it in the command line.\nHow-to:\n\nLogin to Bitbucket\nClick on your profile image in the top-right\nChoose Personal settings\nUnder Access management section look for the App passwords option (https://bitbucket.org/account/settings/app-passwords/)\nCreate an app password with permissions at least to Read under Repositories section. A password will be generated for you. Remember to save it, it will be shown only once!\nThe username will be your BitBucket username (how to find it)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to resolve git status \"Unmerged paths:\"?\nI merged branch dog into animal. When I go to commit, I get the following:\nUnmerged paths:\n(use \"git reset HEAD <file>...\" to unstage)\n(use \"git add <file>...\" to mark resolution\nboth deleted: ../public/images/originals/dog.ai\nadded by them: ../public/images/original_files/dog.ai\n\nI had different directory names and file names in each branch. The animal branch has the changes that I want.\nWhen I go to reset the head, it doesn't work. And when I go to take any other git action (remove, checkout, etc), I get a path not found error.\nWhat commands do I need to execute to resolve this?"
},
{
"role": "assistant",
"content": "All you should need to do is:\n# if the file in the right place isn't already committed:\ngit add <path to desired file>\n\n# remove the \"both deleted\" file from the index:\ngit rm --cached ../public/images/originals/dog.ai\n\n# commit the merge:\ngit commit"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-submodule - Initialize, update or inspect submodules -n --summary-limit"
},
{
"role": "assistant",
"content": "This option is only valid for the summary command.\nLimit the summary size (number of commits shown in total).\nGiving 0 will disable the summary; a negative number means unlimited\n(the default). This limit only applies to modified submodules. The\nsize is always limited to 1 for added/deleted/typechanged submodules."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I remove an empty folder and push that change?\nHow can I remove an empty folder locally and also have that happen for other collaborators that share the remote via pull-push? I know that folders aren't 'tracked' in that sense by git but the question remains.\ne.g. I moved a file to another folder and committed the change (of the move).\nBut I can't git rm name the folder as I get \"doesn't match\"\ngit rmdir name doesn't exist.\nI can do a git clean -f folder but how does that get pushed up?\nI can directly rm the file but how do I get that directory removal done correctly and pushed to the repository and then out to others when they pull so that their existing folder gets deleted."
},
{
"role": "assistant",
"content": "The short answer: You can't push changes to directories (added, removed, etc.) because Git does not track directories on their own. \nAccording to the FAQ:\n\nCurrently the design of the git index (staging area) only permits files to be listed, and nobody competent enough to make the change to allow empty directories has cared enough about this situation to remedy it.\nDirectories are added automatically when adding files inside them. That is, directories never have to be added to the repository, and are not tracked on their own.\n\nSo as far as Git is concerned, your empty directory doesn't exist anymore.\nI have found that getting in the habit of using git clean -fd removes the need for pushing the removal of directories. However, git clean can remove items you may not want removed (including any new files you have not yet committed) so I tend to first use git clean -fdn to see what will be removed if I use the command.\nIt looks like you may be forced to talk to your fellow developers in order to clean up that directory."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-push - Update remote refs along with associated objects --receive-pack=<git-receive-pack> --exec=<git-receive-pack>"
},
{
"role": "assistant",
"content": "Path to the git-receive-pack program on the remote\nend. Sometimes useful when pushing to a remote\nrepository over ssh, and you do not have the program in\na directory on the default $PATH."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitHub keeps saying \"This branch is X commits ahead, Y commits behind\"\nLet's say there is a GitHub repository which I want to contribute to.\nI fork that repository into my GitHub account and I clone the fork from my account in my PC. Fine.\nBefore working on an issue, I first want to synchronize my fork with the 'original' repository. I go to my account fork, click on New Pull request, make sure that I select mine as base and the original master as head fork, I see the differences (all the commits that people did in the original repository that are not on mine).\nThen I create the pull request on my fork and I merge those changes in my fork.\nI go to my local repo and do a git pull, and I have everything synchronized. Fine.\nThe problem comes now, in my GitHub account now it's always saying 'This branch is X commits ahead', where 'X' is the number of times that I did the synchronize process I described above. So, every time I do a pull request into the original repository (not my fork), is showing that I'm committing my code plus X more commits, that are the merges I did on my fork to synchronize with the original repository.\nOf course, I don't want to push those changes into the original repository, since they already have those changes in place, so I don't understand why GitHub keeps saying to me that I have changes to commit.\nI think it's something that has to be solved on my GitHub account, because in my local repository there are no changes or issues, actually I even removed it and re-cloned again.\nDo you have any ideas?"
},
{
"role": "assistant",
"content": "As you guessed, these extra commits are likely the merge commits from the Pull Requests that you created.\nIn the future, there's a much easier way to sync your fork with the original repository. In your local repo, after the initial clone do:\ngit remote add upstream https://github.com/upstream/repo.git\n\nThen, whenever you want to sync the changes from upstream, do:\ngit pull --rebase upstream master\ngit push --force-with-lease origin master\n\n(The --rebase and --force-with-lease options will only be necessary if you have commits that haven't been merged into the upstream repo.)\nObligatory warning: Since a rebase rewrites history, this can be dangerous / disruptive for anyone else working on this branch. Be sure you clearly communicate what you have done with anyone you are collaborating with. Since this is a personal fork, I assume this won't be an issue for you.\n\nNow to fix your current issue after the fact.\n\nAdd the upstream remote as described above.\nReset your local branch to match upstream:\ngit checkout master\ngit reset --hard upstream/master\n\nIf you have created any commits in your fork, you can cherry-pick them onto your updated version of master. If you can't remember or need help finding them, something like\ngit log --oneline master origin/master\n\nshould show you any commits not in upstream.\n\n\nAbove I assumed that you are only using one branch, master. If you aren't already, I highly recommend that you create a new branch for each feature / bug fix that you work on. Among other benefits, this allows you to start work on another feature / bug fix when you are still waiting for an earlier PR to be merged. If you never commit directly to master, then you can sync without the --rebase or --force-with-lease:\ngit checkout master\ngit pull upstream master\ngit push origin master\n\nTo update a feature branch after you have updated master, do:\ngit checkout myfeature\ngit rebase master\ngit push --force-with-lease origin myfeature # if you have already pushed"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I update the password for Git?\nI'm using BitBucket with Xcode and Git for version control, and recently I changed all of my passwords (thanks Adobe!).\nUnsurprisingly, I'm no longer able to push my local commits to my repository on BitBucket (Authentication failed for 'https://______.git'), but I'm forgetting how to update the cached password on my iMac. Somehow I've been unable to find it on Google or Stack Overflow, though it seems to me it should be rather straightforward..."
},
{
"role": "assistant",
"content": "To fix this on macOS, you can use \ngit config --global credential.helper osxkeychain\n\nA username and password prompt will appear with your next Git action (pull, clone, push, etc.).\nFor Windows, it's the same command with a different argument:\ngit config --global credential.helper wincred"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Add Xcode project to github repo?\n\nI have JUST created a new github repo on the website. Keep in mind that I am a noob but can do basic things in terminal. Anyway, so I just created the repo on my account on github.com and didn't do a single thing to it yet.\nSo all I want to do is take my Xcode project folder and upload it to my new github repo. How do I do this via terminal?"
},
{
"role": "assistant",
"content": "The best way really is to follow the instructions GitHub gives you:\nFirst, go the correct directory\ncd <directory of your Xcode project>\n\nIt sound like you've already got a local Git project from Xcode. If that's true, skip this code block.\ngit init .\ngit add .\ngit commit -s\n<type in a commit message>\n\nLast, push into your repository. The following is copied directly from my own github account, after I created a new \"test\" repo. Change the \"dhalperi/test\" part.\n\nPush an existing repository from the command line\ngit remote add origin [email protected]:dhalperi/test.git\ngit push -u origin master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-add - Add file contents to the index -N --intent-to-add"
},
{
"role": "assistant",
"content": "Record only the fact that the path will be added later. An entry\nfor the path is placed in the index with no content. This is\nuseful for, among other things, showing the unstaged content of\nsuch files with git diff and committing them with git commit\n-a ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %h"
},
{
"role": "assistant",
"content": "abbreviated commit hash"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database --no-reflogs"
},
{
"role": "assistant",
"content": "Do not consider commits that are referenced only by an\nentry in a reflog to be reachable. This option is meant\nonly to search for commits that used to be in a ref, but\nnow aren’t, but are still in that corresponding reflog."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab CI runner\n\nI have used this tutorial for setting up a gitlab ci runner. The runner seems to be working. Now I want to build a C++ project with it.\nHow can I do this?"
},
{
"role": "assistant",
"content": "Assuming you have a shell runner, you can create a job and list the command line commands you want to have executed. Create a file .gitlab-ci.yml in the root directory of your git repository:\nmy_project:\n script:\n - cd apps/my_project\n - mkdir build\n - cd build\n - cmake ..\n - make\n\nWhen you push, and ci runners are enabled on gitlab, it will automatically execute all these shell commands for each push.\nMore information about the things you can put into .gitlab-ci.yml can be found here."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-revert - Revert some existing commits --strategy=<strategy>"
},
{
"role": "assistant",
"content": "Use the given merge strategy. Should only be used once.\nSee the MERGE STRATEGIES section in git-merge for details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What does the -u flag mean in git push -u origin master?\n\nI was just wondering what does the -u flag mean in this command? \ngit push -u origin master"
},
{
"role": "assistant",
"content": "The -u option does the following:\nFor every branch that is up to date or successfully pushed, add an upstream (tracking) reference, used by argument-less, git-pull and other commands.\nSo, after pushing your local branch with the -u option, this local branch will be automatically linked with the remote branch, and you can use git pull without any arguments."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options push.negotiate"
},
{
"role": "assistant",
"content": "If set to \"true\", attempt to reduce the size of the packfile\nsent by rounds of negotiation in which the client and the\nserver attempt to find commits in common. If \"false\", Git will\nrely solely on the server’s ref advertisement to find commits\nin common."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to setup connection to MySql database with gitlab CI/CD\n\nI'm trying to set up automatic testing of django project using CI/CD gitlab. The problem is, I can't connect to the Mysql database in any way.\ngitlab-ci.yml\nservices:\n - mysql:5.7\n\nvariables:\n MYSQL_DATABASE: \"db_name\"\n MYSQL_ROOT_PASSWORD: \"dbpass\"\n MYSQL_USER: \"username\"\n MYSQL_PASSWORD: \"dbpass\"\n \n\nstages:\n - test\n\ntest:\n stage: test\n before_script:\n - apt update -qy && apt-get install -qqy --no-install-recommends default-mysql-client\n - mysql --user=$MYSQL_USER --password=$MYSQL_PASSWORD --database=$MYSQL_DATABASE --host=$MYSQL_HOST --execute=\"SHOW DATABASES; ALTER USER '$MYSQL_USER'@'%' IDENTIFIED WITH mysql_native_password BY '$MYSQL_PASSWORD'\"\n script:\n - apt update -qy\n - apt install python3 python3-pip virtualenvwrapper -qy\n - virtualenv --python=python3 venv/\n - source venv/bin/activate\n - pwd\n - pip install -r requirement.txt\n - python manage.py test apps\n\nWith this file configuration, I get error\n ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)\n\nWhat have I tried to do\nadd to mysql script tcp connection unstead socket\nmysql --protocol=TCP --user=$MYSQL_USER --password=$MYSQL_PASSWORD --database=$MYSQL_DATABASE --host=$MYSQL_HOST --execute=\"SHOW DATABASES; ALTER USER '$MYSQL_USER'@'%' IDENTIFIED WITH mysql_native_password BY '$MYSQL_PASSWORD'\"\n\nAnd in this case I got\nERROR 2002 (HY000): Can't connect to MySQL server on 'localhost' (99)\n\nHow do I set up properly?"
},
{
"role": "assistant",
"content": "There can be multiple reasons for your issue:\n\nIncorrect MySQL version.\n\nSolution: Use mysql:5.7 instead of mysql:latest\n\n\nMySQL host is missing.\n\nSolution: add MYSQL_HOST in the variables with the hostname of the MySQL server. (Should be mysql when using mysql:5.7 in services key)\n\n\nDjango uses different credentials of DB.\n\nSolution: check that the credentials in the variables section of your .gitlab-ci.yml and compare against Django's settings.py. They should be the same.\n\n\nMySQL client not installed.\n\nSolution: install the mysql-client in the script section and check if it is able to connect.\n\n\n\nHere is a sample script that installs MySQL client and connects to the database in a debian based image (or a python:latest image):\nscript:\n - apt-get update && apt-get install -y git curl libmcrypt-dev default-mysql-\n - mysql --version\n - sleep 20\n - echo \"SHOW tables;\"| mysql -u root -p\"$MYSQL_ROOT_PASSWORD\" -h \"${MYSQL_HOST}\" \"${MYSQL_DATABASE}\"\n\nHere is a complete and valid example of using MySQL 5.7 as a service and a python image with mysql-client installed successfully connecting to the MySQL database:\nstages:\n - test\n\nvariables:\n MYSQL_DATABASE: \"db_name\"\n MYSQL_ROOT_PASSWORD: \"dbpass\"\n MYSQL_USER: \"username\"\n MYSQL_PASSWORD: \"dbpass\"\n MYSQL_HOST: mysql\n\ntest:\n image: python:latest\n stage: test\n services:\n - mysql:5.7\n script:\n - apt-get update && apt-get install -y git curl libmcrypt-dev default-mysql-client\n - mysql --version\n - sleep 20\n - echo \"SHOW tables;\" | mysql -u root -p\"$MYSQL_ROOT_PASSWORD\" -h \"${MYSQL_HOST}\" \"${MYSQL_DATABASE}\"\n - echo \"Database host is '${MYSQL_HOST}'\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge - Join two or more development histories together"
},
{
"role": "assistant",
"content": "EXAMPLES Merge branches fixes and enhancements on top of\nthe current branch, making an octopus merge: $ git merge fixes enhancements Merge branch obsolete into the current branch, using ours merge strategy: $ git merge -s ours obsolete Merge branch maint into the current branch, but do not make\na new commit automatically: $ git merge --no-commit maint This can be used when you want to include further changes to the\nmerge, or want to write your own merge commit message. You should refrain from abusing this option to sneak substantial\nchanges into a merge commit. Small fixups like bumping\nrelease/version name would be acceptable."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git in Visual Studio - add existing project?\nI'm trying to put an existing project under Git source control, but I'm unclear on several things.\nI have set up a 'Team Foundation Service' Git account online.\nI currently have an ASP.NET MVC 4 solution - in my Projects folder. I have created a Git 'repository' locally (an empty folder currently). Should this just be my current application folder in Projects? Or does it need to be a copy?\nHow do I get my existing files into the online repository?"
},
{
"role": "assistant",
"content": "I went searching around for a similar question - the way I've managed to initialize a Git repository for an existing project file is this (disclaimer: this is done in Visual Studio 2013 Express, without a Team Foundation Server setup):\n\nOpen the project in Visual Studio.\nGo to menu File → Add to Source Control.\n\nThat did it for me - assuming Git is set up for you, you can go to menu View → Team Explorer, then double click the repository for your project file, and make your initial commit (making sure to add whatever files you'd like)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-for-each-ref - Output information on each ref"
},
{
"role": "assistant",
"content": "CAVEATS Note that the sizes of objects on disk are reported accurately, but care\nshould be taken in drawing conclusions about which refs or objects are\nresponsible for disk usage. The size of a packed non-delta object may be\nmuch larger than the size of objects which delta against it, but the\nchoice of which object is the base and which is the delta is arbitrary\nand is subject to change during a repack. Note also that multiple copies of an object may be present in the object\ndatabase; in this case, it is undefined which copy’s size or delta base\nwill be reported."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git delete remotes: remote refs do not exist\nIn short;\n\nHow can I delete remote multiple merged remotes?\n\nMore background;\nI have a git repo with tens of remotes which have been merged into master. I can delete these remotes one at a time by using:\ngit push --delete origin myBranch-1234\n\nHowever this is a slow and tedious process for all remotes. So I'm trying this command:\ngit branch -r --merged | grep origin | grep -v master | xargs git push origin --delete\n\ngit branch -r --merged lists all merged remotes.\ngrep origin tells the command to include origin.\ngrep -v master tells the command to exclude master.\nxargs git push origin --delete tells the command to delete the list of remotes.\nAll together, I expect this to gather all merged remotes and delete them.\nWhen I run the above command, I receive the following for every merged remote;\nerror: unable to delete 'origin/myBranch-1234': remote ref does not exist\nerror: unable to delete 'origin/myBranch-1235': remote ref does not exist\nerror: unable to delete 'origin/myBranch-1236': remote ref does not exist\nerror: unable to delete 'origin/myBranch-1237': remote ref does not exist\n... etc\n\nHowever these remotes do exist and I can checkout each of them. Many sites and people recommend that I run git fetch --prune to clean up missing references. This does nothing because all of these remotes exist.\nSo I ask you, dear stack exchange;\n\nWhy can I delete one remote, but not many?\nIs my command correct?\n\nI think I'm missing something small. Every time I research this, it seems like I'm doing this correctly, but I'm getting the above errors.\n\nDelete local and Remote Branches\ngist Delete Merged Remotes"
},
{
"role": "assistant",
"content": "You may need to prune your local \"cache\" of remote branches first. Try running:\ngit fetch -p origin\nbefore deleting."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-http-push"
},
{
"role": "assistant",
"content": "Push objects over HTTP/DAV to another repository"
}
] |