messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Showing which files have changed between two revisions\nI want to merge two branches that have been separated for a while and wanted to know which files have been modified.\nCame across this link: http://linux.yyz.us/git-howto.html (moved to web.archive.org) which was quite useful.\nThe tools to compare branches I've come across are:\n\ngit diff master..branch\ngit log master..branch\ngit shortlog master..branch\n\nWas wondering if there's something like \"git status master..branch\" to only see those files that are different between the two branches.\nWithout creating a new tool, I think this is the closest you can get to do that now (which of course will show repeats if a file was modified more than once):\n\ngit diff master..branch | grep \"^diff\"\n\nWas wondering if there's something I missed..." }, { "role": "assistant", "content": "To compare the current branch against main branch:\n$ git diff --name-status main\n\nTo compare any two branches:\n$ git diff --name-status firstbranch..yourBranchName\n\nThere is more options to git diff in the official documentation (and specifically --name-status option)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-log" }, { "role": "assistant", "content": "Show commit logs" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Trouble un-ignoring previously ignored files in Git repo\nI have a site that has a /sites/default/files/ directory where user content is typically kept. Figuring that I don't need to be tracking this stuff, I added /sites/default/files/ to my .gitignore file.\nThen I discovered that I also wanted to keep some mostly-permanent uploads in that directory as well. Now it makes more sense to track everything in /sites/default/files/ and exclude undesirable subdirectories, instead of doing it the other way around. \nThe problem is that Git won't stop ignoring that directory. I have removed the lines from .gitignore that specify this directory and it won't track it. I have the option to use git add /sites/default/files/ -f to force git to track the directory, but I've done that before and it seems messy. \nIf .gitignore no longer specifies that directory as ignored, why would I have to force Git to start tracking those files?" }, { "role": "assistant", "content": "You know how to do it already. Yes, git add -f is the way.\nIf you ask why... this is because git set a assume-unchanged bit internally. This bit make git think the file is not modified, so git add won't add it.\nIf you want to mess with the implementation details, you can use git update-index --no-assume-unchanged <file> command." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Tree contains duplicate file entries\nAfter some issues with our hosting, we decided to move our Git repository to GitHub. So I cloned the repository and tried pushing that to GitHub. However, I stumbled upon some errors we have never encountered before:\n C:\\repositories\\appName [master]> git push -u origin master\n Counting objects: 54483, done.\n Delta compression using up to 2 threads.\n Compressing objects: 100% (18430/18430), done.\n error: object 9eac1e639bbf890f4d1d52e04c32d72d5c29082e:contains duplicate file entries\n fatal: Error in object\n fatal: sha1 file '<stdout>' write error: Invalid arguments\n error: failed to push some refs to 'ssh://[email protected]/User/Project.git'\n\nWhen I run fsck:\nC:\\repositories\\appName [master]> git fsck --full\nChecking object directories: 100% (256/256), done.\nerror in tree 0db4b3eb0e0b9e3ee41842229cdc058f01cd9c32: contains duplicate file entries\nerror in tree 9eac1e639bbf890f4d1d52e04c32d72d5c29082e: contains duplicate file entries\nerror in tree 4ff6e424d9dd2e3a004d62c56f99e798ac27e7bf: contains duplicate file entries\nChecking objects: 100% (54581/54581), done.\n\nWhen I run ls-tree with the bad SHA1:\nC:\\repositories\\appName [master]> git ls-tree 9eac1e639bbf890f4d1d52e04c32d72d5c29082e\n160000 commit 5de114491070a2ccc58ae8c8ac4bef61522e0667 MenuBundle\n040000 tree 9965718812098a5680e74d3abbfa26f527d4e1fb MenuBundle\n\nI tried all of the answers already given on this StackOverflow question, but haven't had any success. Is there any way I can prevent this repository and its history from being doomed?" }, { "role": "assistant", "content": "Method 1.\nDo the git fsck first.\n$ git fsck --full\nerror in tree bb81a5af7e9203f36c3201f2736fca77ab7c8f29: contains duplicate file entries\n\nIf this won't fix the problem, you're in trouble.\nYou can either ignore the problem, restore the repository from the backup, or move the files into new repository. If you having trouble pushing the repo into github, try changing the repository to different one or check: Can't push to GitHub error: pack-objects died of signal 13 and Can't push new git repository to github.\n\nThe below methods are only for advanced git users. Please do the backup before starting. The fix is not guaranteed by the following steps and it can make it even worse, so do it for your own risk or education purposes.\n\nMethod 2.\nUse git ls-tree to identify duplicate files.\n$ git read-tree bb81a5af7e9203f36c3201f2736fca77ab7c8f29 # Just a hint.\n$ git ls-tree bb81a5af7e9203f36c3201f2736fca77ab7c8f29 # Try also with: --full-tree -rt -l\n160000 commit def08273a99cc8d965a20a8946f02f8b247eaa66 commerce_coupon_per_user\n100644 blob 89a5293b512e28ffbaac1d66dfa1428d5ae65ce0 commerce_coupon_per_user\n100644 blob 2f527480ce0009dda7766647e36f5e71dc48213b commerce_coupon_per_user\n100644 blob dfdd2a0b740f8cd681a6e7aa0a65a0691d7e6059 commerce_coupon_per_user\n100644 blob 45886c0eda2ef57f92f962670fad331e80658b16 commerce_coupon_per_user\n100644 blob 9f81b5ca62ed86c1a2363a46e1e68da1c7b452ee commerce_coupon_per_user\n\nAs you can see, it contains the duplicated file entries (commerce_coupon_per_user)!\n$ git show bb81a5af7e9203f36c3201f2736fca77ab7c8f29\ntree bb81a5af7e9203f36c3201f2736fca77ab7c8f29\n\ncommerce_coupon_per_user\ncommerce_coupon_per_user\ncommerce_coupon_per_user\ncommerce_coupon_per_user\ncommerce_coupon_per_user\ncommerce_coupon_per_user\n\nAgain, you can see the duplicated file entries (commerce_coupon_per_user)!\nYou may try to use git show for each listed blob and check the content if each file. \nThen keep running ls-tree for that invalid ls-tree object across your different git clones to see if you can track the valid object, or if all are broken.\ngit ls-tree bb81a5af7e9203f36c3201f2736fca77ab7c8f29\n\nIf you found the valid object containing non-duplicated file entries, save it into the file and re-create by using `git mktree` and `git replace`, e.g.\n\nremote$ git ls-tree bb81a5af7e9203f36c3201f2736fca77ab7c8f29 > working_tree.txt\n$ cat working_tree.txt | git mktree\nNEWTREEbb81a5af7e9203f36c3201f2736fca77ab7c8f29\n$ git replace bb81a5af7e9203f36c3201f2736fca77ab7c8f29 NEWTREE4b825dc642cb6eb9a060e54bf8d69288fbee4904\n\nIf this won't help, you can undo the change by:\n$ git replace -d NEWTREE4b825dc642cb6eb9a060e54bf8d69288fbee4904\n\n\nMethod 3.\nWhen you know which file/dir entry is duplicated, you may try to remove that file and re-create it later on. In example:\n$ find . -name commerce_coupon_per_user # Find the duplicate entry.\n$ git rm --cached `find . -name commerce_coupon_per_user` # Add -r for the dir.\n$ git commit -m'Removing invalid git entry for now.' -a\n$ git gc --aggressive --prune # Deletes loose objects! Please do the backup before just in case.\n\nRead more:\n\ngit gc: cleaning up after yourself\n\n\nMethod 4.\nCheck your commit for invalid entries.\nLets check our tree again.\n$ git ls-tree bb81a5af7e9203f36c3201f2736fca77ab7c8f29 --full-tree -rt -l\n160000 commit def08273a99cc8d965a20a8946f02f8b247eaa66 commerce_coupon_per_user\n100644 blob 89a5293b512e28ffbaac1d66dfa1428d5ae65ce0 270 commerce_coupon_per_user\n....\n$ git show def08273a99cc8d965a20a8946f02f8b247eaa66\nfatal: bad object def08273a99cc8d965a20a8946f02f8b247eaa66\n$ git cat-file commit def08273a99cc8d965a20a8946f02f8b247eaa66\nfatal: git cat-file def08273a99cc8d965a20a8946f02f8b247eaa66: bad file\n\nIt seems the above commit is invalid, lets scan our git log for this commit using one of the following commands to check what's going on:\n$ git log -C3 --patch | less +/def08273a99cc8d965a20a8946f02f8b247eaa66\n$ git log -C3 --patch | grep -C10 def08273a99cc8d965a20a8946f02f8b247eaa66\n\ncommit 505446e02c68fe306aec5b0dc2ccb75b274c75a9\nDate: Thu Jul 3 16:06:25 2014 +0100\n\n Added dir.\n\nnew file mode 160000\nindex 0000000..def0827\n--- /dev/null\n+++ b/sandbox/commerce_coupon_per_user\n@@ -0,0 +1 @@\n+Subproject commit def08273a99cc8d965a20a8946f02f8b247eaa66\n\nIn this particular case, our commit points to the bad object, because it was commited as part of git subproject which doesn't exist anymore (check git submodule status).\nYou may exclude that invalid object from the ls-tree and re-create tree without this bad object by e.g.:\n$ git ls-tree bb81a5af7e9203f36c3201f2736fca77ab7c8f29 | grep -v def08273a99cc8d965a20a8946f02f8b247eaa66 | git mktree\nb964946faf34468cb2ee8e2f24794ae1da1ebe20\n\n$ git replace bb81a5af7e9203f36c3201f2736fca77ab7c8f29 b964946faf34468cb2ee8e2f24794ae1da1ebe20\n\n$ git ls-tree bb81a5af7e9203f36c3201f2736fca77ab7c8f29 # Re-test.\n$ git fsck -full\n\nNote: The old object should still throw the duplicate file entries, but if you've now duplicates in the new tree, then you need to remove more stuff from that tree. So:\n$ git replace # List replace objects.\nbb81a5af7e9203f36c3201f2736fca77ab7c8f29\n$ git replace -d bb81a5af7e9203f36c3201f2736fca77ab7c8f29 # Remove previously replaced object.\n\nNow lets try to remove all commits and blobs from that tree, and replace is again:\n$ git ls-tree bb81a5af7e9203f36c3201f2736fca77ab7c8f29 | grep -ve commit -e blob | git mktree\n4b825dc642cb6eb9a060e54bf8d69288fbee4904\n$ git replace bb81a5af7e9203f36c3201f2736fca77ab7c8f29 4b825dc642cb6eb9a060e54bf8d69288fbee4904\n\nNow you have empty tree for that invalid entry. \n$ git status # Check if everything is fine.\n$ git show 4b825dc642cb6eb9a060e54bf8d69288fbee4904 # Re-check\n$ git ls-tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 --full-tree # Re-check\n\nIf you have some weird changes for stage, reset your repository by:\n$ git reset HEAD --hard\n\nIf you'll have the following error:\nHEAD is now at 5a4ed8e Some message at bb81a5af7e9203f36c3201f2736fca77ab7c8f29\n\nDo the rebase and remove that commit (by changing pick to edit):\n$ git rebase -i\n$ git commit -m'Fixed invalid commit.' -a\nrebase in progress; onto 691f725\nYou are currently editing a commit while rebasing branch 'dev' on '691f725'.\n$ git rebase --continue\n$ git reset --hard\n$ git reset HEAD --hard\n$ git reset origin/master --hard\n\n\nMethod 5.\nTry removing and squashing invalid commits containing invalid objects.\n$ git rebase -i HEAD~100 # 100 commits behind HEAD, increase if required.\n\nRead more: Git Tools - Rewriting History and How do I rebase while skipping a particular commit?\n\nMethod 6.\nIdentifying the invalid git objects by the following methods for manual removal:\n\nfor uncompressed objects (*please remove first two characters, as git uses it for the directory name):\n$ find . -name 81a5af7e9203f36c3201f2736fca77ab7c8f29\n\nfor compressed objects\n$ find . -name \\*.idx -exec cat {} \\; | git show-index | grep bb81a5af7e9203f36c3201f2736fca77ab7c8f29\n# Then you need to find the file manually.\n$ git unpack-objects $FILE # Expand the particular file.\n$ git unpack-objects < .git/objects/pack/pack-*.pack # Expand all.\n\n\nSee: How to unpack all objects of a git repository?\n\nRelated:\n\nGit FAQ: How to fix a broken repository?\n[SA] git tree contains duplicate file entries\n[SA] How do you restore a corrupted object in a git repository (for newbies)?\n[SA] How can I manually remove a blob object from a tree in Git?\n[SA] How can I recover my Git repository for a \"missing tree\" error?\n[SA] How to view git objects and index without using git\n[SA] Git recovery: \"object file is empty\". How to recreate trees?\n[SA] Tree contains duplicate file entries\n[SA] git tree (still) contains duplicates and an erroneous signal 13\nOn undoing, fixing, or removing commits in git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-merge - Join two or more development histories together" }, { "role": "assistant", "content": "FAST-FORWARD MERGE Often the current branch head is an ancestor of the named commit.\nThis is the most common case especially when invoked from git\npull : you are tracking an upstream repository, you have committed\nno local changes, and now you want to update to a newer upstream\nrevision. In this case, a new commit is not needed to store the\ncombined history; instead, the HEAD (along with the index) is\nupdated to point at the named commit, without creating an extra\nmerge commit. This behavior can be suppressed with the --no-ff option." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database badTagName" }, { "role": "assistant", "content": "(INFO) A tag has an invalid format." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "setup pre-commit hook jshint\n\nI recently started a project on github.\nI've managed to setup automatic testing after each commit using Travis. But now I would like to setup a pre-commit hook with jshint too. So if jshint reports errors, the commit should fail. But is this possible, and if so, how to do this ?" }, { "role": "assistant", "content": "There's an easier way of doing pre-commit checks (e.g. JSHint) in your Node.js workflow:\nInstall jshint from NPM:\nnpm install jshint\nNext create a .jshintrc file in your project if you don't already have one.\ne.g: https://github.com/nelsonic/learn-jshint/blob/master/.jshintrc\nNow install pre-commit module (and save it as a dev dependency):\nnpm install pre-commit --save-dev\nNext you will need to define the task (script) that will be run for JSHint in your package.json\ne.g: \n{ \"scripts\": { \"jshint\": \"jshint -c .jshintrc --exclude-path .gitignore .\" } }\nthen you register the scripts you want to be run pre-commit (also in package.json) e.g:\n\"pre-commit\": [ \"jshint\", \"coverage\", \"etc\" ]\nThis allows you to have more than just one check in your pre-commit workflow.\n(We have checks to ensure team members code complies with JSHint, Code Style and Test Coverage is 100%)\nFor a more detailed tutorial you can share with your team see: https://github.com/nelsonic/learn-pre-commit" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-checkout - Switch branches or restore working tree files checkout.defaultRemote" }, { "role": "assistant", "content": "When you run git checkout <something> or git switch <something> and only have one\nremote, it may implicitly fall back on checking out and\ntracking e.g. origin/<something> . This stops working as soon\nas you have more than one remote with a <something> reference. This setting allows for setting the name of a\npreferred remote that should always win when it comes to\ndisambiguation. The typical use-case is to set this to origin . Currently this is used by git-switch and git-checkout when git checkout <something> or git switch <something> will checkout the <something> branch on another remote,\nand by git-worktree when git worktree add refers to a\nremote branch. This setting might be used for other checkout-like\ncommands or functionality in the future." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --relative[=<path>] --no-relative" }, { "role": "assistant", "content": "When run from a subdirectory of the project, it can be\ntold to exclude changes outside the directory and show\npathnames relative to it with this option. When you are\nnot in a subdirectory (e.g. in a bare repository), you\ncan name which subdirectory to make the output relative\nto by giving a <path> as an argument. --no-relative can be used to countermand both diff.relative config\noption and previous --relative ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-check-ref-format" }, { "role": "assistant", "content": "Ensures that a reference name is well formed" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker gitprotocol-common" }, { "role": "assistant", "content": "Things common to various protocols" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can anybody push to my project on github?\n\nI set up a repository on GitHub, and I can push local stuff to this remote repository. Can anybody change my repository on GitHub freely? Or if I push something to Linux kernel, are the changes I made added to it and public for all?" }, { "role": "assistant", "content": "No, all repositories are read-only for anonymous users. \nBy default only the owner of the repository has write access. If you can push to your own repo, it's because you are using one of the supported authentification methods (HTTPS, SSH, ...).\nIf you want to grant someone else privileges to push to your repo, you would need to configure that access in the project settings.\nTo contribute to projects in which you don't have push access, you push to your own copy of the repo, then ask for a pull-request. Linux is not a good example for that, because the kernel developers do not use GitHub pull requests." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to refer to a previous commit in git commit message\n\nIs there a convention for referring to a previous commit in a git commit message?\nExample commit message:\nFixed bug such and such introduced in a1b2c3e4\n\nIn particular, is there a convention that github.com will understand, and convert to a link?" }, { "role": "assistant", "content": "Yup - GitHub will pick up references to SHAs and users/repos patterns using the GitHub Flavored Markdown\nSpecifically about linking to commits:\n\nA bit of the GitHub spice\nIn addition to the changes in the previous section, certain references are auto-linked:\n\nSHA: be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2\nUser@SHA ref: mojombo@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2\nUser/Project@SHA: mojombo/god@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2\n#Num: #1\nUser/#Num: mojombo#1\nUser/Project#Num: mojombo/god#1" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order --simplify-merges" }, { "role": "assistant", "content": "Additional option to --full-history to remove some needless\nmerges from the resulting history, as there are no selected\ncommits contributing to this merge." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-apply - Apply a patch to files and/or to the index --allow-binary-replacement --binary" }, { "role": "assistant", "content": "Historically we did not allow binary patch application\nwithout an explicit permission from the user, and this\nflag was the way to do so. Currently, we always allow binary\npatch application, so this is a no-op." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "'git submodule update --init --recursive' VS 'git submodule foreach --recursive git submodule update --init'\nI have git repo which has nested submodules. What is the difference between below 2 commands? \ngit submodule update --init --recursive\n\ngit submodule foreach --recursive git submodule update --init" }, { "role": "assistant", "content": "git submodule update --init --recursive\n\nThe submodule update command will recurse into the registered submodules, update and init (if required) them and any nested submodules within.\ngit submodule foreach --recursive git submodule update --init\n\nforeach will evaluate the command in each checked out submodule. So it will update and init (if required) each submodule and any nested submodules within due to --recursive.\nSo in the end, both commands will achieve the same thing.\nSimply the execution differs, the first command won't step into each directory to execute the command." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git pulling a branch from another repository?\n\nI have a local git repository which is a clone of a repository on github. Someone has forked the repository and made changes in a new branch on a new repository. I want to move this new branch into my repository (locally to work on it first before merging with the master).\nI tried creating a new branch and then pulling from the forked repository but it complains because the new branch is a copy of the master branch as well as the local file changes, so it says \nerror: Your local changes to the following files would be overwritten by merge.\nSo how can I pull the branch in the other repository into a new branch on my local repository?\nI hope that makes sense. If not, this is my repository: https://github.com/MatthewLM/cbitcoin\nAs you can see, someone has created a new repository with the branch \"linuxBuild\": https://github.com/austonst/cbitcoin/tree/linuxBuild\nI want that branch on my local repository for MatthewLM/cbitcoin.\nHow can I do this?" }, { "role": "assistant", "content": "You need to make sure that git status shows that no unstaged changes exist in your local repository.\nYou can do this by first stashing your local changes and than pulling that branch. Afterward you can apply your stash.\n\nIf you want to re-create the branch structure of the fork in your local repository, you can do the following:\ngit remote add fork <url of fork>\ngit fetch fork <branch>\ngit checkout -b fork_branch fork/<branch>\n\nThis will create the local branch fork_branch with the same history like <branch> in the fork, i.e. fork_branch will branch off of your master where <branch> does in the fork.\nAdditionally, your local branch will now track that branch in the fork, so you can easily pull in new changes committed in the fork.\nI think you still need to make sure beforehand that your working copy doesn't contain any changes.\nIf you do not need to track the fork:\ngit remote remove fork" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why doesn't \"git log -‌- foo\" work for deleted file foo?\nMy repository underwent changes such as:\n\n...some unrelated commits...\nCommit new file foo with 100 lines of content\n...intervening commits, some of which touch foo...\nInsert the contents of foo at the top of an existing file bar and git rm foo in the same commit\n...more unrelated commits...\n\nNow I want to see the log of deleted file foo. Everything I've read, including on SO, says I should be able to git log -- foo, but that command produces no output.\nIf I find the commit that includes deleting foo I can git log 1234abcd -- foo and see its log, so I think my path to foo isn't the problem. Also note that git merge-base HEAD 1234abcd outputs 1234abcd[...], so I think that should prove the commit is reachable from HEAD. Note that there is no file foo in my working tree (obvious, since it was deleted). Using Git 1.7.1.1 on OS X.\nWhy doesn't git log -- foo work for me and how can I fix it? Thanks!" }, { "role": "assistant", "content": "You want to use the --follow option on git log, which is described in the man page as:\nContinue listing the history of a file beyond renames.\n\nEffectively, not only does this allow you to see the history of a renamed file, but this also allows you to view the history of a file no longer in the working tree. So the command you should use should look something like:\ngit log --follow -- foo\n\nUpdate:\nGit 2.9+ has now enabled this by default for all git diff and git log commands:\n\nThe end-user facing Porcelain level commands in the \"git diff\" and\n \"git log\" family by default enable the rename detection; you can still\n use \"diff.renames\" configuration variable to disable this.\n\nThanks to x-yuri for the heads up!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters --absolute-git-dir" }, { "role": "assistant", "content": "Like --git-dir , but its output is always the canonicalized\nabsolute path." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options alias.*" }, { "role": "assistant", "content": "Command aliases for the git command wrapper - e.g.\nafter defining alias.last = cat-file commit HEAD , the invocation git last is equivalent to git cat-file commit HEAD . To avoid\nconfusion and troubles with script usage, aliases that\nhide existing Git commands are ignored. Arguments are split by\nspaces, the usual shell quoting and escaping are supported.\nA quote pair or a backslash can be used to quote them. Note that the first word of an alias does not necessarily have to be a\ncommand. It can be a command-line option that will be passed into the\ninvocation of git . In particular, this is useful when used with -c to pass in one-time configurations or -p to force pagination. For example, loud-rebase = -c commit.verbose=true rebase can be defined such that\nrunning git loud-rebase would be equivalent to git -c commit.verbose=true rebase . Also, ps = -p status would be a\nhelpful alias since git ps would paginate the output of git status where the original command does not. If the alias expansion is prefixed with an exclamation point,\nit will be treated as a shell command. For example, defining alias.new = !gitk --all --not ORIG_HEAD , the invocation git new is equivalent to running the shell command gitk --all --not ORIG_HEAD . Note that shell commands will be\nexecuted from the top-level directory of a repository, which may\nnot necessarily be the current directory. GIT_PREFIX is set as returned by running git rev-parse --show-prefix from the original current directory. See git-rev-parse ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "setting tabwidth to 4 in git show / git diff\nAt work we are several developers and don't have a code style guide, and some developers indent with tabs, and some others with 4 spaces (luckily noone of the indent with spaces people uses different than 4 spaces). In general this is no (big) problem because in our editors we set tabwidth=4 and all the indentation seems correct.\nBut in git diff or git show that's what appears:\ndiff --git a/mesclatabs.php b/mesclatabs.php\nnew file mode 100644\nindex 0000000..1986c91\n--- /dev/null\n+++ b/mesclatabs.php\n@@ -0,0 +1,5 @@\n+<?php\n+function foo() {\n+ echo \"line with 1 tab\\n\";\n+ echo \"line with 4 spaces\\n\";\n+}\n\nThe problem is git diff or git show where each tabs appears as wide as 8 spaces (well, in reality appears as a tab, and the shell (bash in my case) is showing the tab as 8 spaces. I suppose there must be some bash config to change this, but I'd like to know if git has an option to output tabs as 4 spaces in diff / show, as some developers work with zsh instead of bash.\nAny ideas?" }, { "role": "assistant", "content": "I believe git config --global core.pager 'less -x1,5'\nReferences:\n\nOriginal: (No longer valid) git-scm chp7-1\nNewer:\n\ngit-config#git-config-corepager\nCustomizing Git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Github: Can I see the number of downloads for a repo?\n\nIn Github, is there a way I can see the number of downloads for a repo?" }, { "role": "assistant", "content": "Update 2019:\nUstin's answer points to:\n\nAPI /repos/:owner/:repo/traffic/clones, to get the total number of clones and breakdown per day or week, but: only for the last 14 days.\nAPI /repos/:owner/:repo/releases/:release_id for getting downloads number of your assets (files attached to the release), field download_count mentioned below, but, as commented, only for the most recent 30 releases..\n\n\nUpdate 2017\nYou still can use the GitHub API to get the download count for your releases (which is not exactly what was asked)\nSee \"Get a single release\", the download_count field.\nThere is no longer a traffic screen mentioning the number of repo clones.\nInstead, you have to rely on third-party services like:\n\nGitItBack (at www.netguru.co/gititback), but even that does not include the number of clones.\n\ngithubstats0, mentioned below by Aveek Saha.\n\nwww.somsubhra.com/github-release-stats (web archive), mentioned below.\nFor instance, here is the number for the latest git for Windows release\n\n\n\n\nUpdate August 2014\nGitHub also proposes the number of clones for repo in its Traffic Graph:\nSee \"Clone Graphs\"\n\n\nUpdate October 2013\nAs mentioned below by andyberry88, and as I detailed last July, GitHub now proposes releases (see its API), which has a download_count field.\nMichele Milidoni, in his (upvoted) answer, does use that field in his python script.\n(very small extract)\nc.setopt(c.URL, 'https://api.github.com/repos/' + full_name + '/releases')\nfor p in myobj:\n if \"assets\" in p:\n for asset in p['assets']:\n print (asset['name'] + \": \" + str(asset['download_count']) +\n \" downloads\")\n\n\nOriginal answer (December 2010)\nI am not sure you can see that information (if it is recorded at all), because I don't see it in the GitHub Repository API:\n$ curl http://github.com/api/v2/yaml/repos/show/schacon/grit\n---\nrepository:\n :name: grit\n :owner: schacon\n :source: mojombo/grit # The original repo at top of the pyramid\n :parent: defunkt/grit # This repo's direct parent\n :description: Grit is a Ruby library for extracting information from a\n git repository in an object oriented manner - this fork tries to\n intergrate as much pure-ruby functionality as possible\n :forks: 4\n :watchers: 67\n :private: false\n :url: http://github.com/schacon/grit\n :fork: true\n :homepage: http://grit.rubyforge.org/\n :has_wiki: true\n :has_issues: false\n :has_downloads: true\n\nYou can only see if it has downloads or not.\n\nAdam Jagosz reports in the comments:\n\nI got it to work with\n curl -H \"Accept: application/vnd.github.v3+json\" https://api.github.com/repos/:user/:repo/releases\n\nA couple of things that I had wrong:\n\nI needed an actual Github release (not just git tag, even though Github does display those under releases, ugh).\nAnd the release needs an asset file other than the zipped source that is added automatically in order to get the download count." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is it possible to use GitHub and GitLab on one machine?\nI have accounts in GitHub and GitLab. I generated and added an RSA key to my account in GitLab, but now I need to work with GitHub on a second project. \nI know that GitLab and GitHub both use git. Please tell me if it's possible to use GitHub and GitLab on one machine?" }, { "role": "assistant", "content": "Yes you can, you can share the same key between them both (ssh key) or create a new one per git server.\nCreate a SSH config file\n\nWhen you have multiple identity files(in your case one for gitlab and one for github) , create a SSH config file to store your various identities.\n\n\nThe format for the alias entries use in this example is:\n\n\nHost alias \n\n\n HostName github.com \n IdentityFile ~/.ssh/identity\n\n\nTo create a config file for two identities (workid and personalid), you would do the following:\n\nOpen a terminal window.\nEdit the ~/.ssh/config file. \n\nIf you don't have a config file, create one.\nAdd an alias for each identity combination for example:\nHost github\nHostName github.com \nIdentityFile ~/.ssh/github\n\nHost gitlab\nHostName gitlab.com \nIdentityFile ~/.ssh/gitlab\n\nThis way you can have as many accounts as you wish each one with a different ssh key attached to it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options http.userAgent" }, { "role": "assistant", "content": "The HTTP USER_AGENT string presented to an HTTP server. The default\nvalue represents the version of the Git client such as git/1.7.1.\nThis option allows you to override this value to a more common value\nsuch as Mozilla/4.0. This may be necessary, for instance, if\nconnecting through a firewall that restricts HTTP connections to a set\nof common USER_AGENT strings (but not including those like git/1.7.1).\nCan be overridden by the GIT_HTTP_USER_AGENT environment variable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git rebase one branch on top of another branch\nIn my git repo, I have a Master branch. One of the remote devs created a branch Branch1 and had a bunch of commits on it. I branched from Branch1, creating a new branch called Branch2 (git checkout -b Branch2 Branch1) such that Branch2 head was on the last commit added to Branch1:(Looks like this)\nMaster---\n \\\n Branch1--commit1--commit2\n \\\n Branch2 (my local branch) \n\nBranch1 has had a number of changes. The other dev squashed his commits and then added a few more commits. Meanwhile, ive had a bunch of changes in my branch but havent committed anything yet. Current structure looks like this:\n Master---\n \\\n Branch1--squashed commit1,2--commit3--commit4\n \\\n Branch2 (my local branch)\n\nNow I want have to rebase my changes on top of Branch1. I am supremely confused on how to go about this. I know the 1st step will be to commit my changes using git add . and git commit -m \"message\". But do i then push? using git push origin Branch2 ? or git push origin Branch2 Branch1 ? Help is much needed and GREATLY appreciated, also if I can some how create a backup of my branch, it will be great in case I screw something up" }, { "role": "assistant", "content": "First backup your current Branch2:\n# from Branch2\ngit checkout -b Branch2_backup\n\nThen rebase Branch2 on Branch1:\n# from Branch2\ngit fetch origin # update all tracking branches, including Branch1\ngit rebase origin/Branch1 # rebase on latest Branch1\n\nAfter the rebase your branch structure should look like this:\nmaster --\n \\\n 1 -- 2 -- 3 -- 4 -- Branch2'\n\nIn the diagram above, the apostrophe on Branch2 indicates that every commit in the rebased Branch2 after commit 4 is actually a rewrite.\nKeep in mind that you have now rewritten the history of Branch2 and if the branch is already published you will have to force push it to the remote via\ngit push --force origin Branch2\n\nForce pushing can cause problems for anyone else using Branch2 so you should be careful when doing this." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-gc - Cleanup unnecessary files and optimize the local repository --quiet" }, { "role": "assistant", "content": "Suppress all progress reports." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Update Git branches from master\nI have four branches (master, b1, b2, and b3). After I worked on b1-b3, I realized I have something to change on branch master that should be in all other branches. I changed what I needed in master and... here is my problem:\nHow do I update all other branches with master branch code?" }, { "role": "assistant", "content": "You have two options:\nThe first is a merge, but this creates an extra commit for the merge. \nCheckout each branch:\ngit checkout b1\n\nThen merge:\ngit merge origin/master\n\nThen push:\ngit push origin b1\n\nAlternatively, you can do a rebase:\ngit fetch\ngit rebase origin/master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-apply - Apply a patch to files and/or to the index" }, { "role": "assistant", "content": "SYNOPSIS git apply [--stat] [--numstat] [--summary] [--check] [--index | --intent-to-add] [--3way]\n\t [--apply] [--no-add] [--build-fake-ancestor=<file>] [-R | --reverse]\n\t [--allow-binary-replacement | --binary] [--reject] [-z]\n\t [-p<n>] [-C<n>] [--inaccurate-eof] [--recount] [--cached]\n\t [--ignore-space-change | --ignore-whitespace]\n\t [--whitespace=(nowarn|warn|fix|error|error-all)]\n\t [--exclude=<path>] [--include=<path>] [--directory=<root>]\n\t [--verbose | --quiet] [--unsafe-paths] [--allow-empty] [<patch>…​]" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "When to use leading slash in gitignore\nI'm trying to understand more clearly the .gitignore syntax, and in particular as far as https://github.com/github/gitignore gitignores are concerned.\nI see that the leading slash is used to match only pathnames relative to the location of the .gitignore file (from http://git-scm.com/docs/gitignore):\n\nA leading slash matches the beginning of the pathname. For example, \"/*.c\" matches \"cat-file.c\" but not \"mozilla-sha1/sha1.c\".\n\nBut what happens when i remove the leading slash? As far as what i understood, there are two cases:\n\nIf the pattern does not contain a slash (or it contains only a trailing slash, which means that it should match a directory), the search is performed inside the entire directory tree. For example, the pattern dir/ will match <root>/dir, <root>/a/dir, <root>/a/b/c/.../dir, etc., where <root> is the location of the .gitignore file.\nIf the pattern contains a slash, which is not in the trailing position (it's not the last character), then it is matched only with pathnames relative to the .gitignore file location.\n\nThese are the examples i made to check this behaviour:\n# Directory structure:\n<root>\n├─ dir/\n│ └─ test\n├─ src/\n│ ├─ dir/\n│ │ └─ test\ntest file is there only because Git does not track empty directories.\n\nFirst test:\n# .gitignore\ndir/\n\n# git status\nnothing to commit\n\nSo Git is ignoring both dir directories. This is consistent with case number 1: the pattern has no slashes (except for the trailing one), so Git is watching the entire directory tree, ignoring everything that matches the pattern.\nSecond test:\n# .gitignore\n/dir/\n\n# git status\nUntracked files:\n src/\n\nHere, Git is ignoring only the dir directory directly beneath the root directory, thanks to the leading slash in the pattern.\nThird test:\n# .gitignore\ndir/*\n\n# git status\nUntracked files:\n src/\n\nThis is consistent with the case number 2: the pattern has some slash inside it, so it is considered as a pathname starting from the root directory.\nNow it's time for the real question. Let's consider this gitignore file: when they ignore the directory downloader/, for example, aren't they actually ignoring every single downloader directory found in the entire directory tree? This is what i'm driven to think since what i saw about Git's workings before.\nSo if i happen to have a custom module with a downloader directory inside of it, will it be unexpectedly ignored as well as the regular one in the root of Magento? This is a bit of a rethorical question because it actually already happened to me, producing a really hard to find bug.\nSo, in the Magento .gitignore file (which i'm referring to only as an example, btw) a lot of the patterns contain slashes, so they are correctly matched against pathnames starting from the root, but there are a few cases, like downloader/ or errors/ that, if i'm not mistaken, are potentially dangerous, and which should probably be changed to /downloader/ and /errors/.\nAs a more general question, should i always use the leading slash for patterns not containing slashes (except for the trailing one) when i want to select a pathname explicitly starting from root, and not to use it for patterns containing slashes, or should i always use the leading slash for clarity? What do you think about it?\nThank you for reading and sorry for the long post." }, { "role": "assistant", "content": "Just wanted to summarize for possible quick future reference -- the leading slash anchors the match to the root. Thus, in the example below, without the slash, the wildcard would also exclude everything within foo because it would take * and move recursively down the tree. However, with /*, it excludes everything except folder foo and its contents:\n$ cat .gitignore\n/*\n!/foo" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker gitfaq" }, { "role": "assistant", "content": "Frequently asked questions about using Git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-reset - Reset current HEAD to the specified state --" }, { "role": "assistant", "content": "Do not interpret any more arguments as options." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gittutorial - A tutorial introduction to Git" }, { "role": "assistant", "content": "Exploring history Git history is represented as a series of interrelated commits. We\nhave already seen that the git log command can list those commits.\nNote that first line of each git log entry also gives a name for the\ncommit: $ git log\ncommit c82a22c39cbc32576f64f5c6b3f24b99ea8149c7\nAuthor: Junio C Hamano <[email protected]>\nDate: Tue May 16 17:18:22 2006 -0700\n\n merge-base: Clarify the comments on post processing. We can give this name to git show to see the details about this\ncommit. $ git show c82a22c39cbc32576f64f5c6b3f24b99ea8149c7 But there are other ways to refer to commits. You can use any initial\npart of the name that is long enough to uniquely identify the commit: $ git show c82a22c39c\t# the first few characters of the name are\n\t\t\t# usually enough\n$ git show HEAD\t\t# the tip of the current branch\n$ git show experimental\t# the tip of the \"experimental\" branch Every commit usually has one \"parent\" commit\nwhich points to the previous state of the project: $ git show HEAD^ # to see the parent of HEAD\n$ git show HEAD^^ # to see the grandparent of HEAD\n$ git show HEAD~4 # to see the great-great grandparent of HEAD Note that merge commits may have more than one parent: $ git show HEAD^1 # show the first parent of HEAD (same as HEAD^)\n$ git show HEAD^2 # show the second parent of HEAD You can also give commits names of your own; after running $ git tag v2.5 1b2e1d63ff you can refer to 1b2e1d63ff by the name v2.5 . If you intend to\nshare this name with other people (for example, to identify a release\nversion), you should create a \"tag\" object, and perhaps sign it; see git-tag for details. Any Git command that needs to know a commit can take any of these\nnames. For example: $ git diff v2.5 HEAD\t # compare the current HEAD to v2.5\n$ git branch stable v2.5 # start a new branch named \"stable\" based\n\t\t\t # at v2.5\n$ git reset --hard HEAD^ # reset your current branch and working\n\t\t\t # directory to its state at HEAD^ Be careful with that last command: in addition to losing any changes\nin the working directory, it will also remove all later commits from\nthis branch. If this branch is the only branch containing those\ncommits, they will be lost. Also, don’t use git reset on a\npublicly-visible branch that other developers pull from, as it will\nforce needless merges on other developers to clean up the history.\nIf you need to undo changes that you have pushed, use git revert instead. The git grep command can search for strings in any version of your\nproject, so $ git grep \"hello\" v2.5 searches for all occurrences of \"hello\" in v2.5 . If you leave out the commit name, git grep will search any of the\nfiles it manages in your current directory. So $ git grep \"hello\" is a quick way to search just the files that are tracked by Git. Many Git commands also take sets of commits, which can be specified\nin a number of ways. Here are some examples with git log : $ git log v2.5..v2.6 # commits between v2.5 and v2.6\n$ git log v2.5.. # commits since v2.5\n$ git log --since=\"2 weeks ago\" # commits from the last 2 weeks\n$ git log v2.5.. Makefile # commits since v2.5 which modify\n\t\t\t\t# Makefile You can also give git log a \"range\" of commits where the first is not\nnecessarily an ancestor of the second; for example, if the tips of\nthe branches stable and master diverged from a common\ncommit some time ago, then $ git log stable..master will list commits made in the master branch but not in the\nstable branch, while $ git log master..stable will show the list of commits made on the stable branch but not\nthe master branch. The git log command has a weakness: it must present commits in a\nlist. When the history has lines of development that diverged and\nthen merged back together, the order in which git log presents\nthose commits is meaningless. Most projects with multiple contributors (such as the Linux kernel,\nor Git itself) have frequent merges, and gitk does a better job of\nvisualizing their history. For example, $ gitk --since=\"2 weeks ago\" drivers/ allows you to browse any commits from the last 2 weeks of commits\nthat modified files under the drivers directory. (Note: you can\nadjust gitk’s fonts by holding down the control key while pressing\n\"-\" or \"+\".) Finally, most commands that take filenames will optionally allow you\nto precede any filename by a commit, to specify a particular version\nof the file: $ git diff v2.5:Makefile HEAD:Makefile.in You can also use git show to see any such file: $ git show v2.5:Makefile" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to close a branch WITHOUT removing it from history in git?\nI'd like to make a commit and close its branch, without removing it from history.\nWith mercurial I'd commit --close-branch, then update to a previous one, and go on working. With git... I'm confused." }, { "role": "assistant", "content": "There's no exact equivalent to closing a branch in Git, because Git branches are more lightweight than in Mercurial. Their Mercurial equivalent is more bookmarks than branches. \nIf I understand correctly, closing a branch in Mercurial roughly makes it disappear from the branch list, so you can achieve the same thing by archiving it. A usual practice is to tag its tip as archive, and delete it:\ngit tag archive/<branchname> <branchname>\ngit branch -d <branchname>\ngit checkout master\n\nThe branch will be deleted, and can be retrieved later by checking out the tag, and recreating the branch:\ngit checkout archive/<branchname>\ngit checkout -b new_branch_name" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %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": "git-apply - Apply a patch to files and/or to the index --reject" }, { "role": "assistant", "content": "For atomicity, git apply by default fails the whole patch and\ndoes not touch the working tree when some of the hunks\ndo not apply. This option makes it apply\nthe parts of the patch that are applicable, and leave the\nrejected hunks in corresponding *.rej files." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to check the differences between a local and GitHub repository before the pull [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\ngit diff between cloned and original remote repository\n\n (3 answers)\n \n\nClosed 10 years ago.\n\n\n\nBefore using pull, I want to check if there are any differences between my local and GitHub master.\nHow can I do it?" }, { "role": "assistant", "content": "git pull is really equivalent to running git fetch and then git merge. The git fetch updates your so-called \"remote-tracking branches\" - typically these are ones that look like origin/master, github/experiment, etc. that you see with git branch -r. These are like a cache of the state of branches in the remote repository that are updated when you do git fetch (or a successful git push).\nSo, suppose you've got a remote called origin that refers to your GitHub repository, you would do:\ngit fetch origin\n\n... and then do:\ngit diff master origin/master\n\n... in order to see the difference between your master, and the one on GitHub. If you're happy with those differences, you can merge them in with git merge origin/master, assuming master is your current branch.\nPersonally, I think that doing git fetch and git merge separately is generally a good idea." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git show files that were changed in the last 2 days\nHow can I have a list with all the files that were changed in the last 2 days? I know about \ngit log --name-status --since=\"2 days ago\" \n\nbut this will show me ids, dates and commit messages. All I need is the list of the file names which were changed.\nIs that possible with git?" }, { "role": "assistant", "content": "git log --pretty=format: --name-only --since=\"2 days ago\"\n\nif some files duplicate in multiple commits, you can use pipe to filter it\ngit log --pretty=format: --name-only --since=\"2 days ago\" | sort | uniq" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database --cache" }, { "role": "assistant", "content": "Consider any object recorded in the index also as a head node for\nan unreachability trace." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --dense" }, { "role": "assistant", "content": "Only the selected commits are shown, plus some to have a\nmeaningful history." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub - List commits by author\nIs there any way on GitHub to list all commits made by a single author, in the browser (neither locally, e.g. via git log, nor via the API)?\nClicking on a user name in the list of commits (Commit History) simply leads to that user's profile page. Examining the GitHub UI and searching (Google, StackOverflow) does not reveal a way to do this." }, { "role": "assistant", "content": "If the author has a GitHub account, just click the author's username from anywhere in the commit history, and the commits you can see will be filtered down to those by that author:\n\nYou can also click the 'n commits' link below their name on the repo's \"contributors\" page:\n\nAlternatively, you can directly append ?author=<theusername> or ?author=<emailaddress> to the URL. For example, https://github.com/jquery/jquery/commits/master?author=dmethvin or https://github.com/jquery/jquery/commits/[email protected] both give me:\n\nFor authors without a GitHub account, only filtering by email address will work, and you will need to manually add ?author=<emailaddress> to the URL - the author's name will not be clickable from the commits list.\n\nYou can also get the list of commits by a particular author from the command line using\ngit log --author=[your git name]\n\nExample:\ngit log --author=Prem" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options gui.displayUntracked" }, { "role": "assistant", "content": "Determines if git-gui shows untracked files\nin the file list. The default is \"true\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "warning: refname 'HEAD' is ambiguous\nI am new to Git and I seem to have one branch too many if I execute the following command:\nwarning: refname 'HEAD' is ambiguous.\n\nI get the following output:\nwarning: refname 'HEAD' is ambiguous.\nFrom github.com:dagda1/hornget\n * branch master -> FETCH_HEAD\nwarning: refname 'HEAD' is ambiguous.\nwarning: refname 'HEAD' is ambiguous.\n\nIf I execute git branch -a\nI get the following:\nHEAD\n* master\nremotes/emmekappa/master\nremotes/origin/HEAD -> origin/master\nremotes/origin/master\n\nI am confused by the remotes/origin/HEAD -> origin/master.\nWhat is this and how can I get rid of the ambiguous branch.\nI got to this stage by performing a merge where I think I added the ambiguous branch." }, { "role": "assistant", "content": "The problem is that you have a branch called HEAD which is absolutely dangerous, since that's the symbolic name for whatever branch is the current branch.\nRename it:\ngit branch -m HEAD newbranch\n\nthen you can examine it and decide what to do (delete it, or save under a descriptive branch name)\n(The origin/HEAD remote branch is not a problem)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-add" }, { "role": "assistant", "content": "Add file contents to the index" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Show history of a file? [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\nClosed 11 years ago.\n\n\n\n\nPossible Duplicate:\nView the change history of a file using Git versioning \n\nSometimes I want to step through the history of a particular file. In the past I used P4V and this was very quick and intuitive. \n\nRight click on a file and select history.\nScrolling through the dates and see a nice diff of exactly what changed in that file on that date. Simple.\n\nSwitching to git this is now a grueling task. \n\n\"git log filename\"\nLook at history and pick a date, copy hash\n\"git diff hash\"\nScroll through diff for the stuff that changed in the file I am interested in.\nNope, that's not it, lets try a different date - back to step 2, rinse and repeat.\n\nI've searched SO, and I've tried a few of the commonly suggested guis: github, gitk, gitg, git-gui.\nThese all remove the need to manually run commands, but the workflow is the same for this. View history of file; view commit; search through diff of lots of irrelevant files. It's slow and repetitive.\nAll the data is in the repo so I see no reason this simple common use case could not be more streamlined.\nCan anyone recommend a tool that does this - or a more efficient way to utilize the command line to do what I want?\nThanks for any suggestions." }, { "role": "assistant", "content": "You can use git log to display the diffs while searching:\ngit log -p -- path/to/file" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git rebase: conflicts keep blocking progress\nI have a git branch (called v4), that was made from master just yesterday. There were a couple of changes to master, that I want to get into v4. So, in v4, I tried to do a rebase from master, and one file keeps screwing things up: a one-line text file, that contains the version number. This file is app/views/common/version.txt, which before rebasing contains this text:\nv1.4-alpha-02\n\nHere's what I'm doing:\n> git rebase master\nFirst, rewinding head to replay your work on top of it...\nApplying: new version, new branch\nerror: patch failed: app/views/common/version.txt:1\nerror: app/views/common/version.txt: patch does not apply\nUsing index info to reconstruct a base tree...\nFalling back to patching base and 3-way merge...\nAuto-merging app/views/common/version.txt\nCONFLICT (content): Merge conflict in app/views/common/version.txt\nFailed to merge in the changes.\nPatch failed at 0001 new version, new branch\n\nWhen you have resolved this problem run \"git rebase --continue\".\nIf you would prefer to skip this patch, instead run \"git rebase --skip\".\nTo restore the original branch and stop rebasing run \"git rebase --abort\".\n\nThe version.txt now looks like this:\n<<<<<<< HEAD:app/views/common/version.txt\nv1.4-alpha-02\n=======\nv1.4-alpha-01\n>>>>>>> new version, new branch:app/views/common/version.txt\n\nSo, I tidy it up and it looks like this now:\nv1.4-alpha-02\n\nand then I tried to carry on: at first I try a commit:\n> git commit -a -m \"merged\"\n# Not currently on any branch.\nnothing to commit (working directory clean)\n\nNo luck there. So, I was trying to add the file:\ngit add app/views/common/version.txt\n\nNo response. No news is good news, I guess. So, I try to continue:\n> git rebase --continue\nApplying: new version, new branch\nNo changes - did you forget to use 'git add'?\n\nWhen you have resolved this problem run \"git rebase --continue\".\nIf you would prefer to skip this patch, instead run \"git rebase --skip\".\nTo restore the original branch and stop rebasing run \"git rebase --abort\".\n\nIt's at this point, after going round and round with this, that I'm banging my head off the desk. \nWhat's going on here? What am I doing wrong? Can anyone set me straight?\nEDIT - for unutbu\nI changed the file as you suggested and get the same error:\n> git rebase master\nFirst, rewinding head to replay your work on top of it...\nApplying: new version, new branch\nerror: patch failed: app/views/common/version.txt:1\nerror: app/views/common/version.txt: patch does not apply\nUsing index info to reconstruct a base tree...\nFalling back to patching base and 3-way merge...\nAuto-merging app/views/common/version.txt\nCONFLICT (content): Merge conflict in app/views/common/version.txt\nFailed to merge in the changes.\nPatch failed at 0001 new version, new branch\n\nWhen you have resolved this problem run \"git rebase --continue\".\nIf you would prefer to skip this patch, instead run \"git rebase --skip\".\nTo restore the original branch and stop rebasing run \"git rebase --abort\"." }, { "role": "assistant", "content": "I encountered a similar problem with a rebase. My problem was caused because one of my commit only changed a file, and when resolving, I discarded the change introduced in this commit. I was able to solve my problem by skipping the corresponding commit (git rebase --skip).\nYou can reproduce this problem in a test repository. First create the repository.\n$ mkdir failing-merge\n$ cd failing-merge\n$ git init\nInitialized empty Git repository in $HOME/failing-merge/.git/\n\nThen commit the original content of version.txt in master.\n$ echo v1.4-alpha-02 > version.txt\n$ git add version.txt\n$ git commit -m initial\n[master (root-commit) 2eef0a5] initial\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 version.txt\n\nCreate the v4 branch and change the content of version.txt.\n$ git checkout -b v4\nSwitched to a new branch 'v4'\n$ echo v1.4-alpha-03 > version.txt\n$ git add version.txt\n$ git commit -m v4\n[v4 1ef8c9b] v4\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\nGo back to master and change the content of version.txt so that there will be a conflit during the rebase.\n$ git checkout master\nSwitched to branch 'master'\n$ echo v1.4-alpha-04 > version.txt\n$ git add version.txt\n$ git commit -m master\n[master 7313eb3] master\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\nSwitch back to v4 branch and try to rebase. It fails with a conflit in version.txt as planned.\n$ git checkout v4\nSwitched to branch 'v4'\n$ git rebase master\nFirst, rewinding head to replay your work on top of it...\nApplying: v4\nUsing index info to reconstruct a base tree...\nFalling back to patching base and 3-way merge...\nAuto-merging version.txt\nCONFLICT (content): Merge conflict in version.txt\nRecorded preimage for 'version.txt'\nFailed to merge in the changes.\nPatch failed at 0001 v4\n\nWhen you have resolved this problem run \"git rebase --continue\".\nIf you would prefer to skip this patch, instead run \"git rebase --skip\".\nTo restore the original branch and stop rebasing run \"git rebase --abort\".\n$ cat version.txt\n<<<<<<< HEAD\nv1.4-alpha-04\n=======\nv1.4-alpha-03\n>>>>>>> v4\n\nWe resolve the conflict by selecting the master content of version.txt. We add the file and try to continue our rebase.\n$ echo v1.4-alpha-04 > version.txt\n$ git add version.txt\n$ git rebase --continue \nApplying: v4\nNo changes - did you forget to use 'git add'?\nIf there is nothing left to stage, chances are that something else\nalready introduced the same changes; you might want to skip this patch.\n\nWhen you have resolved this problem run \"git rebase --continue\".\nIf you would prefer to skip this patch, instead run \"git rebase --skip\".\nTo restore the original branch and stop rebasing run \"git rebase --abort\".\n\nIt fails ! Let's see what changes git think there is in our repository.\n$ git status\n# Not currently on any branch.\nnothing to commit (working directory clean)\n\nAh ah, there is no change. If you read in detail the previous error message, git informed us of this and recommended to use git rebase --skip. He told us \"If there is nothing left to stage, chances are that something else already introduced the same changes; you might want to skip this patch.\" So we just skip the commit and the rebase succeed.\n$ git rebase --skip\nHEAD is now at 7313eb3 master\n\n\nWord of caution: Please note that git rebase --skip will completely drop the commit that git tried to rebase. In our case, this should be okay since git is complaining this is an empty commit. If you think you've lost changes once the rebase is complete, you can use git reflog to get the commit id of your repository before the rebase, and use git reset --hard to get your depot back in that state (this is another destructive operation)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-update-index - Register file contents in the working tree to the index --ignore-submodules" }, { "role": "assistant", "content": "Do not try to update submodules. This option is only respected\nwhen passed before --refresh." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why does git think my .sql file is a binary file?\nI have some .sql files that I just for the first time pushed to github. However when I look at the commit it is saying:\nBIN  WebRole/Sql/Database.sql View\nBinary file not shown\n\nCan someone tell me why it's saying \"Binary file not shown\"" }, { "role": "assistant", "content": "The extension alone isn't enough to GitHub to see if it is a text file.\nSo it has to look at its content.\nAnd as mentioned in \"Why does Git treat this text file as a binary file?\", its content might not include enough ascii character to guess it is text file.\nYou can use a .gitattributes file to explicitly specify a .sql should be a text, not a binary.\n*.sql diff\n\n\nUpdate 2018: as I mention in \"Utf-8 encoding not working on utf-8 encoded document\", Git 2.18 .gitattributes has a new working-tree-encoding attribute.\nSo, as shown in Rusi's answer:\n*.sql text working-tree-encoding=UTF-16LE eol=CRLF\n\n\nAs kostix adds in the comments:\n\nif these files are generated by the Microsoft SQL Management Studio (or whatever it's called in the version of MS SQL Server's management tools you're using), the files it saves are encoded in UCS-2 (or UTF-16) -- a two-byte encoding, which is indeed not text in the eyes of Git\n\nYou can see an example in \"Git says “Binary files a… and b… differ” on for *.reg files\"\nAs mentioned in \"Set file as non-binary in git\":\n\n\"Why is Git marking my file as binary?\" The answer is because it's seeing a NUL (0) byte somewhere within the first 8000 characters of the file.\n Typically, that happens because the file is being saved as something other than UTF-8. So, it's likely being saved as UCS-2, UCS-4, UTF-16, or UTF-32. All of those have embedded NUL characters when using ASCII characters\n\n\nAs Neo mentions in the comments (and in Why does Git treat this text file as a binary file?):\n\nYou can change the encoding of a saved file in SSMS to UTF-8 by selecting encoding 'UTF-8 with signature' from the 'Advanced Save Options' menu item in the File menu." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs" }, { "role": "assistant", "content": "Combined diff format Any diff-generating command can take the -c or --cc option to\nproduce a combined diff when showing a merge. This is the default\nformat when showing merges with git-diff or git-show . Note also that you can give suitable --diff-merges option to any of these commands to force generation of\ndiffs in a specific format. A \"combined diff\" format looks like this: diff --combined describe.c\nindex fabadb8,cc95eb0..4866510\n--- a/describe.c\n+++ b/describe.c\n@@@ -98,20 -98,12 +98,20 @@@\n\treturn (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;\n }\n\n- static void describe(char *arg)\n -static void describe(struct commit *cmit, int last_one)\n++static void describe(char *arg, int last_one)\n {\n +\tunsigned char sha1[20];\n +\tstruct commit *cmit;\n\tstruct commit_list *list;\n\tstatic int initialized = 0;\n\tstruct commit_name *n;\n\n +\tif (get_sha1(arg, sha1) < 0)\n +\t\tusage(describe_usage);\n +\tcmit = lookup_commit_reference(sha1);\n +\tif (!cmit)\n +\t\tusage(describe_usage);\n +\n\tif (!initialized) {\n\t\tinitialized = 1;\n\t\tfor_each_ref(get_name); It is preceded by a \"git diff\" header, that looks like\nthis (when the -c option is used): diff --combined file or like this (when the --cc option is used): diff --cc file It is followed by one or more extended header lines\n(this example shows a merge with two parents): index <hash>,<hash>..<hash>\nmode <mode>,<mode>..<mode>\nnew file mode <mode>\ndeleted file mode <mode>,<mode> The mode <mode>,<mode>..<mode> line appears only if at least one of\nthe <mode> is different from the rest. Extended headers with\ninformation about detected content movement (renames and\ncopying detection) are designed to work with the diff of two\n<tree-ish> and are not used by combined diff format. It is followed by a two-line from-file/to-file header: --- a/file\n+++ b/file Similar to the two-line header for the traditional unified diff\nformat, /dev/null is used to signal created or deleted\nfiles. However, if the --combined-all-paths option is provided, instead of a\ntwo-line from-file/to-file, you get an N+1 line from-file/to-file header,\nwhere N is the number of parents in the merge commit: --- a/file\n--- a/file\n--- a/file\n+++ b/file This extended format can be useful if rename or copy detection is\nactive, to allow you to see the original name of the file in different\nparents. Chunk header format is modified to prevent people from\naccidentally feeding it to patch -p1 . Combined diff format\nwas created for review of merge commit changes, and was not\nmeant to be applied. The change is similar to the change in the\nextended index header: @@@ <from-file-range> <from-file-range> <to-file-range> @@@ There are (number of parents + 1) @ characters in the chunk\nheader for combined diff format. Unlike the traditional unified diff format, which shows two\nfiles A and B with a single column that has - (minus — appears in A but removed in B), + (plus — missing in A but\nadded to B), or \" \" (space — unchanged) prefix, this format\ncompares two or more files file1, file2,…​ with one file X, and\nshows how X differs from each of fileN. One column for each of\nfileN is prepended to the output line to note how X’s line is\ndifferent from it. A - character in the column N means that the line appears in\nfileN but it does not appear in the result. A + character\nin the column N means that the line appears in the result,\nand fileN does not have that line (in other words, the line was\nadded, from the point of view of that parent). In the above example output, the function signature was changed\nfrom both files (hence two - removals from both file1 and\nfile2, plus ++ to mean one line that was added does not appear\nin either file1 or file2). Also, eight other lines are the same\nfrom file1 but do not appear in file2 (hence prefixed with + ). When shown by git diff-tree -c , it compares the parents of a\nmerge commit with the merge result (i.e. file1..fileN are the\nparents). When shown by git diff-files -c , it compares the\ntwo unresolved merge parents with the working tree file\n(i.e. file1 is stage 2 aka \"our version\", file2 is stage 3 aka\n\"their version\")." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Solution. How to install_github when there is a proxy\n\nWhen you try to install some package of R from GitHub's repository\ninstall_github('rWBclimate', 'ropensci')\n\nIf you have the following error:\nInstalling github repo(s) rWBclimate/master from ropensci\nDownloading rWBclimate.zip from https://github.com/ropensci/rWBclimate/archive/master.zip\nError in function (type, msg, asError = TRUE) :\nCould not resolve host: github.com; Host not found, try again\n\nThis error is displayed because R is trying to access on Intenet through a proxy." }, { "role": "assistant", "content": "SOLUTION\nStep 1. Install devtools packages \nif (!require(\"devtools\")) install.packages(\"devtools\")\nlibrary(devtools)\n\nStep 2. Set configuration for our proxy (Please update your information proxy)\nlibrary(httr)\nset_config(\n use_proxy(url=\"18.91.12.23\", port=8080, username=\"user\",password=\"password\")\n)\ninstall_github('rWBclimate', 'ropensci')" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I remove files saying \"old mode 100755 new mode 100644\" from unstaged changes in Git?\nFor some reason, when I initially did a pull from the repository for a git project of mine,\nI got a ton of files in my working copy that have no discernible changes made to them, but keep showing up in my unstaged changes area. \nI'm using Git Gui on Windows xp, and when I go to look at the file to see what has changed.\nAll I see is:\nold mode 100755 \nnew mode 100644 \n\nDoes anyone know what this means? \nHow can I get these files out of my list of unstaged changes? (Very annoying to have to go through 100's of files, just to pick out files I've recently edited and want to commit)." }, { "role": "assistant", "content": "That looks like unix file permissions modes to me (755=rwxr-xr-x, 644=rw-r--r--) - the old mode included the +x (executable) flag, the new mode doesn't.\nThis msysgit issue's replies suggests setting core.filemode to false in order to get rid of the issue:\ngit config core.filemode false" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-filter-branch - Rewrite branches <rev-list options>…​" }, { "role": "assistant", "content": "Arguments for git rev-list . All positive refs included by\nthese options are rewritten. You may also specify options\nsuch as --all , but you must use -- to separate them from\nthe git filter-branch options. Implies Remap to ancestor ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-remote - Manage set of tracked repositories" }, { "role": "assistant", "content": "NAME git-remote - Manage set of tracked repositories" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc 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": "Error with git rebase (\"could not apply...\")\nI'm the administrator of the GitHub repository https://github.com/plison/opendial. I would like to reduce the number of commits on the repository, since the repository already has a few thousand commits, many of whom are minor debugging changes that could easily be squashed together (especially the ones that are a few years old).\nI'm therefore trying to apply rebasing in order to squash together part of my commits. However, I've experience the following issue:\n\nWhen I type e.g. git rebase -i HEAD~10, I get a quite long number of commit lines (much more than 10) in the interactive editor. What could be the reason?\nMore importantly, once I close the interactive editor to start the rebasing, I systematically get the error message \"error:could not apply ', even when I do not make any change to the commits (i.e. if I leave all lines as 'pick', without any modification or reordering).\n\nHow can I solve these issues? It should be noted that the repository was automatically imported from a previous (SVN) repository hosted on Google Code. The conversion seemed so far to have worked well, but I'm wondering why I get these errors when trying to rebase my commits." }, { "role": "assistant", "content": "As a reminder to myself on how to resolve this:\nThe error message is not very informative. If you type \ngit rebase --continue\n\nyou realize the error is because of a merge conflict that git cannot resolve by itself, and needs your help.\nTo see what files have conflicts, type\ngit status\n\nResolve the merge conflicts in your favorite editor/IDE (hint: this should start with i and end with ntelliJ)\nMark resolution with \ngit add .\n\nIf all the conflicts are resolved, you should see something like this:\n(all conflicts fixed: run \"git rebase --continue\")\n\nSo continue your rebase with \ngit rebase --continue\n\nHopefully your rebase should now be successful\ngit status\n\nshows:\nOn branch feature/DIG-19302-Upgrade-mockito-v2\nYour branch is behind 'origin/feature/your-feature-branch' by 2 commits, and can be fast-forwarded.\n(use \"git pull\" to update your local branch)\n\nnothing to commit, working directory clean\n\nDon't do a git pull. If you do, you will only overwrite your merge conflicts. Instead push your merge conflict resolutions to the branch) with \ngit push --force\n\nYou're done! Your git log should show only 1 commit now (which is the forced update you just did)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Set an environment variable in git bash\nWhen I punch from the windows gitbash command line:\nset $HOME = c\n\nand do :\necho $HOME\n\nIt does not set it to c? How can I change/set the value of an environment variable?" }, { "role": "assistant", "content": "A normal variable is set by simply assigning it a value; note that no whitespace is allowed around the =:\nHOME=c\n\nAn environment variable is a regular variable that has been marked for export to the environment.\nexport HOME\nHOME=c\n\nYou can combine the assignment with the export statement.\nexport HOME=c" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Migrate gitlab to gogs\n\nRecently, i found a Gitlab alternative called Gogs.\nAny suggestion for migrating repo in Gitlab to Gogs? I m not expecting all of it of course, just as much as possible." }, { "role": "assistant", "content": "The correct steps for mirroring a repo is:\n\n$ git clone --mirror [email protected]/upstream-repository.git\n $ cd upstream-repository.git\n $ git push --mirror [email protected]/new-location.git\n\nNote: Do not use git push --mirror if you did not clone the repo with git clone --mirror. Also, git clone --mirror is preferred over git clone --bare as it will clone all git notes and attributes as well.\nReference: http://blog.plataformatec.com.br/2013/05/how-to-properly-mirror-a-git-repository/" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Cannot remove remote origin\nI'm running git 1.8.0 on OS X, and every new git repo seems to have a remote called \"origin\":\n$ git init\n$ git remote\norigin\n\nWhat's odd is that I can't remove it:\n$ git remote remove origin\nerror: Could not remove config section 'remote.origin'\n\nAnd therefore I can't add a new remote called origin. Why is this? What can I do to change it?" }, { "role": "assistant", "content": "You should be able to remove origin with\ngit remote rm origin\n\nNot that you need to, you can just change the origin with set-url\ngit remote set-url origin \"https://...\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: Needed a single revision error\nI initialized a new git in my project and I have only two commits so far. My log is like below\ngit log\ncommit e515e5b8dcbd8f1ea4a7a7d4a1efb82a1a0aee7a\nAuthor: Olkun Mustafa <[email protected]>\nDate: Fri Oct 3 10:04:20 2014 +0300\n\n Temp commit\n\ncommit 71781bf0a7807351a56d5155dac94169ea700527\nAuthor: Olkun Mustafa <[email protected]>\nDate: Fri Oct 3 10:01:42 2014 +0300\n\n First Commit\n\nWhen I try to rebase this commits I get error like below\ngit rebase --interactive HEAD~2\nfatal: Needed a single revision\ninvalid upstream HEAD~2\n\nI quite research at google but I haven't found solution till now." }, { "role": "assistant", "content": "In your case, there is no HEAD~2, since you only have 2 commits, hence the \"Needed a single revision\" error message.\nTry:\n git rebase -i --root\n\nsee more about --root at \"Change first commit of project with Git?\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054\nI'm having trouble cloning a repo on git. I've been trying for to days and have tried quite a few solutions (in most the problem was slightly different but seemed to apply) but nothing has done anything to make a difference.\nI've tried switching off the anti-virus and firewall but that didn't help.\nI've also tried uninstalling and reinstalling the network adapter drivers (and restarting the computer) and that didn't work.\nFrom what I understand it's a network issue somewhere as the remote server keeps hanging up but I'm not managing to get anywhere with the issue.\nUsing git clone -v --progress seemed to give the same output as git clone.\nOutput from git clone -v --progress https://github.com/mit-cml/appinventor-sources.git\n\nCloning into 'appinventor-sources'...\n POST git-upload-pack (gzip 1425 to 774 bytes)\n remote: Counting objects: 41649, done.\n remote: Compressing objects: 100% (7/7), done.\n error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054\n fatal: The remote end hung up unexpectedly\n fatal: early EOF\n fatal: index-pack failed \n\nI've now tried increasing the buffer again \n\ngit config --global http.postBuffer 1048576000\n\nbut still nothing.\nI'm following the solution from The remote end hung up unexpectedly while git cloning for troubleshooting." }, { "role": "assistant", "content": "I resolved the same problem by this:\ngit config http.postBuffer 524288000\n\nIt might be because of the large size of the repository and the default buffer size of git so by doing above (on git bash), git buffer size will be increased." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --patience" }, { "role": "assistant", "content": "Generate a diff using the \"patience diff\" algorithm." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Github graphQL OrderBy\n\nI have a GraphQL query.\nI cannot understand why it is not working.\n{\n repositoryOwner(login: \"Naramsim\") {\n login\n repositories(first: 3, isFork: true, orderBy: {field: CREATED_AT}) {\n edges {\n node {\n description\n }\n }\n }\n }\n}\n\nLink" }, { "role": "assistant", "content": "You've got an error\nArgument 'orderBy' on Field 'repositories' has an invalid value.\nExpected type 'RepositoryOrder'.\n\nYou forget to specify direction which is marked as mandatory. This will work:\n{\n repositoryOwner(login: \"Naramsim\") {\n login\n repositories(first: 3, isFork: true, orderBy: {field: CREATED_AT, direction: ASC}) {\n edges {\n node {\n description\n }\n }\n }\n }\n}" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database nulInHeader" }, { "role": "assistant", "content": "(FATAL) NUL byte exists in the object header." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git how to give people push access that needs to be merged in by organizers?\n\nMy project has quite a few people and I want to give them all push & pull access because right now, they forked the project and when they make changes, they have to push to their fork and send me a pull request. Instead, I want them to be able to clone the main project at myusername/project and be able to push to it automatically.\nSo how would I do that?" }, { "role": "assistant", "content": "Ask for the username of the person you're adding as a collaborator. If they don't have one, they can sign up for GitHub.\nIn the top right corner of any page, click your username.\nOn your profile page, click the Repositories tab, then click the name of your repository.\nIn your repository's right sidebar, click Settings.\nClick the \"Collaborators\" tab.\nStart typing the collaborator's username.\nSelect the user from the drop-down menu.\nClick Add." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Windows git: Fatal: TaskCanceledException encountered\nI have recently updated my git (2.7.4.windows.1). Since then pulling from github produces output like this:\n$ git pull --rebase\nFatal: TaskCanceledException encountered.\nCurrent branch ABC-123_Something is up to date.\n\nThe Fatal: TaskCanceledException encountered. appears after a boring 20 seconds and then everything works out just fine. I haven't found anything on the net and I would like to avoid wasting that 20 seconds over and over again." }, { "role": "assistant", "content": "None of the above helped me... So my fix is to remove manager helper from git's system config:\ngit config --system --unset credential.helper\n\nIf you got permission denied, invoke above command after running cmd as administrator." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Resetting remote to a certain commit\nI want to discard all changes done after commit <commit-hash> .\nSo I did:\ngit reset --hard <commit-hash>\n\nNow I want to do the same with my remote. How can I do this? I have done some commits (and pushes) after <commit-hash> and I just want to discard them all. Is just something went terribly wrong in the way and I don't want to make it worse than it is already. ;(\nI basically want to rewind my origin/master to <commit-hash>" }, { "role": "assistant", "content": "Assuming that your branch is called master both here and remotely, and that your remote is called origin you could do:\n git reset --hard <commit-hash>\n git push -f origin master\n\nHowever, you should avoid doing this if anyone else is working with your remote repository and has pulled your changes. In that case, it would be better to revert the commits that you don't want, then push as normal.\nUpdate: you've explained below that other people have pulled the changes that you've pushed, so it's better to create a new commit that reverts all of those changes. There's a nice explanation of your options for doing this in this answer from Jakub Narębski. Which one is most convenient depends on how many commits you want to revert, and which method makes most sense to you.\nSince from your question it's clear that you have already used git reset --hard to reset your master branch, you may need to start by using git reset --hard ORIG_HEAD to move your branch back to where it was before. (As always with git reset --hard, make sure that git status is clean, that you're on the right branch and that you're aware of git reflog as a tool to recover apparently lost commits.) You should also check that ORIG_HEAD points to the right commit, with git show ORIG_HEAD.\nTroubleshooting:\nIf you get a message like \"! [remote rejected] a60f7d85 -> master (pre-receive hook declined)\" \nthen you have to allow branch history rewriting for the specific branch. In BitBucket for example it said \"Rewriting branch history is not allowed\". There is a checkbox named Allow rewriting branch history which you have to check." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-clone - Clone a repository into a new directory --shallow-exclude= <revision>" }, { "role": "assistant", "content": "Create a shallow clone with a history, excluding commits\nreachable from a specified remote branch or tag. This option\ncan be specified multiple times." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository" }, { "role": "assistant", "content": "NAME git-fetch - Download objects and refs from another repository" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rm - Remove files from the working tree and from the index --sparse" }, { "role": "assistant", "content": "Allow updating index entries outside of the sparse-checkout cone.\nNormally, git rm refuses to update index entries whose paths do\nnot fit within the sparse-checkout cone. See git-sparse-checkout for more." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can I create a github repository named the same as one that existed but was deleted?\n\nThrough the github web interface I created a new repository. I forgot to chose some options at creation time and thought I'd delete the new, empty repository and start again.\nI deleted the repository but now cannot create a new repository with the same name as one that was deleted. I get a 'Name already exists on this account' error when I try.\nI don't know if this is a permanent matter (i.e. I can never create a new repository named the same as one that has been deleted) or just a temporary matter perhaps due to some information being cached which will later be cleared.\nCan I create a github repository named the same as one that existed but was deleted?" }, { "role": "assistant", "content": "You certainly should be able to create a new one with the same name. I'm fairly sure I've done this before.\nI'd leave it for 5/10 minutes and try again if I were you." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-bundle - Move objects and refs by archive" }, { "role": "assistant", "content": "EXAMPLES Assume you want to transfer the history from a repository R1 on machine A\nto another repository R2 on machine B.\nFor whatever reason, direct connection between A and B is not allowed,\nbut we can move data from A to B via some mechanism (CD, email, etc.).\nWe want to update R2 with development made on the branch master in R1. To bootstrap the process, you can first create a bundle that does not have\nany prerequisites. You can use a tag to remember up to what commit you last\nprocessed, in order to make it easy to later update the other repository\nwith an incremental bundle: machineA$ cd R1\nmachineA$ git bundle create file.bundle master\nmachineA$ git tag -f lastR2bundle master Then you transfer file.bundle to the target machine B. Because this\nbundle does not require any existing object to be extracted, you can\ncreate a new repository on machine B by cloning from it: machineB$ git clone -b master /home/me/tmp/file.bundle R2 This will define a remote called \"origin\" in the resulting repository that\nlets you fetch and pull from the bundle. The $GIT_DIR/config file in R2 will\nhave an entry like this: [remote \"origin\"]\n url = /home/me/tmp/file.bundle\n fetch = refs/heads/*:refs/remotes/origin/* To update the resulting mine.git repository, you can fetch or pull after\nreplacing the bundle stored at /home/me/tmp/file.bundle with incremental\nupdates. After working some more in the original repository, you can create an\nincremental bundle to update the other repository: machineA$ cd R1\nmachineA$ git bundle create file.bundle lastR2bundle..master\nmachineA$ git tag -f lastR2bundle master You then transfer the bundle to the other machine to replace\n/home/me/tmp/file.bundle, and pull from it. machineB$ cd R2\nmachineB$ git pull If you know up to what commit the intended recipient repository should\nhave the necessary objects, you can use that knowledge to specify the\nprerequisites, giving a cut-off point to limit the revisions and objects that go\nin the resulting bundle. The previous example used the lastR2bundle tag\nfor this purpose, but you can use any other options that you would give to\nthe git-log command. Here are more examples: You can use a tag that is present in both: $ git bundle create mybundle v1.0.0..master You can use a prerequisite based on time: $ git bundle create mybundle --since=10.days master You can use the number of commits: $ git bundle create mybundle -10 master You can run git-bundle verify to see if you can extract from a bundle\nthat was created with a prerequisite: $ git bundle verify mybundle This will list what commits you must have in order to extract from the\nbundle and will error out if you do not have them. A bundle from a recipient repository’s point of view is just like a\nregular repository which it fetches or pulls from. You can, for example, map\nreferences when fetching: $ git fetch mybundle master:localRef You can also see what references it offers: $ git ls-remote mybundle" } ]
[ { "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": "other diff formats The --summary option describes newly added, deleted, renamed and\ncopied files. The --stat option adds diffstat(1) graph to the\noutput. These options can be combined with other options, such as -p , and are meant for human consumption. When showing a change that involves a rename or a copy, --stat output\nformats the pathnames compactly by combining common prefix and suffix of\nthe pathnames. For example, a change that moves arch/i386/Makefile to arch/x86/Makefile while modifying 4 lines will be shown like this: arch/{i386 => x86}/Makefile | 4 +-- The --numstat option gives the diffstat(1) information but is designed\nfor easier machine consumption. An entry in --numstat output looks\nlike this: 1\t2\tREADME\n3\t1\tarch/{i386 => x86}/Makefile That is, from left to right: the number of added lines; a tab; the number of deleted lines; a tab; pathname (possibly with rename/copy information); a newline. When -z output option is in effect, the output is formatted this way: 1\t2\tREADME NUL\n3\t1\tNUL arch/i386/Makefile NUL arch/x86/Makefile NUL That is: the number of added lines; a tab; the number of deleted lines; a tab; a NUL (only exists if renamed/copied); pathname in preimage; a NUL (only exists if renamed/copied); pathname in postimage (only exists if renamed/copied); a NUL. The extra NUL before the preimage path in renamed case is to allow\nscripts that read the output to tell if the current record being read is\na single-path record or a rename/copy record without reading ahead.\nAfter reading added and deleted lines, reading up to NUL would yield\nthe pathname, but if that is NUL , the record will show two paths." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the difference between push.default \"matching\" and \"simple\"\nI have been using Git for a while now, but I have never had to set up a new remote repo myself, and I have been curious to do so. I have been reading tutorials and I am confused on how to get git push to work.\nIf I simply use git push, it asks me to see up a \"default branch\" to point to. What is the difference between these two options it supplies me with?\ngit config --global push.default matching\ngit config --global push.default simple\n\nThe matching option just pushes whatever branches I have on my local repo, and if they don't match I have to then manually tell it to push whatever new local branches I have, correct? Is this best practice to use or is simple best?" }, { "role": "assistant", "content": "git push can push all branches or a single one dependent on this configuration:\nPush all branches\ngit config --global push.default matching\n\nIt will push all the branches to the remote branch and would merge them.\nIf you don't want to push all branches, you can push the current branch if you fully specify its name, but this is much is not different from default.\nPush only the current branch if its named upstream is identical\ngit config --global push.default simple\n\nSo, it's better, in my opinion, to use this option and push your code branch by branch. It's better to push branches manually and individually." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git push to remote branch\nFolks,\nI had cloned a repo. I created a branch out of it to work on a feature by issuing the following command:\ngit branch fix78\nthen I worked on that branch by \ngit checkout fix78\nI continued to make commits to this local branch. Now I wanted to push this to the repo and hence I issued the following command:\ngit push origin master:fix78\nI viewed the repo from a web browser and saw that a new branch called fix78 was created on the repo. But it did not have any of my commits that I had made.\nWhat am I doing wrong here? This is what I am trying to achieve:\nThere is a repo(master(trunk in the SVN lingo)), now when I am working on a feature I want to create a local branch of it and then I also want to check in this branch to the repo(so that other team members can see what I am working on), then I want my local branch to be in sync with this remote branch that I create. \nAny help/feedback would be totally awesome.\nThanks." }, { "role": "assistant", "content": "git push origin master:fix78 pushes the local master to a remote branch called fix78. You wanted to push the local branch fix78, which has the same syntax but without the master:\nYou can fix it by doing git push origin :fix78 to delete the remote branch and then git push origin fix78 to push your local branch to the remote repo." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "github link to wiki page from README\n\nHow do I create a link from a README.md file to a Wiki page in github? Every example seems to show linking from one wiki page to another wiki page, or from one README file to another file in the repository. But none that show linking from one to the other" }, { "role": "assistant", "content": "I just came across this question and saw that this was impossible, but stubbornly kept trying anyway. Good news, because this actually can be done with relative links!\nIf you look at the documentation for relative links on GitHub, you can see that it supports ./ and ../ operands.\nGiven that your README is located at:\nhttps://github.com/<user-name>/<repo-name>/blob/master/README.md\n... and the wiki is located at:\nhttps://github.com/<user-name>/<repo-name>/wiki\n... that means you can just crawl back from the README to the wiki, like so:\n[My Awesome Wiki](../../wiki)\n\nUpdate: As some people have pointed out in the comments (thanks!), please be aware that these relative links will break on clones and forks, so be sure to weigh that into your decision!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Github Commit Syntax to Link a Pull Request/ Issue\nI've seen commit messages that refer to a specific issue / pull request. What is the syntax to include a specific repository's issue or pull request?" }, { "role": "assistant", "content": "Use the documented auto-linking format for issues across repositories.\n\nSyntax: {owner}/{repository}#{issue_number}\nExample: mojombo/jekyll#1\n\nWhen such formatted text is present in a commit message, it's automatically transformed into a clickable link which will redirect one to https://github.com/{owner}/{repository}/issues/{issue_number}" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-describe - Give an object a human readable name based on an available ref --dirty[=<mark>] --broken[=<mark>]" }, { "role": "assistant", "content": "Describe the state of the working tree. When the working\ntree matches HEAD, the output is the same as \"git describe\nHEAD\". If the working tree has local modification \"-dirty\"\nis appended to it. If a repository is corrupt and Git\ncannot determine if there is local modification, Git will\nerror out, unless ‘--broken’ is given, which appends\nthe suffix \"-broken\" instead." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Break a previous commit into multiple commits\nWithout creating a branch and doing a bunch of funky work on a new branch, is it possible to break a single commit into a few different commits after it's been committed to the local repository?" }, { "role": "assistant", "content": "git rebase -i will do it.\nFirst, start with a clean working directory: git status should show no pending modifications, deletions, or additions.\nNow, you have to decide which commit(s) you want to split.\nA) Splitting the most recent commit\nTo split apart your most recent commit, first:\n$ git reset HEAD~\n\nNow commit the pieces individually in the usual way, producing as many commits as you need.\nB) Splitting a commit farther back\nThis requires rebasing, that is, rewriting history. To specify the correct commit, you have several choices:\n\nIf it is three commits back, then\n $ git rebase -i HEAD~3\n\nwhere 3 is how many commits back it is.\n\nIf it is farther back in the tree than you want to count, then\n $ git rebase -i 123abcd~\n\nwhere 123abcd is the SHA1 of the commit you want to split up.\n\nIf you want to rebase the entire current branch simply do:\n $ git rebase -i\n\n\nIf you are on a different branch (e.g., a feature branch) that you want to merge into master:\n $ git rebase -i master\n\n\n\nWhen you get the rebase edit screen, find the commit you want to break apart. At the beginning of that line, replace pick with edit (e for short). Save the buffer and exit. Rebase will now stop just after the commit you want to edit. Then:\n$ git reset HEAD~\n\nCommit the pieces individually in the usual way, producing as many commits as you need.\nFinally\n$ git rebase --continue\n\nIf you want to preserve authorship\nIf you want to preserve the authorship of commits, and possibly the date as well, see copy author and date from other commit, but _not_ the message" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options uploadpackfilter.tree.maxDepth" }, { "role": "assistant", "content": "Only allow --filter=tree:<n> when <n> is no more than the value of uploadpackfilter.tree.maxDepth . If set, this also implies uploadpackfilter.tree.allow=true , unless this configuration\nvariable had already been set. Has no effect if unset." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I merge a pull request on someone else's project in git?\n\nI cloned this repo on my computer: https://github.com/derobins/wmd.git\nThere are several bugs with it though, and it looks like another user has fixed them and issued \"Pull requests\" (I assume these are requests for their changes to be committed?)\nIs it possible to merge those changes into my local version?\nEDIT: just to be clear, this is not my repository. I am using the WMD editor from derobins, but it has several bugs which those pull requests purport to fix. I have cloned the repo on Ubuntu (not in github) and was hoping to merge those changes in if possible." }, { "role": "assistant", "content": "(GitHub has very thorough documentation on how to deal with pull requests.)\nEssentially, you'll want to add a remote for the repository of the person who made the pull requests, e.g.:\ngit remote add helpful git://github.com/helpful-person/whatever.git\n\n... then fetch their changes into remote-tracking branches:\ngit fetch helpful\n\n... so that now you have all the commits from that person's GitHub repository in your clone of the upstream repository. If you look at the additional commits within that pull request you could:\n\nmerge the latest one, e.g. git merge 75708aeab5\ncherry pick each of those changes, e.g. git cherry-pick 2142db89, git cherry-pick 75708aeab5\ncreate a local branch to work on them further, e.g. git checkout -b fix-for-issue3 75708aeab5\netc. etc.\n\nAn alternative is to just clone the repository of the contributor who made the pull requests instead, if that's the same but for those fixes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options checkout.workers" }, { "role": "assistant", "content": "The number of parallel workers to use when updating the working tree.\nThe default is one, i.e. sequential execution. If set to a value less\nthan one, Git will use as many workers as the number of logical cores\navailable. This setting and checkout.thresholdForParallelism affect\nall commands that perform checkout. E.g. checkout, clone, reset,\nsparse-checkout, etc. Note: Parallel checkout usually delivers better performance for repositories\nlocated on SSDs or over NFS. For repositories on spinning disks and/or machines\nwith a small number of cores, the default sequential checkout often performs\nbetter. The size and compression level of a repository might also influence how\nwell the parallel version performs." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission" }, { "role": "assistant", "content": "MUA-SPECIFIC HINTS Here are some hints on how to successfully submit patches inline using\nvarious mailers. GMail GMail does not have any way to turn off line wrapping in the web\ninterface, so it will mangle any emails that you send. You can however\nuse \"git send-email\" and send your patches through the GMail SMTP server, or\nuse any IMAP email client to connect to the google IMAP server and forward\nthe emails through that. For hints on using git send-email to send your patches through the\nGMail SMTP server, see the EXAMPLE section of git-send-email . For hints on submission using the IMAP interface, see the EXAMPLE\nsection of git-imap-send . Thunderbird By default, Thunderbird will both wrap emails as well as flag\nthem as being format=flowed , both of which will make the\nresulting email unusable by Git. There are three different approaches: use an add-on to turn off line wraps,\nconfigure Thunderbird to not mangle patches, or use\nan external editor to keep Thunderbird from mangling the patches. Approach #1 (add-on) Install the Toggle Word Wrap add-on that is available from https://addons.mozilla.org/thunderbird/addon/toggle-word-wrap/ It adds a menu entry \"Enable Word Wrap\" in the composer’s \"Options\" menu\nthat you can tick off. Now you can compose the message as you otherwise do\n(cut + paste, git format-patch | git imap-send , etc), but you have to\ninsert line breaks manually in any text that you type. Approach #2 (configuration) Three steps: Configure your mail server composition as plain text:\nEdit…​Account Settings…​Composition & Addressing,\nuncheck \"Compose Messages in HTML\". Configure your general composition window to not wrap. In Thunderbird 2:\nEdit..Preferences..Composition, wrap plain text messages at 0 In Thunderbird 3:\nEdit..Preferences..Advanced..Config Editor. Search for\n\"mail.wrap_long_lines\".\nToggle it to make sure it is set to false . Also, search for\n\"mailnews.wraplength\" and set the value to 0. Disable the use of format=flowed:\nEdit..Preferences..Advanced..Config Editor. Search for\n\"mailnews.send_plaintext_flowed\".\nToggle it to make sure it is set to false . After that is done, you should be able to compose email as you\notherwise would (cut + paste, git format-patch | git imap-send , etc),\nand the patches will not be mangled. Approach #3 (external editor) The following Thunderbird extensions are needed:\nAboutConfig from https://mjg.github.io/AboutConfig/ and\nExternal Editor from https://globs.org/articles.php?lng=en&pg=8 Prepare the patch as a text file using your method of choice. Before opening a compose window, use Edit→Account Settings to\nuncheck the \"Compose messages in HTML format\" setting in the\n\"Composition & Addressing\" panel of the account to be used to\nsend the patch. In the main Thunderbird window, before you open the compose\nwindow for the patch, use Tools→about:config to set the\nfollowing to the indicated values: mailnews.send_plaintext_flowed => false\n\tmailnews.wraplength => 0 Open a compose window and click the external editor icon. In the external editor window, read in the patch file and exit\nthe editor normally. Side note: it may be possible to do step 2 with\nabout:config and the following settings but no one’s tried yet. mail.html_compose => false\n\tmail.identity.default.compose_html => false\n\tmail.identity.id?.compose_html => false There is a script in contrib/thunderbird-patch-inline which can help\nyou include patches with Thunderbird in an easy way. To use it, do the\nsteps above and then use the script as the external editor. KMail This should help you to submit patches inline using KMail. Prepare the patch as a text file. Click on New Mail. Go under \"Options\" in the Composer window and be sure that\n\"Word wrap\" is not set. Use Message → Insert file…​ and insert the patch. Back in the compose window: add whatever other text you wish to the\nmessage, complete the addressing and subject fields, and press send." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options notes.rewriteRef" }, { "role": "assistant", "content": "When copying notes during a rewrite, specifies the (fully\nqualified) ref whose notes should be copied. May be a glob,\nin which case notes in all matching refs will be copied. You\nmay also specify this configuration several times. Does not have a default value; you must configure this variable to\nenable note rewriting. Set it to refs/notes/commits to enable\nrewriting for the default commit notes. Can be overridden with the GIT_NOTES_REWRITE_REF environment variable.\nSee notes.rewrite.<command> above for a further description of its format." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Edit in configuration file of gitlab and bitbuket by git\n\nI can edit in the configuration file that contains the username,password and github email using git with \ngit config --global -e \n\nOR\ngit config --global --edit\n\nor in the .gitconfig file \nHow can I edit the gitlab and bitbucket config files to contain a username, password, and email, and then where do I save it in Windows?" }, { "role": "assistant", "content": "I don't know where that configuration is, but all you need to do in Windows is make sure you have set the right credential helper to cache your credentials:\ngit config --global credential.helper manager\n\nThen, at the first push, you will be prompted for your GitLab username/password.\nOnce entered, they will be cached in the Windows Credential Manager, and never asked for directly again." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I force \"git pull\" to overwrite local files?\nHow do I force an overwrite of local files on a git pull? My local repository contains a file of the same filename as on the server.\n\nerror: Untracked working tree file 'example.txt' would be overwritten by merge" }, { "role": "assistant", "content": "⚠ Warning:\nAny uncommitted local change to tracked files will be lost, even if staged.\nBut any local file that's not tracked by Git will not be affected.\n\n\nFirst, update all origin/<branch> refs to latest:\ngit fetch --all\n\nBackup your current branch (e.g. master):\ngit branch backup-master\n\nJump to the latest commit on origin/master and checkout those files:\ngit reset --hard origin/master\n\nExplanation:\ngit fetch downloads the latest from remote without trying to merge or rebase anything.\ngit reset resets the master branch to what you just fetched. The --hard option changes all the files in your working tree to match the files in origin/master.\n\nMaintain current local commits\n[*]: It's worth noting that it is possible to maintain current local commits by creating a branch from master before resetting:\ngit checkout master\ngit branch new-branch-to-save-current-commits\ngit fetch --all\ngit reset --hard origin/master\n\nAfter this, all of the old commits will be kept in new-branch-to-save-current-commits.\nUncommitted changes\nUncommitted changes, even if staged (with git add), will be lost. Make sure to stash or commit anything you need. For example, run the following:\ngit stash\n\nAnd later (after git reset), reapply these uncommitted changes:\ngit stash pop\n\n\nWhich may create merge conflicts." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Does the GitHub traffic graph include your own views?\n\nI have several projects on GitHub, and they all have the traffic graph where I can view how much traffic my repository is getting.\nThe blog post I had linked is very vague about visitors. It states:\n\n..how many unique visitors it's had..\n\nI just find it odd that some of my repositories have daily activity, but I'm not sure if most of those views are me, and if they are, why does it say \"unique visitors\" when i would be the only unique visitor\nQuestion:\nDoes the traffic graph used on GitHub include yourself when navigating through your own source? It's very minor, but I'm genuinely curious if the views I'm getting is myself navigating through the source, or if I have people that are actually browsing through my source.\nIn specific, the line that shows \"Views\", not \"Unique visitors\" because unique visitors will obviously mean new people browsing the repository.\n\nFor those who think this is offtopic, re-read the on-topic post.\nMost notably:\n\nbut if your question generally covers… software tools commonly used by programmers" }, { "role": "assistant", "content": "OK I just contacted support and received a response:\n\nHello -\n> Do the numbers in the traffic graphs include your own views? What about the view of contributors?\nThanks for getting in touch! Yes, the numbers include everyone's\n views including repository owners and contributors. There's no way to\n filter this information at the moment, but I can definitely add that\n as a feature request for the team to consider.\nHope that answers your question - thanks!\n\nSo it does include your own views, but they might add the option to filter it later." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -0" }, { "role": "assistant", "content": "Omit diff output for unmerged entries and just show\n\"Unmerged\". Can be used only when comparing the working tree\nwith the index." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs dimmed-zebra" }, { "role": "assistant", "content": "Similar to zebra , but additional dimming of uninteresting parts\nof moved code is performed. The bordering lines of two adjacent\nblocks are considered interesting, the rest is uninteresting. dimmed_zebra is a deprecated synonym." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to create a Git attributes file\nI would like to add an attributes file to my Git repository as described here. It indicates that I should include .gitattributes in the root folder of my repository.\n\nIs .gitattributes simply a file or is it a folder ? How do I create this file/folder ? \nWindows raises the following errors :\n\n\"Can't create a file without a filename\"\n\n\n\n\"You must type a filename\"\n\nWhere should one add the file ? Under the repository root, X:\\PATH\\TO\\Repository\\, or the Git folder, X:\\PATH\\TO\\Repository\\.git\\ ?\nWill the attributes be enforced for other contributors cloning/forking my repository ?\ne.g. If I pushed to GitHub or GitLab and some other party pulled down a copy would the attributes I added be enforced upon their machine as well ?\n\nRelated : Git Ignore\nNote : I'm using TortoiseGit and msysgit on a Windows platform if it helps." }, { "role": "assistant", "content": "Is .gitattributes a file or a folder ? How do I create it ?\n\nWindows : Create a new text file (Right click>new>text file) within windows explorer and rename it (Shortcut : F2) as follows\n.gitattributes.\n\n\n\nNote : That is DOT + gitattributes + DOT, windows will remove the trailing DOT for you producing the appropriate filename\n\nUnix : and it's variants (Ubuntu, Raspberrian, Mac OS etc.)\ntouch .gitattributes\n\n\nAlternatively : Clone the Git Attributes repository and move/copy the .gitattributes file that is applicable to your repository (Footnote 1 and 2).\n\n\nWhere should one add the file ? Under the repository root, X:\\PATH\\TO\\Repository\\, or the Git folder, X:\\PATH\\TO\\Repository\\.git\\ ?\nThere are two locations where one can add the Git attributes file\n \\Repository (1)\n \\Repository\\.git\\info\\attributes (2)\n\n\nAdding a .gitattributes file here sets the attributes \"Universally\".\nCreating the .gitattributes file here sets the attributes \"Personally\", that is the repository upon one's own machine. While inadvisable you may a have good reason for doing so .\n\nWill the attributes be enforced for other contributors cloning/forking my repository ?\nProvided the file is committed to the repository, it will be cloned when the repository is cloned and the attributes enforced upon the machines of the the contributors of ones project accordingly (Footnote : 3 and 4).\nAttributes are applied \"Globally \" when .gitattributes is added to the project root, X:\\PATH\\TO\\Repository\\.gitattributes, and \"Locally\" when added to some sub-folder, X:\\PATH\\TO\\Repository\\SOME\\SUB-FOLDER\\.gitattributes.\n\n**Footnote(s) :**\n\nSome care must be taken if you are using Large File Storage (Git LFS) as these files may not be LFS aware or vice versa. Additionally LFS will create .gitattributes for you when you setup tracking.\nCoincidentally there is also repository for Git Ignore.\nInitially, when I first asked the question, I was concerned about the correct treatment of line endings; .gitattributes handles this well but it is better for each contributor to configure git properly upon their own machines.\nDon't be the idiot that adds .gitattributes to the .gitignore file. Yes this will apply the attributes \"Personally\" but some one will overwrite your workaround \"Globally\" one day and there will be tears and hugging... a lot of hugging !!!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Push error: refusing to update checked out branch\nI have solved some merge conflicts, committed then tried to Push my changes and received the following error:\nc:\\Program Files (x86)\\Git\\bin\\git.exe push --recurse-submodules=check \"origin\" master:master\nDone\nremote: error: refusing to update checked out branch: refs/heads/master\nremote: error: By default, updating the current branch in a non-bare repository\nremote: error: is denied, because it will make the index and work tree inconsistent\nremote: error: with what you pushed, and will require 'git reset --hard' to match\nremote: error: the work tree to HEAD.\nremote: error: \nremote: error: You can set 'receive.denyCurrentBranch' configuration variable to\nremote: error: 'ignore' or 'warn' in the remote repository to allow pushing into\nremote: error: its current branch; however, this is not recommended unless you\nremote: error: arranged to update its work tree to match what you pushed in some\nremote: error: other way.\nremote: error: \nremote: error: To squelch this message and still keep the default behaviour, set\nremote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.\nTo C:/Development/GIT_Repo/Project\n ! [remote rejected] master -> master (branch is currently checked out)\nerror: failed to push some refs to 'C:/Development/GIT_Repo/Project'\n\nDoes anyone know what could be causing this error?" }, { "role": "assistant", "content": "Reason:You are pushing to a Non-Bare Repository\nThere are two types of repositories: bare and non-bare\nBare repositories do not have a working copy and you can push to them. Those are the types of repositories you get in Github! If you want to create a bare repository, you can use\ngit init --bare\n\nSo, in short, you can't push to a non-bare repository (Edit: Well, you can't push to the currently checked out branch of a repository. With a bare repository, you can push to any branch since none are checked out. Although possible, pushing to non-bare repositories is not common). What you can do, is to fetch and merge from the other repository. This is how the pull request that you can see in Github works. You ask them to pull from you, and you don't force-push into them.\n\nUpdate: Thanks to VonC for pointing this out, in the latest git versions (currently 2.3.0), pushing to the checked out branch of a non-bare repository is possible. Nevertheless, you still cannot push to a dirty working tree, which is not a safe operation anyway." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to list files ignored by git that are currently staged or committed?\nHow does one get a list of those files that match a rule in .gitignore file, but that have been staged or committed in the past?" }, { "role": "assistant", "content": "The documentation to ls-files is not exactly clearly written, but it appears that the following simple alias does the job:\ngit config --global alias.showtrackedignored \"ls-files -i --exclude-standard\"\n\nThe above command creates an alias called showtrackedignored. To use, run:\ngit showtrackedignored\n\nand it will list all of the files in the current directory and subdirectories that are tracked but would be ignored if they weren't tracked.\nBug in git ls-files\nUnfortunately, this doesn't work 100% reliably. Apparently Git does a good job of finding files that should not be ignored, but when searching for files that are ignored (the -i option to git ls-files), it doesn't list ignored files inside a directory if it's the directory that matches the ignore rules.\nTo work around this bug, try converting your ignore rules so that only files are matched, not directories (this isn't always possible).\n(Thank you Christoph for discovering this bug and reporting it to the Git mailing list! Edit: A patch is in the works now and will make it into git 1.7.11.2 or later)\nAlternative approach\nHere's a different approach. It's far more complicated and might have broken corner cases.\ngit config --global alias.showtrackedignored '!\ncd \"${GIT_PREFIX}\" &&\nuntracked_list=$(git rev-parse --git-dir)/ignored-untracked.txt &&\ngit ls-files -o -i --exclude-standard >\"${untracked_list}\" &&\nGIT_INDEX_FILE=\"\" git ls-files -o -i --exclude-standard | grep -Fvxf \"${untracked_list}\" &&\nrm -rf \"${untracked_list}\"'\n\nThe alias does the following:\n\ncd back to the directory where git showtrackedignored was run from (Git runs shell-based aliases from the toplevel directory, not the current directory; see the section on alias.* in git help config)\nDefine a variable called untracked_list. This variable holds the path to a temporary file that will contain the list of currently ignored files. This temporary file is in the .git directory.\nWrite the list of ignored files to ${untracked_list}.\nTell Git to act as if the index is empty and list all the ignored files.\nPipe that output to grep, which filters out the files that were written to ${untracked_list}.\nDelete the temporary file ${untracked_list}.\n\nDrawbacks to this approach:\n\nIt creates a temporary file in your .git directory.\nIt assumes you have a POSIX-compatible shell.\nIt assumes you have a POSIX-compatible implementation of grep.\n\nIt also suffers from the same bug as the former alias." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options ignoredHook" }, { "role": "assistant", "content": "Shown when a hook is ignored because the hook is not\nset as executable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-branch - List, create, or delete branches" }, { "role": "assistant", "content": "SYNOPSIS git branch [--color[=<when>] | --no-color] [--show-current]\n\t[-v [--abbrev=<n> | --no-abbrev]]\n\t[--column[=<options>] | --no-column] [--sort=<key>]\n\t[--merged [<commit>]] [--no-merged [<commit>]]\n\t[--contains [<commit>]] [--no-contains [<commit>]]\n\t[--points-at <object>] [--format=<format>]\n\t[(-r | --remotes) | (-a | --all)]\n\t[--list] [<pattern>…​] git branch [--track[=(direct|inherit)] | --no-track] [-f]\n\t[--recurse-submodules] <branchname> [<start-point>] git branch (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>] git branch --unset-upstream [<branchname>] git branch (-m | -M) [<oldbranch>] <newbranch> git branch (-c | -C) [<oldbranch>] <newbranch> git branch (-d | -D) [-r] <branchname>…​ git branch --edit-description [<branchname>]" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-shortlog - Summarize git log output --grep-reflog=<pattern>" }, { "role": "assistant", "content": "Limit the commits output to ones with reflog entries that\nmatch the specified pattern (regular expression). With\nmore than one --grep-reflog , commits whose reflog message\nmatches any of the given patterns are chosen. It is an\nerror to use this option unless --walk-reflogs is in use." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git rebase fatal: Needed a single revision invalid upstream –i\nI am trying to squanshing several commits together. When I used\ngit rebase –i HEAD~8\n\nI got a fatal:\nfatal: Needed a single revision\ninvalid upstream –i\n\nHere is a part of commit logs:\ngit log\nAll of the commits history of the corresponding Github repository is here:\nhttps://github.com/yikouniao/YukiLog/commits/master\nEdit1:\nWhen I used git rebase –i HEAD~2, I got the same result.\nEdit2:\nI didn't know I had modified the file.gitconfig, editor = notepad2 was add to the file. After I removed editor = notepad2, everything is OK. Then I rebased and squanshed 8 commits successfully." }, { "role": "assistant", "content": "Several options:\n\nYou are not on a branch (Detached head) or maybe you are trying to rebase or the wrong branch.\nCheckout the branch you want to rebase and try again.\n\nyou don't have 8 commits in your history (you have 7 or less)\n\ntry: git rebase -i --root\n\n\nHere is the documentation for the --root flag and why it will work for you.\n--root\nRebase all commits reachable from <branch>, instead of limiting them with\nan <upstream>.This allows you to rebase the root commit(s) on a branch. \nWhen used with --onto, it will skip changes already contained in `<newbase>` \n(instead of `<upstream>`) whereas without --onto it will operate on every \nchange. When used together with both --onto and --preserve-merges, all root \ncommits will be rewritten to have `<newbase>` as parent instead.`" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --oneline" }, { "role": "assistant", "content": "This is a shorthand for \"--pretty=oneline --abbrev-commit\"\nused together." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: simplest way of squashing commits on master [duplicate]\nThis question already has answers here:\n \n \n\n\n\nClosed 12 years ago.\n\n\n\n\nPossible Duplicate:\nHow can I squash my last X commits together using git? \n\nI have a project hosted on GitHub and I have a local clone. I have a load of small commits that I have already pushed up to GitHub. This has all been done using the default *master branch.\nI got confused between merge --squash and rebase etc...\nWhat is the most straightforward way of combining several historial commits in to one commit so that it pushes up to GitHub?" }, { "role": "assistant", "content": "Before starting, you should make sure that git status is clean (i.e. there's no output from that command) to avoid losing work. The simplest way to do what you want is probably:\ngit reset --soft <LAST-COMMIT-THAT'S-OK>\ngit commit -m 'Many squashed commits'\ngit push --force origin master\n\nYou should bear in mind that this is rewriting history (that's why you need the --force option to git push) so you should avoid this if anyone else might have cloned or pulled from your repository. For some more alternatives, see this question and its answers:\n\nSquash my last X commits together using Git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "how to download single folder OR file in gitlab repository\n\ni have one repository. In this repository multiple folders are available.\ni have required only one folder in this repository.\ni am already try to following command but it's not working.\ngit clone" }, { "role": "assistant", "content": "If only the content of that folder is of interest (not its history), you can, since GitLab 1.11 (May 2019) download only a folder.\n\nDownload archives of directories within a repository\n\n\n\nDepending on the type of project and its size, downloading an archive of the entire project may be slow or unhelpful – particularly in the case of large monorepos.\nIn GitLab 11.11, you can now download an archive of the contents of the current directory, including subdirectories, so that you download only the files you need.\n\nFrom issue 24704: see documentation.\n\nWith GitLab 14.4 (Oct. 2021), you have:\n\nissue 28827 \"Download a (sub-)folder from a repository via the Repositories API\",\nresolved with MR 71431 and commit 1b4e0a1:\n\ncurl --header \"PRIVATE-TOKEN: <your_access_token>\" \\\n\"https://gitlab.com/api/v4/projects/<project_id>/repository/archive?sha=<commit_sha>&path=<path>\"\n\nIt was not somehow mentioned in the \"GitLab 1.44 released\" page though." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitattributes - Defining attributes per path" }, { "role": "assistant", "content": "RESERVED BUILTIN_* ATTRIBUTES builtin_* is a reserved namespace for builtin attribute values. Any\nuser defined attributes under this namespace will be ignored and\ntrigger a warning. builtin_objectmode This attribute is for filtering files by their file bit modes (40000,\n120000, 160000, 100755, 100644). e.g. :(attr:builtin_objectmode=160000) .\nYou may also check these values with git check-attr builtin_objectmode -- <file> .\nIf the object is not in the index git check-attr --cached will return unspecified." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs -W --function-context" }, { "role": "assistant", "content": "Show whole function as context lines for each change.\nThe function names are determined in the same way as git diff works out patch hunk headers (see Defining a\ncustom hunk-header in gitattributes )." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Pagination in Gitlab API only returns 100 per_page max\n\nI am currently using GitLab API to return all projects within a group. The question I have is, how do I return all projects if there are over 100 projects in the group?\nThe curl command I'm using is curl --header \"PRIVATE-TOKEN: **********\" http://gitlab.example.com/api/v4/groups/myGroup/projects?per_page=100&page=1\nI understand that the default page=1 and the max per_page=100 so what do I do if there are over 100 projects? If I set page=2, it just returns all the projects after the first 100." }, { "role": "assistant", "content": "Check the response for the X-Total-Pages header. As long as page is smaller than total pages, you have to call the api again and increment the page variable.\nhttps://docs.gitlab.com/ee/api/rest/index.html#pagination-link-header" } ]