messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Alias - Multiple Commands and Parameters\nI am trying to create an alias that uses both multiple Git commands and positional parameters. There are Stackoverflow pages for each, and it would appear painfully obvious to do both, but I am having trouble.\nAs an example, I want to switch to branch foo and perform a status. So in my .gitconfig, I have:\n [alias] \n chs = !sh -c 'git checkout $0 && git status'\n\nwhich doesn't work. Whereas something like this will work.\nchs = !sh -c 'git checkout $0'\n\nechoes = !sh -c 'echo hi && echo bye'\n\nAny insight would be appreciated." }, { "role": "assistant", "content": "This will work (tested with zsh and bash):\n[alias] chs = !git checkout $1 && git status" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to use VS Code as merge and diff tool in SourceTree?\nThis question and some others discuss how this could work on a Mac, but I couldn't find documentation from Microsoft or Atlassian on a way to do this on Windows without trying to make it the global Git setting. (I just prefer to change things within the IDE where possible.)\nWhat are the parameters to use with the \"Custom\" settings in SourceTree's \"Options\" dialogue \"Diff\" tab, for diff'ing and merging with VS-Code?" }, { "role": "assistant", "content": "There may be other better variations, but after some experiment I've found these work well enough...\n\nChoose \"Custom\" for the \"External Diff Tool\" and \"Merge Tool\"\nThe \"Diff Command\" in both cases is the path to wherever VS-Code is installed, eg:\n\n\nC:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\n\nThe command-line arguments for Diff'ing are:\n\n--diff --wait \"$LOCAL\" \"$REMOTE\"\n\nAnd for Merging:\n\n-n --wait \"$MERGED\"\n\n\nThe '-n' flag makes VS-Code open a new window, which I prefer since VS-Code opens so fast, but you can omit it. When dealing with merge conflicts, you have to close the file when you're done to continue. SourceTree doesn't seem to consistently delete the intermediate files it creates, but you can select, right-click and 'Remove' them from the un-staged file section easily enough." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is it possible to find out the users who have checked out my project on GitHub?\nI'm wondering if there is any way to know who has checked out my project hosted on GitHub? This would include people who have forked the project directly on GitHub, as well as people who may have cloned the repository using standard git clone commands." }, { "role": "assistant", "content": "If by \"checked out\" you mean people who have cloned your project, then no it is not possible. You don't even need to be a GitHub user to clone a repository, so it would be infeasible to track this." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options diff.ignoreSubmodules" }, { "role": "assistant", "content": "Sets the default value of --ignore-submodules. Note that this\naffects only git diff Porcelain, and not lower level diff commands such as git diff-files . git checkout and git switch also honor\nthis setting when reporting uncommitted changes. Setting it to all disables the submodule summary normally shown by git commit and git status when status.submoduleSummary is set unless it is\noverridden by using the --ignore-submodules command-line option.\nThe git submodule commands are not affected by this setting.\nBy default this is set to untracked so that any untracked\nsubmodules are ignored." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Applying .gitignore to committed files\nI have committed loads of files that I now want to ignore. How can I tell git to now ignore these files from future commits? \nEDIT: I do want to remove them from the repository too. They are files created after ever build or for user-specific tooling support." }, { "role": "assistant", "content": "After editing .gitignore to match the ignored files, you can do git ls-files -ci --exclude-standard to see the files that are included in the exclude lists; you can then do\n\nLinux/MacOS: git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached\nWindows (PowerShell): git ls-files -ci --exclude-standard | % { git rm --cached \"$_\" }\nWindows (cmd.exe): for /F \"tokens=*\" %a in ('git ls-files -ci --exclude-standard') do @git rm --cached \"%a\"\n\nto remove them from the repository (without deleting them from disk).\nEdit: You can also add this as an alias in your .gitconfig file so you can run it anytime you like. Just add the following line under the [alias] section (modify as needed for Windows or Mac):\napply-gitignore = !git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached\n\n(The -r flag in xargs prevents git rm from running on an empty result and printing out its usage message, but may only be supported by GNU findutils. Other versions of xargs may or may not have a similar option.)\nNow you can just type git apply-gitignore in your repo, and it'll do the work for you!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Fetch a single tag from remote repository\nThis command fetches all tags:\ngit fetch origin --tags\n\nThis command fetches a specific tag:\ngit fetch origin refs/tags/1.0.0\n\nBut that doesn't let me do:\ngit checkout tags/2.3.18\n\nHow can I fetch a single tag and then perform a checkout?" }, { "role": "assistant", "content": "git fetch origin refs/tags/1.0.0\n\nThis fails because it doesn't write a local reference: it obtains the remote's refs/tags/1.0.0, and any tag object(s), commits, etc., required to go with it; it drops those into FETCH_HEAD (as all git fetch commands always do); and ... that's it. It never creates reference refs/tags/1.0.0 in your repository, even though it got everything it needed to do so.\nTo make it create such a tag if it does not yet exist:\ngit fetch origin refs/tags/1.0.0:refs/tags/1.0.0\n\nThe name on the right of the colon is the name your Git will use in your repository. You could turn this tag into a branch named wacky, for instance, by naming it refs/heads/wacky. (There's no reason to do this. I am describing this just for illustration.)\nThis is a non-forced fetch, so if you already have a refs/tags/1.0.0, your Git will refuse to update your reference. If you wish to overwrite any existing 1.0.0 tag, use:\ngit fetch origin +refs/tags/1.0.0:refs/tags/1.0.0\n\nIf you wish to fetch all tags, with or without overwriting:\ngit fetch origin 'refs/tags/*:refs/tags/*'\n\nwith or without a leading plus sign. (Note: the quote marks are just to protect the * from your shell. The plus sign may go inside or outside the quotes. In fact, the quotes themselves can go anywhere as long as they surround all asterisks or other shell meta-characters:\nrefs/tags/'*:refs/tags/*'\n\nor you can use backslashes instead:\nrefs/tags/\\*:refs/tags/\\*\n\nIn all cases we are just protecting the sensitive asterisk from the shell's \"asterisks are tasty, let's eat them\" functions.)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is there a good (visual) Git tool for Mac OS X or Windows? [closed]\nClosed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\n Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.\n\n\nClosed 10 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI'm looking at porting my projects to Git from SVN (I'm convinced that Git is worth the move) and I'm trying to come up with a set of tools to use for the project. I've googled around for some tools but I wasn't really impressed with what I found.\nWhat visual tools are recommended for Git users on Mac OS X? What about Windows? (I have multiple development environments and I need git tooling in each one of them)" }, { "role": "assistant", "content": "Here's one for Mac: GitX\nScreenshot:" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_TRACE_CURL" }, { "role": "assistant", "content": "Enables a curl full trace dump of all incoming and outgoing data,\nincluding descriptive information, of the git transport protocol.\nThis is similar to doing curl --trace-ascii on the command line.\nSee GIT_TRACE for available trace output options." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Database on a personal github page\n\nIs it possible to have some data stored somewhere on your personal github page?\nFor example a button that triggers a counter. When you click on the button , counter increments by 1. When other user visits that page and clicks the button , counter gets incremented by 1 once again.\nSo it would be a sum of all click across all visitors that would be displayed on the page." }, { "role": "assistant", "content": "Github pages only allow for static content, so you'd have to use something like firebase in order to get a database." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why is \"origin/HEAD\" shown when running \"git branch -r\"?\nWhen you run git branch -r why the blazes does it list origin/HEAD? For example, there's a remote repo on GitHub, say, with two branches: master and awesome-feature. If I do git clone to grab it and then go into my new directory and list the branches, I see this:\n$ git branch -r\norigin/HEAD\norigin/master\norigin/awesome-feature\n\nOr whatever order it would be in (alpha? I'm faking this example to keep the identity of an innocent repo secret). So what's the HEAD business? Is it what the last person to push had their HEAD pointed at when they pushed? Won't that always be whatever it was they pushed? HEADs move around... why do I care what someone's HEAD pointed at on another machine?\nI'm just getting a handle on remote tracking and such, so this is one lingering confusion. Thanks!\nEDIT: I was under the impression that dedicated remote repos (like GitHub where no one will ssh in and work on that code, but only pull or push, etc) didn't and shouldn't have a HEAD because there was, basically, no working copy. Not so?" }, { "role": "assistant", "content": "@robinst is correct.\nIn git, you can select which branch is checked out by default (i.e. when you clone). By default, origin/HEAD will point at that.\nOn GitHub, You can change this in the Admin settings for your GitHub repo. You can also do it from the command-line via\ngit remote set-head origin trunk\n\nor delete it altogether via\ngit remote set-head origin -d\n\nExample. Look at the 'Switch Branches' drop-down. trunk is checked, so origin/HEAD follows trunk." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: 1.List all files in a branch, 2.compare files from different branch\nLooking for a command like ls -R or dir/s that can list all files in a commit/branch. \nIs there any command that can compare two files from different branches?" }, { "role": "assistant", "content": "git ls-tree -r --name-only <commit> (where instead of <commit> there can be <branch>). You might want to use also -t option which lists subdirectories before descending into them\ngit diff <branchA>:<fileA> <branchB>:<fileB>, or if you want to compare the same file git diff <branchA> <branchB> -- <file>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git keeps asking me for my ssh key passphrase\nI created keys as instructed in the GitHub tutorial, added them to GitHub, and tried using ssh-agent explicitly — yet git continues to ask me for my passphrase every time I try to do a pull or a push.\nWhat could be the cause?" }, { "role": "assistant", "content": "Once you have started the SSH agent with:\neval $(ssh-agent)\n\nDo either:\n\nTo add your private key to it:\n ssh-add\n\nThis will ask you your passphrase just once, and then you should be allowed to push, provided that you uploaded the public key to Github.\n\nTo add and save your key permanently on macOS:\n ssh-add -K \n\nThis will persist it after you close and re-open it by storing it in user's keychain.\nIf you see a warning about deprecated flags, try the new variant:\n ssh-add --apple-use-keychain \n\n\nTo add and save your key permanently on Ubuntu (or equivalent):\n ssh-add ~/.ssh/id_rsa" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-switch - Switch branches -f --force" }, { "role": "assistant", "content": "An alias for --discard-changes ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "pip: pulling updates from remote git repository\n\nI installed scikit-learn from GitHub a couple of weeks ago:\npip install git+git://github.com/scikit-learn/scikit-learn@master\n\nI went to GitHub and there have been several changes to the master branch since then.\nHow can I update my local installation of scikit-learn?\nI tried pip install scikit-learn --upgrade but I got:\nRequirement already up-to-date\nCleaning up ..." }, { "role": "assistant", "content": "pip searches for the library in the Python package index. Your version is newer than the newest one in there, so pip won't update it.\nYou'll have to reinstall from Git:\n$ pip install git+git://github.com/scikit-learn/scikit-learn@main" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "On GitLab, how to compare a file of two different commits\nOn GitLab, how to compare a file of two different commits? I know that that on command line git, the command is:\ngit diff commit1 commit12 -- file_name\n\nWhat is the link format to do this on GitLab?\nSee my related question" }, { "role": "assistant", "content": "It will compare commits, you will be able to find file in list.\n\ngo to Repository > Compare\npaste this url: https://gitlab.com/$USER/$REPO/compare?from=$SHA1&to=$SHA2 or https://your gitlab domain/$ORG/$GROUP/$REPO/-/compare?from=$SHA1&to=$SHA2\nhit enter (notice: gitlab will set 'Source' and 'Target' properly)\nclick button 'compare'" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-switch - Switch branches checkout.guess" }, { "role": "assistant", "content": "Provides the default value for the --guess or --no-guess option in git checkout and git switch . See git-switch and git-checkout ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_AUTHOR_EMAIL" }, { "role": "assistant", "content": "The email address used in the author identity when creating commit or\ntag objects, or when writing reflogs. Overrides the user.email and author.email configuration settings." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc plain" }, { "role": "assistant", "content": "Show words as [-removed-] and {+added+} . Makes no\nattempts to escape the delimiters if they appear in the input,\nso the output may be ambiguous." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-difftool - Show changes using common diff tools --tool-help" }, { "role": "assistant", "content": "Print a list of diff tools that may be used with --tool ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-gc - Cleanup unnecessary files and optimize the local repository gc.pruneExpire" }, { "role": "assistant", "content": "When git gc is run, it will call prune --expire 2.weeks.ago (and repack --cruft --cruft-expiration 2.weeks.ago if using\ncruft packs via gc.cruftPacks or --cruft ). Override the\ngrace period with this config variable. The value \"now\" may be\nused to disable this grace period and always prune unreachable\nobjects immediately, or \"never\" may be used to suppress pruning.\nThis feature helps prevent corruption when git gc runs\nconcurrently with another process writing to the repository; see\nthe \"NOTES\" section of git-gc ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-daemon - A really simple server for Git repositories --enable=<service> --disable=<service>" }, { "role": "assistant", "content": "Enable/disable the service site-wide per default. Note\nthat a service disabled site-wide can still be enabled\nper repository if it is marked overridable and the\nrepository enables the service with a configuration\nitem." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GIT warning: too many files skipping inexact rename detection\nI am aware that the default rename limit is 100 and we can increase this value using the config diff.renamelimit config\nWhat I am worried about is that, if this config is not setup, will there be a wrong merge or any missing code?\nI am trying to merge (git merge) 2 branches that have huge changes.\nCan someone throw more light about this config setting?" }, { "role": "assistant", "content": "In case this helps anyone, I had a lot of files (hundreds, if not thousands) in one branch, which were not yet in the other branch. Running\n$ git config merge.renamelimit 15345\n\nmade the below error when merging go away\n$ git merge master\n.\n.\n.\nwarning: inexact rename detection was skipped due to too many files.\nwarning: you may want to set your merge.renamelimit variable to at least 15345 and retry the command." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "List all files changed in a pull request in Git/GitHub\n\nIs there a way (from the command line) to list the names of all files changed in a PR in Git/GitHub? This would be used to find what tests need to be run in a Travis CI build for that PR.\nThe CI build runs these commands before it calls our script:\ngit clone --depth=50 git://github.com/jekyll/jekyll.git jekyll/jekyll\ncd jekyll/jekyll\ngit fetch origin +refs/pull/2615/merge\ngit checkout -qf FETCH_HEAD" }, { "role": "assistant", "content": "In general, you can list the files changed between any two commits with\ngit diff --name-only <ref1> <ref2>\n\nHow to list only the names of files that changed between two commits\nThe problem here seems to be determining the 'merge base'. If all branches originate with master, then you could do:\ngit --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD master)\n\nThis will show you the changes between the point at which the FETCH_HEAD was branched from master to the current FETCH_HEAD. I tested this locally, and the PR branches are cut from master I believe it should work." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-rerere" }, { "role": "assistant", "content": "Reuse recorded resolution of conflicted merges" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-tag - Create, list, delete or verify a tag object signed with GPG -f --force" }, { "role": "assistant", "content": "Replace an existing tag with the given name (instead of failing)" } ]
[ { "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>] [--] [<path>…​]" }, { "role": "assistant", "content": "This form is to view the changes you made relative to\nthe index (staging area for the next commit). In other\nwords, the differences are what you could tell Git to\nfurther add to the index but you still haven’t. You can\nstage these changes by using git-add ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git - undoing git rm [duplicate]\nThis question already has answers here:\n \n \n\n\n\nClosed 11 years ago.\n\n\n\n\nPossible Duplicate:\nHow to revert a “git rm -r .”? \n\nGit SOS here. I worked 10 hours on a project without committing (I know, I know) and then I git added too many files, so I tried using git rm and accidentally deleted EVERYTHING. Is there hope for me? :(((" }, { "role": "assistant", "content": "If you already commited changes, then:\ngit reset (--hard) HEAD~1\n\nIf not then:\ngit reset\ngit ls-files -d -z | xargs -0 git checkout --" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git error: src refspec master does not match any [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nMessage 'src refspec master does not match any' when pushing commits in Git\n\n (142 answers)\n \n\nClosed 10 years ago.\n\n\n\nI need to create a repo named carboncake.\nI tried this:\nCloned the gitosis-admin repository to my local machine\n$ git clone [email protected]:repositories/gitosis-admin.git\n$ cd gitosis-admin\n$ vim gitosis.conf\n\nAdded the [repo carboncake] and [group carboncake] section to the end of the file\n[gitosis]\n\n[group team]\nwritable = sweepshots\nmembers = git_id_rsa\n\n[group gitosis-admin]\nwritable = gitosis-admin\nmembers = git_id_rsa\n\n[repo carboncake]\ndescription = A brand new app by Mithun.\nowner = Mithun P\n\n[group carboncake]\nwritable = myappname\nmembers = mithun @core\n\nThen copied the pub key file generated by Putty (I'm using Git basg for Windows):\n$cp /some/where/mithun.pub keydir/mithun.pub\nExecuted the following commands:\n$ git add gitosis.conf keydir/mithun.pub\n$ git commit -m \"Added 'carboncake' repository and 'mithun' user.\"\n\n$ git pull --rebase\n$ git push\n\nBut it doesn't create any carboncake.git in My Server.\nSo I followed this:\nExecuted the following commands on the server:\n$ su gitosis \n$ git init --bare /srv/gitosis/repositories/carboncake.git\n\nHere's my problem: \nI tried to checkout/clone the new repository from my local machine\n$ mkdir carboncake\n$ cd carboncake\n$ git init \n$ touch a_text_file.txt \n$ git add a_text_file.txt \n$ git remote add origin [email protected]:repositories/carboncake.git\n$ git push origin master\n\nWhich returned the error:\nerror: src refspec master does not match any.\nfatal: The remote end hung up unexpectedly\nerror: failed to push some refs to '[email protected]:repositories/carboncake.git'\n\nWhen I tried git push origin HEAD:master it returned the error:\nerror: src refspec HEAD does not match any.\nfatal: The remote end hung up unexpectedly\nerror: failed to push some refs to '[email protected]:repositories/carboncake.git'\n\nWhen I tried git push origin master:refs/heads/master it returned the error:\nerror: src refspec master does not match any.\nfatal: The remote end hung up unexpectedly\nerror: failed to push some refs to '[email protected]:repositories/carboncake.git'\n\ngit show-ref on the local machine does not display anything\nAlso /srv/gitosis/repositories/carboncake.git/refs/heads/ directory on the server is empty.\nHow can I fix this?" }, { "role": "assistant", "content": "You've created a new repository and added some files to the index, but you haven't created your first commit yet. After you've done:\n git add a_text_file.txt \n\n... do:\n git commit -m \"Initial commit.\"\n\n... and those errors should go away." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is causing a push to origin to hang up, with Github Desktop?\n\nI am trying to push some files to a remote GitLab repo using GitHub Desktop. And after getting it to finish writing the objects, by increasing the buffer size in the command line; I am stuck halfway in the push.\nI have this pop up, while it is stuck,\nTotal 505 (delta 18), reused 0 (delta 0), pack-reused 0.\nWhat could fix this issue?" }, { "role": "assistant", "content": "Searching for a similar problem, I found this solution here:\n\nanywhere run\ngit config --global http.postBuffer 157286400\n\nin your local repo run git rm -r --cached ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-branch - List, create, or delete branches --column[=<options>] --no-column" }, { "role": "assistant", "content": "Display branch listing in columns. See configuration variable column.branch for option syntax. --column and --no-column without options are equivalent to always and never respectively. This option is only applicable in non-verbose mode." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Create a branch alias? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nIs it possible to alias a branch in Git?\n\n (4 answers)\n \n\nClosed 2 years ago.\n\n\n\nI am researching switching from starteam to Git.\nCurrently, in starteam, we use \"floating views\" with special names. These floating views basically work like aliases. Therefore, we can specify a specific alias to checkout from and we'll get the branch that we're currently model testing.\nHow would this be done in Git?\nThis is basically how our branches are organized:\nThese are all branches\nmaster (stable view)\n | - Branch 2012.05.01\n | | - Project 1\n | | - Project 2\n | | - model [floating view / alias to Branch 2012.05.01]\n |\n | - Branch 2012.07.11 (these would also have various child views for projects)\n | - Branch 2012.10.17\n\n(Branch 2012.05.01 would be merged to master when model testing is complete.)\nIn our automated scripts (ant), to run our model deployment, we just checkout from our branch called model. This way we never have to change our scripts as we change which branch we are model testing, and finding out which view we're model testing is as easy as figuring out which branch the model branch references.\nIs there any such way to do something similar in Git?\nTo clarify:\n\nI want an alias of a branch. A branch, not a commit.\nBranch 2012.05.01 means the branch intended to be shipped on 2012.05.01, it doesn't mean a 2012.05.01 moment in time.\nI want an alias to Branch 2012.05.01. Branch 2012.05.01 is an integration branch, it's constantly modified. But I don't want to reference it as Branch 2012.05.01, I want to reference it as model. This way, I can change my the alias to Branch 2012.07.11 and it will get the most recent code from that branch without changing any of the checkout code script." }, { "role": "assistant", "content": "Please see here: https://stackoverflow.com/a/549949/606723\n\nYou can rename the master branch trunk as Greg has suggested, or you\n can also create a trunk that is a symbolic reference to the master\n branch so that both git and svn users have the 'main' branch that they\n are used to.\ngit symbolic-ref refs/heads/trunk refs/heads/master\n\nNote that trunk isn't a first class citizen. If you checkout trunk and\n perform a git status you will actually be on master, however you can\n use the trunk command in all places that you use the branch name (log,\n merge, etc.)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git asks for username every time I push\n\nWhenever I try to push into my repo git asks for both username & password. \nI have no problem in re-entering my password each time but the problem is in entering username. I use https to clone my repository.\nSo, how can I configure git so that it doesn't asks for username on each git push.\nI am new to linux but IIRC in windows git push only asks for password." }, { "role": "assistant", "content": "Edit (by @dk14 as suggested by moderators and comments)\nWARNING: If you use credential.helper store from the answer, your password is going to be stored completely unencrypted (\"as is\") at ~/.git-credentials. Please consult the comments section below or the answers from the \"Linked\" section, especially if your employer has zero tolerance for security issues.\nEven though accepted, it doesn't answer the actual OP's question about omitting a username only (not password). For the readers with that exact problem @grawity's answer might come in handy.\n\nOriginal answer (by @Alexander Zhu):\nYou can store your credentials using the following command\n$ git config credential.helper store\n$ git push http://example.com/repo.git\nUsername: <type your username>\nPassword: <type your password>\n\nAlso I suggest you to read\n$ git help credentials" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to undo last commit [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do I undo the most recent local commits in Git?\n\n (109 answers)\n \n\nClosed 10 years ago.\n\n\n\nI did the following comments\ngit add /file1/path\ngit rm /file/path\ngit commit -m \"message\"\n\nhow do I undo my last commit using git?\nLike I don't want to have those files committed." }, { "role": "assistant", "content": "Warning: Don't do this if you've already pushed\nYou want to do:\ngit reset HEAD~\n\nIf you don't want the changes and blow everything away:\ngit reset --hard HEAD~" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to restrict merging specific branch into other branches in Gitlab?\n\nIs there a way to restrict merging from a specific branch into other branches? Allow me to explain:\nI have a 'testing' branch and a 'master' branch in Gitlab. The team creates feature branches, merges them into 'testing' for approval and then merge the feature branch into 'master' once approved.\nSometimes, it can take months to get approval of some features, and therefore code is sat in the 'testing' branch for a while. Meanwhile, another feature branch may try to merge into 'testing' and conflicts will arise. This is expected, however, we are only human, and occasionally someone may accidentally merge 'testing' into their feature branch when handling the conflict, which is obviously wrong. Instead, we should switch to 'testing' and merge our feature branch into 'testing' thus managing the conflict within the testing branch.\nAny advise is appreciated." }, { "role": "assistant", "content": "To begin, be sure your needs is very normal and traditional.\nThe answer is ... Yes.\nHow to prevent merging from a branch to another, setting up a server Git Hook\nThese are some useful links:\n\nGit Hook explanations in Official Git Book\nGitLab server-side Hook explanations\nAn example with a Git Hook written in Ruby to prevent merging 'staging' branch to 'master' one\n\nTo help you (and for fun ^^), I wrote a dedicated hook in Python to reach your specific needs (you just need to adapt FORBIDDEN_SOURCE_BRANCH and FORBIDDEN_IF_NOT_DEST_BRANCH if you want to work with some other branches).\n#!/bin/python\n##\n## Author: Bertrand Benoit <mailto:[email protected]>\n## Description: Git Hook (server-side) allowing to prevent merge from some branches to anothers\n## Version: 0.9\n\nimport sys, subprocess, re\n\nFORBIDDEN_SOURCE_BRANCH='testing'\nFORBIDDEN_IF_NOT_DEST_BRANCH='master'\n\n# Considers only merge commit.\nif not (len(sys.argv) >=2 and sys.argv[2] == 'merge'):\n sys.exit(0)\n\n# Defines which is the source branch.\nwith open(sys.argv[1], 'r') as f:\n mergeMessage=f.readline()\nmergeBranchExtract=re.compile(\"Merge branch '([^']*)'.*$\").search(mergeMessage)\nif not mergeBranchExtract:\n print('Unable to extract branch to merge from message: ', mergeMessage)\n sys.exit(0) # Ensures normal merge as failback\n\n# Checks if the merge (source) branch is one of those to check.\nmergeBranch=mergeBranchExtract.group(1)\nif mergeBranch != FORBIDDEN_SOURCE_BRANCH:\n sys.exit(0) # It is NOT the forbidden source branch, so keeps on normal merge\n\n# Defines which is the current branch.\ncurrentBranchFullName=subprocess.check_output(['git', 'symbolic-ref', 'HEAD'])\ncurrentBranchExtract=re.compile(\"^.*/([^/]*)\\n$\").search(currentBranchFullName)\nif not currentBranchExtract:\n print('Unable to extract current branch from: ', currentBranchFullName)\n sys.exit(1) # Ensures normal merge as failback\n\n# Checks if the current (destination) branch is one of those to check.\ncurrentBranch=currentBranchExtract.group(1)\nif currentBranch != FORBIDDEN_IF_NOT_DEST_BRANCH:\n print(\"FORBIDDEN: Merging from '\" + mergeBranch + \"' to '\" + currentBranch + \"' is NOT allowed. Contact your administrator. Now, you should use git merge --abort and keep on your work.\")\n sys.exit(1) # This is exactly the situation which is forbidden\n\n# All is OK, so keeps on normal merge\nsys.exit(0)\n\nTo share all this work, I created a new Gitlab repository, in which I'll add further hooks when needed :)\nFor information, you can also setup protected branches to keep them safe from some users\nThis is the complete documentation about that.\nLet me know if you need further help." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Updating a local repository with changes from a GitHub repository\nI've got a project checked locally from GitHub, and that remote repository has since had changes made to it. What's the correct command to update my local copy with the latest changes?" }, { "role": "assistant", "content": "Probably:\neither: git pull origin master\n\n or: git pull origin main" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-archimport" }, { "role": "assistant", "content": "Import a GNU Arch repository into Git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-branch - List, create, or delete branches Listing branches from a specific remote" }, { "role": "assistant", "content": "$ git branch -r -l '<remote>/<pattern>' (1) $ git for-each-ref 'refs/remotes/<remote>/<pattern>' (2) Using -a would conflate <remote> with any local branches you happen to\nhave been prefixed with the same <remote> pattern. for-each-ref can take a wide range of options. See git-for-each-ref" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters --stop-at-non-option" }, { "role": "assistant", "content": "Only meaningful in --parseopt mode. Lets the option parser stop at\nthe first non-option argument. This can be used to parse sub-commands\nthat take options themselves." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Best Practice for Adding .gitignore to Repo\nWhat is the best practice regarding the .gitignore file with Git; should it be excluded from the repository or included? If it's conditional, what are the conditions for each circumstance?" }, { "role": "assistant", "content": "They should almost always be included, as their purpose is to ignore \"output\" files (compiled binaries, log files) which are going to be generated by anybody working with a clone of your project. They're meant to be version-controlled and included with the repository.\nYou should not use .gitignore files within the repository to ignore files that only appear for you, such as editor-specific swap files. You should be placing those rules in a global .gitignore file so that they apply to all repositories, or in .git/info/excludes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Unable to publish jar to Gitlab package registry with gradle\n\nI am trying to publish some jar artefacts on gitlab package registry but I get this error from the server :\nReceived status code 415 from server: Unsupported Media Type\n\nHere is the publishing section of my build.gradle.kts :\npublishing {\n publications {\n create<MavenPublication>(\"maven\"){\n artifact(tasks[\"bootJar\"])\n }\n }\n repositories {\n maven {\n url = uri(\"https://gitlab.com/api/v4/groups/my-group/-/packages/maven\")\n name = \"Gitlab\"\n credentials(HttpHeaderCredentials::class) {\n name = \"Token\"\n value = System.getenv(\"CI_JOB_TOKEN\")\n }\n authentication {\n create<HttpHeaderAuthentication>(\"header\")\n }\n }\n }\n}\n\nIn my gitlab-ci, I added a task for publish the artefacts :\ndeploy:\n stage: deploy\n script: gradle publish\n only:\n - master\n\nAny help would be appreciated" }, { "role": "assistant", "content": "Quick answer\nReplace your publishing url pointing to the group-scope with the one pointing to the specific-package-repository, e.g. on gitlab.com:\nhttps://gitlab.com/api/v4/projects/<your-project-id>/packages/maven\nYou need to replace <your-project-id> with your specific project-id of course.\nRelated to this a quote from docs.gitlab:\n\nNote: In all cases, you need a project specific URL for uploading a package in the distributionManagement section.\n\nOr in other words: Only the general repositories section can use your groups-url for searching other already published artifacts! (I also had to understand that). So:\n\nyou cannot publish to the group-package-store on gitlab, you can just search there.\nPublication goes always to the project-specific package-store, which will then be visible at group-scope too.\n\nExample gradle config (kotlin-dsl)\nrepositories {\n mavenCenter()\n jcenter()\n\n // Here you USE the group api/v4 url for SEARCHING packages\n maven {\n name = \"GitLab\"\n\n url = uri(\"https://gitlab.com/api/v4/groups/my-group/-/packages/maven\")\n credentials(HttpHeaderCredentials::class) {\n name = \"Job-Token\"\n value = System.getenv(\"CI_JOB_TOKEN\")\n }\n authentication {\n create<HttpHeaderAuthentication>(\"header\")\n }\n }\n\n}\n\npublishing {\n publications {\n create<MavenPublication>(\"maven\"){\n artifact(tasks[\"bootJar\"])\n }\n }\n repositories {\n maven {\n \n // here your PROVIDE the PROJECT-URI for publishing your package\n // in the project-specific package-space which is also visible at\n // the group scope above\n url = uri(\"https://gitlab.com/api/v4/projects/<your-project-id>/packages/maven\")\n name = \"Gitlab\"\n credentials(HttpHeaderCredentials::class) {\n name = \"Job-Token\"\n value = System.getenv(\"CI_JOB_TOKEN\")\n }\n authentication {\n create<HttpHeaderAuthentication>(\"header\")\n }\n }\n }\n}\n\nMore Info\nThere are multiple scenarios on how you may interact with the maven-repository-space on GitLab. The three switches are:\n\nThe place where you want to look for existing published packages\n\nproject-scope (https://.../api/v4/projects/<project-id>/packages/maven)\ngroup-scope (https://.../api/v4/groups/<group-id>/-/packages/maven)\ninstance-scope (https://.../api/v4/packages/maven)\n\n\nThe authorization-method you want to use\n\nPERSONAL_ACCESS_TOKEN\nDEPLOY_TOKEN\nCI_JOB_TOKEN\n\n\nThe place where your want to publish your package\n\nthis must always be a specific project-url (https://.../api/v4/projects/<project-id>/packages/maven)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Mermaid class diagrams get wider only, ignore direction\n\nI am having a problem using Mermaid syntax to layout class diagrams inside GitLab markdown. I have some evidence that I made a mistake in my Mermaid syntax, irrespective of GitLab. Thus, I felt it OK to ask on SO.\nThe class diagrams I am trying to create with Mermaid only lays out wider and wider as I add elements. The text in the diagram also get smaller and smaller. I cannot get the layout to expand vertically instead.\nHere is screen shot with H1 element for reference.\n\nI added the direction key word, but the layout ignores it. I have tried TD and TB and LR and RL for direction values. The class diagrams renders the same in all cases.\nI found this a more complicated diagram that renders nicely in GitLab. That layout uses both horizontal and vertical space. This makes me think that GitLab is working, but my syntax is wrong.\nHow do I get Mermaid to expand more vertically instead of horizontally and/or to not reduce the text size so much?\nHere is the code:\nclassDiagram\n%% Direction does not seem to be working?\ndirection TB\n%% ---- Lib Classes ----\nclass Lib_FancyFruit\nclass Lib_GoodBread{\n +Double yeastAmount\n}\nLib_FancyFruit *-- \"0..*\" Lib_GoodBread : breads\nclass Lib_SeasideManor\nclass Lib_LiberalSpice{\n +String currentFlavor\n}\nLib_SeasideManor *-- \"0..*\" Lib_LiberalSpice : spicesAllAround\nclass Lib_PrimeCurrents\nclass Lib_GardenFresh\nLib_GardenFresh *-- \"0..*\" Lib_PrimeCurrents : currentCurrents\nclass Lib_RepeatingHistory\nclass Lib_TranslationInformation\nclass Lib_HistoryLayerAgain\nLib_RepeatingHistory *-- \"0..*\" Lib_TranslationInformation : recentHistory\nLib_TranslationInformation *-- \"0..*\" Lib_HistoryLayerAgain : anotherTranslationInformation\n%% ---- Interfaces ----\nclass HappinessSadnessDisplay{\n <<interface>>\n ~String formattedCurrentThings\n ~Date onceDate\n ~String formattedDayDate\n ~String goryDetail\n ~String firstName\n ~Bool workComplete\n ~Bool appointmentScheduled\n}\nclass RedTrainSchedule{\n <<interface>>\n ~Double dailyCrayonsDue\n ~Bool willBeOnTimeToday\n ~createFreightTrainRailLine() FreightTrainRailLine\n}\n%% ---- Enums ----\nclass Pill{\n <<enumeration>>\n reallyOval\n circularizedKind\n}\n%% ---- Main Classes ----\nclass WanderingMan\nWanderingMan o-- \"1\" Lib_LiberalSpice : spice\nWanderingMan o-- \"0..1\" Pill : pill\nWanderingMan o-- \"0..1\" Lib_GardenFresh : gardenAccounts\nWanderingMan o-- \"0..1\" PoliteHamAction : hamStory\nWanderingMan o-- \"0..1\" PoliteHamAction : scheduledPorkchops\nWanderingMan o-- \"0..1\" Lib_GoodBread : unwrappedBread\nWanderingMan ..|> RedTrainSchedule\nWanderingMan ..|> HappinessSadnessDisplay\nclass PoliteHamAction{\n ~String porkNumber\n}\nPoliteHamAction o-- \"1\" Lib_HistoryLayerAgain : actionLayerDetail" }, { "role": "assistant", "content": "" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs -B[<n>][/<m>] --break-rewrites[=[<n>][/<m>]]" }, { "role": "assistant", "content": "Break complete rewrite changes into pairs of delete and\ncreate. This serves two purposes: It affects the way a change that amounts to a total rewrite of a file\nnot as a series of deletion and insertion mixed together with a very\nfew lines that happen to match textually as the context, but as a\nsingle deletion of everything old followed by a single insertion of\neverything new, and the number m controls this aspect of the -B\noption (defaults to 60%). -B/70% specifies that less than 30% of the\noriginal should remain in the result for Git to consider it a total\nrewrite (i.e. otherwise the resulting patch will be a series of\ndeletion and insertion mixed together with context lines). When used with -M, a totally-rewritten file is also considered as the\nsource of a rename (usually -M only considers a file that disappeared\nas the source of a rename), and the number n controls this aspect of\nthe -B option (defaults to 50%). -B20% specifies that a change with\naddition and deletion compared to 20% or more of the file’s size are\neligible for being picked up as a possible source of a rename to\nanother file." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch -r --rebase[=(false|true|merges|interactive)]" }, { "role": "assistant", "content": "When true, rebase the current branch on top of the upstream\nbranch after fetching. If there is a remote-tracking branch\ncorresponding to the upstream branch and the upstream branch\nwas rebased since last fetched, the rebase uses that information\nto avoid rebasing non-local changes. When set to merges , rebase using git rebase --rebase-merges so that\nthe local merge commits are included in the rebase (see git-rebase for details). When false, merge the upstream branch into the current branch. When interactive , enable the interactive mode of rebase. See pull.rebase , branch.<name>.rebase and branch.autoSetupRebase in git-config if you want to make git pull always use --rebase instead of merging. Note This is a potentially dangerous mode of operation.\nIt rewrites history, which does not bode well when you\npublished that history already. Do not use this option\nunless you have read git-rebase carefully." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --sparse" }, { "role": "assistant", "content": "All commits that are walked are included. Note that without --full-history , this still simplifies merges: if\none of the parents is TREESAME, we follow only that one, so the other\nsides of the merge are never walked." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-checkout - Switch branches or restore working tree files --recurse-submodules --no-recurse-submodules" }, { "role": "assistant", "content": "Using --recurse-submodules will update the content of all active\nsubmodules according to the commit recorded in the superproject. If\nlocal modifications in a submodule would be overwritten the checkout\nwill fail unless -f is used. If nothing (or --no-recurse-submodules )\nis used, submodules working trees will not be updated.\nJust like git-submodule , this will detach HEAD of the\nsubmodule." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --histogram" }, { "role": "assistant", "content": "Generate a diff using the \"histogram diff\" algorithm." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --ext-diff" }, { "role": "assistant", "content": "Allow an external diff helper to be executed. If you set an\nexternal diff driver with gitattributes , you need\nto use this option with git-log and friends." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "fatal: early EOF fatal: index-pack failed\nI have googled and found many solutions but none work for me.\nI am trying to clone from one machine by connecting to the remote server which is in the LAN network.\nRunning this command from another machine cause error.\nBut running the SAME clone command using git://192.168.8.5 ... at the server it's okay and successful. \nAny ideas ?\nuser@USER ~\n$ git clone -v git://192.168.8.5/butterfly025.git\nCloning into 'butterfly025'...\nremote: Counting objects: 4846, done.\nremote: Compressing objects: 100% (3256/3256), done.\nfatal: read error: Invalid argument, 255.05 MiB | 1.35 MiB/s\nfatal: early EOF\nfatal: index-pack failed\n\nI have added this config in .gitconfig but no help also.\nUsing the git version 1.8.5.2.msysgit.0\n[core]\n compression = -1" }, { "role": "assistant", "content": "First, turn off compression: \ngit config --global core.compression 0\n\nNext, let's do a partial clone to truncate the amount of info coming down: \ngit clone --depth 1 <repo_URI>\n\nWhen that works, go into the new directory and retrieve the rest of the clone: \ngit fetch --unshallow \n\nor, alternately, \ngit fetch --depth=2147483647\n\nNow, do a regular pull: \ngit pull --all\n\nI think there is a glitch with msysgit in the 1.8.x versions that exacerbates these symptoms, so another option is to try with an earlier version of git (<= 1.8.3, I think)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to make git clone faster with multiple threads?\nMy internet speed to github was never fast, and it's lingering at 50kb/s (my internet speed is 20mbit which is not very fast but still much faster than this). The repository is multi-gb by my estimates, so it'll take a very long time.\nDoes git support downloading the objects using multiple-threads so I can max-out my internet speed?" }, { "role": "assistant", "content": "You can at least try and mitigate the issue, with a shallow clone (meaning not cloning the all history):\ngit clone --depth 1 <repository>\n\nMake sure to have a git 1.9+, as I explained in \"Is git clone --depth 1 (shallow clone) more useful than it makes out?\".\nNote: Git 2.5 (Q2 2015) even supports a single fetch commit!See \"Pull a specific commit from a remote git repository\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "error: cannot lock ref.. 'refs/tags' exists; cannot create 'refs/tags/\n\nI'm getting a strange \"cannot lock ref\" error when trying to pull changes from github. I've tried git gc, and looked around for similar errors but can't find a solution.\n> git pull\nerror: cannot lock ref 'refs/tags/v2.8': 'refs/tags' exists; cannot create 'refs/tags/v2.8'\nFrom github.com:k3it/qsorder\n ! [new tag] v2.8 -> v2.8 (unable to update local ref)\nerror: cannot lock ref 'refs/tags/v2.9': 'refs/tags' exists; cannot create 'refs/tags/v2.9'\n ! [new tag] v2.9 -> v2.9 (unable to update local ref)" }, { "role": "assistant", "content": "Your Git is complaining that a reference (rather than a directory) named refs/tags exists. It's not clear what would create that, but see if git rev-parse refs/tags produces a hash ID. If so, that reference needs to go away:\ngit update-ref -d refs/tags\n\nafter which git fetch should work.\nIf git rev-parse refs/tags fails (which it should—refs/tags itself should not be a valid name) then this is not the problem and it's not clear what the actual problem is." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-grep - Print lines matching a pattern -a --text" }, { "role": "assistant", "content": "Process binary files as if they were text." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-gc - Cleanup unnecessary files and optimize the local repository gc.writeCommitGraph" }, { "role": "assistant", "content": "If true, then gc will rewrite the commit-graph file when git-gc is run. When using git gc --auto the commit-graph will be updated if housekeeping is\nrequired. Default is true. See git-commit-graph for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options GIT_CONFIG_GLOBAL GIT_CONFIG_SYSTEM" }, { "role": "assistant", "content": "Take the configuration from the given files instead from global or\nsystem-level configuration. See git for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-update-index - Register file contents in the working tree to the index" }, { "role": "assistant", "content": "UNTRACKED CACHE This cache is meant to speed up commands that involve determining\nuntracked files such as git status . This feature works by recording the mtime of the working tree\ndirectories and then omitting reading directories and stat calls\nagainst files in those directories whose mtime hasn’t changed. For\nthis to work the underlying operating system and file system must\nchange the st_mtime field of directories if files in the directory\nare added, modified or deleted. You can test whether the filesystem supports that with the --test-untracked-cache option. The --untracked-cache option used\nto implicitly perform that test in older versions of Git, but that’s\nno longer the case. If you want to enable (or disable) this feature, it is easier to use\nthe core.untrackedCache configuration variable (see git-config ) than using the --untracked-cache option to git update-index in each repository, especially if you want to do so\nacross all repositories you use, because you can set the configuration\nvariable to true (or false ) in your $HOME/.gitconfig just once\nand have it affect all repositories you touch. When the core.untrackedCache configuration variable is changed, the\nuntracked cache is added to or removed from the index the next time a\ncommand reads the index; while when --[no-|force-]untracked-cache are used, the untracked cache is immediately added to or removed from\nthe index. Before 2.17, the untracked cache had a bug where replacing a directory\nwith a symlink to another directory could cause it to incorrectly show\nfiles tracked by git as untracked. See the \"status: add a failing test\nshowing a core.untrackedCache bug\" commit to git.git. A workaround for\nthat is (and this might work for other undiscovered bugs in the\nfuture): $ git -c core.untrackedCache=false status This bug has also been shown to affect non-symlink cases of replacing\na directory with a file when it comes to the internal structures of\nthe untracked cache, but no case has been reported where this resulted in\nwrong \"git status\" output. There are also cases where existing indexes written by git versions\nbefore 2.17 will reference directories that don’t exist anymore,\npotentially causing many \"could not open directory\" warnings to be\nprinted on \"git status\". These are new warnings for existing issues\nthat were previously silently discarded. As with the bug described above the solution is to one-off do a \"git\nstatus\" run with core.untrackedCache=false to flush out the leftover\nbad data." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Python not working in the command line of git bash\nPython will not run in git bash (Windows). When I type python in the command line, it takes me to a blank line without saying that it has entered python 2.7.10 like its does in Powershell. It doesn't give me an error message, but python just doesn't run.\nI have already made sure the environmental variables in PATH included c:\\python27. What else can I check?\n\nA session wherein this issue occurs looks like the following:\nuser@hostname MINGW64 ~\n$ type python\npython is /c/Python27/python\n\nuser@hostname MINGW64 ~\n$ python\n\n...sitting there without returning to the prompt." }, { "role": "assistant", "content": "Temporary solution\nJust enter this in your git shell on windows - > alias python='winpty python.exe', that is all and you are going to have alias to the python executable. This alias will be valid for the duration of the shell session.\nwinpty is a Windows software package providing an interface similar to a Unix pty-master for communicating with Windows console programs.\nPermanent solution\nAdd the command to your .bashrc in the users home directory. You can use the CLI or a text editor:\nUsing CLI\nThis can be accomplished from git bash like so:\necho \"alias python='winpty python.exe'\" >> ~/.bashrc\n\nwhich will create .bashrc in the current users home directory if the file doesn't exist or append the alias to the end of .bashrc if it does.\nUsing a text editor\nAlternatively, you could first create a .bashrc. Depending on your file manager, this may be easier to accomplish in git bash like so:\ncd ~\ntouch .bashrc\n\nAt which point you can open .bashrc in your prefered text editor and add it there.\nTo apply the change, either use the command source .bashrc or restart the shell.\nUpdate\nNewer versions of Git no longer use .bashrc but instead use .bash_profile. Conda also uses this profile when initializing, so be sure not to overwrite or delete the initialization block. See more here: Git for Windows doesn't execute my .bashrc file." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "integrating gitlab with sonarqube\n\nI have GitLab CE (v8.5 at least) installed on my server. I would like to integrate it with sonarqube so that merge requests shows any issues in the comment section. Has anyone integrated these 2 systems successfully?\nAt the moment, only sonarqube plugin I found is the following but I'm not able to successfully integrate it with GitLab.\nhttps://gitlab.talanlabs.com/gabriel-allaigre/sonar-gitlab-plugin\nI used a docker container for sonarqube (v5.5) and copied the plugin into extensions directory. Configured gitlab user token and gitlab uri in the plugin's setting page in sonarqube.\nI'm using GitLab CI for continuous integration and I have the following build job for sonarqube (using gradle)\nsh gradlew sonarqube -Psonar.analysis.mode=preview -Psonar.issuesReport.console.enable=true \\\n -Psonar.gitlab.commit_sha=$CI_BUILD_REF -Psonar.gitlab.ref_name=$CI_BUILD_REF_NAME \\\n -Psonar.gitlab.project_id=$CI_PROJECT_ID\n\nBut, I'm not sure what to after this. Couple of questions:\n\nWhat happens when a merge request does not exist yet? In my git workflow, users will submit a merge request after they're done working on their branch. So, how will this plugin know which merge request to update?\nRight now I have the sonarqube valiation task set to be running only on master branch. I think this will need to be changed to user branches too, right?\n\nI did try submitting a merge request, but I didn't see any comments being added. I think I'm missing some configuration or a process. Really appreciate if you can help point me to the right direction." }, { "role": "assistant", "content": "I had the same problem than yours. Comments were not showing in the GitLab MR. I made it work with two fixes:\n\nmake sure the preview mode is used. If it is not, the issues are not reported to GitLab\nfor issues to appear as GitLab comments, they have to be \"new\" issues. If you launched an analysis of your project before pushing to GitLab, the issues will not be considered as new by SonarQube, and no comment will be added to the MR.\n\nIf this does not solve your problem, try cloning the plugin repo, adding traces to the code (CommitIssuePostJob.java is the place to look), package the jar with maven and deploy the patched jar to your Sonar installation. That is how I saw that I had no new issues to report." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do you revert to a specific tag in Git?\nI know how to revert to older commits in a Git branch, but how do I revert back to a branch's state dictated by a tag? I envision something like this:\ngit revert -bytag \"Version 1.0 Revision 1.5\"\n\nIs this possible?" }, { "role": "assistant", "content": "Git tags are just pointers to the commit. So you use them the same way as you do HEAD, branch names or commit sha hashes. You can use tags with any git command that accepts commit/revision arguments. You can try it with git rev-parse tagname to display the commit it points to.\nIn your case you have at least these two alternatives:\n\nReset the current branch to specific tag:\ngit reset --hard tagname\n\nGenerate revert commit on top to get you to the state of the tag:\ngit revert tag\n\n\nThis might introduce some conflicts if you have merge commits though." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "husky > pre-commit hook failed (add --no-verify to bypass)\nSuddenly I am getting the \"husky > pre-commit hook failed (add --no-verify to bypass)\" error message when I give the git commit.\n(C:\\Windows\\System32\\cmd.exe)\n> git commit\nhusky > npm run -s precommit (node v12.18.3)\n\n'pretty-quick' is not recognized as an internal or external command,\noperable program or batch file.\n\nhusky > pre-commit hook failed (add --no-verify to bypass)\n\n\nI tried git clean command too. Anyone faced similar issue?" }, { "role": "assistant", "content": "Husky can prevent you from bad git commit, git push, and more. If you are getting this error check your code syntax. In case you are getting this error even if your code is valid, please use the below solution.\n#Solution 1:\nDelete the .git/hooks folder and then do the npm install to reinstall husky. There are chances for conflicts with husky-generated files in the .git/hooks/ files.\n#Solution 2:\nthis is a temporary/quick solution.\ngit commit -m \"message\" --no-verify" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Best practices for using GOOGLE_APPLICATION_CREDENTIALS in gitlab CI/CD [closed]\n\nClosed. This question is opinion-based. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it can be answered with facts and citations by editing this post.\n\n\nClosed last year.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI'm trying to make GitLab pipelines that deploy GCP instances through the GCP terraform provider. Other platforms like AWS have environmental variables like $AWS_ACCESS_KEY_ID and $AWS_SECRET_ACCESS_KEY that can be used to authenticate requests, but GCP seems to use service account credential files instead. \nI could create a CI gitlab file variable to contain my GCP service account credential file, but I can only add it in an insecure way. If I attempt to mask my file variable under the GitLab ci-cd settings it produces the error message This variable can not be masked.\nWhat is the proper best practice for storing GCP service account credential files in GitLab CI/CD environmental variables?" }, { "role": "assistant", "content": "One approach is to take the environment variable and write it out as a file. When you add variable in the newer versions of Gitlab, there is a dropdown that lets you choose between \"Variable\" and \"File\". If you put the contents in the value field, you can use a cp $VARIABLE_NAME name-of-file.bob.\nYou don't need to mask it because it is never written to the log (unless you cat it), but I do recommend you check the \"Protect\" check box which means it will only be used on protected branches.\nA second approach is to encrypt it and decrypt it using a password which is in a protected variable. It would require getting another program in the build, but that might work for you.\nA third is use something like age to check in the encrypted file, write out a SSH as a fancy decryption key, and then package the SSH.\nBut, the first approach is probably going to be your best bet." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to download a single file from GitLab?\n\nI know it is possible to fetch then use checkout with the path/to/file to download that specific file.\nMy issue is that I have a 1 MB data cap per day and git fetch will download all the data anyway even if it does not save them to disc until I use git checkout. I still used my data\nIs my understanding of how git fetch/checkout correct? is there a way to download a specific file only to see if there is a new version before proceeding with the download." }, { "role": "assistant", "content": "Gitlab has a rest API for that.\nYou can GET a file from repository with curl:\ncurl https://gitlab.com/api/v4/projects/:id/repository/files/:filename\\?ref\\=:ref\n\nFor example:\ncurl https://gitlab.com/api/v4/projects/12949323/repository/files/.gitignore\\?ref\\=master\n\nIf your repository isn't public you also need to provide an access token by adding --header 'Private-Token: <your_access_token>'.\n\nLinks:\nYou can check how to find repository api id here.\nApi documentation\nMore on tokens\nThere is also a python library that uses this api.\nNote that this is GitLab specific solution and won't work for other hostings." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do you keep track of your comments on GitHub issues?\n\nI want to find all the GitHub issues that I commented on. I tried searching for commenter:mbigras type:issue like the Searching issues and pull requests GitHub article suggests. But that method returns fewer results than the public activity section of my profile.\nSee both attached images:\nSearch method\nDoesn't display current results:\n\nProfile method\nGets mixed up with other public activity:\n\nIs there a way to get the full history of my comments on GitHub?\nEDIT\nauthor:mbigras type:issue gives wider results but still not the full history:\n\nWhat I'm looking for is a way to quickly view all my comment/issue history in all issues.\nEDIT\nI emailed GitHub about this. Search doesn't match the public activity section because search indexes issues by creation date and not last active date.\nHow do you keep organized about which issues you've commented on?" }, { "role": "assistant", "content": "Search for commenter:username in the main Github search box.\nFor example commenter:gavinandresen\nTo see recent activity, select Recently updated from Sort dropdown\nYou can also narrow the search: is:issue commenter:gavinandresen" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab run a pipeline job when a merge request is merged\n\nI have a gitlab pipeline where there are two stages, one is build and the other one is deploy. The build stage is run when a commit is made. I want a way to run the deploy job when the merge request is merged to master. I tried several things but no luck. Can anyone help?\nstages:\n - build\n - deploy\n\ndotnet:\nscript: \"echo This builds!\"\nstage: build\n\n\nproduction:\nscript: \"echo This deploys!\"\nstage: deploy\n\nonly:\n refs:\n - master" }, { "role": "assistant", "content": "Try using the gitlab-ci.yml \"rules\" feature to check for the merge request event.\nYour current gitlab-ci.yml will run your \"dotnet\" job every commit, merge request, schedule, and manually triggered pipeline.\nhttps://docs.gitlab.com/ee/ci/yaml/#workflowrules\ndotnet:\n script: \"echo This builds!\"\n stage: build\n rules:\n - if: '$CI_COMMIT_REF_NAME != \"master\" && $CI_PIPELINE_SOURCE == \"push\" || $CI_PIPELINE_SOURCE == \"merge_request_event\"'\n\nproduction:\n script: \"echo This deploys!\"\n stage: deploy\n rules:\n - if: '$CI_PIPELINE_SOURCE == \"push\" && $CI_COMMIT_REF_NAME == \"master\"'" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Merge - Incomplete, Missing files and Folders\nI was trying to merge a dev branch into master.\ngit checkout master \ngit pull . dev\n\nEverything seemed to go well, although there were conflicts I fixed these and commited. But when I checked this newly merged working tree is missing a lot of folders and files from dev.\ngit status // Shows conflicts & doesn't list some files/folders. \ngit commit -a \n\nCreated commit 55ffdd1: Merge branch 'dev' into master \n\ngit diff dev --name-status\n\nProduces:\nD folders/lm.gif\nD folders/lmh.gif\n...\n\nSo the files/folders that didn't show up on 'git status'. It also didn't show up at the end when I fixed the merged conflicts.\nAlso when I try to merge again it says:\ngit merge dev \nAlready up-to-date.\n\nYet the master branch clearly is missing files/folders from the dev branch. Why is that? Shouldn't that folder and all it's contents be added? 'folders' is being tracked on the dev branch, so shouldn't it have gotten pulled over when I did the merge?\nWhen there was a merge conflict earlier did git stop the merge process and skipped a bunch of files/folders?\nThe dev branch had quite a lot of changes, could I have messed something up with git in the past that now certain files/folders wouldn't have merged? \n(When I first created the dev branch I didn't know what I was doing and did crazy things like reset, reverts etc.)\nHoping one of you git guru's here on stack overflow knows the answer. :) \nThanks,\nQuang\n\nAnswer\nThanks Walter, Yes this is what happened.\nAfter doing some investigating I found out it was a little complicated what happened. It turned out that.\n\ndev branched from master, it had all the files.\nA third branch, lets call it \"cleaned\", branched off of dev.\ncleaned branch deleted all the files.\ncleaned branch merged (or something?) with master. At this point the files were deleted off of master. And the 'cleaned' branch disappeared.\non dev, the files are still there and I continued adding to this branch, editing files for quite some time.\ndev merged with master and all the files that was deleted previously by cleaned were gone.\n\nHope this helped someone besides me who learned quite a lot about how to use git log, git show, git reflog trying to debug what happened.\nThanks!\nHow to Fix\nSo this is what I did to merge all of the contents in dev that was previously deleted back onto master.\n\nGot all the files/folders that was deleted (on dev but not on the newly merged master) git diff dev --name-status | grep D > deleted_files\nOutput list of all files and folders git log --name-status > file_history Gonna be using this to figure out the last updated version of the deleted file.\nGo through the list of deleted_files one by one, find the the most updated version in file_history and restore it. Example: git checkout 25b8a44 view.php 25b8a44... was the commit with the last updated version of view.php. I tried cherry-pick and just a straight git checkout dev view.php but i found explicitly using the commit id, it merge more of it's history. (Including the commit that cause the file to be deleted in the first place.)\nOnce all the deleted files are back a quick check git diff dev --name-status | grep D shows that all files are copied over. Then like Walter said an ammend commit git commit --amend :)" }, { "role": "assistant", "content": "It sounds like git thinks that the missing files were deleted on the master at some point between where it branches from dev and the pre-merge head. That's the only reason I can think of for why git would silently drop tracked files during a merge.\nUnfortunately, I don't know a good way to fix that. I'd probably just re-add all the deleted files from the dev branch manually (or with a little bit of bash scripting), and then to a git commit --amend to revise the merge commit to include them." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to get just one file from another branch\nI have a main branch with a file called app.js. I made changes to this file on an experiment branch.\nI want to apply only the changes made to app.js from experiment onto the main branch." }, { "role": "assistant", "content": "git checkout main # first get back to main\ngit checkout experiment -- app.js # then copy the version of app.js \n # from branch \"experiment\"\n\nSee also Undo working copy modifications of one file in Git.\n\nUpdate August 2019, Git 2.23\nWith the new git switch and git restore commands, that would be:\ngit switch main\ngit restore --source experiment -- app.js\n\nBy default, only the working tree is restored.\nIf you want to update the index as well (meaning restore the file content, and add it to the index in one command):\ngit restore --source experiment --staged --worktree -- app.js\n# shorter:\ngit restore -s experiment -SW -- app.js\n\n\nAs Jakub Narębski mentions in the comments:\ngit show experiment:path/to/app.js > path/to/app.js\n\nworks too, except that, as detailed in the SO question \"How to retrieve a single file from specific revision in Git?\", you need to use the full path from the root directory of the repo.\nHence the path/to/app.js used by Jakub in his example.\nAs Frosty mentions in the comment:\n\nyou will only get the most recent state of app.js\n\nBut, for git checkout or git show, you can actually reference any revision you want, as illustrated in the SO question \"git checkout revision of a file in git gui\":\n$ git show $REVISION:$FILENAME\n$ git checkout $REVISION -- $FILENAME\n\nwould be the same is $FILENAME is a full path of a versioned file.\n$REVISION can be as shown in git rev-parse:\nexperiment@{yesterday}:app.js # app.js as it was yesterday \nexperiment^:app.js # app.js on the first commit parent\nexperiment@{2}:app.js # app.js two commits ago\n\nand so on.\nschmijos adds in the comments:\n\nyou also can do this from a stash:\ngit checkout stash -- app.js\n\nThis is very useful if you're working on two branches and don't want to commit." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What would be the standard and better approach of the git repository structure for microservice architecture?\n\nThe better approach of repository structure for microservice architecture based applications?\nFor example, I was referring through Microsoft reference architecture i.e. eShopContainers in github repository [https://github.com/dotnet-architecture/eShopOnContainers/tree/dev/src]. But that comes up with some more complexity of dynamic work environment, where team work on various UI, microservices, hence everything under one repository is making it more time consuming process on merge/conflicts, etc. Some team members would like to have each microservice in separate repository while development for better management and then to export to group repository after production i.e. while BAU. Appreciate to have a discussion the pros and cons to make a better decision for our environment." }, { "role": "assistant", "content": "Having done both, here are some of the tradeoffs:\nFor a monorepo (all code and services in the same repo):\n\nMuch easier to keep related changes in sync (e.g., both a producer and a consumer change; the changes to both can be saved as a single commit).\nIt's easier to set up a consistent build environment. Properly set up, all of the services can be built using exactly the same toolchain and possibly the same Makefile.\nIf you choose to use a single GOPATH, all of the services need to be kept in lockstep. This can cause a lot of pain if one service needs to switch to a newer version of a library with a breaking change; every service using that library has to upgrade at once. Multiple GOPATHS make the process more complex to maintain.\nIf properly managed with CI and testing, it's possible to keep HEAD in a deployable state at all times, decreasing the chance you'll end up with a set of services that can't interoperate because they don't match up.\n\nMultiple repositories:\n\nMuch easier to get a service to a stable level and leave it alone. Because it lives in its own repository, there's no requirement to do upgrades even if another service needs a newer version of a library, or you decide to change libraries (e.g. from Gin to Echo).\nTempting to neglect upgrades on stable services (the Gin to Echo change, for example), possibly entailing a significant update for a breaking change under time pressure; definitely increasing maintenance load (do we do the long-postponed upgrade to Echo, or do we just leave it at Gin? If we have to make a significant change to our APIs, how many different frameworks will we need to work with when we do that?)\nProliferation of repositories makes it harder to find something when it's needed (which service did we define this in? I need to reuse that over here)\nProliferation of duplicate or (worse) near-duplicate code across multiple repositories. It's easy to get into the habit of copying a service as a base and then making changes on top of the old code, resulting in a fractal set of differences across the codebase, especially because \"working\" code doesn't tend to get updated to match the changes.\n\nThere are no doubt others, but these are some that I've actually experienced in both cases. A monorepo is probably better if you're going to be evolving a lot of services in parallel; multiple repos is better if you can architect your services pretty much independent of each other." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I change from a PR to a draft PR at github?\n\nGithub release the draft PR a while ago.\nI have a normal PR and I wanted to change that to a draft PR. How can I do that?" }, { "role": "assistant", "content": "Update - Now Available - Jan 2020\nConvert Default → Draft\nThis is possible now, with an option below \"Reviewers\" section in PR.\n\nSee: Feature Request: Switch from ready to draft in pull requests\nConvert Draft → Default\nTo answer @marsandback comment Draft PR --> PR, just click the Ready for review" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git rebase in Visual Studio Code\nHere is my situation: I have a production branch, a dev branch and branches for features. While I was working on a feature I has to do a hotfix on the dev branch. Now I to rebase the feature branch I am currently working on to avoid future merging conflicts. When I used to use IDEs from JetBrain I would do a git rebase and it would do the trick. The only command I found in VSCode is Git: Sync(rebase) but this does not do anything and does not rebase. All I get is this message:\nThis action will push and pull commit to and from 'origin/Current_feature'\n\nAnyone have experience with this?" }, { "role": "assistant", "content": "I just tried, it works!! \nPS: I try to find the approach to setting the default \"Sync\" action with --rebase paramter. I find the PR of Added config option to sync+Rebase from statusbar, but it haven't landed.\nFinally find the solution, git config --global pull.rebase true and it works!!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %aN" }, { "role": "assistant", "content": "author name (respecting .mailmap, see git-shortlog or git-blame )" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Add comments/remarks to .gitattributes\nIs it possible to add comments or remarks to a .gitattributes file?\nIf yes, how exactly do comment lines look like?" }, { "role": "assistant", "content": "# This is a comment! \nin .gitattributes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options addEmptyPathspec" }, { "role": "assistant", "content": "Shown when the user runs git add without providing\nthe pathspec parameter." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Keep file in a Git repo, but don't track changes\nI need to include some files in my GitHub repo, but not track changes on them. How can I accomplish this? An example use case is for a file that includes sensitive user information, such as login credentials.\nFor example, I deploy a new installation of this framework to a new client, I want the following files to be downloaded (they have default values CHANGEME) and I just have to make changes specific to this client (database credentials, email address info, custom CSS).\n// The production config files. I want the files but they need to be updated to specific client needs\napplication/config/production/config.php\napplication/config/production/database.php\napplication/config/production/tank_auth.php\n// Index page, defines the environment (production|development)\n/index.php\n// All of the css/js cache (keep the folder but not the contents)\n/assets/cache/*\n// Production user based styling (color, fonts etc) needs to be updated specific to client needs\n/assets/frontend/css/user/frontend-user.css\n\nCurrently if I run\ngit clone [email protected]:user123/myRepo.git httpdocs\n\nand then edit the files above, all is great. Until I release a hotfix or patch and run git pull. All of my changes are then overwritten." }, { "role": "assistant", "content": "git has a different solution to do this. First change the file you do not want to be tracked and use the following command: \ngit update-index --assume-unchanged FILE_NAME\n\nand if you want to track the changes again use this command: \ngit update-index --no-assume-unchanged FILE_NAME\n\ngit-update-index documentation" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options protocol.allow" }, { "role": "assistant", "content": "If set, provide a user defined default policy for all protocols which\ndon’t explicitly have a policy ( protocol.<name>.allow ). By default,\nif unset, known-safe protocols (http, https, git, ssh) have a\ndefault policy of always , known-dangerous protocols (ext) have a\ndefault policy of never , and all other protocols (including file)\nhave a default policy of user . Supported policies: always - protocol is always able to be used. never - protocol is never able to be used. user - protocol is only able to be used when GIT_PROTOCOL_FROM_USER is\neither unset or has a value of 1. This policy should be used when you want a\nprotocol to be directly usable by the user but don’t want it used by commands which\nexecute clone/fetch/push commands without user input, e.g. recursive\nsubmodule initialization." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_REFLOG_ACTION" }, { "role": "assistant", "content": "When a ref is updated, reflog entries are created to keep\ntrack of the reason why the ref was updated (which is\ntypically the name of the high-level command that updated\nthe ref), in addition to the old and new values of the ref.\nA scripted Porcelain command can use set_reflog_action\nhelper function in git-sh-setup to set its name to this\nvariable when it is invoked as the top level command by the\nend user, to be recorded in the body of the reflog." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options pack.depth" }, { "role": "assistant", "content": "The maximum delta depth used by git-pack-objects when no\nmaximum depth is given on the command line. Defaults to 50.\nMaximum value is 4095." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub: Clone succeeded, but checkout failed\nI am having some problems working with \ngit clone.The files are downloaded in my local git folder. Running the command\ngit checkout -f HEAD gives me-\nError:\n\n'The unable to write new index file error caused by the lack of disk space'. \n\nI've manually removed big files from my computer, but still getting the same error.\nCloning into 'ffmpeg'...\nremote: Counting objects: 7890, done. \nremote: Compressing objects: 100% (4412/4412), done.\nReceiving objects: 100% (7890/7890), 299.75 MiB | 24.19 MiB/s, done.\nremote: Total 7890 (delta 3346), reused 7846 (delta 3317)\nResolving deltas: 100% (3346/3346), done.\nChecking out files: 100% (7019/7019), done.\nfatal: unable to write new index file\nwarning: Clone succeeded, but checkout failed.\nYou can inspect what was checked out with 'git status'\nand retry the checkout with 'git checkout -f HEAD'" }, { "role": "assistant", "content": "For me this was due to long file names and doing a simple config as below resolved it\n\ngit config --system core.longpaths true" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I remove an SSH key?\nI currently have an old SSH key uploaded on a server. The problem is I lost my ~/.ssh directory (with the original id_rsa and id_rsa.pub files).\nConsequently, I want to remove the old SSH key directly on the server and upload a new one.\nI tried the following command without success:\n$> ssh-add -D\n\n\nIs there a way to completely remove an SSH key?" }, { "role": "assistant", "content": "Note that there are at least two bug reports for ssh-add -d/-D not removing keys:\n\n\"Debian Bug report #472477: ssh-add -D does not remove SSH key from gnome-keyring-daemon memory\"\n\"Ubuntu: ssh-add -D deleting all identities does not work. Also, why are all identities auto-added?\"\n\nThe exact issue is:\n\nssh-add -d/-D deletes only manually added keys from gnome-keyring.\nThere is no way to delete automatically added keys.\nThis is the original bug, and it's still definitely present.\nSo, for example, if you have two different automatically-loaded ssh identities associated with two different GitHub accounts -- say for work and for home -- there's no way to switch between them. GitHubtakes the first one which matches, so you always appear as your 'home' user to GitHub, with no way to upload things to work projects.\nAllowing ssh-add -d to apply to automatically-loaded keys (and ssh-add -t X to change the lifetime of automatically-loaded keys), would restore the behavior most users expect.\n\n\nMore precisely, about the issue:\n\nThe culprit is gpg-keyring-daemon:\n\nIt subverts the normal operation of ssh-agent, mostly just so that it can pop up a pretty box into which you can type the passphrase for an encrypted ssh key.\nAnd it paws through your .ssh directory, and automatically adds any keys it finds to your agent.\nAnd it won't let you delete those keys.\n\nHow do we hate this? Let's not count the ways -- life's too short.\nThe failure is compounded because newer ssh clients automatically try all the keys in your ssh-agent when connecting to a host.\nIf there are too many, the server will reject the connection.\nAnd since gnome-keyring-daemon has decided for itself how many keys you want your ssh-agent to have, and has autoloaded them, AND WON'T LET YOU DELETE THEM, you're toast.\n\nThis bug is still confirmed in Ubuntu 14.04.4, as recently as two days ago (August 21st, 2014)\n\nA possible workaround:\n\n\nDo ssh-add -D to delete all your manually added keys. This also locks\nthe automatically added keys, but is not much use since gnome-keyring will ask you to unlock them anyways when you try doing a git push.\nNavigate to your ~/.ssh folder and move all your key files except the one you want to identify with into a separate folder called backup. If necessary you can also open seahorse and delete the keys from there.\nNow you should be able to do git push without a problem.\n\n\n\nAnother workaround:\n\nWhat you really want to do is to turn off gpg-keyring-daemon altogether.\nGo to System --> Preferences --> Startup Applications, and unselect the \"SSH Key Agent (Gnome Keyring SSH Agent)\" box -- you'll need to scroll down to find it.\nYou'll still get an ssh-agent, only now it will behave sanely: no keys autoloaded, you run ssh-add to add them, and if you want to delete keys, you can. Imagine that.\n\nThis comments actually suggests:\n\nThe solution is to keep gnome-keyring-manager from ever starting up, which was strangely difficult by finally achieved by removing the program file's execute permission.\n\n\nRyan Lue adds another interesting corner case in the comments:\n\nIn case this helps anyone: I even tried deleting the id_rsa and id_rsa.pub files altogether, and the key was still showing up.\nTurns out gpg-agent was caching them in a ~/.gnupg/sshcontrol file; I had to manually delete them from there.\n\nThat is the case when the keygrip has been added as in here." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --show-pulls" }, { "role": "assistant", "content": "Include all commits from the default mode, but also any merge\ncommits that are not TREESAME to the first parent but are\nTREESAME to a later parent. This mode is helpful for showing\nthe merge commits that \"first introduced\" a change to a branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "“tag already exists in the remote\" error after recreating the git tag\nI get the following error after I run the steps below:\nTo [email protected]:username/repo-name.git\n ! [rejected] dev -> dev (already exists)\nerror: failed to push some refs to '[email protected]:username/repo-name.git'\nhint: Updates were rejected because the tag already exists in the remote.\n\n\nCreated the repository\nCloned the repo on the local machine.\nModified the README file, commited the changes and pushed the commit.\nCreated tag dev: git tag dev\nPushed tags: git push --tags\nModified the README file, commited the changes and pushed the commit.\nDeleted tag dev , created it again and pushed tags:\ngit tag -d dev\ngit tag dev\ngit push --tags\n\n\nWhy is this happening?\nI am on Mac. My friends that use Linux (Ubuntu) don't have this problem. I know that I can use git push --tags -f to force the tag update, but this is dangerous (e.g. rewriting a commit made by mistake only in the tag, not in the branch)." }, { "role": "assistant", "content": "Edit, 24 Nov 2016: this answer is apparently popular, so I am adding a note here. If you replace a tag on a central server, anyone who has the old tag—any clone of that central-server repository that already has the tag—could retain its old tag. So while this tells you how to do it, be really sure you want to do it. You'll need to get everyone who already has the \"wrong\" tag to delete their \"wrong tag\" and replace it with the new \"right tag\".\nTesting in Git 2.10/2.11 shows that retaining the old tag is the default behavior for clients running git fetch, and updating is the default behavior for clients running git fetch --tags.\n(Original answer follows.)\n\nWhen you ask to push tags, git push --tags sends (along with any commits and other objects needed and any other ref updates from the push settings) to the remote an update request of the form new-sha1 refs/tags/name. (Well, it sends however many: one of those for each tag.)\nThe update request is modified by the remote to add an old-sha1 (or again, one for each tag), then delivered to the pre-receive and/or update hooks (whichever hooks exist on the remote). Those hooks can decide whether to allow or reject the tag create/delete/update.\nThe old-sha1 value is the all-zeros \"null\" SHA-1 if the tag is being created. The new-sha1 is the null SHA-1 if the tag is being deleted. Otherwise both SHA-1 values are real, valid values.\nEven with no hooks, there's a sort of \"built-in hook\" that is also run: the remote will refuse to move a tag unless you use the \"force\" flag (though the \"built-in hook\" is always OK with both \"add\" and \"delete\"). The rejection message you're seeing is coming from this built-in hook. (Incidentally, this same built-in hook also rejects branch updates that are not fast-forwards.)1\nBut—here's one of the keys to understanding what's going on—the git push step has no idea whether the remote has that tag now, and if so, what SHA-1 value it has. It only says \"here's my complete list of tags, along with their SHA-1 values\". The remote compares the values and if there are additions and/or changes, runs the hooks on those. (For tags that are the same, it does nothing at all. For tags you don't have that they do, it also does nothing!)\nIf you delete the tag locally, then push, your push simply does not transfer the tag. The remote assumes no change should be made.\nIf you delete the tag locally, then create it pointing to a new place, then push, your push transfers the tag, and the remote sees this as a tag-change and rejects the change, unless it's a force-push.\nThus, you have two options:\n\ndo a force-push, or\ndelete the tag on the remote.\n\nThe latter is possible via git push2 even though deleting the tag locally and pushing has no effect. Assuming the name of the remote is origin, and the tag you want it to delete is dev:\ngit push origin :refs/tags/dev\n\nThis asks the remote to delete the tag. The presence or absence of the tag dev in your local repository is irrelevant; this kind of push, with :remoteref as a refspec, is a pure-delete push.\nThe remote may or may not allow tag deletion (depending on any extra hooks added). If it allows the deletion, then the tag will be gone, and a second git push --tags, when you have a local dev tag pointing to some commit or annotated tag repo object, send your new dev tag. On the remote, dev will now be a newly created tag, so the remote will probably allow the push (again this depends on any extra hooks added).\nThe force-push is simpler. If you want to be sure not to update anything other than the tag, just tell git push to push only that one refspec:\ngit push --force origin refs/tags/dev:refs/tags/dev\n\n(note: you don't need --tags if you're explicitly pushing just one tag ref-spec).\n\n1Of course, the reason for this built-in hook is to help enforce the behavior that other users of that same remote-repo expect: that branches are not rewound, and tags do not move. If you force-push, you should let the other users know you are doing this, so that they can correct for it. Note that \"tags don't move at all\" is newly enforced by Git 1.8.2; previous versions would allow the tag to \"move forward\" in the commit graph, much like branch names. See the git 1.8.2 release notes.\n2It's trivial if you can log in on the remote. Just go to the Git repository there and run git tag -d dev. Note that either way—deleting the tag on the remote, or using git push to delete it—there's a period of time when anyone who accesses the remote will find that the dev tag is missing. (They will continue to have their own old tag, if they already have it, and they might even push their old tag back up before you can push the new one.)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub relative link in Markdown file\n\nIs there a way to create a URL anchor, <a>, link from within a Markdown file, to another file within the same repository and branch (aka a link relative to the current branch)?\nFor example, in the master branch I have a README.md file, which I would like do something like:\n# My Project\nis really really cool. My Project has a subdir named myLib, see below.\n\n## myLib documentation\nsee documentation [here](myLib/README.md)\n\nThis would allow me to link from one .md to another within the same branch and not have to worry about which branch I'm in (avoid having to do an absolute URL that includes the github.com branch name).\nHere is a working example of what I mean:\n\nGOTO http://github.com/rynop/testRel, link does not work.\nGOTO http://github.com/rynop/testRel/blob/master/README.md, link works.\n\nThis is expected because at this point the starting URL is in the branch. Now how do I get it to pick up the current branch in the README.md at the root of the repository?\nUpdate: I opened an issue against GitHub for this feature request." }, { "role": "assistant", "content": "Update 30th, January 2013, 16 months later:\nGitHub Blog Post Relative links in markup files:\n\nStarting today, GitHub supports relative links in markup files.\nNow you can link directly between different documentation files, whether you view the documentation on GitHub itself, or locally, using a different markup renderer.\nYou want examples of link definitions and how they work? Here's some Markdown for you.\nInstead of an absolute link:\n[a link](https://github.com/user/repo/blob/branch/other_file.md)\n\n…you can use a relative link:\n[a relative link](other_file.md)\n[a relative link](path%20with%20spaces/other_file.md)\n\nand we'll make sure it gets linked to user/repo/blob/branch/other_file.md.\nIf you were using a workaround like [a workaround link](repo/blob/master/other_file.md), you'll have to update your documentation to use the new syntax.\nThis also means your documentation can now easily stand on its own, without always pointing to GitHub.\n\nMarcono1234 adds in the comments\n\nAlso useful: When the link starts with a /, it is relative to the root of the repository (regardless of whether the markdown file is nested in subdirectories)\n\n\nUpdate December 20th, 2011:\nThe GitHub markup issue 84 is currently closed by technoweenie, with the comment:\n\nWe tried adding a <base> tag for this, but it causes problems with other relative links on the site.\n\n\nOctober 12th, 2011:\nIf you look at the raw source of the README.md of Markdown itself(!), relative paths don't seem to be supported.\nYou will find references like:\n[r2h]: http://github.com/github/markup/tree/master/lib/github/commands/rest2html\n[r2hc]: http://github.com/github/markup/tree/master/lib/github/markups.rb#L13\n\n\nAs noted in InvisibleWolf's answer, if the target link is a directory and it has space, then you need to use %20 for each space." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I view all the git repositories on my machine?\nIs there a way in which I can see all the git repositories that exist on my machine? Any command for that?" }, { "role": "assistant", "content": "If you are in Linux find / -name \".git\", otherwise there is no way, they are standard directories, just use your OS file/folder find program to find .git named folders." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-mergetool - Run merge conflict resolution tools to resolve merge conflicts mergetool.hideResolved" }, { "role": "assistant", "content": "During a merge, Git will automatically resolve as many conflicts as\npossible and write the MERGED file containing conflict markers around\nany conflicts that it cannot resolve; LOCAL and REMOTE normally\nrepresent the versions of the file from before Git’s conflict\nresolution. This flag causes LOCAL and REMOTE to be overwritten so\nthat only the unresolved conflicts are presented to the merge tool. Can\nbe configured per-tool via the mergetool.<tool>.hideResolved configuration variable. Defaults to false ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git" }, { "role": "assistant", "content": "CAVEATS For the sake of simplicity and interoperating with Subversion,\nit is recommended that all git svn users clone, fetch and dcommit\ndirectly from the SVN server, and avoid all git clone / pull / merge / push operations between Git repositories and branches. The recommended\nmethod of exchanging code between Git branches and users is git format-patch and git am , or just 'dcommit’ing to the SVN repository. Running git merge or git pull is NOT recommended on a branch you\nplan to dcommit from because Subversion users cannot see any\nmerges you’ve made. Furthermore, if you merge or pull from a Git branch\nthat is a mirror of an SVN branch, dcommit may commit to the wrong\nbranch. If you do merge, note the following rule: git svn dcommit will\nattempt to commit on top of the SVN commit named in git log --grep=^git-svn-id: --first-parent -1 You must therefore ensure that the most recent commit of the branch\nyou want to dcommit to is the first parent of the merge. Chaos will\nensue otherwise, especially if the first parent is an older commit on\nthe same SVN branch. git clone does not clone branches under the refs/remotes/ hierarchy or\nany git svn metadata, or config. So repositories created and managed with\nusing git svn should use rsync for cloning, if cloning is to be done\nat all. Since dcommit uses rebase internally, any Git branches you git push to\nbefore dcommit on will require forcing an overwrite of the existing ref\non the remote repository. This is generally considered bad practice,\nsee the git-push documentation for details. Do not use the --amend option of git-commit on a change you’ve\nalready dcommitted. It is considered bad practice to --amend commits\nyou’ve already pushed to a remote repository for other users, and\ndcommit with SVN is analogous to that. When cloning an SVN repository, if none of the options for describing\nthe repository layout is used (--trunk, --tags, --branches,\n--stdlayout), git svn clone will create a Git repository with\ncompletely linear history, where branches and tags appear as separate\ndirectories in the working copy. While this is the easiest way to get a\ncopy of a complete repository, for projects with many branches it will\nlead to a working copy many times larger than just the trunk. Thus for\nprojects using the standard directory structure (trunk/branches/tags),\nit is recommended to clone with option --stdlayout . If the project\nuses a non-standard structure, and/or if branches and tags are not\nrequired, it is easiest to only clone one directory (typically trunk),\nwithout giving any repository layout options. If the full history with\nbranches and tags is required, the options --trunk / --branches / --tags must be used. When using multiple --branches or --tags, git svn does not automatically\nhandle name collisions (for example, if two branches from different paths have\nthe same name, or if a branch and a tag have the same name). In these cases,\nuse init to set up your Git repository then, before your first fetch , edit\nthe $GIT_DIR/config file so that the branches and tags are associated\nwith different name spaces. For example: branches = stable/*:refs/remotes/svn/stable/*\nbranches = debug/*:refs/remotes/svn/debug/*" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-check-ignore" }, { "role": "assistant", "content": "Debug gitignore / exclude files" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to remove cached credentials from Git?\nI ran:\n$ git config credential.helper store\n\nAnd then:\n$ git push origin master\n\nAfter pushing, I entered my credentials and they were saved.\nI read that they are stored in plaintext, and so now I want to remove my credentials from being saved and entered by default.\nHow can I do this?" }, { "role": "assistant", "content": "Run the following command in the terminal to remove your credentials stored in the cache \ngit config --global --unset credential.helper" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_COMMON_DIR" }, { "role": "assistant", "content": "If this variable is set to a path, non-worktree files that are\nnormally in $GIT_DIR will be taken from this path\ninstead. Worktree-specific files such as HEAD or index are\ntaken from $GIT_DIR. See gitrepository-layout and git-worktree for\ndetails. This variable has lower precedence than other path\nvariables such as GIT_INDEX_FILE, GIT_OBJECT_DIRECTORY…​" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Referencing current branch in github readme.md\n\nIn my github repo's readme.md file I have a Travis-CI badge. I use the following link:\nhttps://travis-ci.org/joegattnet/joegattnet_v3.png?branch=staging\n\nThe obvious problem is that the branch is hardcoded. Is it possible to use some sort of variable so that the branch is the one currently being viewed?" }, { "role": "assistant", "content": "Not that I know of.\nGitHub support confirms (through OP Joe Gatt 's comment)\n\nThe only way to do this would be to pass the link through my own service which would use the github's http referrer header to determine which branch is being referenced and then fetch the appropriate image from Travis CI\n\nI would rather make one Travis-CI badge per branch, for the reader to choose or consider the appropriate when seeing the README.md.\n\nUpdate 2016 (3 years later): while nothing has changed on the GitHub side, fedorqui reports in the workaround mentioned in \"Get Travis Shield on Github to Reflect Selected Branch Status\" by Andrie.\nSimply display all the branches and their respective TravisCI badges.\nIf you have only two or three branches, that could be enough." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs separate" }, { "role": "assistant", "content": "Show full diff with respect to each of parents.\nSeparate log entry and diff is generated for each parent." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I revert my changes to a git submodule?\nI have a git submodule (RestKit) which I have added to my repo.\nI accidentally changed some files in there and I'd like to go back to the source version. In order to do that, I tried to run \nMac:app-ios user$ git submodule update RestKit\n\nBut as you can see here, this did not work as it is still \"modified content\":\nMac:app-ios user$ git status\n...\n# modified: RestKit (modified content)\n\nEven \nMac:app-ios user$ git submodule update -f RestKit \n\ndoesn't revert locally modified files.\nHow do I reset the content of that submodule?" }, { "role": "assistant", "content": "A more fail-safe method than all previous answers:\ngit submodule deinit -f .\ngit submodule update --init\n\nThe first command completely \"unbinds\" all submodules, the second then makes a fresh checkout of them.\nIt takes longer than the other methods, but will work whatever the state of your submodules.\nIf your sub-modules have their own sub-modules, instead of second command, try:\ngit submodule update --init --recursive --checkout\n\nWhere --recursive is obvious, but --checkout prevents \"Skipping submodule ...\" (see skip details)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --ita-invisible-in-index" }, { "role": "assistant", "content": "By default entries added by \"git add -N\" appear as an existing\nempty file in \"git diff\" and a new file in \"git diff --cached\".\nThis option makes the entry appear as a new file in \"git diff\"\nand non-existent in \"git diff --cached\". This option could be\nreverted with --ita-visible-in-index . Both options are\nexperimental and could be removed in future." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "eb awscli cant deploy from git directory\n\nI'm getting started with the ElasticBeanstalk AWS CLI and I've changed some of my workflow around. Previously I deployed from a directory above my git repository (which is a clone of a private GitLab directory), and shifted things around.\nBefore it was structured like this:\n-- some_dir\n |-- .ebextensions\n | |- some_files \n |\n |-- my_git_directory\n |- .git \n |- some_files \n\nAnd when I run eb deploy:\n[some_dir] $ eb deploy\n... Everything is awesome.\n\nBut now, I've moved to try and deploy from the git directory, but things aren't working:\n-- some_dir\n |-- my_git_directory\n |-- .ebextensions\n | |- some_files \n |- .git \n |- some_files \n\n[some_dir/my_git_directory] $ eb deploy\n... Everything sucks.\nERROR: An error occurred while handling git command.\nError code: 128 Error: fatal: Not a git repository (or any of the parent directories): .git\n\nNow its all busted, and deploy no longer works. I've tried adding a branch and deploying a staged version:\n$ eb branch\nusage: eb (sub-commands ...) [options ...] {arguments ...}\neb: error: unrecognized arguments: branch\n\n$ eb deploy\nERROR: This branch does not have a default environment. \nYou must either specify an environment by typing \"deploy my-env-name\" or set a default environment by typing \"eb use my-env-name\".\n$ eb use django-env2\n\n$ eb deploy --staged\n... Nope, still busted" }, { "role": "assistant", "content": "So I got it solved and it is surprisingly basic, but it might help others.\nIf you move where you are deploying from you need to re-initialise something (not sure what), and it was fixed by running:\neb init\n\nThen everything worked fine again." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to fix .vscode tracking in gitignore\n\nI'm having trouble using .gitignore with my .vscode folder in my repository.\nI added a rule in my .gitignore to ignore my entire .vscode/ folder:\n# Visual Studio Code # \n.vscode/* \n.vscode/settings.json\n!.vscode/settings.json \n!.vscode/tasks.json \n!.vscode/launch.json \n!.vscode/extensions.json \n.history.vscode/settings.json\n\nDespite this, .vscode is still being tracked by my local git repository. I've tried a variety of different solutions including using git filter-branch to remove this folder from my git history and git rm --cached .vscode to clear my cache and re-commit my changes, but none of these solutions prevents the .vscode folder from being tracked by git.\nWhen I run git status I keep getting this result:\nOn branch master\nYour branch is up to date with 'origin/master'.\n\nUntracked files:\n (use \"git add <file>...\" to include in what will be committed)\n\n .vscode/\n\nnothing added to commit but untracked files present (use \"git add\" to track)\n\nSo far, I've worked around this by manually excluding this folder when I git add my changes.\nWhy is .vscode/ still being shown as untracked? If I were to git add . and git commit this, it would add this folder to my git history and eventually to my remote repository when I git push. I don't want this behavior to occur." }, { "role": "assistant", "content": "Had similar problem, turned out the files were added to my cache. Clearing it with below command worked.\ngit rm --cached .vscode/settings.json\n\nReference to the issue on github where I found the solution." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I merge multiple branches into master?\nC---D =>b1\n / \n / E---F =>b2\n | / \n A--B =======> master\n | \\\n \\ G---H =>b3\n \\ \n I---J =>b4\n\nI want to merge b1,b2,b3,b4 into master, is it possible merge at once?\nsomething like:\ngit checkout master\ngit merge b1 b2 b3 b4" }, { "role": "assistant", "content": "Git's merge command supports multiple merging strategies. There are two strategies that can merge more than two branches at a time.\nSee also this question for a less formal description of each one.\noctopus\n\nThis resolves cases with more than two\n heads, but refuses to do a complex merge that needs manual resolution.\n It is primarily meant to be used for bundling topic branch heads\n together. This is the default merge strategy when pulling or merging\n more than one branch. \n\nThe last statement implies that if you do git merge branch1 branch2 ..., it'll use the octopus strategy.\nours\n\nThis resolves any number of heads, but the resulting tree of the merge is always that of the current branch head, effectively ignoring\n all changes from all other branches. It is meant to be used to\n supersede old development history of side branches.\n\nSee this question for a use case example." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gist: How are images uploaded to a gist?\nHere is the image file:\nhttps://gist.github.com/mbostock/5503544#file-thumbnail-png\nI tried to drag-and-drop the image file in the edit mode of a gist. That didn't seem to work in Chrome and FireFox.\nUpdate: After back and forth emails with GitHub, this feature (drag-and-drop binary files, including images) isn't supported." }, { "role": "assistant", "content": "With a little creativity you can achieve this faster than cloning. To drag/drop:\n\nCreate the Gist\nDrag an image into the comment field below. This will auto-upload your image file to https://user-images.githubusercontent.com and insert markdown code in the comment field to display the image.\nCopy this markdown code to your gist\n\nNote: It is not required that you submit the comment.\nLive example" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-branch - List, create, or delete branches -c --copy" }, { "role": "assistant", "content": "Copy a branch, together with its config and reflog." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-merge - Join two or more development histories together merge.<driver>.name" }, { "role": "assistant", "content": "Defines a human-readable name for a custom low-level\nmerge driver. See gitattributes for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What does \"Git push non-fast-forward updates were rejected\" mean?\nI'm using Git to manage my two computers and my development. I'm trying to commit changes to GitHub, and I got this error:\n\nFailed to push some refs to <repo>. To prevent you from losing history, non-fast-forward updates were rejected. Merge remote changes before pushing again.\n\nWhat could be causing this, and how can I fix this?\nEDIT:\nPulling the repo returns the following:\n\n*branch master->master (non-fast-forward)\nAlready-up-to-date\n\nPushing still gives me the aforementioned error." }, { "role": "assistant", "content": "GitHub has a nice section called \"Dealing with “non-fast-forward” errors\"\n\nThis error can be a bit overwhelming at first, do not fear.\nSimply put, git cannot make the change on the remote without losing commits, so it refuses the push.\n Usually this is caused by another user pushing to the same branch. You can remedy this by fetching and merging the remote branch, or using pull to perform both at once.\nIn other cases this error is a result of destructive changes made locally by using commands like git commit --amend or git rebase.\n While you can override the remote by adding --force to the push command, you should only do so if you are absolutely certain this is what you want to do.\n Force-pushes can cause issues for other users that have fetched the remote branch, and is considered bad practice. When in doubt, don’t force-push.\n\n\nGit cannot make changes on the remote like a fast-forward merge, which a Visual Git Reference illustrates like:\n\nThis is not exactly your case, but helps to see what \"fast-forward\" is (where the HEAD of a branch is simply moved to a new more recent commit).\n\nThe \"branch master->master (non-fast-forward) Already-up-to-date\" is usually for local branches which don't track their remote counter-part.\nSee for instance this SO question \"git pull says up-to-date but git push rejects non-fast forward\".\nOr the two branches are connected, but in disagreement with their respective history:\nSee \"Never-ending GIT story - what am I doing wrong here?\"\n\nThis means that your subversion branch and your remote git master branch do not agree on something.\n Some change was pushed/committed to one that is not in the other.\n Fire up gitk --all, and it should give you a clue as to what went wrong - look for \"forks\" in the history." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git: difference between \"branchname\" and \"refs/heads/branchname\"\nBest to be explained at an example: I am on branch 0.58 of repository and this his how I pull:\ngit pull origin 0.58\n\nWhen I just call \"git pull\", I get:\nip238:openlierox az$ git pull\nYou asked me to pull without telling me which branch you\nwant to merge with, and 'branch.0.58.merge' in\nyour configuration file does not tell me either. Please\nname which branch you want to merge on the command line and\ntry again (e.g. 'git pull <repository> <refspec>').\nSee git-pull(1) for details on the refspec.\n\nIf you often merge with the same branch, you may want to\nconfigure the following variables in your configuration\nfile:\n\n branch.0.58.remote = <nickname>\n branch.0.58.merge = <remote-ref>\n remote.<nickname>.url = <url>\n remote.<nickname>.fetch = <refspec>\n\nSee git-config(1) for details.\n\nSeems I probably forgot some option (--track ?) when I checked that branch out. Anyway, I have set this now:\ngit config branch.0.58.merge 0.58\ngit config branch.0.58.remote origin\n\nAnd this seems to work. Then, just because of interest, I took a look at some other branch about these setting:\nip238:openlierox az$ git config branch.0.57.merge\nrefs/heads/0.57\nip238:openlierox az$ git config branch.0.57.remote\norigin\n\nI was wondering now, is there a difference between \"0.58\" or should I specify \"refs/heads/0.58\"?\nWhat is the difference exactly?" }, { "role": "assistant", "content": "A ref is anything pointing to a commit, for example, branches (heads), tags, and remote branches. You should see heads, remotes, and tags in your .git/refs directory, assuming you have all three types of refs in your repository.\nrefs/heads/0.58 specifies a branch named 0.58. If you don't specify what namespace the ref is in, git will look in the default ones. This makes using only 0.58 conceivably ambiguous - you could have both a branch and a tag named 0.58." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-column" }, { "role": "assistant", "content": "Display data in columns" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitrevisions - Specifying revisions and ranges for Git <rev>^-<n> , e.g. HEAD^-, HEAD^-2" }, { "role": "assistant", "content": "Equivalent to <rev>^<n>..<rev> , with <n> = 1 if not\ngiven." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Should ipynb checkpoints be stored in Git?\nAs the title says: I'm checking a Jupyter notebook into a GitHub repo, should I store the .ipynb_checkpoints folder in GitHub too, or are they best .gitignored and kept locally?\nI'm not really sure what they are for, so I don't know whether to include them or not." }, { "role": "assistant", "content": "The checkpoints are similar files as the original notebooks but are only updated on a manual save. The original notebooks are updated with autosave and when manually saving (thanks @Thomas K). \nThe question to you is if you want to share your manual saves with your collaborators. I prefer not to share those because git already provides the functionality to go back to an older version. \nAlso, I use https://www.gitignore.io/ to create .gitignore files and according to them the checkpoints are temporary data." } ]