messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git symbolic links in Windows\nOur developers use a mix of Windows and Unix-based OSes. Therefore, symbolic links created on Unix machines become a problem for Windows developers. In Windows (MSysGit), the symbolic link is converted to a text file with a path to the file it points to. Instead, I'd like to convert the symbolic link into an actual Windows symbolic link.\nThe (updated) solution I have to this is:\n\nWrite a post-checkout script that will recursively look for \"symbolic link\" text files.\nReplace them with a Windows symbolic link (using mklink) with the same name and extension as dummy \"symbolic link\"\nIgnore these Windows symbolic links by adding an entry into file .git/info/exclude\n\nI have not implemented this, but I believe this is a solid approach to this problem.\n\nWhat, if any, downsides do you see to this approach?\nIs this post-checkout script even implementable? I.e., can I recursively find out the dummy \"symlink\" files Git creates?" }, { "role": "assistant", "content": "Update note\nFor most Windows developers struggling with symlinks and git on Windows and the issues of sharing a repo with *nix systems, this topic is a solved problem -- once you update your Windows understanding of mklink a bit and turn on Developer Mode.\nSee this more modern answer before digging into the following deep git hacks discussion.\nOlder systems:\nI was asking this exact same question a while back (not here, just in general), and ended up coming up with a very similar solution to OP's proposition.\nI'll post the solution I ended up using.\nBut first I'll provide direct answers to OP's 3 questions:\n\nQ: \"What, if any, downsides do you see to this approach?\"\nA: There are indeed a few downsides to the proposed solution, mainly regarding an increased potential for repository pollution, or accidentally adding duplicate files while they're in their \"Windows symlink\" states. (More on this under \"limitations\" below.)\n\n\nQ: \"Is this post-checkout script even implementable? i.e. can I recursively find out the dummy \"symlink\" files git creates?\"\nA: Yes, a post-checkout script is implementable! Maybe not as a literal post-git checkout step, but the solution below has met my needs well enough that a literal post-checkout script wasn't necessary.\n\n\nQ: \"Has anybody already worked on such a script?\"\nA: Yes!\n\nThe Solution:\nOur developers are in much the same situation as OP's: a mixture of Windows and Unix-like hosts, repositories and submodules with many git symlinks, and no native support (yet) in the release version of MsysGit for intelligently handling these symlinks on Windows hosts.\nThanks to Josh Lee for pointing out the fact that git commits symlinks with special filemode 120000. With this information it's possible to add a few git aliases that allow for the creation and manipulation of git symlinks on Windows hosts.\n\nCreating git symlinks on Windows\n git config --global alias.add-symlink '!'\"$(cat <<'ETX'\n __git_add_symlink() {\n if [ $# -ne 2 ] || [ \"$1\" = \"-h\" ]; then\n printf '%b\\n' \\\n 'usage: git add-symlink <source_file_or_dir> <target_symlink>\\n' \\\n 'Create a symlink in a git repository on a Windows host.\\n' \\\n 'Note: source MUST be a path relative to the location of target'\n [ \"$1\" = \"-h\" ] && return 0 || return 2\n fi\n\n source_file_or_dir=${1#./}\n source_file_or_dir=${source_file_or_dir%/}\n\n target_symlink=${2#./}\n target_symlink=${target_symlink%/}\n target_symlink=\"${GIT_PREFIX}${target_symlink}\"\n target_symlink=${target_symlink%/.}\n : \"${target_symlink:=.}\"\n\n if [ -d \"$target_symlink\" ]; then\n target_symlink=\"${target_symlink%/}/${source_file_or_dir##*/}\"\n fi\n\n case \"$target_symlink\" in\n (*/*) target_dir=${target_symlink%/*} ;;\n (*) target_dir=$GIT_PREFIX ;;\n esac\n\n target_dir=$(cd \"$target_dir\" && pwd)\n\n if [ ! -e \"${target_dir}/${source_file_or_dir}\" ]; then\n printf 'error: git-add-symlink: %s: No such file or directory\\n' \\\n \"${target_dir}/${source_file_or_dir}\" >&2\n printf '(Source MUST be a path relative to the location of target!)\\n' >&2\n return 2\n fi\n\n git update-index --add --cacheinfo 120000 \\\n \"$(printf '%s' \"$source_file_or_dir\" | git hash-object -w --stdin)\" \\\n \"${target_symlink}\" \\\n && git checkout -- \"$target_symlink\" \\\n && printf '%s -> %s\\n' \"${target_symlink#$GIT_PREFIX}\" \"$source_file_or_dir\" \\\n || return $?\n }\n __git_add_symlink\n ETX\n )\"\n\nUsage: git add-symlink <source_file_or_dir> <target_symlink>, where the argument corresponding to the source file or directory must take the form of a path relative to the target symlink. You can use this alias the same way you would normally use ln.\nE.g., the repository tree:\n dir/\n dir/foo/\n dir/foo/bar/\n dir/foo/bar/baz (file containing \"I am baz\")\n dir/foo/bar/lnk_file (symlink to ../../../file)\n file (file containing \"I am file\")\n lnk_bar (symlink to dir/foo/bar/)\n\nCan be created on Windows as follows:\n git init\n mkdir -p dir/foo/bar/\n echo \"I am baz\" > dir/foo/bar/baz\n echo \"I am file\" > file\n git add -A\n git commit -m \"Add files\"\n git add-symlink ../../../file dir/foo/bar/lnk_file\n git add-symlink dir/foo/bar/ lnk_bar\n git commit -m \"Add symlinks\"\n\n\nReplacing git symlinks with NTFS hardlinks+junctions\n git config --global alias.rm-symlinks '!'\"$(cat <<'ETX'\n __git_rm_symlinks() {\n case \"$1\" in (-h)\n printf 'usage: git rm-symlinks [symlink] [symlink] [...]\\n'\n return 0\n esac\n ppid=$$\n case $# in\n (0) git ls-files -s | grep -E '^120000' | cut -f2 ;;\n (*) printf '%s\\n' \"$@\" ;;\n esac | while IFS= read -r symlink; do\n case \"$symlink\" in\n (*/*) symdir=${symlink%/*} ;;\n (*) symdir=. ;;\n esac\n\n git checkout -- \"$symlink\"\n src=\"${symdir}/$(cat \"$symlink\")\"\n\n posix_to_dos_sed='s_^/\\([A-Za-z]\\)_\\1:_;s_/_\\\\\\\\_g'\n doslnk=$(printf '%s\\n' \"$symlink\" | sed \"$posix_to_dos_sed\")\n dossrc=$(printf '%s\\n' \"$src\" | sed \"$posix_to_dos_sed\")\n\n if [ -f \"$src\" ]; then\n rm -f \"$symlink\"\n cmd //C mklink //H \"$doslnk\" \"$dossrc\"\n elif [ -d \"$src\" ]; then\n rm -f \"$symlink\"\n cmd //C mklink //J \"$doslnk\" \"$dossrc\"\n else\n printf 'error: git-rm-symlink: Not a valid source\\n' >&2\n printf '%s =/=> %s (%s =/=> %s)...\\n' \\\n \"$symlink\" \"$src\" \"$doslnk\" \"$dossrc\" >&2\n false\n fi || printf 'ESC[%d]: %d\\n' \"$ppid\" \"$?\"\n\n git update-index --assume-unchanged \"$symlink\"\n done | awk '\n BEGIN { status_code = 0 }\n /^ESC\\['\"$ppid\"'\\]: / { status_code = $2 ; next }\n { print }\n END { exit status_code }\n '\n }\n __git_rm_symlinks\n ETX\n )\"\n\n git config --global alias.rm-symlink '!git rm-symlinks' # for back-compat.\n\nUsage:\n git rm-symlinks [symlink] [symlink] [...]\n\nThis alias can remove git symlinks one-by-one or all-at-once in one fell swoop. Symlinks will be replaced with NTFS hardlinks (in the case of files) or NTFS junctions (in the case of directories). The benefit of using hardlinks+junctions over \"true\" NTFS symlinks is that elevated UAC permissions are not required in order for them to be created.\nTo remove symlinks from submodules, just use git's built-in support for iterating over them:\n git submodule foreach --recursive git rm-symlinks\n\nBut, for every drastic action like this, a reversal is nice to have...\n\nRestoring git symlinks on Windows\n git config --global alias.checkout-symlinks '!'\"$(cat <<'ETX'\n __git_checkout_symlinks() {\n case \"$1\" in (-h)\n printf 'usage: git checkout-symlinks [symlink] [symlink] [...]\\n'\n return 0\n esac\n case $# in\n (0) git ls-files -s | grep -E '^120000' | cut -f2 ;;\n (*) printf '%s\\n' \"$@\" ;;\n esac | while IFS= read -r symlink; do\n git update-index --no-assume-unchanged \"$symlink\"\n rmdir \"$symlink\" >/dev/null 2>&1\n git checkout -- \"$symlink\"\n printf 'Restored git symlink: %s -> %s\\n' \"$symlink\" \"$(cat \"$symlink\")\"\n done\n }\n __git_checkout_symlinks\n ETX\n )\"\n\n git config --global alias.co-symlinks '!git checkout-symlinks'\n\nUsage: git checkout-symlinks [symlink] [symlink] [...], which undoes git rm-symlinks, effectively restoring the repository to its natural state (except for your changes, which should stay intact).\nAnd for submodules:\n git submodule foreach --recursive git checkout-symlinks\n\n\nLimitations:\n\nDirectories/files/symlinks with spaces in their paths should work. But tabs or newlines? YMMV… (By this I mean: don’t do that, because it will not work.)\n\nIf yourself or others forget to git checkout-symlinks before doing something with potentially wide-sweeping consequences like git add -A, the local repository could end up in a polluted state.\nUsing our \"example repo\" from before:\necho \"I am nuthafile\" > dir/foo/bar/nuthafile\necho \"Updating file\" >> file\ngit add -A\ngit status\n# On branch master\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# new file: dir/foo/bar/nuthafile\n# modified: file\n# deleted: lnk_bar # POLLUTION\n# new file: lnk_bar/baz # POLLUTION\n# new file: lnk_bar/lnk_file # POLLUTION\n# new file: lnk_bar/nuthafile # POLLUTION\n#\n\nWhoops...\nFor this reason, it's nice to include these aliases as steps to perform for Windows users before-and-after building a project, rather than after checkout or before pushing. But each situation is different. These aliases have been useful enough for me that a true post-checkout solution hasn't been necessary.\n\n\n\n\nReferences:\nhttp://git-scm.com/book/en/Git-Internals-Git-Objects\nhttp://technet.microsoft.com/en-us/library/cc753194\nLast Update: 2019-03-13\n\nPOSIX compliance (well, except for those mklink calls, of course) — no more Bashisms!\nDirectories and files with spaces in them are supported.\nZero and non-zero exit status codes (for communicating success/failure of the requested command, respectively) are now properly preserved/returned.\nThe add-symlink alias now works more like ln(1) and can be used from any directory in the repository, not just the repository’s root directory.\nThe rm-symlink alias (singular) has been superseded by the rm-symlinks alias (plural), which now accepts multiple arguments (or no arguments at all, which finds all of the symlinks throughout the repository, as before) for selectively transforming git symlinks into NTFS hardlinks+junctions.\nThe checkout-symlinks alias has also been updated to accept multiple arguments (or none at all, == everything) for selective reversal of the aforementioned transformations.\n\nFinal Note: While I did test loading and running these aliases using Bash 3.2 (and even 3.1) for those who may still be stuck on such ancient versions for any number of reasons, be aware that versions as old as these are notorious for their parser bugs. If you experience issues while trying to install any of these aliases, the first thing you should look into is upgrading your shell (for Bash, check the version with CTRL+X, CTRL+V). Alternatively, if you’re trying to install them by pasting them into your terminal emulator, you may have more luck pasting them into a file and sourcing it instead, e.g. as\n. ./git-win-symlinks.sh" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker" }, { "role": "assistant", "content": "GIT COMMANDS We divide Git into high level (\"porcelain\") commands and low level\n(\"plumbing\") commands." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to get an Ansible check to run only once in a playbook?\nAs a safeguard against using an outdated playbook, I'd like to ensure that I have an updated copy of the git checkout before Ansible is allowed to modify anything on the servers.\nThis is how I've attempted to do it. This action is located in a file included by all play books:\n- name: Ensure local git repository is up-to-date\n local_action: git pull\n register: command_result\n failed_when: \"'Updating' in command_result.stdout\"\n\nThe problem is that this command is run once for each node Ansible connects to, instead of only once for each playbook run. How can I avoid that?" }, { "role": "assistant", "content": "Updated\nWhen I fist wrote my answer (2014-02-27), Ansible had no built-in support for running a task only once per playbook, not once per affected host that the playbook was run on. However, as tlo writes, support for this was introduced with run_once: true in Ansible version 1.7.0 (released on 2014-08-06). With this feature, the example task definition from the question should be changed to\n- name: Ensure local git repository is up-to-date\n local_action: git pull\n run_once: true\n register: command_result\n failed_when: \"'Updating' in command_result.stdout\"\n\nto accomplish what is asked for.\nOriginal Answer\n[The following answer was my suggested solution for the particular problem of making sure that the local git branch is updated before Ansible runs the tasks of a playbook.]\nI wrote the following Ansible callback plugin that will avoid playbook execution if the current git branch is out of sync (is either behind or has diverged) with the remote branch. To use it, place the following code in a file like callback_plugins/require_updated_git_branch.py in your top-level Ansible playbook directory:\n#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport os\nimport re\nimport subprocess\nimport sys\n\nfrom ansible.callbacks import display, banner\n\n\nclass CallbackModule(object):\n \"\"\"Makes Ansible require that the current git branch is up to date.\n \"\"\"\n env_var_name = 'IGNORE_OUTDATED_GIT_BRANCH'\n\n msg = 'OUTDATED GIT BRANCH: Your git branch is out of sync with the ' \\\n 'remote branch. Please update your branch (git pull) before ' \\\n 'continuing, or skip this test by setting the environment ' \\\n 'variable {0}=yes.'.format(env_var_name)\n\n out_of_sync_re = re.compile(r'Your branch (is behind|and .* have diverged)',\n re.MULTILINE)\n\n def __init__(self, *args, **kwargs):\n if os.getenv(self.env_var_name, 'no') == 'yes':\n self.disabled = True\n\n def playbook_on_start(self):\n subprocess.call(['git', 'fetch'])\n\n if self.out_of_sync_re.search(subprocess.check_output([\n 'git', 'status', '--untracked-files=no'])):\n display(banner(self.msg), color='bright purple')\n sys.exit(1)\n\nFor example, when the local branch is behind the remote branch, the command ansible-playbook site.yml halts early with the following output:\n __________________________________________________________\n/ OUTDATED GIT BRANCH: Your git branch is out of sync with \\\n| the remote branch. Please update your branch (git pull) |\n| before continuing, or skip this test by setting the |\n\\ environment variable IGNORE_OUTDATED_GIT_BRANCH=yes. /\n ----------------------------------------------------------\n \\ ^__^\n \\ (oo)\\_______\n (__)\\ )\\/\\\n ||----w |\n || ||\n\nAnd, as the cow suggests, to turn off this check you can run the command like:\n$ IGNORE_OUTDATED_GIT_BRANCH=yes ansible-playbook site.yml\n\nThis solution does not solve the general problem of avoiding to run any Ansible task more than once regardless of the number of hosts involved, but it ensures that outdated playbooks are not executed, and it handles the concern that you mentioned regarding my alias-based suggestion." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-shortlog - Summarize git log output --cherry-mark" }, { "role": "assistant", "content": "Like --cherry-pick (see below) but mark equivalent commits\nwith = rather than omitting them, and inequivalent ones with + ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to log first 10 commits in Git\nTwo questions:\n\nHow to show the first 10 commit in git from beginning to end. (no branch)\nHow the specify the commit index and log it. (show the second or third)\n\nI know that git use parent to link the commit, it's easy to log the commit from end to start.\nlike: git log HEAD~10\nBut i need to query from the start to end, is it possible?" }, { "role": "assistant", "content": "git log -10\n\nWould show 10 latest commits matching the revision spec (a missing spec means \"all commits\").\nSee manpage:\ngit help log\n\nsection Commit Limiting\n-<number>, -n <number>, --max-count=<number>\n Limit the number of commits to output." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Number of Commits between two Commitishes\nHow can I find the number of commits between two commitishes in git?\nAdditionally, is there some way that I could do the same with any project on GitHub (using the UI, not the API)?" }, { "role": "assistant", "content": "Before I give you an answer, consider this commit graph:\n o -----------\n / \\\n... - A - o - o - o - B\n \\ /\n o ----- o\n\nEach o represents a commit, as do A and B (they're just letters to let us talk about specific commits). How many commits are there between commits A and B?\nThat said, in more linear cases, just use git rev-list --count A..B and then decide what you mean by \"between\" (does it include B and exclude A? that's how git rev-list --count will behave). In branchy cases like this, you'll get all the commits down all the branches; add --first-parent, for instance, to follow just the \"main line\".\n(You also mentioned \"commitish\", suggesting that we might have annotated tags. That won't affect the output from git rev-list, which only counts specific commits.)\n\nEdit: Since git rev-list --count A..B includes commit B (while omitting commit A), and you want to exclude both end-points, you need to subtract one. In modern shells you can do this with shell arithmetic:\ncount=$(($(git rev-list --count A..B) - 1))\n\nFor instance:\n$ x=$(($(git rev-list --count HEAD~3..HEAD) - 1))\n$ echo $x\n2\n\n(this particular repo has a very linear graph structure, so there are no branches here and there are two commits \"between\" the tip and three-behind-the-tip). Note, however, that this will produce -1 if A and B identify the same commit:\n$ x=$(($(git rev-list --count HEAD..HEAD) - 1))\n$ echo $x\n-1\n\nso you might want to check that first:\ncount=$(git rev-list --count $start..$end)\nif [ $count -eq 0 ]; then\n ... possible error: start and end are the same commit ...\nelse\n count=$((count - 1))\nfi" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to download single raw file from private gitlab repo using username and password\n\nI can clone a private repo with username & password using command below\ngit clone https://some-git-lab-token:[email protected]/foo/bar.git\n\nI'm wondering if it's possible to curl or wget a single raw file from the same repo using the same credential some-git-lab-token:someHash\nA sample gitlab raw file url as below\nhttps://gitlab.com/athos.oc/lodash-has-plugin/-/raw/master/.eslintrc.json\n\nI've tried to curl a single file as below but failed\ncurl https://some-git-lab-token:[email protected]/foo/bar/-/raw/master/testing.js\n\nThe result that I got is as below\n<html><body>You are being <a href=\"https://git.xxx.com/users/sign_in\">redirected</a>.</body></html>" }, { "role": "assistant", "content": "To download a repository file through curl, you need to use the repository files API endpoint.\nUsing your example https://gitlab.com/athos.oc/lodash-has-plugin/-/raw/master/.eslintrc.json, would turn into:\nhttps://gitlab.com/api/v4/projects/30349314/repository/files/%2Eeslintrc%2Ejson/raw?ref=master\nHowever, API authentication does not include username and password as an available authentication method, so you would need to use a token (or a session cookie)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_COMMIT_GRAPH_PARANOIA" }, { "role": "assistant", "content": "When loading a commit object from the commit-graph, Git performs an\nexistence check on the object in the object database. This is done to\navoid issues with stale commit-graphs that contain references to\nalready-deleted commits, but comes with a performance penalty. The default is \"false\", which disables the aforementioned behavior.\nSetting this to \"true\" enables the existence check so that stale commits\nwill never be returned from the commit-graph at the cost of performance." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to add images to README.md on GitHub?\n\nRecently I joined GitHub. I hosted some projects there.\nI need to include some images in my README File. I don't know how to do that.\nI searched about this, but all I got was some links which tell me to \"host images on web and specify the image path in README.md file\".\nIs there any way to do this without hosting the images on any third-party web hosting services?" }, { "role": "assistant", "content": "Try this markdown:\n![alt text](http://url/to/img.png)\n\nI think you can link directly to the raw version of an image if it's stored in your repository. i.e.\n![alt text](https://github.com/[username]/[reponame]/blob/[branch]/image.jpg?raw=true)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git --use-svnsync-props" }, { "role": "assistant", "content": "Set the useSvnsyncProps option in the [svn-remote] config." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I recover/resynchronise after someone pushes a rebase or a reset to a published branch?\nWe have all heard that one should never rebase published work, that it’s dangerous, etc. However, I have not seen any recipes posted for how to deal with the situation in case a rebase is published.\nNow, do note that this is only really feasible if the repository is only cloned by a known (and preferably small) group of people, so that whoever pushes the rebase or reset can notify everyone else that they will need to pay attention next time they fetch(!).\nOne obvious solution that I have seen will work if you have no local commits on foo and it gets rebased:\ngit fetch\ngit checkout foo\ngit reset --hard origin/foo\n\nThis will simply throw away the local state of foo in favour of its history as per the remote repository.\nBut how does one deal with the situation if one has committed substantial local changes on that branch?" }, { "role": "assistant", "content": "Getting back in synch after a pushed rebase is really not that complicated in most cases.\ngit checkout foo\ngit branch old-foo origin/foo # BEFORE fetching!!\ngit fetch\ngit rebase --onto origin/foo old-foo foo\ngit branch -D old-foo\n\nIe. first you set up a bookmark for where the remote branch originally was, then you use that to replay your local commits from that point onward onto rebased remote branch.\nRebasing is like violence: if it doesn’t solve your problem, you just need more of it. ☺\nYou can do this without the bookmark of course, if you look up the pre-rebase origin/foo commit ID, and use that.\nThis is also how you deal with the situation where you forgot to make a bookmark before fetching. Nothing is lost – you just need to check the reflog for the remote branch:\ngit reflog show origin/foo | awk '\n PRINT_NEXT==1 { print $1; exit }\n /fetch: forced-update/ { PRINT_NEXT=1 }'\n\nThis will print the commit ID that origin/foo pointed to before the most recent fetch that changed its history.\nYou can then simply\ngit rebase --onto origin/foo $commit foo" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-credential-cache" }, { "role": "assistant", "content": "Helper to temporarily store passwords in memory" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options worktree.guessRemote" }, { "role": "assistant", "content": "If no branch is specified and neither -b nor -B nor --detach is used, then git worktree add defaults to\ncreating a new branch from HEAD. If worktree.guessRemote is\nset to true, worktree add tries to find a remote-tracking\nbranch whose name uniquely matches the new branch name. If\nsuch a branch exists, it is checked out and set as \"upstream\"\nfor the new branch. If no such match can be found, it falls\nback to creating a new branch from the current HEAD." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "\"git checkout --\" . vs git checkout [duplicate]\nThis question already has an answer here:\n \n \n\n\n\n\nWhy do we use double dash in \"git checkout -- .\"? [duplicate]\n\n (1 answer)\n \n\nClosed 7 years ago.\n\n\n\nI always used git checkout -- . to clear my working directory. I thought I read somewhere that the -- was required to avoid git thinking you are passing parameters (or something)\nNow a colleague told me I could drop the --, and indeed, a quick test did exactly the same.\nIs there are any difference between those two commands?\nPS: Asking here because git checkout -- . vs git checkout . is kind of hard to google..." }, { "role": "assistant", "content": "I seem to recall that the -- is a way to tell Git to treat what follows checkout as a file and not as a branch. Suppose that you had both a file and a branch called stuff. Then the following command would seem ambiguous:\ngit checkout stuff\n\nbecause it is not clear whether you are asking to checkout a file or a branch. By using -- you explicitly tell Git to checkout a file by that name/path. So in this case the following commands allow checking out a branch and a file called stuff:\ngit checkout stuff # checkout the branch stuff\ngit checkout -- stuff # checkout the file stuff\n\nNote that git checkout <name> is really meant for branches, but Git syntax is relaxed, and if Git can't find a branch, then it will look for a file.\nClosely related: Git change branch when file of same name is present" } ]
[ { "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": "NAME git-apply - Apply a patch to files and/or to the index" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Getting started with Version Control System\nI need to implement version control, even for just the developing I do at home. I have read about how great subversion is for the past couple of years and was about to dedicate myself to learning this on the side until I heard about Git being the up and coming version control system.\nGiven the situation, should I hold off and see which one comes out on top? What are their relative advantages?\nOne issue I noticed with Git is, there are not many full featured GUIs, which is important to many users on my team.\nAlso, wouldn't mind suggestions on how to get started with one or the other. (tutorials, etc.)" }, { "role": "assistant", "content": "The most important thing about version control is:\nJUST START USING IT\nNot using version control is a horrible idea. If you are not using version control, stop reading right now and start using it.\nIt is very easy to convert from\ncvs<->svn<->git<->hg\n\nIt doesn't matter which one you choose. Just pick the easiest one for you to use and start recording the history of your code. You can always migrate to another (D)VCS later.\nIf you are looking for a easy to use GUI look at TortoiseSVN (Windows) and Versions (Mac) (Suggested by codingwithoutcomments)\n\nEdit:\n\npix0r said:\nGit has some nice features, but you won't be able to appreciate them unless you've already used something more standard like CVS or Subversion.\n\nThis. Using git is pointless if you don't know what version control can do for you.\nEdit 2:\nJust saw this link on reddit: Subversion Cheat Sheet. Good quick reference for the svn command line." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs notes.rewrite.<command>" }, { "role": "assistant", "content": "When rewriting commits with <command> (currently amend or rebase ), if this variable is false , git will not copy\nnotes from the original to the rewritten commit. Defaults to true . See also \" notes.rewriteRef \" below. This setting can be overridden with the GIT_NOTES_REWRITE_REF environment variable, which must be a colon separated list of refs or\nglobs." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-blame - Show what revision and author last modified each line of a file blame.coloring" }, { "role": "assistant", "content": "This determines the coloring scheme to be applied to blame\noutput. It can be repeatedLines , highlightRecent ,\nor none which is the default." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker gitattributes" }, { "role": "assistant", "content": "Defining attributes per path" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git stash is slow on windows\nOn my windows machine git stash has about 3.5 seconds overhead on each invocation, which adds about 7 seconds to my git commit hook.\nThe same command under linux (same machine) takes about 0.01 seconds. The performance issue applies to empty repositories as well.\nI have tried the following from this thread and this thread:\n\ncore.fscache is set to true\ncore.preloadindex is set to true\ngc.auto is set to 256\nSetting PS1='$ '\nRunning cmd in administration mode\nRunning inside cmd.exe instead of git-bash\n\nRunning GIT_TRACE=true git stash list\n16:58:16.844591 git.c:563 trace: exec: 'git-stash' 'list'\n16:58:16.844591 run-command.c:336 trace: run_command: 'git-stash' 'list'\n16:58:19.699591 git.c:350 trace: built-in: git 'rev-parse' '--git-dir'\n16:58:19.859591 git.c:350 trace: built-in: git 'rev-parse' '--git-path' 'objects'\n16:58:20.069591 git.c:350 trace: built-in: git 'rev-parse' '--show-toplevel'\n16:58:20.154591 git.c:350 trace: built-in: git 'rev-parse' '--git-path' 'index'\n16:58:20.244591 git.c:350 trace: built-in: git 'config' '--get-colorbool' 'color.interactive'\n16:58:20.334591 git.c:350 trace: built-in: git 'config' '--get-color' 'color.interactive.help' 'red bold'\n16:58:20.424591 git.c:350 trace: built-in: git 'config' '--get-color' '' 'reset'\n16:58:20.514591 git.c:350 trace: built-in: git 'rev-parse' '--verify' '--quiet' 'refs/stash'\n\nreal 0m3.845s\nuser 0m0.000s\nsys 0m0.047s\n\nRunning GIT_TRACE_PERFORMANCE=true git stash list\n16:59:18.414591 trace.c:420 performance: 0.001078046 s: git command: 'C:\\Program Files\\Git\\mingw64\\libexec\\git-core\\git.exe' 'rev-parse' '--git-dir' \n16:59:18.569591 trace.c:420 performance: 0.000947184 s: git command: 'C:\\Program Files\\Git\\mingw64\\libexec\\git-core\\git.exe' 'rev-parse' '--git-path' 'objects' \n16:59:18.779591 trace.c:420 performance: 0.001253627 s: git command: 'C:\\Program Files\\Git\\mingw64\\libexec\\git-core\\git.exe' 'rev-parse' '--show-toplevel' \n16:59:18.869591 trace.c:420 performance: 0.001285517 s: git command: 'C:\\Program Files\\Git\\mingw64\\libexec\\git-core\\git.exe' 'rev-parse' '--git-path' 'index' \n16:59:18.955591 trace.c:420 performance: 0.001139994 s: git command: 'C:\\Program Files\\Git\\mingw64\\libexec\\git-core\\git.exe' 'config' '--get-colorbool' 'color.interactive' \n16:59:19.040591 trace.c:420 performance: 0.001182881 s: git command: 'C:\\Program Files\\Git\\mingw64\\libexec\\git-core\\git.exe' 'config' '--get-color' 'color.interactive.help' 'red bold' \n16:59:19.125591 trace.c:420 performance: 0.001128997 s: git command: 'C:\\Program Files\\Git\\mingw64\\libexec\\git-core\\git.exe' 'config' '--get-color' '' 'reset' \n16:59:19.215591 trace.c:420 performance: 0.001567766 s: git command: 'C:\\Program Files\\Git\\mingw64\\libexec\\git-core\\git.exe' 'rev-parse' '--verify' '--quiet' 'refs/stash' \n16:59:19.295591 trace.c:420 performance: 3.730583540 s: git command: 'C:\\Program Files\\Git\\mingw64\\bin\\git.exe' 'stash' 'list' \n\nreal 0m3.819s \nuser 0m0.000s \nsys 0m0.062s \n\nFrom the log we see that it takes around 3 seconds between the git-stash command is run and the git-rev-parse is run. Are there any other flags I can run to find the bottleneck?" }, { "role": "assistant", "content": "With Git for Windows 2.19 (Sept. 2018), git stash (and git rebase) are no longer script-only, but actually a binary compiled with git.exe.\nSee git-for-windows/build-extra PR 203.\nTo activate them, type:\ngit config --global rebase.useBuiltin true\ngit config --global stash.useBuiltin true\n\nWarning:\n\nAs nice as the speed-ups are, the patches in question are still in flux, and they are not battle-tested at all.\n\nSo, for now, the script version of git stash remains the default, that way:\n\n\nusers who want the raw speed improvement we got through three Google Summer of Code projects working in parallel can have that,\nwhile others who are reluctant to play guinea pig by running only well-tested code can stay on the safe side.\n\n\nThe point remains: in the next versions of Git, the bash script for git-stash will eventually disappear, and its replacement is and will be faster.\nNote: that next version will be Git 2.27 (Q2 2020): \"git stash\" has kept an escape hatch to use the scripted version for a few releases, which got stale.\nIt has been removed.\nSee commit 8a2cd3f, commit b0c7362 (03 Mar 2020) by Thomas Gummerer (tgummerer).\n(Merged by Junio C Hamano -- gitster -- in commit 369ae75, 27 Mar 2020)\n\nstash: remove the stash.useBuiltin setting\nSigned-off-by: Thomas Gummerer\n\n\nRemove the stash.useBuiltin setting which was added as an escape hatch to disable the builtin version of stash first released with Git 2.22.\nCarrying the legacy version is a maintenance burden, and has in fact become out of date failing a test since the 2.23 release, without anyone noticing until now.\nSo users would be getting a hint to fall back to a potentially buggy version of the tool.\nWe used to shell out to git config to get the useBuiltin configuration to avoid changing any global state before spawning legacy-stash.\nHowever that is no longer necessary, so just use the 'git_config' function to get the setting instead.\nSimilar to what we've done in d03ebd411c (\"rebase: remove the rebase.useBuiltin setting\", 2019-03-18, Git v2.22.0-rc0 -- merge listed in batch #5), where we remove the corresponding setting for rebase, we leave the documentation in place, so people can refer back to it when searching for it online, and so we can refer to it in the commit message.\n\n\nUpdate Q2 2019, with Git 2.22, git stash is entirely rewritten in C.\n²\nSee commit 40af146, commit 48ee24a, commit ef0f0b4, commit 64fe9c2, commit 1ac528c, commit d553f53, commit d4788af, commit 41e0dd5, commit dc7bd38, commit 130f269, commit bef55dc, commit dac566c, commit ab8ad46 (25 Feb 2019) by Paul-Sebastian Ungureanu (weekly-digest[bot]).\nSee commit c4de61d, commit 577c199, commit 4e2dd39, commit 8a0fc8d (25 Feb 2019) by Joel Teichroeb (klusark).\nSee commit 7906af0, commit 90a4627, commit 8d8e9c2 (25 Feb 2019) by Johannes Schindelin (dscho).\n(Merged by Junio C Hamano -- gitster -- in commit e36adf7, 22 Apr 2019)\nYou can still use the shell script with git legacy-stash.\nAnd:\n\nstash: convert stash--helper.c into stash.c\n\n\nThe old shell script git-stash.sh was removed and replaced entirely by builtin/stash.c.\nIn order to do that, create and push were adapted to work without stash.sh.\nFor example, before this commit, git stash create called git stash--helper create --message \"$*\". If it called git stash--helper create \"$@\", then\nsome of these changes wouldn't have been necessary.\nThis commit also removes the word helper since now stash is\ncalled directly and not by a shell script.\n\nThere are optimizations:\n\nstash: optimize get_untracked_files() and check_changes()\n\n\nThis commits introduces a optimization by avoiding calling the\nsame functions again.\nFor example, git stash push -u would call at some points the following functions:\n\ncheck_changes() (inside do_push_stash())\ndo_create_stash(), which calls: check_changes() and\nget_untracked_files()\n\nNote that check_changes() also calls get_untracked_files().\nSo, check_changes() is called 2 times and get_untracked_files()\n3 times.\nThe old function check_changes() now consists of two functions:\nget_untracked_files() and check_changes_tracked_files().\nThese are the call chains for push and create:\n\npush_stash() -> do_push_stash() -> do_create_stash()\ncreate_stash() -> do_create_stash()\n\nTo prevent calling the same functions over and over again, check_changes() inside do_create_stash() is now placed in the caller functions (create_stash() and do_push_stash()).\nThis way check_changes() and get_untracked files() are called\nonly one time.\n\n\nWith Git 2.36 (Q2 2022), removal of the warning \"the stash.useBuiltin support has been removed!\" is finally done!\nSee commit e9b272e, commit deeaf5e, commit 5d4dc38, commit 6de0722 (27 Jan 2022) by Johannes Schindelin (dscho).\n(Merged by Junio C Hamano -- gitster -- in commit b9f791a, 16 Feb 2022)\n\nstash: stop warning about the obsolete stash.useBuiltin config setting\nSigned-off-by: Johannes Schindelin\n\n\nIn 8a2cd3f (\"stash: remove the stash.useBuiltin setting\", 2020-03-03, Git v2.27.0-rc0 -- merge listed in batch #2), we removed support for stash.useBuiltin, but left a warning in its place.\nAfter almost two years, and several major versions, it is time to remove even that warning." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the best practice for dealing with passwords in git repositories?\nI've got a little Bash script that I use to access twitter and pop up a Growl notification in certain situations. What's the best way to handle storing my password with the script? \nI would like to commit this script to the git repo and make it available on GitHub, but I'm wondering what the best way to keep my login/password private while doing this is. Currently, the password is stored in the script itself. I can't remove it right before I push because all the old commits will contain the password. Developing without a password isn't an option. I imagine that I should be storing the password in an external config file, but I thought I'd check to see if there was an established way to handle this before I tried and put something together." }, { "role": "assistant", "content": "The typical way to do this is to read the password info from a configuration file. If your configuration file is called foobar.config, then you would commit a file called foobar.config.example to the repository, containing sample data. To run your program, you would create a local (not tracked) file called foobar.config with your real password data.\nTo filter out your existing password from previous commits, see the GitHub help page on Removing sensitive data." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How does git bisect skip choose the next commit to try?\nWhen using git bisect, one can run git bisect skip to mark the current commit as being an unbuildable / untestable one, to try and get Git to pick some other commit to test instead.\nHow does Git decide which commit to try after a git bisect skip? Experimenting shows it's not just an adjacent commit, but I can't work out the pattern.\nEdit: I'm aware the basic git bisect is a binary search, but I'm curious about git bisect skip, which is clearly doing something more complicated.\nExperimentation shows it's not just picking an adjacent commit; the below creates 100 commits numbered 0–99 then starts bisecting them. The first commit git bisect picks is in the middle, but each git bisect skip thereafter seems to be more-or-less randomly selected.\n$ git init\nInitialized empty Git repository in .git/\n\n$ for (( i=0; i<100; i++ )); do echo $i > file; git add file; git commit -m $i >/dev/null; done # Create some dummy commits\n\n$ git bisect start HEAD $(git rev-list --max-parents=0 HEAD) # HEAD is bad, root commit is good.\nBisecting: 49 revisions left to test after this (roughly 6 steps)\n[099e5cf2ccde625f92dc369da6cad0bdf2852ce4] 49\n\n$ git bisect skip\nBisecting: 49 revisions left to test after this (roughly 6 steps)\n[88c8208a7c4322222124167e49f07c741af7d3d8] 60\n\n$ git bisect skip\nBisecting: 49 revisions left to test after this (roughly 6 steps)\n[04695f2e5b2473c3ac72435c0dbfc3ba1375abda] 88\n\n$ git bisect skip\nBisecting: 49 revisions left to test after this (roughly 6 steps)\n[1e9bf3d29589bcac2d8c467245ae8d446c195252] 40\n\n$ git bisect skip\nBisecting: 49 revisions left to test after this (roughly 6 steps)\n[9459ed79e4112d674681c8f0f921127217c7ebc6] 13" }, { "role": "assistant", "content": "I did some digging into the Git source code and found most of an answer myself...\nAs of Git v1.6.4 (specifically, as of commit ebc9529f), Git uses \"a PRNG (pseudo random number generator) with a bias\" to determine which commit to try next after skipping one.\nI can't say I follow the algorithm itself (which, as of v2.8.1, appears to be fundamentally untouched since it was first added), but the commit message does a reasonable job of explaining what's going on:\n\nbisect: use a PRNG with a bias when skipping away from untestable commits\nUsing a PRNG (pseudo random number generator) with a bias should be better\n than alternating between 3 fixed ratios.\nIn repositories with many untestable commits it should prevent alternating\n between areas where many commits are untestable. The bias should favor\n commits that can give more information, so that the bisection process\n should not loose much efficiency.\nHPA suggested to use a PRNG and found that the best bias is to raise a\n ratio between 0 and 1 given by the PRNG to the power 1.5.\n\nSo it looks as though Git picks the next commit to try at random, but the random distribution was picked to (hopefully) choose commits that give more information for the binary search and to avoid commits likely to be in regions of untestable commits." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-stash - Stash the changes in a dirty working directory away list [<log-options>]" }, { "role": "assistant", "content": "List the stash entries that you currently have. Each stash entry is\nlisted with its name (e.g. stash@{0} is the latest entry, stash@{1} is\nthe one before, etc.), the name of the branch that was current when the\nentry was made, and a short description of the commit the entry was\nbased on. stash@{0}: WIP on submit: 6ebd0e2... Update git-stash documentation\nstash@{1}: On master: 9cc0589... Add git-stash The command takes options applicable to the git log command to control what is shown and how. See git-log ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options core.whitespace" }, { "role": "assistant", "content": "A comma separated list of common whitespace problems to\nnotice. git diff will use color.diff.whitespace to\nhighlight them, and git apply --whitespace=error will\nconsider them as errors. You can prefix - to disable\nany of them (e.g. -trailing-space ): blank-at-eol treats trailing whitespaces at the end of the line\nas an error (enabled by default). space-before-tab treats a space character that appears immediately\nbefore a tab character in the initial indent part of the line as an\nerror (enabled by default). indent-with-non-tab treats a line that is indented with space\ncharacters instead of the equivalent tabs as an error (not enabled by\ndefault). tab-in-indent treats a tab character in the initial indent part of\nthe line as an error (not enabled by default). blank-at-eof treats blank lines added at the end of file as an error\n(enabled by default). trailing-space is a short-hand to cover both blank-at-eol and blank-at-eof . cr-at-eol treats a carriage-return at the end of line as\npart of the line terminator, i.e. with it, trailing-space does not trigger if the character before such a carriage-return\nis not a whitespace (not enabled by default). tabwidth=<n> tells how many character positions a tab occupies; this\nis relevant for indent-with-non-tab and when Git fixes tab-in-indent errors. The default tab width is 8. Allowed values are 1 to 63." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Move git repository to another github user\n\nThere are many answers on Google that point in the same direction, but when it comes to version control I don't want to try anything and then mess up my repository.\nI have set up a repository on GitHub and would like to move it to another user, so that I can close the repository. He would then invite me to the repo once it belongs to his account. I guess this is quite a common use case for working with clients - once you finished the project, you hand it over to them.\nNow, assuming this is possible, how would I change my local Git settings in the project so that I am now pushing to/pulling from the new location? And, by moving the repo, would I lose the commit history?" }, { "role": "assistant", "content": "Any of the following will work:\n\nJust transfer ownership of the repo to another user and have them add you as a collaborator.\nIf someone forks your repo, then you delete the original, their fork is still there, unless it's a private repository. they can then add you as a collaborator on their fork repo.\nAnother user can simply clone your repo (commits intact), create a new repo on GitHub, add the new repo's remote info, and push your repo up to their new one. (Then, they can add you as a collaborator.)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Clone another GitLab repository in GitLab CI script\n\nI've seen this: `git clone project2` in gitlab-ci.yml? as well as a bunch of similar posts with similar answers implying that one should use Git submodules.\nWithout getting into arguments about whether submodules in Git work well, in my case, that just isn't an option at all (what other project to check out depends on the arguments passed to the trigger of the job, or, at least, it should).\nAnother requirement is that I need to be able to track the user who started the chain of triggers. I.e. hard-coding my personal token, or just any token will not do it: I need GitLab to use the permissions of the user who executed the job in order to clone other repositories.\nShort of giving up GitLab and looking for a mature CI alternative, is there any way to get this done?" }, { "role": "assistant", "content": "As New CI job permissions model states that there are 2 options: use gitlab-ci-token:${CI_JOB_TOKEN} or write it to ~/.netrc (doesn't work for me).\nBut we have multiple dependent repositories defined in package.json so our solution is to overwrite git config\ngit config --global url.\"https://gitlab-ci-token:${CI_JOB_TOKEN}@your-gitlab.com/\".insteadOf \"ssh://[email protected]/\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What does UserA committed with UserB 13 days ago on github mean?\nI am interested in knowing which one of the two users made the file changes when github lists both. The git record contains only UserA however." }, { "role": "assistant", "content": "UserA is the one who actually made the changes. UserB is the one who committed those changes to this branch. i.e if UserA commits his changes to branch1, UserB comes, commits a couple changes to branch2, rebases branch1 with branch2. Now, topmost commits in branch1 will show that UserA has committed these changes with UserB. \nEdit: This mainly happens during rebasing and cherry-picking, since authors and committers can be different in these processes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Reset git proxy to default configuration\nI installed Socat to use the Git Protocol Through a HTTP CONNECT Proxy, then I create a script called gitproxy in your bin directory.\n#!/bin/sh\n# Use socat to proxy git through an HTTP CONNECT firewall.\n# Useful if you are trying to clone git:// from inside a company.\n# Requires that the proxy allows CONNECT to port 9418.\n#\n# Save this file as gitproxy somewhere in your path (e.g., ~/bin) and then run\n# chmod +x gitproxy\n# git config --global core.gitproxy gitproxy\n#\n# More details at https://www.emilsit.net/blog/archives/how-to-use-the-git-protocol-through-a-http-connect-proxy/\n\n# Configuration. Common proxy ports are 3128, 8123, 8000.\n_proxy=proxy.yourcompany.com\n_proxyport=3128\n\nexec socat STDIO PROXY:$_proxy:$1:$2,proxyport=$_proxyport\n\nthen I configured git to use it: \n$ git config --global core.gitproxy gitproxy\n\nNow I want to reset git to the default proxy configurations, how can I do that?" }, { "role": "assistant", "content": "For me, I had to add:\ngit config --global --unset http.proxy\n\nBasically, you can run:\ngit config --global -l \n\nto get the list of all proxy defined, and then use \"--unset\" to disable them" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_DIFF_PATH_COUNTER" }, { "role": "assistant", "content": "A 1-based counter incremented by one for every path." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_TRACE_REDACT" }, { "role": "assistant", "content": "By default, when tracing is activated, Git redacts the values of\ncookies, the \"Authorization:\" header, the \"Proxy-Authorization:\"\nheader and packfile URIs. Set this Boolean environment variable to false to prevent this\nredaction." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git un-remove before commit?\nI accidentally did a \ngit rm filename.txt -f\nnow if I do a git commit -m '', it will commit this delete. How do I un-remove it before I do a git commit?" }, { "role": "assistant", "content": "To get the version from the current commit (HEAD) into both the index (staging area, what you're about to commit) and the work tree:\ngit checkout HEAD filename.txt\n\nNote that this isn't just for \"unremoval\" - it's for getting you back to the version from the commit, whether you've modified it by changing one line or deleting the entire file.\nAlso, in case others find this looking for a slightly different answer, if you want to get the version from the index back into the work tree, you can use\ngit checkout filename.txt\n\nThat's handy for when you manage to stage everything for a commit, then do something stupid (like remove a file) - you can save yourself by recovering from the index." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to remove remote git hooks?\nI have pre-push hook implemented with Husky. Now I wanna remove it.\nProblem is that after yarn remove husky git hooks are still there inside .git/hooks.\nBecause of that I get this error every time I want to commit or switch branch or commit, thus commiting is not even possible --> \n.git/hooks/pre-commit: line 6: node_modules/run-node/run-node: No such file or directory\nI know I can always delete every hook inside .git/hooks but how I can push this changes remotely? How not to force my teammates do the same thing?\nAlso I know I can commit using -n flag but still I would like not to do it." }, { "role": "assistant", "content": "Assuming you have no non-husky hooks, you might want to keep: \nrm -f .git/hooks/*\n\nevery file inside \".git/hooks/\" is either a git-hook or ignored by git. By removing everything inside, you'll get rid of all hooks, and restore the default behavior. \nBy default there are example-hooks in there, but except for being examples they serve no purpose, so you can delete them." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Combining mingw and git\nI have installation of MinGW in D:\\mingw. I have Git installation in C:\\Program Files\\git. I want to develop/compile using MinGW and use git for versioning.\nI guess I have to use correct paths but some paths are hardcoded. Like msys mount script calls /bin/msysmnt.exe\nSo I have 2 options:\n1. use git's shell (to be able to show me branch at prompt)\n2. use mingw(msys)'s shell - to have correct paths\nWhichever I choose I must make the other functionality work under it." }, { "role": "assistant", "content": "Small update: Since the Git 2.x releases, Git for Windows is based off of MSYS2 and available in 32 and 64 bit binary form. It still is a fork, and not interchangeable with the real MSYS2.\n\nOne thing you must understand: msysgit (the git you are using) is a fork of msys with added git functionality. A lot of unix tools are included in the msys shell (for a full list, see the msysgit/bin folder).\nIt might be possible to add additional msys tools to the msysgit bin folder, but I would not risk my head on that.\nIn light of this, I think it would be optimal to just add your toolchain to the msysgit path (using the bash profile file or whatever in the msysgit tree) and just use that. If a particular utility is missing, add it from the MinGW-msys tree and hope it works OK.\nAlternatively, just use msys-git from cmd.exe. Since recent versions, it works very well (including git show, editing commit messages etc...). To do that, add the /cmd directory to PATH, and you can use all the git commands you want. This is what I do, as msys is a drag, but a necessary evil for git to work on Windows.\nUPDATE: detailed instructions to add a directory to PATH under any kind of MSYS:\nexport PATH=/d/MinGW/bin:$PATH\n\nor hackishly find /etc/profile and change this section\nif [ $MSYSTEM == MINGW32 ]; then\n export PATH=\".:/usr/local/bin:/mingw/bin:/bin:$PATH\"\nelse\n export PATH=\".:/usr/local/bin:/bin:/mingw/bin:$PATH\"\nfi\n\nto: \nif [ $MSYSTEM == MINGW32 ]; then\n export PATH=\".:/usr/local/bin:/d/MinGW/bin:/bin:$PATH\"\nelse\n export PATH=\".:/usr/local/bin:/bin:/mingw/bin:$PATH\"\nfi\n\nThere is no cleaner way because the msys-git people disabled the fstab functionality present in vanilla msys.\nUpdate from Nick (what I did to make it work):\nI created file in C:\\Program Files\\Git\\etc called bash_profile. This is the contents of the file:\nexport PATH=$PATH:/d/mingw/bin:/d/mingw/msys/1.0/bin\n\nmake and gcc worked.\nThe bash_profile does not come with msysgit so you won't overwrite it if you update." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Change Git repository directory location.\nWith Git/Github for Windows, if I have a repository with this directory: C:\\dir1\\dir2, what do I need to do to move the repo files to C:\\dir1? I can obviously physically copy and paste the files, but what do I need to do on the Git side?\nI have this repo on GitHub and I use Git Bash and GitHub for Windows." }, { "role": "assistant", "content": "Simply copy the entire working directory contents (including the hidden .git directory). This will move the entire working directory to the new directory and will not affect the remote repository on GitHub.\nIf you are using GitHub for Windows, you may move the repository using the method as above. However, when you click on the repository in the application it will be unable to find it. To resolve this simply click on the blue circle with the !, select Find It and then browse to the new directory." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects %GG" }, { "role": "assistant", "content": "raw verification message from GPG for a signed commit" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to prevent group creation in GitLab\n\nI have setup GitLab 7.12 in my firm. But users start creating groups (and groups and groups ...) and it will become a total mess very soon.\nDoes anyone know how to restrict groups creation to administrators of the platform ?\nThe idea is to have people creating projects in their personal space, and reserving groups for official ones." }, { "role": "assistant", "content": "For an Omnibus install, the correct place is:\n /etc/gitlab/gitlab.rb\n gitlab_rails['gitlab_default_can_create_group'] = false\n\nThen you'll need to execute sudo gitlab-ctl reconfigure and sudo gitlab-ctl restart to apply the changes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-grep - Print lines matching a pattern -A <num> --after-context <num>" }, { "role": "assistant", "content": "Show <num> trailing lines, and place a line containing -- between contiguous groups of matches." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Installed gitlab, but only nginx welcome page shows\n\nI installed gitlab using its installation guide. Everything was OK, but when I open localhost:80 in the browser all I see it the message Welcome to nginx!. I can't find any log file with any errors in it.\nI am running Ubuntu in VirtualBox. My /etc/nginx/sites-enabled/gitlab config file reads:\n# GITLAB\n# Maintainer: @randx\n# App Version: 3.0\n\nupstream gitlab {\n server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket;\n}\n\nserver {\n listen 192.168.1.1:80; # e.g., listen 192.168.1.1:80;\n server_name aridev-VirtualBox; # e.g., server_name source.example.com;\n root /home/gitlab/gitlab/public;\n\n # individual nginx logs for this gitlab vhost\n access_log /var/log/nginx/gitlab_access.log;\n error_log /var/log/nginx/gitlab_error.log;\n\n location / {\n # serve static files from defined root folder;.\n # @gitlab is a named location for the upstream fallback, see below\n try_files $uri $uri/index.html $uri.html @gitlab;\n }\n\n # if a file, which is not found in the root folder is requested,\n # then the proxy pass the request to the upsteam (gitlab unicorn)\n location @gitlab {\n proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694\n proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694\n proxy_redirect off;\n\n proxy_set_header X-Forwarded-Proto $scheme;\n proxy_set_header Host $http_host;\n proxy_set_header X-Real-IP $remote_addr;\n\n proxy_pass http://gitlab;\n }\n}" }, { "role": "assistant", "content": "The nginx documentation says:\nServer names are defined using the server_name directive and determine which server block is used for a given request. \n\nThat means in your case that that you have to enter aridev-VirtualBox within your browser instead of localhost.\nTo get this working you have to enter aridev-VirtualBox within your local Hosts file and point it to the IP of your VirtualBox PC.\nThis would look something like follows:\n192.168.1.1 aridev-VirtualBox" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Delete fork dependency of a GitHub repository\n\nHow can I make GitHub forget or disassociate that my repo was originally a fork of another project?\nI forked a project in GitHub. I can now see \"forked from whatever/whatever\". The parent repository \"whatever/whatever\" is no longer maintained. I have been allowed to continue use of the code base of the original repository to create an independent repository.\nIs there a way to detach my project from the original repository?" }, { "role": "assistant", "content": "Update Jan 2022:\nUse the GitHub chatbot-virtual-assistant at https://support.github.com/contact?tags=rr-forks&subject=Detach%20Fork&flow=detach_fork\nFirst answer:\nYou can contact github support and ask them to switch your repository to \"normal mode\".\nOn this page, \"Commit was made in a fork\" paragraph, it is explained that one has to go through support to switch. Therefore, it is likely that there is no way to do that by yourself (unless you destroy and recreate your repo which is explained before... if you do so be careful if you have tickets or a wiki attached to your project as they will be deleted!)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary commit" }, { "role": "assistant", "content": "As a noun: A single point in the\nGit history; the entire history of a project is represented as a\nset of interrelated commits. The word \"commit\" is often\nused by Git in the same places other revision control systems\nuse the words \"revision\" or \"version\". Also used as a short\nhand for commit object . As a verb: The action of storing a new snapshot of the project’s\nstate in the Git history, by creating a new commit representing the current\nstate of the index and advancing HEAD to point at the new commit." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I clone a github project to run locally?\n\nI am trying to follow this railscast tutorial for authlogic - and it points to the source here - \nI have git installed - how do I replicate the source onto my localhost so that I can follow the tutorial like in the screencast?" }, { "role": "assistant", "content": "git clone git://github.com/ryanb/railscasts-episodes.git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order" }, { "role": "assistant", "content": "EXAMPLES Print the list of commits reachable from the current branch. git rev-list HEAD Print the list of commits on this branch, but not present in the\nupstream branch. git rev-list @{upstream}..HEAD Format commits with their author and commit message (see also the\nporcelain git-log ). git rev-list --format=medium HEAD Format commits along with their diffs (see also the porcelain git-log , which can do this in a single process). git rev-list HEAD |\ngit diff-tree --stdin --format=medium -p Print the list of commits on the current branch that touched any\nfile in the Documentation directory. git rev-list HEAD -- Documentation/ Print the list of commits authored by you in the past year, on\nany branch, tag, or other ref. git rev-list [email protected] --since=1.year.ago --all Print the list of objects reachable from the current branch (i.e., all\ncommits and the blobs and trees they contain). git rev-list --objects HEAD Compare the disk size of all reachable objects, versus those\nreachable from reflogs, versus the total packed size. This can tell\nyou whether running git repack -ad might reduce the repository size\n(by dropping unreachable objects), and whether expiring reflogs might\nhelp. # reachable objects\ngit rev-list --disk-usage --objects --all\n# plus reflogs\ngit rev-list --disk-usage --objects --all --reflog\n# total disk size used\ndu -c .git/objects/pack/*.pack .git/objects/??/*\n# alternative to du: add up \"size\" and \"size-pack\" fields\ngit count-objects -v Report the disk size of each branch, not including objects used by the\ncurrent branch. This can find outliers that are contributing to a\nbloated repository size (e.g., because somebody accidentally committed\nlarge build artifacts). git for-each-ref --format='%(refname)' |\nwhile read branch\ndo\n\tsize=$(git rev-list --disk-usage --objects HEAD..$branch)\n\techo \"$size $branch\"\ndone |\nsort -n Compare the on-disk size of branches in one group of refs, excluding\nanother. If you co-mingle objects from multiple remotes in a single\nrepository, this can show which remotes are contributing to the\nrepository size (taking the size of origin as a baseline). git rev-list --disk-usage --objects --remotes=$suspect --not --remotes=origin" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Permission denied error on Github Push\nRecently, I'm added as a member/contributor for Github project. I have cloned that project on local machine.\nI have made some changes and committed locally and now trying to Push changes to original repo but when I try to Push,I get some permission error?\nC:\\Users\\MM\\Documents\\GitHub\\software-licensing-php [master]> git push\norigin master\nremote: Permission to EasySoftwareLicensing/software-licensing-php.git denied to\n irfandayan.\nfatal: unable to access 'https://github.com/EasySoftwareLicensing/software-licen\nsing-php.git/': The requested URL returned error: 403\nC:\\Users\\MM\\Documents\\GitHub\\software-licensing-php [master]> git statu\ns\n# On branch master\n# Your branch is ahead of 'origin/master' by 2 commits.\n# (use \"git push\" to publish your local commits)\n#\nnothing to commit, working directory clean\n\nAm I lacking some permission for pushing changes so I could ask the original author of project?" }, { "role": "assistant", "content": "click fork button on original github project page\nclone your forked repository instead original\npush to it\npress Pull Requests button on your repository\ncreate it\nwait for original author to accept it" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to configure Mac OS X term so that git has color? [closed]\nClosed. This question is off-topic. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it's on-topic for Stack Overflow.\n\n\nClosed 11 years ago.\n\n\nThe community reviewed whether to reopen this question 2 years ago and left it closed:\n\nOriginal close reason(s) were not resolved\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI've seen a Mac OS X git demo online in which it's configured to have multiple colors.\nFor example, his prompt is amber, his ls directory is purple and his git diff output has ~ 4 colors (pink, light green, red, pale yellow).\nCan you tell me how can I configure Mac OS X terminal to achieve that? It's definitely Mac OS X Terminal.app, not iTerm." }, { "role": "assistant", "content": "William Purcell's answer only enables color for the 'git diff' command. Do this to enable colors for all git commands:\n$ git config --global color.ui true" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Push origin master error on new repository\nI just started using git with github. I followed their instructions and ran into errors on the last step. I'm checking in an existing directory that isn't currently source-controlled (project about a week old). Other than that, my use case should be pretty run of the mill.\nHere's what's happening:\n$ git push origin master\nerror: src refspec master does not match any.\nfatal: The remote end hung up unexpectedly\nerror: failed to push some refs to '[email protected]:{username}/{projectname}.git'\n\nGithub's instructions:\nGlobal setup:\n\n Download and install Git\n git config --global user.name \"Your Name\"\n git config --global user.email {username}@gmail.com\n\nNext steps:\n\n mkdir projectname\n cd projectname\n git init\n touch README\n git add README\n git commit -m 'first commit'\n git remote add origin [email protected]:{username}/{projectname}.git\n git push origin master" }, { "role": "assistant", "content": "I was having the same issue and then smacked myself in the head because I hadn't actually added my project files.\ngit add -A\ngit commit -am \"message\"\ngit push origin master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %ci" }, { "role": "assistant", "content": "committer date, ISO 8601-like format" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database treeNotSorted" }, { "role": "assistant", "content": "(ERROR) A tree is not properly sorted." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-gc - Cleanup unnecessary files and optimize the local repository gc.cruftPacks" }, { "role": "assistant", "content": "Store unreachable objects in a cruft pack (see git-repack ) instead of as loose objects. The default\nis true ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: Where exactly is the \"working directory\"?\n\nI am going through some Git tutorials. The concept of a \"working directory\" keeps being mentioned, however, none of the tutorials or documents I read points out where or what this \"working directory\" is.\nI have thought that it was actually the .git's parent directory, a.k.a the directory I run git init in. But the video tutorial I am watching talks about the state of nothing to commit and \"working directory clean\":\n\nIn fact you can actually make a copy of the repository, and make that\n copy so that it does not have a working directory, this is actually\n called the bare clone. This is actually what GitHub uses.\n\nIf my understanding of the \"working directory\" is correct, how can a repository not have a \"working directory\"? And what does it mean, when it says that GitHub uses a \"bare clone\"?" }, { "role": "assistant", "content": "This should hopefully clear things up for us:\n\nWhat is the difference between a repository created using the git init\n command and the git init --bare command?\nRepositories created with the git init command are called working\n directories. In the top level folder of the repository you will find\n two things:\nA .git subfolder with all the git related revision history of your repo\nA working tree, or checked out copies of your project files.\n\nRepositories created with git init --bare are called bare repos. They\n are structured a bit differently from working directories. First off,\n they contain no working or checked out copy of your source files. And\n second, bare repos store git revision history of your repo in the root\n folder of your repository instead of in a .git subfolder. Note… bare\n repositories are customarily given a .git extension.\n\nTaken from John Saints - What is a bare git repository?\nA bare git clone does not contain a working directory of checked out code, in other words.\nThink of it as just the .git directory (the Git database) without anything else." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Add new commit to the existing Git tag\nI have created a Git tag as v1.1 using \ngit tag -a v1.1 -m 'my version 1.1'\n\nand I pushed that tag. Later, I made some changes related to v1.1. Now when I push new changes and check the git tag using \ngit describe it is showing me v1.1-g2dcc97.\nHow can I add my new commit to the existing tag?" }, { "role": "assistant", "content": "You can't put a new commit into an existing tag without breaking an important Git guideline: Never(*) modify commits that you have published.\nTags in Git aren't meant to be mutable. Once you push a tag out there, leave it alone.\nYou can, however, add some changes on top of v1.1 and release something like v1.1.1 or v1.2. One way of doing that would be\n# Create a new branch from tag v1.1\ngit checkout -b newbranch v1.1\n\n# Do some work and commit it\n\n# Create a new tag from your work\ngit tag -a -m \"Tag version 1.1.1, a bugfix release\" v1.1.1\n\n(*) Unless you have a really super special reason for doing so, and only if you completely understand the implications, and even then, don't make a habit of it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git pull - Please move or remove them before you can merge\nI am trying to do a git pull origin master from my server but keep getting the error:\nPlease move or remove them before you can merge.\nThere are no untracked files, but it seems like it has issues with the ignored files for some reason.\nI tried running a git clean -nd to see what would be deleted and it lists a whole bunch of files that are ignored in .gitignore.\nHow can I fix this so I can do a pull?" }, { "role": "assistant", "content": "I just faced the same issue and solved it using the following. First clear tracked files by using :\n# caution: it will **delete all untracked files**\ngit clean -d -f\n\nthen try git pull origin master\nYou can view other git clean options by typing git clean -help" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitlab-ce 12.X : how do I find the hashed storage path of a repository on the server?\n\nWith gitlab-ce-12.x, Geo requires the storage path to be hashed (https://docs.gitlab.com/ee/administration/repository_storage_types.html) \nFor a given repository, the data will therefore be stored in :\n\"@hashed/#{hash[0..1]}/#{hash[2..3]}/#{hash}.git\"\nFrom a practical point of view, say I have a repository whose URL is \n\nhttps://my-gitlab-server/Group1/project1.git\n\nHow do I work out the path to the storage on the server ?\ni.e. how do i find the value of \n\n#{hash[0..1]}/#{hash[2..3]}/#{hash}\n\nThanks" }, { "role": "assistant", "content": "I found the answer to my question.\nIn order to get the hashed storage location of a project, you first need to get the project id of the project repository.\nOnce you get that project id, say your project id is 1, \nyou get the hash this way :\nSay project.id is 1\n\necho -n 1 | sha256sum\n\n=> You get the HASH\n6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b\nThe hashed storage location of your repository on the server will therefore be :\n\nserver/@hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b.git\n\nThis has been discussed by gitlab developers in \nhttps://gitlab.com/gitlab-org/gitlab-ce/issues/63250" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git says local branch is behind remote branch, but it's not\nScenario: \n\nI make a new branch\nhack on it\ncommit it\npush it\nhack on it some more\ncommit again\ntry to push again\n\nGit responds:\n\nUpdates were rejected because the tip of your current branch is behind\n its remote counterpart. etc.\n\nI'm the only one hacking on this branch - no one else is touching it. The remote branch is actually behind the local branch. I shouldn't have to pull at all.\n(And if I do pull, Git reports conflicts between the two, and forces me to merge the branch into itself)\nWhy is this (likely) happening? And how can I diagnose/fix it?\nTo be clear, I'm not branching anywhere, and no one else is working on it:\nRemote: Commit A -------- Commit B \n\nLocal: Commit A -------- Commit B -------- Commit C \n\nC is a straight continuation of B, no branching involved. But git thinks C is a branch of A: \nRemote: Commit A -------- Commit B \n\n ------- Commit C \n / \nLocal: Commit A -------- Commit B \n\nIt's not; it's a straight continuation of B." }, { "role": "assistant", "content": "You probably did some history rewriting? Your local branch diverged from the one on the server. Run this command to get a better understanding of what happened:\ngitk HEAD @{u}\n\nI would strongly recommend you try to understand where this error is coming from. To fix it, simply run:\ngit push -f\n\nThe -f makes this a “forced push” and overwrites the branch on the server. That is very dangerous when you are working in team. But\nsince you are on your own and sure that your local state is correct\nthis should be fine. You risk losing commit history if that is not the case." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to list unpushed Git commits (local but not on origin)\nHow can I view any local commits I've made, that haven't yet been pushed to the remote repository? Occasionally, git status will print out that my branch is X commits ahead of origin/master, but not always.\nIs this a bug with my install of Git, or am I missing something?" }, { "role": "assistant", "content": "This gives a log of all commits between origin/master and HEAD:\ngit log origin/master..HEAD\n\nWhen HEAD is on the master branch, this gives a log of unpushed commits.\n\nSimilarly, to view the diff:\ngit diff origin/master..HEAD" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --skip-to=<file> --rotate-to=<file>" }, { "role": "assistant", "content": "Discard the files before the named <file> from the output\n(i.e. skip to ), or move them to the end of the output\n(i.e. rotate to ). These options were invented primarily for the use\nof the git difftool command, and may not be very useful\notherwise." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-filter-branch - Rewrite branches" }, { "role": "assistant", "content": "DESCRIPTION Lets you rewrite Git revision history by rewriting the branches mentioned\nin the <rev-list-options>, applying custom filters on each revision.\nThose filters can modify each tree (e.g. removing a file or running\na perl rewrite on all files) or information about each commit.\nOtherwise, all information (including original commit times or merge\ninformation) will be preserved. The command will only rewrite the positive refs mentioned in the\ncommand line (e.g. if you pass a..b , only b will be rewritten).\nIf you specify no filters, the commits will be recommitted without any\nchanges, which would normally have no effect. Nevertheless, this may be\nuseful in the future for compensating for some Git bugs or such,\ntherefore such a usage is permitted. NOTE : This command honors .git/info/grafts file and refs in\nthe refs/replace/ namespace.\nIf you have any grafts or replacement refs defined, running this command\nwill make them permanent. WARNING ! The rewritten history will have different object names for all\nthe objects and will not converge with the original branch. You will not\nbe able to easily push and distribute the rewritten branch on top of the\noriginal branch. Please do not use this command if you do not know the\nfull implications, and avoid using it anyway, if a simple single commit\nwould suffice to fix your problem. (See the \"RECOVERING FROM UPSTREAM\nREBASE\" section in git-rebase for further information about\nrewriting published history.) Always verify that the rewritten version is correct: The original refs,\nif different from the rewritten ones, will be stored in the namespace refs/original/ . Note that since this operation is very I/O expensive, it might\nbe a good idea to redirect the temporary directory off-disk with the -d option, e.g. on tmpfs. Reportedly the speedup is very noticeable. Filters The filters are applied in the order as listed below. The <command>\nargument is always evaluated in the shell context using the eval command\n(with the notable exception of the commit filter, for technical reasons).\nPrior to that, the $GIT_COMMIT environment variable will be set to contain\nthe id of the commit being rewritten. Also, GIT_AUTHOR_NAME,\nGIT_AUTHOR_EMAIL, GIT_AUTHOR_DATE, GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL,\nand GIT_COMMITTER_DATE are taken from the current commit and exported to\nthe environment, in order to affect the author and committer identities of\nthe replacement commit created by git-commit-tree after the\nfilters have run. If any evaluation of <command> returns a non-zero exit status, the whole\noperation will be aborted. A map function is available that takes an \"original sha1 id\" argument\nand outputs a \"rewritten sha1 id\" if the commit has been already\nrewritten, and \"original sha1 id\" otherwise; the map function can\nreturn several ids on separate lines if your commit filter emitted\nmultiple commits." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: Cannot rebase because of uncommitted changes\nGit won't let me rebase from anywhere.\nCannot rebase: Your index contains uncommitted changes.\nPlease commit or stash them.\n\nFollowing the instructions from this answer:\n$ git update-index -q --ignore-submodules --refresh\n$ git diff-files --ignore-submodules\n\nBoth do not produce any output but that one does:\n$ git diff-index --cached --ignore-submodules HEAD --\n:100644 000000 cab819f1e5ed6cc7cff374eecae273e1d6ae6a01 0000000000000000000000000000000000000000 D .idea/codeStyleSettings.xml\n:100644 000000 2953f353d2c65dd62e36926accb7f645a600b7e0 0000000000000000000000000000000000000000 D .idea/dictionaries/roxy.xml\n:100644 000000 0e7ecef362d8a77067edf4bae5972f33185bd986 0000000000000000000000000000000000000000 D .idea/inspectionProfiles/Project_Default.xml\n:100644 000000 3b312839bf2e939fea3ebdef15630a4b33e57caf 0000000000000000000000000000000000000000 D .idea/inspectionProfiles/profiles_settings.xml\n:100644 000000 e31af55b33d82e28f471a2ba51b63c2a91fa53b7 0000000000000000000000000000000000000000 D .idea/php.xml\n:100644 000000 9c25e8d4f1169b5d3103b14fdb60e7d7c3975b70 0000000000000000000000000000000000000000 D db/sfront.sql\n\nand I can't delete those files:\n$ git rm --cached .idea/php.xml\nfatal: pathspec '.idea/php.xml' did not match any files\n\nAny ideas that can help me?\nEDIT:\ngit stash\nFixed my problem. I'm not sure I understand what happened though. The files that it complain about were supposed to be ignored." }, { "role": "assistant", "content": "git stash stores the different files away from everything else, returning your working directory to the last commit. Once you have done your rebase, run git stash pop. This will return those files to the working directory and allow you to work as before.\nEDIT: A good link for learning all about the git stash command: Git Tools - Stashing and Cleaning" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Pushing to Git returning Error Code 403 fatal: HTTP request failed\nI was able to clone a copy of this repo over HTTPS authenticated. I've made some commits and want to push back out to the GitHub server. Using Cygwin on Windows 7 x64.\nC:\\cygwin\\home\\XPherior\\Code\\lunch_call>git push\nPassword:\nerror: The requested URL returned error: 403 while accessing https://MichaelDrog\n[email protected]/derekerdmann/lunch_call.git/info/refs\n\nfatal: HTTP request failed\n\nAlso set it up with verbose mode. I'm still pretty baffled.\nC:\\cygwin\\home\\XPherior\\Code\\lunch_call>set GIT_CURL_VERBOSE=1\n\nC:\\cygwin\\home\\XPherior\\Code\\lunch_call>git push\nPassword:\n* Couldn't find host github.com in the _netrc file; using defaults\n* About to connect() to github.com port 443 (#0)\n* Trying 207.97.227.239... * 0x23cb740 is at send pipe head!\n* Connected to github.com (207.97.227.239) port 443 (#0)\n* successfully set certificate verify locations:\n* CAfile: C:\\Program Files (x86)\\Git/bin/curl-ca-bundle.crt\n CApath: none\n* SSL connection using AES256-SHA\n* Server certificate:\n* subject: 2.5.4.15=Private Organization; 1.3.6.1.4.1.311.60.2.1.3=US; 1.\n3.6.1.4.1.311.60.2.1.2=California; serialNumber=C3268102; C=US; ST=California; L\n=San Francisco; O=GitHub, Inc.; CN=github.com\n* start date: 2011-05-27 00:00:00 GMT\n* expire date: 2013-07-29 12:00:00 GMT\n* subjectAltName: github.com matched\n* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Ass\nurance EV CA-1\n* SSL certificate verify ok.\n> GET /derekerdmann/lunch_call.git/info/refs?service=git-receive-pack HTTP/1.1\nUser-Agent: git/1.7.4.3282.g844cb\nHost: github.com\nAccept: */*\nPragma: no-cache\n\n< HTTP/1.1 401 Authorization Required\n< Server: nginx/1.0.4\n< Date: Thu, 15 Sep 2011 22:44:41 GMT\n< Content-Type: text/plain\n< Connection: keep-alive\n< Content-Length: 55\n< WWW-Authenticate: Basic realm=\"GitHub\"\n<\n* Ignoring the response-body\n* Expire cleared\n* Connection #0 to host github.com left intact\n* Issue another request to this URL: 'https://[email protected]/dereker\ndmann/lunch_call.git/info/refs?service=git-receive-pack'\n* Couldn't find host github.com in the _netrc file; using defaults\n* Re-using existing connection! (#0) with host github.com\n* Connected to github.com (207.97.227.239) port 443 (#0)\n* 0x23cb740 is at send pipe head!\n* Server auth using Basic with user 'MichaelDrogalis'\n> GET /derekerdmann/lunch_call.git/info/refs?service=git-receive-pack HTTP/1.1\nAuthorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nUser-Agent: git/1.7.4.3282.g844cb\nHost: github.com\nAccept: */*\nPragma: no-cache\n\n< HTTP/1.1 401 Authorization Required\n< Server: nginx/1.0.4\n< Date: Thu, 15 Sep 2011 22:44:41 GMT\n< Content-Type: text/plain\n< Connection: keep-alive\n< Content-Length: 55\n* Authentication problem. Ignoring this.\n< WWW-Authenticate: Basic realm=\"GitHub\"\n* The requested URL returned error: 401\n* Closing connection #0\n* Couldn't find host github.com in the _netrc file; using defaults\n* About to connect() to github.com port 443 (#0)\n* Trying 207.97.227.239... * 0x23cb740 is at send pipe head!\n* Connected to github.com (207.97.227.239) port 443 (#0)\n* successfully set certificate verify locations:\n* CAfile: C:\\Program Files (x86)\\Git/bin/curl-ca-bundle.crt\n CApath: none\n* SSL re-using session ID\n* SSL connection using AES256-SHA\n* old SSL session ID is stale, removing\n* Server certificate:\n* subject: 2.5.4.15=Private Organization; 1.3.6.1.4.1.311.60.2.1.3=US; 1.\n3.6.1.4.1.311.60.2.1.2=California; serialNumber=C3268102; C=US; ST=California; L\n=San Francisco; O=GitHub, Inc.; CN=github.com\n* start date: 2011-05-27 00:00:00 GMT\n* expire date: 2013-07-29 12:00:00 GMT\n* subjectAltName: github.com matched\n* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Ass\nurance EV CA-1\n* SSL certificate verify ok.\n* Server auth using Basic with user 'MichaelDrogalis'\n> GET /derekerdmann/lunch_call.git/info/refs HTTP/1.1\nAuthorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nUser-Agent: git/1.7.4.3282.g844cb\nHost: github.com\nAccept: */*\nPragma: no-cache\n\n* The requested URL returned error: 403\n* Expire cleared\n* Closing connection #0\nerror: The requested URL returned error: 403 while accessing https://MichaelDrog\n[email protected]/derekerdmann/lunch_call.git/info/refs\n\nfatal: HTTP request failed\n\nThese are the versions of git and curl that I have:\nC:\\Users\\XPherior>git --version\ngit version 1.7.4.msysgit.0\n\nC:\\Users\\XPherior>curl --version\ncurl 7.21.7 (amd64-pc-win32) libcurl/7.21.7 OpenSSL/0.9.8r zlib/1.2.5\nProtocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp\nsmtp smtps telnet tftp\nFeatures: AsynchDNS GSS-Negotiate Largefile NTLM SSL SSPI libz" }, { "role": "assistant", "content": "I just got the same problem and just figured out what's cause.\nGithub seems only supports ssh way to read&write the repo, although https way also displayed 'Read&Write'.\nSo you need to change your repo config on your PC to ssh way:\n\nEdit .git/config file under your repo directory.\nFind url=entry under section [remote \"origin\"].\nChange it from:\nurl=https://[email protected]/derekerdmann/lunch_call.git\nto:\nurl=ssh://[email protected]/derekerdmann/lunch_call.git\nThat is, change all the texts before @ symbol to ssh://git\nSave config file and quit. now you could use git push origin master to sync your repo on GitHub." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options submodulesNotUpdated" }, { "role": "assistant", "content": "Shown when a user runs a submodule command that fails\nbecause git submodule update --init was not run." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects %ae" }, { "role": "assistant", "content": "author email" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Merge Git branch without commit log\nCurrently when I'm using Git, I create a branch for each job and make various commits before I'm finished. I then merge back with my master branch and push upstream. I'm likely to have several branches at any one time and also flick between them mid-job as things crop up.\nBut most of these commits are just save points, i.e. not that important in the grand scheme of things. So when I merge the branch, I'd like it if the branch logs didn't merge with the master logs.\nIs there a way to just merge the log message for commit g below (and not commits c or e)?\na [master] \n|\nb (create branch 'job')\n|\\\n| \\\n| c \n| |\nd e\n| |\nf g (next step is to merge 'job' branch with 'master')" }, { "role": "assistant", "content": "I consider merge --squash extremely useful when I use a \"branch per feature\" approach. My commit history in temporary branches is a complete garbage, absolutely meaningless. And I really want to be unable to see that history anymore, not just to be able to skip it.\nWhen the commits go to code review, it is important not to create extra commits." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_ASKPASS" }, { "role": "assistant", "content": "If this environment variable is set, then Git commands which need to\nacquire passwords or passphrases (e.g. for HTTP or IMAP authentication)\nwill call this program with a suitable prompt as command-line argument\nand read the password from its STDOUT. See also the core.askPass option in git-config ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git add remote branch\nI want to add a remote, and a branch of that remote.\nI did git remote add <newname> <url>, then I did git fetch --all but git branch -a is not showing any branch of the remote. My .git/config is showing the added remote.\nCan anyone please help me out?" }, { "role": "assistant", "content": "I am not sure if you are trying to create a remote branch from a local branch or vice versa, so I've outlined both scenarios as well as provided information on merging the remote and local branches.\nCreating a remote called \"github\":\ngit remote add github git://github.com/jdoe/coolapp.git\ngit fetch github\n\nList all remote branches:\ngit branch -r\n github/gh-pages\n github/master\n github/next\n github/pu\n\nCreate a new local branch (test) from a github's remote branch (pu):\ngit branch test github/pu\ngit checkout test\n\nMerge changes from github's remote branch (pu) with local branch (test):\ngit fetch github\ngit checkout test\ngit merge github/pu\n\nUpdate github's remote branch (pu) from a local branch (test):\ngit push github test:pu\n\nCreating a new branch on a remote uses the same syntax as updating a remote branch. For example, create new remote branch (beta) on github from local branch (test):\ngit push github test:beta\n\nDelete remote branch (pu) from github:\ngit push github :pu" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git -t --tag" }, { "role": "assistant", "content": "Create a tag by using the tags_subdir instead of the branches_subdir\nspecified during git svn init." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitrevisions - Specifying revisions and ranges for Git @{<n>} , e.g. @{1}" }, { "role": "assistant", "content": "You can use the @ construct with an empty ref part to get at a\nreflog entry of the current branch. For example, if you are on\nbranch blabla then @{1} means the same as blabla@{1} ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is it safe to shallow clone with --depth 1, create commits, and pull updates again?\nThe --depth 1 option in git clone:\n\nCreate a shallow clone with a history truncated to the specified number of revisions. A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches. \n\nBut I've successfully done a shallow clone, committed some changes and pushed those changes back to the (bare clone) origin.\nIt makes sense to me - I mean why not? when the cloned HEAD is identifiable in the origin, and my commit comes on top of this, there seems no reason. But the manual says otherwise.\nI like the idea of shallow clone - e.g. of drupal core: there's no way I need to know what went on in drupal 4 when I've started from 7. - but I don't want to shoot myself in the foot.\nSo is it safe to shallow clone, develop commits in it, pull again to keep up with updates from origin?" }, { "role": "assistant", "content": "Note that Git 1.9/2.0 (Q1 2014) has removed that limitation.\nSee commit 82fba2b, from Nguyễn Thái Ngọc Duy (pclouds):\n\nNow that git supports data transfer from or to a shallow clone, these limitations are not true anymore.\n\nThe documentation now reads:\n--depth <depth>::\n\n\nCreate a 'shallow' clone with a history truncated to the specified number of revisions.\n\nThat stems from commits like 0d7d285, f2c681c, and c29a7b8 which support clone, send-pack /receive-pack with/from shallow clones.\nsmart-http now supports shallow fetch/clone too.\nAll the details are in \"shallow.c: the 8 steps to select new commits for .git/shallow\".\nUpdate June 2015: Git 2.5 will even allow for fetching a single commit!\n(Ultimate shallow case)\n\nUpdate January 2016: Git 2.8 (Mach 2016) now documents officially the practice of getting a minimal history.\nSee commit 99487cf, commit 9cfde9e (30 Dec 2015), commit 9cfde9e (30 Dec 2015), commit bac5874 (29 Dec 2015), and commit 1de2e44 (28 Dec 2015) by Stephen P. Smith (``).\n(Merged by Junio C Hamano -- gitster -- in commit 7e3e80a, 20 Jan 2016) \nThis is \"Documentation/user-manual.txt\" \n\nA <<def_shallow_clone,shallow clone>> is created by specifying the git-clone --depth switch.\n The depth can later be changed with the git-fetch --depth switch, or full history restored with --unshallow.\nMerging inside a <<def_shallow_clone,shallow clone>> will work as long as a merge base is in the recent history.\n Otherwise, it will be like merging unrelated histories and may have to result in huge conflicts.\n This limitation may make such a repository unsuitable to be used in merge based workflows.\n\nUpdate 2020:\n\ngit 2.11.1 introduced option git fetch --shallow-exclude= to prevent fetching all history\ngit 2.11.1 introduced option git fetch --shallow-since= to prevent fetching old commits.\n\n\nFor more on the shallow clone update process, see \"How to update a git shallow clone?\".\n\nAs commented by Richard Michael:\n\nto backfill history: git pull --unshallow\n\nAnd Olle Härstedt adds in the comments:\n\nTo backfill part of the history: git fetch --depth=100." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects %ad" }, { "role": "assistant", "content": "author date (format respects --date= option)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "giteveryday - A useful minimum set of commands for Everyday Git A typical integrator’s Git day." }, { "role": "assistant", "content": "$ git status (1) $ git branch --no-merged master (2) $ mailx (3) & s 2 3 4 5 ./+to-apply\n& s 7 8 ./+hold-linus\n& q\n$ git switch -c topic/one master\n$ git am -3 -i -s ./+to-apply (4) $ compile/test\n$ git switch -c hold/linus && git am -3 -i -s ./+hold-linus (5) $ git switch topic/one && git rebase master (6) $ git switch -C seen next (7) $ git merge topic/one topic/two && git merge hold/linus (8) $ git switch maint\n$ git cherry-pick master~4 (9) $ compile/test\n$ git tag -s -m \"GIT 0.99.9x\" v0.99.9x (10) $ git fetch ko && for branch in master maint next seen (11) do\n\tgit show-branch ko/$branch $branch (12) done\n$ git push --follow-tags ko (13) see what you were in the middle of doing, if anything. see which branches haven’t been merged into master yet.\nLikewise for any other integration branches e.g. maint , next and seen . read mails, save ones that are applicable, and save others\nthat are not quite ready (other mail readers are available). apply them, interactively, with your sign-offs. create topic branch as needed and apply, again with sign-offs. rebase internal topic branch that has not been merged to the\nmaster or exposed as a part of a stable branch. restart seen every time from the next. and bundle topic branches still cooking. backport a critical fix. create a signed tag. make sure master was not accidentally rewound beyond that\nalready pushed out. In the output from git show-branch , master should have\neverything ko/master has, and next should have\neverything ko/next has, etc. push out the bleeding edge, together with new tags that point\ninto the pushed history." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to compare two different commits on the same branch in github?\nComparing histories on the same branch is very confusing for me on GitHub. I struggle with this regularly:\nIf I use compare/master in the URL after the GitHub repo name, I can compare against other branches in the repo based on the options in the drop-down menus.\nhttps://help.github.com/en/articles/comparing-commits-across-time\nHowever, I usually want to compare several commits on master. \nHow is this easily done? Could I get a more clear example?" }, { "role": "assistant", "content": "You can use the following URL structure to compare commits in the same branch:\ngithub.com/<username>/<repo_name>/compare/<commit1>...<commit2>\n\nReplace values for username, repo_name, commit1(old commit) & commit2(new commit) acc. to your project.\nThe separator between the two commits is ... i.e. 3 dots." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git diff with line numbers (Git log with line numbers)\nWhen I do a git diff or a git log -p, how do I get line numbers of the source file(s) inlined with the output?\nI tried to look it up man git-diff | grep \"line numbers\" and I tried googling but got nothing quickly." }, { "role": "assistant", "content": "You can't get human-readable line numbers with git diff\nThere aren't currently any options to get line-numbers displayed vertically on the side with git diff.\nUnified-diff format\nThat information is available in the (c)hunk headers for each change in the diff though, it's just in unified-diff format:\n@@ -start,count +start,count @@\n\nThe original state of the file is represented with -, and the new state is represented with + (they don't mean additions and deletions in the hunk header. start represents the starting line number of each version of the file, and count represents how many lines are included, starting from the start point.\nExample\ndiff --git a/osx/.gitconfig b/osx/.gitconfig\nindex 4fd8f04..fcd220c 100644\n--- a/osx/.gitconfig\n+++ b/osx/.gitconfig\n@@ -11,7 +11,7 @@ <== HERE!\n [color \"branch\"]\n upstream = cyan\n [color \"diff\"]\n- meta = yellow\n+ meta = cyan\n plain = white dim\n old = red bold\n new = green bold\n\nThe hunk header\n@@ -11,7 +11,7 @@\n\nsays that the previous version of the file starts at line 11, and includes 7 lines:\n11 [color \"branch\"]\n12 upstream = cyan\n13 [color \"diff\"]\n14 - meta = yellow\n14 + meta = cyan\n15 plain = white dim\n16 old = red bold\n17 new = green bold\n\nwhile the next version of the file also starts at line 11, and also includes 7 lines.\nUnified-diff format isn't really for human consumption\nAs you can probably tell, unified-diff format doesn't make it easy to figure out line numbers (at least if you're not a machine). If you really want line numbers that you can read, you'll need to use a diffing tool that will display them for you.\nAdditional Reading\n\nOfficial git-diff(1) Manual Page" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs -U<n> --unified=<n>" }, { "role": "assistant", "content": "Generate diffs with <n> lines of context instead of\nthe usual three.\nImplies --patch ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-am - Apply a series of patches from a mailbox --patch-format" }, { "role": "assistant", "content": "By default the command will try to detect the patch format\nautomatically. This option allows the user to bypass the automatic\ndetection and specify the patch format that the patch(es) should be\ninterpreted as. Valid formats are mbox, mboxrd,\nstgit, stgit-series, and hg." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-worktree - Manage multiple working trees lock" }, { "role": "assistant", "content": "If a worktree is on a portable device or network share which is not always\nmounted, lock it to prevent its administrative files from being pruned\nautomatically. This also prevents it from being moved or deleted.\nOptionally, specify a reason for the lock with --reason ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-cvsexportcommit" }, { "role": "assistant", "content": "Export a single commit to a CVS checkout" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-cherry-pick - Apply the changes introduced by some existing commits keep" }, { "role": "assistant", "content": "The commit will be kept. Implies --allow-empty ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the point of 'git submodule init'?\nBackground\nTo populate a repository's submodules, one typically invokes:\ngit submodule init\ngit submodule update\n\nIn this usage, git submodule init seems to do only one thing: populate .git/config with information that is already in .gitmodules.\nWhat is the point of that?\nCouldn't git submodule update simply use the information from .gitmodules? This would avoid both:\n\nan unnecessary command (git submodule init); and\nan unnecessary duplication of data (.gitmodules content into .git/config).\n\nQuestion\nEither:\n\nthere are use-cases for git submodule init that I do not know (in which case, please enlighten me!); or else\ngit submodule init is cruft that could be deprecated in Git without any harm.\n\nWhich of these is true?" }, { "role": "assistant", "content": "Imagine the repository has 10 submodules and you are interested in only two submodules of these. In such a case, you may want to get updates from only these two submodules from the remote repository from time to time. git init works well for this, because once you execute the command git init for these two submodules, git submodule update --remote applies only to them.\n\nAppended two workflows demo.\nWorkflow1: Submodules are libraries which several projects use.\nI think this is one of the common use cases.\nYou just cloned \"my-project\".\ngit clone https://example.com/demo/my-project\n\nAnd the surface of its structure is like below.\n\nThe contents of .gitmodules\n[submodule \"lib1\"]\n path = lib1\n url = https://example.com/demo/lib1\n[submodule \"lib2\"]\n path = lib2\n url = https://example.com/demo/lib2\n[submodule \"lib3\"]\n path = lib3\n url = https://example.com/demo/lib3\n[submodule \"lib4\"]\n path = lib4\n url = https://example.com/demo/lib4\n\nYou want to refactor the code code1.js which references lib1 and lib2 which means you don't need to clone and checkout lib3 and lib4. So you just run the below command.\ngit submodule init lib1 lib2\n\nNow let's see the contents of .git/config\n...\n[submodule \"lib1\"]\n active = true\n url = https://example.com/demo/lib1\n[submodule \"lib2\"]\n active = true\n url = https://example.com/demo/lib2\n\nThis means something like \"Ready to update lib1 and lib2 from example.com/demo\".\nAt this point, lib1 and lib2 directories are empty. You can clone and checkout lib1 and lib2 with one command:\ngit submodule update\n\nNow you are able to refactor code1.js without import errors.\nSubmodules are just references to certain commits. So when you want to update libraries to new versions, you have to update the references. You can do it by the below command.\ngit submodule update --remote\n\nNow you can see how useful it is to only initialize the submodules you need.\nWorkflow 2: Each submodule is a project and one big top project includes them.\nI'm a fan of this.\nYou clone \"main-project\".\ngit clone https://example.com/demo/main-project\n\nAnd the surface of its structure is like below.\n\nYou can see a directory named \"shared\". There is a rule in this workflow: if you want to use shared codes of main-project in your project, you have to create the project as a submodule of main-project.\nI like to put entity classes in shared directory like below.\n\nBack to the submodule workflow, the contents of .gitmodules is like the following.\n[submodule \"sub-project1\"]\n path = sub-project1\n url = https://example.com/demo/sub-project1\n[submodule \"sub-project2\"]\n path = sub-project2\n url = https://example.com/demo/sub-project2\n[submodule \"sub-project3\"]\n path = sub-project3\n url = https://example.com/demo/sub-project3\n[submodule \"sub-project4\"]\n path = sub-project4\n url = https://example.com/demo/sub-project4\n\nThis time you want to refactor some code in the shared directory of the main-project and you know that only sub-project1 and sub-project2 reference shared code, which means you don't need to clone and checkout sub-project3 and sub-project4. So you just run the command below.\ngit submodule init sub-project1 sub-project2\n\nAnd like I mentioned in workflow1, you need to run the command below to clone and checkout them.\ngit submodule update\n\nWould I do git submodule update --remote in this case? Or do I even have to init and update submodules to refactor code in the shared directory? Yes, because you have to run tests in submodules after refactoring the shared code and if any update of submodules is committed and pushed to the remote repository while you are refactoring, then you need to get it by git submodule update --remote." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-unpack-file" }, { "role": "assistant", "content": "Creates a temporary file with a blob’s contents" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git push requires username and password\nI cloned a Git repository from my GitHub account to my PC.\nI want to work with both my PC and laptop, but with one GitHub account.\nWhen I try to push to or pull from GitHub using my PC, it requires a username and password, but not when I'm using the laptop!\nI don't want to type my username and password every time I interact with origin. What am I missing here?" }, { "role": "assistant", "content": "A common cause is cloning using the default (HTTPS) instead of SSH. You can correct this by going to your repository, clicking \"Clone or download\", then clicking the \"Use SSH\" button above the URL field and updating the URL of your origin remote like this:\ngit remote set-url origin [email protected]:username/repo.git\n\nYou can check if you have added the remote as HTTPS or SSH using:\ngit remote -v\n\nThis is documented at GitHub: Switching remote URLs from HTTPS to SSH." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How would Git handle a SHA-1 collision on a blob?\nThis probably never happened in the real-world yet, and may never happen, but let's consider this: say you have a git repository, make a commit, and get very very unlucky: one of the blobs ends up having the same SHA-1 as another that is already in your repository. Question is, how would Git handle this? Simply fail? Find a way to link the two blobs and check which one is needed according to the context?\nMore a brain-teaser than an actual problem, but I found the issue interesting." }, { "role": "assistant", "content": "I did an experiment to find out exactly how Git would behave in this case. This is with version 2.7.9~rc0+next.20151210 (Debian version). I basically just reduced the hash size from 160-bit to 4-bit by applying the following diff and rebuilding git:\n--- git-2.7.0~rc0+next.20151210.orig/block-sha1/sha1.c\n+++ git-2.7.0~rc0+next.20151210/block-sha1/sha1.c\n@@ -246,6 +246,8 @@ void blk_SHA1_Final(unsigned char hashou\n blk_SHA1_Update(ctx, padlen, 8);\n\n /* Output hash */\n- for (i = 0; i < 5; i++)\n- put_be32(hashout + i * 4, ctx->H[i]);\n+ for (i = 0; i < 1; i++)\n+ put_be32(hashout + i * 4, (ctx->H[i] & 0xf000000));\n+ for (i = 1; i < 5; i++)\n+ put_be32(hashout + i * 4, 0);\n }\n\nThen I did a few commits and noticed the following.\n\nIf a blob already exists with the same hash, you will not get any warnings at all. Everything seems to be ok, but when you push, someone clones, or you revert, you will lose the latest version (in line with what is explained above).\nIf a tree object already exists and you make a blob with the same hash: Everything will seem normal, until you either try to push or someone clones your repository. Then you will see that the repo is corrupt.\nIf a commit object already exists and you make a blob with the same hash: same as #2 - corrupt\nIf a blob already exists and you make a commit object with the same hash, it will fail when updating the \"ref\".\nIf a blob already exists and you make a tree object with the same hash. It will fail when creating the commit.\nIf a tree object already exists and you make a commit object with the same hash, it will fail when updating the \"ref\".\nIf a tree object already exists and you make a tree object with the same hash, everything will seem ok. But when you commit, all of the repository will reference the wrong tree.\nIf a commit object already exists and you make a commit object with the same hash, everything will seem ok. But when you commit, the commit will never be created, and the HEAD pointer will be moved to an old commit.\nIf a commit object already exists and you make a tree object with the same hash, it will fail when creating the commit.\n\nFor #2 you will typically get an error like this when you run \"git push\":\nerror: object 0400000000000000000000000000000000000000 is a tree, not a blob\nfatal: bad blob object\nerror: failed to push some refs to origin\n\nor:\nerror: unable to read sha1 file of file.txt (0400000000000000000000000000000000000000)\n\nif you delete the file and then run \"git checkout file.txt\".\nFor #4 and #6, you will typically get an error like this:\nerror: Trying to write non-commit object\nf000000000000000000000000000000000000000 to branch refs/heads/master\nfatal: cannot update HEAD ref\n\nwhen running \"git commit\". In this case you can typically just type \"git commit\" again since this will create a new hash (because of the changed timestamp)\nFor #5 and #9, you will typically get an error like this:\nfatal: 1000000000000000000000000000000000000000 is not a valid 'tree' object\n\nwhen running \"git commit\"\nIf someone tries to clone your corrupt repository, they will typically see something like:\ngit clone (one repo with collided blob,\nd000000000000000000000000000000000000000 is commit,\nf000000000000000000000000000000000000000 is tree)\n\nCloning into 'clonedversion'...\ndone.\nerror: unable to read sha1 file of s (d000000000000000000000000000000000000000)\nerror: unable to read sha1 file of tullebukk\n(f000000000000000000000000000000000000000)\nfatal: unable to checkout working tree\nwarning: Clone succeeded, but checkout failed.\nYou can inspect what was checked out with 'git status'\nand retry the checkout with 'git checkout -f HEAD'\n\nWhat \"worries\" me is that in two cases (2,3) the repository becomes corrupt without any warnings, and in 3 cases (1,7,8), everything seems ok, but the repository content is different than what you expect it to be. People cloning or pulling will have a different content than what you have. The cases 4,5,6 and 9 are ok, since it will stop with an error. I suppose it would be better if it failed with an error at least in all cases." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository fetch.bundleURI" }, { "role": "assistant", "content": "This value stores a URI for downloading Git object data from a bundle\nURI before performing an incremental fetch from the origin Git server.\nThis is similar to how the --bundle-uri option behaves in git-clone . git clone --bundle-uri will set the fetch.bundleURI value if the supplied bundle URI contains a bundle\nlist that is organized for incremental fetches. If you modify this value and your repository has a fetch.bundleCreationToken value, then remove that fetch.bundleCreationToken value before fetching from\nthe new bundle URI." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to combine two branches from two different repositories in a single repository?\nThe structures of my Git repositories look like this:\nA-B-C-D-E-F # master branch in separate repo1\nA-B-C-D-E-G-H # master branch in separate repo2\n\nA-H are simple commits. As you can see the repositories are related (repo2 is a fork of repo1). I'm trying to combine these two repositories in one.\nAfterwards the single repository should have the following structure:\nA-B-C-D-E-F # master branch of previous repo1\n \\\n \\\n G-H # master branch of previous repo2\n\nI've already spent a lot of time reading the Git User's Guide and so on. However, this (special) case of use doesn't seem to be documented anywhere." }, { "role": "assistant", "content": "You can treat another git repository on the same filesystem as a remote repo.\nIn the first, do the following:\ngit remote add <name> /path/to/other/repo/.git\ngit fetch <name>\ngit branch <name> <name>/master #optional\n\nNow they're both branches in a single repository. You can switch between them with git checkout, merge with git merge, etc." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --output=<file>" }, { "role": "assistant", "content": "Output to a specific file instead of stdout." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects %cn" }, { "role": "assistant", "content": "committer name" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch --progress" }, { "role": "assistant", "content": "Progress status is reported on the standard error stream\nby default when it is attached to a terminal, unless -q\nis specified. This flag forces progress status even if the\nstandard error stream is not directed to a terminal." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters --git-common-dir" }, { "role": "assistant", "content": "Show $GIT_COMMON_DIR if defined, else $GIT_DIR ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to unwatch multiple repos easily on github?\n\nI realize I watch too many repos in GitHub and the only way I've found to unwatch many of them is going to github.com/my_user_name/following, getting inside each of them and pressing Unwatch button.\nIsn't there any way to unwatch them faster and easily?" }, { "role": "assistant", "content": "For the lazy, one can do this without the API reasonably quickly at this url: https://github.com/watching\nA clean simple list, click click click click.\nAdditionally, there's a box that is golden. Uncheck it to not automatically be set to watch all repos you're given push access to. Hooray for managing the signal to noise ratio." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Github : I am missing \"Settings\" menu on the landing page of my repo\n\nThe \"Settings\" menu is supposed to be the last menu, just after the \"Graphs\" menu.\nNot having the \"Settings\" menu interferes with my ability to set Webhooks.\nAnd yes, this is my repo - I own it.\n landing page of my test-repo-travis repo" }, { "role": "assistant", "content": "I was having the same issue today. Eventually, I figured that I do not have enough permissions to access the repo settings because in my case the repo belongs to an 'organization' and even though I have read/write access to it, I am not the admin." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-am - Apply a series of patches from a mailbox" }, { "role": "assistant", "content": "HOOKS This command can run applypatch-msg , pre-applypatch ,\nand post-applypatch hooks. See githooks for more\ninformation." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.renameLimit" }, { "role": "assistant", "content": "The number of files to consider in the exhaustive portion of\ncopy/rename detection; equivalent to the git diff option -l . If not set, the default value is currently 1000. This\nsetting has no effect if rename detection is turned off." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What does the git index contain EXACTLY?\nWhat does the Git index exactly contain, and what command can I use to view the content of the index?\n\nThanks for all your answers. I know that the index acts as a staging area, and what is committed is in the index rather than the working tree. I am just curious about what an index object consists of. I guess it might be a list of filename/directory names, SHA-1 pairs, a kind of virtual tree maybe?\nIs there, in Git terminology, any plumbing command that I can use to list the contents of the index?" }, { "role": "assistant", "content": "The Git book contains an article on what an index includes:\n\nThe index is a binary file (generally kept in .git/index) containing a sorted list of path names, each with permissions and the SHA1 of a blob object; git ls-files can show you the contents of the index:\n\n$ git ls-files --stage\n100644 63c918c667fa005ff12ad89437f2fdc80926e21c 0 .gitignore\n100644 5529b198e8d14decbe4ad99db3f7fb632de0439d 0 .mailmap\n\nThe Racy git problem gives some more details on that structure:\n\nThe index is one of the most important data structures in git.\nIt represents a virtual working tree state by recording list of paths and their object names and serves as a staging area to write out the next tree object to be committed.\nThe state is \"virtual\" in the sense that it does not necessarily have to, and often does not, match the files in the working tree.\n\n\nNov. 2021: see also \"Make your monorepo feel small with Git’s sparse index\" from Derrick Stolee (Microsoft/GitHub)\n\n\nThe Git index is a critical data structure in Git. It serves as the “staging area” between the files you have on your filesystem and your commit history.\n\nWhen you run git add, the files from your working directory are hashed and stored as objects in the index, leading them to be “staged changes”.\nWhen you run git commit, the staged changes as stored in the index are used to create that new commit.\nWhen you run git checkout, Git takes the data from a commit and writes it to the working directory and the index.\n\nIn addition to storing your staged changes, the index also stores filesystem information about your working directory.\nThis helps Git report changed files more quickly.\n\n\nTo see more, cf. \"git/git/blob/master/Documentation/gitformat-index.txt\":\nThe Git index file has the following format\n\nAll binary numbers are in network byte order.\nVersion 2 is described here unless stated otherwise.\n\n\n\nA 12-byte header consisting of:\n4-byte signature:\nThe signature is { 'D', 'I', 'R', 'C' } (stands for \"dircache\")\n4-byte version number:\nThe current supported versions are 2, 3 and 4.\n32-bit number of index entries.\nA number of sorted index entries.\nExtensions:\nExtensions are identified by signature.\nOptional extensions can be ignored if Git does not understand them.\nGit currently supports cached tree and resolve undo extensions.\n4-byte extension signature. If the first byte is 'A'..'Z' the extension is optional and can be ignored.\n32-bit size of the extension\nExtension data\n160-bit SHA-1 over the content of the index file before this checksum.\n\n\n\nmljrg comments:\n\nIf the index is the place where the next commit is prepared, why doesn't \"git ls-files -s\" return nothing after commit?\n\nBecause the index represents what is being tracked, and right after a commit, what is being tracked is identical to the last commit (git diff --cached returns nothing).\nSo git ls-files -s lists all files tracked (object name, mode bits and stage number in the output).\nThat list (of element tracked) is initialized with the content of a commit.\nWhen you switch branch, the index content is reset to the commit referenced by the branch you just switched to.\n\nGit 2.20 (Q4 2018) adds an Index Entry Offset Table (IEOT):\nSee commit 77ff112, commit 3255089, commit abb4bb8, commit c780b9c, commit 3b1d9e0, commit 371ed0d (10 Oct 2018) by Ben Peart (benpeart).\nSee commit 252d079 (26 Sep 2018) by Nguyễn Thái Ngọc Duy (pclouds).\n(Merged by Junio C Hamano -- gitster -- in commit e27bfaa, 19 Oct 2018)\n\nieot: add Index Entry Offset Table (IEOT) extension\n\n\nThis patch enables addressing the CPU cost of loading the index by adding\nadditional data to the index that will allow us to efficiently multi-\nthread the loading and conversion of cache entries.\nIt accomplishes this by adding an (optional) index extension that is a\ntable of offsets to blocks of cache entries in the index file.\nTo make this work for V4 indexes, when writing the cache entries, it periodically\"resets\" the prefix-compression by encoding the current entry as if the path name for the previous entry is completely different and saves the\noffset of that entry in the IEOT.\nBasically, with V4 indexes, it generates offsets into blocks of prefix-compressed entries.\n\nWith the new index.threads config setting, the index loading is now faster.\n\nAs a result (of using IEOT), commit 7bd9631 clean-up the read-cache.c load_cache_entries_threaded() function for Git 2.23 (Q3 2019).\nSee commit 8373037, commit d713e88, commit d92349d, commit 113c29a, commit c95fc72, commit 7a2a721, commit c016579, commit be27fb7, commit 13a1781, commit 7bd9631, commit 3c1dce8, commit cf7a901, commit d64db5b, commit 76a7bc0 (09 May 2019) by Jeff King (peff).\n(Merged by Junio C Hamano -- gitster -- in commit c0e78f7, 13 Jun 2019)\n\nread-cache: drop unused parameter from threaded load\n\n\nThe load_cache_entries_threaded() function takes a src_offset parameter\nthat it doesn't use. This has been there since its inception in 77ff112 (read-cache: load cache entries on worker threads, 2018-10-10, Git v2.20.0-rc0).\nDigging on the mailing list, that parameter was part of an earlier iteration of the series, but became unnecessary when the code switched to using the IEOT extension.\n\n\nWith Git 2.29 (Q4 2020), the format description adjusts to the recent SHA-256 work.\nSee commit 8afa50a, commit 0756e61, commit 123712b, commit 5b6422a (15 Aug 2020) by Martin Ågren (none).\n(Merged by Junio C Hamano -- gitster -- in commit 74a395c, 19 Aug 2020)\n\nindex-format.txt: document SHA-256 index format\nSigned-off-by: Martin Ågren\n\n\nDocument that in SHA-1 repositories, we use SHA-1 and in SHA-256 repositories, we use SHA-256, then replace all other uses of \"SHA-1\" with something more neutral.\nAvoid referring to \"160-bit\" hash values.\n\ntechnical/index-format now includes in its man page:\n\nAll binary numbers are in network byte order.\nIn a repository using the traditional SHA-1, checksums and object IDs\n(object names) mentioned below are all computed using SHA-1.\nSimilarly, in SHA-256 repositories, these values are computed using SHA-256.\nVersion 2 is described here unless stated otherwise.\n\n\nCommit 4950aca from commit cf4a3bd, Git 2.44, Q1 2024, details the block management in a Git index." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-send-email - Send a collection of patches as emails --smtp-server-option=<option>" }, { "role": "assistant", "content": "If set, specifies the outgoing SMTP server option to use.\nDefault value can be specified by the sendemail.smtpServerOption configuration option. The --smtp-server-option option must be repeated for each option you want\nto pass to the server. Likewise, different lines in the configuration files\nmust be used for each option." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to list files ignored with 'skip-worktree'\nI have used git update-index --skip-worktree <file> as suggested here to make git ignore local changes to a tracked file. But now I have forgotten which files I have applied it to. How can I list all files that have skip-worktree flag applied to them?" }, { "role": "assistant", "content": "Use the following command if on *nix (Linux, Mac):\ngit ls-files -v . | grep ^S\n\nor, if on Windows, you can use:\ngit ls-files -v . | findstr \"^S\"\n\nExplanation:\ngit ls-files . lists all files in the repo (assuming you are in the root folder). -v makes the output verbose, meaning that it will abbreviate the file status with a letter in front of the filename. The options are:\n\nH cached\nS skip-worktree\nM unmerged\nR removed/deleted\nC modified/changed\nK to be killed\n? other\n\nDocumentation\nSo, to only list files with skip-worktree flag, the output is piped to grep with ^S as argument, meaning that only lines beginning with S are listed." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Escape comment character (#) in git commit message [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nStart a Git commit message with a hashmark (#)\n\n (10 answers)\n \n\nClosed 10 years ago.\n\n\n\nI have set mcedit as my editor for git commit messages. By default it ignores any lines starting with the # character. However odd this may seem, I need to be able to have the my commit message looking like this:\n#FOO-123: Implement bar foo\n\nCommitting work in progress\n\nThe #FOO-123: ... is actually the key + title of an issue in our tracker. The tracker can automatically pick up these commit messages and add them to the issue.\nUnfortunately, the first line gets treated like a comment and gets ignored.\nI don't want to have to be committing from the command line by adding -m as it's inconvenient/ugly when you have multiple lines.\nHow could I work around this?" }, { "role": "assistant", "content": "You can try and define a different character for comments in commit message:\ngit config core.commentchar <another char>\n\nAs I mention in \"Start a git commit message with a hashmark (#)\", this setting is available since git 1.8.2 (February 2013).\nIn your case: \ngit config core.commentchar \"*\"\n\nNote that you could in theory put a core.commentchar word (multiple characters), but git 2.0.x/2.1 will be stricter.\nSee commit 50b54fd by Nguyễn Thái Ngọc Duy (pclouds):\nconfig: be strict on core.commentChar\n\nWe don't support comment strings (at least not yet). And multi-byte character encoding could also be misinterpreted.\nThe test with two commas is updated because it violates this. It's added with the patch that introduces core.commentChar in eff80a9 (Allow custom \"comment char\" - 2013-01-16). It's not clear to me why that behavior is wanted.\n\n\npoke also mentions in the comments to change the commit template:\n\nWhen editing the commit message, start the editor with the contents in the given file.\n The commit.template configuration variable is often used to give this option implicitly to the command.\n\n\nNote that Git 2.23 (Q3 2019) fixes a bug, as \"git interpret-trailers\" always treated '#' as the comment character, regardless of core.commentChar setting, which has been corrected.\nSee commit 29c83fc (19 Jun 2019) by Jeff King (peff).\n(Merged by Junio C Hamano -- gitster -- in commit 3a50607, 09 Jul 2019) \n\ninterpret-trailers: load default config\nThe interpret-trailers program does not do the usual loading of config via git_default_config(), and thus does not respect many of the usual options.\n In particular, we will not load core.commentChar, even though the underlying trailer code uses its value.\nThis can be seen in the accompanying test, where setting core.commentChar to anything besides \"#\" results in a failure to treat the comments correctly." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I make Gitlab runner merge code into a branch on a successful build\n\nWell the title is pretty much self-explanatory.\nIn summary, I want a branch (i.e. dev) to be merged to another branch (i.e. production) IF the build is successful." }, { "role": "assistant", "content": "I tried @jakub-kania solution but I was always getting id_rsa invalid format. I think that gitlab secret variables are screwed somehow.\nI made it working by directly passing the deployment key into ssh-add without creating ssh keys. Here is working solution:\nmerge to master:\n stage: deploy\n image: alpine\n only:\n - dev-branch\n before_script:\n - apk add --update git openssh-client\n - mkdir ~/.ssh\n - ssh-keyscan -p 2222 <gitlab.domain.com> > ~/.ssh/known_hosts\n - eval `ssh-agent -s`\n - ssh-add <(echo \"$GITLAB_DEPLOY_KEY\")\n - ssh -T git@<gitlab.domain.com> -p 2222\n - git config --global user.email \"$GITLAB_USER_EMAIL\"\n - git config --global user.name \"$GITLAB_USER_ID\"\n - git remote set-url origin ssh://git@<gitlab.domain.com>:2222/path/to/repo.git\n script: \n - git checkout master\n - git reset --hard origin/master\n - git merge $CI_BUILD_REF\n - git push origin master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is a subproject commit?\nI'm trying to add the Laravel files to a Github repo.\nI ran \n$ git clone https://github.com/laravel/laravel.git\nThe files show up fine locally but do not show up when I push to github:\n\nThe commit shows:\n\nHow can I add the laravel files to my github repo? Also, what is a subproject commit?" }, { "role": "assistant", "content": "A submodule commit is a gitlink, special entry recorded in the index, created when you add a submodule to your repo;\nIt records the SHA1 currently referenced by the parent repo.\nA git submodule update --init is enough to populate the laravel subdirectory in your repo.\nOnce it is filled, note that your submodule repo is in a detached HEAD mode.\nAs shown here, when switching branches in the parent repo, your submodule gitlink will change accordingly, but your submodule content won't change until you make again a git submodule update (after the git checkout)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can anybody push to my project on github?\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 can I change the default comments in the git commit message?\nIs it possible to modify the commented part of the default git commit message?\nI want to add a bit more 'context' information for my users.\n# Please enter the commit message for your changes.\n# (Comment lines starting with '#' will not be included)\n# Explicit paths specified without -i nor -o; assuming --only paths...\n# On branch master\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# modified: test.txt\n#" }, { "role": "assistant", "content": "There is commit.template configuration variable, which according to git-config(1) manpage:\n\nSpecify a file to use as the template for new commit messages. \"~/\" is expanded to the value of $HOME and \"~user/\" to the specified user's home directory.\n\nYou can put it in per-repository (.git/config), user's (~/.gitconfig) and system (/etc/gitconfig) configuration file(s)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is it possible to use pip to install a package from a private GitHub repository?\n\nI am trying to install a Python package from a private GitHub repository. For a public repository, I can issue the following command which works fine:\npip install git+git://github.com/django/django.git\n\nHowever, if I try this for a private repository:\npip install git+git://github.com/echweb/echweb-utils.git\n\nI get the following output:\nDownloading/unpacking git+git://github.com/echweb/echweb-utils.git\nCloning Git repository git://github.com/echweb/echweb-utils.git to /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-VRsIoo-build\nComplete output from command /usr/local/bin/git clone git://github.com/echweb/echweb-utils.git /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-VRsIoo-build:\nfatal: The remote end hung up unexpectedly\n\nCloning into /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-VRsIoo-build...\n\n----------------------------------------\nCommand /usr/local/bin/git clone git://github.com/echweb/echweb-utils.git /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-VRsIoo-build failed with error code 128\n\nI guess this is because I am trying to access a private repository without providing any authentication. I therefore tried to use Git + ssh hoping that pip would use my SSH public key to authenticate:\npip install git+ssh://github.com/echweb/echweb-utils.git\n\nThis gives the following output:\nDownloading/unpacking git+ssh://github.com/echweb/echweb-utils.git\nCloning Git repository ssh://github.com/echweb/echweb-utils.git to /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-DQB8s4-build\nComplete output from command /usr/local/bin/git clone ssh://github.com/echweb/echweb-utils.git /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-DQB8s4-build:\nCloning into /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-DQB8s4-build...\n\nPermission denied (publickey).\n\nfatal: The remote end hung up unexpectedly\n\n----------------------------------------\nCommand /usr/local/bin/git clone ssh://github.com/echweb/echweb-utils.git /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-DQB8s4-build failed with error code 128\n\nIs what I am trying to achieve even possible? If so, how can I do it?" }, { "role": "assistant", "content": "You can use the git+ssh URI scheme, but you must set a username. Notice the git@ part in the URI:\npip install git+ssh://[email protected]/echweb/echweb-utils.git\n\nAlso read about deploy keys.\nPS: In my installation, the \"git+ssh\" URI scheme works only with \"editable\" requirements:\npip install -e URI#egg=EggName\n\nRemember: Change the : character that git remote -v prints to a / character before using the remote's address in the pip command:\n$ git remote -v\norigin [email protected]:echweb/echweb-utils.git (fetch)\n# ^ change this to a '/' character\n\nIf you forget, you will get this error:\nssh: Could not resolve hostname github.com:echweb:\n nodename nor servname provided, or not known" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Using Git for writing thesis [closed]\nClosed. This question is off-topic. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it's on-topic for Stack Overflow.\n\n\nClosed 11 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI am planning to use Git for writing my thesis with Latex. As Git is specifically designed for software development, would it be feasible for my requirements? If it is a good choice for me, then what special and unique features are available in Git which are ideal for writing a thesis. Also I want to know what precautions I should take before getting into the Git work flow. I am a complete beginner for Git, so what should be my starting point before I get into it." }, { "role": "assistant", "content": "There are some technical considerations and best practices. I am going for the second one, specifically for writing your thesis and/or papers. For the technical ones, you can check any git tutorial.\n\nDefine the directory structure for your thesis. You can change it\nlater, and use git for tracking the changes. Having a good structure\nwould make your life easier.\nWork with multiple files (use include and/or input in LaTeX). You can split them by chapters or sections. This will make easier to track changes that involve specific parts of your thesis (e.g. git log content/introduction.tex).\nTrack only the files you are going to touch, not the ones auto-generated. Creating a proper .gitignore file will help you a lot (LaTeX generate plenty of working files).\nAs in programs, do micro-commits, that is: one commit per idea/feature/fix/activity.\nEvery time you commit, write meaningful messages (high level) that explains what you were trying to achieve in every change. After a week you might not remember what you tried to accomplish.\nKeeping track of every activity/idea/fix [see (4) and (5)] could be very helpful to know how much you have done (using git log). You can write your advance report for your supervisor(s) based on git log. Even more, you can share the repository with your supervisor (using a web interface), and they can check whatever you have been doing in your thesis. For the next meeting, they will know what to expect (it will depend on how fond are your supervisors on following a RSS).\nUsing git will be useful for keeping you in a good mood (sometimes you would feel you have not done too much, but having track of every change will help you to keep things in perspective).\nFor every progress report you send, create a tag. For the next report, you can checkout both version and apply latexdiff. It will be useful for tracking changes between versions you submit for revision. This also will help you to check if you addressed the feedback you received for the previous report.\n\nAt last but not least, I recommend you to read \"A successful Git branching model\". It is a very short article on a git workflow. You can apply the same concepts when you write your thesis. For instance, if you are writing an experiment, you can create a branch for it, and merge it once it is \"ready.\" If you have to revisit it later, it would be easier to see what were the changes involved and why." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options diff.submodule" }, { "role": "assistant", "content": "Specify the format in which differences in submodules are\nshown. The \"short\" format just shows the names of the commits\nat the beginning and end of the range. The \"log\" format lists\nthe commits in the range like git-submodule summary does. The \"diff\" format shows an inline diff of the changed\ncontents of the submodule. Defaults to \"short\"." } ]