messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Changing \"git status\" output colors in Posh-Git\nIn Posh-Git, when I run \"git status\" in a repository, the colors for changes and untracked files are dark red, when I have tried to configure them to be \"normal\" red. I want to do this because I have a console with a dark background, so dark red is difficult to read.\nI searched around, and there seem to be two configuration changes which I needed to make:\n\nChange \"WorkingForegroundColor\" and \"UntrackedForegroundColor\" from \"DarkRed\" to \"Red\" in $GitPromptSettings.\nChange \"color.status.changed\" and \"color.status.untracked\" to red in git config.\n\nFrom my reading, that's all I should need to do, and yet the results of \"git status\" remain dark red.\nHere's a summary, to prove I set them as I claimed, and maybe someone can spot the error:" }, { "role": "assistant", "content": "The output of git status is controlled by your .gitconfig file. The default for changed and untracked files is a dim Red but you likely want Red Bold which is the bright (default) red you have in the prompt.\nAdd the following to your .gitconfig file:\n[color]\n ui = true\n[color \"status\"]\n changed = red bold\n untracked = red bold\n added = green bold\n\nFor anyone else referencing this in the future, the accepted colours are normal, black, red, green, yellow, blue, magenta, cyan, and white as well a single optional modifier bold, dim, ul, blink, or reverse. If two colours are given the first is the foreground, and the second is the background." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %T" }, { "role": "assistant", "content": "tree hash" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-grep - Print lines matching a pattern -B <num> --before-context <num>" }, { "role": "assistant", "content": "Show <num> leading lines, and place a line containing -- between contiguous groups of matches." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-send-email - Send a collection of patches as emails --relogin-delay=<int>" }, { "role": "assistant", "content": "Waiting $<int> seconds before reconnecting to SMTP server. Used together\nwith --batch-size option. Defaults to the sendemail.smtpReloginDelay configuration variable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GIT push whines about untrusted X11 forwarding setup failed\nI'm new to both git and OSX, coming from Ubuntu and svn.\nWhen I do a \"git push\" from the OSX terminal shell, I get the following warning:\nfolklore$ git push origin master\nWarning: untrusted X11 forwarding setup failed: xauth key data not generated\nWarning: No xauth data; using fake authentication data for X11 forwarding.\nCounting objects: 7, done.\n\nIt seems to be working fine, its just a warning. But I dont' understand it. Why is there any X11 in play here?\nI've checked my .ssh/ keys and they are properly 600.\nI guess I could just keep ignoring the warning, but I'd rather clean it up. And perhaps learn a bit." }, { "role": "assistant", "content": "This is an ssh issue, not a git issue. What you are seeing is not a git whine, it's a valid warning from your ssh client. You should ensure that your ssh config doesn't attempt X11 forwarding by default (git doesn't need it), or at least turn it off for the host you are connecting to.\nIn your ~/.ssh/config try:\nForwardX11 no\n\neither in the host specific section or globally." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to make git merge handle uncommitted changes to my working tree?\nA co-worker and I are both working on the master branch at the moment. I have some code in my working tree that I don't want to commit (debugging statements and the like). Now if he commits changes to some of those same files, I can't merge them:\n$ git merge origin/master\nUpdating 1b8c5c6..eb44c23\nerror: Entry 'blah.java' not uptodate. Cannot merge.\n\nComing from a subversion background, I'm used to having my working tree automatically merged when I pull changes from the repository and if there are conflicts, I resolve them manually.\nThe quickest way I have found to do this in git is:\n$ git stash\n$ git merge origin/master\n$ git stash pop\n\nEssentially, removing my uncommitted changes, doing the merge and then re-applying the changes. How can I tell merge to automatically merge my working tree with the changes I'm trying to pull in?" }, { "role": "assistant", "content": "Forget everything you ever learned from subversion.\nAlways commit before introducing external changes.\nImagine you had a mostly-working tree -- maybe not perfect, but you're making some progress. Then you go to do a merge and the code you're bringing in just wreaked havoc (was buggy itself, too many conflicts to deal with, etc...). Wouldn't it be nice if you could just undo that?\nIf you commit, you can. If you don't, you're just going to suffer.\nRemember: What you commit doesn't have to be what you push, but what you don't commit you can easily lose.\nJust do the safe and easy thing and commit early and commit often." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to recover from a git push -force?\n\nHere is what happened:\nI have two remote git branches: master and feature1. For some reason I have to use git push --force for the feature1 branch, but I didn't know when I use git push --force it will also push the master branch. Then, a disaster happened, as I pushed my local master branch to the remote repository.\nLuckily, my local branch is not too far away from the remote. Basically, my remote master has two pull requests merged ahead of my local master.\nSo my problem is: can I reopen the pull request and remerge? I noticed that there is commit version for merge request, so I am worried if I simply make new pull request it will mess up something? Ideally I just want to redo the merging of the two requests.\nIs there some other way to recover from this disaster? I learned the --force is a really, really bad choice. :(\nUpdate, example of what happened:\nI have following branches:\nmaster\nfeature1\norigin/master\norigin/feature1\n\nI integrate two pull requests by using the GitHub's Auto merge pull requests. Then, I didn't fetch the master branch on my local machine. Thus, I think my origin/master is two versions behind the remote master.\nThen I accidentally used git -f push, which overwrote the remote branch and now I lost the commits from the pull requests on remote repository.\nHow can I recover from it without messing up other contributors' history?" }, { "role": "assistant", "content": "When working with github, refer to GHugo's answer which gives a foolproof procedure with github. If you're on an in-house (or other non-github) installation, read on.\nYou can always restore the previously observed state of master, by resetting to the old commit and issuing another push -f. The steps involved typically look like this:\n# work on local master\ngit checkout master\n\n# reset to the previous state of origin/master, as recorded by reflog\ngit reset --hard origin/master@{1}\n\n# at this point verify that this is indeed the desired commit.\n# (if necessary, use git reflog to find the right one, and\n# git reset --hard to that one)\n\n# finally, push the master branch (and only the master branch) to the server\ngit push -f origin master\n\nNote, however, that this restores remote master to the state most recently retrieved by git fetch or equivalent. Any commits pushed by others after the last time you fetched will be lost. However, those commits will still be available in their reflogs, so they can restore them using steps like the above." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git interactive unstage part of a file or by hunks\nThere's git add -p to stage changes and git checkout -p to discard changes interactively. How can I unstage changes from index by hunks? \n(I thought that git unstage -p or git reset HEAD -p might work.)" }, { "role": "assistant", "content": "If I am not mistaken, what you want is to unstage hunks interactively? I thought git reset -p does exactly that. Its prompt message is even exactly like Unstage this hunk?\nAlso from the manual:\n\nThis means that git reset -p is the opposite of git add -p, i.e. you\n can use it to selectively reset hunks. See the “Interactive Mode”\n section of git-add(1) to learn how to operate the --patch mode." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is it possible to retroactively turn a set of commits into a branch?\nSay I have a git repository and I've been working on master, can I retroactively create a branch. For example:\nA - B - C - A1 - D - A2 - E\nI want to make it look like this:\nA - A1 - A2 \n\\ \\ \nB - C - D - E\n\nThe specific use case is when I've cherry-picked a bunch of commits into an old version branch and it needs to go into multiple older versions and I don't want to repeat the cherry-pick on all those revision.\nEssentially it's something that would have been good as a feature or topic branch in the first place but wasn't created like that." }, { "role": "assistant", "content": "If you want all the commits after revision XXX to have happened in a branch, I find this a lot easier than the other proposed methods.\n$ git branch fixes # copies master to new branch\n$ git reset --hard XXX # resets master to XXX\n\nThe commits are now only in the \"fixes\" branch.\nThis procedure is described in git's help page for reset under \"Undo a commit, making it a topic branch\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git push results in fatal: protocol error: bad line length character: This\n\nI am trying to get GitLab working on my server (running CentOS 6.5). I followed the gitlab-receipe to the line, but I just can't get it working. I am able to access the web interface, create new projects but pushing to the master branch returns the following error : \nfatal: protocol error: bad line length character: This\n\nI have done checks on the production environment, here are the results : \nChecking Environment ...\n\nGit configured for git user? ... yes\n\nChecking Environment ... Finished\n\nChecking GitLab Shell ...\n\nGitLab Shell version >= 1.7.9 ? ... OK (1.8.0)\nRepo base directory exists? ... yes\nRepo base directory is a symlink? ... no\nRepo base owned by git:git? ... yes\nRepo base access is drwxrws---? ... yes\nupdate hook up-to-date? ... yes\nupdate hooks in repos are links: ... \nASC / Wiki ... repository is empty\nRunning /home/git/gitlab-shell/bin/check\nCheck GitLab API access: OK\nCheck directories and files: \n /home/git/repositories: OK\n /home/git/.ssh/authorized_keys: OK\nTest redis-cli executable: redis-cli 2.4.10\nSend ping to redis server: PONG\ngitlab-shell self-check successful\n\nChecking GitLab Shell ... Finished\n\nChecking Sidekiq ...\n\nRunning? ... yes\nNumber of Sidekiq processes ... 1\n\nChecking Sidekiq ... Finished\n\nChecking LDAP ...\n\nLDAP is disabled in config/gitlab.yml\n\nChecking LDAP ... Finished\n\nChecking GitLab ...\n\nDatabase config exists? ... yes\nDatabase is SQLite ... no\nAll migrations up? ... yes\nGitLab config exists? ... yes\nGitLab config outdated? ... no\nLog directory writable? ... yes\nTmp directory writable? ... yes\nInit script exists? ... yes\nInit script up-to-date? ... no\n Try fixing it:\n Redownload the init script\n For more information see:\n doc/install/installation.md in section \"Install Init Script\"\n Please fix the error above and rerun the checks.\nprojects have namespace: ... \nASC / Wiki ... yes\nProjects have satellites? ... \nASC / Wiki ... can't create, repository is empty\nRedis version >= 2.0.0? ... yes\nYour git bin path is \"/usr/bin/git\"\nGit version >= 1.7.10 ? ... yes (1.8.3)\n\nChecking GitLab ... Finished\n\nFor the init script error, the receipt says \n\nDo not mind about that error if you are sure that you have downloaded\n the up-to-date\n\nso as I have downloaded the latest one, I can't really do much about it.\nI've been banging my head for the past week, and can not figure out why this error is occurring, any help would appreciated!!" }, { "role": "assistant", "content": "If anyone else has this problem, the solution is to change the login shell of the user 'git' (or whatever your user is called) to /bin/bash. This can be done via the command : usermod -s /bin/bash git (Link). The reason for changing the login shell is because the default shell for the git user is /sbin/nologin (or similar, depending on environment), which prevents the git application from logging in as the git user on the git server." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-daemon - A really simple server for Git repositories stderr" }, { "role": "assistant", "content": "Write to standard error.\nNote that if --detach is specified,\nthe process disconnects from the real standard error,\nmaking this destination effectively equivalent to none ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git push/clone to new server\nI'm just learning Git and there is something I can't work out. After creating and using a git repository locally on my Mac, can I push a copy to another server somewhere else? I am behind a firewall so unfortunately I can't run git clone from the other machine." }, { "role": "assistant", "content": "git remote add name url\ngit push name branch\n\nExample:\ngit remote add origin [email protected]:foo/bar.git\ngit push origin master\n\nSee the docs for git push -- you can set a remote as the default remote for a given branch; if you don't, the name origin is special. Just git push alone will do the same as git push origin thisbranch (for whatever branch you're on)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-bundle" }, { "role": "assistant", "content": "Move objects and refs by archive" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --name-only" }, { "role": "assistant", "content": "Show only names of changed files. The file names are often encoded in UTF-8.\nFor more information see the discussion about encoding in the git-log manual page." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc git diff --cached" }, { "role": "assistant", "content": "compares a (c)ommit and the (i)ndex;" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs -D --irreversible-delete" }, { "role": "assistant", "content": "Omit the preimage for deletes, i.e. print only the header but not\nthe diff between the preimage and /dev/null . The resulting patch\nis not meant to be applied with patch or git apply ; this is\nsolely for people who want to just concentrate on reviewing the\ntext after the change. In addition, the output obviously lacks\nenough information to apply such a patch in reverse, even manually,\nhence the name of the option. When used together with -B , omit also the preimage in the deletion part\nof a delete/create pair." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitlabCi deploy on multiple servers\n\nI use Gitlab runner and works fine for a single server. The gitlab-ci.yml is simple:\nstages:\n - test\n - deploy\n\ntest:\n stage: test\n image: php\n tags:\n - docker\n script:\n - echo \"Run tests...\"\ndeploy:\n stage: deploy\n tags:\n - shell\n script:\n - sh deploy.sh\n\nAs i said this is fine for a single server but to deploy same app on another server? I tried with same gitlab-runner config (same conf.toml) but then it was only updating one of them randomly.\nIs there somehow gitlab Ci to be triggered by more than 1 runner and deploy all of them according gitlab-ci.yml?" }, { "role": "assistant", "content": "You can register several runners (e.g. tagged serverA and serverB) from different servers and have multiple deployment jobs, each of them performed by a different runner. This is because you can set more than one tag in a job and only a runner having all the tags will be used.\nstages:\n - test\n - deploy\n\ntest:\n stage: test\n image: php\n tags:\n - docker\n script:\n - echo \"Run tests...\"\n\ndeployA:\n stage: deploy\n tags:\n - shell\n - serverA\n script:\n - sh deploy.sh\n\ndeployB:\n stage: deploy\n tags:\n - shell\n - serverB\n script:\n - sh deploy.sh\n\nHowever, take into account a situation when one of the deployment jobs fails - this would end up in you having two different versions of the code on the servers. Depending on your situation this might or might not be a problem." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %ct" }, { "role": "assistant", "content": "committer date, UNIX timestamp" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-cat-file" }, { "role": "assistant", "content": "Provide contents or details of repository objects" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab-runner with syntax error\n\nI recently used the docker image gitlab/gitlab-runner:9.1.0 in conjunction with a gitlab container to have some CI.\nAn error occurs and similar support requests recommended using a different version, so I tried with :latest and some :1.11 too.\nUnfortunately it keeps telling me this error:\nRunning with gitlab-ci-multi-runner 1.11.4 (5e7ba4a)\n on foo (02cdacdc)\nUsing Docker executor with image pretzlaw/php:7.1-apache ...\nStarting service mariadb:latest ...\nPulling docker image mariadb:latest ...\nWaiting for services to be up and running...\nPulling docker image pretzlaw/php:7.1-apache ...\nRunning on runner-02cdacdc-project-7-concurrent-0 via 9d1d33dc9212...\nFetching changes...\nHEAD is now at 7580815 QA: CI Lint\nFrom http://idgaf.example.org/foo/bar\n 7580815..affeede develop -> origin/develop\nChecking out affeede as develop...\nSkipping Git submodules setup\n[: 1: [: Syntax error: end of file unexpected\n[: 1: [: Syntax error: end of file unexpected\nERROR: Job failed: exit code 2\n\nNeither do I know how to debug this nor do I see any problem in my container or test script. This is the .gitlab-ci.yml:\nbefore_script:\n - composer install\n\ntest_7_1:\n image: pretzlaw/php:7.1-apache\n script: ls\n\nIt could be a problem of the container somewhere but I don't get it. Doing this manually (with the recent failed docker container) everything works fine:\ndocker container exec 68c7b5448a56 ls\nbin\nbuilds\n...\n\nHow do I trace back the problem?\nWhat is it all about?\nIt's for GitLab 9.1.1-ce.0." }, { "role": "assistant", "content": "As pointed out by #1550, the problem seems to be coming from the shell detection done in the bash.go file between lines 16-31 which it is injected without newlines and thus creating the syntax error you are yourself experiencing.\nSince you have a custom entrypoint in your Dockerfile and it looks like you have not passed quotes to the arguments of the exec here, that's what I think is failing and should be modified.\nChange it to\nexec \"${*}\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Web access HTML file in my Gitlab repo\n\nI want to use Gitlab to manage web-application development. Is it possible to access the html file I have created in my Gitlab repo from the browser? \nCurrently there are ssh/http url for access to the repo like:\nssh: [email protected]:balbal/web-app.git \nhttp: (ht tps://something.some.ca:balbal/web-app.git)\n\nWhen I access https from a browser it will just jump into the git repo manage UI (like show you all the commits, branches and detail files)\nWhat I want is web access to a particular html file I have created in my repo (like if there is a index.html file in a folder called 'www' in my repo). I want some URL that I can type into the browser and which will show me the index.html content. \nIs it possible for me to set up an web access to these html files?" }, { "role": "assistant", "content": "As of now, Gitlab does not support this functionality. There's a feature request for this: http://feedback.gitlab.com/forums/176466-general/suggestions/5599145-preview-render-static-html-pages-pushed-to-repos\nCurrently, if you query Gitlab for the raw html file, it sets certain HTTP headers to make it render as text/plain instead:\n$ curl -I http://my-gitlab/user/project/raw/dev/doc/_book/index.html\nHTTP/1.1 200 OK\nServer: nginx\nDate: Mon, 20 Apr 2015 13:17:48 GMT\nContent-Type: text/plain; charset=utf-8\nConnection: keep-alive\nStatus: 200 OK\nX-Frame-Options: DENY\nX-XSS-Protection: 1; mode=block\nX-Content-Type-Options: nosniff\nX-UA-Compatible: IE=edge\nContent-Disposition: inline; filename=\"index.html\"\nContent-Transfer-Encoding: binary\nCache-Control: private\nETag: \"b81191c550c47eae1ab4adf72dfd0c92\"\nSet-Cookie: request_method=HEAD; path=/\nX-Request-Id: 04ae0499-2fdf-4f89-82ab-8392a8d6a076\nX-Runtime: 0.019857" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "how to rename a repository on github? [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\nClosed 12 years ago.\n\n\n\n\nPossible Duplicate:\nChange repo name in github \n\nI got some github repos that i now need to rename, but i can't anywhere find a solution for this except deleting the repo and setting up a new one. I can't delete the repos, because there are a lot of links pointing to the current repos, which i don't want to loose. Anyone any idea on how to do this? (I already read a lot of the google results and searched the github support)." }, { "role": "assistant", "content": "I have changed the name of repositories before, and I'm doing it again right now ;-)\nEdit the name using the built-in feature under the \"Settings\" tab at the top of your GitHub repository page. Then go to your local repository and rename the remote. Like this:\n\nFirst remove it:\ngit remote rm origin\n\nthen add back the new name\ngit remote add origin [email protected]:\"yourname\"/\"projectname\".git\n\n\nIf you have recent enough git version you should use set-url command:\n git remote set-url origin [email protected]:\"yourname\"/\"projectname\".git\n\nNow it should be good to go." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Delete file from Pull Request on GitHub\nI have make pull request on git (with \"xcodeproj/project.pbxproj\" file - my fault), so can I delete this file from created Pull Request? Thanks.." }, { "role": "assistant", "content": "You probably will merge this pull request on master,\nso you can checkout just this specific file again, from master,\non your branch, just type:\ngit checkout master -- xcodeproj/project.pbxproj\ngit commit -m \"removing a file from PR\"\ngit push origin {YOUR BRANCH}" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is there a way to \"autosign\" commits in Git with a GPG key?\nIs there an easy way to make Git always signs each commit or tag that is created?\nI tried it with something like:\nalias commit = commit -S\nBut that didn't do the trick.\nI don't want to install a different program to make this happen. Is it doable with ease?\nJust a side question, maybe commits shouldn't be signed, only tags, which I never create, as I submit single commits for a project like Homebrew, etc." }, { "role": "assistant", "content": "Note: if you don't want to add -S all the time to make sure your commits are signed, there is a proposal (branch 'pu' for now, December 2013, so no guarantee it will make it to a git release) to add a config which will take care of that option for you.\nUpdate May 2014: it is in Git 2.0 (after being resend in this patch series)\nSee commit 2af2ef3 by Nicolas Vigier (boklm):\nAdd the commit.gpgsign option to sign all commits\n\nIf you want to GPG sign all your commits, you have to add the -S option all the time.\nThe commit.gpgsign config option allows to sign all commits automatically.\n\ncommit.gpgsign\n\n\nA boolean to specify whether all commits should be GPG signed.\nUse of this option when doing operations such as rebase can result in a large number of commits being signed. It may be convenient to use an agent to avoid typing your GPG passphrase several times.\n\n\nThat config is usually set per repo (you don't need to sign your private experimental local repos):\ncd /path/to/repo/needing/gpg/signature\ngit config commit.gpgsign true\n\nYou would combine that with user.signingKey used as a global setting (unique key used for all repo where you want to sign commit)\ngit config --global user.signingkey F2C7AB29!\n ^^^\n\nAs ubombi suggests in the comments (and explain in \"GPG Hardware Key and Git Signing\", based on \"How to Specify a User Id\")\n\nWhen using gpg an exclamation mark (!) may be appended to force using the specified primary or secondary key, and not to try and calculate which primary or secondary key to use.\n\nNote that Rik adds in the comments:\n\nIf you're using something like a YubiKey (as recommended) you don't need to worry about the exclamation point because the only signing key(s) you should have available for a primary key-pair are:\n\nthe primary key itself, which should have a # after it indicating it's not available,\nand the secret subkey with a > after it indicating it's a stub that points to the YubiKey as the only available signing key in its applet.\n\nOnly if you keep all your private keys available on your system (bad practice), then probably it would be a good idea to prevent auto-selection between available signing keys\n\n\nuser.signingKey was introduced in git 1.5.0 (Jan. 2007) with commit d67778e:\n\nThere shouldn't be a requirement that I use the same form of my name in\nmy git repository and my gpg key.\nFurther I might have multiple keys in my keyring, and might want to use one that doesn't match up with the address I use in commit messages.\n\n\nThis patch adds a configuration entry \"user.signingKey\" which, if present, will be passed to the \"-u\" switch for gpg, allowing the tag signing key to be overridden.\n\nThis is enforced with commit aba9119 (git 1.5.3.2) in order to catch the case where If the user has misconfigured user.signingKey in their .git/config or just doesn't have any secret keys on their keyring.\nNotes:\n\nBy convention, since git 2.4.0 March 2015, it is signingKey, not signingkey, even though the git config keys are case insensitive. That would matter only if you do git config --get-regexp, which is case sensitive, otherwise, it is only a readability convention;\nIf you want the git server to check the signature for each push, you will need git 2.2+ (Oct. 2014) at least (commit b945901), as git push --signed failed to consider the user.signingKey config value;\ngit 2.9 (June 2016) will use user.signingKey to force signing annotated tags as well as commits: commit 61c2fe0." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to use git to get just the latest revision of a project?\nI don't want to clone the full repository and I'm not going to be submitting patches. I do want to easily get new revisions in the future.\nI have tried using git clone, but this creates a copy of the entire repository (huge file size) and tracking changes makes the disk space even bigger (100mb of files now takes up over 2gb).\nIs this possible?" }, { "role": "assistant", "content": "Use git clone with the --depth option set to 1 to create a shallow clone with a history truncated to the latest commit.\nFor example:\ngit clone --depth 1 https://github.com/user/repo.git\n\nTo also initialize and update any nested submodules, also pass --recurse-submodules and to clone them shallowly, also pass --shallow-submodules.\nFor example:\ngit clone --depth 1 --recurse-submodules --shallow-submodules https://github.com/user/repo.git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-shortlog - Summarize git log output -E --extended-regexp" }, { "role": "assistant", "content": "Consider the limiting patterns to be extended regular expressions\ninstead of the default basic regular expressions." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Find out a Git branch creator\nI want to find out who created a branch.\nI am sort of able to do so with:\ngit branch -a | xargs -L 1 bash -c 'echo \"$1 `git log --pretty=format:\"%H %an\" $1^..$1`\"' _\n\nHowever, this returns the last committer per branch, not necessarily the person who created the branch." }, { "role": "assistant", "content": "List remote Git branches by author sorted by committer date:\ngit for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)' --sort=committerdate" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database emptyName" }, { "role": "assistant", "content": "(WARN) A path contains an empty name." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker gitglossary" }, { "role": "assistant", "content": "A Git Glossary" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --remotes[=<pattern>]" }, { "role": "assistant", "content": "Pretend as if all the refs in refs/remotes are listed\non the command line as <commit> . If <pattern> is given, limit\nremote-tracking branches to ones matching given shell glob.\nIf pattern lacks ? , * , or [ , /* at the end is implied." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %ai" }, { "role": "assistant", "content": "author date, ISO 8601-like format" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Fingerprint has already been taken gitlab\n\nI formatted my Windows 7 laptop and in an attempt to have git setup working again, I installed git and source tree application.\nI deleted the SSH Key from gitlab and regenerated the key using ssh-keygen. But when I try to add the SSH Key at gitlab, it throws the following exception :\nKey is invalid\nFingerprint has already been taken\nFingerprint cannot be generated\n\nBecause of this I am unable to clone the git repository from the source tree application since gitlab is unable to authenticate the SSH key.I followed queries at google groups of gitlab but none of them seem to resolve my issue. Is there any workaround or steps to get the SSH key accepted by gitlab?" }, { "role": "assistant", "content": "In my case; the public key i was trying to add was already used with 'work' Gitlab account and i received the said error upon trying to use the same key with 'personal' Gitlab account.\nSolution - Add another public key on the same machine and use that with 'personal' gitlab account (both on same machine).\nnavigate to .ssh folder in your profile (even works on windows) and run command\nssh-keygen -t rsa\n\nwhen asked for file name give another filename id_rsa_2 (or any other).\nenter for no passphrase (or otherwise).\nYou will end up making id_rsa_2 and id_rsa_2.pub\nuse the command\ncat id_rsa_2.pub\n\ncopy and save key in 'personal' Gitlab account.\ncreate a file with no extension in .ssh folder named 'config'\nput this block of configuration in your config file\nHost gitlab.com\nHostName gitlab.com\nIdentityFile C:\\Users\\<user name>\\.ssh\\id_rsa\nUser <user name>\n\n\nHost gitlab_2\nHostName gitlab.com\nIdentityFile C:\\Users\\<user name>\\.ssh\\id_rsa_2\nUser <user name>\n\nnow whenever you want to use 'personal' gitlab account simply change alias in git URLs for action to remote servers.\nfor example\ninstead of using\ngit clone git@gitlab.com:..............\nsimply use\ngit clone git@gitlab_2:...............\ndoing that would use the second configuration with gitlab.com (from 'config' file) and will use the new id_rsa_2 key pair for authentication.\nFind more about above commands on this link\nhttps://clubmate.fi/how-to-setup-and-manage-multiple-ssh-keys/" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to `git log` a tree-ish from another branch?\nLet's say I have a Git repo with branch A and branch B.\nBranch B is currently checked out (i.e. .git/HEAD contains refs/heads/B).\nNow, without checking out branch A, how to view the history (log) of path/file in branch A?\nFollowing git help rev-parse, I've attempted to use git log A:path/file, but that doesn't seem to work (outputs nothing). Why?" }, { "role": "assistant", "content": "Try this (without the angle brackets):\ngit log <branch> -- <path/to/file>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git adding files to repo\nI followed basic Git tutorial and added README file, which worked. Then I copied my project files to the same folder and tried to add them to repository by running\ngit add --all\ngit ci 'test' (my alias for commit)\ngit push origin master\n\nand nothing got pushed. \nWhat are the commands I should run to push my files to the remote repository (master)?\nI tried to commit changes and run status but it says 'nothing to commit'. It does not recognize, that I copied lots of new files to that folder..\nOK, so I type: git add . (get no response from console)\nthen type to commit, and says no changes.." }, { "role": "assistant", "content": "This is actually a multi-step process. First you'll need to add all your files to the current stage:\ngit add .\n\nYou can verify that your files will be added when you commit by checking the status of the current stage:\ngit status\n\nThe console should display a message that lists all of the files that are currently staged, like this:\n# On branch master\n#\n# Initial commit\n#\n# Changes to be committed:\n# (use \"git rm --cached <file>...\" to unstage)\n#\n# new file: README\n# new file: src/somefile.js\n#\n\nIf it all looks good then you're ready to commit. Note that the commit action only commits to your local repository. \ngit commit -m \"some message goes here\"\n\nIf you haven't connected your local repository to a remote one yet, you'll have to do that now. Assuming your remote repository is hosted on GitHub and named \"Some-Awesome-Project\", your command is going to look something like this:\ngit remote add origin [email protected]:username/Some-Awesome-Project\n\nIt's a bit confusing, but by convention we refer to the remote repository as 'origin' and the initial local repository as 'master'. When you're ready to push your commits to the remote repository (origin), you'll need to use the 'push' command:\ngit push origin master\n\nFor more information check out the tutorial on GitHub: http://learn.github.com/p/intro.html" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to tell git to use the correct identity (name and email) for a given project?\nI use my personal laptop for both work and personal projects and I would like to use my work email address for my commits at work (gitolite) and my personal email address for the rest (github).\nI read about the following solutions which are all either global or temporary:\n\ngit config --global user.email \"[email protected]\"\ngit config user.email \"[email protected]\"\ngit commit --author \"Bob <[email protected]>\"\nsetting one of the GIT_AUTHOR_EMAIL, GIT_COMMITTER_EMAIL or EMAIL environment variables\n\nOne solution is to run manually a shell function that sets my environment to work or personal, but I am pretty sure that I will often forget to switch to the correct identity resulting in committing under the wrong identity.\nIs there a way of binding a certain repository, project name, etc. to an identity (name, email)? What do people do?" }, { "role": "assistant", "content": "git config user.email \"[email protected]\"\nDoing that one inside a repo will set the configuration on THAT repo, and not globally.\nSeems like that's pretty much what you're after, unless I'm misreading you." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --color-moved[=<mode>]" }, { "role": "assistant", "content": "Moved lines of code are colored differently.\nThe <mode> defaults to no if the option is not given\nand to zebra if the option with no mode is given.\nThe mode must be one of: no Moved lines are not highlighted. default Is a synonym for zebra . This may change to a more sensible mode\nin the future. plain Any line that is added in one location and was removed\nin another location will be colored with color.diff.newMoved .\nSimilarly color.diff.oldMoved will be used for removed lines\nthat are added somewhere else in the diff. This mode picks up any\nmoved line, but it is not very useful in a review to determine\nif a block of code was moved without permutation. blocks Blocks of moved text of at least 20 alphanumeric characters\nare detected greedily. The detected blocks are\npainted using either the color.diff.{old,new}Moved color.\nAdjacent blocks cannot be told apart. zebra Blocks of moved text are detected as in blocks mode. The blocks\nare painted using either the color.diff.{old,new}Moved color or color.diff.{old,new}MovedAlternative . The change between\nthe two colors indicates that a new block was detected. dimmed-zebra Similar to zebra , but additional dimming of uninteresting parts\nof moved code is performed. The bordering lines of two adjacent\nblocks are considered interesting, the rest is uninteresting. dimmed_zebra is a deprecated synonym." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options suggestDetachingHead" }, { "role": "assistant", "content": "Shown when git-switch refuses to detach HEAD\nwithout the explicit --detach option." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Do Git tags only apply to the current branch?\nI'm currently working with a repository that has multiple branches.\nWhen I create a tag, does that tag refer to the then-current branch?\nIn other words: Whenever I create a tag, do I need to switch to the desired branch and tag inside that branch so that the tag refers to that branch at that point in time?" }, { "role": "assistant", "content": "CharlesB's answer and helmbert's answer are both helpful, but it took me a while to understand them.\nHere's another way of putting it:\n\nA tag is a pointer to a commit, and commits exist independently of branches.\n\n\nIt is important to understand that tags have no direct relationship with branches - they only ever identify a commit.\n\n\nThat commit can be pointed to from any number of branches - i.e., it can be part of the history of any number of branches - including none.\n\nTherefore, running git show <tag> to see a tag's details contains no reference to any branches, only the ID of the commit that the tag points to.\n\n\n(Commit IDs (a.k.a. object names or SHA-1 IDs) are 40-character strings composed of hex. digits that are hashes over the contents of a commit; e.g.: 6f6b5997506d48fc6267b0b60c3f0261b6afe7a2)\n\n\n\n\nBranches come into play only indirectly:\n\n\nAt the time of creating a tag, by implying the commit that the tag will point to:\n\n\nNot specifying a target for a tag defaults to the current branch's most recent commit (a.k.a. HEAD); e.g.:\n\n\ngit tag v0.1.0 # tags HEAD of *current* branch\n\nSpecifying a branch name as the tag target defaults to that branch's most recent commit; e.g.:\n\n\ngit tag v0.1.0 develop # tags HEAD of 'develop' branch\n\n(As others have noted, you can also specify a commit ID explicitly as the tag's target.)\n\nWhen using git describe to describe the current branch:\n\ngit describe [--tags] describes the current branch in terms of the commits since the most recent [possibly lightweight] tag in this branch's history.\nThus, the tag referenced by git describe may NOT reflect the most recently created tag overall." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Switching branches without touching the working tree?\nI am currently on a debug branch, and would like to switch to the master branch, without modifying the working tree (leave it the way it is in the debug branch), so I can commit some of the changes into the master branch.\nIs there a way to do this?" }, { "role": "assistant", "content": "You can do the following:\ngit checkout --detach\ngit reset --soft master\ngit checkout master\n\n\nExplanation:\nIf you are on the debug branch and would do git reset --soft master you would leave your working tree and index untouched and move to the commit master points to. The problem is, debug will be reset to this commit too. So your commits on debug are \"lost\" (well, not really, but they are not directly accessible anymore) and you are still on the debug branch.\nTo prevent git reset from moving debug but still setting your HEAD to the master commit, you first do git checkout --detach to point HEAD directly to your current commit (see man git-checkout, section \"DETACHED HEAD\"). Then you can do the reset without touching the debugbranch.\nNow HEAD is pointing directly to the commit master points to, i.e. it is still detached. You can simply git checkout master to attach to master and are now ready to commit on the master branch.\nNote that git checkout (by default and when no path is passed) only updates files that have been changed between the \"source\" and \"target\" commit and local modifications to the files in the working tree are kept. As both commits are the same in this case, no files in the working directory are touched." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Way to compare range of commits in pull request on Github?\n\nScenario, first 5 commits in a PR have already been code reviewed. Made a few more commits and want to focus in on those.\nHow can I compare a range of commits in the pull request on Github?" }, { "role": "assistant", "content": "The most convenient way I found is:\n\nOpen PR conversation\nFind the last commit that have already been reviewed and click its hash link, your URL will look like https://github.com/airbnb/javascript/pull/188/commits/2b6c524e6984f300f6c6e08e57c8dbab9497e798\nChange commits to files and add ..HEAD to the end of URL such as https://github.com/airbnb/javascript/pull/188/files/2b6c524e6984f300f6c6e08e57c8dbab9497e798..HEAD\n\nYou'll see commits range you want to review in context of the PR.\nP.S. Now GitHub provides functionality to view \"Changes since your previous code review\" but sometimes it is useful to select changes manually" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to lookup the latest git commit hash from an ant build script\nHow can I lookup the latest git commit hash from an ant build script?\nI am currently working on a new open source project which I store on github. I would like to extend my existing ANT build file to allow me to create numbered builds. I am imagining that I would launch the build with something like \"ant buildnum -Dnum=12\".\nI would like the resulting jar to have two crucial bits of information in it's manifest file:\n\nbuild.number=12\nbuild.gitcommit=\n\nI know how to create the build.number line. However, I am unsure of the best ant plumbing to lookup the latest git commit hash which is the value I want to fill in for ." }, { "role": "assistant", "content": "I wrote the following ant target for a project on github. Usage:\n\nstores version in property \"repository.version\"\nworks if no git is installed or no .git directory is present (fallback)\nother targets must depend on this target if they need the git version\nonly one git command gets executed (--always)\n\n\n<available file=\".git\" type=\"dir\" property=\"git.present\"/>\n\n<target name=\"git.revision\" description=\"Store git revision in ${repository.version}\" if=\"git.present\">\n <exec executable=\"git\" outputproperty=\"git.revision\" failifexecutionfails=\"false\" errorproperty=\"\">\n <arg value=\"describe\"/>\n <arg value=\"--tags\"/>\n <arg value=\"--always\"/>\n <arg value=\"HEAD\"/>\n </exec>\n <condition property=\"repository.version\" value=\"${git.revision}\" else=\"unknown\">\n <and>\n <isset property=\"git.revision\"/>\n <length string=\"${git.revision}\" trim=\"yes\" length=\"0\" when=\"greater\"/>\n </and>\n </condition>\n</target>\n\nIt e.g. be used for expanding the token @repository.version@ in a template file:\n<target name=\"index.html\" depends=\"git.revision\" description=\"build index.html from template\">\n <copy file=\"index.html.template\" tofile=\"index.html\" overwrite=\"yes\">\n <filterchain>\n <replacetokens>\n <token key=\"repository.version\" value=\"${repository.version}\" />\n </replacetokens>\n </filterchain>\n </copy>\n</target>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Easiest way to rename git project configured on BitBucket\nI have a project hosted on BitBucket\nCan I rename it ?\nIf not and I need to create a new repository can someone tell me the easiest way to do that and have new repo on BitBucket (one particular cause of confusion for me is whether to drive the process locally or from the bitbucket website)\nUpdate\nThankyou Rafal I've followed your instructions and it works great but Im just going to make it a little clearer for noobies like myself (on linux)\n\nIn Bitbucket project settings rename project\nvi projectname/.git/config and edit url value to reflect new bitbucket repository url\nmv projectname newprojectname" }, { "role": "assistant", "content": "You can rename the project form the settings menu of the projects on Bitbucket.\nOnce you rename it, you need to update your git config file to fetch the data from the new location\nnano .git/config\n\nChange the name of the project to the new name and save" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options" }, { "role": "assistant", "content": "BUGS When using the deprecated [section.subsection] syntax, changing a value\nwill result in adding a multi-line key instead of a change, if the subsection\nis given with at least one uppercase character. For example when the config\nlooks like [section.subsection]\n key = value1 and running git config section.Subsection.key value2 will result in [section.subsection]\n key = value1\n key = value2" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Hg: How to do a rebase like git's rebase\nIn Git I can do this:\n\n1. Start working on new feature:\n$ git co -b newfeature-123 # (a local feature development branch)\ndo a few commits (M, N, O)\n\nmaster A---B---C\n \\\nnewfeature-123 M---N---O\n\n2. Pull new changes from upstream master:\n$ git pull\n(master updated with ff-commits)\n\nmaster A---B---C---D---E---F\n \\\nnewfeature-123 M---N---O\n\n3. Rebase off master so that my new feature \ncan be developed against the latest upstream changes:\n(from newfeature-123)\n$ git rebase master\n\nmaster A---B---C---D---E---F\n \\\nnewfeature-123 M---N---O\n\n\nI want to know how to do the same thing in Mercurial, and I've scoured the web for an answer, but the best I could find was: git rebase - can hg do that\nThat link provides 2 examples:\n1. I'll admit that this: (replacing the revisions from the example with those from my own example)\n\nhg up -C F \nhg branch -f newfeature-123 \nhg transplant -a -b newfeature-123 \n\nis not too bad, except that it leaves behind the pre-rebase M-N-O as an unmerged head and creates 3 new commits M',N',O' that represent them branching off the updated mainline.\nBasically the problem is that I end up with this:\n\nmaster A---B---C---D---E---F\n \\ \\\nnewfeature-123 \\ M'---N'---O'\n \\\nnewfeature-123 M---N---O\n\nthis is not good because it leaves behind local, unwanted commits that should be dropped.\n\nThe other option from the same link is \n\n\nhg qimport -r M:O\nhg qpop -a\nhg up F\nhg branch newfeature-123\nhg qpush -a\nhg qdel -r qbase:qtip\n\nand this does result in the desired graph:\n\nmaster A---B---C---D---E---F\n \\\nnewfeature-123 M---N---O\n\nbut these commands (all 6 of them!) seem so much more complicated than \n\n$ git rebase master\n\nI want to know if this is the only equivalent in Hg or if there is some other way available that is simple like Git." }, { "role": "assistant", "content": "VonC has the answer you're looking for, the Rebase Extension. It is, however, worth spending a second or two thinking about why neither mq nor rebase are enabled by default in mercurial: because mercurial is all about indelible changesets. When I work in the manner you're describing, which is nearly daily, here's the pattern I take:\n1. Start working on a new feature:\n$ hg clone mainline-repo newfeature-123\ndo a few commits (M, N, O)\n\nmaster A---B---C\n \\\nnewfeature-123 M---N---O\n\n2. Pull new changes from upstream mainline:\n$ hg pull\n\nmaster A---B---C---D---E---F\n \\\nnewfeature-123 M---N---O\n\n3. merge master into my clone so that my new feature \ncan be developed against the latest upstream changes:\n(from newfeature-123)\n$ hg merge F\n\nmaster A---B---C---D---E---F\n \\ \\\nnewfeature-123 M---N---O---P\n\nand that's really all that's necessary. I end up with a newfeature-123 clone I can easily push back to the mainline when I'm happy with it. Most importantly, however, I never changed history. Someone can look at my csets and see what they were originally coded against and how I reacted to changes in the mainline throughout my work. Not everyone thinks that has value, but I'm a firm believer that it's the job of source control to show us not what we wished had happened, but what actually happened -- every deadend and every refactor should leave an indelible trace, and rebasing and other history editing techniques hide that.\nNow go pick VonC's answer while I put my soapbox away. :)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Getting \"fatal: Authentication failed\" -error when sending git commands in Windows 10\nAfter updating domain password, accessing git-repo is no longer possible. VS Code and Source Tree as well as Visual Studio are returning the following error message on pull, push, fetch etc..\n\nfatal: Authentication failed\n\nNormally a credentials pop-up should appear however this is not happening. Also the common recommendation is not working:\ngit config --global credential.helper wincred" }, { "role": "assistant", "content": "The password is stored in windows credential manager and needs to be updated. Open command prompt and enter the following command to view the list of stored passwords:\nrundll32.exe keymgr.dll,KRShowKeyMgr\n\nScroll down in the list until you spot the git-related entries. Click it and edit the correct password.\nVoilà!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-commit - Record changes to the repository -s --signoff --no-signoff" }, { "role": "assistant", "content": "Add a Signed-off-by trailer by the committer at the end of the commit\nlog message. The meaning of a signoff depends on the project\nto which you’re committing. For example, it may certify that\nthe committer has the rights to submit the work under the\nproject’s license or agrees to some contributor representation,\nsuch as a Developer Certificate of Origin.\n(See https://developercertificate.org for the one used by the\nLinux kernel and Git projects.) Consult the documentation or\nleadership of the project to which you’re contributing to\nunderstand how the signoffs are used in that project. The --no-signoff option can be used to countermand an earlier --signoff\noption on the command line." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the difference between \"git reset\" vs \"git rebase\"?\nI have been playing around with git (still very noob) and I wanted to know the difference between \"reset\" and \"rebase\". Is the one more powerful than the other?\nSay I wanted to delete the 3 commits in bold from the history, which one will be better to use, or should I tag it and then delete it with git tag -d <tagname>? \n\n17a64df 2012-06-21 | Hello uses style.css (HEAD, origin/style, master),\n a6792e4 2012-06-21 | Added css stylesheet\n 801e13e 2012-06-21 | Added README\n 5854339 2012-06-21 | Added index.html\n 0b1dd4c 2012-06-21 | Moved hello.html to lib\n 55649c3 2012-06-21 | Add an author/email comment\n 9b2f3ce 2012-06-21 | Added an author comment\n cdb39b0 2012-06-21 | Commit p tags with text (v1.1)\nb7b5fce 2012-06-21 | This reverts commit a6faf60631b5fbc6ee79b52a1bdac4c971b69ef8. \na6faf60 2012-06-21 | Revert \"Oops, we didn't want this commit\" \na006669 2012-06-21 | Oops, we didn't want this commit\n 262d1f7 2012-06-21 | Added HTML header (v1)\n b1846e5 2012-06-21 | Added standard HTML page tags (v1-beta)\n bf1131e 2012-06-21 | Added HI TAG \n 02b86d0 2012-06-21 | First Commit" }, { "role": "assistant", "content": "They are completely different. git-reset works with refs, on your working directory and the index, without touching any commit objects (or other objects). git-rebase on the other hand is used to rewrite previously made commit objects.\nSo if you want to rewrite the history, git-rebase is what you want. Note that you should never rewrite history that was pushed and was available to someone else, as rebasing rewrites the objects making them incompatible with the old objects, resulting in a mess for anyone else involved.\nThat being said, what you want to do is interactive rebasing. Invoke it using git rebase -i 262d1f7 and you should get a prompt looking like this:\npick 262d1f7 Added HTML header (v1)\npick a006669 Oops, we didn't want this commit\npick a6faf60 Revert \"Oops, we didn't want this commit\"\npick b7b5fce This reverts commit a6faf60631b5fbc6ee79b52a1bdac4c971b69ef8.\npick cdb39b0 Commit p tags with text (v1.1)\npick 9b2f3ce Added an author comment\npick 55649c3 Add an author/email comment\npick 0b1dd4c Moved hello.html to lib\npick 5854339 Added index.html\npick 801e13e Added README\npick a6792e4 Added css stylesheet\npick 17a64df Hello uses style.css (HEAD, origin/style, master),\n\nThere, simply delete the lines for the commits you want to remove, save and exit the editor and Git will rewrite your history. Again, don’t do this if you already pushed the changes. In general having such commits in the history is perfectly fine." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --line-prefix=<prefix>" }, { "role": "assistant", "content": "Prepend an additional prefix to every line of output." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-checkout - Switch branches or restore working tree files --ignore-other-worktrees" }, { "role": "assistant", "content": "git checkout refuses when the wanted ref is already checked\nout by another worktree. This option makes it check the ref\nout anyway. In other words, the ref can be held by more than one\nworktree." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Pushing a local branch up to GitHub\nI have Git configured so that when I run git push, it pushes changes to my GitHub repo. Until now I have only had a master branch.\nHowever, I have now created a local branch and committed to it using: \ngit checkout -b my_new_branch\ngit commit\n\nWhat I would like to do now is push my changes on this branch to GitHub. Do I just do a git push?\nWhen I first set it up I did run:\ngit config push.default current" }, { "role": "assistant", "content": "I believe you're looking for git push origin my_new_branch, assuming your origin remote is configured to hit your github repository." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %cd" }, { "role": "assistant", "content": "committer date (format respects --date= option)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git gc error: failed to run repack message\nI've just run git gc on my local repository to do some regular clean-up. Today for the first time, it failed. Here's what I've done: (Windows 7)\nC:\\Source\\TxTranslation>git gc\nCounting objects: 880, done.\nDelta compression using up to 8 threads.\nCompressing objects: 100% (540/540), done.\nWriting objects: 100% (880/880), done.\nTotal 880 (delta 504), reused 589 (delta 333)\nrm: cannot unlink `pack-18179305b5b5dbdaf059e4ded50b736ab93e220c.pack': Permission denied\n\nC:\\Source\\TxTranslation>git gc\nCounting objects: 880, done.\nDelta compression using up to 8 threads.\nCompressing objects: 100% (369/369), done.\nWriting objects: 100% (880/880), done.\nTotal 880 (delta 504), reused 880 (delta 504)\nmv: cannot move `/c/Source/TxTranslation/.git/objects/pack/pack-3002d22690e007a4205f6ecfa19d6e93296fdd78.pack' to `/c/Source/TxTranslation/.git/objects/pack/old-pack-3002d22690e007a4205f6ecfa19d6e93296fdd78.pack'\nerror: failed to run repack\n\nI can retry it as often as I want, I always get the second output again. The \"permission denied\" error above is nonsense. I believe it's a common spurious error that I see on many Windows systems these days. It may be coming from virus scanners that keep files open so that they can't be deleted immediately. That leads to all sorts of issues but apparently can't be avoided.\nIs this a problem? Is something broken? I absolutely don't understand what those message mean to me. Browsing the log with diffs still works. What could I do to fix that problem? (Luckily I have pushed everything to Github just before, so I could simply re-clone it, but I'd like to try fixing it first, in case it happens again.)" }, { "role": "assistant", "content": "As it turned out, Visual Studio had a lock on some of Git's files. Closing Visual Studio resolved the issue.\nFTR, I'm using the Git source control provider (in the last usable version 0.6.4) in VS2010. Maybe this is part of the cause." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-ls-tree - List the contents of a tree object --abbrev[=<n>]" }, { "role": "assistant", "content": "Instead of showing the full 40-byte hexadecimal object\nlines, show the shortest prefix that is at least <n> hexdigits long that uniquely refers the object.\nNon default number of digits can be specified with --abbrev=<n>." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --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": "git-archive - Create an archive of files from a named tree -<number>" }, { "role": "assistant", "content": "Specify compression level. The value will be passed to the\ncompression command configured in tar.<format>.command . See\nmanual page of the configured command for the list of supported\nlevels and the default level if this option isn’t specified." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rm - Remove files from the working tree and from the index <pathspec>…​" }, { "role": "assistant", "content": "Files to remove. A leading directory name (e.g. dir to remove dir/file1 and dir/file2 ) can be given to remove all files in\nthe directory, and recursively all sub-directories, but this\nrequires the -r option to be explicitly given. The command removes only the paths that are known to Git. File globbing matches across directory boundaries. Thus, given two\ndirectories d and d2 , there is a difference between using git rm 'd*' and git rm 'd/*' , as the former will also remove all\nof directory d2 . For more details, see the pathspec entry in gitglossary ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Download a single folder or directory from a GitHub repository\n\nHow can I download only a specific folder or directory from a remote Git repository hosted on GitHub?\nSay the example GitHub repository lives here:\n[email protected]:foobar/Test.git\n\nIts directory structure:\nTest/\n├── foo/\n│ ├── a.py\n│ └── b.py\n└── bar/\n ├── c.py\n └── d.py\n\nI want to download only the foo folder and not clone the whole Test project." }, { "role": "assistant", "content": "Update April 2021: there are a few tools created by the community that can do this for you:\n\nDownload Directory (Credits to fregante)\n\nIt has also been integrated into the excellent Refined GitHub Chrome extension as a button in the GitHub web user interface.\n\n\nGitZip (Credits to Kino—see his answer here)\nDownGit (Credits to Minhas Kamal—see his answer here)\n\nNote: if you're trying to download a large number of files, you may need to provide a token to these tools to avoid rate limiting.\n\nOriginal (manual) approach: Checking out an individual directory is not supported by Git natively, but GitHub can do this via Subversion (SVN). If you checkout your code with Subversion, GitHub will essentially convert the repository from Git to Subversion on the backend, and then serve up the requested directory.\nHere's how you can use this feature to download a specific folder. I'll use the popular JavaScript library Lodash as an example.\n\nNavigate to the folder you want to download. Let's download /test from master branch.\n\n\nModify the URL for subversion. Replace tree/master with trunk.\nhttps://github.com/lodash/lodash/tree/master/test ➜\nhttps://github.com/lodash/lodash/trunk/test\n\nDownload the folder. Go to the command line and grab the folder with SVN.\nsvn checkout https://github.com/lodash/lodash/trunk/test\n\n\n\nYou might not see any activity immediately because GitHub takes up to 30 seconds to convert larger repositories, so be patient.\n\nFull URL format explanation:\n\nIf you're interested in master branch, use trunk instead. So the full path is trunk/foldername\nIf you're interested in foo branch, use branches/foo instead. The\nfull path looks like branches/foo/foldername\nPro tip: You can use svn ls to see available tags and branches before downloading if you wish\n\n\nThat's all! GitHub supports more Subversion features as well, including support for committing and pushing changes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": ".gitlab-ci.yml after_script section: how can I tell whether the task succeeded or failed?\n\nI'm using Gitlab CI, and so have been working on a fairly complex .gitlab-ci.yml file. The file has an after_script section which runs when the main task is complete, or the main task has failed somehow. Problem: I need to do different cleanup based on whether the main task succeeded or failed, but I can't find any Gitlab CI variable that indicates the result of the main task.\nHow can I tell, inside the after_script section, whether the main task has succeeded or failed?" }, { "role": "assistant", "content": "Since gitlab-runner 13.5, you can use the CI_JOB_STATUS variable.\ntest_job:\n # ...\n after_script:\n - >\n if [ $CI_JOB_STATUS == 'success' ]; then\n echo 'This will only run on success'\n else\n echo 'This will only run when job failed or is cancelled'\n fi\n\nSee GitLab's documentation on predefined_variables: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-merge - Join two or more development histories together --allow-unrelated-histories" }, { "role": "assistant", "content": "By default, git merge command refuses to merge histories\nthat do not share a common ancestor. This option can be\nused to override this safety when merging histories of two\nprojects that started their lives independently. As that is\na very rare occasion, no configuration variable to enable\nthis by default exists and will not be added." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: How to remove file from historical commit?\nI have a commit with the ID 56f06019, for example. In that commit I have accidentally committed large file (50 MB). In another commit I added the same file but in the right size (small). Now my repo is too heavy when I clone. How do I remove that large file from the repo history to reduce the size of my repo?" }, { "role": "assistant", "content": "Chapter 9 of the Pro Git book has a section on Removing Objects.\nLet me outline the steps briefly here:\ngit filter-branch --index-filter \\\n 'git rm --cached --ignore-unmatch path/to/mylarge_50mb_file' \\\n --tag-name-filter cat -- --all\n\nLike the rebasing option described before, filter-branch is rewriting operation. If you have published history, you'll have to --force push the new refs.\nThe filter-branch approach is considerably more powerful than the rebase approach, since it \n\nallows you to work on all branches/refs at once, \nrenames any tags on the fly\noperates cleanly even if there have been several merge commits since the addition of the file\noperates cleanly even if the file was (re)added/removed several times in the history of (a) branch(es)\ndoesn't create new, unrelated commits, but rather copies them while modifying the trees associated with them. This means that stuff like signed commits, commit notes etc. are preserved\n\nfilter-branch keeps backups too, so the size of the repo won't decrease immediately unless you expire the reflogs and garbage collect:\nrm -Rf .git/refs/original # careful\ngit gc --aggressive --prune=now # danger" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc histogram" }, { "role": "assistant", "content": "This algorithm extends the patience algorithm to \"support\nlow-occurrence common elements\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %cr" }, { "role": "assistant", "content": "committer date, relative" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %x00" }, { "role": "assistant", "content": "%x followed by two hexadecimal digits is replaced with a\nbyte with the hexadecimal digits' value (we will call this\n\"literal formatting code\" in the rest of this document)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to squash all git commits into one?\nHow do you squash your entire repository down to the first commit?\nI can rebase to the first commit, but that would leave me with 2 commits.\nIs there a way to reference the commit before the first one?" }, { "role": "assistant", "content": "As of git 1.6.2, you can use git rebase --root -i\nFor each commit except the first, change pick to squash in the editor that pops up." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I migrate an SVN repository with history to a new Git repository?\nI read the Git manual, FAQ, Git - SVN crash course, etc. and they all explain this and that, but nowhere can you find a simple instruction like:\nSVN repository in: svn://myserver/path/to/svn/repos\nGit repository in: git://myserver/path/to/git/repos\ngit-do-the-magic-svn-import-with-history \\\nsvn://myserver/path/to/svn/repos \\\ngit://myserver/path/to/git/repos\n\nI don't expect it to be that simple, and I don't expect it to be a single command. But I do expect it not to try to explain anything - just to say what steps to take given this example." }, { "role": "assistant", "content": "Create a users file (i.e. users.txt) for mapping SVN users to Git:\nuser1 = First Last Name <[email protected]>\nuser2 = First Last Name <[email protected]>\n...\n\nYou can use this one-liner to build a template from your existing SVN repository:\nsvn log -q | awk -F '|' '/^r/ {gsub(/ /, \"\", $2); sub(\" $\", \"\", $2); print $2\" = \"$2\" <\"$2\">\"}' | sort -u > users.txt\n\nSVN will stop if it finds a missing SVN user, not in the file. But after that, you can update the file and pick up where you left off.\nNow pull the SVN data from the repository:\ngit svn clone --stdlayout --no-metadata --authors-file=users.txt svn://hostname/path dest_dir-tmp\n\nThis command will create a new Git repository in dest_dir-tmp and start pulling the SVN repository. Note that the \"--stdlayout\" flag implies you have the common \"trunk/, branches/, tags/\" SVN layout. If your layout differs, become familiar with --tags, --branches, --trunk options (in general git svn help).\nAll common protocols are allowed: svn://, http://, https://. The URL should target the base repository, something like http://svn.mycompany.com/myrepo/repository. The URL string must not include /trunk, /tag or /branches.\nNote that after executing this command it very often looks like the operation is \"hanging/frozen\", and it's quite normal that it can be stuck for a long time after initializing the new repository. Eventually, you will then see log messages which indicate that it's migrating.\nAlso note that if you omit the --no-metadata flag, Git will append information about the corresponding SVN revision to the commit message (i.e. git-svn-id: svn://svn.mycompany.com/myrepo/<branchname/trunk>@<RevisionNumber> <Repository UUID>)\nIf a user name is not found, update your users.txt file then:\ncd dest_dir-tmp\ngit svn fetch\n\nYou might have to repeat that last command several times, if you have a large project until all of the Subversion commits have been fetched:\ngit svn fetch\n\nWhen completed, Git will checkout the SVN trunk into a new branch. Any other branches are set up as remotes. You can view the other SVN branches with:\ngit branch -r\n\nIf you want to keep other remote branches in your repository, you want to create a local branch for each one manually. (Skip trunk/master.) If you don't do this, the branches won't get cloned in the final step.\ngit checkout -b local_branch remote_branch\n# It's OK if local_branch and remote_branch are the same names\n\nTags are imported as branches. You have to create a local branch, make a tag and delete the branch to have them as tags in Git. To do it with tag \"v1\":\ngit checkout -b tag_v1 remotes/tags/v1\ngit checkout master\ngit tag v1 tag_v1\ngit branch -D tag_v1\n\nClone your GIT-SVN repository into a clean Git repository:\ngit clone dest_dir-tmp dest_dir\nrm -rf dest_dir-tmp\ncd dest_dir\n\nThe local branches that you created earlier from remote branches will only have been copied as remote branches into the newly cloned repository. (Skip trunk/master.) For each branch you want to keep:\ngit checkout -b local_branch origin/remote_branch\n\nFinally, remove the remote from your clean Git repository that points to the now-deleted temporary repository:\ngit remote rm origin" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options minimal" }, { "role": "assistant", "content": "Spend extra time to make sure the smallest possible diff is\nproduced." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs -m" }, { "role": "assistant", "content": "Show diffs for merge commits in the default format. This is\nsimilar to --diff-merges=on , except -m will\nproduce no output unless -p is given as well." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What's the significance of the \"No newline at end of file\" log?\nWhen doing a git diff it says \"No newline at end of file\".\nWhat's the significance of the message and what's it trying to tell us?" }, { "role": "assistant", "content": "It indicates that you do not have a newline (usually \\n, aka LF or CRLF) at the end of file.\nThat is, simply speaking, the last byte (or bytes if you're on Windows) in the file is not a newline.\nThe message is displayed because otherwise there is no way to tell the difference between a file where there is a newline at the end and one where is not. Diff has to output a newline anyway, or the result would be harder to read or process automatically.\nNote that it is a good style to always put the newline as a last character, in text files, if it is allowed by the file format. Furthermore, for example, for C and C++ header files it is required by the language standard." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-submodule - Initialize, update or inspect submodules --depth" }, { "role": "assistant", "content": "This option is valid for add and update commands. Create a shallow clone with a history truncated to the specified number of revisions.\nSee git-clone" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git - easiest way to see diff with previous version if I have the sha\nA colleague of mine checked in some changes to Git, and I want to see exactly what those changes were. In other words, the diff between his check-in and its parent.\nWhat seemed logical to me was to run this command:\ngit diff shaOfHisCheckIn\n\nBut this didn't work. It appears to show the diff between that SHA and my current working copy.\nWhat's the correct command to show the diff between a given SHA and its parent?" }, { "role": "assistant", "content": "git show is your friend:\ngit show shaOfHisCheckIn" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database fsck.<msg-id>" }, { "role": "assistant", "content": "During fsck git may find issues with legacy data which\nwouldn’t be generated by current versions of git, and which\nwouldn’t be sent over the wire if transfer.fsckObjects was\nset. This feature is intended to support working with legacy\nrepositories containing such data. Setting fsck.<msg-id> will be picked up by git-fsck , but\nto accept pushes of such data set receive.fsck.<msg-id> instead, or\nto clone or fetch it set fetch.fsck.<msg-id> . The rest of the documentation discusses fsck.* for brevity, but the\nsame applies for the corresponding receive.fsck.* and fetch.fsck.* . variables. Unlike variables like color.ui and core.editor , the receive.fsck.<msg-id> and fetch.fsck.<msg-id> variables will not\nfall back on the fsck.<msg-id> configuration if they aren’t set. To\nuniformly configure the same fsck settings in different circumstances,\nall three of them must be set to the same values. When fsck.<msg-id> is set, errors can be switched to warnings and\nvice versa by configuring the fsck.<msg-id> setting where the <msg-id> is the fsck message ID and the value is one of error , warn or ignore . For convenience, fsck prefixes the error/warning\nwith the message ID, e.g. \"missingEmail: invalid author/committer\nline - missing email\" means that setting fsck.missingEmail = ignore will hide that issue. In general, it is better to enumerate existing objects with problems\nwith fsck.skipList , instead of listing the kind of breakages these\nproblematic objects share to be ignored, as doing the latter will\nallow new instances of the same breakages go unnoticed. Setting an unknown fsck.<msg-id> value will cause fsck to die, but\ndoing the same for receive.fsck.<msg-id> and fetch.fsck.<msg-id> will only cause git to warn. See the Fsck Messages section of git-fsck for supported\nvalues of <msg-id> ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Change remote repository credentials (authentication) on Intellij IDEA 14\nI recently changed my Bitbucket password for security reasons. However, IntelliJ didn't update my repository to the new credentials, so it stops me from pulling/pushing anything to my repository. I am not using any plugins for this, just the integrated VCS operations inside the IDE.\nEvery time I pull/push, this pops out:\n\nfatal: Authentication failed for 'https://momothereal:[email protected]/team/repo.git/\n\nWhere xxxxxxxxxxxx is my old password. I think changing this remote address with the correct password would fix it, though I cannot find where to do so." }, { "role": "assistant", "content": "The easiest of all the above ways is to:\n\nGo to Settings>>Appearance & Behavior>>System Settings>>Passwords\nChange the setting to not store passwords at all\nInvalidate and restart IntelliJ\nGo to Settings>>Version Control>>Git>>SSH executable: Build-in\nDo a fetch/pull operation\nEnter the password when prompted\nAgain go to Settings>>Appearance & Behavior>>System Settings>>Passwords\nThis time select store passwords on disk(protected with master password)\n\nVoila!\nNote that this will not work if your password is in your URL itself. If that is the case then you need to follow the steps given by @moleksyuk here\nYou also choose to use the credentials helper option in IntelliJ to achieve similar functionality as suggested by Ramesh here" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-mergetool - Run merge conflict resolution tools to resolve merge conflicts mergetool.writeToTemp" }, { "role": "assistant", "content": "Git writes temporary BASE , LOCAL , and REMOTE versions of\nconflicting files in the worktree by default. Git will attempt\nto use a temporary directory for these files when set true .\nDefaults to false ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Create patch or diff file from git repository and apply it to another different git repository\nI work on WordPress based project and I want to patch my project at each new release version of WP. For this, I want generate a patch between two commits or tags.\nFor example, in my repo /www/WP I do this:\n$ git patch-format com1..com2 --stdout > '~/patchs/mypatch.patch'\n\n# or\n\n$ git patch-format tag1..tag2 --stdout > '~/patchs/mypatch.patch'\n\n/www/WP git natif WordPress\n/www/myproject My git project WordPress based\nThe git apply command line doesn't work, I think because we are in different repositories.\nCan I generate a patch file without a commit, just a differential and apply it to another git repository?" }, { "role": "assistant", "content": "You can just use git diff to produce a unified diff suitable for git apply:\ngit diff tag1..tag2 > mypatch.patch\n\nYou can then apply the resulting patch with:\ngit apply mypatch.patch" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub SSH Config: \"Bad configuration option: IdentifyFile\" [closed]\n\nClosed. This question is not reproducible or was caused by typos. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\n This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.\n\n\nClosed 2 years ago.\n\n\nThe community reviewed whether to reopen this question 2 years ago and left it closed:\n\nOriginal close reason(s) were not resolved\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI'm trying to create a .ssh/config file for multiple SSH accounts (specifically for github.com). I've tried several tutorials and github help walk-throughs but nothing seems to work.\nI created a id_rsa_test and id_rsa_test.pub. I uploaded id_rsa_test.pub to github.\nI then created a ~/.ssh/config file with the following:\n# github account\nHost github.com-test github.com\n Hostname github.com\n User git \n IdentifyFile ~/.ssh/id_rsa_test\n\nand\n# github account\nHost github.com-test github.com\n Hostname github.com\n User git \n IdentifyFile ~/.ssh/id_rsa_test.pub\n\nI then try several commands. i.e.:\ngit clone git@github-test:username/my_project.git\n\ngit push\n\n...everytime I get the following error:\n/home/username/.ssh/config: line 5: Bad configuration option: IdentifyFile\n/home/username/.ssh/config: terminating, 1 bad configuration options\nfatal: The remote end hung up unexpectedly\n\nAny suggestions?" }, { "role": "assistant", "content": "It is IdentityFile with a 't', not IdentifyFile." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git is deleting an ignored file when i switch branches\nI have one branch (let's call it B) that ignores a certain file, which isn't ignored in some other branches (eg branch A). When i switch from branch B to branch A, then back to B again, the file has been deleted.\nIs this normal? I can sort of see how it would happen, in the sense that branch B thinks it's not there, and branch A thinks that it is, so when i go back to B it 'tidies it away'. But it's kind of annoying.\nAny suggestions?" }, { "role": "assistant", "content": "Since the only viable solution is to track the file 'f' at all times, you could add, only in branch B, a smudge/clean process with a gitattributes filter driver:\n\nWhen checkouting branch B:\n\nthe smudge process would change:\n\nsave the content of f in a temp file\nreplace the content of f with one fbis file (a tracked file which would contain, for branch B, the \"B content of f\")\n\nthe clean process would:\n\nsave f content (as modified in B) in fbis (fbis gets committed with f modifications in branch B)\nrestore f content (with the temp file), meaning f is not committed (ignored in B)\n\n\nYou can add, still in branch B, a custom merge driver which will protect fbis in case of merges from other branches to B:\nthe merge driver will always keep B version of fbis content, making sure the ignored file f gets back its content whenever branch B is checked-out.\nSince those drivers (filter and merge) are not committed in other branches, the file 'f' is committed in other branches with all its modifications.\nIn branch B, its content will never change, and yet the \"local modifications\" made to f are still restored whenever B is checked-out. \nIf that content restoration is not needed, you don't need to manage fbis.\nJust keep the filter driver and you will be sure that whatever modification you do to f in branch B, those changes will never be committed, effectively ignoring f content." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options http.sslCAPath" }, { "role": "assistant", "content": "Path containing files with the CA certificates to verify the peer\nwith when fetching or pushing over HTTPS. Can be overridden\nby the GIT_SSL_CAPATH environment variable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is git-svn dcommit after merging in git dangerous?\nMy motivation for trying out git-svn is the effortless merging and branching. Then I noticed that man git-svn(1) says: \n\nRunning git-merge or git-pull is NOT recommended on a branch you plan\n to dcommit from. Subversion does not represent merges in any\n reasonable or useful fashion; so users using Subversion cannot see any\n merges you've made. Furthermore, if you merge or pull from a git\n branch that is a mirror of an SVN branch, dcommit may commit to the\n wrong branch.\n\nDoes this mean I cannot create a local branch from svn/trunk (or a branch), hack away, merge back into svn/trunk, then dcommit? I understand that svn users will see the same mess that merges in svn pre 1.5.x have always been, but are there any other drawbacks? That last sentence worries me, too. Do people routinely do these kinds of things?" }, { "role": "assistant", "content": "Actually, I found an even better way with the --no-ff option on git merge.\nAll this squash technic I used before is no longer required. \nMy new workflow is now as follows: \n\nI have a \"master\" branch that is the only branch that I dcommit from and that clone the SVN repository (-s assume you have a standard SVN layout in the repository trunk/, branches/, and tags/):\ngit svn clone [-s] <svn-url>\n\nI work on a local branch \"work\" (-b creates the branch \"work\")\ngit checkout -b work\n\ncommit locally into the \"work\" branch (-s to sign-off your commit message). In the sequel, I assume you made 3 local commits\n...\n(work)$> git commit -s -m \"msg 1\"\n...\n(work)$> git commit -s -m \"msg 2\"\n...\n(work)$> git commit -s -m \"msg 3\"\n\n\nNow you want to commit onto the SVN server\n\n[Eventually] stash the modifications you don't want to see committed on the SVN server (often you commented some code in the main file just because you want to accelerate the compilation and focus on a given feature)\n(work)$> git stash\n\nrebase the master branch with the SVN repository (to update from the SVN server)\n(work)$> git checkout master\n(master)$> git svn rebase\n\ngo back to the work branch and rebase with master\n(master)$> git checkout work\n(work)$> git rebase master\n\nEnsure everything is fine using, for instance: \n(work)$> git log --graph --oneline --decorate\n\nNow it's time to merge all three commits from the \"work\" branch into \"master\" using this wonderful --no-ff option\n(work)$> git checkout master\n(master)$> git merge --no-ff work\n\nYou can notice the status of the logs: \n(master)$> git log --graph --oneline --decorate\n* 56a779b (work, master) Merge branch 'work'\n|\\ \n| * af6f7ae msg 3\n| * 8750643 msg 2\n| * 08464ae msg 1\n|/ \n* 21e20fa (git-svn) last svn commit\n\nNow you probably want to edit (amend) the last commit for your SVN dudes (otherwise they will only see a single commit with the message \"Merge branch 'work'\"\n(master)$> git commit --amend\n\nFinally commit on the SVN server\n(master)$> git svn dcommit\n\nGo back to work and eventually recover your stashed files:\n(master)$> git checkout work\n(work)$> git stash pop" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to compare two commits in BitBucket?\nI was trying to compare two commits on the same branch (master in this case) in BitBucket and did not find a good answer in any forum, so decided to try their client, SourceTree to see if installing it locally would help and it did.\nTherefore, thought it might be useful to add question and answer here." }, { "role": "assistant", "content": "BitBucket Cloud (bitbucket.org) supports commit comparison on the branch compare page:\n\nNavigate to a repo\nClick the '+' menu in the left-nav\nClick 'Compare branches and tags'\nPaste your commit hashes into the search fields in the branch/tag dropdowns\nClick 'Compare'" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How does Git(Hub) handle possible collisions from short SHAs?\nBoth Git and GitHub display short versions of SHAs -- just the first 7 characters instead of all 40 -- and both Git and GitHub support taking these short SHAs as arguments.\nE.g. git show 962a9e8\nE.g. https://github.com/joyent/node/commit/962a9e8\nGiven that the possibility space is now orders of magnitude lower, \"just\" 268 million, how do Git and GitHub protect against collisions here? And how do they handle them?" }, { "role": "assistant", "content": "These short forms are just to simplify visual recognition and to make your life easier. Git doesn't really truncate anything, internally everything will be handled with the complete value. You can use a partial SHA-1 at your convenience, though:\n\nGit is smart enough to figure out what commit you meant to type if you provide the first few characters, as long as your partial SHA-1 is at least four characters long and unambiguous — that is, only one object in the current repository begins with that partial SHA-1." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-merge - Join two or more development histories together --progress --no-progress" }, { "role": "assistant", "content": "Turn progress on/off explicitly. If neither is specified,\nprogress is shown if standard error is connected to a terminal.\nNote that not all merge strategies may support progress\nreporting." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --textconv --no-textconv" }, { "role": "assistant", "content": "Allow (or disallow) external text conversion filters to be run\nwhen comparing binary files. See gitattributes for\ndetails. Because textconv filters are typically a one-way\nconversion, the resulting diff is suitable for human\nconsumption, but cannot be applied. For this reason, textconv\nfilters are enabled by default only for git-diff and git-log , but not for git-format-patch or\ndiff plumbing commands." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to unpack all objects of a git repository?\nHow can I unpack all objects of a pack file? \nI've just cloned a remote repository, so my local repository currently doesn't contain any loose object, only a .pack and a .idx files.\nI've tried running git unpack-objects < .git/objects/pack/pack-.pack, but nothing happens. \nI'm doing something wrong? Is there any other command to do that?" }, { "role": "assistant", "content": "You need to move the pack objects outside the .git/objects/pack directory before using the command. However, the pack files need to be inside the repository.\nFor example, create a directory name SAMPLE in your project's root. Then, move the pack files to SAMPLE directory. After that, inside the repository without the pack files, use the command\ngit unpack-objects < SAMPLE/*.pack\n\nGit will generate all objects inside .git/objects directory of your repository." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Removing non-repository files with git?\nI'm writing Autotools code and in the process of development, tons of files are generated.\nIs there anyway to tell git to remove all files from a directory that are not part of the repository?" }, { "role": "assistant", "content": "You can use git-clean. This command will remove untracked files/directories. By default, it will only print what it would have removed, without actually removing them.\nGiven the -f flag to remove the files, and the -d flag to remove empty directories as well :\ngit clean -df\n\nAlso removing ignored files :\ngit clean -dfx" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_TRACE_PACKFILE" }, { "role": "assistant", "content": "Enables tracing of packfiles sent or received by a\ngiven program. Unlike other trace output, this trace is\nverbatim: no headers, and no quoting of binary data. You almost\ncertainly want to direct into a file (e.g., GIT_TRACE_PACKFILE=/tmp/my.pack ) rather than displaying it on\nthe terminal or mixing it with other trace output. Note that this is currently only implemented for the client side\nof clones and fetches." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "remove .git/index.lock': Permission denied\nI'm completely stuck as to why my git has completely locked me out. I have a laptop that I use at work and when I'm home. For both accounts I use git extensively and both are located in different paths. Today I came into work and I can't do anything, all I see is:\n/Applications/MAMP/htdocs/my_site/.git/index.lock': Permission denied\n\nFor all I care the branch I'm on can be deleted. I've tried removing the branch, checking out any other branch, removing the index.lock file (as suggested by other users on sites). I only have the terminal window open, no other possible programs using git (as far as I know and nothing noticeable in the activity window). I have rebooted the computer straight into my work account and still no luck. How can I remove this lock?" }, { "role": "assistant", "content": "I had the exact same problem wanting to commit my changes to git, and solved it this way: \n\nI needed to change the group of my .git folder and its contents:\nsudo chown -R <owner>:<group> .git\nneeded to change the permission of this folder:\nsudo chmod -R 775 .git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-status - Show the working tree status --renames --no-renames" }, { "role": "assistant", "content": "Turn on/off rename detection regardless of user configuration.\nSee also git-diff --no-renames ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Restore git submodules from .gitmodules\nI have a folder, which was a git repo. It contains some files and .gitmodules file. Now, when I do git init and then git submodule init, the latter command output is nothing. How can I help git to see submodules, defined in .gitmodules file without running git submodule add by hand again?\nUpdate:\nthis is my .gitmodules file:\n[submodule \"vim-pathogen\"]\n path = vim-pathogen\n url = git://github.com/tpope/vim-pathogen.git\n[submodule \"bundle/python-mode\"]\n path = bundle/python-mode\n url = git://github.com/klen/python-mode.git\n[submodule \"bundle/vim-fugitive\"]\n path = bundle/vim-fugitive\n url = git://github.com/tpope/vim-fugitive.git\n[submodule \"bundle/ctrlp.vim\"]\n path = bundle/ctrlp.vim\n url = git://github.com/kien/ctrlp.vim.git\n[submodule \"bundle/vim-tomorrow-theme\"]\n path = bundle/vim-tomorrow-theme\n url = git://github.com/chriskempson/vim-tomorrow-theme.git\n\nand here is listing of this dir:\ndrwxr-xr-x 4 evgeniuz 100 4096 июня 29 12:06 .\ndrwx------ 60 evgeniuz 100 4096 июня 29 11:43 ..\ndrwxr-xr-x 2 evgeniuz 100 4096 июня 29 10:03 autoload\ndrwxr-xr-x 7 evgeniuz 100 4096 июня 29 12:13 .git\n-rw-r--r-- 1 evgeniuz 100 542 июня 29 11:45 .gitmodules\n-rw-r--r-- 1 evgeniuz 100 243 июня 29 11:18 .vimrc\n\nso, definitely, it is in top level. the git directory is not changed, only git init is done" }, { "role": "assistant", "content": "git submodule init only considers submodules that already are in the index (i.e. \"staged\") for initialization. I would write a short script that parses .gitmodules, and for each url and path pair runs:\ngit submodule add <url> <path>\n\nFor example, you could use the following script:\n#!/bin/sh\n\nset -e\n\ngit config -f .gitmodules --get-regexp '^submodule\\..*\\.path$' |\n while read path_key local_path\n do\n url_key=$(echo $path_key | sed 's/\\.path/.url/')\n url=$(git config -f .gitmodules --get \"$url_key\")\n git submodule add $url $local_path\n done\n\nThis is based on how the git-submodule.sh script itself parses the .gitmodules file." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --pickaxe-regex" }, { "role": "assistant", "content": "Treat the <string> given to -S as an extended POSIX regular\nexpression to match." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Not showing as a contributor on GitHub\n\nI'm struggling to get GitHub to show my contributions to a project. It is not my repository, but other repositories I've contributed to do show up on my profile. \nI've tested contributions to both shared and private repositories work. I've pushed from other projects and everything is working as expected. The patches from the non-working project and a working one, both show the same details. Any pushes to working projects show me as a contributor on both the repository and my personal profile. \ngit config --global user.email and git config --global user.name are both correct. The repository I am committing to shows me as the author, but not on my profile. \nI'm a bit lost on what to do. Does anyone have any ideas?" }, { "role": "assistant", "content": "Github shows only the top 100 contributors for a project.\nIf there are more than 100, the other contributors beyond these top 100 are never shown.\nEven if you set a date range and there are less than 100 contributors displayed for the selected period, the list still only contains contributors who are among the all-time top 100." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Change branch base\nI've a tree like this:\n(commit 1) - master\n \\-- (commit 2) - (commit 3) - demo\n \\-- (commit 4) - (commit 5) - PRO\n\nand I have to move the PRO branch to master\n(commit 1) - master\n |-- (commit 2) - (commit 3) - demo\n \\-- (commit 4) - (commit 5) - PRO\n\nI've tried a git rebase master from PRO branch, but nothing happens.\nTo clarify: I was working in master and then I had to make a product demo (git checkout -b demo and some commits). Then, by mistake, I create another branch from demo (git checkout -b PRO and some commits) and now I need to move PRO branch to master and leave demo intact. At the end, both demo and PRO will hang from master." }, { "role": "assistant", "content": "Assuming newBase is the branch you want to move your commits onto, oldBase is the old basis for your branch, you can use --onto for that:\ngit rebase --onto newBase oldBase feature/branch\n\nGiven your case:\ngit checkout PRO # Just to be clear which branch to be on.\ngit rebase --onto master demo PRO\n\nBasically, you take all the commits from after demo up to and including PRO, and rebase them onto the master commit." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to color text in Markdown/GitLab\n\nI'm trying color text in markdown. In editor preview all looks good, but when I push it to a GitLab repository the text is not colored. How can I color text?\nIn his beard lived three <span style=\"color:red\">cardinals</span>." }, { "role": "assistant", "content": "You could try this it seems that Gitlab renders it pretty nice, hope it helps:\n$`\\textcolor{red}{\\text{your text}}`$ \n$`\\textcolor{blue}{\\text{your text}}`$ \n$`\\textcolor{green}{\\text{your text}}`$ \n\nAlso there's diff fence:\n```diff\n- RED text\n+ GREEN text\n! ORANGE text\n# GRAY text\n```" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_DEFAULT_REF_FORMAT" }, { "role": "assistant", "content": "If this variable is set, the default reference backend format for new\nrepositories will be set to this value. The default is \"files\".\nSee --ref-format in git-init ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options diff.noPrefix" }, { "role": "assistant", "content": "If set, git diff does not show any source or destination prefix." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-cat-file - Provide contents or details of repository objects --batch-all-objects" }, { "role": "assistant", "content": "Instead of reading a list of objects on stdin, perform the\nrequested batch operation on all objects in the repository and\nany alternate object stores (not just reachable objects).\nRequires --batch or --batch-check be specified. By default,\nthe objects are visited in order sorted by their hashes; see\nalso --unordered below. Objects are presented as-is, without\nrespecting the \"replace\" mechanism of git-replace ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Deploying to Heroku using git on bitbucket\n\nI want to host my source on bitbucket using git because I obviously get a free private repo and I want to host my app on heroku using the source code from bitbucket. \nCan i do it using the github client and heroku toolbelt. Will it work? Github is great but i dont want everyone seeing my code and I dont want to pay for a private repo because its a small project." }, { "role": "assistant", "content": "Deploying to Heroku should work regardless of where you host your code as the Heroku CLI adds it's own git remote for the sake of deployments. In fact, you can even git pull from Heroku, so you could technically use Heroku as a private git repository instead (though not recommended). As for using the GitHub client to connect to bitbucket, simply change the repository remote to the URL provided by bitbucket in the settings tab of the client." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to read a Git log graph\nIn the Git community book, it says\n\nAnother interesting thing you can do is visualize the commit graph with the '--graph' option, like so:\n\n$ git log --pretty=format:'%h : %s' --graph\n* 2d3acf9 : ignore errors from SIGCHLD on trap\n* 5e3ee11 : Merge branch 'master' of git://github.com/dustin/grit\n|\\\n| * 420eac9 : Added a method for getting the current branch.\n* | 30e367c : timeout code and tests\n* | 5a09431 : add timeout protection to grit\n* | e1193f8 : support for heads with slashes in them\n|/\n* d6016bc : require time for xmlschema\n\n\nIt will give a pretty nice ASCII representation of the commit history lines.\n\nHow should I read this graph? How does 420eac9 differ from the rest?" }, { "role": "assistant", "content": "The asterisks show where something was committed:\ne1193f8, 5a09431 and 30e367c were committed to the left branch (yielding a | on the right branch) whereas 420eac9 was committed to the right branch (yielding a | on the left branch). And that is how 420eac9 differs from the rest: it's the only commit to the right branch.\nFor the sake of completeness:\n\nd6016bc was the branching point\n5e3ee11 is the merging commit\n2d3acf9 is the first commit after merging" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Whitelisting and subdirectories in Git\nI have created a white-list for text files only.\n*\n!*.txt\n\nNow, I have an untracked text file in a sub-directory - sub/dir/file.txt, and this is NOT shown (it is ignored). Text files in the root directory are shown, however.\nWhy is that, and how do I fix it?" }, { "role": "assistant", "content": "If you try it that way, it'll fail, because you'll end up blacklisting the directories in your structure. \nTo solve, you want to blacklist everything that is not a directory, and is not one of the file-types you want to commit, while not blacklisting directories. \nThe .gitignore file that will do this:\n# First, ignore everything\n*\n# Now, whitelist anything that's a directory\n!*/\n# And all the file types you're interested in.\n!*.one\n!*.two\n!*.etc\n\nTested this in a three-level structure white-listing for .txt files in the presence of *.one, *.two and *.three files using a .gitignore located in the root directory of the repository - works for me. You won't have to add .gitignore files to all directories in your structure. \nInformation I used to figure out the answer came from, amongst other things, this (stackoverflow.com)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to use multiple auths/ logins for same docker registry\n\nI'm using latest gitlab and the integrated docker registry. For each project I create an individual deploy token. On the host where I want to deploy the images I do docker login https://registry.example.com/project1, enter the deploy token and get success. Pulling the image just works fine.\nOn the same host I need to deploy another image from the same registry. So I do docker login https://registry.example.com/project2, the the deploy token (which is differrent to token 1, because each project has its own deploy tokens) and get success.\nHowever looking in the .docker/config.json I can see docker just stores the domain, not the full url, and so replaces the old auth token with the new one. So I can only pull image 2 now, but not image 1 anymore.\nIs this a bug in docker? How to use more than one auth/ deploy token for the same registry?" }, { "role": "assistant", "content": "You can use the --config option of the Docker client to store multiple credentials into different paths:\ndocker --config ~/.project1 login registry.example.com -u <username> -p <deploy_token>\ndocker --config ~/.project2 login registry.example.com -u <username> -p <deploy_token> \n\nThen you are able to call Docker commands by selecting your credential:\ndocker --config ~/.project1 pull registry.example.com/project1\ndocker --config ~/.project2 pull registry.example.com/project2" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Author not defined when importing SVN repository into Git\nI'm trying to import our SVN repository into Git. When I run either this command:\ngit svn --authors-file=/path/to/authors --trunk=trunk clone https://my-repo/project .\n\nor this command:\nsvn2git https://my-repo/project --no-minimize-url -v --authors /path/to/authors\n\nBoth return this error:\nAuthor: patrick not defined in /path/to/authors file\n\n..but as far as I can tell, there is nothing wrong with my authors file:\n$ grep patrick /path/to/authors\npatrick = Patrick <[email protected]>\n\nThat error doesn't happen until it gets to revision 8700, so it must be grabbing the other author names correctly.\nWhat could be going on here? Thanks." }, { "role": "assistant", "content": "I've had the same issue when trying to execute this on Windows. It turned out that the encoding of the file that I stored the authors in was set to UTF-8 instead of UTF-8 without BOM. As the \"with BOM\" version adds some additional bytes to the beginning of the file, the first author in the list was never found." } ]