messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-daemon - A really simple server for Git repositories git daemon as regular daemon for virtual hosts" }, { "role": "assistant", "content": "To set up git daemon as a regular, non-inetd service that\nhandles repositories for multiple virtual hosts based on\ntheir IP addresses, start the daemon like this: git daemon --verbose --export-all\n\t\t--interpolated-path=/pub/%IP/%D\n\t\t/pub/192.168.1.200/software\n\t\t/pub/10.10.220.23/software In this example, the root-level directory /pub will contain\na subdirectory for each virtual host IP address supported.\nRepositories can still be accessed by hostname though, assuming\nthey correspond to these IP addresses." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can GitHub show the history of changes made to one file in patch form?\n\nIf you do git log --patch -- path/to/file, you will get the history of the file along with a diff of all the changes made to it with each commit, like this:\n$ git log --patch -- git-rebase.sh\n\ncommit 20351bb06bf4d32ef3d1a6849d01636f6593339f\nAuthor: Ramkumar Ramachandra <[email protected]>\nDate: Sat Jun 15 18:43:26 2013 +0530\n\n rebase: use 'git stash store' to simplify logic\n\n rebase has no reason to know about the implementation of the stash. In\n the case when applying the autostash results in conflicts, replace the\n relevant code in finish_rebase () to simply call 'git stash store'.\n\n Signed-off-by: Ramkumar Ramachandra <[email protected]>\n Signed-off-by: Junio C Hamano <[email protected]>\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex d0c11a9..17be392 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -153,11 +153,8 @@ finish_rebase () {\n then\n echo \"$(gettext 'Applied autostash.')\"\n else\n- ref_stash=refs/stash &&\n- >>\"$GIT_DIR/logs/$ref_stash\" &&\n- git update-ref -m \"autostash\" $ref_stash $stash_sha1 ||\n- die \"$(eval_gettext 'Cannot store $stash_sha1')\"\n-\n+ git stash store -m \"autostash\" -q $stash_sha1 ||\n+ die \"$(eval_gettext \"Cannot store \\$stash_sha1\")\"\n gettext 'Applying autostash resulted in conflicts.\n Your changes are safe in the stash.\n You can run \"git stash pop\" or \"git stash drop\" it at any time.\n\ncommit 2e6e276decde2a9f04fc29bce734a49d3ba8f484\nAuthor: Ramkumar Ramachandra <[email protected]>\nDate: Fri Jun 14 18:47:52 2013 +0530\n\n rebase: use peel_committish() where appropriate\n\n The revisions specified on the command-line as <onto> and <upstream>\n arguments could be of the form :/quuxery; so, use peel_committish() to\n resolve them. The failing tests in t/rebase and t/rebase-interactive\n now pass.\n\n Signed-off-by: Ramkumar Ramachandra <[email protected]>\n Signed-off-by: Junio C Hamano <[email protected]>\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex d0c11a9..6987b9b 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -434,7 +434,7 @@ then\n shift\n ;;\n esac\n- upstream=`git rev-parse --verify \"${upstream_name}^0\"` ||\n+ upstream=$(peel_committish \"${upstream_name}\") ||\n die \"$(eval_gettext \"invalid upstream \\$upstream_name\")\"\n upstream_arg=\"$upstream_name\"\n else\n@@ -470,7 +470,7 @@ case \"$onto_name\" in\n fi\n ;;\n *)\n- onto=$(git rev-parse --verify \"${onto_name}^0\") ||\n+ onto=$(peel_committish \"$onto_name\") ||\n die \"$(eval_gettext \"Does not point to a valid commit: \\$onto_name\")\"\n ;;\n esac\n\nI want to be able to get the same kind of format using GitHub's web interface (not the command line), and I want a link to send to someone else without the code." }, { "role": "assistant", "content": "The following URL will show all the commits for a single file in a format similar to git log -p:\nhttp://github.com/<username>/<project>/commits/<branch>/<path/to/file>\n...where:\n\n<username> is the username of the person that owns the repo\n<project> is the repo name\n<branch> can be 'master' or any other branch\n<path/to/file> is hopefully self-explanatory\n\nPicking at (somewhat) random, here is an example from the vim-fugitive repo." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What's the fastest way to edit hundreds of Git commit messages?\nI have a fairly large Git repository with 1000s of commits, originally imported from SVN. Before I make my repo public, I'd like to clean up a few hundred commit messages that don't make sense in my new repo, as well as to remove all that git-svn informational text that got added.\nI know that I can use 'git rebase -i' and then 'git commit --amend' to edit each individual commit message, but with hundreds of messages to be edited, that's a huge pain in the you-know-what.\nIs there any faster way to edit all of these commit messages? Ideally I'd have every commit message listed in a single file where I could edit them all in one place.\nThanks!" }, { "role": "assistant", "content": "That's an old question but as there is no mention of git filter-branch, I just add my two cents.\nI recently had to mass-replace text in commit message, replacing a block of text by another without changing the rest of the commit messages. For instance, I had to replace Refs: #xxxxx with Refs: #22917.\nI used git filter-branch like this\ngit filter-branch --msg-filter 'sed \"s/Refs: #xxxxx/Refs: #22917/g\"' master..my_branch\n\n\nI used the option --msg-filter to edit only the commit message but you can use other filters to change files, edit full commit infos, etc.\nI limited filter-branch by applying it only to the commits that were not in master (master..my_branch) but you can apply it on your whole branch by omitting the range of commits.\n\nAs suggested in the doc, try this on a copy of your branch.\nHope that helps.\n\nSources used for the answer\n\nUse case on when to use the function : https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#The-Nuclear-Option:-filter-branch\nFunction reference (with the list of options) : https://git-scm.com/docs/git-filter-branch\nExamples of rewrite : https://davidwalsh.name/update-git-commit-messages" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to cherry-pick from a remote branch?\nI'm having trouble performing a cherry-pick. On my local machine, I'm currently on my \"master\" branch. I want to cherry-pick in a commit from another branch, named \"zebra\". The \"zebra\" branch is a remote branch. \nSo git status:\n# On branch master\nnothing to commit (working directory clean)\n\nOk, now I try to cherry-pick the commit I want:\ngit cherry-pick xyz\nfatal: bad object xyz\n\nwhere \"xyz\" is the signature of the commit I'm interested in, that happened on branch \"zebra\".\nSo the first obvious question is, why can't git find the commit I'm referencing? I don't really understand how this is working in the first place to be honest. Does git store something like a database of commits locally in my working directory, for all other branches? When executing the cherry-pick command, does it go and search that local database to find the commit I'm talking about?\nSince \"zebra\" is a remote branch, I was thinking I don't have its data locally. So I switched branches:\ngit checkout zebra\nSwitched to branch 'zebra'\n\nSo now here on my local machine, I can see that the files in the directory reflect zebra's state correctly. I switch back to master, try to cherry-pick again (hoping the commit data is available now), but I get the same problem.\nI've got a fundamental misunderstanding of what's going on here, any help would be great." }, { "role": "assistant", "content": "Since \"zebra\" is a remote branch, I was thinking I don't have its data\n locally.\n\nYou are correct that you don't have the right data, but tried to resolve it in the wrong way. To collect data locally from a remote source, you need to use git fetch. When you did git checkout zebra you switched to whatever the state of that branch was the last time you fetched. So fetch from the remote first:\n# fetch just the one remote\ngit fetch <remote>\n# or fetch from all remotes\ngit fetch --all\n# make sure you're back on the branch you want to cherry-pick to\ngit cherry-pick xyz" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git: change origin of cloned submodule\n\nI created a project submodule and put it up on Github.\nI created another project, supermodule, and then did this:\ncd supermodule\ngit init\nmkdir lib\ngit clone git://github.com/tandu/submodule lib/submodule\ngit submodule add ./lib/submodule lib/submodule\n\nThis worked fine, but on the website, it can't find the link to the submodule when viewing the files (in fact it just says \"Loading Commit data\" forever). The submodule folder itself has the correct origin.\nApparently, what I should have done was\n...\nmkdir lib\ngit submodule add git://github.com/tandu/submodule lib\n\n...but it's too late for that now. How can I have the submodule in this project correctly point to origin?" }, { "role": "assistant", "content": "This apparently is very much dependent on the version of git you are using.\n\nIf present, change the url entry in the [submodule \"<dirname>\"] section of the .gitmodules file.\nIf present, change the url entry in the [submodule \"<dirname>\"] section of the .git/config file.\nChange the url in the configuration of the submodule itself. The location of the config file is version dependent. Older versions had it in <dirname>/.git/config, newer ones in .git/modules/<dirname>/config. However, you can always use below command:\n\ncd <dirname>\ngit config remote.origin.url <new_url>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary detached HEAD" }, { "role": "assistant", "content": "Normally the HEAD stores the name of a branch , and commands that operate on the\nhistory HEAD represents operate on the history leading to the\ntip of the branch the HEAD points at. However, Git also\nallows you to check out an arbitrary commit that isn’t necessarily the tip of any\nparticular branch. The HEAD in such a state is called\n\"detached\". Note that commands that operate on the history of the current branch\n(e.g. git commit to build a new history on top of it) still work\nwhile the HEAD is detached. They update the HEAD to point at the tip\nof the updated history without affecting any branch. Commands that\nupdate or inquire information about the current branch (e.g. git\nbranch --set-upstream-to that sets what remote-tracking branch the\ncurrent branch integrates with) obviously do not work, as there is no\n(real) current branch to ask about in this state." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-checkout - Switch branches or restore working tree files" }, { "role": "assistant", "content": "ARGUMENT DISAMBIGUATION When there is only one argument given and it is not -- (e.g. git\ncheckout abc ), and when the argument is both a valid <tree-ish> (e.g. a branch abc exists) and a valid <pathspec> (e.g. a file\nor a directory whose name is \"abc\" exists), Git would usually ask\nyou to disambiguate. Because checking out a branch is so common an\noperation, however, git checkout abc takes \"abc\" as a <tree-ish> in such a situation. Use git checkout -- <pathspec> if you want\nto checkout these paths out of the index." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do you reset the stored credentials in 'git credential-osxkeychain'?\n\nI've followed the GitHub instructions for setting up my account, and I'm able to clone, but I'm unable to push remotely.\nWhen I do a \"git push\" I get the 403 error. It has the correct URL. I tried a \"git credential-osxkeychain get\" to see what it was giving, and this prints out the wrong credentials.\nI believe what happened is the first time it asked for the credentials, I thought it was another application asking, and it put the wrong ones in.\nI just need to reset it so that it uses the correct keychain item for my GitHub account.\nI've tried:\ngit credential-osxkeychain erase\ngit credential-osxkeychain set\n\nThe program never gives any prompts. Set will say \"bad input\" if I don't do the right thing. I tried putting in \"password=password\", etc., but then when I do a \"get\" I still get the old ones.\nI can't figure out where these are being stored, as they are not in .gitconfigure. Further there are no recent keychain items that could be it. (I have several GitHub accounts in my keychain and it is not using any of them.)" }, { "role": "assistant", "content": "From Terminal:\n(You need to enter the following three lines)\n $ git credential-osxkeychain erase ⏎\n host=github.com ⏎\n protocol=https ⏎\n ⏎\n ⏎\n\nNOTE: after you enter “protocol=https” above you need to press ~~RETURN~~ TWICE (Each '⏎' is equivalent to a 'press enter/return' )" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc histogram" }, { "role": "assistant", "content": "This algorithm extends the patience algorithm to \"support\nlow-occurrence common elements\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git --no-rebase" }, { "role": "assistant", "content": "After committing, do not rebase or reset." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-revert - Revert some existing commits --cleanup=<mode>" }, { "role": "assistant", "content": "This option determines how the commit message will be cleaned up before\nbeing passed on to the commit machinery. See git-commit for more\ndetails. In particular, if the <mode> is given a value of scissors ,\nscissors will be appended to MERGE_MSG before being passed on in the case\nof a conflict." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-describe - Give an object a human readable name based on an available ref --candidates=<n>" }, { "role": "assistant", "content": "Instead of considering only the 10 most recent tags as\ncandidates to describe the input commit-ish consider\nup to <n> candidates. Increasing <n> above 10 will take\nslightly longer but may produce a more accurate result.\nAn <n> of 0 will cause only exact matches to be output." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: whole file to stdout\nIs there a command that can take a ref and a file path, and output the full contents of the file as it was at that commit to STDOUT?\nEg. Something like this:\ngit show-me-the-file HEAD~2 some/file | do_something_with_piped_output_here" }, { "role": "assistant", "content": "git show\ne.g.\ngit show HEAD:./<path_to_file>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Understanding detached HEAD in git [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nWhy did my Git repo enter a detached HEAD state?\n\n (15 answers)\n \n\nClosed 10 years ago.\n\n\n\nI am learning git and am following the excellent tutorials at http://gitimmersion.com.\nIn those tutorials, there is a blurb that tries to explain detached HEADs, and that states:\n\nA “detached HEAD” message in git just means that HEAD (the part of git that tracks what your current working directory should match) is pointing directly to a commit rather than a branch. Any changes that are committed in this state are only remembered as long as you don’t switch to a different branch. As soon as you checkout a new branch or tag, the detached commits will be “lost” (because HEAD has moved). If you want to save commits done in a detached state, you need to create a branch to remember the commits.\n\nA few questions on this:\n\nWhat exactly is a detached HEAD, and what conditions create it?\nWhy is a detached HEAD pointing to a specific commit and not a branch?\nWhen you have a detached HEAD, do you always need to create a new branch to be able to commit/push the changes in it? Why/why not?\n\nThanks in advance!" }, { "role": "assistant", "content": "If you are working in your repo and do git checkout <SHA> you will be in a \"detached HEAD\". You are not on a branch (the commit is likely to be on multiple branches). You are checked out to a specific instance in the history.\nA detached head can also occur when you are rebasing. You are checked out to a specific commit.\nYou would need to create a branch in order to commit/push changes because you would be creating commits that would be \"in limbo\" with no way to identify them other than the SHA. Git will remove the commit during its garbage collection because of it not being on a branch.\nCheckout the \"Detached Head\" Section on this page for more in depth information:\nhttp://git-scm.com/docs/git-checkout" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Tag list, display commit sha1 hashes\nso the git tag command lists the current git tags\ntag1\ntag2\n\ngit tag -n prints tag's message\ntag1 blah blah\ntag2 blah blah\n\nWhat's the best way to get the hash of tag1 & tag2 ?" }, { "role": "assistant", "content": "To get git tags with the SHA1 hash of the Tag object, you can run:\ngit show-ref --tags\n\nThe output will then look something like:\n0e76920bea4381cfc676825f3143fdd5fcf8c21f refs/tags/1.0.0\n5ce9639ead3a54bd1cc062963804e5bcfcfe1e83 refs/tags/1.1.0\n591eceaf92f99f69ea402c4ca639605e60963ee6 refs/tags/1.2.0\n40414f41d0fb89f7a0d2f17736a906943c05acc9 refs/tags/1.3.0\n\nEach line is the SHA1 hash of the tag, followed by the tag name prefixed with refs/tags/.\nIf you want the SHA1 hash of the commit, instead of the tag object, you can run:\ngit show-ref --tags -d\n\nThis will produce output like:\n0e76920bea4381cfc676825f3143fdd5fcf8c21f refs/tags/1.0.0\n3e233dd8080617685992dc6346f739a6f6396aae refs/tags/1.0.0^{}\n5ce9639ead3a54bd1cc062963804e5bcfcfe1e83 refs/tags/1.1.0\n09173980152a7ed63d455829553448ece76c6fdc refs/tags/1.1.0^{}\n591eceaf92f99f69ea402c4ca639605e60963ee6 refs/tags/1.2.0\n56d803caaa8a93a040b7be0b8a36abdc4ce8c509 refs/tags/1.2.0^{}\n40414f41d0fb89f7a0d2f17736a906943c05acc9 refs/tags/1.3.0\n1bdf628a70fda7a0d840c52f3abce54b1c6b0130 refs/tags/1.3.0^{}\n\nThe lines ending with ^{} start with the SHA1 hash of the actual commit that the tag points to." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Automatic merge of pull requests on Github without the merge bubble\n\nThe \"This pull request can be automatically merged [Merge pull request]\" button in github is great -- except that it creates merge bubbles. \nIs there a way to use this button/functionality in github without it creating merge bubbles?" }, { "role": "assistant", "content": "No.\nThe git blog says using this button you always get an --no-ff merge (no fast-forward merge).\nYou'd have to do a manual merge if you don't want merge bubbles:\ngit checkout master\ngit remote add cameronmcefee git://github.com/cameronmcefee/Spoon-Knife.git\ngit fetch cameronmcefee \ngit merge cameronmcefee/my-branch\ngit push origin master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %gD" }, { "role": "assistant", "content": "reflog selector, e.g., refs/stash@{1} or refs/stash@{2\nminutes ago} ; the format follows the rules described for the -g option. The portion before the @ is the refname as\ngiven on the command line (so git log -g refs/heads/master would yield refs/heads/master@{0} )." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Highlight changed lines and changed bytes in each changed line\nOpen Source project Trac has an excellent diff highlighter — it highlights changed lines and changed bytes in each changed line! See here or here for examples.\nIs there way to use the same color highlight (i.e. changed lines and changed bytes too) in bash terminal, git, or vim for diff output (patch-file)?" }, { "role": "assistant", "content": "The diff-highlight Perl contrib script produces output so similar to that of the Trac screenshots that it is likely that Trac is using it:\n\nInstall with:\nwget https://raw.githubusercontent.com/git/git/fd99e2bda0ca6a361ef03c04d6d7fdc7a9c40b78/contrib/diff-highlight/diff-highlight && chmod +x diff-highlight\n\nMove the file diff-highlight to the ~/bin/ directory (or wherever your $PATH is), and then add the following to your ~/.gitconfig:\n[pager]\n diff = diff-highlight | less\n log = diff-highlight | less\n show = diff-highlight | less\n\nSingle copy paste install suggested by @cirosantilli:\ncd ~/bin\ncurl -O https://raw.githubusercontent.com/git/git/fd99e2bda0ca6a361ef03c04d6d7fdc7a9c40b78/contrib/diff-highlight/diff-highlight\nchmod +x diff-highlight\ngit config --global pager.log 'diff-highlight | less'\ngit config --global pager.show 'diff-highlight | less'\ngit config --global pager.diff 'diff-highlight | less'\ngit config --global interactive.diffFilter diff-highlight" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to fully delete a git repository created with init?\nI created a git repository with git init. I'd like to delete it entirely and init a new one." }, { "role": "assistant", "content": "Git keeps all of its files in the .git directory. Just remove that one and init again.\nIf you can't find it, it's because it is hidden.\n\nIn Windows 7, you need to go to your folder, click on Organize on the top left, then click on Folder and search options, then click on the View tab and click on the Show hidden files, folders and drives radio button.\nOn a Mac OS:\n\nOpen a Terminal (via Spotlight: press CMD + SPACE, type terminal and press Enter) and run:\ndefaults write com.apple.finder AppleShowAllFiles 1 && killall Finder\n\nNote: The keyboard shortcut to show hidden files in Finder is \nCMD + SHIFT + . so it is no longer necessary to modify the \nfinder config this way\nYou could also type cd (the space is important), drag and drop your git repo folder from Finder to the terminal window, press return, then type rm -fr .git, then return again.\n\nOn Ubuntu, use shortcut Ctrl + H." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git keeps prompting me for a password\n\nI've been using Git for a while now, but the constant requests for a password are starting to drive me up the wall.\nI'm using Mac OS X and GitHub, and I set up Git and my SSH keys as instructed by GitHub's Set Up Git page. \nI've also added the github SSH key to my Mac OS X keychain, as mentioned on GitHub's SSH key passphrases page. My public key is registered with Git.\nNevertheless, every time I try to Git pull, I have to enter my username and password. Is there something other than an SSH key that I need to set up for this?" }, { "role": "assistant", "content": "I think you may have the wrong Git repository URL. \nOpen .git/config and find the [remote \"origin\"] section. Make sure you're using the SSH one:\nssh://[email protected]/username/repo.git\n\nYou can see the SSH URL in the main page of your repository if you click Clone or download and choose ssh.\nAnd NOT the https or git one:\nhttps://github.com/username/repo.git\ngit://github.com/username/repo.git\n\nYou can now validate with just the SSH key instead of the username and password. \nIf Git complains that 'origin' has already been added, open the .config file and edit the url = \"...\" part after [remote origin] as url = ssh://github/username/repo.git\n\nThe same goes for other services. Make sure the address looks like: protocol://something@url\nE.g. .git/config for Azure DevOps:\n[remote \"origin\"]\n url = https://[email protected]/mystore/myproject/\n fetch = +refs/heads/*:refs/remotes/origin/*" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Convert Mercurial project to Git [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nConverting Mercurial folder to a Git repository\n\n (8 answers)\n \n\nClosed 5 years ago.\nThe community reviewed whether to reopen this question 8 months ago and left it closed:\n\nOriginal close reason(s) were not resolved\n\n\n\n\nI need to convert a mercurial project to a git project, but I would like to keep the commit history intact. My current solution was to just remove hg related files and then git init && add manually the files I needed, but that would not keep the history. Are there any solutions to this?" }, { "role": "assistant", "content": "You can try using fast-export:\ncd ~\ngit clone https://github.com/frej/fast-export.git\ngit init git_repo\ncd git_repo\n~/fast-export/hg-fast-export.sh -r /path/to/old/mercurial_repo\ngit checkout HEAD\n\nAlso have a look at this SO question.\n\nIf you're using Mercurial version below 4.6, adrihanu got your back:\nAs he stated in his comment: \"In case you use Mercurial < 4.6 and you got \"revsymbol not found\" error. You need to update your Mercurial or downgrade fast-export by running git checkout tags/v180317 inside ~/fast-export directory.\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I keep my fork in sync without adding a separate remote?\nLet's assume there is a repository someone/foobar on GitHub, which I forked to me/foobar.\nHow do I pull new commits from the parent repository directly to my fork, without having to add a separate remote and remember to pull regularly from there ?\nThe goal is to:\n\ngit pull to fetch from the parent repository\ngit push to send everything to my fork" }, { "role": "assistant", "content": "Open the forked Git repository me/foobar.\nClick on Compare:\n\nYou will get the notification:\n\nThere isn't anything to compare.\nsomeone:master is up to date with all commits from me:master. Try switching the base for your comparison.\n\nClick on switching the base on this page:\n\nThen you get to see all the commits made to someone/foobar after the day you forked it.\nClick on Create pull request:\n\nGive the pull request a title and maybe a description and click Create pull request.\nOn the next page, scroll to the bottom of the page and click Merge pull request and Confirm merge.\nYour Git repository me/foobar will be updated.\nEdit: rebase options are shown here:" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-prune" }, { "role": "assistant", "content": "Prune all unreachable objects from the object database" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitattributes - Defining attributes per path Set" }, { "role": "assistant", "content": "Notice all types of potential whitespace errors known to Git.\nThe tab width is taken from the value of the core.whitespace configuration variable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to move a git repository into another directory and make that directory a git repository?\nI have a directory gitrepo1. This directory is a git repository.\n\nI would like to move this gitrepo1 into another directory newrepo.\nDirectory newrepo should be the new git repository with no loss of git history and should contain the directory gitrepo1.\nDirectory gitrepo1 should just be a directory now (inside newrepo), without any .git index, i.e. it should NO longer be an independent git repository or a submodule.\n\nHow can I do this?" }, { "role": "assistant", "content": "It's very simple. Git doesn't care about what's the name of its directory. It only cares what's inside. So you can simply do:\n# copy the directory into newrepo dir that exists already (else create it)\n$ cp -r gitrepo1 newrepo\n\n# remove .git from old repo to delete all history and anything git from it\n$ rm -rf gitrepo1/.git\n\nNote that the copy is quite expensive if the repository is large and with a long history. You can avoid it easily too:\n# move the directory instead\n$ mv gitrepo1 newrepo\n\n# make a copy of the latest version\n# Either:\n$ mkdir gitrepo1; cp -r newrepo/* gitrepo1/ # doesn't copy .gitignore (and other hidden files)\n\n# Or:\n$ git clone --depth 1 newrepo gitrepo1; rm -rf gitrepo1/.git\n\n# Or (look further here: http://stackoverflow.com/q/1209999/912144)\n$ git archive --format=tar --remote=<repository URL> HEAD | tar xf -\n\n\nOnce you create newrepo, the destination to put gitrepo1 could be anywhere, even inside newrepo if you want it. It doesn't change the procedure, just the path you are writing gitrepo1 back." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Change drive in git bash for windows\nI was trying to navigate to my drive location E:/Study/Codes in git bash in windows. In command prompt in order to change drive I use E: It returns an error in git bash. \n\nbash: E:: command not found.\n\nHow do I change my current directory location from /c/users to E:Study/Codes" }, { "role": "assistant", "content": "In order to navigate to a different drive just use\ncd /E/Study/Codes" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git error: \"Host Key Verification Failed\" when connecting to remote repository\nI am trying to connect to a remote Git repository that resides on my web server and clone it to my machine.\nI am using the following format for my command:\ngit clone ssh://[email protected]/repository.git\n\nThis has worked fine for most of my team members. Usually after running this command Git will prompt for the user's password, and then run the cloning. However, when running on one of my machines I get the following error:\n\nHost key verification failed.\nfatal: Could not read from remote\nrepository.\n\nWe are not using SSH keys to connect to this repository, so I'm not sure why Git is checking for one on this particular machine." }, { "role": "assistant", "content": "As I answered previously in Cloning git repo causes error - Host key verification failed. fatal: The remote end hung up unexpectedly, add GitHub to the list of known hosts:\nssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git --include-paths=<regex>" }, { "role": "assistant", "content": "When passed to init or clone this regular expression will\nbe preserved as a config key. See fetch for a description\nof --include-paths ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-push - Update remote refs along with associated objects -v --verbose" }, { "role": "assistant", "content": "Run verbosely." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to link folder from a git repo to another repo?\n\nI want to create a public repo to put some sample files from my main repo (private). Is there any way to soft link few folders from a git repo to another git repo?" }, { "role": "assistant", "content": "Then you should use submodules for this task.\nSubmodule are different git repositories under the same root.\nThis way you can manage 2 different project at folder level inside the root repository\n\nSubmodules allow foreign repositories to be embedded within a dedicated subdirectory of the source tree, always pointed at a particular commit.\n\n\ngit submodule\nBreak your big project to sub projects as you did so far.\nNow add each sub project to you main project using :\ngit submodule add <url>\n\nOnce the project is added to your repo, you have to init and update it.\ngit submodule init\ngit submodule update\n\nAs of Git 1.8.2 new option --remote was added\ngit submodule update --remote --merge\n\nwill fetch the latest changes from upstream in each submodule, merge them in, and check out the latest revision of the submodule.\nAs the docs describe it:\n\n--remote\nThis option is only valid for the update command. Instead of using the superproject’s recorded SHA-1 to update the submodule, use the status of the submodule’s remote-tracking branch.\n\nThis is equivalent to running git pull in each submodule.\n\n\nHowever, how would I push a commit in the scenario of bug fix in C which affects the code shared with the parent layers?\n\nAgain: using submodule will place your code inside your main project as part of its content. The difference between having it locally inside the folder or having it as part of a submodule is that in submodule the content is managed (commited) to a different standalone repository.\n\nThis is an illustration of submodule - project inside another project in which each project is a standalone project.\n\n\ngit subtree\nGit subtree allows you to insert any repository as a sub-directory of another one\nVery similar to submodule but the main difference is where your code is managed. In submodules the content is placed inside a separate repo and is managed there which allow you to clone it to many other repos as well.\nsubtree is managing the content as part of the root project and not in a separate project.\nInstead of writing down how to set it up and to understand how to use it you can simply read this excellent post which will explain it all.\nhttps://developer.atlassian.com/blog/2015/05/the-power-of-git-subtree/" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to commit a change in git when git commit opens Nano?\nI'm new to git and I'm trying to commit my first changes on a Windows machine. However, when I type in $git commit it takes me to a different screen than any online tutorials show or than what is mentioned in Pro Git. No online searching yields an explanation of how to use this screen, either.\nThe screen looks like this: \nI have tried every key on the keyboard, but nothing seems to actually do the commit. Also there are all these little help options in green at the bottom of the screen that seem to be giving commands, but when I press the buttons they show it just types them into the commit message. What are those help options and how do I use them?\nEveryone else seems to be using something called \"vim\" which I believe I chose not to install when installing Git because I thought the Windows console was fine.\nSo how do I actually commit and what are those green commands at the bottom of the screen? Thanks!" }, { "role": "assistant", "content": "That screen is just a text editor and those options at the bottom, represent commands, tipically its the ctrl key + the letter for the command.\nTo make the commit you should write your commit message, then press ctrl+o to write your message, and then ctrl+x to exit that screen.\nTo avoid that screen you could do something like git commit -m 'your commit message', the -m indicates that your commit message goes in the command." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch theirs" }, { "role": "assistant", "content": "This is the opposite of ours ; note that, unlike ours , there is\nno theirs merge strategy to confuse this merge option with." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs" }, { "role": "assistant", "content": "DESCRIPTION Shows the commit logs. List commits that are reachable by following the parent links from the\ngiven commit(s), but exclude commits that are reachable from the one(s)\ngiven with a ^ in front of them. The output is given in reverse\nchronological order by default. You can think of this as a set operation. Commits reachable from any of\nthe commits given on the command line form a set, and then commits reachable\nfrom any of the ones given with ^ in front are subtracted from that\nset. The remaining commits are what comes out in the command’s output.\nVarious other options and paths parameters can be used to further limit the\nresult. Thus, the following command: $ git log foo bar ^baz means \"list all the commits which are reachable from foo or bar , but\nnot from baz \". A special notation \" <commit1> .. <commit2> \" can be used as a\nshort-hand for \"^ <commit1> <commit2> \". For example, either of\nthe following may be used interchangeably: $ git log origin..HEAD\n$ git log HEAD ^origin Another special notation is \" <commit1> …​ <commit2> \" which is useful\nfor merges. The resulting set of commits is the symmetric difference\nbetween the two operands. The following two commands are equivalent: $ git log A B --not $(git merge-base --all A B)\n$ git log A...B The command takes options applicable to the git-rev-list command to control what is shown and how, and options applicable to\nthe git-diff command to control how the changes\neach commit introduces are shown." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc default , myers" }, { "role": "assistant", "content": "The basic greedy diff algorithm. Currently, this is the default." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options mergetool.<vimdiff variant>.layout" }, { "role": "assistant", "content": "Configure the split window layout for vimdiff’s <variant> , which is any of vimdiff , nvimdiff , gvimdiff .\nUpon launching git mergetool with --tool=<variant> (or without --tool if merge.tool is configured as <variant> ), Git will consult mergetool.<variant>.layout to determine the tool’s layout. If the\nvariant-specific configuration is not available, vimdiff 's is used as\nfallback. If that too is not available, a default layout with 4 windows\nwill be used. To configure the layout, see the BACKEND SPECIFIC HINTS section in git-mergetool ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Disable pipeline for every commit in Gitlab and only run it on open merge request\n\nThe CI pipeline runs on every commit in my Gitlab repository at work. Is there way to disable that and only run the CI pipeline on an open merge request to the master branch?" }, { "role": "assistant", "content": "There is currently no configuration option to do that. Here are some things that can be used to \"disable\" a pipeline build.\n\nAdding [ci skip] inside the commit message will not trigger a pipeline on push.\nUsing except and only options on all jobs inside the pipeline. To avoid duplication in this case, you can use Anchors.\n\nUpdate: GitLab 11.7\nWhen pushing to GitLab you can skip triggering a pipeline by passing ci.skip option to the push command: git push -o ci.skip" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-notes - Add or inspect object notes GIT_NOTES_REWRITE_MODE" }, { "role": "assistant", "content": "When copying notes during a rewrite, what to do if the target\ncommit already has a note.\nMust be one of overwrite , concatenate , cat_sort_uniq , or ignore .\nThis overrides the core.rewriteMode setting." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Android Studio Git Push Rejected\nI'm trying to uploading my Android Project on github but I get this error when I try to push:\nPush rejected: Push to origin/master was rejected\n\nI made this steps:\n\nVCS->Import into version control->Create new repository...\nFrom the git bash in Project folder:\ngit remote add origin https://github.com/[username]/[project_name].git\nGit->Add\nGit-> Commit directory\nGit-> Push" }, { "role": "assistant", "content": "after push follow these,\nVCS --> Git --> Branches\nthen select origin/master --> Rebase\nafter finish rebase successful message, you could able to push to remote directory." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index color" }, { "role": "assistant", "content": "Highlight changed words using only colors. Implies --color ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to make 'git log' decorate by default\nI frequently type git log when what I actually want is git log --decorate. How do I make it decorate by default?\nI have seen lots of answers of the form \"make an alias lg and then type git lg instead of git log\". But, I can't find anywhere how to change the default behaviour of git log itself. alias log does not work." }, { "role": "assistant", "content": "git config log.decorate auto\nFor a global setting, add the --global parameter.\nSo it would be:\ngit config --global log.decorate auto\n\nThe aliases are made with git config alias.lg \"log --decorate\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git submodules workflow\nIn my project I need to use third party code, stored in several Git repositories. My project is also stored in (separate) Git repository. There are several people working with me on the main project, and I'm the maintainer.\nIn earlier projects I used to copy dependencies manually to the Git working tree, adding a little file specifying version I use.\nNow this is rather uncomfortable since I need to update daily one of dependencies, and often contribute code to it myself, most of the time coupled with changes into the main project.\nI've decided to try Git submodules to do the management. The more I try them, the more frustrated I become. It even seems that manual copy is, perhaps, better.\nHere are some of my concerns:\n\nWe're no longer able to get consistent repository state with a single command (git checkout now needs git submodule update --init). \nWe're not able to use some of the Git tools properly (git archive is the most notable).\nWe're not able to see the status changes / diffs into submodules from the main project.\nAs I've just found in a hard way, git submodule does not work with --git-dir and --work-tree options, and require physical change of current directory to the \"toplevel of the working tree\". \n\nIt seems that in order to streamline our submodules workflow (that is one operation == one command) we have to write a rather thick wrapper around Git. This is sad.\nNote that it is not an option to move away from Git or to merge subproject development entirely into the main project.\nPerhaps I'm using git submodules in a wrong way? Is there any good tutorial on the workflow?\nPlease speak up even if you don't know the proper answer, but do share my concerns. :-)" }, { "role": "assistant", "content": "You may want to try git subtree (alt link) instead. I’ve had a lot of luck with it, using both remote repos and clean (untied to master history) branches in my project." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "github server-side git hooks (i.e. pre-commit and post-commit)\nI've looked around the answers on SO, and the web, and I can't see anything on how to set up a server-side git hook on github (as opposed to webhooks). Is there a way to do this?\nOr alternatively, is there a way to set it up so that .git/hooks is a symlink to a part of the working tree at the time of cloning?\nI should add that this is an internally-hosted github server." }, { "role": "assistant", "content": "For obvious reasons, GitHub won’t allow you to execute arbitrary code on their servers as part of Git hooks. The only hooking they allow is through their webhooks or the integrated third-party services.\nIf you need to run some custom code, you will have to host that somewhere and set up a webhook to run it on your own server." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary hash" }, { "role": "assistant", "content": "In Git’s context, synonym for object name ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --stdout" }, { "role": "assistant", "content": "Print all commits to the standard output in mbox format,\ninstead of creating a file for each one." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitignore - Specifies intentionally untracked files to ignore" }, { "role": "assistant", "content": "NOTES The purpose of gitignore files is to ensure that certain files\nnot tracked by Git remain untracked. To stop tracking a file that is currently tracked, use git rm --cached to remove the file from the index. The filename\ncan then be added to the .gitignore file to stop the file from\nbeing reintroduced in later commits. Git does not follow symbolic links when accessing a .gitignore file in\nthe working tree. This keeps behavior consistent when the file is\naccessed from the index or a tree versus from the filesystem." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters --all" }, { "role": "assistant", "content": "Show all refs found in refs/ ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-clone - Clone a repository into a new directory --filter= <filter-spec>" }, { "role": "assistant", "content": "Use the partial clone feature and request that the server sends\na subset of reachable objects according to a given object filter.\nWhen using --filter , the supplied <filter-spec> is used for\nthe partial clone filter. For example, --filter=blob:none will\nfilter out all blobs (file contents) until needed by Git. Also, --filter=blob:limit= <size> will filter out all blobs of size\nat least <size> . For more details on filter specifications, see\nthe --filter option in git-rev-list ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: Is there a way to figure out where a commit was cherry-pick'ed from?\nIf I cherry-pick from multiple branches, is there a simple way to figure out where the commit was coming from (e.g. the sha of the original commit)?\nExample:\n- at master branch\n- cherry pick commit A from a dev branch\n- A becomes D at the master branch \nBefore:\n* B (master) Feature Y\n| * C (dev) Feature Z\n| * A Feature X\n|/\n* 3\n* 2\n* 1 \n\nAfter:\n* D (master) Feature X\n* B Feature Y\n| * C (dev) Feature Z\n| * A Feature X\n|/\n* 3\n* 2\n* 1 \n\nIs it possible to figure out that D was cherry-picked from A (aside from searching for the commit message)?\nEdit:\nAlthough I will go with daggy-fixes (see VonCs answer) I accepted Chris Johnsens answer because it is closer to the actual question. Thanks guys." }, { "role": "assistant", "content": "By default, the information about the original, “cherry” commit is not recorded as part of the new commit.\nRecord the Source Commit in the Commit Message\nIf you can force the use of particular workflows/options, \ngit cherry-pick has the -x option:\n\nWhen recording the commit, append to the original commit message a note that indicates which commit this change was cherry-picked from.\n\nThis is obviously useless if you can not rely on the cherry pickers using the option.\nAlso, since the recorded information is just plain text—not an actual reference as far as Git is concerned—even if you use -x, you still have to take steps to make sure that the original commit is kept alive (e.g. is is part of the DAG of a tag or a non-rewinding branch).\ngit cherry and git patch-id\nIf you can restrict your search to two particular branches of the history DAG, then git cherry can find both “unpicked” and “picked” cherries.\nNote: This command (and the related git patch-id) can only identify conflict-free cherries that were individually picked without extra changes. If there was a conflict while picking the cherry (e.g. you had to slightly modify it to get it to apply), or you used -n/--no-commit to stage extra changes (e.g. multiple cherries in a single commit), or the content of the commit was rewritten after the picking, then you will have to rely on commit message comparison (or the -x information if it was recorded).\ngit cherry is not really designed to identify the origin of picked cherries, but we can abuse it a bit to identify single cherry pairs.\nGiven the following history DAG (as in the original poster’s example):\n1---2---3---B---D master\n \\\n A---C dev\n# D is a cherry-picked version of C\n\nyou will see something like this:\n% git cherry master dev\n+ A\n- C\n% git cherry dev master\n+ B\n- D\n\n(A, B, C, and D are full SHA-1 hashes in the real output)\nSince we see one cherry (the - lines) in each list, they must form a cherry pair. D was a cherry picked from C (or vice versa; you can not tell by the DAG alone, though the commit dates might help).\nIf you are dealing with more than one potential cherry, you will have to “roll your own” program to do the mapping. The code should be easy in any language with associative arrays, hashes, dictionaries, or equivalent. In awk, it might look like this:\nmatch_cherries() {\n a=\"$(git rev-parse --verify \"$1\")\" &&\n b=\"$(git rev-parse --verify \"$2\")\" &&\n git rev-list \"$a...$b\" | xargs git show | git patch-id |\n awk '\n { p[$1] = p[$1] \" \" $2 }\n END { \n for (i in p) {\n l=length(p[i])\n if (l>41) print substr(p[i],2,l-1)\n }\n }'\n}\nmatch_cherries master dev\n\nWith an extended example that has two picked cherries:\n1---2---3---B---D---E master\n \\\n A---C dev\n# D is a cherry-picked version of C\n# E is a cherry-picked version of A\n\nThe output might look like this:\nmatch_cherries master dev\nD C\nE A\n\n(A, C, D, and E are full SHA-1 hashes in the real output)\nThis tells us that C and D represent the same change and that E and A represent the same change. As before, there is no way to tell which of each pair was “the first” unless you also consider (e.g.) the commit dates of each commit.\nCommit Message Comparison\nIf your cherries were not picked with -x, or they are “dirty” (had conflicts, or other changes added to them (i.e. with --no-commit plus staging extra changes, or with git commit --amend or other “history rewriting” mechanism)), then you may have to fall back on less the less reliable technique of comparing commit messages.\nThis technique works best if you can find some bit of the commit message that is likely to be unique to the commit and is unlikely to have changed in the commit that resulted from the cherry pick. The bit that would work best would depend on the style of commit messages used in your project.\nOnce you have picked out an “identifying part” of the message, you can use git log to find commits (also demonstrated in Jefromi’s answer).\ngit log --grep='unique part of the commit message' dev...master\n\nThe argument to --grep is actually a regular expression, so you might need to escape any regexp metacharacters ([]*?.\\).\nIf you are not sure which branches might hold the original commit and the new commit, you can use --all as Jefromi showed." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --numstat" }, { "role": "assistant", "content": "Similar to --stat , but shows number of added and\ndeleted lines in decimal notation and pathname without\nabbreviation, to make it more machine friendly. For\nbinary files, outputs two - instead of saying 0 0 ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Visualize branches on GitHub\n\nIn TortoiseGit, gitk or on BitBucket, it is common to have a visualization of the project history with all the branches, like this:\n\nHowever, GutHub's commit history seems to be flat, at least I couldn't find a way to display this kind of graph. Can the GitHub's web UI somehow visualize branches like other Git clients commonly can?" }, { "role": "assistant", "content": "You can see a graph, but without commit messages in Insights => Network section (commit messages with authors are shown on hover).\nNote: this works for public repos or GitHub Enterprise only!\nExample: https://github.com/google/orbit/network" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Using git, how do you reset the working tree (local file system state) to the state of the index (\"staged\" files)?\nSituation:\n\nEdit files\nAdd files to the index with git add (these files are now \"staged\")\nEdit more files\n\nNow we have three different states: the state of HEAD (which points to the last commit), the state of the index (which includes all added, or \"staged\" files) and the state of the working tree (the unstaged, local file system state). What is the command to undo changes in the working tree so that it matches the state of the index?" }, { "role": "assistant", "content": "I tend to use git checkout . which discards all changes from the working directory down. This makes a difference if you're not at the root of the repository.\nThis command doesn't remove newly created files which is usually a good thing. If you need to do this then you can use git clean as well." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Reference an issue from a commit message in gitlab\n\nIs it possible to make a reference to an issue in Gitlab from a commit message?\nI haven't found anything on the web." }, { "role": "assistant", "content": "There should be a way to reference a GitLab issue from a commit message, simply with #xx (id of the issue).\nConsider \"Default closing pattern value \"\n\nFor example the following commit message:\nAwesome commit message\n\nFix #20, Fixes #21 and Closes group/otherproject#22.\nThis commit is also related to #17 and fixes #18, #19\nand https://gitlab.example.com/group/otherproject/issues/23.\n\nwill close #18, #19, #20, and #21 in the project this commit is pushed to, as well as #22 and #23 in group/otherproject.\n#17 won't be closed as it does not match the pattern.\nIt works with multi-line commit messages as well as one-liners when used with git commit -m.\n\nSee also \"Tutorial: It's all connected in GitLab\"\n\nAdd references in issue or merge request descriptions or in comments.\nThis will update the issue with info about anything related.\n\nTo reference an issue: #123\nTo reference a MR: !123\nTo reference a snippet $123\n\n\n\npierreb adds in the comments:\n\nAlthough this is not specifically asked in the original question, it may be worth adding that one can also cross-reference a previous commit in a new commit message in Gitlab.\nYou do it by copying the hash from the commit message you want to reference and simply pasting it in the new commit message.\nSomething along these lines:\nThis is related with commit 7as7b101\n\n\nYou can see (much) more in:\n\n\"gitlab-ce issue 13345 'ability to reference a commit'\"\n\"Tutorial: It's all connected in GitLab\".\n\nandrybak adds in the comments:\n\n\n\"You do it by copying the hash from the commit message you want to reference and simply pasting it in the new commit message.\"\n\nThere is also a special, more human-readable format:\ngit log -1 --format=reference\n\n<abbrev-hash> (<title-line>, <short-author-date>)\n\nSee git log PRETTY FORMATS\n\n\nThis format is used to refer to another commit in a commit message and is the same as --pretty='format:%C(auto)%h (%s, %ad)'.\nBy default, the date is formatted with --date=short unless another --date option is explicitly specified.\nAs with any format: with format placeholders, its output is not affected by other options like --decorate and --walk-reflogs.\n\n\nFr0zenFyr adds in the comments:\n\nSimilarly, even a closed issue can be referenced like Related to #78 and #93." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I force git to checkout the master branch and remove carriage returns after I've normalized files using the \"text\" attribute?\nOkay, so I added the file .gitattributes with lines like this\n*.css text\n*.js text\netc...\n\nI then followed the instructions at http://git-scm.com/docs/gitattributes#_checking-out_and_checking-in\n$ rm .git/index # Remove the index to force Git to\n$ git reset # re-scan the working directory\n$ git status # Show files that will be normalized\n$ git add -u\n$ git add .gitattributes\n$ git commit -m \"Introduce end-of-line normalization\"\n\nBut now my working copy still has the carriage returns! I have untracked files that I would like to keep. How do I have git checkout the master branch again with the normalized files?\nI know the files are normalized in the repository because when I clone the repo, I have all the files without the carriage returns." }, { "role": "assistant", "content": "Ah ah! Checkout the previous commit, then checkout the master.\ngit checkout HEAD^\ngit checkout -f master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Delete a svn-Branch via git?\nI'am using git as scm of choice but have to use a svn-repo. I can create a svn-remote-branch like this:\ngit svn branch the_branch\n\nBut how can i delete the remote branch?" }, { "role": "assistant", "content": "Currently, it is not possible to delete an SVN branch using git-svn. But it is easy to delete the branch using SVN, without even having to check it out. So simply type \nsvn rm $URL/branches/the_branch\n\nPlease note that deleting a Subversion branch does not cause it to be deleted from the git-svn repository. (This is intentional, because deleting a Subversion branch does not cause any information loss, whereas deleting a git branch causes its existence to be forgotten following the next git garbage collection.) So if you want the remote SVN branch to be deleted from your git repository, you have to do it manually:\ngit branch -D -r the_branch\nrm -rf .git/svn/the_branch\n\nOR\nrm -rf .git/svn/refs/remotes/f8745/ (for newer versions)\n\nTo delete a git branch that corresponds to a Subversion tag, the commands are slightly different:\ngit branch -D -r tags/the_tag\nrm -rf .git/svn/tags/the_tag" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Error loading key \"(stdin)\": invalid format Gitlab CI\n\nThis is piece of my yaml file about ssh for gitlab ci:\neval $(ssh-agent -s)\necho \"$SSH_PRIVATE_KEY\" | tr -d '\\r' | ssh-add - > /dev/null\nmkdir -p ~/.ssh\nchmod 700 ~/.ssh\n'[[ -f /.dockerenv ]] && echo -e \"Host *\\n\\tStrictHostKeyChecking no\\n\\n\" > ~/.ssh/config'\n\nWhen I attempted to set SSH_PRIVATE_KEY variable to protected state, it occurs error:\n\nError loading key \"(stdin)\": invalid format\n\nand I don't know why it's okay when I set SSH_PRIVATE_KEY variable to unprotected state" }, { "role": "assistant", "content": "For me it also failed because the SSH_PRIVATE_KEY was marked as \"Protected\" but the tag I was using was not.\nSo either make the branch or tag you are using also protected or remove the \"Protected\" setting from the SSH_PRIVATE_KEY variable.\nSee: https://gitlab.com/help/ci/variables/README#create-a-custom-variable-in-the-ui\n\nProtect variable (Optional): If selected, the variable will only be available in pipelines that run on protected branches or tags." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Jenkins and Git sparse checkouts\nI have a large repository in Git. How do I create a job in Jenkins that checks out just one sub-folder from the project?" }, { "role": "assistant", "content": "Jenkins Git Plugin support sparse checkouts since git-plugin 2.1.0 (April, 2014). You will need git >= 1.7.0 for this feature. It is under \"Additional Behaviors\" -> \"Sparse Checkout paths.\" \n\nSee: Jira issue JENKINS-21809" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository -f --force" }, { "role": "assistant", "content": "When git fetch is used with <src>:<dst> refspec, it may\nrefuse to update the local branch as discussed\nin the <refspec> part below.\nThis option overrides that check." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-mv - Move or rename a file, a directory, or a symlink -n --dry-run" }, { "role": "assistant", "content": "Do nothing; only show what would happen" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Merging changes from master into my branch\nI have two branches in git: master and custom_branch.\nSomebody added some code to master that I need to use in my custom_branch. I tried this:\ngit branch custom_branch\ngit merge master\n\nBut when I do that, it says:\nAlready up-to-date.\n\nBut, when I compare master and custom_branch, the changes are still not there. What am I missing?\nP.S. I don't want to rebase since other people also use this branch." }, { "role": "assistant", "content": "git checkout custom_branch && git rebase master\nThis will update custom_branch with changes from master branch.\nDon't forget to make sure master is up to date first. git pull\n\nThis is also possible with git checkout custom_branch && git merge master\n\nFor an explanation on why the first one is (probably) what you should be using: When do you use git rebase instead of git merge?" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "'gh' is not recognized... error while trying to create GitHub repo from command prompt\nI'm following the instructions on how to add an existing project to GitHub from GitHub docs. However, I get an 'gh' is not recognized as an internal or external command, operable program or batch file. error message when I try to use gh repo create fs1 command in the project root directory as instructed. Here fs1 is my project name. I browsed StackOverflow but couldn't find any help yet. What am I missing?" }, { "role": "assistant", "content": "The page you are following doesn't include the instructions to install the GitHub CLI, so it is likely you don't have it installed (it doesn't come with git as far as I know).\nInstallation instructions can be found here: https://cli.github.com/" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitLab configuration\n\nI try to install Gitlab 5.2 on OS-X Server 10.8.5. I follow the procedure document from :\n \"http://thoughtpointers.net/2013/05/23/installing-gitlab-v52-on-os-x/\".\nIn the section of the document titled \"Configure GitLab\" they ask to edit the file \"gitlab.yml\" and change \"gitlab.example.com\" with the \"fully qualified domain name\" of your host serving Gitlab.\nI dont understand what I need to change..\n\n1. Do I need to change \"host: gitlab.example.com\" with \"localhost\" ? or with \"server.local => what I get when typing \"hostname\") ?\n\n\n2. What is \"gitlab.example.com\" ? Something to download and install on my computer (so where?)? What replace it ?\n\n\nI think when I type the address on my browser :\n\n \"http://fully qualified domain name\"\n\n\nI will receive a page, from where comes that page (is it an index.html/php?) - where is the folder of that page/project...\n\n\nThanks for the assistance." }, { "role": "assistant", "content": "By default, what you see in the config/gitlab.yml is:\n ## GitLab settings\n gitlab:\n ## Web server settings\n host: localhost\n port: 80\n https: false\n\nThat allows you to test Gitlab locally.\nIf you replace:\nhost: localhost\n\nwith:\nhost: ip.address (192.168.x.x)\n#\nhost: fqn (your fully qualified name)\n\nThen you will be able to test / access GitLab from another computer.\nSo gitlab.example.com is an example of such a fully qualified name, and should be changed by your own.\nAs explained here, check what host hostname returns." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options rebase.autoStash" }, { "role": "assistant", "content": "When set to true, automatically create a temporary stash entry\nbefore the operation begins, and apply it after the operation\nends. This means that you can run rebase on a dirty worktree.\nHowever, use with care: the final stash application after a\nsuccessful rebase might result in non-trivial conflicts.\nThis option can be overridden by the --no-autostash and --autostash options of git-rebase .\nDefaults to false." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs git log master --not --remotes=*/master" }, { "role": "assistant", "content": "Shows all commits that are in local master but not in any remote\nrepository master branches." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options push.default" }, { "role": "assistant", "content": "Defines the action git push should take if no refspec is\ngiven (whether from the command-line, config, or elsewhere).\nDifferent values are well-suited for\nspecific workflows; for instance, in a purely central workflow\n(i.e. the fetch source is equal to the push destination), upstream is probably what you want. Possible values are: nothing - do not push anything (error out) unless a refspec is\ngiven. This is primarily meant for people who want to\navoid mistakes by always being explicit. current - push the current branch to update a branch with the same\nname on the receiving end. Works in both central and non-central\nworkflows. upstream - push the current branch back to the branch whose\nchanges are usually integrated into the current branch (which is\ncalled @{upstream} ). This mode only makes sense if you are\npushing to the same repository you would normally pull from\n(i.e. central workflow). tracking - This is a deprecated synonym for upstream . simple - push the current branch with the same name on the remote. If you are working on a centralized workflow (pushing to the same repository you\npull from, which is typically origin ), then you need to configure an upstream\nbranch with the same name. This mode is the default since Git 2.0, and is the safest option suited for\nbeginners. matching - push all branches having the same name on both ends.\nThis makes the repository you are pushing to remember the set of\nbranches that will be pushed out (e.g. if you always push maint and master there and no other branches, the repository you push\nto will have these two branches, and your local maint and master will be pushed there). To use this mode effectively, you have to make sure all the\nbranches you would push out are ready to be pushed out before\nrunning git push , as the whole point of this mode is to allow you\nto push all of the branches in one go. If you usually finish work\non only one branch and push out the result, while other branches are\nunfinished, this mode is not for you. Also this mode is not\nsuitable for pushing into a shared central repository, as other\npeople may add new branches there, or update the tip of existing\nbranches outside your control. This used to be the default, but not since Git 2.0 ( simple is the\nnew default)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-commit-tree - Create a new commit object -F <file>" }, { "role": "assistant", "content": "Read the commit log message from the given file. Use - to read\nfrom the standard input. This can be given more than once and the\ncontent of each file becomes its own paragraph." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository <group>" }, { "role": "assistant", "content": "A name referring to a list of repositories as the value\nof remotes.<group> in the configuration file.\n(See git-config )." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --clear-decorations" }, { "role": "assistant", "content": "When specified, this option clears all previous --decorate-refs or --decorate-refs-exclude options and relaxes the default\ndecoration filter to include all references. This option is\nassumed if the config value log.initialDecorationSet is set to all ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-checkout" }, { "role": "assistant", "content": "Switch branches or restore working tree files" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --ancestry-path[=<commit>]" }, { "role": "assistant", "content": "Limit the displayed commits to those which are an ancestor of\n<commit>, or which are a descendant of <commit>, or are <commit>\nitself. As an example use case, consider the following commit history: D---E-------F\n\t / \\ \\\n\t B---C---G---H---I---J\n\t / \\\n\tA-------K---------------L--M A regular D..M computes the set of commits that are ancestors of M ,\nbut excludes the ones that are ancestors of D . This is useful to see\nwhat happened to the history leading to M since D , in the sense\nthat “what does M have that did not exist in D ”. The result in this\nexample would be all the commits, except A and B (and D itself,\nof course). When we want to find out what commits in M are contaminated with the\nbug introduced by D and need fixing, however, we might want to view\nonly the subset of D..M that are actually descendants of D , i.e.\nexcluding C and K . This is exactly what the --ancestry-path option does. Applied to the D..M range, it results in: E-------F\n\t\t \\ \\\n\t\t G---H---I---J\n\t\t\t \\\n\t\t\t\tL--M We can also use --ancestry-path=D instead of --ancestry-path which\nmeans the same thing when applied to the D..M range but is just more\nexplicit. If we instead are interested in a given topic within this range, and all\ncommits affected by that topic, we may only want to view the subset of D..M which contain that topic in their ancestry path. So, using --ancestry-path=H D..M for example would result in: E\n\t\t \\\n\t\t G---H---I---J\n\t\t\t \\\n\t\t\t\tL--M Whereas --ancestry-path=K D..M would result in K---------------L--M" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I prevent auto-generated links in the GitHub wiki?\n\nOn a GitHub wiki page, if I type:\nwww.foobar.com\n\nGitHub automatically assumes this is a URL and makes the text a hyperlink to http://www.foobar.com. However, sometimes I do not want a hyperlink to be created. Is there a way to stop this behavior? Perhaps some sort of markdown?" }, { "role": "assistant", "content": "Update Nov. 2021, VSCode 1.63:\nThis issue should be allievated with issue 136198 \"markdown preview wrongly creates links \"\n\nWhile \"markdown.preview.linkify\": false will disable linkify features entirely, setting md.linkify.fuzzyLink to false will disable it only for links without http(s) header.\nWhich, I think, is a better alternative, and it's already supported by markdown-it.\n\n\nOriginal answer (2014):\nThis isn't limited to wiki page, and is part of the GFM (GitHub Flavored Markdown) url autolinking feature.\nPutting them in `` can work but display the url as a code: foo http://example.com bar.\nfoo `http://example.com` bar\n\nAnother trick (mentioned in this gist) is\nht<span>tp://</span>example.com \n\nThat will display http://example.com as regular text.\nIn your case (without the http://)\nw<span>ww.</span>foobar.com\n\nThat would also display www.foobar.com as regular text.\ngeekley adds in the comments:\n\nFor emails, you can use foo<span>@</span>example.com\n\n\nVenryx suggests in the comments a shorter/cleaner solution:\n\nJust add one of the void element tags (I prefer <area>), at a location that breaks the URL detectability, eg. right before the first dot.\nExample: www<area>.foobar.com" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rebase - Reapply commits on top of another base tip stop ask" }, { "role": "assistant", "content": "The rebase will halt when the commit is applied, allowing you to\nchoose whether to drop it, edit files more, or just commit the empty\nchanges. This option is implied when -i / --interactive is\nspecified. ask is a deprecated synonym of stop ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub Merge branch 'master'\n\nBeen trying out Git and Github after many years of svn use. I seem to have the basics down, but one item is confusing me.\n\nUserA makes a change to FileA and pushes to the remote server\n(GitHub) \nUserB makes a change to FileB. He first pulls from remote\nserver, and then pushes his change to FileB to the remote server\nGitHub commit history shows the push from UserA and the push from UserB\nHowever, there is an additional entry in the commit history from UserB called 'Merge branch 'master' of https://github.com/xxx/yyy'. Viewing the diff in Github shows this to be an exact replica of the Changes that UserA made to FileA\n\nWhy is this duplicate shown - both the push from UserA to FileA and the Merge branch master entries are identical...the second seems superfluous to me." }, { "role": "assistant", "content": "Each version (\"commit\") stored in git forms part of a graph, and it's frequently helpful to think about what you're doing in git in terms of that graph.\nWhen UserA begins, let's say that there had only been two commits created, which we'll call P and Q:\nP--Q (master)\n\nHe then modifies FileA, stages that change and creates a commit that represents the new state of the source code - let's say that commit is called R. This has a single parent, which is the commit Q:\nP--Q--R (master)\n\nAfter successfully pushing, the commit graph for the GitHub repository looks the same.\nUserB started with the same history:\nP--Q (master)\n\n... but created a different commit, say called S, which has his modified version of FileB:\nP--Q--S (master)\n\nUserB tries to push that to GitHub, but the push is refused - unless you \"force\" the push, you're not allowed to update a remote branch unless the version you're pushing includes all of the history in that remote branch. So, UserB pulls from GitHub. A pull really consists of two steps, fetching and merging. The fetch updates origin/master, which is like a cache of the state of the remote branch master from the remote origin. (This is an example of a \"remote-tracking branch\".)\nP--Q--S (master)\n \\\n R (origin/master)\n\nThe history in this graph has diverged, so the merge tries to unify those two histories by creating a merge commit (say M) which has both S and R as parents, and hopefully represents the changes from both branches:\nP--Q--S--M (master)\n \\ /\n \\ /\n R (origin/master)\n\nWhen GitHub shows you a diff that represents the changes introduced by the commit, it's simple in the case of a commit with one parent - it can just do a diff from that version. However, in the case of a commit such as M, with more than one parent, it has to choose a parent to show the diff against. That explains why the diff shown for the merge commit M might appear to be the same as that shown for one of S or R. Commits in git are defined by the exact state of the source tree, not the changes that got the tree into that state." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "In Git, how can I write the current commit hash to a file in the same commit\nI'm trying to do a fancy stuff here with Git hooks, but I don't really know how to do it (or if it's possible).\nWhat I need to do is: in every commit I want to take its hash and then update a file in the commit with this hash.\nAny ideas?" }, { "role": "assistant", "content": "I would recommend doing something similar to what you have in mind: placing the SHA1 in an untracked file, generated as part of the build/installation/deployment process. It's obviously easy to do (git rev-parse HEAD > filename or perhaps git describe [--tags] > filename), and it avoids doing anything crazy like ending up with a file that's different from what git's tracking.\nYour code can then reference this file when it needs the version number, or a build process could incorporate the information into the final product. The latter is actually how git itself gets its version numbers - the build process grabs the version number out of the repo, then builds it into the executable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-checkout - Switch branches or restore working tree files git checkout -b|-B <new-branch> [<start-point>]" }, { "role": "assistant", "content": "Specifying -b causes a new branch to be created as if git-branch were called and then checked out. In\nthis case you can use the --track or --no-track options,\nwhich will be passed to git branch . As a convenience, --track without -b implies branch creation; see the\ndescription of --track below. If -B is given, <new-branch> is created if it doesn’t exist; otherwise, it\nis reset. This is the transactional equivalent of $ git branch -f <branch> [<start-point>]\n$ git checkout <branch> that is to say, the branch is not reset/created unless \"git checkout\" is\nsuccessful (e.g., when the branch is in use in another worktree, not\njust the current branch stays the same, but the branch is not reset to\nthe start-point, either)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn: what's the equivalent to `svn switch --relocate`?\nAn svn repository I'm mirroring through git-svn has changed URL.\nIn vanilla svn you'd just do svn switch --relocate old_url_base new_url_base.\nHow can I do this using git-svn? \nSimply changing the svn url in the config file fails." }, { "role": "assistant", "content": "This handles my situation pretty well:\nhttps://git.wiki.kernel.org/index.php/GitSvnSwitch\nI cloned using the file:// protocol, and wanted to switch to the http:// protocol.\nIt is tempting to edit the url setting in the [svn-remote \"svn\"] section of .git/config, but on its own this does not work. In general you need to follow the following procedure:\n\nSwitch the svn-remote url setting to the new name.\nRun git svn fetch. This needs to fetch at least one new revision from svn!\nChange the svn-remote url setting back to the original URL.\nRun git svn rebase -l to do a local rebase (with the changes that came in with the last fetch operation).\nChange the svn-remote url setting back to the new URL.\nNow, git svn rebase should work again.\n\nAdventurous souls may want to try --rewrite-root." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters --exclude-hidden=(fetch|receive|uploadpack)" }, { "role": "assistant", "content": "Do not include refs that would be hidden by git-fetch , git-receive-pack or git-upload-pack by consulting the appropriate fetch.hideRefs , receive.hideRefs or uploadpack.hideRefs configuration along with transfer.hideRefs (see git-config ). This option affects the next pseudo-ref option --all or --glob and is cleared after processing them." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-cherry-pick - Apply the changes introduced by some existing commits --allow-empty" }, { "role": "assistant", "content": "By default, cherry-picking an empty commit will fail,\nindicating that an explicit invocation of git commit\n--allow-empty is required. This option overrides that\nbehavior, allowing empty commits to be preserved automatically\nin a cherry-pick. Note that when \"--ff\" is in effect, empty\ncommits that meet the \"fast-forward\" requirement will be kept\neven without this option. Note also, that use of this option only\nkeeps commits that were initially empty (i.e. the commit recorded the\nsame tree as its parent). Commits which are made empty due to a\nprevious commit will cause the cherry-pick to fail. To force the\ninclusion of those commits, use --empty=keep ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "In GitHub Actions, how can I trigger on push but only if a PR is active?\n\nSay I have 2 branches, a feature branch and a develop branch.\nThere's no SLA on feature branch normally, meaning I can push broken code up to it all day long and no CI build should be triggered.\nThen I open a PR into develop. I trigger a CI build action on pull_request: created. Let's say this build fails. By default I can't merge the PR, which is correct.\nNow I want to push edits to feature branch to update the PR. I want these pushes to trigger a CI build (because we're now working inside an open PR). I don't want to allow the PR to proceed/be merged until these push-CIs pass.\nHow can I do that in GitHub Actions? I tried on pull_request: edited but that didn't work for me.\nI'm looking for the functional equivalent of:\non:\n push:\n if: inside_open_pr" }, { "role": "assistant", "content": "Use the event pull_request and don't specify activities or specify the activity synchronize:\non:\n pull_request:\n\n\nNote: By default, a workflow only runs when a pull_request's activity type is opened, synchronize, or reopened. To trigger workflows for more activity types, use the types keyword.\n\nsource\n\nif you push a new commit to the HEAD ref of a pull request then this “synchronize” event will be triggered. This is because the system is syncing the pull requests with the latest changes. This will NOT trigger if the base ref is updated.\n\nsource\nIf you also need to react to a change of the base branch, then you have to add the activity edited.\nsource" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is `git diff --patience` for?\nHow does the patience algorithm differ from the default git diff algorithm, and when would I want to use it?" }, { "role": "assistant", "content": "You can read a post from Bram Cohen, the author of the patience diff algorithm, but I found this blog post to summarize the patience diff algorithm very well:\n\nPatience Diff, instead, focuses its energy on the low-frequency high-content lines which serve as markers or signatures of important content in the text. It is still an LCS-based diff at its core, but with an important difference, as it only considers the longest common subsequence of the signature lines:\n\nFind all lines which occur exactly once on both sides, then do longest common subsequence on those lines, matching them up.\n\n\nWhen should you use patience diff? According to Bram, patience diff is good for this situation:\n\nThe really bad cases are ones where two versions have diverged\ndramatically and the developer isn't being careful to keep patch sizes\nunder control. Under those circumstances a diff algorithm can occasionally\nbecome 'misaligned' in that it matches long sections of curly brackets\ntogether, but it winds up correlating the curly brackets of functions in\none version with the curly brackets of the next later function in the\nother version. This situation is very ugly, and can result in a totally\nunusable conflict file in the situation where you need such things to be\npresented coherently the most." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "npm install and build of forked github repo\n\nI'm using a module for my angular app called angular-translate. However, I've had to make a few small modifications to the source code to get everything working the way I'd like, and now I want to persist those changes on npm install. A colleague suggested that I fork the repo of the source code and point to my forked repo as a dependency, which I've tried in these ways, e.g.\nnpm install https://github.com/myRepo/angular-translate\nnpm install https://github.com/myRepo/angular-translate/archive/master.tar.gz\n\nThe first gives me a directory like this with no build. Just a package.json, .npmignore, and some markdown files\n-angular-translate\n .npmignore \n .nvmrc\n CHANGELOG.md \n package.json\n etc\n\nThe second npm install gives me the full repo, but again I don't get a build like when I use the command npm install angular-translate. I've seen some dicussion of running the prepublish script, but I'm not sure how to do this when installing all the modules. I've also tried publishing the fork as my own module to the npm registry, but again I get no build, and I'm not sure that's the right thing to do...\nI apologise for my ignorance on the topic. I don't have a huge amount of experience with npm. Would love to get some feedback on this issue. It seems like it could be a common enough issue when modifications need to be made to a package's source code? Maybe there's a better solution?" }, { "role": "assistant", "content": "Try npm install <ghusername>/<repoName>, where <ghUsername> is your GitHub username (without the @) and <repoName> is the name of the repository. That should correctly install it. You will most likely want to use the --save or --save-dev flag with the install command to save dependency in your package.json.\nIf that isn't working correctly, check the contents of your .npmignore file.\nDon't panic if the install command takes a long time; installing from a git repository is slower than installing from the npm registry.\n\nEdit:\nYour problem is that in your case, dist/ is not committed to the repo (since it is in the .gitignore). That is where the actual code lives. dist/ is built from the files in src/ before the package is published to the npm registry, but dist/ is never committed to the repo.\nIt's ugly, but in this case you will have to remove dist/ from the .gitignore and then run:\nnpm run build\ngit add .\ngit commit\ngit push\n\n(Ensure that you have run npm install first)\nYou then should be able to install from github.\nThere might be another way to do this using a prepare script, but I'm not sure if that's possible; I've never tried it. Edit: Cameron Tacklind has written an excellent answer detailing how to do this: https://stackoverflow.com/a/57829251/7127751" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git cherry pick vs rebase\nI have recently started working with Git.\nGoing over the Git book online I found the following under the \"Git Rebase\" section:\n\nWith the rebase command, you can take all the changes that were\n committed on one branch and replay them on another one.\n\n(Quoted from: http://git-scm.com/book/en/Git-Branching-Rebasing)\nI thought this is the exact definition of git cherry-pick (reapply a commit or a set of commit objects on the currently checked out branch).\nWhat is the difference between the two ?" }, { "role": "assistant", "content": "Since the time git cherry-pick learned to be able to apply multiple commits, the distinction indeed became somewhat moot, but this is something to be called convergent evolution ;-)\nThe true distinction lies in original intent to create both tools:\n\ngit rebase's task is to forward-port a series of changes a developer has in their private repository, created against version X of some upstream branch, to version Y of that same branch (Y > X). This effectively changes the base of that series of commits, hence \"rebasing\".\n(It also allows the developer to transplant a series of commits onto any arbitrary commit, but this is of less obvious use.)\ngit cherry-pick is for bringing an interesting commit from one line of development to another. A classic example is backporting a security fix made on an unstable development branch to a stable (maintenance) branch, where a merge makes no sense, as it would bring a whole lot of unwanted changes.\nSince its first appearance, git cherry-pick has been able to pick several commits at once, one-by-one.\n\nHence, possibly the most striking difference between these two commands is how they treat the branch they work on: git cherry-pick usually brings a commit from somewhere else and applies it on top of your current branch, recording a new commit, while git rebase takes your current branch and rewrites a series of its own tip commits in one way or another. Yes, this is a heavily dumbed down description of what git rebase can do, but it's intentional, to try to make the general idea sink in.\nUpdate to further explain an example of using git rebase being discussed.\nGiven this situation,The Book states:\n\nHowever, there is another way: you can take the patch of the change that was introduced in C3 and reapply it on top of C4. In Git, this is called rebasing. With the rebase command, you can take all the changes that were committed on one branch and apply them onto another one.\nIn this example, you’d run the following:\n$ git checkout experiment\n$ git rebase master\nFirst, rewinding head to replay your work on top of it...\nApplying: added staged command\n\n\n\"The catch\" here is that in this example, the \"experiment\" branch (the subject for rebasing) was originally forked off the \"master\" branch, and hence it shares commits C0 through C2 with it — effectively, \"experiment\" is \"master\" up to, and including, C2 plus commit C3 on top of it. (This is the simplest possible case; of course, \"experiment\" could contain several dozens of commits on top of its original base.)\nNow git rebase is told to rebase \"experiment\" onto the current tip of \"master\", and git rebase goes like this:\n\nRuns git merge-base to see what's the last commit shared by both \"experiment\" and \"master\" (what's the point of diversion, in other words). This is C2.\nSaves away all the commits made since the diversion point; in our toy example, it's just C3.\nRewinds the HEAD (which points to the tip commit of \"experiment\" before the operation starts to run) to point to the tip of \"master\" — we're rebasing onto it.\nTries to apply each of the saved commits (as if with git apply) in order. In our toy example it's just one commit, C3. Let's say its application will produce a commit C3'.\nIf all went well, the \"experiment\" reference is updated to point to the commit resulted from applying the last saved commit (C3' in our case).\n\nNow back to your question. As you can see, here technically git rebase indeed transplants a series of commits from \"experiment\" to the tip of \"master\", so you can rightfully tell there indeed is \"another branch\" in the process. But the gist is that the tip commit from \"experiment\" ended up being the new tip commit in \"experiment\", it just changed its base:\n\nAgain, technically you can tell that git rebase here incorporated certain commits from \"master\", and this is absolutely correct." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-bisect - Use binary search to find the commit that introduced a bug" }, { "role": "assistant", "content": "SYNOPSIS git bisect <subcommand> <options>" } ]
[ { "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 --[no-]progress" }, { "role": "assistant", "content": "Progress status is reported on the standard error stream\nby default when it is attached to a terminal. This flag\nenables progress reporting even if not attached to a\nterminal. Can’t use --progress together with --porcelain or --incremental ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Stopping a started background service (phantomjs) in gitlab-ci\n\nI'm starting phantomjs with specific arguments as part of my job.\nThis is running on a custom gitlab/gitlab-ci server, I'm currently not using containers, I guess that would simplify that.\nI'm starting phantomjs like this:\n- \"timeout 300 phantomjs --ssl-protocol=any --ignore-ssl-errors=true vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768 2>&1 >> /tmp/gastonjs.log &\"\n\nThen I'm running my behat tests, and then I'm stopping that process again:\n- \"pkill -f 'src/Client/main.js' || true\"\n\nThe problem is when a behat test fails, then it doesn't execute the pkill and the test-run is stuck waiting on phantomjs to finish. I already added the timeout 300 but that means I'm still currently waiting 2min or so after a fail and it will eventually stop it while test are still running when they get slow enough.\nI haven't found a way to run some kind of post-run/cleanup command that also runs in case of fails.\nIs there a better way to do this? Can I start phantomjs in a way that gitlab-ci doesn't care that it is still running? nohup maybe?" }, { "role": "assistant", "content": "TL;DR; - spawn the process in a new thread with & but then you have to make sure the process is killed in successfull and failure builds.\ni use this (with comments):\n'E2E tests':\n before_script:\n - yarn install --force >/dev/null\n # if there is already an instance running kill it - this is ok in my case - as this is not run very often\n - /bin/bash -c '/usr/bin/killall -q lite-server; exit 0'\n - export DOCKERHOST=$(ifconfig | grep -E \"([0-9]{1,3}\\\\.){3}[0-9]{1,3}\" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d ':' | head -n1)\n - export E2E_BASE_URL=\"http://$DOCKERHOST:8000/#.\"\n # start the lite-server in a new process\n - lite-server -c bs-config.js >/dev/null &\n script:\n # run the tests\n - node_modules/.bin/protractor ./protractor.conf.js --seleniumAddress=\"http://localhost:4444/wd/hub\" --baseUrl=\"http://$DOCKERHOST:8000\" --browser chrome\n # on a successfull run - kill lite server\n - killall lite-server >/dev/null\n after_script:\n # when a test fails - try to kill it in the after_script. this looks rather complicated, but it makes sure your builds dont fail when the tests succeedes and the lite-server is already killed. to have a successfull build we ensure a non-error return code (exit 0)\n - /bin/bash -c '/usr/bin/killall -q lite-server; exit 0'\n stage: test\n dependencies:\n - Build\n tags:\n - selenium\n\nhttps://gist.github.com/rufinus/9ee8f04fc1f9248eeb0c73ad5360a006#file-gitlab-ci-yml-L7" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can Git treat ZIP files as directories and files inside the ZIP as blobs?\nThe scenario\nImagine I am forced to work with some of my files always stored inside .zip files. Some of the files inside the ZIP file are small text files and change often, while others are larger but luckily rather static (e.g. images).\nIf I want to place these ZIP files inside a Git repository, each ZIP is treated as a blob, so whenever I commit the repository grows by the size of the ZIP file... even if only one small text file inside changed!\nWhy this is realistic\nMicrosoft Word 2007/2010 .docx and Excel .xlsx files are ZIP files...\nWhat I want\nIs there, by any chance, a way to tell Git to not treat ZIP files as files, but rather as directories and treat their contents as files?\nThe advantages\n\nmuch smaller repository size, i.e. quicker transfer/backup\nDisplay changes with Git to ZIP files would automagically work\n\nBut it couldn't work, you say?\nI realize that without extra metadata this would lead to some amount of ambiguity: on a git checkout Git would have to decide whether to create foo.zip/bar.txt as a file in a regular directory or a ZIP file. However, this could be solved through configuration options, I would think.\nTwo ideas how it could be done (if it doesn't exist yet)\n\nusing a library such as minizip or IO::Compress::Zip inside Git\nsomehow adding a filesystem layer such that Git actually sees ZIP files as directories to start with" }, { "role": "assistant", "content": "This doesn't exist, but it could easily exist in the current framework. Just as Git acts differently with displaying binary or ASCII files when performing a diff, it could be told to offer special treatment to certain file types through the configuration interface.\nIf you don't want to change the code base (although this is kind of a cool idea you've got), you could also script it for yourself by using pre-commit and post-checkout hooks to unzip and store the files, then return them to their .zip state on checkout. You would have to restrict actions to only those files blobs / indexes that are specified by git add.\nEither way is a bit of work -- it's just a question of whether the other Git commands are aware of what's going on and play nicely." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Retrieve a single file from a repository\nWhat is the most efficient mechanism (in respect to data transferred and disk space used) to get the contents of a single file from a remote git repository?\nSo far I've managed to come up with:\ngit clone --no-checkout --depth 1 [email protected]:foo/bar.git && cd bar && git show HEAD:path/to/file.txt\n\nThis still seems overkill.\nWhat about getting multiple files from the repo?" }, { "role": "assistant", "content": "In git version 1.7.9.5 this seems to work to export a single file from a remote\ngit archive --remote=ssh://host/pathto/repo.git HEAD README.md | tar xO\n\nThis will cat the contents of the file README.md." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to increase maximum artifacts size for Gitlab on-premises\n\nWe've installed Gitlab on-premises, however someone else did the installation so I don't know as much about configuring the runners, etc. A pipeline failed due to the following error:\nUploading artifacts...\napp/build/outputs/apk/debug/app-debug.apk: found 1 matching files\napp/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk: found 1 matching files\nERROR: Uploading artifacts to coordinator... too large archive id=13832 responseStatus=413 Request Entity Too Large status=413 Request Entity Too Large token=fCysmH9H\nFATAL: Too large\nERROR: Job failed: exit code 1\n\nWhere/how do I configure the allowable artifact size?" }, { "role": "assistant", "content": "I was able to solve my problem after finding https://gitlab.com/gitlab-org/gitlab-runner/issues/2584. It suggests increasing maximum artifacts size on the on-prem instance of Gitlab. Here are the steps that worked for me:\n\nClick Admin Area (top of Gitlab on-prem screen)\nClick Settings\n\nThe direct link, assuming the on-prem instance is hosted at gitlab.MYCOMPANY.com is: https://gitlab.MYCOMPANY.com/admin/application_settings/ci_cd\n\nExpand \"Continuous Integration and Deployment\"\nSet the \"Maximum artifacts size (MB)\"\n\nThis assumes your login credentials allow you to see the Admin Area." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Create a repo in Gitlab using CLI\n\nWe have a gitlab setup at our office, and we have somewhat around 100-150 project each week to create over there, while Admin wants to keep the control of creating repos and assigning teams to it, it seems quite a bit of task for anyone to create that many repos every week.\nIs there a way to create repo on Gitlab using CLI - I won't mind if i have to use ssh for it." }, { "role": "assistant", "content": "gitlab-cli is no longer maintained, the author references the Gitlab module to be used instead - it also includes a CLI tool.\nFor your specific request - namely creating a project on the command line, use the following command:\ngitlab create_project \"YOUR_PROJECT_NAME\" \"{namespace_id: 'YOUR_NUMERIC_GROUP_ID'}\"\nBe sure to use the option namespace_id and not group_id! If you are not sure what your GROUP_ID is, you can use\ngitlab groups | grep YOUR_GROUP_NAME\nto find out.\nThe parameters for each command can be inferred from the API documentation. Any non-scalar valued parameter has to be encoded in an inline YAML syntax (as above)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git-windows case sensitive file names not handled properly\nWe have the git bare repository in unix that has files with same name that differs only in cases.\nExample:\nGRANT.sql\ngrant.sql\n\nWhen we clone the bare repository from unix in to a windows box, git status detects the file as modified. The working tree is loaded only with grant.sql, but git status compares grant.sql and GRANT.sql and shows the file as modified in the working tree.\nI tried using the core.ignorecase false but the result is the same.\nIs there any way to fix this issue?" }, { "role": "assistant", "content": "Windows is case-insensitive (more precisely, case-preserving). There is simply no possible way for two files to exist whose names only differ in case: two filenames which differ only in case are the same filename. Period.\nSo, Git is walking the repository, checking out one file after the other, until it hits the first one of the two problem files. Git checks it out, then goes further about its business until it hits the second file. Again, Git checks it out. Since from Windows' point of view the filename is the same as the first one, the first file simply gets overwritten with the second one. Which now makes Git think that the first file was changed to have the same content as the second one.\nNote that this has nothing to do with Git: exactly the same would happen if you had a tarball, a zipfile or a Subversion repository.\nIf you want to do development on multiple different platforms, you have to respect the restrictions of those platforms and you have to confine yourself to the lowest common denominator of all the platforms you support. Windows supports ADS, Linux doesn't. OSX supports resource forks, Windows doesn't. BSD supports case-sensitivity, Windows doesn't. So, you can't use any of those. That's just the way it is.\ncore.ignorecase isn't going to help you here, because that handles exactly the opposite problem." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Using a private Docker Image from Gitlab Registry as the base image for CI\n\nHow should I authenticate if I want to use an image from the Gitlab Registry as a base image of another CI build?\nAccording to https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/configuration/advanced-configuration.md#using-a-private-docker-registry I first have to manually login on the runner machine. Somehow it feels strange to login with an existing Gitlab user. \nIs there a way to use the CI variable \"CI_BUILD_TOKEN\" (which is described as \"Token used for authenticating with the GitLab Container Registry\") for authentication to pull the base image from Gitlab Registry?\nEDIT: I found out that I can use images from public projects. But I don't really want to make my docker projects public.\nUPDATE: Starting with Gitlab 8.14 you can just use the docker images from the build in docker registry. See https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/configuration/advanced-configuration.md#support-for-gitlab-integrated-registry" }, { "role": "assistant", "content": "All of the above answers including the acepted one are deprecated, This is possible in 2021:\nhttps://docs.gitlab.com/ee/ci/docker/using_docker_images.html#access-an-image-from-a-private-container-registry\n\nTL;DR\nSet the CI/CD variable DOCKER_AUTH_CONFIG value with appropriate authentication information in following format:\nStep 1:\n# The use of \"-n\" - prevents encoding a newline in the password.\necho -n \"my_username:my_password\" | base64\n\n# Example output to copy\nbXlfdXNlcm5hbWU6bXlfcGFzc3dvcmQ=\n\nStep 2 (This JSON is the value to be set for DOCKER_AUTH_CONFIG variable):\n{\n \"auths\": {\n \"registry.example.com:5000\": {\n \"auth\": \"(Base64 content from above)\"\n }\n }\n}" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker gitprotocol-v2" }, { "role": "assistant", "content": "Git Wire Protocol, Version 2" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How should I move changes from one commit to another?\nI have two commits on the same branch, one right after another. I added changes to file A to the first commit, and then I made some changes to other files and then made another commit. Now I want the changes to file A to be on the second commit rather than the first. What's the most elegant way?" }, { "role": "assistant", "content": "I know this is an old question but I had the exact same request and I just figured out the best way to resolve this issue: you need to use interactive rebase and choose \"edit\" for the two commits you want to move a change from and to.\nFor instance, let say you have 3 commits:\n$ git log -3 --oneline\n97e9d62 Commit C, editing file2.txt\n34b066b Commit B, creating file2.txt + editing file1.txt\n73ff1bb Commit A, creating file1.txt\n\nNow, if you want the Commit B to only contain the file2.txt creation but not the file1.txt edition which should be in Commit C, git rebase -i will display this:\npick 73ff1bb Commit A, creating file1.txt\npick 34b066b Commit B, creating file2.txt + editing file1.txt\npick 97e9d62 Commit C, editing file2.txt\n\n# ...\n\nIf I replace \"pick\" with \"edit\" or \"e\" for Commit B and Commit C and close my editor, git will stop on the second commit and let me amend my changes:\npick 73ff1bb Commit A, creating file1.txt\nedit 34b066b Commit B, creating file2.txt + editing file1.txt\nedit 97e9d62 Commit C, editing file2.txt\n\nStopped at 34b066b... Commit B, creating file2.txt + editing file1.txt\nYou can amend the commit now, with\n\n git commit --amend\n\nOnce you are satisfied with your changes, run\n\n git rebase --continue\n\n$ vi file1.txt # edit of file1.txt to remove the updated line\n$ git commit --amend file1.txt\n$ git rebase --continue\n\n# -- git continues rebasing and stops on the Commit C to edit it\n\n$ vi file1.txt # edit of file1.txt to put the removed line\n$ git commit --amend file1.txt\n$ git rebase --continue\n\nAnd that's it.\nTake care to save somewhere the line(s) you're removing from first commit to put them in the second one. It can be in clipboard, text file, etc. I guess it should be possible to rely on git stash too but if it's a simple change it's easier to keep it in the clipboard." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-clone - Clone a repository into a new directory <repository>" }, { "role": "assistant", "content": "The (possibly remote) <repository> to clone from. See the GIT URLS section below for more information on specifying\nrepositories." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do you manage your gists on GitHub? [closed]\n\nClosed. This question is seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. It does not meet Stack Overflow guidelines. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\n We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.\n\n\nClosed 6 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI love GitHub and their gist service, and that's why I'm keeping a lot of code snippets and even development notes as a gist on my GitHub account. It also makes it easy to share them with my colleagues.\nThe problem is that it doesn't scale!! The GitHub features for gist are primitive, and I have lots of gists there which make it really difficult to find some of my old gists. There's no search, no tagging, or anything. \nDo you know any application that can handle this mess? I would like an application that could\n\nSearch my gists\nList my gists by source type and date\nLet me edit or copy them \nLet me tag or at least edit description \n\nI would love to see something like this, and I'm willing to pay even some bucks for it. \nSo how do you manage you gists on GitHub? Do you know any software? \nThere's one called drift written in MacRuby, but I couldn't compile it, and it hasn't been updated for a while." }, { "role": "assistant", "content": "Check out GistBox. It supports searching, editing and labels. Here's a screenshot:\n\nThere's also a demo video at: http://www.youtube.com/watch?v=VLgyY6lqpsQ\nGistBox Clipper (a Chrome extension) also provides the ability to save <pre> tags and arbitrary text on any web page.\n\nEdit:\n\nUnfortunately, GistBox is becoming Cacher cacher.io - the free plan will only include: 15 private snippets, 3 private labels, unlimited public snippets. If you plan on having many private gists then you will need to but (sic) a paid plan. – Bartek Skwira" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to commit new changes to an open merge request?\n\nI am new to working in branching and git.\nI developed some test cases and created new branch to push the changes in that branch and opened a merge request in GitLab to be merged in master branch.\nAfter PR, my reviewer highlighted some code refactoring and other minor changes.\nNow, I have made those changes and the merge request is still open. How can I push the new changes/commit to an already opened merge request?" }, { "role": "assistant", "content": "So, I should follow these steps? -> git add . -> git commit --amend --no-edit -> git push\nNo need for git commit --amend: you can make a new commit, explaining why those changes are introduced, and push.\nThat will update the current MR (Merge Request in GitLab parlor).\nAs mentioned in \"Merge requests versions\"/\n\nEvery time you push to a branch that is tied to a merge request, a new version of merge request diff is created.\nWhen you visit a merge request that contains more than one pushes, you can select and compare the versions of those merge request diffs." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-mv - Move or rename a file, a directory, or a symlink -v --verbose" }, { "role": "assistant", "content": "Report the names of files as they are moved." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do you use Git with multiple computers?\nI'm trying to use git and I have many computers. I usually work on my desktop, but sometimes use laptops. \nHow do you sync source code on git when you go home from work and you didn't finish working on the code? Do you send a patch file through email or just commit to git the incomplete codes?\nI agree the latter is more convenient, but I think it makes the git changelog dirty." }, { "role": "assistant", "content": "Commit your work in progress and push it to a remote branch. When you're ready to merge it into your main branch you can use an interactive rebase to rewrite your history and eliminate \"work in progress\" commits." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-revert - Revert some existing commits --quit" }, { "role": "assistant", "content": "Forget about the current operation in progress. Can be used\nto clear the sequencer state after a failed cherry-pick or\nrevert." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to create a new gitlab repo from my existing local git repo, using CLI?\n\nI have many local git repos on my OSX. Using the command line I want to make new gitlab repositories on https://gitlab.companyname.com from existing local repositories.\nIs it possible to do that?" }, { "role": "assistant", "content": "2018 Solution: just use --set-upstream\nAssuming you'll take care of writing the script that would do the following for each of your local repo, it seems that as of Gitlab 10.5 you can simply use\n# To your own domain\ngit push --set-upstream address/your-project.git\n\n# To gitlab.com with SSH\ngit push --set-upstream [email protected]:username/new-repo.git master\n\n# To gitlab.com with HTTP\ngit push --set-upstream https://gitlab.example.com/username/new-repo.git master\n\nThis will create a new project on Gitlab without you creating it manually on the server\n\nFrom the Documentation\nPush to create a new project\n\nWhen you create a new repository locally, instead of manually creating a new project in GitLab and then cloning the repository locally, you can directly push it to GitLab to create the new project, all without leaving your terminal. If you have access rights to the associated namespace, GitLab automatically creates a new project under that GitLab namespace with its visibility set to Private by default (you can later change it in the project's settings).\nThis can be done by using either SSH or HTTPS:\n\n## Git push using SSH\ngit push --set-upstream [email protected]:namespace/nonexistent-project.git master\n\n## Git push using HTTPS\ngit push --set-upstream https://gitlab.example.com/namespace/nonexistent-project.git master\n\n\nYou can pass the flag --tags to the git push command to export existing repository tags.\nOnce the push finishes successfully, a remote message indicates the command to set the remote and the URL to the new project:\n\nremote:\nremote: The private project namespace/nonexistent-project was created.\nremote:\nremote: To configure the remote, run:\nremote: git remote add origin https://gitlab.example.com/namespace/nonexistent-project.git\nremote:\nremote: To view the project, visit:\nremote: https://gitlab.example.com/namespace/nonexistent-project\nremote:" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-cherry-pick - Apply the changes introduced by some existing commits" }, { "role": "assistant", "content": "DESCRIPTION Given one or more existing commits, apply the change each one\nintroduces, recording a new commit for each. This requires your\nworking tree to be clean (no modifications from the HEAD commit). When it is not obvious how to apply a change, the following\nhappens: The current branch and HEAD pointer stay at the last commit\nsuccessfully made. The CHERRY_PICK_HEAD ref is set to point at the commit that\nintroduced the change that is difficult to apply. Paths in which the change applied cleanly are updated both\nin the index file and in your working tree. For conflicting paths, the index file records up to three\nversions, as described in the \"TRUE MERGE\" section of git-merge . The working tree files will include\na description of the conflict bracketed by the usual\nconflict markers <<<<<<< and >>>>>>> . No other modifications are made. See git-merge for some hints on resolving such\nconflicts." } ]