messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I make git commit messages divide into multiple lines?\nWhen I use git log to check out my commit explanatory note I want it to look like this:\n1. what I changed\n2. blank line\n3. why I changed it\n\n...being in 3 lines not 1 like this: \n1. what i changed 2. blank line 3. why i changed\n\nHowever, git log shows it in one line. So, how do I get this to happen using git commit -m?" }, { "role": "assistant", "content": "You just use the following command:\n$ git commit -m \"1. what i changed\n> 2. blank line\n> 3. why i changed\"\n\nIn your terminal, just hit 'enter' for a new line. The commit message won't end until you add the closing quote. The git log will look like:\n$ git log\ncommit abcde2f660c707br2d20411581c4183170c3p0c2\nAuthor: Alex Pan <[email protected]>\nDate: Tue Apr 28 20:52:44 2015 -0700\n\n 1. what i changed\n 2. blank line\n 3. why i changed" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --cherry" }, { "role": "assistant", "content": "A synonym for --right-only --cherry-mark --no-merges ; useful to\nlimit the output to the commits on our side and mark those that\nhave been applied to the other side of a forked history with git log --cherry upstream...mybranch , similar to git cherry upstream mybranch ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Get raw file from repository\n\nI want to get a file content in gitlab by using its api.\nFirstly, I check my gitlab version, its written as,\nGitLab Community Edition 9.4.3 b125d21 update asap\nThen I create a private token and \nhttp://gitadress/api/v4/projects/id/repository/files?private_token=PRIVATE_TOKEN\nreturns as;\n{\"error\":\"404 Not Found\"}\n\nthen I modify the query as;\nhttp://gitadress/api/v4/projects/222/repository/tree?private_token=PRIVATE_TOKEN \nthis request returns as;\n[{\"id\":\"8078365d80c\",\"name\":\"test.js\",\"type\":\"blob\",\"path\":\"test.js\",\"mode\":\"100644\"}]\n\nWhat I want is to get the content of the test.js but whatever I tried I couldn't achieve it.\nhttp://gitadress/api/v4/projects/id/repository/tree/test.js/raw?private_token=PRIVATE_TOKEN&ref=master\nreturns as; \n{\"error\":\"404 Not Found\"}\n\nHow can I get the raw file content by using gitlab api?\nDocumentation is here;\nhttps://github.com/gitlabhq/gitlabhq/blob/master/doc/api/repository_files.md#get-raw-file-from-repository" }, { "role": "assistant", "content": "The documentation mentions:\n\nUrl encoded full path to new file. Ex. lib%2Fclass%2Erb\n\nThat means you need to URL encode test.js: test%2Ejs.\n(See Percent encoding: character data)\nhttp://gitadress/api/v4/projects/id/repository/files/test%2Ejs/raw?private_token=PRIVATE_TOKEN\n\nYou can add ?ref=master to make sure to get the content from the master branch for instance.\nhttp://gitadress/api/v4/projects/id/repository/files/test%2Ejs/raw?ref=master&private_token=PRIVATE_TOKEN\n\nThat being said, you have the gitlab-ce issue 31470 which is still open:\n\nAPI to \"Get raw file from repository\" fails for files with dots\n\nA fix is in progress: gitlab-ce merge_request 13370, and will be delivered for GitLab 9.5." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Merge different issues on github\n\nSometimes the developers open new issues regarding the same subject. \nIt will be great to have the possibility to merge the issues.\nIf it is possible in github, how can I do it?\nIf not, what is the best way to link different issues?" }, { "role": "assistant", "content": "Currently, the simplest way to resolve this situation is to pick one of the issues to be the main one (whether the best documented, oldest, or whatever). Then, add a comment to the other issues linking to the main issue and close the duplicates.\nHere's an example.\nHere's another showing the \"Duplicate of #123\" syntax.\nAlternatively, you can leave the issues open and reference them all together in your commit messages: Example.\nI imagine that in the future, the team behind GitHub will make this process easier." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git SSH error: \"Connect to host: Bad file number\"\nI followed the git guide but I have this strange issue when trying to connect to github:\n$ ssh -v [email protected]\nOpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007\ndebug1: Reading configuration data /c/Documents and Settings/mugues/.ssh/config\ndebug1: Applying options for github.com\ndebug1: Connecting to github.com [207.97.227.239] port 22.\ndebug1: connect to address 207.97.227.239 port 22: Attempt to connect timed out without establishing a connection\nssh: connect to host github.com port 22: Bad file number\n\nThis is my config file under .ssh\nHost github.com\n User git\n Hostname github.com\n PreferredAuthentications publickey\n IdentityFile \"C:\\Documents and Settings\\mugues\\.ssh\\id_rsa\"\n TCPKeepAlive yes\n IdentitiesOnly yes\n\nAny idea?" }, { "role": "assistant", "content": "After having this problem myself, I found a solution that works for me:\nError message: \n ssh -v [email protected]\n OpenSSH_5.8p1, OpenSSL 1.0.0d 8 Feb 2011\n debug1: Connecting to github.com [207.97.227.239] port 22.\n debug1: connect to address 207.97.227.239 port 22: Connection timed out\n ssh: connect to host github.com port 22: Connection timed out\n ssh: connect to host github.com port 22: Bad file number\n\nYou will only see the bad file number message when on windows using the MINGGW shell. Linux users will just get Timed out.\nProblem:\nSSH is probably blocked on port 22. You can see this by typing\n $nmap -sS github.com -p 22\n Starting Nmap 5.35DC1 ( http://nmap.org ) at 2011-11-05 10:53 CET\n Nmap scan report for github.com (207.97.227.239)\n Host is up (0.10s latency).\n PORT STATE SERVICE\n 22/tcp ***filtered*** ssh\n\n Nmap done: 1 IP address (1 host up) scanned in 2.63 seconds\n\nAs you can see the state is Filtered, which means something is blocking it.\nYou can solve this by performing an SSH to port 443 (your firewall / isp will not block this).\nIt is also important that you need to ssh to \"ssh.github.com\" instead of github.com.\nOtherwise, you will report to the webserver instead of the ssh server. \nBelow are all the steps needed to solve this problem.\nSolution:\n(First of all make sure you generated your keys like explained on http://help.github.com/win-set-up-git/)\ncreate file ~/.ssh/config (ssh config file located in your user directory. \nOn windows probably %USERPROFILE%\\.ssh\\config\nPaste the following code in it:\n Host github.com\n User git\n Hostname ssh.github.com\n PreferredAuthentications publickey\n IdentityFile ~/.ssh/id_rsa\n Port 443\n\nSave the file.\nPerform ssh like usual:\n$ssh -T github.com \n $Enter passphrase for key '.......... (you can smile now :))\n\nNote that I do not have to supply the username or port number." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to copy commits from one Git repo to another?\nLast week I created a Github repo and forgot to select a license for the repo. Now there are already 3 large commits.\nI have asked the 3 contributors if it is ok if I delete the repo and then create it again with the same name and this time selecting the license when creating the repo, and they were fine with that.\nQuestion\nIs there a way I can get the commits into the new repo (this time the first commit is the LICENSE file) and still keep the commit meta info?" }, { "role": "assistant", "content": "Is there a way I have get the commits into new repo (this time the first commit is the LICENSE file) and still keep the commit meta info?\n\nYes, by adding a remote and cherry-picking the commits on top of your first commit.\n# add the old repo as a remote repository \ngit remote add oldrepo https://github.com/path/to/oldrepo\n\n# get the old repo commits\ngit remote update\n\n# examine the whole tree\ngit log --all --oneline --graph --decorate\n\n# copy (cherry-pick) the commits from the old repo into your new local one\ngit cherry-pick sha-of-commit-one\ngit cherry-pick sha-of-commit-two\ngit cherry-pick sha-of-commit-three\n\n# check your local repo is correct\ngit log\n\n# send your new tree (repo state) to github\ngit push origin master\n\n# remove the now-unneeded reference to oldrepo\ngit remote remove oldrepo\n\n\nThe rest of this answer is if you still want to add the LICENSE to your previous repo.\nYes. You can place your LICENSE commit as the first commit by rebasing.\nRebasing is gits way of rearranging commit order while keeping all the commit authors and commit dates intact.\nWhen working on a shared repo, it's generally discouraged unless your entire team is git-fluent. For those that aren't, they can just clone a fresh copy of the repository.\nHere's how you get your LICENSE commit as the first commit.\n1. Update and rebase your local copy\nCheck out your project and place the LICENSE file in a commit ON TOP of your current 3 commit stack.\n#create LICENSE file, edit, add content, save\ngit add LICENSE\ngit commit -m 'Initial commit'\n\nThen do an interactive rebase on the master branch to REARRANGE the commits.\ngit rebase -i --root\n\nIt will open an editor. Move the bottom line (your \"Initial commit\" commit, the most recent commit) to the top of the file. Then save and quit the editor.\nAs soon as you exit the editor, git will write the commits in the order you just specified.\nYou now have your local copy of the repository updated. do:\ngit log\n\nto verify.\n2. Force push your new repo state to github\nNow that your copy is updated, you have to force push it to github.\ngit push -f origin master\n\nThis will tell github to move the master branch to its new location.\nYou should only force push in rare occasions like this where everybody working with it is aware of the pending change, else it will confuse your collaborators.\n3. Synchronize collaborators to github\nLastly, all the collaborators will have to synchronize to this repository.\nFirst they must have clean repositories as the following command can be destructive if there are unsaved changes.\n# make sure there are no unsaved changes\ngit status \n\n# pull the latest version from github\ngit fetch \n\n# move their master branch pointer to the one you published to github.\ngit reset --hard origin/master\n\nThat's it. Everybody should be in sync now." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Check if \"git stash\" stashed anything\nI have a Windows Command script designed to merge the dev branch into a project branch. It starts by reading the current branch name, stashing changes, fetching and merging the dev and project branches, then switches back to the original branch and pops the stash.\nThe issue is there might not be any changes to stash. This leaves the previous stash at the top of the stack. When it gets to the end of the script and pops the stash, it's popping the previous stash which is unrelated to the current branch.\nSet SourceBranch=dev\nSet ProjectBranch=project\n\n:: Stash current changes.\nFor /F \"tokens=1,2\" %%a In ('Git branch -q') Do If \"%%a\"==\"*\" Set CurrentBranch=%%b\nGit stash save -u\n\n:: Pull latest source branch.\nGit checkout %SourceBranch%\nGit pull\nFor /F \"tokens=1,3\" %%a In ('Git branch -q -v') Do If \"%%a\"==\"*\" Set MergeHash=%%b\n\n:: Merge source into project branch.\nGit checkout %ProjectBranch%\nGit pull\nGit merge --commit %MergeHash%||Exit 1\n\n:: Return to original branch.\nGit checkout %CurrentBranch%\nGit stash pop\n\nHow can I get feedback from Git stash or Git status to determine whether I need to pop the stash?" }, { "role": "assistant", "content": "What you want is:\ngit stash list\n\n\ngit stash allows you to provide a message. You can use a generated token as your message so that you know it won't conflict with other git stash messages.\nThen, when you want to check whether or not to pop, simply check if the git stash list output contains your token. If so, pop the stash." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_NO_LAZY_FETCH" }, { "role": "assistant", "content": "Setting this Boolean environment variable to true tells Git\nnot to lazily fetch missing objects from the promisor remote\non demand." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to escape the (hash) # sign in a GitHub markdown header? (backslash is not working)\n\nI have the following code on a README.md file on GitHub, where I am trying to display the hash sign on a header (I am trying to escape it using the \\ symbol) like so:\n### C\\#\n* [Beginning Game Programming with C#](https://www.coursera.org/course/gameprogramming)\n\nHowever it renders like so:\n\nI obviously want the hash sign to appear on the header, and I also tried to use a double backslash, but it didn't work. How do I get the pound sign to appear?\nEDIT: the linked question deals with GitHub links, my question is to do with headers on a .md file." }, { "role": "assistant", "content": "You could try and add a matching '#', followed by one extra '#':\n### C# #" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order --left-only --right-only" }, { "role": "assistant", "content": "List only commits on the respective side of a symmetric difference,\ni.e. only those which would be marked < resp. > by --left-right . For example, --cherry-pick --right-only A...B omits those\ncommits from B which are in A or are patch-equivalent to a commit in A . In other words, this lists the + commits from git cherry A B .\nMore precisely, --cherry-pick --right-only --no-merges gives the exact\nlist." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git pull into wrong branch\nMyself and one other developer had been merging and pushing our work to a non-master branch called toolwork. That way, we didn't impact the rest of the team. My topic branch was called DPM-93 and my git workflow was this.\n# do some work\ngit checkout DPM-93\ngit commit -m \"did some work\"\n\n# catch up\ngit checkout toolwork\ngit pull origin toolwork\n\n# rebase my topic branch\ngit checkout DPM-93\ngit rebase toolwork\n\n# merge and push my changes\ngit checkout toolwork\ngit merge --no-ff DPM-93\ngit push origin toolwork\n\nThat was mostly working fine until I accidently issued these git commands\ngit checkout toolwork\ngit pull origin master\n\nAt that point, a bunch of new stuff showed up in branch toolwork and I'm not sure how to get rid of it short of deleting my workspace and re-cloning from the repo.\nIs there any way to back this out to the state before the pull?" }, { "role": "assistant", "content": "git reset --hard ORIG_HEAD \n\nFrom the git reset man page (if you just did the pull):\nUndo a merge or pull\n$ git pull (1)\nAuto-merging nitfol\nCONFLICT (content): Merge conflict in nitfol\nAutomatic merge failed; fix conflicts and then commit the result.\n$ git reset --hard (2)\n$ git pull . topic/branch (3)\nUpdating from 41223... to 13134...\nFast-forward\n$ git reset --hard ORIG_HEAD (4)\n\n\n\nTry to update from the upstream resulted in a lot of conflicts; you were not ready to spend a lot of time merging right now, so you decide to do that later.\n\"pull\" has not made merge commit, so \"git reset --hard\" which is a synonym for \"git reset --hard HEAD\" clears the mess from the index file and the working tree.\nMerge a topic branch into the current branch, which resulted in a fast-forward.\nBut you decided that the topic branch is not ready for public consumption yet.\n\"pull\" or \"merge\" always leaves the original tip of the current branch in ORIG_HEAD, so resetting hard to it brings your index file and the working tree back to that state, and resets the tip of the branch to that commit.\n\n\nSee HEAD and ORIG_HEAD for more." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-svn" }, { "role": "assistant", "content": "Bidirectional operation between a Subversion repository and Git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to compare the working tree with a commit?\nI'm using\ngit diff mycommit\n\nfor comparing my working tree with mycommit, but it seems to ignore files not present in the current index. You can reproduce it as follows:\ngit init\necho A > A.txt; git add .; git commit -m A; git branch A\necho B > B.txt; git add .; git commit -m B; git branch B\ngit reset --hard A\necho BB > B.txt\ngit diff B\n\nThe output (as of git version 1.7.3.3) is empty. Using --diff-filter=ACDMRTUXB shows \"deleted file\" which is wrong as well, since the file B.txt exists both in the working tree and in commit B. IMHO, the file should be shown as modified. Surprisingly, it works after adding the file to the index, although it's not the index what gets compared. How can I get the right diff without it?" }, { "role": "assistant", "content": "A simple graphic might be of help:\n\nSo there are three types of diff you can ask for:\n\ngit diff --cached\nThis is the difference between what is in the index and the last commit. It shows you that changes that will be in the next commit.\ngit diff\nThis shows the difference in between the index and the working tree. These are the changes that you have made to files since you last added them to the index. This is why I wasn’t getting any results. I had no changes between the index and the working tree.\ngit diff HEAD\nThis shows the difference between the files in the working tree and the last commit. There is a gotcha here: if you've made changes, added them to the index, and then backed out these changes in the working tree, you’ll get no results for git diff HEAD (because there is no difference) but you will get output for git diff --cached because there are still changes in the index.\n\nAnd if you want to compare it against previous commits:\n\nThis just compares against the previous commits, but you can replace HEAD~ with any other reference to a commit." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_PROTOCOL" }, { "role": "assistant", "content": "For internal use only. Used in handshaking the wire protocol.\nContains a colon : separated list of keys with optional values <key>[=<value>] . Presence of unknown keys and values must be\nignored. Note that servers may need to be configured to allow this variable to\npass over some transports. It will be propagated automatically when\naccessing local repositories (i.e., file:// or a filesystem path), as\nwell as over the git:// protocol. For git-over-http, it should work\nautomatically in most configurations, but see the discussion in git-http-backend . For git-over-ssh, the ssh server may need\nto be configured to allow clients to pass this variable (e.g., by using AcceptEnv GIT_PROTOCOL with OpenSSH). This configuration is optional. If the variable is not propagated, then\nclients will fall back to the original \"v0\" protocol (but may miss out\non some performance improvements or features). This variable currently\nonly affects clones and fetches; it is not yet used for pushes (but may\nbe in the future)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git non-fast-forward rejected\nI feel like this question has been asked many times, but the solution is typically \"I deleted the directory and re-did my work with a fresh checkout.\" I did a commit and push but realized that I referred to the wrong ticket number in the commit message. So I looked on SO for a quick solution and ended up typing the following into the terminal:\n$ git reset --soft HEAD^\n$ git commit -m \"... correct message ...\"\n\nThe only problem is I am getting the following error message:\nTo prevent you from losing history, non-fast-forward updates were rejected\nMerge the remote changes before pushing again. See the 'Note about\nfast-forwards' section of 'git push --help' for details.\n\nI am using the git-flow model and am working on the develop branch. How can I merge things back in to make git happy again?" }, { "role": "assistant", "content": "If you push a commit to the server, and then rewrite that commit locally (with git reset, git rebase, git filter-branch, or any other history manipulation), and then pushed that rewritten commit back up to the server, you will screw up anyone else who had pulled. Here's an example; say you have committed A, and pushed it to the server.\n\n-*-*-A <-- master\n\n-*-*-A <-- origin/master\n\nNow you decide to rewrite A, in the way you mentioned, resetting and re-committing. Note that this leaves a dangling commit, A, which will eventually be garbage collected as it is not reachable.\n\n-*-*-A\n \\\n A' <-- master\n\n-*-*-A <-- origin/master\n\nIf someone else, let's say Fred, pulls down master from the server while you're doing this, they will have a reference to A, which they might start working from:\n\n-*-*-A' <-- master\n\n-*-*-A <-- origin/master\n\n-*-*-A-B <-- fred/master\n\nNow if you were able to push your A' to origin/master, which would create a non-fast-forward, it wouldn't have A in its history. So if Fred tried to pull again, he'd suddenly have to merge, and would re-introduce the A commit:\n\n-*-*-A' <-- master\n\n-*-*-A <-- origin/master\n\n-*-*-A-B-\\ \n \\ * <-- fred/master\n A'--/\n\nIf Fred happens to notice this, then he could do a rebase, which would prevent commit A from reappearing again. But he'd have to notice this, and remember to do this; and if you have more than one person who pulled A down, they would all have to rebase in order to avoid getting the extra A commit in the tree.\nSo, it's generally not a good idea to change history on a repo that other people pull from. If, however, you happen to know that no one else is pulling from that repo (for instance, it's your own private repo, or you only have one other developer working on the project who you can coordinate with easily), then you can forcibly update by running:\ngit push -f\n\nor \ngit push origin +master\n\nThese will both ignore the check for a non-fast-forward push, and update what's on the server to your new A' revision, abandoning the A revision so it will eventually be garbage collected.\nIt's possible that force pushes are entirely disabled with the receive.denyNonFastForwards config option. This option is enabled by default on shared repositories. In that case, if you really, really want to force a push, the best option is to delete the branch and re-create it, with git push origin :master; git push origin master:master. However, the denyNonFastForwards option is enabled for a reason, which is described above; on a shared repository, it means that now everyone who uses it needs to ensure that they rebase onto the new history.\nOn a shared repository, it is generally better to just push new commits on top that fix whatever problem you have; you can use git revert to generate commits that will undo the changes of previous commits." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What does it mean to squash commits in git?\nWhat does Squashing commits in git mean. How do I squash commits in Github?" }, { "role": "assistant", "content": "You can think of Git as an advanced database of snapshots of your working directory(ies).\nOne very nice feature of Git is the ability to rewrite the history of commits.\nThe principal reason for doing this is that a lot of such history is relevant only for the developer who generated it, so it must be simplified, or made more nice, before submitting it to a shared repository.\nSquashing a commit means, from an idiomatic point of view, to move the changes introduced in said commit into its parent so that you end up with one commit instead of two (or more).\nIf you repeat this process multiple times, you can reduce n commit to a single one.\nVisually, if you started your work at the commit tagged Start, you want this\n\nYou may notice that the new commit has a slightly darker shade of blue. This is intentional.\nIn Git squashing is achieved with a Rebase, of a special form called Interactive Rebase.\nSimplifying: when you rebase a set of commits into a branch B, you apply all the changes introduced by those commits as they were done, starting from B instead of their original ancestor.\nA visual clue\n\nNote again the different shades of blue.\nAn interactive rebase let you choose how commits should be rebased.\nIf you run this command:\n git rebase -i branch\n\nYou would end up with a file that lists the commits that will be rebased\n pick ae3...\n pick ef6...\n pick 1e0...\n pick 341...\n\nI didn't name the commits, but these four ones are intended to be the commits from Start to Head\nThe nice thing about this list is that it is editable.\nYou can omit commits, or you can squash them.\nAll you have to do is to change the first word to squash.\n pick ae3...\n squash ef6...\n squash 1e0...\n squash 341...\n\nIf you close the editor and no merge conflicts are found, you end up with this history:\n\nIn your case, you don't want to rebase into another branch, but rather into a previous commit.\nIn order to transform the history as shown in the very first example, you have to run something like\ngit rebase -i HEAD~4\n\nchange the \"commands\" to squash for all the commits apart from the first one, and then close your editor.\n\nNote about altering history\nIn Git, commits are never edited. They can be pruned, made not reachable, cloned but not changed.\nWhen you rebase, you are actually creating new commits.\nThe old ones are not longer reachable by any refs, so are not shown in the history but they are still there!\nThis is what you actually get for a rebase:\n\nIf you have already pushed them somewhere, rewriting the history will actually make a branch!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc git diff --cached" }, { "role": "assistant", "content": "compares a (c)ommit and the (i)ndex;" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Duplicated code in .gitlab-ci.yml's script section\n\nIs there a way within gitlab ci to create something like a function? I would like to don't have the duplicated code in the stages or should I use a external script for such a task?\nI had a look into the gitlab template but with a template I can only use a job in the template once.\nstages:\n - build-artefakts\n - build-image\n\nvariables:\n CI_REGISTRY_NAMESPACE: 'main'\n CI_BASE_IMAGE: '...'\n\n 1_GROUP_ID: '...'\n 1_ARTIFACT_ID: '...'\n 1_CLASSIFIER: '...'\n 1_JAR_NAME: '...'\n 1_IMAGE_NAME: '...'\n\n 2_GROUP_ID: '...'\n 2_ARTIFACT_ID: '...'\n 2_CLASSIFIER: '...'\n 2_JAR_NAME: '...'\n 2_IMAGE_NAME: '...'\n\n\ndeploy-maven:\n image: maven:3.6-jdk-11\n stage: build-artefakts\n script:\n - 'mvn deploy -f pom.xml -s ~config/maven/ci_settings.xml -P prod'\n only:\n - master\n artifacts:\n paths:\n - ./target\n expire_in: 1 weeks\n\ndeploy-docker-1:\n image: $CI_BASE_IMAGE\n stage: build-image\n variables:\n ARTIFACT_ID: $1_ARTIFACT_ID\n JAR_NAME: $1_JAR_NAME\n IMAGE_NAME: $1_IMAGE_NAME\n\n before_script:\n - 'docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_TOKEN $CI_REGISTRY'\n script:\n - 'cd docker'\n - 'mv ../target/$ARTIFACT_ID/*.jar $JAR_NAME'\n - 'docker build . -t $IMAGE_NAME:$PROJECT_VERSION --build-arg JAR_FILE=$JAR_NAME'\n - 'docker tag $IMAGE_NAME:$PROJECT_VERSION $CI_REGISTRY/$CI_REGISTRY_NAMESPACE/$IMAGE_NAME:$PROJECT_VERSION'\n - 'docker push $CI_REGISTRY/$CI_REGISTRY_NAMESPACE/$IMAGE_NAME:$PROJECT_VERSION'\n\ndeploy-docker-2:\n image: $CI_BASE_IMAGE\n stage: build-image\n variables:\n ARTIFACT_ID: $2_ARTIFACT_ID\n JAR_NAME: $2_JAR_NAME\n IMAGE_NAME: $2_IMAGE_NAME\n\n before_script:\n - 'docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_TOKEN $CI_REGISTRY'\n script:\n - 'cd docker'\n - 'mv ../target/$ARTIFACT_ID/*.jar $JAR_NAME'\n - 'docker build . -t $IMAGE_NAME:$PROJECT_VERSION --build-arg JAR_FILE=$JAR_NAME'\n - 'docker tag $IMAGE_NAME:$PROJECT_VERSION $CI_REGISTRY/$CI_REGISTRY_NAMESPACE/$IMAGE_NAME:$PROJECT_VERSION'\n - 'docker push $CI_REGISTRY/$CI_REGISTRY_NAMESPACE/$IMAGE_NAME:$PROJECT_VERSION'" }, { "role": "assistant", "content": "You can use YAML-Anchors in \"script\"-sections:\n.some-script: &some-script\n - echo \"executed script\"\n\n.some-other-script: &some-other-script\n - echo \"executed other script\"\n\nfirst_job:\n script:\n - *some-script\n\nsecond_job:\n script:\n - *some-other-script\n\nSince GitLab 13.9 you can also use the custom YAML tag !reference:\n.some-script:\n script:\n - echo \"executed script\"\n\n.some-other-script:\n script:\n - echo \"executed other script\"\n\nfirst_job:\n script:\n - !reference [.some-script, script]\n\nsecond_job:\n script:\n - !reference [.some-other-script, script]\n\nThe difference between the two approaches is that YAML anchors cannot be used across included YAML files. Referenced tags, on the other hand, can be used across included YAML files." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Pull in changes from a Github fork\n\nSomeone forked a Github project of mine and made some changes. How can I merge the changes back in to my upstream version? \nAlso, is it possible to pull in just a specific commit?\nWhat I'm looking is if there is a way to pull a specific commit instead of the entire branch." }, { "role": "assistant", "content": "Pulling in a single commit would be a cherry-pick and would rewrite the commit ID (and mark you as the committer while retaining the author). The process is pretty straightforward, though:\ngit fetch git://github.com/user/project.git\ngit cherry-pick <SHA-COMMIT-ID>\n\nYou get the SHA from the repository log, for example:\ngit log --oneline\n\nb019cc0 Check whether we have <linux/compiler.h>.\n0920898 Include <linux/compiler.h> before including <linux/usbdevice_fs.h>.\ncbf0ba1 Add DLT_DBUS, for raw D-Bus messages.\n77ed5cd Libnl 2.x returns its own error codes, not errnos; handle that.\n\nWith git cherry-pick 0920898 you bring the respective commit to your current branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Does TortoiseGit allow selective staging, like git-gui?\nThis question:\nCan you interact with the index/staging area with TortoiseGit?\ntakes the position that TortoiseGit's main function is not to eliminate the need for the git command line, and in general, I agree.\nHowever, git-gui has a feature I use a lot (maybe to compensate for bad workflow): the ability to selectively stage or unstage hunks or lines from the current patch in order to split a bunch of interspersed changes into coherent changesets in multiple commits.\nThe command-line alternative (for me, at any rate) is a bit clunky, so, ideally, I'd like to do the same selective committing in TortoiseGit.\nSo far I haven't found a way to do this, and I suspect, from the answer to the other question, that it isn't possible. Can anyone confirm this, please?" }, { "role": "assistant", "content": "Yes it does now: see issue 222 - it takes the same approach as TortoiseSVN where you:\n\n\nright-click on file, choose \"Restore after commit\"\nTSVN creates a copy of the file outside the working copy, the file is shown differently in > the commit dialog (maybe an overlay icon or a different color)\nuser can double-click the file to open it in TMerge or some other diff tool and undo all the changes that should not be committed, then save those changes\ncommit\nafter the commit is finished, the copy of the original file is moved back\n\n(From TSVN Issue 68)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-commit - Record changes to the repository ISO 8601" }, { "role": "assistant", "content": "Time and date specified by the ISO 8601 standard, for example 2005-04-07T22:13:13 . The parser accepts a space instead of the T character as well. Fractional parts of a second will be ignored,\nfor example 2005-04-07T22:13:13.019 will be treated as 2005-04-07T22:13:13 . Note In addition, the date part is accepted in the following formats: YYYY.MM.DD , MM/DD/YYYY and DD.MM.YYYY ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to checkout old git commit including all submodules recursively?\nI have a git repo with multiple submodules. One of those submodules has multiple submodules of it's own. All I'm looking to do is check out an old commit on the master repo and have it checkout the appropriate commits from all submodules to get the correct state of the code at that time.\nI know that git contains the information necessary as the ls-tree command can tell me which commit each submodule was on. However, I have to manually check out each one, which is painfully time consuming.\nI'm looking for something like git checkout --recursive but such a command doesn't seem to exist.\nIs there anyway to do this?" }, { "role": "assistant", "content": "You need two commands to achieve this:\ngit checkout *oldcommit*\ngit submodule update --recursive\n\n\nUpdate: This answer is outdated as of 2018 – see VonC's answer below for more current information." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git clone particular version of remote repository\nI cloned a remote git repository about a month ago. The remote repository has undergone many changes and has now become unstable. Now I need another copy of the repository, version identical to the one I cloned a month ago.\nHow do I do this?" }, { "role": "assistant", "content": "You could \"reset\" your repository to any commit you want (e.g. 1 month ago). \nUse git-reset for that:\ngit clone [remote_address_here] my_repo\ncd my_repo\ngit reset --hard [ENTER HERE THE COMMIT HASH YOU WANT]" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-merge-file" }, { "role": "assistant", "content": "Run a three-way file merge" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --ext-diff" }, { "role": "assistant", "content": "Allow an external diff helper to be executed. If you set an\nexternal diff driver with gitattributes , you need\nto use this option with git-log and friends." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Diff with Beyond Compare\nI have succeeded in getting git to start Beyond Compare 3 as a diff tool however, when I do a diff, the file I am comparing against is not being loaded. Only the latest version of the file is loaded and nothing else, so there is nothing in the right pane of Beyond Compare.\nI am running git 1.6.3.1 with Cygwin with Beyond Compare 3. I have set up beyond compare as they suggest in the support part of their website with a script like such: \n#!/bin/sh \n# diff is called by git with 7 parameters: \n# path old-file old-hex old-mode new-file new-hex new-mode \n\"path_to_bc3_executable\" \"$2\" \"$5\" | cat\n\nHas anyone else encountered this problem and know a solution to this? \nEdit:\nI have followed the suggestions by VonC but I am still having exactly the same problem as before. I am kinda new to Git so perhaps I am not using the diff correctly. \nFor example, I am trying to see the diff on a file with a command like such:\n git diff main.css\nBeyond Compare will then open and only display my current main.css in the left pane, there is nothing in the right pane. I would like the see my current main.css in the left pane compared to the HEAD, basically what I have last committed. \nMy git-diff-wrapper.sh looks like this: \n#!/bin/sh \n# diff is called by git with 7 parameters: \n# path old-file old-hex old-mode new-file new-hex new-mode \n\"c:/Program Files/Beyond Compare 3/BCompare.exe\" \"$2\" \"$5\" | cat\n\nMy git config looks like this for Diff: \n[diff] \nexternal = c:/cygwin/bin/git-diff-wrapper.sh" }, { "role": "assistant", "content": "I don't use extra wrapper .sh files. My environment is Windows XP, git 1.7.1 on cygwin, and Beyond Compare 3. Following is my .git/config file.\n[diff]\n tool = bc3\n[difftool]\n prompt = false\n[difftool \"bc3\"]\n #use cygpath to transform cygwin path $LOCAL (something like /tmp/U5VvP1_abc) to windows path, because bc3 is a windows software\n cmd = \\\"c:/program files/beyond compare 3/bcomp.exe\\\" \"$(cygpath -w $LOCAL)\" \"$REMOTE\"\n[merge]\n tool = bc3\n[mergetool]\n prompt = false\n[mergetool \"bc3\"]\n #trustExitCode = true\n cmd = \\\"c:/program files/beyond compare 3/bcomp.exe\\\" \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\"\n\nThen, I use $ git difftool to compare and $ git mergetool to merge.\nAbout trustExitCode:\nFor a custom merge command, specify whether the exit code of the merge command can be used to determine whether the merge was successful. If this is not set to true then the merge target file timestamp is checked and the merge assumed to have been successful if the file has been updated, otherwise the user is prompted to indicate the success of the merge.\nSee also Directory Diff with working directory (local files)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to get total time spend in Gitlab?\n\nIs there a way to get the total time spend on all issues that a user have spend with the time tracking /spend slash command?\nTime tracking stats with the API gets just a small amount of data: https://docs.gitlab.com/ce/api/issues.html#get-time-tracking-stats\nGitlab CE 9.1.4" }, { "role": "assistant", "content": "As I see it is possible to parse comments from API v3 and calculate total. \nFor example,\nhttps://gitlab.com/api/v3/projects/:id/issues/:issue_id/notes?private_token=your_token\n{\n id: 73113225,\n body: \"added 1h of time spent at 2018-05-15\",\n attachment: null,\n author: {\n ...\n username: \"mnvxxx\",\n },\n ...\n}\n\nMore info:\nhttps://docs.gitlab.com/ee/api/notes.html\nUPDATE\nCurrently I has created instrument for calculating spent time by every contributor. I hope it will be helpful:\nhttps://github.com/zubroide/gitpab" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab docker executor - cache image after before_script\n\nIn gitlab-ci there's an option in the .gitlab-ci.yml file to execute commands before any of the actual script runs, called before_script. .gitlab-ci.yml examples illustrate installing ancillary programs here. However, what I've noticed is that these changes are not cached in Docker when using a docker executor. I had naively assumed that after running these commands, docker would cache the image, so for the next run or test, docker would just load the cached image produced after before_script. This would drastically speed up builds.\nAs an example, my .gitlab-ci.yml looks a little like:\nimage: ubuntu\n\nbefore_script:\n - apt-get update -qq && apt-get install -yqq make ...\n\nbuild:\n script:\n - cd project && make\n\nA possible solution is to go to the runner machine and create a docker image that can build my software without any other installation and then reference it in the image section of the yaml file. The downside of this is that whenever I want to add a dependency, I need to log in to the runner machine and update the image before builds will succeed. It would be much nicer if I just had to add the dependency to to the end of apt-get install and have docker / gitlab-ci handle the appropriate caching.\nThere is also a cache command in .gitlab-ci.yml, which I tried setting to untracked: true, which I thought would cache everything that wasn't a byproduct of my project, but it didn't seem to have any effect.\nIs there any way to get the behavior I desire?" }, { "role": "assistant", "content": "You can add a stage to build the image in first place. If the image doesn't have any change, the stage will be very short, under 1 second.\nYou can use that image on the following stages, speeding up the whole process.\nThis is an example of a .gitlab-ci.yml:\nstages:\n - build_test_image\n - test\n\nbuild_test:\n stage: build_test_image\n script:\n - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY\n - docker build -t $CI_REGISTRY_IMAGE:test -f dockerfiles/test/Dockerfile .\n - docker push $CI_REGISTRY_IMAGE:test\n tags:\n - docker_build\n\ntest_syntax:\n image: $CI_REGISTRY_IMAGE:test\n stage: test\n script:\n - pip install flake8\n - flake8 --ignore=E501,E265 app/\n\nLook at the tag docker_build. That tag is used to force the execution of the stage on the runner which has that tag. The executor for that runner is shell, and it's used only to build Docker images. So, the host where the runner lives should have installed Docker Engine. I found this solution suits better my needs than docker in docker and another solutions.\nAlso, I'm using a private registry, that's why I'm using $CI_REGISTRY* variables, but you can use DockerHub without need to specify the registry. The problem would be to authenticate on DockerHub, though." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-ls-files - Show information about files in the index and the working tree eolattr" }, { "role": "assistant", "content": "The <eolattr> (see the description of the --eol option)\nthat applies to the path." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order --pretty[=<format>] --format=<format>" }, { "role": "assistant", "content": "Pretty-print the contents of the commit logs in a given format,\nwhere <format> can be one of oneline , short , medium , full , fuller , reference , email , raw , format:<string> and tformat:<string> . When <format> is none of the above,\nand has %placeholder in it, it acts as if --pretty=tformat:<format> were given. See the \"PRETTY FORMATS\" section for some additional details for each\nformat. When =<format> part is omitted, it defaults to medium . Note: you can specify the default pretty format in the repository\nconfiguration (see git-config )." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Move existing, uncommitted work to a new branch in Git\nI started some work on a new feature and after coding for a bit, I decided this feature should be on its own branch. \nHow do I move the existing uncommitted changes to a new branch and reset my current one?\nI want to reset my current branch while preserving existing work on the new feature." }, { "role": "assistant", "content": "Update 2020 / Git 2.23\nGit 2.23 adds the new switch subcommand in an attempt to clear some of the confusion that comes from the overloaded usage of checkout (switching branches, restoring files, detaching HEAD, etc.)\nStarting with this version of Git, replace the checkout command with:\ngit switch -c <new-branch>\n\nThe behavior is identical and remains unchanged.\n\nBefore Update 2020 / Git 2.23\nUse the following:\ngit checkout -b <new-branch>\n\nThis will leave your current branch as it is, create and checkout a new branch and keep all your changes. You can then stage changes in files to commit with:\ngit add <files>\n\nand commit to your new branch with:\ngit commit -m \"<Brief description of this commit>\"\n\nThe changes in the working directory and changes staged in index do not belong to any branch yet. This changes the branch where those modifications would end in.\nYou don't reset your original branch, it stays as it is. The last commit on <old-branch> will still be the same. Therefore you checkout -b and then commit." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-grep - Print lines matching a pattern --no-index" }, { "role": "assistant", "content": "Search files in the current directory that is not managed by Git,\nor by ignoring that the current directory is managed by Git. This\nis rather similar to running the regular grep(1) utility with its -r option specified, but with some additional benefits, such as\nusing pathspec patterns to limit paths; see the pathspec entry\nin gitglossary for more information. This option cannot be used together with --cached or --untracked .\nSee also grep.fallbackToNoIndex in CONFIGURATION below." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-commit - Record changes to the repository scissors" }, { "role": "assistant", "content": "Same as whitespace except that everything from (and including)\nthe line found below is truncated, if the message is to be edited.\n\" # \" can be customized with core.commentChar. # ------------------------ >8 ------------------------" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --show-notes-by-default" }, { "role": "assistant", "content": "Show the default notes unless options for displaying specific\nnotes are given." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options pack.writeBitmapLookupTable" }, { "role": "assistant", "content": "When true, Git will include a \"lookup table\" section in the\nbitmap index (if one is written). This table is used to defer\nloading individual bitmaps as late as possible. This can be\nbeneficial in repositories that have relatively large bitmap\nindexes. Defaults to false." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git add * (asterisk) vs git add . (period)\nI have a question about adding files in git. I have found multiple stackoverflow questions about the difference between git add . and git add -a, git add --all, git add -A, etc. But I've been unable to find a place that explains what git add * does. I've even looked at the git add man page, but it didn't help. I've been using it in place of git add . and my co-worker asked me why. I didn't have an answer. I've just always used git add *.\nAre git add . and git add * the same? Does one add changed files from the current directory only, while the other adds files from the current directory and subdirectories (recursively)?\nThere's a great chart listed on one of the other stack questions that shows the difference between git add -A git add . and git add -u, but it doesn't have git add *.\n\nNote: I understand what it means to use the asterisk as a wildcard (add all files with a given extension). For example, git add *.html would add all files that have a .html extension (but ignore .css, .js, etc).\nThanks for the help!" }, { "role": "assistant", "content": "add * means add all files in the current directory, except for files whose name begin with a dot. This is your shell functionality and Git only ever receives a list of files.\nadd . has no special meaning in your shell, and thus Git adds the entire directory recursively, which is almost the same, but including files whose names begin with a dot." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to publish to Github Pages from Travis CI?\n\nWe are compiling Doxygen docs on the travis-ci server and want to push them onto our gh-pages branch.\nHow do I handle the authorization for git push? Does someone have an example for using encrypted variables in travis-ci? Should I go for https authorization or for an SSH key?" }, { "role": "assistant", "content": "Step-by-step example with HTTPS API Token in environment variable\nOthers have mentioned it, but here goes a more detailed procedure.\n\nCreate a separate repository for the website (optional). This will reduce the likelihood that you overwrite your main repository, and will keep output files from polluting it.\nGet a Personal Access Token under https://github.com/settings/tokens\nOnly enable \"public_repo\" access for public repositories, \"repo\" for private.\nSave the token somewhere as you can only see it once.\nOn the Travis settings for the repository https://travis-ci.org/<me>/<myrepo>/settings create an environment variable:\nGITHUB_API_KEY=<token>\n\nand make sure to mark \"Display value in build log\" as \"Off\".\nThis is safe because only authorized pushes by you see such environment variables, so if a malicious user tries to make a pull request to get your string, the variable won't be there.\nJust make sure that you never, ever list your environment variables on your build!\nAdd the following to your .travis.yml:\nafter_success: |\n if [ -n \"$GITHUB_API_KEY\" ]; then\n cd \"$TRAVIS_BUILD_DIR\"\n # This generates a `web` directory containing the website.\n make web\n cd web\n git init\n git checkout -b gh-pages\n git add .\n git -c user.name='travis' -c user.email='travis' commit -m init\n # Make sure to make the output quiet, or else the API token will leak!\n # This works because the API key can replace your password.\n git push -f -q https://<me>:[email protected]/<me>/<myrepo>-gh-pages gh-pages &>/dev/null\n cd \"$TRAVIS_BUILD_DIR\"\n fi\n\n\nAlternative travis encrypt method\nExplained in detail at: https://stackoverflow.com/a/33109519/895245\nEncrypt the string GITHUB_API_KEY=<key> with the travis gem, and add it to your .travis.yml:\nenv:\n secure: <encrypted>\n\nThis has the advantage that it does not require using the Travis web interface, but does require using a Gem and some more copy pasting." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission -I<regex> --ignore-matching-lines=<regex>" }, { "role": "assistant", "content": "Ignore changes whose all lines match <regex>. This option may\nbe specified more than once." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-am - Apply a series of patches from a mailbox drop" }, { "role": "assistant", "content": "The e-mail message will be skipped." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitfaq - Frequently asked questions about using Git What’s the recommended way to store files in Git?" }, { "role": "assistant", "content": "While Git can store and handle any file of any type, there are some\nsettings that work better than others. In general, we recommend that\ntext files be stored in UTF-8 without a byte-order mark (BOM) with LF\n(Unix-style) endings. We also recommend the use of UTF-8 (again,\nwithout BOM) in commit messages. These are the settings that work best\nacross platforms and with tools such as git diff and git merge . Additionally, if you have a choice between storage formats that are text based\nor non-text based, we recommend storing files in the text format and, if\nnecessary, transforming them into the other format. For example, a text-based\nSQL dump with one record per line will work much better for diffing and merging\nthan an actual database file. Similarly, text-based formats such as Markdown\nand AsciiDoc will work better than binary formats such as Microsoft Word and\nPDF. Similarly, storing binary dependencies (e.g., shared libraries or JAR files) or\nbuild products in the repository is generally not recommended. Dependencies and\nbuild products are best stored on an artifact or package server with only\nreferences, URLs, and hashes stored in the repository. We also recommend setting a gitattributes file to explicitly mark\nwhich files are text and which are binary. If you want Git to guess, you can\nset the attribute text=auto . For example, the following might be appropriate\nin some projects: # By default, guess.\n*\ttext=auto\n# Mark all C files as text.\n*.c\ttext\n# Mark all JPEG files as binary.\n*.jpg\tbinary These settings help tools pick the right format for output such as patches and\nresult in files being checked out in the appropriate line ending for the\nplatform." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-merge-base - Find as good common ancestors as possible for a merge --octopus" }, { "role": "assistant", "content": "Compute the best common ancestors of all supplied commits,\nin preparation for an n-way merge. This mimics the behavior\nof git show-branch --merge-base ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.<driver>.textconv" }, { "role": "assistant", "content": "The command that the diff driver should call to generate the\ntext-converted version of a file. The result of the\nconversion is used to generate a human-readable diff. See gitattributes for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --dd" }, { "role": "assistant", "content": "Produce diff with respect to first parent for both merge and\nregular commits.\nShortcut for --diff-merges=first-parent -p ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "! [rejected] master -> master (fetch first)\nIs there a good way to explain how to resolve \"! [rejected] master -> master (fetch first)'\" in Git?\nWhen I use this command $ git push origin master it display an error message.\n! [rejected] master -> master (fetch first)\nerror: failed to push some refs to '[email protected]:zapnaa/abcappp.git'" }, { "role": "assistant", "content": "The answer is there, git is telling you to fetch first.\nProbably somebody else has pushed to master already, and your commit is behind. Therefore you have to fetch, merge the changeset, and then you'll be able to push again.\nIf you don't (or even worse, if you force it by using the --force option), you can mess up the commit history.\nEDIT: I get into more detail about the last point, since a guy here just gave the Very Bad Advice of using the --force option.\nAs git is a DVCS, ideally many other developers are working on the same project as you, using the same repository (or a fork of it). If you overwrite forcefully with your changeset, your repository will mismatch other people's, because \"you rewrote history\". You will make other people unhappy and the repository will suffer. Probably a kitten in the world will cry, too.\nTL;DR\n\nIf you want to solve, fetch first (and then merge).\nIf you want to hack, use the --force option. \n\nYou asked for the former, though. Go for 1) always, even if you will always use git by yourself, because it is a good practice." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "'git status' shows changed files, but 'git diff' doesn't\nI've had a look at all similar questions. However, I've double checked and something strange is definitely happening.\nOn one server (Solaris with Git 1.8.1) I cloned the Git repository then copied the .git folder into my existing live files. This worked perfectly, I could run\ngit status\n\nthen\ngit diff [filename]\n\nto check any files that were different.\nOn another server (Solaris with Git 1.7.6) I'm doing exactly the same however\ngit diff [filename]\n\nshows nothing, even if the contents of the file is definitely different. I have also tested adding a new file, committing it, and then editing. The same issue, git status shows the file as changed, but git diff shows nothing. If I download the changed file and run a diff locally then I get diff output." }, { "role": "assistant", "content": "For me, it had something to do with file permissions.\nSomeone with Mac/Linux on my project seems to commit some files with non-default permissions which my Windows Git client failed to reproduce.\nThe solution for me was to tell Git to ignore file permissions:\ngit config core.fileMode false\n\nOther insight: How do I make Git ignore file mode (chmod) changes?" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitlab-ci.yml jobs:build-production config key may not be used with `rules`: only\n\nI am having a syntax error when I test my gitlab-ci.yml in CI Lint. Can someone suggest a solution to this problem?\nbuild-production:\n stage: build\n only:\n - master\n image:\n name: gcr.io/kaniko-project/executor:debug\n entrypoint: [\"\"]\n script:\n - mkdir -p /kaniko/.docker\n - echo \"{\\\"auths\\\":{\\\"$CI_REGISTRY\\\":{\\\"username\\\":\\\"$CI_REGISTRY_USER\\\",\\\"password\\\":\\\"$CI_REGISTRY_PASSWORD\\\"}}}\" > /kaniko/.docker/config.json\n - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG\n rules:\n - if: $CI_COMMIT_TAG\n\nStatus: syntax is incorrect \n\njobs:build-production config key may not be used with `rules`: only" }, { "role": "assistant", "content": "Documentation is pretty clear :\n\nrules replaces only/except and they can’t be used together in the same job. If you configure one job to use both keywords, the linter returns a key may not be used with rules error.\n\nI suggest to use rules: for both of your conditions :\nrules:\n - if: '$CI_COMMIT_REF_NAME == \"master\" && $CI_COMMIT_TAG'" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-for-each-ref - Output information on each ref HEAD" }, { "role": "assistant", "content": "* if HEAD matches current ref (the checked out branch), ' '\notherwise." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Keep commits history after a 'git merge'\nWhen I work on two different features (on two different branches created from the master) it is quite annoying that I will not have the commit history when I proceed with merging.\nI'll explain better. When I finish work on Branch-A, I merge it into master. And that's fine, if I git log I see all the commits I made on Branch-A.\nInstead, when I finish work on Branch-B and I try to merge it to master (after that Branch-A has been already merged), I have to specify a commit message for the merging (while for the first branch I have not been asked anything).\nAnd after the merging to master, if I type git log, I cannot see the commits of the Branch-B in the history of my master branch\nLet's say I have \n**Branch A**\n\ncommit 09b2unfas9d781n2e\n Add more stuff\n\ncommit 8uj8masd89jas898a\n Add stuff\n\n**Branch B**\n\ncommit 09b2unfas9d781n2e\n Add feature setting\n\ncommit 8uj8masd89jas898a\n Add feature\n\nI finish having\n**Master**\n\ncommit 6hf6h8hd871udjkdn\nMerge: 09b2un 34osd6\n Merge branch 'Branch-B' into master\n\ncommit 09b2unfas9d781n2e\n Add more stuff\n\ncommit 8uj8masd89jas898a\n Add stuff\n\ncommit 34osd62dhc91123j8\n I'm a previous commit from 'master'.\n The last one before branching...\n\nwhile I would like to obtain something like:\n**Master**\n\ncommit 09b2unfas9d781n2e\n Add feature setting\n\ncommit 8uj8masd89jas898a\n Add feature\n\ncommit 09b2unfas9d781n2e\n Add more stuff\n\ncommit 8uj8masd89jas898a\n Add stuff\n\ncommit 34osd62dhc91123j8\n I'm a previous commit from 'master'.\n The last one before branching...\n\n... that would reflect more exactly the history of the performed commits.\nI don't get why I can keep the history from just one of the two branches.\nHow can I keep everything clear without those merge commits that hide/omit the real history of the merged commits?" }, { "role": "assistant", "content": "It looks like the first merge was a fast-forward, and the second one was a three-way merge.\nExplanation\nGit has two versions of merge: fast-forward and three-way. (There are other versions, but that is not what happened here.) The default behavior is to do a fast-forward merge when possible, and otherwise do a three-way merge.\nA fast-forward merge can take place when the commit that is being merged has the current position of the branch in its history (you can force this behavior with the option --ff-only, which will cause the merge to fail when fast-forward is impossible). For example:\nA - B - C - D <-master\n \\\n E - F - G <- branch-a\n\nExecuting git merge (with default settings) will result in\nA - B - C - D - E - F - G <- branch-a <-master\n\nYou will also not get a chance to edit the merge commit because there is none.\nA three-way merge when your other branch diverges from master (not just ahead):\nA - B - C - D - E - F - G <-master\n \\\n E1 - E2 <- branch-b\n\nIn this case, Git cannot just move the pointer of master from G to E2 because that will get rid of the changes that were made in F and G. When a three-way merge happens, it creates a commit that has two parents, and also has a commit message. Now, master can be moved to this commit. (Notice that in this situation, master and branch-b do NOT point to the same commit.\nA - B - C - D - E - F - G - H <-master\n \\ /\n E1 - E2 <- branch-b\n\nIf you want to have a linear history then you need to use rebase, but be forewarned that if anybody else has seen your branch commits this may lead to issues that are beyond the scope of this answer. Using rebase will involve two steps, rebasing and then fast-forward merge. So, instead of merging you first execute the following while on branch-b, git rebase master. This creates new commits that are copies of the old commits, i.e., the same change-set, author information and message, but new committer information and parent history. (I call the commits E1' and E2' in the illustration to indicate that they are just copies.) The old commits will exist until they are garbage collected, but will not be reachable unless you look at the reflog.)\nA - B - C - D - E - F - G <-master\n \\ \\\n E1 - E2 \\ \n E1' - E2' <- branch-b\n\nExecuting git checkout master; git merge --ff-only branch-b will now fast-forward your changes into master, thereby giving you a linear history.\nA - B - C - D - E - F - G - E1' -E2' <-master <- branch-b" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -D --irreversible-delete" }, { "role": "assistant", "content": "Omit the preimage for deletes, i.e. print only the header but not\nthe diff between the preimage and /dev/null . The resulting patch\nis not meant to be applied with patch or git apply ; this is\nsolely for people who want to just concentrate on reviewing the\ntext after the change. In addition, the output obviously lacks\nenough information to apply such a patch in reverse, even manually,\nhence the name of the option. When used together with -B , omit also the preimage in the deletion part\nof a delete/create pair." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fast-import - Backend for fast Git data importers" }, { "role": "assistant", "content": "PACKFILE OPTIMIZATION When packing a blob fast-import always attempts to deltify against the last\nblob written. Unless specifically arranged for by the frontend,\nthis will probably not be a prior version of the same file, so the\ngenerated delta will not be the smallest possible. The resulting\npackfile will be compressed, but will not be optimal. Frontends which have efficient access to all revisions of a\nsingle file (for example reading an RCS/CVS ,v file) can choose\nto supply all revisions of that file as a sequence of consecutive blob commands. This allows fast-import to deltify the different file\nrevisions against each other, saving space in the final packfile.\nMarks can be used to later identify individual file revisions during\na sequence of commit commands. The packfile(s) created by fast-import do not encourage good disk access\npatterns. This is caused by fast-import writing the data in the order\nit is received on standard input, while Git typically organizes\ndata within packfiles to make the most recent (current tip) data\nappear before historical data. Git also clusters commits together,\nspeeding up revision traversal through better cache locality. For this reason it is strongly recommended that users repack the\nrepository with git repack -a -d after fast-import completes, allowing\nGit to reorganize the packfiles for faster data access. If blob\ndeltas are suboptimal (see above) then also adding the -f option\nto force recomputation of all deltas can significantly reduce the\nfinal packfile size (30-50% smaller can be quite typical). Instead of running git repack you can also run git gc\n--aggressive , which will also optimize other things after an import\n(e.g. pack loose refs). As noted in the \"AGGRESSIVE\" section in git-gc the --aggressive option will find new deltas with\nthe -f option to git-repack . For the reasons elaborated\non above using --aggressive after a fast-import is one of the few\ncases where it’s known to be worthwhile." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options merge.<driver>.driver" }, { "role": "assistant", "content": "Defines the command that implements a custom low-level\nmerge driver. See gitattributes for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository" }, { "role": "assistant", "content": "REMOTES The name of one of the following can be used instead\nof a URL as <repository> argument: a remote in the Git configuration file: $GIT_DIR/config , a file in the $GIT_DIR/remotes directory, or a file in the $GIT_DIR/branches directory. All of these also allow you to omit the refspec from the command line\nbecause they each contain a refspec which git will use by default. Named remote in configuration file You can choose to provide the name of a remote which you had previously\nconfigured using git-remote , git-config or even by a manual edit to the $GIT_DIR/config file. The URL of\nthis remote will be used to access the repository. The refspec\nof this remote will be used by default when you do\nnot provide a refspec on the command line. The entry in the\nconfig file would appear like this: [remote \"<name>\"]\n\t\turl = <URL>\n\t\tpushurl = <pushurl>\n\t\tpush = <refspec>\n\t\tfetch = <refspec> The <pushurl> is used for pushes only. It is optional and defaults\nto <URL> . Pushing to a remote affects all defined pushurls or all\ndefined urls if no pushurls are defined. Fetch, however, will only\nfetch from the first defined url if multiple urls are defined. Named file in $GIT_DIR/remotes You can choose to provide the name of a\nfile in $GIT_DIR/remotes . The URL\nin this file will be used to access the repository. The refspec\nin this file will be used as default when you do not\nprovide a refspec on the command line. This file should have the\nfollowing format: URL: one of the above URL formats\n\tPush: <refspec>\n\tPull: <refspec> Push: lines are used by git push and Pull: lines are used by git pull and git fetch .\nMultiple Push: and Pull: lines may\nbe specified for additional branch mappings. Named file in $GIT_DIR/branches You can choose to provide the name of a\nfile in $GIT_DIR/branches .\nThe URL in this file will be used to access the repository.\nThis file should have the following format: <URL>#<head> <URL> is required; #<head> is optional. Depending on the operation, git will use one of the following\nrefspecs, if you don’t provide one on the command line. <branch> is the name of this file in $GIT_DIR/branches and <head> defaults to master . git fetch uses: refs/heads/<head>:refs/heads/<branch> git push uses: HEAD:refs/heads/<head>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: Set local user.name and user.email different for each repo\nI'm currently working on 2 projects, which expect that I configure my local username and email with different data when I push to them. For that I'm updating my config all the time like:\ngit config --local user.email \"[email protected]\"\nSince they are different repositories, is there a way I could define an local email for each repository?\nMaybe in the .gitconfig?" }, { "role": "assistant", "content": "For just one repo, go into to the relevant repo DIR and:\ngit config user.name \"Your Name Here\"\ngit config user.email [email protected]\n\nFor (global) default email (which is configured in your ~/.gitconfig):\ngit config --global user.name \"Your Name Here\"\ngit config --global user.email [email protected]\n\nYou can check your Git settings with:\ngit config user.name && git config user.email\nIf you are in a specific repo which you setup a new user/config for (different to global) then it should show that local config, otherwise it will show your global config." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-check-ref-format" }, { "role": "assistant", "content": "Ensures that a reference name is well formed" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "jitpack.io failed to resolve github repo\n\nI have a Github repo and pushed tags on it.\nThis is my gradle file of my main project.\napply plugin: 'com.android.application'\n\nandroid {\n compileSdkVersion 23\n buildToolsVersion \"23.0.0\"\n\n defaultConfig {\n applicationId \"dropbox.ric.es.myapplication\"\n minSdkVersion 16\n targetSdkVersion 23\n versionCode 1\n versionName \"1.0\"\n }\n buildTypes {\n release {\n minifyEnabled false\n proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n }\n }\n}\n\nrepositories {\n //mavenCentral()\n //jcenter()\n\n maven { url \"https://jitpack.io\" }\n\n}\n\ndependencies {\n compile fileTree(dir: 'libs', include: ['*.jar'])\n compile 'com.android.support:appcompat-v7:23.0.1'\n compile 'com.github.rchampa:DropboxHttpConector:1.0.1'\n}\n\nBut when I sync gradle I have the following error Failed to resolve com.github.rchampa:DropboxHttpConector:1.0.1\nAnother attempt:\nallprojects {\n repositories {\n jcenter()\n maven { url \"https://jitpack.io\" }\n }\n}\n\ndependencies {\n compile fileTree(dir: 'libs', include: ['*.jar'])\n compile 'com.android.support:appcompat-v7:23.0.1'\n compile 'com.github.rchampa:DropboxHttpConector:1.0.1'\n}\n\nStill failing." }, { "role": "assistant", "content": "For anyone else that made the simple mistake I made:\nEnsure you add the maven { url \"https://jitpack.io\" } under allprojects instead of buildscript.\nProject build.gradle file:\nbuildscript {\n repositories {\n jcenter()\n // DO NOT ADD IT HERE!!!\n }\n ...\n}\n\nallprojects {\n repositories {\n mavenLocal()\n jcenter()\n // ADD IT HERE\n maven { url \"https://jitpack.io\" }\n }\n}\n\nThanks to Alexander Pacha for pointing that out in a comment above." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git submodule tracking latest\nWe are moving our (huge) project to git and we are thinking about using submodules. Our plan is to have three different heads in the superproject:\n\nrelease, stable, latest\n\nThe project leads will handle the release and stable branches. They will move the submodules as required.\nThe issue is the \"latest\" head. We would like the superproject \"latest\" head to track the master branches of all the submodules (automatically). And also it would be great if it would show the history of all commits to the submodule.\nI have looked at gitslave, but it is not quite what we want. Any suggestions?" }, { "role": "assistant", "content": "Edit (2020.12.28): GitHub change default master branch to main branch since October 2020. See https://github.com/github/renaming\nThis answer below still reflect the old naming convention.\n\nUpdate March 2013\nGit 1.8.2 added the possibility to track branches.\n\n\"git submodule\" started learning a new mode to integrate with the tip of the remote branch (as opposed to integrating with the commit recorded in the superproject's gitlink).\n\n# add submodule to track master branch\ngit submodule add -b master [URL to Git repo];\n\n# update your submodule\ngit submodule update --remote \n\nIf you had a submodule already present you now wish would track a branch, see \"how to make an existing submodule track a branch\".\nAlso see Vogella's tutorial on submodules for general information on submodules.\nNote:\ngit submodule add -b . [URL to Git repo];\n ^^^\n\nSee git submodule man page:\n\nA special value of . is used to indicate that the name of the branch in the submodule should be the same name as the current branch in the current repository.\n\n\nSee commit b928922727d6691a3bdc28160f93f25712c565f6:\n\nsubmodule add: If --branch is given, record it in .gitmodules\nSigned-off-by: W. Trevor King\nThis allows you to easily record a submodule.<name>.branch option in .gitmodules when you add a new submodule. With this patch,\n$ git submodule add -b <branch> <repository> [<path>]\n$ git config -f .gitmodules submodule.<path>.branch <branch>\n\nreduces to\n$ git submodule add -b <branch> <repository> [<path>]\n\nThis means that future calls to\n$ git submodule update --remote ...\n\nwill get updates from the same branch that you used to initialize the submodule, which is usually what you want.\n\n\nOriginal answer (February 2012):\nA submodule is a single commit referenced by a parent repo.\nSince it is a Git repo on its own, the \"history of all commits\" is accessible through a git log within that submodule.\nSo for a parent to track automatically the latest commit of a given branch of a submodule, it would need to:\n\ncd in the submodule\ngit fetch/pull to make sure it has the latest commits on the right branch\ncd back in the parent repo\nadd and commit in order to record the new commit of the submodule.\n\ngitslave (that you already looked at) seems to be the best fit, including for the commit operation.\n\nIt is a little annoying to make changes to the submodule due to the requirement to check out onto the correct submodule branch, make the change, commit, and then go into the superproject and commit the commit (or at least record the new location of the submodule).\n\nOther alternatives are detailed here." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "is not checked out... bundle install does NOT fix help!\nhttps://github.com/intridea/omniauth.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)\n\nSo what do I do? bundle install works on development, but when I push and deploy to my production server. I get this error, even after running bundle install on my production server." }, { "role": "assistant", "content": "You're probably running Passenger. This is the issue with some solutions - http://code.google.com/p/phusion-passenger/issues/detail?id=505\nTry running bundle install --deployment" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gem file with git remote failing on heroku push\nI have the following line in my gemfile:\ngem 'client_side_validations', :git => \"[email protected]:Dakuan/client_side_validations.git\", :branch => \"master\", ref: '2245b4174ffd4b400d999cb5a2b6dccc0289eb67'\n\nThe repo it's pointing at is public and I can run bundle install / update locally just fine. When I try to push to Heroku I get the following error:\n\n Fetching [email protected]:Dakuan/client_side_validations.git\n Host key verification failed.\n fatal: The remote end hung up unexpectedly\n Git error: command `git clone '[email protected]:Dakuan/client_side_validations.git' \"/tmp/build_1xa9f06n4k1cu/vendor/bundle/ruby/1.9.1/cache/bundler/git/client_side_validations-56a04875baabb67b5f8c192c6c6743df476fd90f\" --bare --no-hardlinks` in directory /tmp/build_1xa9f06n4k1cu has failed.\n\n!\n ! Failed to install gems via Bundler.\n !\n ! Heroku push rejected, failed to compile Ruby/rails app\n\nAnyone got any ideas about what's going on here?" }, { "role": "assistant", "content": "Use this GitHub URL instead: git://github.com/Dakuan/client_side_validations.git\nThe [email protected]:… URL is the writable SSH version, which requires authentication with an SSH key connected to a GitHub account that has write access to the repository.\nThe git://github.com/… URL is the public, read-only version.\nSince the gem you're using is in a public GitHub repository, you can also use this shorthand in your Gemfile:\ngem 'client_side_validations', :github => 'Dakuan/client_side_validations'\n\nSee the Bundler Git documentation for more information." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git: how to move some commits to new branch\nI have been working in straight line:\nA---B---C---D---E---F (master:HEAD)\n\nNow I want to move backward:\ngit checkout C\n\nand move few last commits to a new branch:\nOption 1:\n D---E---F (new:HEAD)\n /\nA---B---C (master)\n\nOption 2:\n F (new:HEAD)\n /\nA---B---C (master)\n\nHow to rebase to Option 1 and how to Option 2?" }, { "role": "assistant", "content": "To get from your first diagram (master = HEAD = F) to option 1:\ngit branch new # Make a 'new' branch pointing at HEAD, which is F\ngit reset --hard C # Move master back to point at C\ngit checkout new # Make HEAD follow new, and get F in the working tree\n\nAnd from option 1 to option 2 (picking up where the above left off),\ngit rebase -i master # Start the process of re-jiggering this branch\n# edit the commit list that opens up to only include F\n# save and exit\n# resolve potential conflicts from missing changes in D and E\n\nTo go directly from your starting point to option 2:\ngit checkout -b new C # Start the 'new' branch at C\ngit cherry-pick F # Include F on it\ngit checkout master # Switch back to master\ngit reset --hard C # Rewind master to the earlier commit" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "When would you use the different git merge strategies?\nFrom the man page on git-merge, there are a number of merge strategies you can use. \n\nresolve - \nThis can only resolve two heads (i.e. the current branch and another branch you pulled from) using 3-way merge algorithm. It tries to carefully detect criss-cross merge ambiguities and is considered generally safe and fast.\nrecursive - \nThis can only resolve two heads using 3-way merge algorithm. When there are more than one common ancestors that can be used for 3-way merge, it creates a merged tree of the common ancestors and uses that as the reference tree for the 3-way merge. This has been reported to result in fewer merge conflicts without causing mis-merges by tests done on actual merge commits taken from Linux 2.6 kernel development history. Additionally this can detect and handle merges involving renames. This is the default merge strategy when pulling or merging one branch.\noctopus - \nThis resolves more than two-head case, but refuses to do complex merge that needs manual resolution. It is primarily meant to be used for bundling topic branch heads together. This is the default merge strategy when pulling or merging more than one branches.\nours - \nThis resolves any number of heads, but the result of the merge is always the current branch head. It is meant to be used to supersede old development history of side branches.\nsubtree - \nThis is a modified recursive strategy. When merging trees A and B, if B corresponds to a subtree of A, B is first adjusted to match the tree structure of A, instead of reading the trees at the same level. This adjustment is also done to the common ancestor tree.\n\nWhen should I specify something different than the default? What scenarios are each best for?" }, { "role": "assistant", "content": "I'm not familiar with resolve, but I've used the others:\nRecursive\nRecursive is the default for non-fast-forward merges. We're all familiar with that one.\nOctopus\nI've used octopus when I've had several trees that needed to be merged. You see this in larger projects where many branches have had independent development and it's all ready to come together into a single head.\nAn octopus branch merges multiple heads in one commit as long as it can do it cleanly.\nFor illustration, imagine you have a project that has a master, and then three branches to merge in (call them a, b, and c).\nA series of recursive merges would look like this (note that the first merge was a fast-forward, as I didn't force recursion):\n\nHowever, a single octopus merge would look like this:\ncommit ae632e99ba0ccd0e9e06d09e8647659220d043b9\nMerge: f51262e... c9ce629... aa0f25d...\n\n\nOurs\nOurs == I want to pull in another head, but throw away all of the changes that head introduces.\nThis keeps the history of a branch without any of the effects of the branch.\n(Read: It is not even looked at the changes between those branches. The branches are just merged and nothing is done to the files. If you want to merge in the other branch and every time there is the question \"our file version or their version\" you can use git merge -X ours)\nSubtree\nSubtree is useful when you want to merge in another project into a subdirectory of your current project. Useful when you have a library you don't want to include as a submodule." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git clone without project folder\nI have given access to server, and want to clone git repo into my root folder. But when I do git clone it will make me folder with project name, and my project folder is my root. I dont have access to my parent folder\nmy root is\n/var/www/sites/mysite/\n\nand when I do cloning folder structure will be\n/var/www/sites/mysite/mysite" }, { "role": "assistant", "content": "git clone accepts a last argument that is the destination directory, it is by default the name of the project but you can change it. In your case you probably want simply .:\n$ git clone origin-url .\n\nBut note that, from man git-clone:\n\nCloning into an existing directory is only allowed if the directory is empty." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --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": "How to change the license for a project at Github? [closed]\nClosed. This question 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 This question does not appear to be about programming within the scope defined in the help center.\n\n\nClosed 10 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI have created a simple list API in C and I want to release it via Github.\nIs there any way to change the license after the creation of the repository?" }, { "role": "assistant", "content": "If you release it with a license, you allow people to use it as the licence describes. You can't just say \"no I changed my mind I don't want it to be under GPL\". Of course your future release may be in another license (GPL forces other people's modified versions to be GPL, but you, as the creator, may release new versions of your work under a new license).\nAmendment\nWebsites like choosealicense.com may help you to choose a suitable license. The license picker provides some templates that can be committed to your repository; for an existing repository you can bring it back this way:\n\nbrowse to your repository at GitHub.com\ncreate a new file by pressing the blue + icon (updated to: New File button)\nname it LICENSE.md or LICENSE.txt to show up the license picker again\nchoose a template" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can I use Git to search for matching filenames in a repository?\nJust say I have a file: \"HelloWorld.pm\" in multiple subdirectories within a Git repository.\nI would like to issue a command to find the full paths of all the files matching \"HelloWorld.pm\":\nFor example:\n/path/to/repository/HelloWorld.pm\n/path/to/repository/but/much/deeper/down/HelloWorld.pm\n/path/to/repository/please/dont/make/me/search/through/the/lot/HelloWorld.pm\n\nHow can I use Git to efficiently find all the full paths that match a given filename?\nI realise I can do this with the Linux/Unix find command but I was hoping to avoid scanning all subdirectories looking for instances of the filename." }, { "role": "assistant", "content": "git ls-files will give you a listing of all files in current state of the repository (the cache or index). You can pass a pattern in to get files matching that pattern.\ngit ls-files HelloWorld.pm '**/HelloWorld.pm'\n\nIf you would like to find a set of files and grep through their contents, you can do that with git grep:\ngit grep some-string -- HelloWorld.pm '**/HelloWorld.pm'" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Troubleshooting git push - it asks for a user/pass\n\nI'm using git on a new git linux computer. When I do git push, it me asks for user/password.\nI've setup git properly, and in fact cloning the repo from github into a new folder works perfectly (using my public key, not the readonly copy). When I try to push from a previous clone I made to the same repo I get prompted for a user/pass.\nOf course sshing into [email protected] works, and I made sure my public key is configured in github. Any ideas how to continue debugging?" }, { "role": "assistant", "content": "this occurs because you did\ngit clone https://github.com/username/repo\n\ninstead of \ngit clone [email protected]:username/repo.git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-archive - Create an archive of files from a named tree git archive --format=zip --prefix=git-docs/ HEAD:Documentation/ > git-1.4.0-docs.zip" }, { "role": "assistant", "content": "Put everything in the current head’s Documentation/ directory\ninto git-1.4.0-docs.zip , with the prefix git-docs/ ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can I pass environment variables from Gitlab .gitlab-ci.yml to a React app?\n\nI'm trying to set environment variables dynamically using the gitlab CI pipeline. \nWhat I am trying to achieve is to inject the right API keys and URLs depending on the stage I am deploying to (stage, prod).\nIn my React app I access the variables using process.env.REACT_APP_APPSYNC_URL as decribed in the react documentation. \nSo far I have tried setting the variables in the gitlab UI and referencing them in my .gitlab-ci.yml file (see code below). \nUnfortunately I cannot access the variables this way, so I would be very thankful for any help. \nI'm just getting started on CI/CD and different environments, so if I am generally using a bad approach here please let me know!\nHere's the .gitlab-ci.yml:\nimage: nikolaik/python-nodejs:latest\n\nstages:\n - install\n - test\n - deploy\n\ninstall:\n stage: install\n script:\n - npm install\n - npm run build\n artifacts:\n untracked: true\n only:\n - stage\n - master\n\ntest:\n stage: test\n dependencies:\n - install\n script:\n - npm run test\n artifacts:\n untracked: true\n only:\n - stage\n - master\n\ndeployDev:\n stage: deploy\n only:\n - stage\n dependencies:\n - install\n - test\n script:\n - pip3 install awscli\n - aws configure set aws_access_key_id \"$DEV_AWS_KEY\"\n - aws configure set aws_secret_access_key \"$DEV_AWS_SECRET\"\n - aws s3 sync ./build/ s3://example.dev\n variables:\n REACT_APP_COGNITO_REGION: $DEV_COGNITO_REGION\n REACT_APP_COGNITO_USER_POOL_ID: $DEV_COGNITO_USER_POOL_ID\n REACT_APP_COGNITO_APP_CLIENT_ID: $DEV_COGNITO_APP_CLIENT_ID\n REACT_APP_COGNITO_IDENTITY_POOL_ID: $DEV_COGNITO_IDENTITY_POOL_ID\n REACT_APP_APPSYNC_URL: $DEV_APPSYNC_URL\n REACT_APP_APPSYNC_REGION: $DEV_APPSYNC_REGION\n REACT_APP_APPSYNC_AUTHENTIACTION_TYPE: $DEV_APPSYNC_AUTHENTIACTION_TYPE\ndeployProd:\n stage: deploy\n only:\n - master\n dependencies:\n - install\n - test\n script:\n - pip3 install awscli\n - aws configure set aws_access_key_id \"$PROD_AWS_KEY\"\n - aws configure set aws_secret_access_key \"$PROD_AWS_SECRET\"\n - aws s3 sync ./build/ s3://example.com\n\nCheers!" }, { "role": "assistant", "content": "This line from CRA docs is important: The environment variables are embedded during the build time. So set the variables before running build command. \nimage: node:10.16.0-alpine\n\nstages:\n - build\n - deploy\n\nbuild_app:\n stage: build\n script:\n - export REACT_APP_SECRET_API_KEY=$API_KEY # set REACT_APP variables before build command\n - yarn install\n - yarn build\n artifacts:\n name: \"$CI_PIPELINE_ID\"\n paths:\n - build\n when: on_success\n\ndeploy_app:\n stage: deploy\n dependencies:\n - build_app\n script:\n - echo \"Set deployment variables\"\n - echo \"Deployment scripts\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to sync gitlab with github\n\nI have several developers working on a local Gitlab instance. The client requires that their Github repo is kept updated. So our Gitlab repo should push any commits directly to Github. Any commits to Github should likewise be pulled into Gitlab. \nI could do the first part (dev --> gitlab --> github) with jenkins or something, but am stuck on the reverse. Our Gitlab and Jenkins run inside our firewall. \nAny hints or pointers (or drop in solutions!) would be very appreciated." }, { "role": "assistant", "content": "It's only in the enterprise edition and on GitLab.com, but GitLab has introduced this feature directly, without any workarounds.\nThey've documented pulling/pushing from/to a remote repository in GitLab Docs → User Docs → Projects → Repositories → Mirroring.\nIt's in the same section of configuration that you can push, too:\n\nFrom within a project use the gear icon to select Mirror Repository\nScroll down to Push to a remote repository\nCheckmark Remote mirror repository: Automatically update the remote mirror's branches, tags, and commits from this repository every hour.\nEnter the repository you want to update; for GitHub you can include your username and password in the URL, like so: https://yourgithubusername:[email protected]/agaric/guts_discuss_resource.git\n\nNote that I haven't tried it, but you should be able to push to and pull from the same repository. It's working great for me pulling from a remote repository (drupal.org), and pushing to a different remote repository (gitlab.com)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git not displaying unicode file names\nI'm using git 2.5.4 on Mac OS X. \nI have filenames containing é and git is displaying it with escapes. Is there a way to make it use unicode and show the character? The terminal can obviously handle it.\n> ls\nSél\n\n> git status\nUntracked files:\n(use \"git add <file>...\" to include in what will be committed)\n...\n\"S\\303\\251l\"\n\nI'd like that file to display as Sél, not S\\303\\251l." }, { "role": "assistant", "content": "Check first if git config core.quotePath false helps.\ngit config --global core.quotePath false\n\nThis is the documentation for core.quotePath:\n\ncore.quotePath\nCommands that output paths (e.g. ls-files, diff), will quote \"unusual\" characters in the pathname by enclosing the pathname in double-quotes and escaping those characters with backslashes in the same way C escapes control characters (e.g. \\t for TAB, \\n for LF, \\\\ for backslash) or bytes with values larger than 0x80 (e.g. octal \\302\\265 for \"micro\" in UTF-8). If this variable is set to false, bytes higher than 0x80 are not considered \"unusual\" any more. Double-quotes, backslash and control characters are always escaped regardless of the setting of this variable. A simple space character is not considered \"unusual\". Many commands can output pathnames completely verbatim using the -z option. The default value is true.\n\nIf not, as stated in \"Git and the Umlaut problem on Mac OS X\", try:\ngit config --global core.precomposeunicode true\n\nFrom git config man page:\n\ncore.precomposeUnicode\nThis option is only used by Mac OS implementation of Git. When core.precomposeUnicode=true, Git reverts the unicode decomposition of filenames done by Mac OS. This is useful when sharing a repository between Mac OS and Linux or Windows. (Git for Windows 1.7.10 or higher is needed, or Git under cygwin 1.7). When false, file names are handled fully transparent by Git, which is backward compatible with older versions of Git." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Discard Git Stash Pop\nI did a git stash pop and now I have a ton of conflicts. I had committed all my recent code before the git stash pop, so is there a way to go back to the last commit and get rid of all the conflicts and code the git stash pop injected?" }, { "role": "assistant", "content": "This has already been asked and answered on stackoverflow (see How to revert Git repository to a previous commit?), but the simple answer is:\ngit reset --hard HEAD\n\nThis should take care of your problem. Note that this removes all uncommitted changes from the repository.\nNote that if there are conflicts, the stash is preserved. From the stash docs:\n\nApplying the state can fail with conflicts; in this case, it is not\n removed from the stash list. You need to resolve the conflicts by hand\n and call git stash drop manually afterwards." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %GF" }, { "role": "assistant", "content": "show the fingerprint of the key used to sign a signed commit" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to attribute a single commit to multiple developers?\nThe way all version control systems I'm familiar with work is that each commit is attributed to a single developer. The rise of Agile Engineering, and specifically pair programming, has lead to a situation where two developers have made a significant contribution to the same task, a bug fix for example.\nThe issue of attribution won't be too much of a big deal in a work environment since the project manager will be aware of the work the pairs are doing, but what about if two open source contributors decide to pair up and push out some code to a particular project that has no idea they're working together. Is there any way for a version control system like Git to attribute a particular patch to multiple developers?" }, { "role": "assistant", "content": "Commit title\n\nCommit body\n\nCo-authored-by: name <[email protected]>\nCo-authored-by: name <[email protected]>\n\n\nSupported by GitHub and GitLab\nUsed by others: https://git.wiki.kernel.org/index.php/CommitMessageConventions\n\nOne problem with this approach is that you can't create a signed key for this group of devs, so you could essentially add anybody to this list even if they didn't work on a feature and GitHub would treat it as if they did. However, this shouldn't be an issue in most cases.\ne.g. Co-authored-by: Linus Torvalds <[email protected]>\nWith normal authors or signing groups (the old method) you would see it's not signed and know that you can't trust the commit. However, there is no signing process on co-authors.\n\nMostly outdated answer:\nOne solution would be to set a name for the pair:\ngit config user.name \"Chris Wilson and John Smith\"\n\nHere is a related bug report with other temporary solutions:\nBug git-core: Git should support multiple authors for a commit" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-update-index - Register file contents in the working tree to the index On an inefficient filesystem with core.ignorestat set" }, { "role": "assistant", "content": "$ git update-index --really-refresh (1) $ git update-index --no-assume-unchanged foo.c (2) $ git diff --name-only (3) $ edit foo.c\n$ git diff --name-only (4) M foo.c\n$ git update-index foo.c (5) $ git diff --name-only (6) $ edit foo.c\n$ git diff --name-only (7) $ git update-index --no-assume-unchanged foo.c (8) $ git diff --name-only (9) M foo.c forces lstat(2) to set \"assume unchanged\" bits for paths that match index. mark the path to be edited. this does lstat(2) and finds index matches the path. this does lstat(2) and finds index does not match the path. registering the new version to index sets \"assume unchanged\" bit. and it is assumed unchanged. even after you edit it. you can tell about the change after the fact. now it checks with lstat(2) and finds it has been changed." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I check in a Bash script if my local Git repository has changes?\nThere are some scripts that do not work correctly if they check for changes.\nI tried it like this:\nVN=$(git describe --abbrev=7 HEAD 2>/dev/null)\n\ngit update-index -q --refresh\nCHANGED=$(git diff-index --name-only HEAD --)\nif [ ! -z $CHANGED ];\n then VN=\"$VN-mod\"\nfi\n\nIs there some kind of boolean check if there has been changes since the last commit, or how can I really test if there are new changes to my local repository?\nI'm doing all this for a version creation script (that I found somewhere here)." }, { "role": "assistant", "content": "Using git status:\ncd /git/directory\nif [[ `git status --porcelain` ]]; then\n # Changes\nelse\n # No changes\nfi" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Updating the current branch from parent branch\nI created a new git branch B from branch A with tracking option.\nNow, when A branch gets updated by few commits, I want to pull the commits to B as well, so I can keep track of it, and do not have to face big change sometimes later.\nHow should I approach this? Is it automatically done in git?" }, { "role": "assistant", "content": "This is not made automatically. You have to manually merge your changes from A to B, which is pretty simple. Just switch to branch B and do\ngit merge A\n\nWhich will automatically merge your changes from A to B. As long as you don't have any conflicts, all of the changes in A will be marked as merged in B. A common best practices is to make daily merges, but that is dependent on the number of users/commits using your branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to integrate a GitHub wiki into the main project\nI want keep all my source code and documentation in one single Git repository. I already have the GitHub pages integrated into my main project and now I want to do the same with the GitHub wiki.\nI know that GitHub wikis are plain Git repositories. My plan is to add the wiki as a remote to my main repository and keep everything in one place. However in the wiki repository everything is in the root directory and thus would clutter my main project.\nWhat is the best way to handle this?" }, { "role": "assistant", "content": "You want to add the wiki as a submodule. The same Wiki Git repository connected as a remote, but within a subdirectory with its own .git directory.\ngit submodule add git://github.com/you/proj.wiki\n\nIn the root of your main repository to add the wiki repository as a submodule in the wiki/ directory." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to deal with IntelliJ IDEA project files under Git source control constantly changing?\nEveryone on our team uses IntelliJ IDEA, and we find it useful to put its project files (.ipr and .iml) into source control so that we can share build configurations, settings, and inspections. Plus, we can then use those inspection settings on our continuous integration server with TeamCity. (We have the per-user workspace .iws file in the .gitignore file and not in source control.)\nHowever, those files change in little ways when you do just about anything in IDEA. There's an issue in IDEA's issue database for it (IDEA-64312), so perhaps one might consider this a bug in IDEA, but it's one we'll need to live with for the foreseeable future.\nUp until recently, we were using Subversion, but we recently switched to Git. We had each just gotten used to having a change list of project files that we ignored and didn't check in unless there were project file changes that we wanted to share with others. But with Git, the real power seems to be (from what we're exploring) the continuous branching that it encourages, and switching between branches is a pain with the project files always having been modified. Often it can just merge in the changes somehow, and tries to deal with the project file changes now being applied to the new branch. However, if the new branch has changed project files (such as the branch is working on a new module that isn't in the other branches yet), git just throws an error that it doesn't make any sense to merge in the files when both the branch has changes and you have changes locally, and I can rather understand its point. From the command line, one can use \"-f\" on the \"git checkout\" command to force it to throw out the local changes and use the branch's instead, but (1) the Git Checkout GUI command in IDEA (10.5.1) doesn't seem to have that as an option that we can find, so we'd need to switch to the command line on a regular basis, and (2) We're not sure we want to be in the habit of using that flag and telling Git to throw out our local changes.\nSo, here are some thoughts we have on options we have to deal with this:\n\nTake the project files out of source control entirely. Put them in the .gitignore, and distribute them to each person and TeamCity via some other means, maybe by putting them in source control somewhere else or under other names. Our team's small enough this option is feasible enough to consider, but it doesn't seem great.\nContinue living with it, trying to be sure to manage which files we have on which branches at a given time. As part of this, we might encourage each developer to have more than one copy of each project on their system, so they can have each checked out to a different branch with possibly different sets of project files.\nTry having just the project (.ipr) in source control, with the module (.iml) files not in source control and in the .gitignore file. The main thing that seems to switch around on its own in the .ipr on a regular basis is the order of the shared build configurations, but maybe we can just share the information separately on how to set those up. I'm not quite sure how IDEA deals with this kind of thing of only having some of its files though, especially on a new checkout.\n\nI guess I'm hoping there's some obvious (or non-obvious) solution we've missed, perhaps dealing with the huge customizability that Git and IDEA both seem to have. But it seems like we couldn't possibly be the only team having this problem. Questions that are kind of similar on Stack Overflow include 3495191, 1000512, and 3873872, but I don't know as they're exactly the same issue, and maybe someone can come up with the pros and cons for the various approaches I've outlined, approaches listed in the answers to those questions, or approaches that they recommend." }, { "role": "assistant", "content": "You can use IDEA's directory-based project structure, where the settings are stored in .idea directory instead of .ipr file. It gives more fine-grained control over what is stored in version control. The .iml files will still be around, so it doesn't solve the random changes in them (maybe keep them out of source control?), but sharing things such as code style and inspection profiles is easy, since each of them will be in its own file under the .idea directory." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is it possible to fork a public GitHub repo into an enterprise repository?\n\nThere exist a public repo for Quick framework here. I'd like to be able to fork this into a private enterprise GitHub repository. Forking would allow all the branches to remain. \nthe alternative would be to clone the repo and push up only a single branch to the enterprise but then I lose on not having all the branches from the source/original. \nupdate:\nI ended up pushing all my branches into the enterprise git. \nif you just do a git push yourRemoteName myNewBranch then it will push the code into that branch on the enterprise git while creating that branch in enterprise GitHub." }, { "role": "assistant", "content": "It's not possible, because your GitHub Enterprise (GHE) installation is separate from the public one, so there's no way for the two systems to track each other's branch relationships.\nThe best you can do is exactly as you describe: Clone the repo, then push it to your GHE installation, and yes, you will then lose the branching relationships across repos.\nThe other option would be to keep a fork on the public GitHub (GH) repo--possibly keeping it in sync (manually, or with a cronjob) with your GHE repo. Then you'll have two instances of your repo, and the public one would retain branch relationships with the original repo.\nDepending on why you need to put this on GHE, it may or may not work. If you're making private contributions, it clearly won't work--as your private contributions would no longer be private. If you want it on GHE due to some corporate policy that all open source projects used internally are kept on the GHE, or something similar, then it would work, with the added administrative overhead of keeping the repo in sync two places." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_PROTOCOL_FROM_USER" }, { "role": "assistant", "content": "Set this Boolean environment variable to false to prevent protocols used by fetch/push/clone which are\nconfigured to the user state. This is useful to restrict recursive\nsubmodule initialization from an untrusted repository or for programs\nwhich feed potentially-untrusted URLS to git commands. See git-config for more details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_ATTR_SOURCE" }, { "role": "assistant", "content": "Sets the treeish that gitattributes will be read from." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git update submodules recursively\nMy project struture\nProjectA\n-FrameworkA (submodule)\n--Twig (submodule of FrameworkA)\n\nHow I can update submodules recursively? I already tried some git commands (on ProjectA root)\ngit submodule foreach git pull origin master\n\nor\ngit submodule foreach --recursive git pull origin master\n\nbut cannot pull files of Twig." }, { "role": "assistant", "content": "git submodule update --recursive\n\nYou will also probably want to use the --init option which will make it initialize any uninitialized submodules:\ngit submodule update --init --recursive\n\nNote: in some older versions of Git, if you use the --init option, already-initialized submodules may not be updated. In that case, you should also run the command without --init option." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs 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": "gitlab signup users without email confirmation\n\nI want to setup a gitlab instance for internal use. Since the instance can only be reached over a local network I haven't setup the email setup. Unfortunately gitlab still wants to sent new users confirmation emails with a temporary password, but they never receive this email.\nIs there a way to configure gitlab so that it doesn't send these confirmation mails? I already tried to set email_enabled: false in gitlab.yml but it didn't work.\nUpdate:\nIt should work without me having to interfere manually in the signup process." }, { "role": "assistant", "content": "Admin can confirm user manually!\n\nLogin gitlab with admin account and create a new user (Mini), ignore password.\nAdmin area ---> users ---> edit Mini user ---> set password.\nUser Mini can login gitlab." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "In GitLab CI, is there a variable for a Merge Request's target branch?\n\nIn my pipeline, I'd like to have a job run only if the Merge Requests target branch is a certain branch, say master or release. \nIs this possible?\nI've read through https://docs.gitlab.com/ee/ci/variables/ and unless I missed something, I'm not seeing anything that can help." }, { "role": "assistant", "content": "Update: 2019-03-21\nGitLab has variables for merge request info since version 11.6 (https://docs.gitlab.com/ce/ci/variables/ see the variables start with CI_MERGE_REQUEST_). But, these variables are only available in merge request pipelines.(https://docs.gitlab.com/ce/ci/merge_request_pipelines/index.html)\nTo configure a CI job for merge requests, we have to set:\nonly: \n - merge_requests\n\nAnd then we can use CI_MERGE_REQUEST_* variables in those jobs.\nThe biggest pitfall here is only: merge_request has complete different behavior from normal only/except parameters.\nusual only/except parameters:\n(https://docs.gitlab.com/ce/ci/yaml/README.html#onlyexcept-basic)\n\n\nonly defines the names of branches and tags for which the job will run.\nexcept defines the names of branches and tags for which the job will not run.\n\n\nonly: merge_request: (https://docs.gitlab.com/ce/ci/merge_request_pipelines/index.html#excluding-certain-jobs)\n\nThe behavior of the only: merge_requests parameter is such that only jobs with that parameter are run in the context of a merge request; no other jobs will be run.\n\nI felt hard to reorganize jobs to make them work like before with only: merge_request exists on any job. Thus I'm still using the one-liner in my original answer to get MR info in a CI job.\n\nOriginal answer:\nNo.\nBut GitLab have a plan for this feature in 2019 Q2: https://gitlab.com/gitlab-org/gitlab-ce/issues/23902#final-assumptions\nCurrently, we can use a workaround to achieve this. The method is as Rekovni's answer described, and it actually works.\nThere's a simple one-liner, get the target branch of an MR from the current branch:\nscript: # in any script section of gitlab-ci.yml\n - 'CI_TARGET_BRANCH_NAME=$(curl -LsS -H \"PRIVATE-TOKEN: $AWESOME_GITLAB_API_TOKEN\" \"https://my.gitlab-instance.com/api/v4/projects/$CI_PROJECT_ID/merge_requests?source_branch=$CI_COMMIT_REF_NAME\" | jq --raw-output \".[0].target_branch\")'\n\nExplanation:\nCI_TARGET_BRANCH_NAME is a newly defined variable which stores resolved target branch name. Defining a variable is not necessary for various usage.\nAWESOME_GITLAB_API_TOKEN is the variable configured in repository's CI/CD variable config. It is a GitLab personal access token(created in User Settings) with api scope.\nAbout curl options: -L makes curl aware of HTTP redirections. -sS makes curl silent(-s) but show(-S) errors. -H specifies authority info accessing GitLab API.\nThe used API could be founded in https://docs.gitlab.com/ce/api/merge_requests.html#list-project-merge-requests. We use the source_branch attribute to figure out which MR current pipeline is running on. Thus, if a source branch has multiple MR to different target branch, you may want to change the part after | and do your own logic.\nAbout jq(https://stedolan.github.io/jq/), it's a simple CLI util to deal with JSON stuff(what GitLab API returns). You could use node -p or any method you want." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Resolve \"CONFLICT (delete/modify)\" in git\nIn one branch in one branch A a file is changed and the change commited. Now in another branch B the very same file is edited and renamed.\nWhen merging B into A git recognises the conflict properly (CONFLICT (delete/modify)) and both files are in the working directory.\nIf I know want to have both changes in one file, how do I do this best?\nThere is git merge-file that is - if I'm right - expecting both files and a common ancestor. But how to give latter? How can I say \"use $path from $commit\" or something like that?\nExample:\nmkdir git-rename-repo\ncd git-rename-repo\ngit init\n\necho \"First line\" > afile\n\ngit add .\ngit commit -m \"First commit in master\"\ngit checkout -b mybranch\n\necho \"Second line in mybranch\" >> afile\ngit mv afile bfile\n\ngit commit -a -m \"change and rename in mybranch\"\ngit checkout master\n\necho \"Changed first line in master\" > afile\n\ngit commit -a -m \"changed afile\"\ngit merge mybranch\n\nI now want a file named 'bfile' with both changes:\n\nChanged first line in master\nSecond line in mybranch\n\nThanks" }, { "role": "assistant", "content": "I also had the scenario\n\n**CONFLICT (modify/delete):***FileName deleted in HEAD and modified in 6efb2a94ba0601aa1ec5050ab222a0359ee8379a. Version 6efb2a94ba0601aa1ec5050ab222a0359ee8379a of FileName left in tree.*\n\nI was also equally confused and reached this post.\nBut on typing git status, all doubts are vanished. git status, stated the following about the conflicted files:\n\nUnmerged paths:\n (use \"git add/rm ...\" as appropriate to mark resolution)\n\nSo I just did git rm FileName, and after that the CONFLICT got resolved." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git remote prune – didn't show as many pruned branches as I expected\nFrom the man page:\n\nDeletes all stale tracking branches under <name>.\nThese stale branches have already been removed from the remote repository\nreferenced by <name>, but are still locally available in \"remotes/<name>\".\n\n\nSo I removed a bunch of branches using\ngit push origin :staleStuff\n\nand then ran\ngit remote prune origin\n\nHowever, only one single local branch was pruned. Some of these branches were created by me, some by co-workers. Does this indicate that I wasn't tracking those branches correctly in the first place?" }, { "role": "assistant", "content": "When you use git push origin :staleStuff, it automatically removes origin/staleStuff, so when you ran git remote prune origin, you have pruned some branch that was removed by someone else. It's more likely that your co-workers now need to run git prune to get rid of branches you have removed.\n\nSo what exactly git remote prune does? Main idea: local branches (not tracking branches) are not touched by git remote prune command and should be removed manually.\nNow, a real-world example for better understanding:\nYou have a remote repository with 2 branches: master and feature. Let's assume that you are working on both branches, so as a result you have these references in your local repository (full reference names are given to avoid any confusion):\n\nrefs/heads/master (short name master)\nrefs/heads/feature (short name feature)\nrefs/remotes/origin/master (short name origin/master)\nrefs/remotes/origin/feature (short name origin/feature)\n\nNow, a typical scenario:\n\nSome other developer finishes all work on the feature, merges it into master and removes feature branch from remote repository.\nBy default, when you do git fetch (or git pull), no references are removed from your local repository, so you still have all those 4 references.\nYou decide to clean them up, and run git remote prune origin.\ngit detects that feature branch no longer exists, so refs/remotes/origin/feature is a stale branch which should be removed. \nNow you have 3 references, including refs/heads/feature, because git remote prune does not remove any refs/heads/* references.\n\nIt is possible to identify local branches, associated with remote tracking branches, by branch.<branch_name>.merge configuration parameter. This parameter is not really required for anything to work (probably except git pull), so it might be missing.\n(updated with example & useful info from comments)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Add images to README.md on BitBucket\nCan I somehow reference the image from readme.md file so that it renders when viewed in BitBucket directly from project (without hosting the image elsewhere on web) ?\nUPDATE:\nThe issue was resolved so it's working now as it was explained in the question:\nI have stored readme.md file and an image file in a BitBucket repo as follows:\n\nreadme.md\nimages/\n\n\nscheme.jpg\n\n\nI reference the image from readme.md as follows:\n![Scheme](images/scheme.jpg)" }, { "role": "assistant", "content": "Update 2016-12-14\nThis is fixed now, please see the resolved status of this issue: https://bitbucket.org/site/master/issues/6315/relative-urls-in-readmemd-files-only-work\nYou can now use \n![Scheme](images/scheme.jpg)\n\nto refer to images in your repo using relative links.\nOld Answer\nAt the moment, this is not possible. BitBucket does not support relative links to images in markdown.\nThe following issue in BitBucket's issue tracker has more info on this, its current status (2015-02-27) is open: https://bitbucket.org/site/master/issue/6315/relative-urls-in-readmemd-files-only-work\nThe BitBucket team have indicated on the ticket that they intend to fix this \"in the coming quarters\" (comment from 2014-12-19: https://bitbucket.org/site/master/issue/6315/relative-urls-in-readmemd-files-only-work#comment-14400835).\nThe ticket contains a couple of (ugly) workarounds, using a combination of two links, where one works locally, and one on the web site (https://bitbucket.org/site/master/issue/6315/relative-urls-in-readmemd-files-only-work#comment-15852315) as well as some other possible solutions, none of which are particularly nice or reliable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-check-mailmap" }, { "role": "assistant", "content": "Show canonical names and email addresses of contacts" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitsubmodules - Mounting one repository inside another" }, { "role": "assistant", "content": "Implementation details When cloning or pulling a repository containing submodules the submodules\nwill not be checked out by default; you can instruct clone to recurse\ninto submodules. The init and update subcommands of git submodule will maintain submodules checked out and at an appropriate revision in\nyour working tree. Alternatively you can set submodule.recurse to have checkout recurse into submodules (note that submodule.recurse also\naffects other Git commands, see git-config for a complete list)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -l<num>" }, { "role": "assistant", "content": "The -M and -C options involve some preliminary steps that\ncan detect subsets of renames/copies cheaply, followed by an\nexhaustive fallback portion that compares all remaining\nunpaired destinations to all relevant sources. (For renames,\nonly remaining unpaired sources are relevant; for copies, all\noriginal sources are relevant.) For N sources and\ndestinations, this exhaustive check is O(N^2). This option\nprevents the exhaustive portion of rename/copy detection from\nrunning if the number of source/destination files involved\nexceeds the specified number. Defaults to diff.renameLimit.\nNote that a value of 0 is treated as unlimited." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order %><( <N> ) , %><|( <M> )" }, { "role": "assistant", "content": "similar to %<( <N> ) , %<|( <M> ) respectively, but padding both sides\n(i.e. the text is centered)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "ignoring changes matching a string in git diff\nI've made a single simple change to a large number of files that are version controlled in git and I'd like to be able to check that no other changes are slipping into this large commit.\nThe changes are all of the form\n- \"main()\",\n+ OOMPH_CURRENT_FUNCTION,\n\nwhere \"main()\" could be the name of any function. I want to generate a diff of all changes that are not of this form.\nThe -G and -S options to git diff are tantalisingly close--they find changes that DO match a string or regexp.\nIs there a good way to do this?\nAttempts so far\nAnother question describes how regexs can be negated, using this approach I think the command should be\ngit diff -G '^((?!OOMPH_CURRENT_FUNCTION).)*$'\n\nbut this just returns the error message\nfatal: invalid log-grep regex: Invalid preceding regular expression\n\nso I guess git doesn't support this regex feature.\nI also noticed that the standard unix diff has the -I option to \"ignore changes whose lines all match RE\". But I can't find the correct way to replace git's own diff with the unix diff tool." }, { "role": "assistant", "content": "No more grep needed!\nWith Git 2.30 (Q1 2021), \"git diff\"(man) family of commands learned the \"-I<regex>\" option to ignore hunks whose changed lines all match the given pattern.\nSee commit 296d4a9, commit ec7967c (20 Oct 2020) by Michał Kępień (kempniu).\n(Merged by Junio C Hamano -- gitster -- in commit 1ae0949, 02 Nov 2020)\n\ndiff: add -I<regex> that ignores matching changes\nSigned-off-by: Michał Kępień\n\n\nAdd a new diff option that enables ignoring changes whose all lines (changed, removed, and added) match a given regular expression.\nThis is similar to the -I/--ignore-matching-lines option in standalone diff utilities and can be used e.g. to ignore changes which only affect code comments or to look for unrelated changes in commits containing a large number of automatically applied modifications (e.g. a tree-wide string replacement).\nThe difference between -G/-S and the new -I option is that the latter filters output on a per-change basis.\nUse the 'ignore' field of xdchange_t for marking a change as ignored or not.\nSince the same field is used by --ignore-blank-lines, identical hunk emitting rules apply for --ignore-blank-lines and -I.\nThese two options can also be used together in the same git invocation (they are complementary to each other).\nRename xdl_mark_ignorable() to xdl_mark_ignorable_lines(), to indicate that it is logically a \"sibling\" of xdl_mark_ignorable_regex() rather than its \"parent\".\n\ndiff-options now includes in its man page:\n\n-I<regex>\n--ignore-matching-lines=<regex>\nIgnore changes whose all lines match <regex>.\nThis option may be specified more than once.\n\nExamples:\ngit diff --ignore-blank-lines -I\"ten.*e\" -I\"^[124-9]\"\n\n\nA small memleak in \"diff -I<regexp>\" has been corrected with Git 2.31 (Q1 2021).\nSee commit c45dc9c, commit e900d49 (11 Feb 2021) by Ævar Arnfjörð Bjarmason (avar).\n(Merged by Junio C Hamano -- gitster -- in commit 45df6c4, 22 Feb 2021)\n\ndiff: plug memory leak from regcomp() on {log,diff} -I\nSigned-off-by: Ævar Arnfjörð Bjarmason\n\n\nFix a memory leak in 296d4a9 (\"diff: add -I that ignores matching changes\", 2020-10-20, Git v2.30.0-rc0 -- merge listed in batch #3) by freeing the memory it allocates in the newly introduced diff_free().\nThis memory leak was intentionally introduced in 296d4a9, see the discussion on a previous iteration of it.\nAt that time freeing the memory was somewhat tedious, but since it isn't anymore with the newly introduced diff_free() let's use it.\nLet's retain the pattern for diff_free_file() and add a diff_free_ignore_regex(), even though (unlike \"diff_free_file\") we don't need to call it elsewhere.\nI think this will make for more readable code than gradually accumulating a giant diff_free() function, sharing \"int i\" across unrelated code etc." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What are the file limits in Git (number and size)?\nDoes anyone know what are the Git limits for number of files and size of files?" }, { "role": "assistant", "content": "This message from Linus himself can help you with some other limits\n\n[...] CVS, ie it really ends up being pretty much oriented to a \"one file\n at a time\" model.\nWhich is nice in that you can have a million files, and then only check\n out a few of them - you'll never even see the impact of the other\n 999,995 files.\nGit\n fundamentally never really looks at less than the whole repo. Even if you\n limit things a bit (ie check out just a portion, or have the history go\n back just a bit), git ends up still always caring about the whole thing,\n and carrying the knowledge around.\nSo git scales really badly if you force it to look at everything as one\n huge repository. I don't think that part is really fixable, although we\n can probably improve on it.\nAnd yes, then there's the \"big file\" issues. I really don't know what to\n do about huge files. We suck at them, I know. \n\nSee more in my other answer: the limit with Git is that each repository must represent a \"coherent set of files\", the \"all system\" in itself (you can not tag \"part of a repository\").\nIf your system is made of autonomous (but inter-dependent) parts, you must use submodules.\nAs illustrated by Talljoe's answer, the limit can be a system one (large number of files), but if you do understand the nature of Git (about data coherency represented by its SHA-1 keys), you will realize the true \"limit\" is a usage one: i.e, you should not try to store everything in a Git repository, unless you are prepared to always get or tag everything back. For some large projects, it would make no sense.\n\nFor a more in-depth look at git limits, see \"git with large files\"\n(which mentions git-lfs: a solution to store large files outside the git repo. GitHub, April 2015)\nThe three issues that limits a git repo:\n\nhuge files (the xdelta for packfile is in memory only, which isn't good with large files)\nhuge number of files, which means, one file per blob, and slow git gc to generate one packfile at a time.\nhuge packfiles, with a packfile index inefficient to retrieve data from the (huge) packfile.\n\n\nA more recent thread (Feb. 2015) illustrates the limiting factors for a Git repo:\n\n\nWill a few simultaneous clones from the central server also slow down other concurrent operations for other users?\n\nThere are no locks in server when cloning, so in theory cloning does not affect other operations. Cloning can use lots of memory though (and a lot of cpu unless you turn on reachability bitmap feature, which you should).\n\nWill 'git pull' be slow?\n\nIf we exclude the server side, the size of your tree is the main factor, but your 25k files should be fine (linux has 48k files).\n\n'git push'?\n\nThis one is not affected by how deep your repo's history is, or how wide your tree is, so should be quick..\nAh the number of refs may affect both git-push and git-pull.\n I think Stefan knows better than I in this area.\n\n'git commit'? (It is listed as slow in reference 3.)\n 'git status'? (Slow again in reference 3 though I don't see it.)\n (also git-add)\n\nAgain, the size of your tree. At your repo's size, I don't think you need to worry about it.\n\nSome operations might not seem to be day-to-day but if they are called frequently by the web front-end to GitLab/Stash/GitHub etc then they can become bottlenecks. (e.g. 'git branch --contains' seems terribly adversely affected by large numbers of branches.)\n\ngit-blame could be slow when a file is modified a lot." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.ignoreSubmodules" }, { "role": "assistant", "content": "Sets the default value of --ignore-submodules. Note that this\naffects only git diff Porcelain, and not lower level diff commands such as git diff-files . git checkout and git switch also honor\nthis setting when reporting uncommitted changes. Setting it to all disables the submodule summary normally shown by git commit and git status when status.submoduleSummary is set unless it is\noverridden by using the --ignore-submodules command-line option.\nThe git submodule commands are not affected by this setting.\nBy default this is set to untracked so that any untracked\nsubmodules are ignored." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "pip install a local git repository\nI can't find the correct way to install a local directory as a python package using pip.\n(venv) C:\\(...)>pip install . --no-index\nIgnoring indexes: http://pypi.python.org/simple/\nUnpacking c:\\users\\fsantos\\desktop\\biskates.com\\biskates\\forks\\django-pipeline\n Running setup.py egg_info for package from file:///(...)%5Cforks%5Cdjango-pipeline\n\nInstalling collected packages: django-pipeline\n Running setup.py install for django-pipeline\n\nSuccessfully installed django-pipeline\nCleaning up...\n\n(venv) C:\\(...)>cd ..\n(venv) C:\\(...)>python\nPython 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> import pipeline\n>>> pipeline.__file__\n'C:\\\\(...)site-packages\\\\pipeline\\\\__init__.py'\n>>>\n\nAs you can see pip just copied over the package to site-packages. How can I avoid this, and use the package directly from its source folder?\nI'm trying to integrate django-pipeline into my Django project, but I want to add support for Django 1.4 first, so I forked and cloned my fork." }, { "role": "assistant", "content": "I can also just use:\ncd your-local-repo\npip install -e .\n\nor\npython setup.py install develop" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options diff.relative" }, { "role": "assistant", "content": "If set to true , git diff does not show changes outside of the directory\nand show pathnames relative to the current directory." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options fetch.showForcedUpdates" }, { "role": "assistant", "content": "Set to false to enable --no-show-forced-updates in git-fetch and git-pull commands.\nDefaults to true." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to modify a pull request on GitHub to change target branch to merge into?\n\nI have a pull request that is requesting a merge into master from my branch, but the owner wants me to change the request to merge into a different branch from my branch.\nIs this possible? What are the possible solutions?" }, { "role": "assistant", "content": "Update August 2016: Change the base branch of a Pull Request finally allows for changing that branch.\n(And this closes issue 18, which was 3 years old and had 1500+ comments)\n\nAfter you’ve created a pull request, you can modify the base branch so that the changes in the pull request are compared against a different branch.\n\n\nAs noted in the comments byspazm:\n\nIt is (and was) working.\nChanging target branch is not enabled while the PR is closed.\nSolution was to \"reopen\" the PR (meaning by using the option in the UI) and then change the target branch\n\n\nOriginal answer:\nSince a PR cannot be edited in term of branch (see below), the easiest way would be to:\n\ncreate a local new branch on top of your current branch\npush that new branch\nmake a new PR with the right destination.\nclose the previous PR\nreference the \"old\" pull request from the new one; eg. Supersedes #123 (as commented below by Rivera)\n\n\n(original answer, valid only when creating the PR)\nYou could try and chose another base branch, as in \"Changing the branch range and destination repository\" (Clicking on the Edit button at the top of a PR page)\n\n\nThe easiest way of thinking about the branch range is this:\n\nthe base branch is where you think changes should be applied,\nthe head branch is what you would like to be applied.\n\nChanging the base repository changes who is notified of the pull request.\nEveryone that can push to the base repository will receive an email notification and see the new pull request in their dashboard the next time they sign in.\n\nIf you select as a base branch the one that the original maintainer (the owner) wants, your PR should merge from your branch (unchanged) to the new base branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Quantifying the amount of change in a git diff?\nI use git for a slightly unusual purpose--it stores my text as I write fiction. (I know, I know...geeky.)\nI am trying to keep track of productivity, and want to measure the degree of difference between subsequent commits. The writer's proxy for \"work\" is \"words written\", at least during the creation stage. I can't use straight word count as it ignores editing and compression, both vital parts of writing. I think I want to track:\n (words added)+(words removed)\n\nwhich will double-count (words changed), but I'm okay with that.\nIt'd be great to type some magic incantation and have git report this distance metric for any two revisions. However, git diffs are patches, which show entire lines even if you've only twiddled one character on the line; I don't want that, especially since my 'lines' are paragraphs. Ideally I'd even be able to specify what I mean by \"word\" (though \\W+ would probably be acceptable).\nIs there a flag to git-diff to give diffs on a word-by-word basis? Alternately, is there a solution using standard command-line tools to compute the metric above?" }, { "role": "assistant", "content": "wdiff does word-by-word comparison. Git can be configured to use an external program to do the diffing. Based on those two facts and this blog post, the following should do roughly what you want.\nCreate a script to ignore most of the unnecessary arguments that git-diff provides and pass them to wdiff. Save the following as ~/wdiff.py or something similar and make it executable.\n#!/usr/bin/python\n\nimport sys\nimport os\n\nos.system('wdiff -s3 \"%s\" \"%s\"' % (sys.argv[2], sys.argv[5]))\n\nTell git to use it.\ngit config --global diff.external ~/wdiff.py\ngit diff filename" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What does “~ (END)” mean when displayed in a terminal?\nI'm running through the gitimmersion.com labs and every time I run a: git hist --all command it seems to break terminal and throw this:\n\n~\n ~\n ~\n ~\n (END)\n\nand I'm not able to type any more commands. So I end up closing that terminal window and starting over.\nAnyone know why this happens and how to resolve it?\nThanks!" }, { "role": "assistant", "content": "Git pipes long output into what's called a pager by default, which can make it easier to view the output if it doesn't fit on a screen. The ~ characters indicate that those lines were not in the original output, but it's showing them so that you can scroll down past the bottom (i.e. the last line of output can go up to the top of the screen).\nYou typically can use the arrow keys to scroll up or down, and can exit by pressing q.\n\nAlternatively, if you don't want the output in a pager, try this:\n$ git --no-pager hist --all" } ]