messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Stage file by its file name, regardless of directory--Git\nI have very nested directories in a project, and I'm a lazy programmer. \nLet's say I have a file name EventEditor.foo I want to stage my file regardless of whether it's in the root directory or ./src/holy/sweet/mother/of/baby/raptor/jesus/this/is/a/long/hiearchy/EventEditor.foo\nMy goal would be to be all, \"Yo Git, add EventEditor\" and bam. It stages it with me only having to type something like git add *EventEdi*. Is this possible? Or am I day dreaming?" }, { "role": "assistant", "content": "If you would like to match a glob recursively when using git add, start the glob you pass in to git add with a directory name (such as . for the current directory), and make sure that the glob is in quotes so that Git can interpret it instead of the shell:\ngit add \"./*EventEdi*\"\nA full example:\n\n$ git init git-add\nInitialized empty Git repository in /Users/lambda/tmp/stackoverflow/git-add/.git/\n$ cd git-add/\n$ mkdir -p foo/bar/baz\n$ touch foo/bar/baz/some-long-filename.txt\n$ git add \"./*long-filename*\"\n$ git status\n# On branch master\n#\n# Initial commit\n#\n# Changes to be committed:\n# (use \"git rm --cached ...\" to unstage)\n#\n# new file: foo/bar/baz/some-long-filename.txt\n#\n\nFrom the manual:\n\nFileglobs (e.g. *.c) can be given to add all matching files. Also a leading directory name (e.g. dir to add dir/file1 and dir/file2) can be given to add all files in the directory, recursively." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-tag - Create, list, delete or verify a tag object signed with GPG --create-reflog" }, { "role": "assistant", "content": "Create a reflog for the tag. To globally enable reflogs for tags, see core.logAllRefUpdates in git-config .\nThe negated form --no-create-reflog only overrides an earlier --create-reflog , but currently does not negate the setting of core.logAllRefUpdates ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Amazon cli image doesn't work with Gitlab CI\n\nI'm trying to run the aws command (to invalidate cloudfront) using official aws image and have the following config of .gitlab-ci.yml:\nstatic-invalidation:\n <<: *production-env\n stage: static_invalidation\n image: amazon/aws-cli:latest\n variables:\n AWS_ACCESS_KEY_ID: $CLOUDFRONT_AWS_ACCESS_KEY_ID\n AWS_SECRET_ACCESS_KEY: $CLOUDFRONT_AWS_SECRET_ACCESS_KEY\n script:\n - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION --invalidation-batch file://deployment/configs/inv-batch.json\n\nThe job fails with the following error:\nUsing docker image sha256:00cf4f100b03d1b26e93cce377c1311c34efa753e379cd5c6ea5d458337cbaab for amazon/aws-cli:2.2.17 with digest amazon/aws-cli@sha256:39e9898fc43f618636a2190f82b9babcdc618d054e66b49c9959b9cd23285ade ...\nusage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]\nTo see help text, you can run:\n aws help\n aws <command> help\n aws <command> <subcommand> help\naws: error: argument command: Invalid choice, valid choices are:\naccessanalyzer | acm \nacm-pca | alexaforbusiness\n...\nERROR: Job failed: exit code 252\n\nAny ideas why it's not working?\nWhen I run the command locally it works." }, { "role": "assistant", "content": "amazon/aws-cli docker has set entrypoint to aws as it's expected to be executed as\n$ docker run amazon/aws-cli cloudfront create-invalidation --distribution-id ...\n\nbut gitlab expects entry point to shell so it can then execute script commands.\nCheck out gitlab documentation: https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#available-settings-for-image\nYou will find there how to override docker image entrypoint.\n\nWorking config is:\nimage:\n name: amazon/aws-cli:2.2.18\n entrypoint: [\"\"]" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to give user level access to private GitLab repository?\n\nI have a private repository in GitLab. I have to give its access to members of my team. How can I do that using GitLab web-interface?\nI know, how to do this in GitHub, but in GitLab it's somehow different." }, { "role": "assistant", "content": "Update 2021: This answer is out of date, scroll down for the 2021 info.\nUPDATE: Gitlab has changed a bit in 2 years, so here is the updated flow.\n\nClick on the project that you want to share.\nClick on the Settings tab (the gear icon on the left).\nClick on the Members subtab.\nAdd member, and find the user if it exists on GitLab, or insert\nemail to send an invitation.\nSelect access level for the user, the possible levels are:\n\n\nGuest, can see wiki pages, view and create issues.\nReporter, can do what the guest can plus view the code.\nDeveloper, normal developer access, can develop, but cannot push or merge to procted branches by default.\nMaintainer, can do everything except managing the project.\n\n\nFor more info about the user access level refer to gitlab official help.\n(Optional) Set expiration date of the user access.\n\n\nOld instructions:\n\nClick on the project that you want to share.\nClick on members.\nAdd member, and find the user if it exists on GitLab, or insert\nemail to send an invitation." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Xcode 8 source control does not show conflicts\nAfter Xcode has updated to version 8.0 (8A218a), I have a problem pulling changes from git repository from Xcode only when some files are conflicted. We are all working on the same branch.\nAs long as there are no conflicts, everything works perfectly and I am able to commit, pull and push. \nBut I figured out that whenever we have a conflict in some of the files, Xcode is not showing conflicts anymore. It just closes the pull popup window without showing the conflict resolver window. No info or anything. I don't see the\n\nPull successful\n\nmessage. And I can't push my commit (because changes are not pulled) getting the message:\n\nMake sure all changes have been pulled from the remote repository and\n try again\n\nI have tried pulling using terminal, but the conflicted file gets messed up with git messages showing mine and other people changes in the same conflicted file along those git messages. And the files that other people were working on are now shown as my own changes/additions.\nI also tried updating git to the newest version, which is currently 2.10.0. No luck either.\nSo I end up deleting my copy and cloning the latest one and reapplying changes that i've made which is very annoying.\nDoes anyone have a solution for this?\nEDIT:\nHere is what you can do as a workaround using the terminal: \n\nOpen terminal and tell the system where Xcode utilities live: \nsudo xcode-select -switch /Applications/Xcode.app/Contents/Developer\n\nSet \"opendiff\" as the default mergetool globally: \ngit config --global merge.tool opendiff\n\nOpen Xcode mergetool manually and get rid of the conflict the usual way: \ngit mergetool\n\nSave changes, commit, push." }, { "role": "assistant", "content": "I use git in Terminal to solve this problem, mergetool is used.\nFisrt, I pull some changes, but oops, not up to date:\ngit fetch origin\ngit pull origin master\n\nFrom ssh://[email protected]:22/projectname\n * branch master -> FETCH_HEAD\nUpdating a030c3a..ee25213\nerror: Entry 'filename.c' not uptodate. Cannot merge.\n\nSo get up-to-date and try again, but have a conflict:\ngit add filename.c\ngit commit -m \"made some wild and crazy changes\"\ngit pull origin master\n\nFrom ssh://[email protected]:22/projectname\n * branch master -> FETCH_HEAD\nAuto-merging filename.c\nCONFLICT (content): Merge conflict in filename.c\nAutomatic merge failed; fix conflicts and then commit the result.\n\nSo I decide to take a look at the changes:\ngit mergetool\n\nuse mergetool to merge the conflict\nchanges...no...their changes...\ngit checkout --ours filename.c\ngit checkout --theirs filename.c\ngit add filename.c\ngit commit -m \"using theirs\"\n\nAnd then we try a final time\ngit pull origin master\n\nFrom ssh://[email protected]:22/projectname\n * branch master -> FETCH_HEAD\nAlready up-to-date.\n\nanswer from:How to resolve merge conflicts in Git?" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to remove remote origin from a Git repository\nI just did git init to initialize my folder as Git repository and then added a remote repository using git remote add origin URL. Now I want to remove this git remote add origin and add a new repository git remote add origin new-URL. How can I do it?" }, { "role": "assistant", "content": "Instead of removing and re-adding, you can do this:\ngit remote set-url origin git://new.url.here\n\nSee this question: How to change the URI (URL) for a remote Git repository?\nTo remove remote use this:\ngit remote remove origin" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Pull a certain branch from the remote server\nSay that someone created a branch xyz. How do I pull the branch xyz from the remote server (e.g. GitHub) and merge it into an existing branch xyz in my local repo?\nThe answer to\nPush branches to Git gives me the error \"! [rejected]\" and mentions \"non fast forward\"." }, { "role": "assistant", "content": "But I get an error \"! [rejected]\" and something about \"non fast forward\"\n\nThat's because Git can't merge the changes from the branches into your current master. Let's say you've checked out branch master, and you want to merge in the remote branch other-branch. When you do this:\n$ git pull origin other-branch\n\nGit is basically doing this:\n$ git fetch origin other-branch && git merge other-branch\n\nThat is, a pull is just a fetch followed by a merge. However, when pull-ing, Git will only merge other-branch if it can perform a fast-forward merge. A fast-forward merge is a merge in which the head of the branch you are trying to merge into is a direct descendent of the head of the branch you want to merge. For example, if you have this history tree, then merging other-branch would result in a fast-forward merge:\nO-O-O-O-O-O\n^ ^\nmaster other-branch\n\nHowever, this would not be a fast-forward merge:\n v master\nO-O-O\n\\\n \\-O-O-O-O\n ^ other-branch\n\nTo solve your problem, first fetch the remote branch:\n$ git fetch origin other-branch\n\nThen merge it into your current branch (I'll assume that's master), and fix any merge conflicts:\n$ git merge origin/other-branch\n# Fix merge conflicts, if they occur\n# Add merge conflict fixes\n$ git commit # And commit the merge!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order --sparse" }, { "role": "assistant", "content": "All commits in the simplified history are shown." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options http.sslCAInfo" }, { "role": "assistant", "content": "File containing the certificates to verify the peer with when\nfetching or pushing over HTTPS. Can be overridden by the GIT_SSL_CAINFO environment variable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rebase - Reapply commits on top of another base tip rebase.autoStash" }, { "role": "assistant", "content": "When set to true, automatically create a temporary stash entry\nbefore the operation begins, and apply it after the operation\nends. This means that you can run rebase on a dirty worktree.\nHowever, use with care: the final stash application after a\nsuccessful rebase might result in non-trivial conflicts.\nThis option can be overridden by the --no-autostash and --autostash options of git-rebase .\nDefaults to false." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %G?" }, { "role": "assistant", "content": "show \"G\" for a good (valid) signature,\n\"B\" for a bad signature,\n\"U\" for a good signature with unknown validity,\n\"X\" for a good signature that has expired,\n\"Y\" for a good signature made by an expired key,\n\"R\" for a good signature made by a revoked key,\n\"E\" if the signature cannot be checked (e.g. missing key)\nand \"N\" for no signature" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to auto deploy Docker Image on own server with GitLab?\n\nI am trying to Google it for few hours, but can't find it.\nI have Java/Spring application (+MySQL if it matters) and I am looking to create CI for that.\nI know what to do and how:\n\nI know that I have to move my Git repo to Gitlab.\nPush to repo will trigger CI script.\nGitlab will build my docker image into Gitlab Docker Registry.\n\nQuestion is:\nWhat do I have to do to force docker compose on my VPS to pull the new image from Gitlab and restart the server? \nI know (correct me if I am wrong) that on my VPS I should run docker-compose pull && docker-compose up inside my app folder, but I have literally no idea how to make it automatically with Gitlab?" }, { "role": "assistant", "content": "What do I have to do to force docker compose on my VPS to pull the new image from Gitlab and restart the server? \n\n@m-uu, you don't need restart the server at all, just do docker-compose up to pull new image and restart service\n\nI know (correct me if I am wrong) that on my VPS I should run docker-compose pull && docker-compose up inside my app folder, but I have literally no idea how to make it automatically with Gitlab?\n\nYes, you are on the right way. Look at my Gitlab CI configuration file, I think it doesn't difficult to change it for Java project. Just give you ideas how to build, push to your registry and deploy an image to your server. One thing you need to do is generate SSH keys and push public to server (.ssh/authorized_keys) and private to GITLAB pipeline secret variable (https://docs.gitlab.com/ee/ci/variables/#secret-variables)\ncache:\n key: \"cache\"\n paths:\n - junte-api\n\nstages:\n - build\n - build_image\n - deploy\n\nbuild:\n image: golang:1.7\n stage: build\n script:\n - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'\n - eval $(ssh-agent -s)\n - echo \"$SSH_PRIVATE_KEY\" > ~/key && chmod 600 ~/key\n - ssh-add ~/key\n - mkdir -p ~/.ssh\n - '[[ -f /.dockerenv ]] && echo -e \"Host *\\n\\tStrictHostKeyChecking no\\n\\n\" > ~/.ssh/config'\n\n - go get -u github.com/kardianos/govendor\n - mkdir -p $GOPATH/src/github.com/junte/junte-api\n - mv * $GOPATH/src/github.com/junte/junte-api\n - cd $GOPATH/src/github.com/junte/junte-api\n - govendor sync\n - go build -o junte-api\n - cd -\n - cp $GOPATH/src/github.com/junte/junte-api .\n\nbuild_image:\n image: docker:latest\n stage: build_image\n script:\n - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY\n - docker build -t $CI_REGISTRY_IMAGE .\n - docker push $CI_REGISTRY_IMAGE\n\ndeploy-dev:\n stage: deploy\n image: junte/ssh-agent\n variables:\n # should be set up at Gitlab CI env vars\n SSH_PRIVATE_KEY: $SSH_DEV_PRIVATE_KEY\n script:\n # copy docker-compose yml to server\n - scp docker-compose.dev.yml root@SERVER_IP:/home/junte/junte-api/\n # login to gitlab registry \n - ssh root@SERVER_IP docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY\n # then we cd to folder with docker-compose, run docker-compose pull to update images, and run services with `docker-compose up -d`\n - ssh root@SERVER_IP \"cd /home/junte/junte-api/ && docker-compose -f docker-compose.dev.yml pull api-dev && HOME=/home/dev docker-compose -f docker-compose.dev.yml up -d\"\n environment:\n name: dev\n only:\n - dev\n\nYou also need Gitlab runner with Docker support. How install it look at in Gitlab doc, please.\nAbout stages:\n\nbuild - just change it to build what you need\nbuild_image - very simple, just login to gitlab registry, build new image and push it to registry. Look at cache part, it need to cache files between stages and can be different for you.\ndeploy-dev - that part more about what you asked. Here first 6 commands just install ssh and create your private key file to have access to your VPS. Just copy it and add your SSH_PRIVATE_KEY to secret vars in Gitlab UI. Last 3 SSH commands more interesting for you." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Easy way to clean up un-staged deleted files in Git\nOften I move files in a git repository using my IDE or via the command line (not via git mv).\nAs a result I and end up with several unstaged files to be deleted on my next commit as below:\n# On branch master\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# modified: test.html\n#\n# Changes not staged for commit:\n# (use \"git add/rm <file>...\" to update what will be committed)\n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n# deleted: css/bootstrap.css\n# deleted: css/bootstrap.min.css\n# deleted: img/glyphicons-halflings-white.png\n# deleted: img/glyphicons-halflings.png\n# deleted: js/bootstrap.js\n# deleted: js/bootstrap.min.js\n\nI typically will select all the deleted files and edit them in a text editor to produce like:\ngit rm css/bootstrap.css\ngit rm css/bootstrap.min.css\ngit rm img/glyphicons-halflings-white.png\ngit rm img/glyphicons-halflings.png\ngit rm js/bootstrap.js\ngit rm js/bootstrap.min.js\n\nWhich I then throw back into the console.\nIs there a way to do this without having to copy/paste?" }, { "role": "assistant", "content": "If I understand your question correctly, you want to commit your deletes...that is, you want to perform the equivalent of git rm for all of the files that show up as deleted. git clean won't do this.\nYou can run git add -u:\n\nOnly match against already tracked files in the index\n rather than the working tree. That means that it will never stage new\n files, but that it will stage modified new contents of tracked files\n and that it will remove files from the index if the corresponding\n files in the working tree have been removed.\n\nThis will pick up all changes to tracked files, including deletes. So if you start with this:\n# Changes not staged for commit:\n# (use \"git add/rm <file>...\" to update what will be committed)\n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n# deleted: file2\n# deleted: file3\n# deleted: file4\n# deleted: file5\n\nRunning git add -u will get you to this:\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# deleted: file2\n# deleted: file3\n# deleted: file4\n# deleted: file5\n\nAnd a commit at this point will do the right thing." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Adding an existing android studio project to gitlab repository\n\nI have a project in android studio that i want to commit to a gitlab repository. I have a link for this repository. What do i need to do, step for step, to add this project to said repository?" }, { "role": "assistant", "content": "First you have to guarantee that this project is already a git repository on your local machine.\nYou can do this by checking if there's a folder .git in the directory. If there's none, do the following command:\n# create a git repository on the current directory\ngit init\n\nAfter that you need to make your repository point to gitlab\ngit remote add origin \"url from gitlab\"\n\nAdd files for your initial commit\ngit add -A\n\nCommit the files\ngit commit -m \"your initial commit message\"\n\nPush all the files to the remote(gitlab)\ngit push -u origin master\n\nMore information of each command can be found typing:\nman git command\n\n# example\nman git push" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Definition of \"downstream\" and \"upstream\"\nI've started playing with Git and have come across the terms \"upstream\" and \"downstream\". I've seen these before but never understood them fully. What do these terms mean in the context of SCMs (Software Configuration Management tools) and source code?" }, { "role": "assistant", "content": "In terms of source control, you're downstream when you copy (clone, checkout, etc) from a repository. Information flowed \"downstream\" to you.\nWhen you make changes, you usually want to send them back \"upstream\" so they make it into that repository so that everyone pulling from the same source is working with all the same changes. This is mostly a social issue of how everyone can coordinate their work rather than a technical requirement of source control. You want to get your changes into the main project so you're not tracking divergent lines of development.\nSometimes you'll read about package or release managers (the people, not the tool) talking about submitting changes to \"upstream\". That usually means they had to adjust the original sources so they could create a package for their system. They don't want to keep making those changes, so if they send them \"upstream\" to the original source, they shouldn't have to deal with the same issue in the next release." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %gn" }, { "role": "assistant", "content": "reflog identity name" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --inter-hunk-context=<lines>" }, { "role": "assistant", "content": "Show the context between diff hunks, up to the specified number\nof lines, thereby fusing hunks that are close to each other.\nDefaults to diff.interHunkContext or 0 if the config option\nis unset." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "RPC failed; HTTP 400 curl 22 The requested URL returned error: 400 Bad Request\n\nI am trying to push my code from an old repository to a new repository as my old repository seems to be currupted somehow\ngetting following error:\nCounting objects: 19815, done.\nCompressing objects: 100% (5264/5264), done.\nWriting objects: 100% (19815/19815), 44.91 MiB | 134.87 MiB/s, done.\nTotal 19815 (delta 14641), reused 19405 (delta 14283)\nerror: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400 Bad Request\nfatal: The remote end hung up unexpectedly\nfatal: The remote end hung up unexpectedly\nEverything up-to-date\n\nI tried git config http.postBuffer 524288000 but it did not help I even tried to do git push --force origin and git push --all but am receiving same error" }, { "role": "assistant", "content": "I faced a similar issue on my Arch Linux machine. Apparently my issue was an HTTP buffer issue.\nI got it to work by using\ngit config http.postBuffer 524288000\n\nfollowed by\ngit pull && git push\n\nThis did the trick for me and I can push to my repositories. However I wonder if there is a better way of implementing this rather than running an extra command." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rebase - Reapply commits on top of another base tip --continue" }, { "role": "assistant", "content": "Restart the rebasing process after having resolved a merge conflict." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --ignore-cr-at-eol" }, { "role": "assistant", "content": "Ignore carriage-return at the end of line when doing a comparison." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git submodules with modified and untracked content - why and how to remove it?\nthis is what my git status' result looks like:\n# On branch master\n# Changed but not updated:\n# (use \"git add <file>...\" to update what will be committed)\n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n# (commit or discard the untracked or modified content in submodules)\n#\n# modified: vim/bundle/pathogen (modified content)\n# modified: vim/bundle/sparkup (untracked content)\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nrunning git diff vim shows this:\ndiff --git a/vim/bundle/pathogen b/vim/bundle/pathogen\n--- a/vim/bundle/pathogen\n+++ b/vim/bundle/pathogen\n@@ -1 +1 @@\n-Subproject commit fcf77f5101f3e589ce006c40ad3a0432735a05cf\n+Subproject commit fcf77f5101f3e589ce006c40ad3a0432735a05cf-dirty\ndiff --git a/vim/bundle/sparkup b/vim/bundle/sparkup\n--- a/vim/bundle/sparkup\n+++ b/vim/bundle/sparkup\n@@ -1 +1 @@\n-Subproject commit 04a81b41f116a19184359a6f8685c192f5c36c70\n+Subproject commit 04a81b41f116a19184359a6f8685c192f5c36c70-dirty\n\nWhy is the one untracked, the other modified, what does the diff mean? But most important: how did it happen and how to get rid of it?" }, { "role": "assistant", "content": "One of the tracked files in vim/bundle/pathogen has been modified somehow. There is also some untracked (and unignored) content in the submodule vim/bundle/sparkup. In either case, the way to figure out what is modified / untracked is to change into the submodule directory and run git status. (In the case of untracked files in a submodule, this is frequently a build product that has not been added to .gitignore in upstream.)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects <object>…​" }, { "role": "assistant", "content": "The names of objects to show (defaults to HEAD ).\nFor a more complete list of ways to spell object names, see\n\"SPECIFYING REVISIONS\" section in gitrevisions ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can I 'git commit' a file and ignore its content changes?\nEvery developer on my team has their own local configuration. That configuration information is stored in a file called devtargets.rb which is used in our rake build tasks. I don't want developers to clobber each other's devtargets file, though. \nMy first thought was to put that file in the .gitignore list so that it is not committed to git.\nThen I started wondering: is it possible to commit the file, but ignore changes to the file? So, I would commit a default version of the file and then when a developer changes it on their local machine, git would ignore the changes and it wouldn't show up in the list of changed files when you do a git status or git commit.\nIs that possible? It would certainly be a nice feature..." }, { "role": "assistant", "content": "Sure, I do exactly this from time to time using\ngit update-index --assume-unchanged [<file> ...]\n\nTo undo and start tracking again (if you forgot what files were untracked, see this question):\ngit update-index --no-assume-unchanged [<file> ...]\n\nRelevant documentation:\n\n--[no-]assume-unchanged\nWhen this flag is specified, the object names recorded for the paths are not updated. Instead, this option sets/unsets the \"assume unchanged\" bit for the paths. When the \"assume unchanged\" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).\nGit will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.\n\nFail gracefully in this case means, if there are any changes upstream to that file (legitimate changes, etc.) when you do a pull, it will say:\n$ git pull\n…\nFrom https://github.com/x/y\n 72a914a..106a261 master -> origin/master\nUpdating 72a914a..106a261\nerror: Your local changes to the following files would be overwritten by merge:\n filename.ext\n \n\nand will refuse to merge.\nAt that point, you can overcome this by either reverting your local changes, here’s one way:\n $ git checkout filename.ext\n\nthen pull again and re-modify your local file, or could set –no-assume-unchanged and you can do normal stash and merge, etc. at that point." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab integration with SonarQube\n\nI am pretty new to Development community and specifically to DevOps practices , as a part of project we are trying to integrate SonarQube with Gitlab , did some R& D on SonarQube and Git CI ( Continuous Integration ) and look like plugin is released for Github and SonarQube whereas not for Gitlab. \nHow realistic is it to configure GitLab with SonarQube for inspecting code quality for every pull request and what will be the best practice to integrate these two piece.\nThanks" }, { "role": "assistant", "content": "you don't really need a plugin.\nmake something like this in your .gitlab-ci.yml\nstages: \n- build \nbuild_master:\n image: maven\n stage: build\n artifacts:\n paths:\n - target/*.jar\n script:\n - mvn package sonar:sonar -Dsonar.host.url=https://sonar.yourdomain.tld/ \n only:\n - master\n\nand every master push will be tested!\n(this is for a Java project...)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Move repository from one group to another in GitLab\nIs it possible to move a GitLab repository from one group to another in GitLab?\nFor example, I have https://gitlab.com/my-user/my-repo. I'd like to move it to https://gitlab.com/my-group/another-group/my-repo.\nIdeally, I'd like to keep all the issues associated with it." }, { "role": "assistant", "content": "Yes, you can move your GitLab project from one namespace to another.\nYour project -> Settings -> General -> Advanced\n\nThen, almost at the end of the list.\nTransfer project" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "'git pull origin mybranch' leaves local mybranch N commits ahead of origin. Why?\nI just observed something odd about git pull, which I don't understand.\nOn Friday, I worked on a local branch. let's call it mybranch. Before leaving the office I pushed it to origin (which is my github repo): git push origin mybranch.\nYesterday at home, I pulled mybranch to my laptop, did some more coding, and then pushed my changes back to github (origin).\nNow I'm at work again, and tried to pull the changes from yesterday to my work machine (I didn't change anything in my work place's local repo over the weekend):\ngit pull origin mybranch\n\nthat caused a fast forward merge, which is fine. I then did a git status, and it said:\n# On branch mybranch\n# Your branch is ahead of 'origin/mybranch' by 6 commits.\n#\nnothing to commit (working directory clean)\n\nHuh? How can it be 6 commits ahead when I didn't even touch it over the weekend, AND just pulled from origin? So I ran a git diff origin/mybranch and the diffs were exactly the 6 changes I just pulled from remote.\nI could only \"fix\" this by running git fetch origin:\nFrom [email protected]:me/project\naf8be00..88b0738 mybranch -> origin/mybranch\n\nApparently, my local repo was missing some reference objects, but how can that be? I mean, a pull does a fetch already, and I didn't work on anything except that branch, so a git fetch origin and git fetch origin mybranch should have the same result?\nShould I always use git pull origin instead of git pull origin branchname?\nI'm confused." }, { "role": "assistant", "content": "git pull calls git fetch with the appropriate parameters before merging the explicitly fetched heads (or if none the remote branch configured for merge) into the current branch.\nThe syntax: git fetch <repository> <ref> where <ref> is just a branch name with no colon is a 'one shot' fetch that doesn't do a standard fetch of all the tracked branches of the specified remote but instead fetches just the named branch into FETCH_HEAD.\nUpdate: for Git versions since 1.8.4, if there is a remote tracking branch which tracks the ref that you asked to fetch then the tracking branch will now be updated by fetch. This change has been made specifically to avoid the confusion that the previous behaviour caused.\nWhen you perform git pull <repository> <ref>, FETCH_HEAD is updated as above, then merged into your checked out HEAD but none of the standard tracking branches for the remote repository will be updated (Git <1.8.4). This means that locally it looks like you are ahead of of the remote branch, whereas in fact you are up to date with it.\nPersonally I always do git fetch followed by git merge <remote>/<branch> because I get to see any warnings about forced updates before I merge, and I can preview what I'm merging in. If I used git pull a bit more than I do, I would do a plain git pull with no parameters most of the time, relying on branch.<branch>.remote and branch.<branch>.merge to 'do the right thing'." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-apply - Apply a patch to files and/or to the index --unidiff-zero" }, { "role": "assistant", "content": "By default, git apply expects that the patch being\napplied is a unified diff with at least one line of context.\nThis provides good safety measures, but breaks down when\napplying a diff generated with --unified=0 . To bypass these\nchecks use --unidiff-zero . Note, for the reasons stated above, the usage of context-free patches is\ndiscouraged." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "giteveryday - A useful minimum set of commands for Everyday Git Give push/pull only access to developers using git-over-ssh." }, { "role": "assistant", "content": "e.g. those using: $ git push/pull ssh://host.xz/pub/scm/project $ grep git /etc/passwd (1) alice:x:1000:1000::/home/alice:/usr/bin/git-shell\nbob:x:1001:1001::/home/bob:/usr/bin/git-shell\ncindy:x:1002:1002::/home/cindy:/usr/bin/git-shell\ndavid:x:1003:1003::/home/david:/usr/bin/git-shell\n$ grep git /etc/shells (2) /usr/bin/git-shell log-in shell is set to /usr/bin/git-shell, which does not\nallow anything but git push and git pull . The users require\nssh access to the machine. in many distributions /etc/shells needs to list what is used\nas the login shell." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fast-import - Backend for fast Git data importers Exact byte count format" }, { "role": "assistant", "content": "The frontend must specify the number of bytes of data. 'data' SP <count> LF\n\t<raw> LF? where <count> is the exact number of bytes appearing within <raw> . The value of <count> is expressed as an ASCII decimal\ninteger. The LF on either side of <raw> is not\nincluded in <count> and will not be included in the imported data. The LF after <raw> is optional (it used to be required) but\nrecommended. Always including it makes debugging a fast-import\nstream easier as the next command always starts in column 0\nof the next line, even if <raw> did not end with an LF ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --author=<pattern> --committer=<pattern>" }, { "role": "assistant", "content": "Limit the commits output to ones with author/committer\nheader lines that match the specified pattern (regular\nexpression). With more than one --author=<pattern> ,\ncommits whose author matches any of the given patterns are\nchosen (similarly for multiple --committer=<pattern> )." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository (space)" }, { "role": "assistant", "content": "for a successfully fetched fast-forward;" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-pack-objects" }, { "role": "assistant", "content": "Create a packed archive of objects" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: How to estimate a contribution of a person to my project in terms of added/changed lines of code?\nI have a GIT repository and I want to calculate how many lines of code were added/changed by one person or a group of persons during some period of time. Is it possible to calculate with git?" }, { "role": "assistant", "content": "You can use git log and some shell-fu:\ngit log --shortstat --author \"Aviv Ben-Yosef\" --since \"2 weeks ago\" --until \"1 week ago\" \\\n | grep \"files\\? changed\" \\\n | awk '{files+=$1; inserted+=$4; deleted+=$6} END \\\n {print \"files changed\", files, \"lines inserted:\", inserted, \"lines deleted:\", deleted}'\n\nExplanation: git log --shortstat displays a short statistic about each commit, which, among other things, shows the number of changed files, inserted and deleted lines. We can then filter it for a specific committer (--author \"Your Name\") and a time range (--since \"2 weeks ago\" --until \"1 week ago\").\nNow, in order to actually sum up the stats instead of seeing the entry per commit, we do some shell scripting to do it. First, we use grep to filter only the lines with the diffs. These lines look like this:\n 8 files changed, 169 insertions(+), 81 deletions(-)\n\nor this:\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\nWe then sum these using awk: for each line we add the files changed (1st word), inserted lines (4th word) and deleted lines (6th word) and then print them after summing it all up.\nEdit: forward slashes were added in the top snippet so it can be copy and pasted into a command line." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %H" }, { "role": "assistant", "content": "commit hash" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --no-notes" }, { "role": "assistant", "content": "Do not show notes. This negates the above --notes option, by\nresetting the list of notes refs from which notes are shown.\nOptions are parsed in the order given on the command line, so e.g.\n\"--notes --notes=foo --no-notes --notes=bar\" will only show notes\nfrom \"refs/notes/bar\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I resolve a conflict after git pull?\nI have to solve some conflict after a git pull.\n$ git pull\nCONFLICT (rename/add): Renamed vignette_generator_mashed.h->vision_problem_8.h in 49423dd0d47abe6d839a783b5517bdfd200a202f. vision_problem_8.h added in HEAD\nAdded as vision_problem_8.h~HEAD_1 instead\nRemoved vignette_generator_cross_square.cc\nAutomatic merge failed; fix conflicts and then commit the result.\n\nSo I googled it a bit, and found people saying using git mergetool. But here is what I got:\n$ git mergetool\nmerge tool candidates: meld kdiff3 tkdiff xxdiff meld gvimdiff emerge opendiff emerge vimdiff\nNo files need merging\n$ git mergetool opendiff\nmerge tool candidates: meld kdiff3 tkdiff xxdiff meld gvimdiff emerge opendiff emerge vimdiff\nopendiff: file not found\n\nSo does it mean I have to install something?\nWhat if I simply want the version from git pull to overwrite everything?" }, { "role": "assistant", "content": "You don't need mergetool for this. It can be resolved pretty easily manually.\nYour conflict is that your local commits added a file, vision_problem_8.h, that a remote commit also created, by a rename from vignette_generator_mashed.h. If you run ls -l vision_problem_8.h* you will probably see multiple versions of this file that git has preserved for you. One of them will be yours, another of them will be the remote version. You can use an editor or whatever tools you like to resolve the conflicting contents. When you're done, git add the affected files and commit to complete the merge.\nIf you just want to use the remote commit's version, then you can just move the copy that you didn't write into place and git add it.\n\nRegarding the merge tools, have a look at git help mergetool. Basically, it's going to try running each of the included possibilities until it finds one, or use one you have explicitly configured." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-checkout - Switch branches or restore working tree files --orphan <new-branch>" }, { "role": "assistant", "content": "Create a new unborn branch, named <new-branch> , started from <start-point> and switch to it. The first commit made on this\nnew branch will have no parents and it will be the root of a new\nhistory totally disconnected from all the other branches and\ncommits. The index and the working tree are adjusted as if you had previously run git checkout <start-point> . This allows you to start a new history\nthat records a set of paths similar to <start-point> by easily running git commit -a to make the root commit. This can be useful when you want to publish the tree from a commit\nwithout exposing its full history. You might want to do this to publish\nan open source branch of a project whose current tree is \"clean\", but\nwhose full history contains proprietary or otherwise encumbered bits of\ncode. If you want to start a disconnected history that records a set of paths\nthat is totally different from the one of <start-point> , then you should\nclear the index and the working tree right after creating the orphan\nbranch by running git rm -rf . from the top level of the working tree.\nAfterwards you will be ready to prepare your new files, repopulating the\nworking tree, by copying them from elsewhere, extracting a tarball, etc." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --diff-algorithm={patience|minimal|histogram|myers}" }, { "role": "assistant", "content": "Choose a diff algorithm. The variants are as follows: default , myers The basic greedy diff algorithm. Currently, this is the default. minimal Spend extra time to make sure the smallest possible diff is\nproduced. patience Use \"patience diff\" algorithm when generating patches. histogram This algorithm extends the patience algorithm to \"support\nlow-occurrence common elements\". For instance, if you configured the diff.algorithm variable to a\nnon-default value and want to use the default one, then you\nhave to use --diff-algorithm=default option." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Rebase a branch without checking it out\nSo I'm working on a project that sometimes has long build times, and the build is clobbered very often. If I have an older branch with some work going on (which has been committed, but is based on an older parent), running git checkout oldbranch changes the working dir to represent all the old code, which makes me need to run a full build again.\nHowever, usually I've only modified one or two files, and the rest don't need to be reset. What I'd like to do is to rebase this branch to the current master head, and preserve those changes to the files.\nBasically, if a.rs and b.rs have been modified, then I need a way of making these changes base themselves onto the current head, without touching any files other than those two.\nIs there a git-ish way of doing this? Currently I'm juggling patch files to do this." }, { "role": "assistant", "content": "Going through the same right now I learned git rebase allows you to specify two branches in one go, essentially making it git rebase <remote> <local>, eg.\ngit rebase origin/master dev\n\nThis performs a more efficient rebase where your files don't get all re-written (which is the case if you checkout the branch first). You still need to resolve merge conflicts first and you end up with a repository where your local dev branch is checked out." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-read-tree - Reads tree information into the index" }, { "role": "assistant", "content": "NAME git-read-tree - Reads tree information into the index" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index --color-words[=<regex>]" }, { "role": "assistant", "content": "Equivalent to --word-diff=color plus (if a regex was\nspecified) --word-diff-regex=<regex> ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %w([<w>[,<i1>[,<i2>]]])" }, { "role": "assistant", "content": "switch line wrapping, like the -w option of git-shortlog ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-apply - Apply a patch to files and/or to the index --allow-empty" }, { "role": "assistant", "content": "Don’t return an error for patches containing no diff. This includes\nempty patches and patches with commit text only." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Prevent commit when gitlab-CI pipeline fail\n\nIs there a way to prevent a push to gitlab if the pipeline fail?\nHere's a gitlab-ci.yml sample with multiple jobs. This pipeline is triggered on every push. \nIf one of the job failed I don't want my code to be pushed on my repository. (I know this feature exist for pull request).\nimage: node:9.4.0\n\ncache:\n paths:\n - node_modules/\n\nbefore_script:\n - npm install\n\nstages:\n - lint\n - test\n\nlint:\n stage: lint\n script:\n - npm run lint\n\ntest:\n stage: test\n script:\n - npm run test" }, { "role": "assistant", "content": "Sorry Simon - this is not how this is supposed to work. You need the stuff in the repo so the pipeline can run.\nYou should use a branching flow, where you only allow successful builds/merge requests to be merged against develop/master, so you don't have to care if failing code is added in the repo. Your main branches always stay clean. You can enforce this behavior by only allowing merges against develop/master (protected branches) and not allow direct pushes.\nFor simpler things you can use pre-commit hooks, with only allow pushing if, for example, npm run lint succeeds. But, running a whole pipeline is too much for a pre-commit-hook (it may work, but it's not best practice)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary parent" }, { "role": "assistant", "content": "A commit object contains a (possibly empty) list\nof the logical predecessor(s) in the line of development, i.e. its\nparents." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker gitformat-index" }, { "role": "assistant", "content": "Git index format" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fast-import - Backend for fast Git data importers --export-marks=<file>" }, { "role": "assistant", "content": "Dumps the internal marks table to <file> when complete.\nMarks are written one per line as :markid SHA-1 .\nFrontends can use this file to validate imports after they\nhave been completed, or to save the marks table across\nincremental runs. As <file> is only opened and truncated\nat checkpoint (or completion) the same path can also be\nsafely given to --import-marks." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --patch-with-stat" }, { "role": "assistant", "content": "Synonym for -p --stat ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What should I put in a meteor .gitignore file?\nI have a new meteor project. I'm guessing the .meteor dir has a combination of configuration files (needed) and temporary files (not needed). \nSo what's in your .gitignore?" }, { "role": "assistant", "content": "The only directory you want excluded from version control is .meteor/local.\nMeteor automatically creates the right .meteor and .meteor/.gitignore, though -- you shouldn't need to do anything." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab Webhook and Jenkins: No Data Received\n\nI have been following the below links in order to integrate Gitlab with Jenkins using web hooks. All the below links mention to receive 'JSON' or 'payload' or token over at Jenkins side, but I do not see anything when I try to echo or print these parameters in the Shell script of Jenkins configurations.\nIn shell script I have this, but I never receive any payloads:\n\necho \"the build worked! The payload is $payload\"\n\nI do see some JSON coming through on /var/log/Jenkins/Jenkins.logs, but I want to see the messages coming in inside my 'Console Output', so that I can use the messages coming in from Gitlab to whether trigger a build or not.\nMost of these links mention options are not available via Gitlab. One article was mentioning to convert web hook format to application/json, but there are no such options on the Gitlab UI.\nHow to process a github webhook payload in Jenkins?\nhttp://chloky.com/github-json-payload-in-jenkins/\nJenkins Settings:\n\nGitlab webhook: \n\nhttp://xx.xx.xx.xxx:8080/job/Interim_Build/buildWithParameters?token=TOKEN_NAME\n\nAny help would be great. Thanks." }, { "role": "assistant", "content": "I suggest you to try two solutions (both working for me):\n\nconvert json data from Gitlab webhook using this elegant proxy written in Go https://github.com/akira/githookproxy .\nIt will take the webhook request, and translate it to a request to the target_url in the format of:\n\npayload: JSON body\nSTART: Start commit hash\nEND: End commit hash\nREFNAME: Ref name\n\nemulate jenkins as a Gitlab CI using this Jenkins plugin https://github.com/jenkinsci/gitlab-plugin \n\nFor me the best is the first because it is simple and more transparent." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-difftool - Show changes using common diff tools -x <command> --extcmd=<command>" }, { "role": "assistant", "content": "Specify a custom command for viewing diffs. git-difftool ignores the configured defaults and runs <command> $LOCAL $REMOTE when this option is specified.\nAdditionally, $BASE is set in the environment." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git changes my file permissions upon checkout\nOur workflow is develop on a local machine, commit the changes to a central repository, then check out the branch of that repository that we need.\nThe problem is that Git changes ownership and even file permissions of the files that it checks out, depending on the user making the checkout. A direct result of this is that our CSS files become unreadable after a checkout, as Git changes the file ownership to the person who did the Git pull in the webroot.\nExample:\n\nBefore git pull: style.css owned by user_a:group_a\nAfter git pull: style.css owned by user_b:user_b\n\nI want to keep ownership as user_a:group_a. I don't want to have to log in every time one of my team has made a change to the files, and change the ownership back to the original configuration.\nHow do other people deal with this? How do you deal with repositories used by multiple users. We have suphp on our system and cannot take it off." }, { "role": "assistant", "content": "Git does not change file permissions or ownership. It's just that it (mostly) doesn't store it either, it doesn't exist in your repo, so they get changed to whatever your user has. Just like with any file creation.\nGit supports two permission sets: executable bit on and executable bit off. Nothing else. Ownership information is not stored at all.\nSee this thread - \"If you want specific permissions, you'll need to do it manually.\"\nThere are some solutions suggested: you can use a separate tool to do it for you, use a proper combination of user account and umask to set them properly by default or write a git hook yourself to do it. A hook would've to be installed on the user doing the checkout.\nLike @ikke said in the comments, Git is not really a deployment tool and should not be used as such. It is a version control system for source code." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --quiet" }, { "role": "assistant", "content": "Disable all output of the program. Implies --exit-code ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Rebase only part of a branch\nI've got two branches (and master). Branch 2 is based on Branch 1 is based on master. I've submitted Branch 1 for review, it had some changes, I rebased some of those changes into history and merged the result into master. \nNow I need to rebase Branch 2 on top of master to prepare it for review/merge.\nThe problem is that Branch 2 still contains the original commits of Branch 1, which don't exist anymore, so git gets confused. I tried rebase -i to drop the original commits of Branch 1, but the commits of Branch 2 don't base on top of master-before-branch-1.\nWhat I need to do is take branch 2, drop some commits, and rebase just the remaining commits on top of master in a single operation. But I only know how to do these two operations in two distinct steps.\nHow can I rebase part of my branch onto another branch, dropping all commits that are not in common ancestry, except the ones I specify (e.g. from HEAD~2 up)?\nHere's the current state:\nmaster new branch 1\n- - - - - - - - - - - | - - - - - - - - -\n \\\n \\ branch 1\n \\ _ _ _ _ _ _ _\n \\\n \\ branch 2\n \\ _ _ _ _ _ _ _\n\nWhat I want to end up with:\nmaster new branch 1 \n- - - - - - - | - - - - - - - - - -\n \\\n \\\n \\\n \\ branch 2\n - - - - - - - - -" }, { "role": "assistant", "content": "The actual command would be:\ngit rebase --onto newbranch1 branch1 branch2\n\nThat will replay on top of new_branch1 all commits after branch1 up to branch2 HEAD.\nAs Joshua Goldberg puts it in the comments:\n git rebase --onto <place-to-put-it> <last-change-that-should-NOT-move> <change to move>\n\nAs Denis Sivtsov illustrates in the comments:\n\nIf you need only replay the last commit only from branch, in this case work:\ngit rebase --onto newbranch1 HEAD~1" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --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-update-ref - Update the object name stored in a ref safely" }, { "role": "assistant", "content": "SYNOPSIS git update-ref [-m <reason>] [--no-deref] (-d <ref> [<old-oid>] | [--create-reflog] <ref> <new-oid> [<old-oid>] | --stdin [-z])" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Heroku + Node: Cannot find module error\nMy Node app is running fine locally, but has run into an error when deploying to Heroku. The app uses Sequelize in a /models folder, which contains index.js, Company.js and Users.js. Locally, I am able to import the models using the following code in /models/index.js:\n// load models\nvar models = [\n 'Company',\n 'User'\n];\nmodels.forEach(function(model) {\n module.exports[model] = sequelize.import(__dirname + '/' + model);\n});\n\nThis works fine, however, when I deploy to Heroku the app crashes with the following error:\nError: Cannot find module '/app/models/Company'\n at Function.Module._resolveFilename (module.js:338:15)\n at Function.Module._load (module.js:280:25)\n at Module.require (module.js:364:17)\n at require (module.js:380:17)\n at module.exports.Sequelize.import (/app/node_modules/sequelize/lib/sequelize.js:219:24)\n at module.exports.sequelize (/app/models/index.js:60:43)\n at Array.forEach (native)\n at Object.<anonymous> (/app/models/index.js:59:8)\n at Module._compile (module.js:456:26)\n at Object.Module._extensions..js (module.js:474:10)\nProcess exited with status 8\n\nInitially I thought it was due to case sensitivity (local mac vs heroku linux), but I moved the file, made a git commit, and then moved back and committed again to ensure Company.js is capitalized in the git repository. This didn't solve the problem and I'm not sure what the issue could be." }, { "role": "assistant", "content": "The problem was due to case sensitivity and file naming. Mac OS X is case insensitive (but aware) whereas Heroku is based on Linux and is case sensitive. By running heroku run bash from my terminal, I was able to see how the /models folder appeared on Heroku's file system. The solution was to rename User.js and Company.js on my local system to new temporary files, commit the changes to git, then rename back to User.js and Company.js being mindful of the capitalized first letter and then committing the changes again via git. Previously I had tried to rename the files directly from user.js to User.js and company.js to Company.js but the git commit and case-sensitive file name changes did not reflect on Heroku." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-apply - Apply a patch to files and/or to the index --recount" }, { "role": "assistant", "content": "Do not trust the line counts in the hunk headers, but infer them\nby inspecting the patch (e.g. after editing the patch without\nadjusting the hunk headers appropriately)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git - deleted some files locally, how do I get them from a remote repository\nI've deleted some files on my PC, how do I download them again?\nPull says: \"Already up-to-date\"." }, { "role": "assistant", "content": "Since git is a distributed VCS, your local repository contains all of the information. No downloading is necessary; you just need to extract the content you want from the repo at your fingertips.\nIf you haven't committed the deletion, just check out the files from your current commit:\ngit checkout HEAD <path>\n\nIf you have committed the deletion, you need to check out the files from a commit that has them. Presumably it would be the previous commit:\ngit checkout HEAD^ <path>\n\nbut if it's n commits ago, use HEAD~n, or simply fire up gitk, find the SHA1 of the appropriate commit, and paste it in." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why should I care about lightweight vs. annotated tags?\nI switched from Subversion to Git as my day-to-day VCS last year and am still trying to grasp the finer points of \"Git-think\".\nThe one which has been bothering me lately is \"lightweight\" vs. annotated vs. signed tags. It seems pretty universally accepted that annotated tags are superior to lightweight tags for all real uses, but the explanations I've found for why that's the case always seem to boil down to either \"because best practices\" or \"because they're different\". Unfortunately, those are very unsatisfying arguments without knowing why it's best practices or how those differences are relevant to my Git usage.\nWhen I first switched to Git, lightweight tags seemed to be the best thing since sliced bread; I could just point at a commit and say \"that was 1.0\". I'm having trouble grasping how a tag could ever need to be more than that, but I certainly can't believe that the Git experts of the world prefer annotated tags arbitrarily! So what's all the hubbub about?\n(Bonus points: Why would I ever need to sign a tag?)\nEDIT\nI've been successfully convinced that annotated tags are a Good Thing — knowing who tagged and when is important! As a follow-up, any advice on good tag annotations? Both git tag -am \"tagging 1.0\" 1.0 and trying to summarize the commit log since the previous tag feel like losing strategies." }, { "role": "assistant", "content": "The big plus of an annotated tag is that you know who created it. Just like with commits, sometimes it's nice to know who did it. If you're a developer and you see that v1.7.4 has been tagged (declared ready) and you're not so sure, who do you talk to? The person whose name is in the annotated tag! (If you live in a distrustful world, this also keeps people from getting away with tagging things they shouldn't.) If you're a consumer, that name is a stamp of authority: that's Junio Hamano saying this version of git is hereby released.\nThe other metadata can be helpful too - sometimes it's nice to know when that version was released, not just when the final commit was made. And sometimes the message can even be useful. Maybe it helps explain the purpose of that particular tag. Maybe the tag for a release candidate contains a bit of a status/to-do list.\nSigning tags is pretty much like signing anything else - it provides one more level of security for the paranoid. Most of us aren't ever going to use it, but if you really want to verify everything before you put that software on your computer, you might want it.\nEdit:\nAs for what to write in a tag annotation, you're right - there's not always much useful to say. For a version number tag, it's implicitly understood that it marks that version, and if you're happy with your changelogs elsewhere, there's no need to put one there. In this case, it's really the tagger and date that are the most important. The only other thing I can think of is some sort of stamp of approval from a test suite. Have a look at git.git's tags: they all just say something like \"Git 1.7.3 rc1\"; all we really care about is Junio Hamano's name on them.\nHowever, for less obviously named tags, the message could become much more important. I could envision tagging a specific special-purpose version for a single user/client, some important non-version milestone, or (as mentioned above) a release candidate with extra information. The message is then much more useful." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git $GIT_DIR/svn/**/.rev_map.*" }, { "role": "assistant", "content": "Mapping between Subversion revision numbers and Git commit\nnames. In a repository where the noMetadata option is not set,\nthis can be rebuilt from the git-svn-id: lines that are at the\nend of every commit (see the svn.noMetadata section above for\ndetails). git svn fetch and git svn rebase automatically update the rev_map\nif it is missing or not up to date. git svn reset automatically\nrewinds it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Push existing project into Github\n\nI have a folder with my project sources. How I can push this project into Github's repository? \nI tried using this steps:\n\nI created empty repository on GitHub. \nI run git-bash and typed git init, so inside project root appeared .git folder. \nI added some files to version control using git add sourcesFolderName\nI committed files added in previous step using git commit -m \"initial commit\"\nI specified remote repository using git remote add MyProject <url>\nFinally git push, but nothing is pushed to remote repo... (no authorization failure)\n\nSo how I can push existing sources into newly created github repo?" }, { "role": "assistant", "content": "git init\ngit add .\ngit commit -m \"Initial commit\"\ngit remote add origin <project url>\ngit push -f origin master\n\nThe -f option on git push forces the push. If you don't use it, you'll see an error like this:\nTo [email protected]:roseperrone/project.git\n ! [rejected] master -> master (fetch first)\nerror: failed to push some refs to '[email protected]:roseperrone/project.git'\nhint: Updates were rejected because the remote contains work that you do\nhint: not have locally. This is usually caused by another repository pushing\nhint: to the same ref. You may want to first merge the remote changes (e.g.,\nhint: 'git pull') before pushing again.\nhint: See the 'Note about fast-forwards' in 'git push --help' for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gittutorial - A tutorial introduction to Git" }, { "role": "assistant", "content": "Next Steps This tutorial should be enough to perform basic distributed revision\ncontrol for your projects. However, to fully understand the depth\nand power of Git you need to understand two simple ideas on which it\nis based: The object database is the rather elegant system used to\nstore the history of your project—​files, directories, and\ncommits. The index file is a cache of the state of a directory tree,\nused to create commits, check out working directories, and\nhold the various trees involved in a merge. Part two of this tutorial explains the object\ndatabase, the index file, and a few other odds and ends that you’ll\nneed to make the most of Git. You can find it at gittutorial-2 . If you don’t want to continue with that right away, a few other\ndigressions that may be interesting at this point are: git-format-patch , git-am : These convert\nseries of git commits into emailed patches, and vice versa,\nuseful for projects such as the Linux kernel which rely heavily\non emailed patches. git-bisect : When there is a regression in your\nproject, one way to track down the bug is by searching through\nthe history to find the exact commit that’s to blame. git bisect can help you perform a binary search for that commit. It is\nsmart enough to perform a close-to-optimal search even in the\ncase of complex non-linear history with lots of merged branches. gitworkflows : Gives an overview of recommended\nworkflows. giteveryday : Everyday Git with 20 Commands Or So. gitcvs-migration : Git for CVS users." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I move an issue on github to another repo?\n\nIt happens every now and then. Some library depends on another and a user opens an issue that belongs to the wrong repo. Can I move the issue to the other repo?\nYou could argue that the issue could be seen as being both repos' issue because one depends on the other and as long as one doesn't work properly both don't. But I'd rather talk about solutions to the issue in the repo it belongs in." }, { "role": "assistant", "content": "No, officialy you can't move issues between repositories.\nThere is a hack though, github-issues-import, kind of a plugin, to import issues from a repository to another." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I name and retrieve a Git stash by name?\nHow do I save/apply a stash with a name? I don't want to have to look up its index number in git stash list. I tried git stash save \"my_stash_name\", but that only changes the stash description, and the corresponding git apply \"my_stash_name\" doesn't work." }, { "role": "assistant", "content": "To save a stash with a message:\ngit stash push -m \"my_stash_name\"\n\nAlternatively (deprecated since v2.16):\ngit stash save \"my_stash_name\"\n\n\nTo list stashes:\ngit stash list\n\nAll the stashes are stored in a stack.\n\nTo pop (i.e. apply and drop) the nth stash:\ngit stash pop stash@{n}\n\nTo pop (i.e. apply and drop) a stash by name is not possible with git stash pop (see footnote-1).\n\nTo apply the nth stash:\ngit stash apply stash@{n}\n\nTo apply a stash by name:\ngit stash apply stash^{/my_stash_name}\n\n\nfootnote-1:\n\nSee the man git-stash section regarding apply:\n\nUnlike pop, may be any commit that looks like a commit created by stash push or stash create.\n\n\nPossible workaround (tested on git version 2.27 and 2.31):\ngit stash pop $(git stash list --pretty='%gd %s'|grep \"my_stash_name\"|head -1|gawk '{print $1}')" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-gc" }, { "role": "assistant", "content": "Cleanup unnecessary files and optimize the local repository" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do you attach a new pull request to an existing issue on github?\n\nI'm not sure, but I have a vague memory of creating a github pull request with \"Issue 4\" or something in the title, and it automatically attached itself to Issue 4 in the project that I was submitting it to. I tried it again recently and it didn't work -- it just created a brand new issue instead. I don't see any options like \"Attach to issue\" on the new pull request page, nor \"Open a new pull request for this issue\" on the issue page. Is there any way to do this, to help project owners keep their Issues page clean and avoid duplication?\nEdit: To clarify, I know that creating a pull request always creates a new issue. I would like to instead attach the pull request to an existing issue." }, { "role": "assistant", "content": "Adding a pull request to an existing upstream issue is easy assuming you forked using the normal github means. \nSimply reference the issue in your commit message using any of the supported keywords:\n\nclose\ncloses\nclosed\nfix\nfixes\nfixed\nresolve\nresolves\nresolved\n\nFor example: \"this commit fixes #116\"\nThe text referencing the issue does not need to appear in the subject line of your commit.\nPush your commit to your github repo and the pull request will be automatically appended to the issue. \nNote: While it is not required, it is strongly recommended that you commit anything that will be part of a pull request to a separate branch specific to that issue, because future commits on that branch will be appended to the pull request (automatically by github). So, if you didn't make a separate branch, left it on master, and then kept developing, then all your unrelated commits to master would get appended to your pull request." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitLab CI - avoid build when adding tag\n\nHow do I prevent a gitlab ci pipeline being triggered when I add a git tag? I'm running this command locally (as opposed to within a gitlab-ci job) \ngit tag -a \"xyz\"\n\nand then pushing the tag; and this triggers various pipelines. I want to exclude some of those pipelines from running. \nI'm trying variations on ideas from questions such as this; that question is using only, I'm wanting to exclude, so I'm trying except. The answers there have two variants, one with refs one without.\nbuild: \n # ... my work here ... \n except:\n - tags\n\n\nbuild: \n # ... my work here ... \n except:\n refs:\n - tags\n\nNeither seem to have any effect; I add a tag, the build still happens.\nMy understanding may be completely awry here as there seem to be three possible meanings of the word tags and when reading docs or examples I'm not always sure which meaning is applicable:\n\nGit tags applied using git tag\nGitlab CI tags used to determine which runners pick a job\nThe ref identifier of a commit used to trigger a pipeline via the REST API. This is usually a branch name, but could be a git tag.\n\nI'm interested in controlling what happens if the first case. It does seem clear from comments so far that \"except: -tags\" is not relevant to my case, so is there any approach that does work?" }, { "role": "assistant", "content": "It looks like GitLab recommends using rules instead of except as per the documentation\n\nonly and except are not being actively developed. rules is the\npreferred keyword to control when to add jobs to pipelines.\n\nSo it'd be\nyour_job:\n stage: your_stage\n script:\n - echo \"Hello\"\n rules:\n - if: $CI_COMMIT_TAG\n when: never \n - when: always" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-branch - List, create, or delete branches --contains [<commit>]" }, { "role": "assistant", "content": "Only list branches which contain the specified commit (HEAD\nif not specified). Implies --list ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs color" }, { "role": "assistant", "content": "Highlight changed words using only colors. Implies --color ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub - fatal: could not read Username for 'https://github.com': No such file or directory\nI have the following problem when I try to pull code using git Bash on Windows:\nfatal: could not read Username for 'https://github.com': No such file or directory\n\nI already tried to implement the accepted solution provided here:\n\nError when push commits with Github: fatal: could not read Username\n\nHowever the problem still persists.\nAfter adding/removing origin I still get the same error.\nCould advise on this issue?\nThanks!" }, { "role": "assistant", "content": "Follow the steps to setup SSH keys here: https://help.github.com/articles/generating-ssh-keys\nOR\ngit remote add origin https://{username}:{password}@github.com/{username}/project.git\n\nUpdate: If you get \"fatal: remote origin already exists.\" then you have to use set-url:\ngit remote set-url origin https://{username}:{password}@github.com/{username}/project.git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "error: Your local changes to the following files would be overwritten by checkout\nThis question is similar to this one, but more specific.\nI have a project with two branches: staging and beta.\nI develop on staging, and use the master branch to fix bugs. So if I'm working on staging and I see an error, I change to master branch:\ngit checkout master\n\nand do the stuff:\ngit add fileToAdd\ngit commit -m \"bug fixed\"\n\nand then I merge with both branches:\ngit checkout staging\ngit merge master\ngit checkout beta\ngit merge beta\n\nAnd doesn't matter if there are other files on the working tree.\nBut now, when I try to change to the master branch, I'm getting an error:\nerror: Your local changes to the following files would be overwritten by checkout:\nsrc/Pro/ConvocationBundle/Controller/DefaultController.php\nPlease, commit your changes or stash them before you can switch branches.\nAborting\n\nI thought that I should remove the file from the staging area:\ngit reset HEAD src/Pro/ConvocationBundle/Controller/DefaultController.php\n\nBut I'm getting the same error. If I do git status, I get No changes to commit" }, { "role": "assistant", "content": "Warning: Running this will discard local changes. Only run this if you want to discard local changes.\nI encountered the same problem and solved it by\ngit checkout -f branch\n\nand its specification is rather clear.\n\n-f, --force\n\nWhen switching branches, proceed even if the index or the working\ntree differs from HEAD. This is used to throw away local changes.\n\nWhen checking out paths from the index, do not fail upon unmerged\nentries; instead, unmerged entries are ignored." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --summary" }, { "role": "assistant", "content": "Output a condensed summary of extended header information\nsuch as creations, renames and mode changes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can't git push to Bitbucket: Unauthorized - fatal: Could not read from remote repository\nI can't push to Bitbucket and this is the error message:\n\n> git push origin master:master\n Unauthorized\n fatal: Could not read from remote repository.\nPlease make sure you have the correct access rights and the repository\n exists.\n\nDebugging, I receive this message when I ssh to bitbucket:\n\n> ssh -T bitbucket.org\n authenticated via a deploy key.\nYou can use git or hg to connect to Bitbucket. Shell access is\n disabled.\nThis deploy key has read access to the following repositories:\n my-username/my-repository\n\nThe read access part of this message is suspicious.\nPS: I know there are dozens of similar questions, but I couldn't find the exact error message here and only got the solution outside. That's why I'm self answering this to help others." }, { "role": "assistant", "content": "I was able to solve this using this suggestion:\n\n\nRemove the SSH key from the repo. (Click on repo name > Settings > Access Keys)\nAdd SSH key to Account settings SSH keys. (Click on your avatar > Personal Settings > SSH Keys)\n\n\nSo, adding the keys under the repo only gives you a read-only access. For read and write access, you need to add your keys under your account.\nTo be fair, Bitbucket warns about the read-only access when adding the key to the repo:" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Whole team gets 'too many unreachable loose objects' messages\n\nNot long ago, we have made the switch from SVN to Git.\nA few days ago, I realized that all of our team gets those messages when they push :\n$ git push\nCounting objects: 32, done.\nDelta compression using up to 8 threads.\nCompressing objects: 100% (19/19), done.\nWriting objects: 100% (32/32), 2.94 KiB | 0 bytes/s, done.\nTotal 32 (delta 14), reused 0 (delta 0)\nerror: The last gc run reported the following. Please correct the root cause\nand remove gc.log.\nAutomatic cleanup will not be performed until the file is removed.\n\nwarning: There are too many unreachable loose objects; run 'git prune' to remove them.\n\nTo [email protected]:root/xxx.git\n 15c3bbb..69e6d8b xxxx -> xxx\n\nI thought it was coming from my computer for a while, until I realize that everybody has the same issues.\nNeedless to say, there is no gc.log in my .git folder, and using 'git gc' or 'git prune' has no effect.\nSo my question is : Could it be that the repository hosted on the server is somehow not clean? If so, how to I actually clean it?\nAll of the solutions I have found so far relate to local copies of repositories.\nAlso, we use Gitlab to host our repos.\nEDIT : It is worth saying that I have since I posted this question also tried \"Housecleaning\" the repository using Gitlab but with no result so far." }, { "role": "assistant", "content": "This is followed by issue 14357 (GitLab 8.6- or less)\nThe manual fix was:\n\nSSH into worker1\ncd into the gitlab-org/gitlab-ce directory\nran rm gc.log, this just contained the line \" warning: There are too many unreachable loose objects; run 'git prune' to remove them.\"\nran git prune and prayed it didn't break things (which it thankfully didn't)\n\nBut it looks like, starting GitLab 8.7, auto gc is disabled.\nThis is also done in the context of (still opened) issue 13524:\n\nTypically after a rebase, amend or other action that requires a force push we can have dangled commits.\nSuch \"dereferenced\" commits are getting lost due to git gc that may be executed internally or by using GitLab Housekeeping features.\nIf it happens that there was a discussion attached to a specific commit - it is not available after dereferenced commit has been garbage-collected.\nCommits are being recorded in push events and are available through system notes added to merge request, and currently this produces error 500 in GitLab.\n\nUpdate: that issue was closed a month later (July 2016) with:\n\nMR 5062: Don't garbage collect commits that have related DB records like comments\n\n\nMakes sure a commit is kept around when Git garbage collection runs.\nGit GC will delete commits from the repository that are no longer in any branches or tags, but we want to keep some of these commits around, for example if they have comments or CI builds.\n\n\nMR 4101: Refactor: Convert existing array-based diff refs to the DiffRefs model" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Does removing a GitHub Repo also remove the Git Contribution History from the chart on your profile page?\n\nIf I have a Repository called my_project and make a large number of commits over a few different weeks, my contribution history on my GitHub/GitLab (Should be true for both), the main page profile will look like the following:\n\nAs above you can see varied commits in the contribution panel, dark colours for more and light green for less, with grey as no commits to the repo.\nIf I remove the repo does this all become grey? As in does the commit history for this graph on my landing page turn all those coloured cells from green to grey as there is no repo there any more associated with those commits.\nThe only reason I ask this, is because I have made a repo which I no longer need and was using to test out some python and git, however if I remove the repo I am worried that my profile will show that I have made no contributions for the past month on GitHub/GitLab, but I have, it's only I want to remove the project as it's no longer needed.\nAny help is appreciated!" }, { "role": "assistant", "content": "Yes, it will be removed too.\nHowever, if you don't want it you can make that repo as private so that publically it is not accessible to anyone and your contribution still shows up in history" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --stat[=<width>[,<name-width>[,<count>]]]" }, { "role": "assistant", "content": "Generate a diffstat. By default, as much space as necessary\nwill be used for the filename part, and the rest for the graph\npart. Maximum width defaults to terminal width, or 80 columns\nif not connected to a terminal, and can be overridden by <width> . The width of the filename part can be limited by\ngiving another width <name-width> after a comma or by setting diff.statNameWidth=<width> . The width of the graph part can be\nlimited by using --stat-graph-width=<width> or by setting diff.statGraphWidth=<width> . Using --stat or --stat-graph-width affects all commands generating a stat graph,\nwhile setting diff.statNameWidth or diff.statGraphWidth does not affect git format-patch .\nBy giving a third parameter <count> , you can limit the output to\nthe first <count> lines, followed by ... if there are more. These parameters can also be set individually with --stat-width=<width> , --stat-name-width=<name-width> and --stat-count=<count> ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git log to return only the commits made to the master branch?\nI've done a bit of searching and found:\ngit log myBranchName\n\nas a possible solution. But what happens when my branch is the master branch? when I run:\ngit log master\n\nIt seems to return everything commited to any branch. Based on what I've read, it lists all of the commits related to the master branch. Knowing that, how I can call up the commit history of the master branch only?" }, { "role": "assistant", "content": "I think this is what you want \ngit log --first-parent master\n\nTo quote the manual\n\nFollow only the first parent commit upon seeing a merge commit. This\n option can give a better overview when viewing the evolution of a\n particular topic branch, because merges into a topic branch tend to be\n only about adjusting to updated upstream from time to time, and this\n option allows you to ignore the individual commits brought in to your\n history by such a merge." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I reset or revert a file to a specific revision?\nHow can I revert a modified file to its previous revision at a specific commit hash (which I determined via git log and git diff)?" }, { "role": "assistant", "content": "Assuming the hash of the commit you want is c5f567:\ngit checkout c5f567 -- file1/to/restore file2/to/restore\n\nThe git checkout man page gives more information.\nIf you want to revert to the commit before c5f567, append ~1 (where 1 is the number of commits you want to go back, it can be anything):\ngit checkout c5f567~1 -- file1/to/restore file2/to/restore\n\nAs a side note, I've always been uncomfortable with this command because it's used for both ordinary things (changing between branches) and unusual, destructive things (discarding changes in the working directory).\nFor the meaning of -- in the command, refer to In Git, what does -- (dash dash) mean?\n\nThere is also a new git restore command that is specifically designed for restoring working copy files that have been modified. If your git is new enough you can use this command, but the documentation comes with a warning:\n\nTHIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.\n\nBecause git restore is experimental, it should not yet be promoted as the primary answer to this question. When the command is no longer marked as \"experimental\", then this answer can be amended to promote the use of git restore. [At the time of writing, the git restore command has been marked as \"experimental\" for at least four years.]" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-update-ref - Update the object name stored in a ref safely option" }, { "role": "assistant", "content": "Modify the behavior of the next command naming a <ref>.\nThe only valid option is no-deref to avoid dereferencing\na symbolic ref." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitrevisions - Specifying revisions and ranges for Git <rev1>..<rev2>" }, { "role": "assistant", "content": "Include commits that are reachable from <rev2> but exclude\nthose that are reachable from <rev1>. When either <rev1> or\n<rev2> is omitted, it defaults to HEAD ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index cumulative" }, { "role": "assistant", "content": "Count changes in a child directory for the parent directory as well.\nNote that when using cumulative , the sum of the percentages\nreported may exceed 100%. The default (non-cumulative) behavior can\nbe specified with the noncumulative parameter." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options merge.renormalize" }, { "role": "assistant", "content": "Tell Git that canonical representation of files in the\nrepository has changed over time (e.g. earlier commits record\ntext files with CRLF line endings, but recent ones use LF line\nendings). In such a repository, Git can convert the data\nrecorded in commits to a canonical form before performing a\nmerge to reduce unnecessary conflicts. For more information,\nsee section \"Merging branches with differing checkin/checkout\nattributes\" in gitattributes ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "FATAL: Failed to start gitlab-runner: \"launchctl\" failed with stderr: Load failed: 5: Input/output error\n\nAfter installing and registering gitlab-runner, when I'm running gitlab-runner start I get this error message. What will be the reason for this ?\nRuntime platform arch=amd64 os=darwin pid=65915 revision=c1edb478 version=14.0.1\nFATAL: Failed to start gitlab-runner: \"launchctl\" failed with stderr: Load failed: 5: Input/output error" }, { "role": "assistant", "content": "I edited the /Users/$USER/Library/LaunchAgents/gitlab-runner.plist file and changed the location of the log files to a location writeable by my user:\n<key>StandardOutPath</key>\n <string>/Users/USERNAME/.gitlab-runner/gitlab-runner.out.log</string>\n<key>StandardErrorPath</key>\n <string>/Users/USERNAME/.gitlab-runner/gitlab-runner.err.log</string>\n\nThen issued a\nlaunchctl unload /Users/$USER/Library/LaunchAgents/gitlab-runner.plist\nlaunchctl load -w /Users/$USER/Library/LaunchAgents/gitlab-runner.plist\ngitlab-runner stop\ngitlab-runner start\ngitlab-runner status\n\nAnd the service is up and running\nFor more info: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/28136\nEDIT:\nSee also GitLab Issue #29383 where Brad King wrote a single sed command to edit the file for you:\ngitlab-runner install\nsed -i '' \"s|/usr/local/var/log/|$HOME/.gitlab-runner/|\" ~/Library/LaunchAgents/gitlab-runner.plist\ngitlab-runner start" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I create a new GitHub repo from a branch in an existing repo?\nI have master and new-project branches. And now I'd like to create a brand new repo with its master based on the new-project branch.\nBackground: I have one repository which contains three independent applications. It didn't start out this way. There was originally just one app in the repo. Over time, however, business needs have changed. One app became two (a legacy version and a re-write.) A web service was added. Separate branches were used to contain the three projects. However, they don't share any code. And so it'd be simpler to have them split out into their own repos." }, { "role": "assistant", "content": "I started with @user292677's idea, and refined it to solve my problem:\n\nCreate the new-repo in github.\ncd to your local copy of the old repo you want to extract from, which is set up to track the new-project branch that will become the new-repo's master.\n$ git push https://github.com/accountname/new-repo.git +new-project:master \n\nThe new Github repo is finished. The result is;\n\na new Github repository named new-repo,\nwhose master corresponds to the old repo's new-project, with\nall history preserved.\n\nIn fact, I found that by using this method, I could create the new repo with a hand-picked selection of branches, renamed as I wanted:\n$ git push [email protected]:accountname/new_repo +new-project:master +site3a:rails3\nThe result is that the pre-existing site3a branch is now also moved to the new repo and will appear as rails3. This works really well: the network diagram shows the new master and rails3 with full history and in their correct relationship to each other.\nUpdate 2013-12-07: Used this with another project, and verified that this recipe still works.\nUpdate 2018-01-11: Updated step 3. to use GitHub recommendation for https protocol. Recipe still works." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc" }, { "role": "assistant", "content": "NAME git-diff - Show changes between commits, commit and working tree, etc" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc <limit>" }, { "role": "assistant", "content": "An integer parameter specifies a cut-off percent (3% by default).\nDirectories contributing less than this percentage of the changes\nare not shown in the output." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options user.name user.email author.name author.email committer.name committer.email" }, { "role": "assistant", "content": "The user.name and user.email variables determine what ends\nup in the author and committer fields of commit\nobjects.\nIf you need the author or committer to be different, the author.name , author.email , committer.name , or committer.email variables can be set.\nAll of these can be overridden by the GIT_AUTHOR_NAME , GIT_AUTHOR_EMAIL , GIT_COMMITTER_NAME , GIT_COMMITTER_EMAIL , and EMAIL environment variables. Note that the name forms of these variables conventionally refer to\nsome form of a personal name. See git-commit and the\nenvironment variables section of git for more information on\nthese settings and the credential.username option if you’re looking\nfor authentication credentials instead." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %gD" }, { "role": "assistant", "content": "reflog selector, e.g., refs/stash@{1} or refs/stash@{2\nminutes ago} ; the format follows the rules described for the -g option. The portion before the @ is the refname as\ngiven on the command line (so git log -g refs/heads/master would yield refs/heads/master@{0} )." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab pipeline test stage to fail AND create artifacts anyway\n\nI have a gitlab pipeline running on a windows machine with Windows 7 and powershell 4.0. \nThe .yaml has the typical 3 stages: build, test and deploy.\nFor the second stage I want to perform some simple tests that generate a log file which should be available after the test stage finishes.\nHere the script section from the test:\nscript:\n - '$exitCode = (start-process C:\\app_versions\\app_20181211\\bin\\app.exe -PassThru -Wait).ExitCode'\n - 'cat .\\TestLogs\\BasicFunctionsTestPlan.log'\n - 'exit $exitCode'\nartifacts:\n paths:\n - .\\TestLogs\n expire_in: 1 year\n\nHere I had one problem, after the test run has finished the stage finishes always successfully even if the test themselves failed. Then I had to force the script exit with an error code in case the application tells me that the tests failed. \nThis caused the second problem: the artifacts link do not get created even they are available (my test produce it anyway). \nProbably if I knew how to tell gitlab that the test failed in a more clean way, the artifacts would be available anyway.\nI agree that the log file is not an artifact but I would like to keep that file in order to check how the tests have performed, maybe there is a better way to save this file.\nThanks in advance for your help!\nEDIT: \nLooks like there were more people having the same issue here, maybe it helps understanding better the problem." }, { "role": "assistant", "content": "I had the same question, but it's easily solved:\nYou can use artifacts:when to upload artifacts on job failure or despite the\nfailure.\n\nartifacts:when\nsource: Gitlab CI yaml reference: artifacts:when\n\nIntroduced in GitLab 8.9 and GitLab Runner v1.3.0.\n\nartifacts:when is used to upload artifacts on job failure or despite the\nfailure.\nartifacts:when can be set to one of the following values:\n\non_success - upload artifacts only when the job succeeds. This is\nthe default. \non_failure - upload artifacts only when the job\nfails. \nalways - upload artifacts regardless of the job status.\n\nExample:\nTo upload artifacts only when job fails:\njob:\n artifacts:\n when: on_failure\n\n\nallow_failure\nBTW: you can tell Gitlab CI to continue to the next job after a job failure with allow_failure: true \nsource: Gitlab CI yaml Reference: allow_failure\njob1:\n stage: test\n script:\n - execute_script_that_will_fail\n allow_failure: true\n\n\nSo combined it could look something like:\njob1:\n stage: test\n script:\n - execute_script_that_will_fail\n allow_failure: true\n artifacts:\n when: always # or 'on_failure'\n paths:\n - resulting_artifacts" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-replay" }, { "role": "assistant", "content": "EXPERIMENTAL: Replay commits on a new base, works with bare repos too" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I configure KDiff3 as a merge tool and diff tool for git?\nRecently I was using GitExtension 2.46, but the Git version that has the same is 1.9.4.msysgit.2. Willing to use only Git commands, I uninstalled GitExtension and install the latest version available of Git and KDiff3.\nWhen I make a merge and have conflicts, I run the following command:\ngit mergetool\n\nThen I receive the message:\n\nThe merge tool kdiff3 is not available as 'kdiff3'.\n\nI guess it must be by the KDiff3 path.\nEnvironment\n\nOS: Windows 10\nGit 2.6.1.windows.1\nKDiff3 0.9.98 (64 bit)\n\nQuestions:\n\nWhat do I have to configure in the .gitconfig file for the command git mergetool to open the KDiff3 GUI with the versions LOCAL, REMOTE, BASE and MERGED of conflicted file?\n\nHow can I configure it to use it as a diff tool?" }, { "role": "assistant", "content": "These sites were very helpful, almost, mergetool and difftool. I used the global configuration, but can be used by repository without problems. You just need to execute the following commands:\ngit config --global merge.tool kdiff3\ngit config --global mergetool.kdiff3.path \"C:/Program Files/KDiff3/bin/kdiff3.exe\"\ngit config --global mergetool.kdiff3.trustExitCode false\n\ngit config --global diff.guitool kdiff3\ngit config --global difftool.kdiff3.path \"C:/Program Files/KDiff3/bin/kdiff3.exe\"\ngit config --global difftool.kdiff3.trustExitCode false\n\nNote that the latest version kdiff3 moved the executable from the root of the application folder C:/Program Files/KDiff3 into the bin/ folder inside the application folder. If you're using an older version, remove \"bin/\" from the paths above.\nThe use of the trustExitCode option depends on what you want to do when diff tool returns. From documentation:\n\ngit-difftool invokes a diff tool individually on each file. Errors reported by the diff tool are ignored by default. Use --trust-exit-code to make git-difftool exit when an invoked diff tool returns a non-zero exit code." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %e" }, { "role": "assistant", "content": "encoding" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to get last Git tag matching regex criteria\nI need Git command to get/find last tag starting with 'v' to get last versioning commit (I am using tags with v letter at the beginning to tag next application version (example: v0.9.1beta).\nIs there any way to do it?" }, { "role": "assistant", "content": "Use the following command:\ngit describe --tags --match=\"v[0-9]*\" HEAD\n\nIt will also modify the version if you did something with the source tree since your last versioned tag.\nNOTE: --match accepts a glob, not a regex, and therefore the command shown may match other tags, e.g. v1234_this_matches_too." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-help - Display help information about Git --no-external-commands" }, { "role": "assistant", "content": "When used with --all , exclude the listing of external \"git-*\"\ncommands found in the $PATH ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What goes into your .gitignore if you're using CocoaPods?\nI've been doing iOS development for a couple of months now and just learned of the promising CocoaPods library for dependency management.\nI tried it out on a personal project: added a dependency to Kiwi to my Podfile, ran pod install CocoaPodsTest.xcodeproj, and voila, it worked great.\nThe only thing I'm left wondering is: what do I check in, and what do I ignore for version control? It seems obvious that I want to check in the Podfile itself, and probably the .xcworkspace file as well; but do I ignore the Pods/ directory? Are there other files that will be generated down the road (when I add other dependencies) that I should also add to my .gitignore?" }, { "role": "assistant", "content": "I commit my Pods directory. I don't agree that the Pods directory is a build artefact. In fact I'd say it most definitely isn't. It's part of your application source: it won't build without it!\nIt's easier to think of CocoaPods as a developer tool rather than a build tool. It doesn't build your project, it simply clones and installs your dependencies for you. It shouldn't be necessary to have CocoaPods installed to be able to simply build your project. \nBy making CocoaPods a dependency of your build, you now need to make sure it's available everywhere you might need to build your project...a team admin needs it, your CI server needs it. You should, as a rule, always be able to clone your source repository and build without any further effort. \nNot committing your Pods directory also creates a massive headache if you frequently switch branches. Now you need to run pod install every time you switch branches to make sure your dependencies are correct. This might be less hassle as your dependencies stabilise but early in a project this is a massive time sink. \nSo, what do I ignore? Nothing. Podfile, the lock file and the Pods directory all get committed. Trust me, it will save you a lot of hassle. What are the cons? A slightly bigger repo? Not the end of the world." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What should Xcode 6 gitignore file include?\nWhat should the typical .gitignore include for Xcode 6?\nAlso for information regarding the xccheckout introduced in Xcode 5 see here" }, { "role": "assistant", "content": "1)\nThe easiest answer is that mine looks like this:\n# Xcode\n.DS_Store\nbuild/\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\n*.xcworkspace\n!default.xcworkspace\nxcuserdata\nprofile\n*.moved-aside\nDerivedData\n.idea/\n# Pods - for those of you who use CocoaPods\nPods\n\nwhich I believe is the same .gitignore that GitHub sets up with all their repositories by default.\n2)\nAnother answer is that there's a website called \"gitignore.io\" , which generates the files based on the .gitignore templates from https://github.com/github/gitignore." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Understanding Gitlab CI tags\nI've read documentation, some articles and you might call me dumb, but this is my first time working with a concept like this.\n\nI've registered runner with tag \"testing\"\ncreated tag \"testing\" in gitlab\nbinded this runner, with particular project \nI've also added the same tag e.g. \"testing\"in my local repo. \n\nBUT how exactly is running my jobs dependent on those tags? Are all these operations necessary? If I push new code to repo, *.yml file is executed anyway as far as I tested.\nSo what if I want to run build only when I define a version in a commit?\nIDK...\n git commit --tags \"v. 2.0\" -m \"this is version 2.0\" (probably not right)\n\nBut of course it should be universal, so I don't have to always tell, which tag to use to trigger the runner, but for example let him recognize numeric values.\nAs you can see, I'm fairly confused... If you could elaborate how exactly tags work, so I would be able to understand the concept, I would be really grateful." }, { "role": "assistant", "content": "Tags for GitLab CI and tags for Git are two different concepts.\nWhen you write your .gitlab-ci.yml, you can specify some jobs with the tag testing. If a runner with this tag associated is available, it will pickup the job.\nIn Git, within your repository, tags are used to mark a specific commit. It is often used to tag a version.\nThe two concepts can be mixed up when you use tags (in Git) to start your pipeline in GitLab CI. In your .gitlab-ci.yml, you can specify the section only with tags.\nRefer to GitLab documentation for tags and only.\nAn example is when you push a tag with git:\n$ git tag -a 1.0.0 -m \"1.0.0\"\n$ git push origin 1.0.0\n\nAnd a job in .gitlab-ci.yml like this:\ncompile:\n stage: build\n only: [tags]\n script:\n - echo Working...\n tags: [testing] \n\nwould start using a runner with the testing tag.\nBy my understanding, what is missing in your steps is to specify the tag testing to your runner. To do this, go in GitLab into your project. Next to\nWiki, click on Settings. Go to CI/CD Pipelines and there you have your runner(s). Next to its Guid, click on the pen icon. On next page the tags can be modified." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git undo local branch delete\nI just deleted the wrong branch with some experimental changes I need with git branch -D branchName.\nHow do I recover the branch?" }, { "role": "assistant", "content": "You can use git reflog to find the SHA1 of the last commit of the branch. From that point, you can recreate a branch using\ngit branch branchName <sha1>\n\nEdit: As @seagullJS says, the branch -D command tells you the sha1, so if you haven't closed the terminal yet it becomes real easy. For example this deletes and then immediately restores a branch named master2:\nuser@MY-PC /C/MyRepo (master)\n$ git branch -D master2\nDeleted branch master2 (was 130d7ba). <-- This is the SHA1 we need to restore it!\n\nuser@MY-PC /C/MyRepo (master)\n$ git branch master2 130d7ba" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --summary" }, { "role": "assistant", "content": "Output a condensed summary of extended header information\nsuch as creations, renames and mode changes." } ]