messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-send-email - Send a collection of patches as emails --smtp-server-port=<port>"
},
{
"role": "assistant",
"content": "Specifies a port different from the default port (SMTP\nservers typically listen to smtp port 25, but may also listen to\nsubmission port 587, or the common SSL smtp port 465);\nsymbolic port names (e.g. \"submission\" instead of 587)\nare also accepted. The port can also be set with the sendemail.smtpServerPort configuration variable."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "PS1 line with Git current branch and colors\nHere is my current PS1:\nexport PS1='[\\u@\\h \\W$(__git_ps1 \" (%s)\")]\\$ '\n\nHow can I display the current branch in a different color?"
},
{
"role": "assistant",
"content": "Here is, part by part (and no Ruby):\nfunction color_my_prompt {\n local __user_and_host=\"\\[\\033[01;32m\\]\\u@\\h\"\n local __cur_location=\"\\[\\033[01;34m\\]\\w\"\n local __git_branch_color=\"\\[\\033[31m\\]\"\n #local __git_branch=\"\\`ruby -e \\\"print (%x{git branch 2> /dev/null}.grep(/^\\*/).first || '').gsub(/^\\* (.+)$/, '(\\1) ')\\\"\\`\"\n local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\\\\\\*\\ \\(.+\\)$/\\(\\\\\\\\\\1\\)\\ /`'\n local __prompt_tail=\"\\[\\033[35m\\]$\"\n local __last_color=\"\\[\\033[00m\\]\"\n export PS1=\"$__user_and_host $__cur_location $__git_branch_color$__git_branch$__prompt_tail$__last_color \"\n}\ncolor_my_prompt\n\nLooks like this (with my own terminal palette):\n\nAlso, see this and this article."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-rev-list"
},
{
"role": "assistant",
"content": "Lists commit objects in reverse chronological order"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %ad"
},
{
"role": "assistant",
"content": "author date (format respects --date= option)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Diff tool in SourceTree\nI am using SourceTree as a Git client in my windows 7. I faced with a conflict and in order to resolve I click on Launch external merge tool as suggested. A window pops up very shortly and nothing happens then after!\nI just tried it on my Mac OS and it shows external merge tool as expected.\nunder Tools -> Options -> Diff -> External Diff / Merge dropdown box, System Default is selected.\nI expect to see the diff merge tool but it never shows up in my windows, anyone know what could be the reason?"
},
{
"role": "assistant",
"content": "Do you have a diff tool installed on your system? \nIn Mac, when you install Xcode you get a diff tool named FileMerge, simple but sufficient in most of the cases. You can try WinMerge for Windows, I've used it in the past and it's pretty nice, and open source.\nYou can also try the P4 Merge tool from Perforce which is offered for free.\nBoth options can be selected as a Diff/Merge Tool in SourceTree."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Tortoisegit undo last commit into the repo\n\nIs there an option in tortoisegit to undo the last commit into the repo?\nBy mistake I pushed a large number of unnecessary files into my git repository(branch:master) which I need to undo. I have searched a lot for the right option in tortoise git to undo the push and go back to the state before the last commit. Please show me a way to undo my last commit."
},
{
"role": "assistant",
"content": "If you haven't pushed your changes yet (so your commit is only local)\n\nTortoiseGit -> Show log\nSelect the commit to which you want to rollback to\nReset \"<branch>\" to this... (Note: The commit is not lost after the reset, the HEAD is just not pointing to it)\nTortoiseGit -> Show log\n\nIf you have, then this can still be done, but then you'd have to also do a force-push (check \"overwrite known changes\" 1).\n1 The \"overwrite known changes\" flag will replace the already pushed commit with a new one. If there is a chance that someone already fetched the commit that you're replacing, don't use this feature, otherwise doing so will create a fork in the history with two conflicting truths.\n\nThere is also a shortcut for when you want to just (1) redo the last commit and (2) you haven't pushed it yet:\n\nCommit -> Check \"Amend Last Commit\"\n\nThat will replace the last commit with a new one. But I don't recommend using this - if the last commit is already pushed, you can end up with a big mess. TortoiseGit will not stop you here.\nBy doing a Reset you are forced to have a look at the log, and there you see if the commit is local or not."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Using gitlab's nginx to serve another app\n\nHello I have installed Gitlab using this\nhttps://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#installation\nNow I want to use nginx to serve another content other than gitlab application\nhow can I do this \n\nWhere are the config files that I need to modify\nHow can I point a directory like /var/www so that nginx knows that is the root for another app.\n\nUpdate(forgot to mention I'm running this under Red Hat 6.5, Debian/Ubuntu solution welcome)"
},
{
"role": "assistant",
"content": "Here I am using \n- gitlab.example.com to serve gitlab.example.com over https.\n- example.com over http to serve another content other than gitlab application.\n\nGitlab installed from deb package is using chef to provision ngnix, so you have to modify chef recipies and add new vhost template into chef cookbooks directory\nYou can find all chef cookbooks here:\n/opt/gitlab/embedded/cookbooks/gitlab/\nopen \n/opt/gitlab/embedded/cookbooks/gitlab/recipes/nginx.rb\nchange:\nnginx_vars = node['gitlab']['nginx'].to_hash.merge({\n :gitlab_http_config => File.join(nginx_etc_dir, \"gitlab-http.conf\"),\n})\n\nto:\nnginx_vars = node['gitlab']['nginx'].to_hash.merge({\n :gitlab_http_config => File.join(nginx_etc_dir, \"gitlab-http.conf\"),\n :examplecom_http_config => File.join(nginx_etc_dir, \"examplecom-http.conf\"),\n})\n\nadd this to the same file:\ntemplate nginx_vars[:examplecom_http_config] do\n source \"nginx-examplecom-http.conf.erb\"\n owner \"root\"\n group \"root\"\n mode \"0644\"\n variables(nginx_vars.merge(\n {\n :fqdn => \"example.com\",\n :port => 80,\n }\n ))\n notifies :restart, 'service[nginx]' if OmnibusHelper.should_notify?(\"nginx\")\nend\n\nthen in template directory(/opt/gitlab/embedded/cookbooks/gitlab/templates/default), create nginx vhost template file( nginx-examplecom-http.conf.erb) and add this there:\nserver {\n listen <%= @listen_address %>:<%= @port %>;\n server_name <%= @fqdn %>;\n root /var/www/example.com;\n\n access_log <%= @log_directory %>/examplecom_access.log;\n error_log <%= @log_directory %>/examplecom_error.log;\n\n location /var/www/example.com {\n # serve static files from defined root folder;.\n # @gitlab is a named location for the upstream fallback, see below\n try_files $uri $uri/index.html $uri.html;\n }\n\n error_page 502 /502.html;\n}\n\nyou have to set nginx['redirect_http_to_https'] = false in(/etc/gitlab/gitlab.rb):\nexternal_url \"https://gitlab.example.com\"\ngitlab_rails['gitlab_email_from'] = \"[email protected]\"\ngitlab_rails['gitlab_support_email'] = \"[email protected]\"\n\n\n\nnginx['redirect_http_to_https'] = false\nnginx['ssl_certificate'] = \"/etc/gitlab/ssl/ssl-unified.crt\"\nnginx['ssl_certificate_key'] = \"/etc/gitlab/ssl/ssl.key\"\n\n\ngitlab_rails['gitlab_default_projects_limit'] = 10\n\nadd include <%= @examplecom_http_config %>; into /opt/gitlab/embedded/cookbooks/gitlab/templates/default/nginx.conf.erb :\nhttp {\n sendfile <%= @sendfile %>;\n tcp_nopush <%= @tcp_nopush %>;\n tcp_nodelay <%= @tcp_nodelay %>;\n\n keepalive_timeout <%= @keepalive_timeout %>;\n\n gzip <%= @gzip %>;\n gzip_http_version <%= @gzip_http_version %>;\n gzip_comp_level <%= @gzip_comp_level %>;\n gzip_proxied <%= @gzip_proxied %>;\n gzip_types <%= @gzip_types.join(' ') %>;\n\n include /opt/gitlab/embedded/conf/mime.types;\n\n include <%= @gitlab_http_config %>;\n include <%= @examplecom_http_config %>;\n}\n\nafter all those changes run:\ngitlab-ctl reconfigure\ngitlab-ctl restart"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do you stash an untracked file?\nI have changes to a file, plus a new file, and would like to use git stash to put them away while I switch to another task. But git stash by itself stashes only the changes to the existing file; the new file remains in my working tree, cluttering up my future work. How do I stash this untracked file?"
},
{
"role": "assistant",
"content": "To stash your working directory including untracked files (especially those that are in the .gitignore) then you probably want to use this cmd:\ngit stash --include-untracked\n\nAlternatively, you can use the shorthand -u instead of --include-untracked, or simply git stash --all (see warning below for this one) which stashes all files, including untracked and ignored files. This behaviour changed in 2018, so make sure your git is up to date.\n\nWarning: there seems to be (or have been) situations in which contents of ignored directories could be deleted permanently. See this archived website for more information."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Use token to push some code to GitHub - \"Support for password authentication was removed\" [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\n\nMessage \"Support for password authentication was removed.\"\n\n (51 answers)\n \n\nClosed 2 years ago.\n\n\n\nError message when using git push:\n\nSupport for password authentication was removed on August 13, 2021. Please use a personal access token instead.\nremote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.\nfatal: unable to access 'https://github.com/codingTheWorld777/react-mini-projects.git/': The requested URL returned error: 403\"***\n\nI cannot use my token to access GitHub, so how can I push code to GitHub?"
},
{
"role": "assistant",
"content": "GitHub announced their intent to require the use of token-based authentication for all authenticated Git operations. They will no longer accept account passwords when authenticating Git operations on GitHub.com:\nGenerate token:\n\nGo to your GitHub account token settings\nGenerate a token\n\nOn Mac:\n\nGo to keychain Access\nPress the Login tab and all items\nClick GitHub key\nChange the password to the recent generated token\n\n\nOn Windows:\n\nGo to Control Panel → User Accounts → Credential Manager\n\nEdit the Generic Credential of GitHub\n\nPaste the token instead of the password"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options apply.whitespace"
},
{
"role": "assistant",
"content": "Tells git apply how to handle whitespace, in the same way\nas the --whitespace option. See git-apply ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-mergetool - Run merge conflict resolution tools to resolve merge conflicts -O<orderfile>"
},
{
"role": "assistant",
"content": "Process files in the order specified in the\n<orderfile>, which has one shell glob pattern per line.\nThis overrides the diff.orderFile configuration variable\n(see git-config ). To cancel diff.orderFile ,\nuse -O/dev/null ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Commit Without Setting User Name and Email\nI try to commit like this:\ngit commit --author='Paul Draper <[email protected]>' -m 'My commit message'\n\nbut I get:\n*** Please tell me who you are.\n\nRun\n\ngit config --global user.email \"[email protected]\"\ngit config --global user.name \"Your Name\"\n\nto set your account's default identity.\nOmit --global to set the identity only in this repository.\n\nI can set these, but I am on a shared box, and I would have to (want to) unset them afterwards:\ngit config user.name 'Paul Draper'\ngit config user.email '[email protected]'\ngit commit -m 'My commit message'\ngit config --unset user.name\ngit config --unset user.email\n\nThat's a lot of lines for one commit!\nIs there shorter way?"
},
{
"role": "assistant",
"content": "(This occurred to me after suggesting the long version with the environment variables—git commit wants to set both an author and a committer, and --author only overrides the former.)\nAll git commands take -c arguments before the action verb to set temporary configuration data, so that's the perfect place for this:\ngit -c user.name='Paul Draper' -c user.email='[email protected]' commit -m '...'\n\nSo in this case -c is part of the git command, not the commit subcommand."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is there a way to remove all ignored files from a local git working tree?\nYesterday I spent several hours debugging a problem with my git repo that wasn't fixed by git reset HEAD --hard because the files causing the problem were ignored by .gitignore. Is there a way to \"flush\" or \"clean\" a git repo of all files that are being ignored, so that only the files tracked by git are present?\nI finally fixed my problem by deleting the repo and cloning it from github again, but in the future, I would like to immediately remove all potentially problematic files (those that are being ignored)."
},
{
"role": "assistant",
"content": "git clean -dfX\n\ngit-clean - Remove untracked files from the working tree\n-d Remove directories\n-f Remove forcefully\n-n Don’t actually remove anything, just show what would be done.\n-X Remove only files ignored by Git. This may be useful to rebuild everything from scratch, but keep manually created files.\nIf the ignored files are already added to the index/staging, you must remove the files from the tracking index before using the above clean command.\ngit rm -rf --cached .\nThen add the files except the ones included in the .gitignore file\n git add . and create a commit with git commit -m \"message\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc git diff [<options>] [--merge-base] <commit> [--] [<path>…]"
},
{
"role": "assistant",
"content": "This form is to view the changes you have in your\nworking tree relative to the named <commit>. You can\nuse HEAD to compare it with the latest commit, or a\nbranch name to compare with the tip of a different\nbranch. If --merge-base is given, instead of using <commit>, use the merge base\nof <commit> and HEAD. git diff --merge-base A is equivalent to git diff $(git merge-base A HEAD) ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Make the current Git branch a master branch\nI have a repository in Git. I made a branch, then did some changes both to the master and to the branch.\nThen, tens of commits later, I realized the branch is in much better state than the master, so I want the branch to \"become\" the master and disregard the changes on master.\nI cannot merge it, because I don't want to keep the changes on master. What should I do?\nExtra: In this case, the 'old' master has already been push-ed to another repository such as GitHub. How does this change things?"
},
{
"role": "assistant",
"content": "The problem with the other two answers is that the new master doesn't have the old master as an ancestor, so when you push it, everyone else will get messed up. This is what you want to do:\ngit checkout better_branch # This is the branch whose commits you want to keep\ngit merge --strategy=ours master # keep the content of this branch, but record a merge\ngit checkout master # You want to **lose** all changes on this branch\ngit merge better_branch # fast-forward master up to the merge\n\nIn older versions of git, if you want your history to be a little clearer, I'd recommend adding some information to the merge commit message to make it clear what you've done. Change the second line to:\ngit merge --strategy=ours --no-commit master\ngit commit # add information to the template merge message\n\nIn newer versions of git, git will automatically open the git message editor for you. (Or you can use git mere --strategy=ours master -m \"Keeping better_branch\")"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-restore - Restore working tree files --pathspec-from-file=<file>"
},
{
"role": "assistant",
"content": "Pathspec is passed in <file> instead of commandline args. If <file> is exactly - then standard input is used. Pathspec\nelements are separated by LF or CR/LF. Pathspec elements can be\nquoted as explained for the configuration variable core.quotePath (see git-config ). See also --pathspec-file-nul and\nglobal --literal-pathspecs ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I synchronize two branches in the same Git repository?\nHere's a common workflow hurdle I encounter often:\nmaster is our \"stable\" branch\n$ git status\n# On branch master\nnothing to commit (working directory clean)\n\nCreate a module on a branch\n$ git checkout -b foo\n$ echo \"hello\" > world\n$ git add .\n$ git commit -m \"init commit for foo module\"\n$ git checkout master\n$ git merge foo\n\nDo work on master or other branches\nOver the next couple weeks, more code will be committed to master directly and by other branches. The foo branch will go untouched for this time period.\nResume work/make updates on the foo branch\n$ git checkout foo\n\nOh no! foo is massively out of date! I understand why, but I do need foo back in sync.\nThe question\nHow do I get the latest contents from the master branch?"
},
{
"role": "assistant",
"content": "If you don't need the branch around:\nIf you've merged foo back to master, \"git branch -d foo\" to kill the topic branch, and then \"checkout -b foo\" in the future when you need to hack on it again.\nIf you do need the branch around:\nYou can rebase your topic branch against the master branch:\ngit checkout foo\ngit rebase master\n\nOr:\ngit rebase master foo"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Forking a sub directory of a repository on GitHub and making it part of my own repo\n\nApologies, I am very new to Git and GitHub, I've read through a few things but I'm not sure if what I'm trying to do is entirely possible.\nBasically I want to fork the Confluence Skin used on XBMC and modify various elements located here:\nhttps://github.com/xbmc/xbmc/tree/master/addons/skin.confluence\nHowever I don't want to fork the entire XBMC repository, so a simple fork action won't do.\nHere are my general requirements:\n\nI would like to take the contents of the skin.confluence folder and put it into a repository on my own GitHub account\nI need to be able to keep it linked within the original XBMC repo to receive upstream commits, as my modifications will generally be theme based, rather than functionality.\n\nThanks to the response posted by tbekolay, I have been able to do a subtree split to take only the skin.confluence part of repo and essentially create a branch, however I am unsure on how to keep it linked with the original XBMC repo while being pushed to my own repo with my modifications."
},
{
"role": "assistant",
"content": "This is mostly possible with git, though it is not a typical use case, so there may be some rough edges as you do this (especially if you are new to git).\nThe tool that we'll use for this job is git subtree.\nSetting up a repository\nStart by cloning the whole XBMC repository.\ngit clone https://github.com/xbmc/xbmc.git\ncd xbmc\n\nWe start on the master branch by default. We want to make our own master branch, so let's rename master to upstream-master.\ngit branch -m upstream-master\n\nNow use git subtree split to only include the part that you want. We'll make the split off part a new branch called upstream-skin.\ngit subtree split --prefix=addons/skin.confluence -b upstream-skin\ngit checkout upstream-skin\n\nThis gives you a new upstream-skin branch that only contains the contents of addons/skin.confluence, and with a filtered history that contains only the commits that modified files in addons/skin.confluence.\nNow, let's set up our remotes. Since you cloned xbmc/xbmc.git, the origin remote will point there. Let's rename that to upstream.\ngit remote rename origin upstream\n\nMake a repository on Github to contain your modifications to addons/skin.confluence. As an example, I'll use tbekolay/xbmc-skin, but replace this with your own repo. Add this repo as a remote, and push your upstream-skin branch to it.\ngit remote add origin https://github.com/tbekolay/xbmc-skin.git\ngit fetch origin\ngit push -u origin upstream-skin\n\nFinally, we'll make a new branch called master that will contain your changes.\ngit checkout -b master\ngit push -u origin master\n\nYou now have a \"fork\" of the addons/skin.confluence subdirectory.\nMaking changes to your repositories\nWhen you're dealing with your own local and remote repositories, you can use normal git commands. Make sure to do this on the master branch (or some other branch, if you'd like) and not the upstream-skin branch, which should only ever contain commits from the upstream project.\ngit checkout master\necho \"My XBMC Skin\" > README\ngit add README\ngit commit -m \"Added README\"\ngit push\n\nReceiving upstream commits\nWhen you're dealing with the upstream repository, you will have to use a mix of git and git subtree commands. To get new filtered commits, we need to do it in three stages.\nIn the first stage, we'll update upstream-master to the current version of the XBMC repository.\ngit checkout upstream-master\ngit pull\n\nThis should pull down new commits, if there are any.\nNext, we will update upstream-skin with the new filtered version of the commits. Since git subtree ensures that commit hashes will be the same, this should be a clean process. Note that you want to run these commands while still on the upstream-master branch.\ngit subtree split --prefix=addons/skin.confluence \\\n --onto upstream-skin -b upstream-skin\n\nWith upstream-skin now updated, you can update your master branch as you see fit (either by merging or rebasing).\ngit checkout master\ngit rebase upstream-skin\n\n\nNote that the XBMC repository is gigantic, and the git subtree commands will take quite a bit of time to filter through all that history -- and since you're regenerating the split subtree each time you interact with the remote repository, it's quite an expensive operation. I'm not sure if this can be sped up.\nThis blog post goes into some more detail on the commands above. Also see the git-subtree docs for even more detail."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab CI runner not able to expose ports of nested Docker containers\n\nWhen using GitLab CI, as well as the gitlab-ci-multi-runner, I'm unable to get internally-started Docker containers to expose their ports to the \"host\", which is the Docker image in which the build is running.\nMy .gitlab-ci.yml file:\ntest:\n image: docker\n stage: test\n services:\n - docker:dind\n script:\n - APP_CONTAINER_ID=`docker run -d --privileged -p \"9143:9143\" appropriate/nc nc -l 9143`\n - netstat -a\n - docker exec $APP_CONTAINER_ID netstat -a\n - nc -v localhost 9143\n\nMy command:\ngitlab-ci-multi-runner exec docker --docker-privileged test\n\nThe output:\n$ netstat -a\nActive Internet connections (servers and established)\nProto Recv-Q Send-Q Local Address Foreign Address State\ntcp 0 0 runner--project-1-concurrent-0:54664 docker:2375 TIME_WAIT\ntcp 0 0 runner--project-1-concurrent-0:54666 docker:2375 TIME_WAIT\nActive UNIX domain sockets (servers and established)\nProto RefCnt Flags Type State I-Node Path\n\n$ docker exec $APP_CONTAINER_ID netstat -a\nActive Internet connections (servers and established)\nProto Recv-Q Send-Q Local Address Foreign Address State\ntcp 0 0 0.0.0.0:9143 0.0.0.0:* LISTEN\nActive UNIX domain sockets (servers and established)\nProto RefCnt Flags Type State I-Node Path\n\n$ nc -v localhost 9143\nERROR: Build failed: exit code 1\nFATAL: exit code 1\n\nWhat am I doing wrong here?\nOriginal Question Follows - above is a shorter, easier-to-test example\nI have an application image that listens on port 9143. Its startup and config is managed via docker-compose.yml, and works great on my local machine with docker-compose up - I can access localhost:9143 without issue.\nHowever, when running on GitLab CI (the gitlab.com version) via a shared runner, the port doesn't seem to be exposed.\nThe relevant portion of my .gitlab-ci.yml:\ntest:\n image: craigotis/buildtools:v1\n stage: test\n script:\n - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com/craigotis/myapp\n - docker-compose up -d\n - sleep 60 # a temporary hack to get the logs\n - docker-compose logs\n - docker-machine env\n - docker-compose port app 9143\n - netstat -a\n - docker-compose ps\n - /usr/local/bin/wait-for-it.sh -h localhost -p 9143 -t 60\n - cd mocha\n - npm i\n - npm test\n - docker-compose down\n\nThe output is:\n$ docker-compose logs\n...\napp_1 | [Thread-1] INFO spark.webserver.SparkServer - == Spark has ignited ...\napp_1 | [Thread-1] INFO spark.webserver.SparkServer - >> Listening on 0.0.0.0:9143\napp_1 | [Thread-1] INFO org.eclipse.jetty.server.Server - jetty-9.0.z-SNAPSHOT\napp_1 | [Thread-1] INFO org.eclipse.jetty.server.ServerConnector - Started ServerConnector@6919dc5{HTTP/1.1}{0.0.0.0:9143}\n...\n\n$ docker-compose port app 9143\n0.0.0.0:9143\n\n$ netstat -a\nActive Internet connections (servers and established)\nProto Recv-Q Send-Q Local Address Foreign Address State \ntcp 0 0 runner-e11ae361-project-1925166-concurrent-0:53646 docker:2375 TIME_WAIT \ntcp 0 0 runner-e11ae361-project-1925166-concurrent-0:53644 docker:2375 TIME_WAIT \ntcp 0 0 runner-e11ae361-project-1925166-concurrent-0:53642 docker:2375 TIME_WAIT \nActive UNIX domain sockets (servers and established)\nProto RefCnt Flags Type State I-Node Path\n\n$ docker-compose ps\nstty: standard input: Not a tty\n Name Command State Ports \n----------------------------------------------------------------------------------------\nmy_app_1 wait-for-it.sh mysql_serve ... Up 8080/tcp, 0.0.0.0:9143->9143/tcp \nmysql_server docker-entrypoint.sh --cha ... Up 3306/tcp \n\n$ /usr/local/bin/wait-for-it.sh -h localhost -p 9143 -t 60\nwait-for-it.sh: waiting 60 seconds for localhost:9143\nwait-for-it.sh: timeout occurred after waiting 60 seconds for localhost:9143\n\nThe contents of my docker-compose.yml:\nversion: '2'\n\nnetworks:\n app_net:\n driver: bridge\n\nservices:\n app:\n image: registry.gitlab.com/craigotis/myapp:latest\n depends_on:\n - \"db\"\n networks:\n - app_net\n command: wait-for-it.sh mysql_server:3306 -t 60 -- java -jar /opt/app*.jar\n ports:\n - \"9143:9143\"\n\n db:\n image: mysql:latest\n networks:\n - app_net\n container_name: mysql_server\n environment:\n - MYSQL_ALLOW_EMPTY_PASSWORD=true\n\nIt seems like my application container is listening on 9143, and it's properly exposed to the shared GitLab runner, but it doesn't seem to actually be exposed. It works fine on my local machine - is there some special workaround/tweak I need to make this work inside a Docker container running on GitLab?"
},
{
"role": "assistant",
"content": "When using docker:dind a container is created and your docker-compose containers get setup within it. It exposes the ports to localhost within the docker:dind container. You cannot access this as localhost from the environment that your code is executing in.\nA hostname of docker is setup for you to reference this docker:dind container. You can check by using cat /etc/hosts.\nInstead of referencing localhost:9143 you should use docker:9143."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I filter all GitHub pull requests for a specific target branch\n\nI'm working on a GitHub repo with lots of branches and pull requests.\nLet's say, for example, that I have the following pull requests:\n\na to branch X\nb to branch X\nc to branch Y\nd to branch X\ne to branch Y.\n\nIs there a way to find all the pull requests that are targeted for branch X (i.e. a -> X, b -> X, d -> X)?"
},
{
"role": "assistant",
"content": "Yes, you can do it.\nIn Github's terminology the \"to branch\" is \"base\"\nSo the search phrase is: is:open is:pr base:X\nOfficial description: Search based on branch names\nOptionally you can add is:merged or is:unmerged filters as well."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "A way to restrict Git branch access?\nI have four branches in my git repository, which is managed using GitHub:\n\nProduction\nStaging\nMaster\n[person's name]-development\n\nIs there a way to restrict write access to only a single branch ([person's name]-development)? How would I do this? \nFor reference, a similar question: How to write a git hook to restrict writing to branch?."
},
{
"role": "assistant",
"content": "When using GitHub, your best option would be for each developer to have their own fork of the master repository. Everybody pushes to their own repository and somebody with push access to the master repository handles pulling from each developer's repository. This is how most open source projects work.\nIf using your own Git server, it should be possible to use hooks to prevent users from pushing to wrong branches."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-parse - Pick out and massage parameters --is-inside-work-tree"
},
{
"role": "assistant",
"content": "When the current working directory is inside the work tree of the\nrepository print \"true\", otherwise \"false\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I view all commits for a specific day?\nI've already looked at the relevant docs from git-scm.com and gitref.org, but I can't seem to figure this out. \nLet's say I want to get all commits for Tuesday, November 12th, 2013. Using an existing repo as an example, I know for a fact that I have commits on that day, as well as commits the day before and the day after. \nWith 2013-11-11 and 2013-11-12\nAll the following give me commits for both November 11th and 12th:\n\ngit log --after=\"2013-11-11\" --until=\"2013-11-12\"\ngit log --since=\"2013-11-11\" --until=\"2013-11-12\"\ngit log --after=\"2013-11-11\" --before=\"2013-11-12\"\ngit log --since=\"2013-11-11\" --before=\"2013-11-12\"\n\nWith 2013-11-12 only\nAll the following give me no commits:\n\ngit log --since=\"2013-11-12\" --until=\"2013-11-12\" \ngit log --since=\"2013-11-12\" --before=\"2013-11-12\"\ngit log --after=\"2013-11-12\" --until=\"2013-11-12\"\ngit log --after=\"2013-11-12\" --before=\"2013-11-12\" \n\nWith 2013-11-12 and 2013-11-13\nAs expected (from the results of 2013-11-11 and 2013-11-12 above), all of the following give me results from both November 12th and 13th:\n\ngit log --since=\"2013-11-12\" --before=\"2013-11-13\"\ngit log --after=\"2013-11-12\" --before=\"2013-11-13\"\ngit log --since=\"2013-11-12\" --until=\"2013-11-13\"\ngit log --after=\"2013-11-12\" --before=\"2013-11-13\"\n\n...and so on and so forth. I feel like I've tried every possible combination of since, after, before, and until but still can't find the answer, nor do I understand whether those options are inclusive or exclusive, since they seem to be inclusive if the two dates are different, but exclusive if they're on the same day. Did I miss something / what am I doing wrong?!"
},
{
"role": "assistant",
"content": "Thanks John Bartholomew! \nThe answer is to specify the time, e.g. git log --after=\"2013-11-12 00:00\" --before=\"2013-11-12 23:59\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "show commits since branch creation\nIs there a way to see with git log or some other command only the commits that were added after branch creation?\nusage: git log [<options>] [<since>..<until>] [[--] <path>...]\n or: git show [options] <object>...\n\n --quiet suppress diff output\n --source show source\n --decorate[=...] decorate options"
},
{
"role": "assistant",
"content": "Full documentation is here: https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html\nSuppose you have a repo that looks like this:\nbase - A - B - C - D (master)\n \\\n \\- X - Y - Z (myBranch)\n\nVerify the repo status:\n> git checkout master\nAlready on 'master'\n> git status ; git log --oneline\nOn branch master\nnothing to commit, working directory clean\nd9addce D\n110a9ab C\n5f3f8db B\n0f26e69 A\ne764ffa base\n\nand for myBranch:\n> git checkout myBranch\n> git status ; git log --oneline\nOn branch myBranch\nnothing to commit, working directory clean\n3bc0d40 Z\n917ac8d Y\n3e65f72 X\n5f3f8db B\n0f26e69 A\ne764ffa base\n\nSuppose you are on myBranch, and you want to see only changes SINCE branching from master. Use the two-dot version:\n> git log --oneline master..myBranch\n3bc0d40 Z\n917ac8d Y\n3e65f72 X\n\nThe three-dot version gives all changes from the tip of master to the tip of myBranch. However, note that the common commit B is not included:\n> git log --oneline master...myBranch\nd9addce D\n110a9ab C\n3bc0d40 Z\n917ac8d Y\n3e65f72 X\n\nPLEASE NOTE: git log and git diff BEHAVE DIFFERENTLY! The behavior is not exactly opposite, but almost:\n> git diff master..myBranch\ndiff --git a/rev.txt b/rev.txt\nindex 1784810..e900b1c 100644\n--- a/rev.txt\n+++ b/rev.txt\n@@ -1 +1 @@\n-D\n+Z\n\n> git diff master...myBranch\ndiff --git a/rev.txt b/rev.txt\nindex 223b783..e900b1c 100644\n--- a/rev.txt\n+++ b/rev.txt\n@@ -1 +1 @@\n-B\n+Z\n\nSo, the two-dot version shows the diff from tip of master (i.e. D) to tip of myBranch (Z). The three-dot version shows the difference from the base of myBranch (i.e. B) to the tip of myBranch (Z)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Build .NET solution using GitLab CI Pipeline\n\nI have a solution with several .NET projects in it. I use GitLab, not self-hosted, for version control and would like to start using their CI tools as well. I have added the following .gitlab-ci.yml file to my root:\nstages:\n - build\n - test\n\nbuild_job:\n stage: build\n script:\n - 'echo building...'\n - 'msbuild.exe Bizio.sln'\n except:\n - tags\n\ntest_job:\n stage: test\n script:\n - 'echo: testing...'\n - 'msbuild.exe Bizio.sln'\n - 'dir /s /b *.Tests.dll | findstr /r Tests\\\\bin\\\\ > tests_list.txt'\n - 'for /f %%f in (tests_list.txt) do mstest.exe /testcontainer: \"%%f\"'\n except:\n - tags\n\nThe build stage always fails because it doesn't know what msbuild is. The exact error is:\n\n/bin/bash: line 61: msbuild.exe: command not found\n\nAfter some investigating, I've figured out that I'm using a shared runner. Here is the entire output from the job run:\nRunning with gitlab-runner 10.6.0-rc1 (0a9d5de9)\n on docker-auto-scale 72989761\nUsing Docker executor with image ruby:2.5 ...\nPulling docker image ruby:2.5 ...\nUsing docker image sha256:bae0455cb2b9010f134a2da3a1fba9d217506beec2d41950d151e12a3112c418 for ruby:2.5 ...\nRunning on runner-72989761-project-1239128-concurrent-0 via runner-72989761-srm-1520985217-1a689f37...\nCloning repository...\nCloning into '/builds/hyjynx-studios/bizio'...\nChecking out bc8085a4 as master...\nSkipping Git submodules setup\n$ echo building...\nbuilding...\n$ C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe Bizio.sln\n/bin/bash: line 61: msbuild.exe: command not found\nERROR: Job failed: exit code 1\n\nIt looks like the shared runner I have is using a Docker image for Ruby, which seems wrong. I don't know how I can change that or select a different one that can be used for .NET. After some further investigating I'm getting worried that I'll have to jump through a lot of hoops to get what I want, like using an Azure VM to host a GitLab Runner that can build .NET apps.\nWhat do I need to do to use GitLab's CI pipelines to build my .NET solution using a non-self-hosted GitLab instance?"
},
{
"role": "assistant",
"content": "You should be able to setup your own shared runner on a machine with the Framework 4 build tools on it (either using a Docker image, like microsoft/dotnet-framework-build, or just your native machine).\nThe simplest case to get going is using your own desktop, where you know your solution already builds. (Since using Docker images for the build is absolutely possible, but involves all of the extra steps of making sure you have docker working on your machine).\n\nDownload gitlab-runner on your computer from https://docs.gitlab.com/runner/install/windows.html \n\nCreate a directory on computer (C:\\gitlab-runner) \nDownload the latest binary x86 or x64 to that folder\nRename the binary to \"gitlab-runner.exe\"\n\nGet a gitlab-ci token for your runner\n\n\nProbably the easiest way to do this is to go to your project in gitlab.com and go to Settings -> CI/CD and expand General Pipeline Settings.\nIn the Runner Token section, click the Reveal Value button to show the token value. You will need this during the runner registration step.\n\nRegister the gitlab runner according to Registering Runners - Windows\n\nOpen an elevated command prompt (Run as administrator)\ncd to c:\\gitlab-runner\ntype gitlab-runner register\nThe register prompts will take you through the steps to register the runner, but in a nutshell, you will be putting in \ngitlab.com as your coordinator URL, entering the token from your project \ngiving your runner a name\ntagging your runner (so that you can associate it with projects that it is capable of building, testing, etc - for simplicity, you can skip tags now)\nallowing it to run for untagged jobs (again, simplicity, say true)\nlock runner to current project (simplicity, say true)\nand choosing the executor (enter shell, which is basically saying use the Windows Command-line) \n\nInstall gitlab-runner as a service, so that it is mostly always checking for work to do\n\n\nIn your command prompt, type gitlab-runner install\nThen type gitlab-runner start\n(Now, if you go to Services, you will see gitlab-runner listed, and it should be running - Just when when/if the runner crashes, you should go to Services to restart it)\n\n\nWhew. Now that runner is setup, it should be activated when you push a commit or a merge is requested. \nIf you are having issues still with the .gitlab-ci.yml file building properly, you can debug it locally (without having to keep triggering it through gitlab.com) by going to your solution folder in the command line and then executing c:\\gitlab-runner\\gitlab-runner build (To test the build step, for example).\nIf the build step has problem finding your solution file, you might want to try changing it from 'msbuild.exe Bizio.sln' to 'msbuild.exe .\\Bizio.sln'"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Cannot checkout, file is unmerged\nI am trying to remove the file from my working directory but after using the following command \ngit checkout file_Name.txt\n\nI got the following error message\nerror: path 'first_Name.txt' is unmerged\n\nWhat is that and how to resolve it?\nFollowing is my git status \n$ git status\nOn branch master\nYou are currently reverting commit f200bf5.\n (fix conflicts and run \"git revert --continue\")\n (use \"git revert --abort\" to cancel the revert operation)\n\nUnmerged paths:\n (use \"git reset HEAD <file>...\" to unstage)\n (use \"git add <file>...\" to mark resolution)\n\n both modified: first_file.txt\n\nUntracked files:\n (use \"git add <file>...\" to include in what will be committed)\n\n explore_california/\n\nno changes added to commit (use \"git add\" and/or \"git commit -a\")"
},
{
"role": "assistant",
"content": "If you want to discard modifications you made to the file, you can do:\ngit reset first_Name.txt\ngit checkout first_Name.txt"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Add users to group in GitLab\n\nI am filled with chagrin having to ask this, but I can't figure out how to add users in GitLab. I get to the screen where it allows me to add new members as follows:\n\nFrom my Group page -> click the 'members' icon on the toolbar along\n the left edge -> click 'Add Members' expando button -> enter username\n in 'Find existing member by name' or 'People' fields and get no\n results.\n\nThe 'People' field auto-populates with a bunch of names I don't recognize. But won't let me find a user who has registered by username or actual name. Am I missing something?"
},
{
"role": "assistant",
"content": "What version? These instructions are for gitlab community edition on ubuntu; the deb was named gitlab_7.4.3-omnibus.5.1.0.ci-1_amd64: \n\nLogin\nClick the gears icon (top right) to enter the Admin area\nClick the Groups link (top center) to enter the Groups page\nClick the name of the group you wish to extend (\"Mygroup\")\nLook at the right side of the screen; if you have the right privs you should see \"Add user(s) to the group:\"\nType the first few letters of the user name into the box, a drop-down should appear so you can select the user.\n\nHTH"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "show current GIT branch name in windows command prompt\nIs is possible to display current git branch name in regular windows command prompt?\nLet's say on windows 7 or 10."
},
{
"role": "assistant",
"content": "Not in command prompt but in PowerShell and Windows Terminal, it is possible. You can even have custom themes for terminal.\nHere are the steps:\n\nYou obviously need Git to begin with. Install Git for windows from Git website\nThen download \"Windows Terminal\" app from \"Windows Store\". It has multiple capabilities and new features and you can open multiple tabs of different terminals on the same window and so on.\nAfter installing \"Windows Terminal\", open it and and now you should install \"Posh-Git\" and \"Oh-My-Posh\" using PowerShell: (You may need to install NuGet if you don't already have it. Your PowerShell command line will ask if you want to install NuGet if this is the case. Select [Y] Yes. You may also need to approve that you are installing modules from PSGallery, an 'untrusted repository'. Select [Y] Yes.)\n\nInstall-Module posh-git -Scope CurrentUser\nInstall-Module oh-my-posh -Scope CurrentUser\n\n\nNow open your \"PowerShell\" profile with notepad $PROFILE and add these lines to end of the file: (this is a different profile than the \"Windows Terminal\" profile. PowerShell profile is a script that runs every time PowerShell starts.). If Set-PoshPrompt does not work here try to use Set-Theme command instead (https://superuser.com/questions/1629589/powershell-theming-doesnt-work-set-theme-not-found).\n\nImport-Module posh-git\nImport-Module oh-my-posh\nSet-PoshPrompt Paradox\n\n\nNow as you see some characters on the terminal are squares because the default font doesn't support them. (You may not have see this problem based on your terminal's font. if you see all of the characters fine and not squares, skip this step) You want to install \"Cascadia PL\" fonts to support those characters. Download them from Cascadia Code release page. You need to install these versions of the font in order for it to support the characters:\n\nCascadia Code PL\nCascadia Mono PL\n\n\nThen, in Windows Terminal, press Ctrl+, to open the Windows Terminal profile settings in \"settings.json\" and add these lines to the \"defaults\" section of the \"profiles\" as shown below:\n\n\"fontFace\": \"Cascadia Code PL\"\n\nHow to go to the Windows Terminal settings picture guide\nWhere to change the font face picture guide\nPS 1: If you want to have these changes on the integrated terminals such as the one on the VS Code, you should add this line to the settings of the VS Code:\n\"terminal.integrated.fontFamily\": \"Cascadia Code PL\"\n\nPS 2: In order to know more about \"Oh-My-Posh\" and change the theme of it, visit Oh-My-Posh's github page for more information.\n\nSources:\nhttps://learn.microsoft.com/en-us/windows/terminal/tutorials/powerline-setup\nhttps://www.hanselman.com/blog/how-to-make-a-pretty-prompt-in-windows-terminal-with-powerline-nerd-fonts-cascadia-code-wsl-and-ohmyposh"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc ignore-space-change"
},
{
"role": "assistant",
"content": "Ignore changes in amount of whitespace. This ignores whitespace\nat line end, and considers all other sequences of one or\nmore whitespace characters to be equivalent."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fast-import - Backend for fast Git data importers checkpoint"
},
{
"role": "assistant",
"content": "Forces fast-import to close the current packfile, generate its\nunique SHA-1 checksum and index, and start a new packfile.\nThis command is optional and is not needed to perform\nan import."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do Git LFS and git-annex differ?\ngit-annex has been around for quite some time, but never really gained momentum.\nGit LFS is rather young and is already supported by GitHub, Bitbucket and GitLab.\nBoth tools handle binary files in git repositories. On the other hand, GitLab seems to have replaced git-annex with Git LFS within one year.\n\nWhat are the technical differences?\nDo they solve the same problem?"
},
{
"role": "assistant",
"content": "They do solve the same problem.\nLet me start off with pro/con, then I'll move into technical differences.\ngit-annex\nPros:\n\nSupports multiple remotes that you can store the binaries.\nCan be used without support from hosting provider (for more details see here).\n\nCons:\n\nWindows support in beta, and has been for a long time\nUsers need to learn separate commands for day-to-day work\nnot supported by github and bitbucket\n\ngit-lfs\nPros:\n\nSupported by github, bitbucket and gitlab\nMost supported on all os's\nEasy to use.\nautomated based on filters\n\nCons:\n\nRequires a custom server implementation to work. A simple ssh remote is not sufficient. Reference server is under development https://github.com/git-lfs/lfs-test-server.\n\nTechnical\ngit-annex\ngit-annex works by creating a symlink in your repo that gets committed. The actual data gets stored into a separate backend (S3, rsync, and MANY others). It is written in haskell. Since it uses symlinks, windows users are forced to use annex in a much different manner, which makes the learning curve higher.\ngit-lfs\nPointer files are written. A git-lfs api is used to write the BLOBs to lfs. A special LFS server is required due to this. Git lfs uses filters so you only have to set up lfs once, and again when you want to specify which types of files you want to push to lfs."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I receive Github Webhooks in Python\n\nGithub offers to send Post-receive hooks to an URL of your choice when there's activity on your repo.\nI want to write a small Python command-line/background (i.e. no GUI or webapp) application running on my computer (later on a NAS), which continually listens for those incoming POST requests, and once a POST is received from Github, it processes the JSON information contained within. Processing the json as soon as I have it is no problem.\nThe POST can come from a small number of IPs given by github; I plan/hope to specify a port on my computer where it should get sent.\nThe problem is, I don't know enough about web technologies to deal with the vast number of options you find when searching.. do I use Django, Requests, sockets,Flask, microframeworks...? I don't know what most of the terms involved mean, and most sound like they offer too much/are too big to solve my problem - I'm simply overwhelmed and don't know where to start. \nMost tutorials about POST/GET I could find seem to be concerned with either sending or directly requesting data from a website, but not with continually listening for it.\nI feel the problem is not really a difficult one, and will boil down to a couple of lines, once I know where to go/how to do it. Can anybody offer pointers/tutorials/examples/sample code?"
},
{
"role": "assistant",
"content": "First thing is, web is request-response based. So something will request your link, and you will respond accordingly. Your server application will be continuously listening on a port; that you don't have to worry about.\nHere is the similar version in Flask (my micro framework of choice):\nfrom flask import Flask, request\nimport json\n\napp = Flask(__name__)\n\[email protected]('/',methods=['POST'])\ndef foo():\n data = json.loads(request.data)\n print \"New commit by: {}\".format(data['commits'][0]['author']['name'])\n return \"OK\"\n\nif __name__ == '__main__':\n app.run()\n\nHere is a sample run, using the example from github:\nRunning the server (the above code is saved in sample.py):\nburhan@lenux:~$ python sample.py \n * Running on http://127.0.0.1:5000/\n\nHere is a request to the server, basically what github will do:\nburhan@lenux:~$ http POST http://127.0.0.1:5000 < sample.json\nHTTP/1.0 200 OK\nContent-Length: 2\nContent-Type: text/html; charset=utf-8\nDate: Sun, 27 Jan 2013 19:07:56 GMT\nServer: Werkzeug/0.8.3 Python/2.7.3\n\nOK # <-- this is the response the client gets\n\nHere is the output at the server:\nNew commit by: Chris Wanstrath\n127.0.0.1 - - [27/Jan/2013 22:07:56] \"POST / HTTP/1.1\" 200 -"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs minimal"
},
{
"role": "assistant",
"content": "Spend extra time to make sure the smallest possible diff is\nproduced."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What are .git/info/grafts for?\nI am trying to figure out what is the 'grafts' in the Git.\nFor example, in one of the latest comments here, Tobu suppose to use git-filter-branch and .git/info/grafts to join two repositories.\nBut I don't understand why I need these grafts? It seems, that all work without last two commands."
},
{
"role": "assistant",
"content": "From Git Wiki:\n\nGraft points or grafts enable two\n otherwise different lines of\n development to be joined together. It\n works by letting users record fake\n ancestry information for commits. This\n way you can make git pretend the set\n of parents a commit has is different\n from what was recorded when the commit\n was created.\nReasons for Using Grafts\nGrafts can be useful when moving\n development to git, since it allows\n you to make cloning of the old history\n imported from another SCM optional.\n This keeps the initial clone for users\n who just wants to follow the latest\n version down while developers can have\n the full development history\n available.\nWhen Linus started using git for\n maintaining his kernel tree there\n didn't exist any tools to convert the\n old kernel history. Later, when the\n old kernel history was imported into\n git from the bkcvs gateway, grafts was\n created as a method for making it\n possible to tie the two different\n repositories together."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What does depth for git clone mean?\nWe tried to speed up the CI build of one of our software projects at work. Somebody committed some huge (by git's standards) binaries early in the project's life. Rewriting git's history just to get rid of them seems like too much trouble, so we figured doing a shallow clone that avoided those big early commits would be good enough.\nI did some experiments with --depth parameter for clone and encountered some weird behavior. This is what help for git clone says about it:\n--depth <depth>\n Create a shallow clone with a history truncated to the specified number of commits. Implies\n --single-branch unless --no-single-branch is given to fetch the histories near the tips of all\n branches. If you want to clone submodules shallowly, also pass --shallow-submodules.\n\nThis would indicate that <depth> will equal the number of commits that will be fetched during the clone, but it's not the case. This is what I got when I tried different values for depth:\n| depth | commit count linux repo | commit count git repo |\n|---------|-------------------------|-----------------------|\n| 1 | 1 | 1 |\n| 5 | 15 | 13 |\n| 10 | 80 | 46 |\n| 100 | 93133 | 39552 |\n| 1000 | 788718 | 53880 |\n\nFor cloning I used this command git clone --depth 10 https://github.com/torvalds/linux.git, git clone --depth 100 https://github.com/git/git.git, and for counting the commits I used this git log --oneline | wc -l. (At work I observed the same thing with a GitLab server, so it can't be an artifact of how GitHub works.)\nDoes anybody know what is going on? How does the value for depth correspond to the actual amount of data downloaded? Do I understand the documentation wrongly, or is there a bug?\nEDIT: I added results for a second repo"
},
{
"role": "assistant",
"content": "As Jonathon Reinhart commented, you're seeing the effect of merges.\nThe --depth parameter refers to how deep Git goes on a \"walk\" from each starting point. As the documentation you quoted mentions, it also implies --single-branch, which simplifies talking about this. The important point here is that the walk visits all parents of each commit, which—for each depth level—is more than one commit if the commit itself is a merge.\nSuppose we have a commit graph that looks like this:\n$ git log --graph --oneline master\n* cf68824 profile: fix PATH with GOPATH\n* 7c2376b profile: add Ruby gem support\n* 95c8270 profile: set GOPATH\n* 26a9cc3 vimrc: fiddle with netrw directory display\n* 80b88a5 add ruby gems directory to path\n[snip]\n\nHere, each commit has just one parent. If we use --depth 3 we'll pick up the tip commit cf68824, its parent 7c2376b at depth 2, and finally 95c8270 at depth 3—and then we stop, with three commits.\nWith the Git repository for Git, however:\n$ git log --graph --oneline master\n* 965798d1f2 Merge branch 'es/format-patch-range-diff-fix-fix'\n|\\ \n| * ac0edf1f46 range-diff: always pass at least minimal diff options\n* | 5335669531 Merge branch 'en/rebase-consistency'\n|\\ \\ \n| * | 6fcbad87d4 rebase docs: fix incorrect format of the section Behavioral Differences\n* | | 7e75a63d74 RelNotes 2.20: drop spurious double quote\n* | | 7a49e44465 RelNotes 2.20: clarify sentence\n[snip]\n\nWith --depth 3, we start with 965798d1f2, then—for depth 2—pick up both parents, ac0edf1f46 and 5335669531. To add the depth-3 commits, we pick up all the parents of those two commits. The (lone) parent of ac0edf1f46 is not visible here, while the two parents of 5335669531 are (namely 6fcbad87d4 and 7e75a63d74). To get the hash IDs of the parents of ac0edf1f46 we can use:\n$ git rev-parse ac0edf1f46^@\nd8981c3f885ceaddfec0e545b0f995b96e5ec58f\n\nso that gives us our six commits: the tip of master (which is currently a merge commit), two parents of that commit, one parent of one of those parents, and two parents of the other of that parent.\nDepending on precisely when you ran the clone of Git, the tip-most master is often not a merge, but often has a merge as its immediate parent, so that --depth 2 will often get you 3 commits, and --depth 3 will therefore get at least 5, depending on whether the two parents of the tip of master are themselves merges.\n(Compare the above git rev-parse output with:\n$ git rev-parse 965798d1f2^@\n5335669531d83d7d6c905bcfca9b5f8e182dc4d4\nac0edf1f46fcf9b9f6f1156e555bdf740cd56c5f\n\nfor instance. The ^@ suffix means all parents of the commit, but not the commit itself.)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Searching code in a specific GitHub branch\nI am trying to search some code in a branch in a GitHub repository.\nHowever this indicates that I can only search the default branch.\nIs there a way I can search code in non-default branch in my GitHub repository?"
},
{
"role": "assistant",
"content": "Not from the GitHub web interface itself, as mentioned in \"How can I search for a commit message on GitHub?\": only the default branch (generally master) is indexed.\nYour best bet is to clone the repository, and there, search in all branches (with git log -S for instance)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Convert line-endings for whole directory tree (Git)\nFollowing situation:\nI'm working on a Mac running OS X and recently joined a project whose members so far all use Windows. One of my first tasks was to set up the codebase in a Git repository, so I pulled the directory tree from FTP and tried to check it into the Git repo I had prepared locally. When trying to do this, all I got was this\nfatal: CRLF would be replaced by LF in blog/license.txt.\n\nSince this affects all files below the \"blog\" folder, I'm looking for a way to conveniently convert ALL files in the tree to Unix line-endings. Is there a tool that does that out of the box or do I get scripting something myself?\nFor reference, my Git config concerning line-endings:\ncore.safecrlf=true\ncore.autocrlf=input"
},
{
"role": "assistant",
"content": "dos2unix does that for you. Fairly straight forward process.\ndos2unix filename\n\nThanks to toolbear, here is a one-liner that recursively replaces line endings and properly handles whitespace, quotes, and shell meta chars.\nfind . -type f -exec dos2unix {} \\;\n\nIf you're using dos2unix 6.0 binary files will be ignored."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-parse - Pick out and massage parameters <rev>"
},
{
"role": "assistant",
"content": "Include commits that are reachable from <rev> (i.e. <rev> and its\nancestors)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git stage and commit with one command\nIs there a way in Git to stage and commit files in one command? For example in my local repository I created files index.html, styles.css located in css folder and script.js located in js folder. Now I want to run one command to stage and commit all this files. I tried code below but it didn't work\ngit commit -a -m \"my commit message\""
},
{
"role": "assistant",
"content": "What you want to do is:\ngit commit -am \"Message for my commit\"\n\nThis will automatically add all tracked files and you can type your message in one command.\n\n-a --all\nTell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.\n\n\n-m <msg> --message=<msg>\nUse the given as the commit message. If multiple -m options are given, their values are concatenated as separate paragraphs.\n\n\nhttps://git-scm.com/docs/git-commit\n\nIf you want to stage and commit untracked files, you can:\ngit add -A && git commit -am 'message'"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs Default mode"
},
{
"role": "assistant",
"content": "Commits are included if they are not TREESAME to any parent\n(though this can be changed, see --sparse below). If the\ncommit was a merge, and it was TREESAME to one parent, follow\nonly that parent. (Even if there are several TREESAME\nparents, follow only one of them.) Otherwise, follow all\nparents. This results in: .-A---N---O\n\t / / /\n\tI---------D Note how the rule to only follow the TREESAME parent, if one is\navailable, removed B from consideration entirely. C was\nconsidered via N , but is TREESAME. Root commits are compared to an\nempty tree, so I is !TREESAME. Parent/child relations are only visible with --parents , but that does\nnot affect the commits selected in default mode, so we have shown the\nparent lines."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-http-backend"
},
{
"role": "assistant",
"content": "Server side implementation of Git over HTTP"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to export revision history from mercurial or git to cvs?\nI'm going to be working with other people on code from a project that uses cvs. We want to use a distributed vcs to make our work and when we finish or maybe every once in a while we want to commit our code and all of our revision history to cvs. We don't have write access to the project's cvs repo so we can't commit very frequently. What tool can we use to export our revision history to cvs? Currently we were thinking of using git or mercurial but we could use another distributed vcs if it could make the export easier."
},
{
"role": "assistant",
"content": "Fortunately for those of us who are still forced to use CVS, git provides pretty good tools to do exactly what you're wanting to do. My suggestions (and what we do here at $work):\nCreating the Initial Clone\nUse git cvsimport to clone the CVS revision history into a git repository. I use the following invocation:\n% git cvsimport -d $CVSROOT -C dir_to_create -r cvs -k \\\n -A /path/to/authors/file cvs_module_to_checkout\n\nThe -A option is optional but it helps to make your revision history that's imported from CVS look more git-like (see man git-cvsimport for more info on how this is set up).\nDepending on the size and history of the CVS repository, this first import will take a VERY long time. You can add a -v to the above command if you want the peace of mind that something is in fact happening.\nOnce this process is completed, you will have a master branch that should reflect CVS's HEAD (with the exception that git cvsimport by default ignores the last 10 minutes worth of commits to avoid catching a commit that is half-finished). You can then use git log and friends to examine the entire history of the repository just as if it had been using git from the beginning.\nConfiguration Tweaks\nThere are a few configuration tweaks that will make incremental imports from CVS (as well as exports) easier in the future. These are not documented on the git cvsimport man page so I suppose they could change without notice but, FWIW:\n% git config cvsimport.module cvs_module_to_checkout\n% git config cvsimport.r cvs\n% git config cvsimport.d $CVSROOT\n\nAll of these options can be specified on the command line so you could safely skip this step.\nIncremental Imports\nSubsequent git cvsimport should be much faster than the first invocation. It does, however, do an cvs rlog on every directory (even those that have only files in Attic) so it can still take a few minutes. If you've specified the suggested configs above, all you need to do is execute:\n% git cvsimport\n\nIf you haven't set up your configs to specify the defaults, you'll need to specify them on the command line:\n% git cvsimport -r cvs -d $CVSROOT cvs_module_to_checkout\n\nEither way, two things to keep in mind:\n\nMake sure you're in the root directory of your git repository. If you're anyplace else, it will try to do a fresh cvsimport that will again take forever.\nMake sure you're on your master branch so that the changes can be merged (or rebased) into your local/topic branches.\n\nMaking Local Changes\nIn practice, I recommend always making changes on branches and only merging to master when you're ready to export those changes back to the CVS repository. You can use whatever workflow you like on your branches (merging, rebasing, squashing, etc) but of course the standard rebasing rules apply: don't rebase if anyone else has been basing their changes on your branch.\nExporting Changes to CVS\nThe git cvsexportcommit command allows you to export a single commit out to the CVS server. You can specify a single commit ID (or anything that describes a specific commit as defined in man git-rev-parse). A diff is then generated, applied to a CVS checkout and then (optionally) committed to CVS using the actual cvs client. You could export each micro commit on your topic branches but generally I like to create a merge commit on an up-to-date master and export that single merge commit to CVS. When you export a merge commit, you have to tell git which commit parent to use to generate the diff. Also, this won't work if your merge was a fast-forward (see the \"HOW MERGE WORKS\" section of man git-merge for a description of a fast-forward merge) so you have to use the --no-ff option when performing the merge. Here's an example:\n# on master\n% git merge --no-ff --log -m \"Optional commit message here\" topic/branch/name\n% git cvsexportcommit -w /path/to/cvs/checkout -u -p -c ORIG_HEAD HEAD\n\nYou can see what each of those options mean on the man page for git-cvsexportcommit. You do have the option of setting the -w option in your git config:\n% git config cvsexportcommit.cvsdir /path/to/cvs/checkout\n\nIf the patch fails for whatever reason, my experience is that you'll (unfortunately) probably be better off copying the changed files over manually and committing using the cvs client. This shouldn't happen, however, if you make sure master is up-to-date with CVS before merging your topic branch in.\nIf the commit fails for whatever reason (network/permissions issues, etc), you can take the command printed to your terminal at the end of the error output and execute it in your CVS working directory. It usually looks something like this:\n% cvs commit -F .msg file1 file2 file3 etc\n\nThe next time you do a git cvsimport (waiting at least 10 minutes) you should see the patch of your exported commit re-imported into your local repository. They will have different commit IDs since the CVS commit will have a different timestamp and possibly a different committer name (depending on whether you set up an authors file in your initial cvsimport above).\nCloning your CVS clone\nIf you have more than one person needing to do the cvsimport, it would be more efficient to have a single git repository that performs the cvsimport and have all the other repositories created as a clone. This works perfectly and the cloned repository can perform cvsexportcommits just as described above. There is one caveat, however. Due to the way CVS commits come back through with different commit IDs (as described above), you don't want your cloned branch to track the central git repository. By default, this is how git clone configures your repository but this is easily remedied:\n% git clone [CENTRAL_REPO_HERE]\n% cd [NEW_GIT_REPO_DIR_HERE]\n% git config --unset branch.master.remote\n% git config --unset branch.master.merge\n\nAfter you've removed these configs, you will have to explicitly say where and what to pull from when you want to pull in new commits from the central repository:\n% git pull origin master\n\n\nOverall, I've found this work-flow to be quite manageable and the \"next best thing\" when migrating completely to git isn't practical."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options core.packedGitLimit"
},
{
"role": "assistant",
"content": "Maximum number of bytes to map simultaneously into memory\nfrom pack files. If Git needs to access more than this many\nbytes at once to complete an operation it will unmap existing\nregions to reclaim virtual address space within the process. Default is 256 MiB on 32 bit platforms and 32 TiB (effectively\nunlimited) on 64 bit platforms.\nThis should be reasonable for all users/operating systems, except on\nthe largest projects. You probably do not need to adjust this value. Common unit suffixes of k , m , or g are supported."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitLab CI Pipeline on specific branch only\n\nI'm trying to implement GitLab CI Pipelines to build and deploy an Angular app. In our project we have two general branches: master (for production only) and develop. For development we create feature/some-feature branches from develop branch. When development finished, we create merge request from feature/some-feature to develop. When merge request approved and merged into develop branch I want to run a Pipeline in order to build application and deploy the build on some environment.\nI use the following setup in .gitlab-ci.yml:\nimage: node:7.5-configured\n\nstages:\n - build\n - deploy\n\nbuild_job:\n stage: build\n only:\n - develop\n script:\n - /bin/bash <some script here>\n\n...\n\nThe problem is that Pipeline executed every time I push into any feature/some-feature branch. What's wrong with my setup? How can I force the Pipeline to be executed only when push performed into develop branch directly?\nSolution\nIt was my mistake - I had two different .gitlab-ci.yml files in develop branch and feature/some-feature branch."
},
{
"role": "assistant",
"content": "Although it has been passed much time on this discussion I would like to suggest an opinion, which I am using most of the time.\nrules:\n - if: '$CI_PIPELINE_SOURCE == \"push\" && $CI_COMMIT_BRANCH == \"master\"'\n when: on_success\n changes:\n - folder/some_folder/**/* \n - if: '$CI_PIPELINE_SOURCE == \"web\" && $CI_COMMIT_BRANCH == \"development\"'\n when: manual\n changes:\n - folder/some_other_folder/**/* \n\nThis structure solved my various problems, I hope it helps you to!\nRegards."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to count total lines changed by a specific author in a Git repository?\nIs there a command I can invoke which will count the lines changed by a specific author in a Git repository? I know that there must be ways to count the number of commits as Github does this for their Impact graph."
},
{
"role": "assistant",
"content": "This gives some statistics about the author, modify as required.\nUsing Gawk:\ngit log --author=\"_Your_Name_Here_\" --pretty=tformat: --numstat \\\n| gawk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf \"added lines: %s removed lines: %s total lines: %s\\n\", add, subs, loc }' -\n\nUsing Awk on Mac OSX:\ngit log --author=\"_Your_Name_Here_\" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf \"added lines: %s, removed lines: %s, total lines: %s\\n\", add, subs, loc }' -\n\n\nUsing count-lines git-alias:\nSimply create count-lines alias (once per system), like:\ngit config --global alias.count-lines \"! git log --author=\\\"\\$1\\\" --pretty=tformat: --numstat | awk '{ add += \\$1; subs += \\$2; loc += \\$1 - \\$2 } END { printf \\\"added lines: %s, removed lines: %s, total lines: %s\\n\\\", add, subs, loc }' #\"\n\nAnd use each time later, like:\ngit count-lines [email protected]\n\n\nFor Windows, works after adding Git-Bash to PATH (environment-variable).\nFor Linux, maybe replace awk part with gawk.\nFor MacOS, works without any change.\n\nUsing existing script (Update 2017)\nThere is a new package on github that looks slick and uses bash as dependencies (tested on linux). It's more suitable for direct usage rather than scripts.\nIt's git-quick-stats (github link).\nCopy git-quick-stats to a folder and add the folder to path.\nmkdir ~/source\ncd ~/source\ngit clone [email protected]:arzzen/git-quick-stats.git\nmkdir ~/bin\nln -s ~/source/git-quick-stats/git-quick-stats ~/bin/git-quick-stats\nchmod +x ~/bin/git-quick-stats\nexport PATH=${PATH}:~/bin\n\nUsage:\ngit-quick-stats"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-shortlog - Summarize git log output -e --email"
},
{
"role": "assistant",
"content": "Show the email address of each author."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "error: pathspec 'test-branch' did not match any file(s) known to git\nI am a new user of Git. I have forked a repository called Spoon-Knife (available for practicing forking with Git). Then, I cloned it locally by running\ngit clone https://github.com/rohinichoudhary/Spoon-Knife.git\n\nThis repository contains three branches, i.e.\n\nmaster,\ntest-branch,\nchange-the-title.\n\nWhen I run git branch, it only shows *master, not the remaining two branches. And when I run\ngit checkout test-branch\n\nI get the following error:\n\nerror: pathspec 'test-branch' did not match any file(s) known to git.\n\nWhy is this happening? How can I solve this problem?"
},
{
"role": "assistant",
"content": "The modern Git should able to detect remote branches and create a local one on checkout.\nHowever if you did a shallow clone (e.g. with --depth 1), try the following commands to correct it:\ngit config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'\ngit fetch --all\n\nand try to checkout out the branch again.\nAlternatively try to unshallow your clone, e.g. git fetch --unshallow and try again.\nSee also: How to fetch all remote branches?"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git autocomplete in bash aliases?\nI'm using go as a simple bash alias for git checkout branchname. The thing that I miss is the autocomplete feature that works with the full git checkout branchna... command, but not in the alias.\nIs there a way to instruct Bash to \"inherit\" the autocomplete \"driver\" for another command?"
},
{
"role": "assistant",
"content": "After using complete -F:\ncomplete -F _git_checkout go\n\nTabbing after go may result in:\nbash: [: 1: unary operator expected\n\nInstead of complete, use __git_complete\nThis is git bash completion's built-in function for this purpose.\nAfter declaring your alias, bind the correct auto-complete function to it:\n# Main git completions (prior to git 2.30, you an use _git instead of __git_main)\nalias g=\"git\"\n__git_complete g __git_main\n\nalias go=\"git checkout\"\n__git_complete go _git_checkout\n\nalias gp=\"git push\"\n__git_complete gp _git_push"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: Pulling a rebased branch\nLet me describe my situation:\nMr Blond and Mr Orange are working on branch A that branches out of the master branch on commit M1. Branch A has 2 commits: A1 and A2.\nM1 \n \\\n \\\n A1 - A2\n\nMeanwhile, Mr Orange committed and pushed 2 more commits on the master branch, M2 and M3.\nM1 - M2 - M3\n \\\n \\\n A1 - A2\n\nMr Blond pulls from the remote, and after a while decides to rebase onto the master branch:\nM1 - M2 - M3\n \\ \\\n \\ \\\n A1 - A2 A1` - A2`\n\nNow A1` and A2` are the rebased commits that exist locally at Mr blond's, and A1 and A2 exist remotely. Mr Blond pushes his commits, using -f to force his changes and \"rewrite\" history. Now the remote repository looks like this:\nM1 - M2 - M3\n \\\n \\\n A1` - A2`\n\nBut Mr. Orange worked on the A branch as well. His local repository still looks like this:\nM1 - M2 - M3\n \\\n \\\n A1 - A2\n\nWhat does Mr. Orange need to do in order to be synchronized with A branch in the remote repository?\nA normal pull won't work. Will pull -f force the changes from the remote locally? I know that deleting the local version of A and bringing it again from the remote repository will do the trick but that doesn't seem to be a good way to achieve that."
},
{
"role": "assistant",
"content": "If Mr. Orange doesn't mind losing his changes, he can fetch from the server, then checkout the the branch:\ngit checkout A to get onto his local A branch.\nThen, assuming the remote is named \"origin\", reset your local branch in favor of the remote branch:\ngit reset --hard origin/A\nIf he is concerned with losing changes, he can merge the server's changes in to resolve them (from his own A branch, and presuming again that the remote is named \"origin\") with git merge origin/A. This will make a new commit that's on top of both his and the remote's A branches with the changes from both merged together. Then this can be pushed back to the remote."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to abort 'git commit --amend'?\nI accidentally used git commit --amend. My text editor is open and waiting for input. I know, that when I close it now (not changing the existing commit message) the commit will be amended. What can I do to abort the process? \nThis blog article says that I can simply delete the commit message and the commit will then not be valid and ignored. Is that correct? Are there alternatives?"
},
{
"role": "assistant",
"content": "That is correct. Saving the file with no contents will abort the amend."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How does git merge after cherry-pick work?\nLet's imagine that we have a master branch.\nThen we create a newbranch\ngit checkout -b newbranch\n\nand make two new commits to newbranch: commit1 and commit2\nThen we switch to master and make cherry-pick\ngit checkout master\ngit cherry-pick hash_of_commit1\n\nLooking into gitk we see that commit1 and its cherry-picked version have different hashes, so technically they are two different commits.\nFinally we merge newbranch into master:\ngit merge newbranch\n\nand see that these two commits with different hashes were merged without problems although they imply that the same changes should be applied twice, so one of them should fail.\nDoes git really do a smart analysis of commit's content while merging and decide that changes shouldn't be applied twice or these commits are marked internally as linked together?"
},
{
"role": "assistant",
"content": "Short answer\nDon't worry, Git will handle it.\nLong answer\nUnlike e.g. SVN1, Git does not store commits in delta format, but is snapshot-based2,3. While SVN would naively try to apply each merged commit as a patch (and fail, for the exact reason you described), Git is generally able to handle this scenario.\nWhen merging, Git will try to combine the snapshots of both HEAD commits into a new snapshot. If a portion of code or a file is identical in both snapshots (i.e. because a commit was already cherry-picked), Git won't touch it.\nSources\n1 Skip-Deltas in Subversion\n2 Git Basics\n3 The Git object model"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs log.showSignature"
},
{
"role": "assistant",
"content": "If true, makes git-log , git-show , and git-whatchanged assume --show-signature ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fetch - Download objects and refs from another repository t"
},
{
"role": "assistant",
"content": "for a successful tag update;"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab on port 8080\n\nI'm currently in the process of trying to get Gitlab omnibus installed on my private Debian server, and it works perfectly on port 80, the problem is I also have an Apache server listening on port 80. So I'm trying to get Nginx listening on port 8080 but for some reason I'm getting a \n \"502\nGitlab is not responding\" Error\nI have edited both \"external_url\" in gitlab.rb and also the port number under the server block in the nginx.conf file. and no joy.\nIf someone could help me that would be great!"
},
{
"role": "assistant",
"content": "Most likely you have another service listening on 8080, I think the omnibus install have some service hooking 8080 - just use 8081 instead.\nEdit: I just did a quick search and found that it's the unicorn server that is listening to 8080 with the original omnibus installer.\nNote: You will only need to change the external_url in gitlab.rb, no other config file should have to be edited for this.\nEdit#2: As @emeraldjava stated there is an option in the configuration file for using another unicorn port: #unicorn['port'] = '8080'"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Remote branch on Visual Studio online doesn't appear on Visual Studio 2015 Team Explorer\nI have created a new Git repository on Visual Studio online. I have cloned on my computer and I have added it a project. After that, I have created a new branch called develop on Visual Studio online, and I have tried to check it out creating a new local branch but it doesn't appear on Team Explorer.\nThis is my Visual Studio online:\n\nAnd this is Visual Studio 2015 Team Explorer:\n\nWhy develop branch doesn't appear on Team Explorer?"
},
{
"role": "assistant",
"content": "You can now do this in Visual Studio by going to the Synchronisation tab (Sync in the Team drop down menu) and clicking Fetch at the top."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git error when trying to push to remote branch\nI've cloned repository A's master branch from git and created my own branch called Li.\nI've made some changes a while ago and pushed the contents of local Li to remote Li.\nNow I've pulled some updates from remote master to my local master branch and from the local master branch to the local Li, and I'm trying to push the updates from local Li to remote Li.\nHowever, when I try to run:\ngit checkout Li\ngit push origin Li\n\nI get the following error:\nerror: failed to push some refs to '[email protected]:anodejs/system.git'\nhint: Updates were rejected because the tip of your current branch is behind\nhint: its remote counterpart. Merge the remote changes (e.g. 'git pull')\nhint: before pushing again.\nhint: See the 'Note about fast-forwards' in 'git push --help' for details.\n\nNote that my local master branch is updated (I invoked git pull origin master) and merged into the local Li branch. I did, however, add local Li a new file, so local Li is not identical to local master (but this shouldn't matter, right?)\nThanks,\nLi"
},
{
"role": "assistant",
"content": "Updates were rejected because a pushed branch tip is behind its remote.\ngit config --global push.default current\n\nTry the command above to set the current branch as default and \ngit push"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --submodule[=<format>]"
},
{
"role": "assistant",
"content": "Specify how differences in submodules are shown. When specifying --submodule=short the short format is used. This format just\nshows the names of the commits at the beginning and end of the range.\nWhen --submodule or --submodule=log is specified, the log format is used. This format lists the commits in the range like git-submodule summary does. When --submodule=diff is specified, the diff format is used. This format shows an\ninline diff of the changes in the submodule contents between the\ncommit range. Defaults to diff.submodule or the short format\nif the config option is unset."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Completely remove a file from whole git repository\n\nUsing git for a project, I accidentally added to a commit a big .zip file. I didn't notice until I started uploading it to github. When I noticed, I hit ctrl-c, git remove, git commit and uploaded it again (now with the file untracked).\nI know that this wasn't the right choice to do, because once I committed the .zip, it stays in the repo until I revert the commit, but sadly I didn't.\nNow, when someone tries to download from the repo, it takes a lot of time to do it, sometimes yields git the remote end hung up unexpectedly (which I've read can be solved by doing some git config) and is very annoying.\nMy point is: is there a way to tell further pull/fetch request that forget this specific file in this specific commit version?"
},
{
"role": "assistant",
"content": "Github provide a useful help page on removing files like this. There are also other questions on StackOverflow which cover this\n\nCompletely remove unwanted file from Git repository history\nHow can I completely remove a file from a git repository?\n\nSee also this section of the Pro Git book, an example given there:\n\nTo remove a file named passwords.txt from your entire history, you can\n use the --tree-filter option to filter-branch:\n$ git filter-branch --tree-filter 'rm -f passwords.txt' HEAD\nRewrite 6b9b3cf04e7c5686a9cb838c3f36a8cb6a0fc2bd (21/21)\nRef 'refs/heads/master' was rewritten\n\n\nAfter the cleanup, you could also try a git gc to further compress and clean up for repository."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs notes.<name>.mergeStrategy"
},
{
"role": "assistant",
"content": "Which merge strategy to choose when doing a notes merge into\nrefs/notes/<name>. This overrides the more general\n\"notes.mergeStrategy\". See the \"NOTES MERGE STRATEGIES\" section in git-notes for more information on the available strategies."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-remote - Manage set of tracked repositories prune"
},
{
"role": "assistant",
"content": "Deletes stale references associated with <name>. By default, stale\nremote-tracking branches under <name> are deleted, but depending on\nglobal configuration and the configuration of the remote we might even\nprune local tags that haven’t been pushed there. Equivalent to git\nfetch --prune <name> , except that no new references will be fetched. See the PRUNING section of git-fetch for what it’ll prune\ndepending on various configuration. With --dry-run option, report what branches would be pruned, but do not\nactually prune them."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects %gs"
},
{
"role": "assistant",
"content": "reflog subject"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Showing branch hierarchy at the command line?\nI'm curious if there is a way to show branch hierarchy on the command line? For instance if I use git branch, instead of seeing output like this:\n* master\njoes_work\nrefactoring\nexperiment\n\nYou see output like this:\n* master\n joes_work\n refactoring\n experiment\n\nThat way it's easy to see which branch a particular branch.. branched off of. Even if there's no specific command that outputs a tree structure, is there a command that outputs information on which branch came from which branch? I can use a perl script to format the output."
},
{
"role": "assistant",
"content": "sehe's solution looks great, here is another one that seems to contain similar information, formatted differently, it uses git log, so it contains commit information as well (ignore the branch names, I kind of messed them up!):\ngit log --all --graph --decorate --oneline --simplify-by-decoration\n\n* ae038ad (HEAD, branch2-1) add content to tmp1\n| * f5a0029 (branch2-1-1) Add another\n|/ \n* 3e56666 (branch1) Second wave of commits\n| * 6c9af2a (branch1-2) add thing\n|/ \n* bfcf30a (master) commit 1"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs default , myers"
},
{
"role": "assistant",
"content": "The basic greedy diff algorithm. Currently, this is the default."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git pushing to remote GitHub repository as wrong user\nI have a work GitHub account and a personal one. First I used the personal one for test projects, then I moved on and did a repository with the other account on the same computer.\nNow I wanted to create a new repository on my personal account again, I changed the global and local user.name, and did a new ssh key pair, entered in the GitHub setup page. Then I set up the directory\ngit init\ngit remote add origin <url>\ngit push origin\n\nbut that now tells me\n\nERROR: Permission to personaluser/newrepo.git denied to \n\nI have no idea how the other account is connected to this one. .git/config shows no workusername related things.\nIf you're using Windows 10 take your time to read the Rajan's answer."
},
{
"role": "assistant",
"content": "this sounds very similar to my current work set up. it seems that you already have set up your separate ssh-keys so you also need to create a ~/.ssh/config file and populate it with information similar to this:\nHost work.github.com\n HostName github.com\n User WORK_GITHUB_USERNAME\n PreferredAuthentications publickey\n IdentityFile ~/.ssh/id_work_rsa\n IdentitiesOnly yes\n\nHost personal.github.com\n HostName github.com\n User PERSONAL_GITHUB_USERNAME \n PreferredAuthentications publickey\n IdentityFile ~/.ssh/id_personal_rsa\n IdentitiesOnly yes\n\nEvery property sounds pretty self explanatory but the IdentitiesOnly one. I won't try to explain what that is for, but that is in my current setup and works fine.\nIt's also worth noting that the Host URL is just a pointer to grab the correct user settings and does not have any affect on getting the files correctly to your target HostName url.\nNow you just need to make sure your origin (or any remote in general) url match the correct Host url in your respective repos depending on your user name. If you already have existing personal repos, you can edit that repo's .git/config file in your text editor:\n[remote \"origin\"]\n fetch = +refs/heads/*:refs/remotes/origin/*\n url = [email protected]:PERSONAL_GITHUB_USERNAME/project.git\n\nor do it via command line:\ngit remote set-url origin [email protected]:PERSONAL_GITHUB_USERNAME/project.git\n\nLikewise to your work one:\n[remote \"origin\"]\n fetch = +refs/heads/*:refs/remotes/origin/*\n url = [email protected]:your_work_organization/project.git\n\nor again, via command line:\ngit remote set-url origin [email protected]:your_work_organization/project.git\n\nOf course, you can always set one of your Host urls in your ~/.ssh/config file as just\nHost github.com\n\nI only used work.github.com to see the config relationships easier.\nOnce these are all set, you should be able to push to each respective remote.\nEDIT\nOne thing to note that I just found out myself is that if you ever set global git config values for your user.email value (and i'm guessing user.name would send a different value as well), git will show your commits as that email user. To get around this, you can override the global git config settings within your local repository:\n$ git config user.name \"John Doe\"\n$ git config user.email [email protected]\n\nThis should now send up commits as the correct user for that repo."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git checkout --ours does not remove files from unmerged files list\nHi I need to merge two branches like this.\nThis is just an example what is happening, I work with hundreds of files which need resolution.\ngit merge branch1\n...conflicts...\ngit status\n....\n# Unmerged paths:\n# (use \"git add/rm <file>...\" as appropriate to mark resolution)\n#\n# both added: file1\n# both added: file2\n# both added: file3\n# both added: file4\ngit checkout --ours file1\ngit chechout --theirs file2\ngit checkout --ours file3\ngit chechout --theirs file4\ngit commit -a -m \"this should work\"\nU file1\nfatal: 'commit' is not possible because you have unmerged files.\nPlease, fix them up in the work tree, and then use 'git add/rm <file>' as\nappropriate to mark resolution and make a commit, or use 'git commit -a'.\n\nWhen I do git merge tool, there is the correct content just from the 'ours' branch and when I save it, the file disappears from the unmerged list. But since I have hundreds of files like this, this is not an option.\nI thought that this approach will bring me where I want to be - easily say which file from which branch I want to keep.\nBut I guess I misunderstood the concept of the git checkout --ours/theirs commands after a merge.\nCould you please provide me some info, how to handle this situation? I use git 1.7.1"
},
{
"role": "assistant",
"content": "It's mostly a quirk of how git checkout works internally. The Git folks have a tendency to let implementation dictate interface.\nThe end result is that after git checkout with --ours or --theirs, if you want to resolve the conflict, you must also git add the same paths:\ngit checkout --ours -- path/to/file\ngit add path/to/file\n\nBut this is not the case with other forms of git checkout:\ngit checkout HEAD -- path/to/file\n\nor:\ngit checkout MERGE_HEAD -- path/to/file\n\n(these are subtly different in multiple ways). In some cases this means the fastest way is to use the middle command. (Incidentally, the -- here is to make sure Git can distinguish between a path name and an option or branch name. For instance, if you have a file named --theirs, it will look like an option, but -- will tell Git that no, it's really a path name.)\nTo see how this all works internally, and why you need the separate git add except when you don't, read on. :-) First, let's do a quick review of the merge process.\nMerge, part 1: how merge begins\nWhen you run:\n$ git merge commit-or-branch\nthe first thing Git does is find the merge base between the named commit and the current (HEAD) commit. (Note that if you supply a branch name here, as in git merge otherbranch, Git translates that to a commit-ID, namely the tip of the branch. It saves the branch name argument for the eventual merge log message, but needs the commit ID to find the merge base.)\nHaving found a suitable merge base,1 Git then produces two git diff listings: one from the merge base to HEAD, and one from the merge base to the commit you identified. This gets \"what you changed\" and \"what they changed\", which Git now has to combine.\nFor files where you made a change and they didn't, Git can just take your version.\nFor files where they made a change and you didn't, Git can just take their version.\nFor files where you both made changes, Git must do some real merge work. It compares the changes, line by line, to see if it can combine them. If it can combine them, it does so. If the merges seem—based, again, on purely line-by-line comparisons—to conflict, Git declares a \"merge conflict\" for that file (and goes ahead and tries to merge anyway, but leaves conflict markers in place).\nOnce Git has merged everything it can, it either finishes the merge—because there were no conflicts—or stops with a merge conflict.\n\n1The merge base is obvious if you draw the commit graph. Without drawing the graph, it's kind of mysterious. This is why I always tell people to draw the graph, or at least, as much of it as needed to make sense.\nThe technical definition is that the merge base is the \"lowest common ancestor\" (LCA) node in the commit graph. In less technical terms, it's the most recent commit where your current branch joins up with the branch you're merging. That is, by recording each merge's parent commit IDs, Git is able to find the last time the two branches were together, and hence figure out both what you did, and what they did. For this to work at all, though, Git has to record each merge. Specifically, it has to write both (or all, for so-called \"octopus\" merges) parent IDs into the new merge commit.\nIn some cases, there's more than one suitable merge base. The process then depends on your merge strategy. The default recursive strategy will merge the multiple merge bases to produce a \"virtual merge base\". This is rare enough that you can ignore it for now.\n\nMerge, part 2: stopping with a conflict, and Git's \"index\"\nWhen Git does stop this way, it needs to give you a chance to resolve the conflicts. But this also means that it needs to record the conflicts, and this is where Git's \"index\"—also called \"the staging area\", and sometimes \"the cache\"—really earns its existence.\nFor every staged file in your work-tree, the index has up to four entries, rather than just one entry. At most three of these are ever actually in use, but there are four slots, which are numbered, 0 through 3.\nSlot zero is used for resolved files. When you're working with Git and not doing merges, only slot zero gets used. When you edit a file in the work tree, it has \"unstaged changes\", and then you git add the file and the changes are written to the repository, updating slot zero; your changes are now \"staged\".\nSlots 1-3 are used for unresolved files. When git merge has to stop with a merge conflict, it leaves slot zero empty, and writes everything to slots 1, 2, and 3. The merge base version of the file is recorded in slot 1, the --ours version is recorded in slot 2, and the --theirs version is recorded in slot 3. These nonzero slot entries are how Git knows that the file is unresolved.2\nAs you resolve files, you git add them, which erases all the slot 1-3 entries and writes a slot-zero, staged-for-commit entry. This is how Git knows the file is resolved and ready for a new commit. (Or, in some cases, you git rm the file, in which case Git writes a special \"removed\" value to slot zero, again erasing slots 1-3.)\n\n2There are a few cases where one of these three slots is also empty. Suppose file new does not exist in the merge base and is added in both ours and theirs. Then :1:new is left empty and :2:new and :3:new record the add/add conflict. Or, suppose file f does exist in the base, is modified in our HEAD branch, and is removed in their branch. Then :1:f records the base file, :2:f records our version of the file, and :3:f is empty, recording the modify/delete conflict.\nFor modify/modify conflicts, all three slots are occupied; only when one file is missing is one of these slots empty. It's logically impossible to have two empty slots: there's no such thing as a delete/delete conflict, nor a nocreate/add conflict. But there is some weirdness with rename conflicts, which I've omitted here as this answer is long enough! In any case, it's the very existence of some value(s) in slots 1, 2, and/or 3 that mark the file as unresolved.\n\nMerge, part 3: finishing the merge\nOnce all files are resolved—all entries are only in the zero-numbered slots—you can git commit the merge result. If git merge is able to do the merge without assistance, it normally runs git commit for you, but the actual commit is still done by running git commit.\nThe commit command works the same way as it always does: it turns the index contents into tree objects and writes a new commit. The only thing special about a merge commit is that it has more than one parent commit ID.3 The extra parents come from a file git merge leaves behind. The default merge message also comes from a file (a separate file in practice, although in principle they could have been combined).\nNote that in all cases, the new commit's contents are determined by the index's contents. Moreover, once the new commit is done, the index is still full: it still contains the same contents. By default, git commit won't make another new commit at this point because it sees that the index matches the HEAD commit. It calls this \"empty\" and requires --allow-empty to make an extra commit, but the index is not empty at all. It's still quite full—it just is full of the same thing as the HEAD commit.\n\n3This assumes you are making a real merge, not a squash merge. When making a squash merge, git merge deliberately does not write the extra parent ID to the extra file, so that the new merge commit has only a single parent. (For some reason, git merge --squash also suppresses the automatic commit, as if it included the --no-commit flag as well. It's not clear why, since you could just run git merge --squash --no-commit if you want the automatic commit suppressed.)\nA squash merge does not record its other parent(s). This means that if we go to merge again, some time later, Git won't know where to start the diffs from. This means you should generally only squash-merge if you plan to abandon the other branch. (There are some tricky ways to combine squash merges and real merges but they're well out of the scope of this answer.)\n\nHow git checkout branch uses the index\nWith all that out of the way, we then have to look at how git checkout uses Git's index, too. Remember, in normal usage, only slot zero is occupied, and the index has one entry for every staged file. Moreover, that entry matches the current (HEAD) commit unless you've modified the file and git add-ed the result. It also matches the file in the work-tree unless you've modified the file.4\nIf you are on some branch and you git checkout some other branch, Git tries to switch to the other branch. For this to succeed, Git has to replace the index entry for each file with the entry that goes with the other branch.\nLet's say, just for concreteness, that you're on master and you are doing git checkout branch. Git will compare each current index entry with the index entry it would need to be on the tip-most commit of branch branch. That is, for file README.txt, are the master contents the same as those for branch, or are they different?\nIf the contents are the same, Git can take it easy and just move on to the next file. If the contents are different, Git has to do something to the index entry. (It's around this point that Git checks to see if the work-tree file differs from the index entry, too.)\nSpecifically, in the case where branch's file differs from master's, git checkout has to replace the index entry with the version from branch—or, if README.txt doesn't exist in the tip commit of branch, Git has to remove the index entry. Moreover, if git checkout is going to modify or remove the index entry, it also needs to modify or remove the work-tree file. Git makes sure this is a safe thing to do, i.e., that the work-tree file matches the master commit's file, before it will let you switch branches.\nIn other words, this is how (and why) Git finds out whether it's OK to change branches—whether you have modifications that would be clobbered by switching from master to branch. If you have modifications in your work-tree, but the modified files are the same in both branches, Git can just leave the modifications in the index and work-tree. It can and will alert you to these modified files \"carried over\" into the new branch: easy, since it had to check for this anyway.\nOnce all the tests have passed and Git has decided that it's OK to switch from master to branch—or if you specified --force—git checkout actually updates the index with all the changed (or removed) files, and updates the work-tree to match.\nNote that all this action has used slot zero. There are no slot 1-3 entries at all, so that git checkout does not have to remove any such things. You're not in the middle of a conflicted merge, and you ran git checkout branch to not just check out one file, but rather an entire set of files and switch branches.\nNote also that you can, instead of checking out a branch, check out a specific commit. For instance, this is how you might look at a previous commit:\n$ git log\n... peruse log output ...\n$ git checkout f17c393 # let's see what's in this commit\n\nThe action here is the same as for checking out a branch, except that instead of using the tip commit of the branch, Git checks out an arbitrary commit. Instead of now being \"on\" the new branch, you're now on no branch:5 Git gives you a \"detached HEAD\". To reattach your head, you must git checkout master or git checkout branch to get back \"on\" the branch.\n\n4The index entry may not match the work-tree version if Git is doing special CR-LF ending modifications, or applying smudge filters. This gets pretty advanced and the best thing is to ignore this case for now. :-)\n5More accurately, this puts you on an anonymous (unnamed) branch that will grow from the current commit. You will stay in detached HEAD mode if you make new commits, and as soon as you git checkout some other commit or branch, you'll switch there and Git will \"abandon\" the commits you've made. The point of this detached HEAD mode is both to let you look around and to let you make new commits that will just go away if you don't take special action to save them. For anyone relatively new to Git, though, having commits \"just go away\" is not so good—so make sure you know that you're in this \"detached HEAD\" mode, whenever you are in it.\nThe git status command will tell you if you're in detached HEAD mode. Use it often.6 If your Git is old (the OP's is 1.7.1, which is very old now), git status is not as helpful as it is in modern versions of Git, but it's still better than nothing.\n6Some programmers like to have key git status information encoded into each command-prompt. I personally do not go this far, but can be a good idea.\n\nChecking out specific files, and why it sometimes resolves merge conflicts\nThe git checkout command has other modes of operation, though. In particular, you can run git checkout [flags etc] -- path [path ...] to check out specific files. This is where things get weird. Note that when you use this form of the command, Git does not check to make sure you are not overwriting your files.7\nNow, instead of changing branches, you're telling Git to get some particular file(s) from somewhere, and drop them into the work-tree, overwriting whatever is there, if anything. The tricky question is: just where is Git getting these files?\nGenerally speaking, there are three places that Git keeps files:\n\nin commits;8\nin the index;\nand in the work-tree.\n\nThe checkout command can read from either of the first two places, and always writes the result to the work-tree.\nWhen git checkout gets a file from a commit, it first copies it to the index. Whenever it does this, it writes the file to slot zero. Writing to slot zero wipes out slots 1-3, if they are occupied. When git checkout gets a file from the index, it does not have to copy it to the index. (Of course not: it's already there!) This is how git checkout works when you are not in the middle of a merge: you can git checkout -- path/to/file to get the index version back.9\nSuppose, though, that you are in the middle of a conflicted merge and are going to git checkout some path, maybe with --ours. (If you are not in the middle of a merge, there's nothing in slots 1-3, and --ours makes no sense.) So you run git checkout --ours -- path/to/file.\nThis git checkout gets the file from the index—in this case, from index slot 2. Since this is already in the index, Git does not write to the index, just to the work-tree. So the file is not resolved!\nThe same goes for git checkout --theirs: it gets the file from the index (slot 3), and does not resolve anything.\nBut: if you git checkout HEAD -- path/to/file, you are telling git checkout to extract from the HEAD commit. Since this is a commit, Git starts by writing the file contents to the index. This writes slot 0 and erases 1-3. And now the file is resolved!\nSince, during a conflicted merge, Git records the being-merged commit's ID in MERGE_HEAD, you can also git checkout MERGE_HEAD -- path/to/file to get the file from the other commit. This, too, extracts from a commit, so it writes to the index, resolving the file.\n\n7I often wish Git used a different front-end command for this, since we could then say, unequivocally, that git checkout is safe, that it won't overwrite files without --force. But this kind of git checkout does overwrite files, on purpose!\n8This is a bit of a lie, or at least a stretch: commits don't contain files directly. Instead, commits contain a (single) pointer to a tree object. This tree object contains the IDs of additional tree objects and of blob objects. The blob objects contain the actual file contents.\nThe same is, in fact, true of the index as well. Each index slot contains, not the actual file contents, but rather the hash IDs of blob objects in the repository.\nFor our purposes, though, this doesn't really matter: we just ask Git to retrieve commit:path and it finds the trees and the blob ID for us. Or, we ask Git to retrieve :n:path and it finds the blob ID in the index entry for path for slot n. Then it gets us the file's contents, and we're good to go.\nThis colon-and-number syntax works everywhere in Git, while the --ours and --theirs flags only work in git checkout. The funny colon syntax is described in gitrevisions.\n9The use-case for git checkout -- path is this: suppose, whether or not you are merging, you made some changes to a file, tested, found those changes worked, then ran git add on the file. Then you decided to make more changes, but have not run git add again. You test the second set of changes and find they are wrong. If only you could get the work-tree version of the file set back to the version you git add-ed just a moment ago.... Aha, you can: you git checkout -- path and Git copies the index version, from slot zero, back to the work-tree.\n\nSubtle behavior warning\nNote, though, that using --ours or --theirs has another slight subtle difference besides just the \"extract from index and therefore don't resolve\" behavior. Suppose that, in our conflicted merge, Git has detected that some file was renamed. That is, in the merge base, we had file doc.txt, but now in HEAD we have Documentation/doc.txt. The path we need for git checkout --ours is Documentation/doc.txt. This is also the path in the HEAD commit, so it's OK to git checkout HEAD -- Documentation/doc.txt.\nBut what if, in the commit we're merging, doc.txt did not get renamed? In this case, we should10 be able to git checkout --theirs -- Documentation/doc.txt to get their doc.txt from the index. But if we try to git checkout MERGE_HEAD -- Documentation/doc.txt, Git won't be able to find the file: it's not in Documentation, in the MERGE_HEAD commit. We have to git checkout MERGE_HEAD -- doc.txt to get their file ... and that would not resolve Documentation/doc.txt. In fact, it would just create ./doc.txt (if it was renamed there's almost certainly no ./doc.txt, hence \"create\" is a better guess than \"overwrite\").\nBecause merging uses HEAD's names, it's generally safe enough to git checkout HEAD -- path to extract-and-resolve in one step. And if you're working on resolving files and have been running git status, you should know whether they have a renamed file, and therefore whether it's safe to git checkout MERGE_HEAD -- path to extract-and-resolve in one step by discarding your own changes. But you should still be aware of this, and know what to do if there is a rename to be concerned with.\n\n10I say \"should\" here, not \"can\", because Git currently forgets the rename a little bit too soon. So if using --theirs to get a file that you renamed in HEAD, you have to use the old name here too, and then rename the file in the work-tree."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "SourceTree keeps asking for Github password\nMy organization is switching from Bitbucket to Github for project management. Today, I was trying to transfer our most recent project from Bitbucket to Github, by using SourceTree. I added a second remote repository to the project (using the URL of the destination repository on Github), brought everything up to date, and then attempted to push the code to the repository. A box popped up, asking for the password to my Github account. I entered in my (correct) password, and clicked 'OK', and the dialog box popped up again. I entered in my password (correctly) again, and it did the same thing.\nMy username is correctly identified, my password is correct, and I tried updating SourceTree because I had heard that it was an issue with a previous version. The problem persists.\nI am using SourceTree 2.3.1"
},
{
"role": "assistant",
"content": "If you are using two-factor authentication with GitHub you will need to create a personal access token and use it with SourceTree:\n\nTo work with GitHub's two-factor authentication in SourceTree you can simply use your access token instead of your password. The steps to do this are as follows:\n\nGo to your Personal Access Tokens settings in GitHub.\nClick on the Generate new token button.\nName the token something descriptive.\nSelect which scopes you wish to grant this token.\nClick the Generate token button.\nCopy the token and use it as a password in your hosted repositories.\n\nYou can find more information about this on GitHub's help here.\n\nMac Users:\nIf your SourceTree keeps on asking for the password, go to the Terminal and type this:\ngit config --global credential.helper osxkeychain"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Configure Lerna to publish NPM packages to private Gitlab repo\n\nI'm doing some tests with Lerna to create a mono-repo with a bunch of packages that I'd like to share with some applications. I've followed Lerna's documentation to setup a project and this is the file structure:\n- lernatest/\n - lerna.json\n - package.json\n - packages/\n - common\n - src/\n - index.ts\n - .npmrc\n - package.json\n - models\n - src\n - index.ts\n - .npmrc\n - package.json\n\nI need to publish the packages to a private project inside my Gitlab account. Before using Lerna, I could do it manually on each package adding a .npmrc file with the following content:\n@mypackages:registry=https://gitlab.com/api/v4/packages/npm/\n//gitlab.com/api/v4/projects/<PROJECT_ID>/packages/npm/:_authToken=<TOKEN>\n//gitlab.com/api/v4/packages/npm/:_authToken=<TOKEN>\n\nAnd in each package.json file:\n{\n \"name\": \"@mypackages/common\",\n \"publishConfig\": {\n \"@mypackages:registry\": \"https://gitlab.com/api/v4/projects/<PROJECT_ID>/packages/npm/\"\n }\n (ETC...)\n}\n\nI don't know how to configure Lerna properly to publish the packages to my Gitlab registry. This is my lerna.json file:\n{\n \"version\": \"0.0.5\",\n \"packages\": [\n \"packages/*\"\n ],\n \"command\": {\n \"publish\": {\n \"registry\": \"https://gitlab.com/api/v4/projects/<PROJECT_ID>/packages/npm/\"\n }\n }\n}\n\nBut when I run npx lerna publish, I get the following error:\nlerna info publish Publishing packages to npm...\nlerna notice Skipping all user and access validation due to third-party registry\nlerna notice Make sure you're authenticated properly ¯\\_(ツ)_/¯\nlerna http fetch PUT 401 https://gitlab.com/api/v4/projects/<PROJECT_ID>/packages/npm/@mypackages%2fcommon 462ms\nlerna ERR! E401 401 Unauthorized - PUT https://gitlab.com/api/v4/projects/<PROJECT_ID>/packages/npm/@mypackages%2fgcommon\n\nI've tried searching the documentation but I can't find anything helpful, any ideas?\nThanks!"
},
{
"role": "assistant",
"content": "It seems that the .npmrc files in each package are ignored when publishing. I've created a single .npmrc file in the root of the project with the needed authentication data and now it works like a charm.\nThis is how my .npmrc file looks like:\n@mypackages:registry=https://gitlab.com/api/v4/packages/npm/\n//gitlab.com/api/v4/projects/<PROJECT_ID>/packages/npm/:_authToken=<TOKEN>\n//gitlab.com/api/v4/packages/npm/:_authToken=<TOKEN>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to recover from a git push -force?\nHere is what happened:\nI have two remote git branches: master and feature1. For some reason I have to use git push --force for the feature1 branch, but I didn't know when I use git push --force it will also push the master branch. Then, a disaster happened, as I pushed my local master branch to the remote repository.\nLuckily, my local branch is not too far away from the remote. Basically, my remote master has two pull requests merged ahead of my local master.\nSo my problem is: can I reopen the pull request and remerge? I noticed that there is commit version for merge request, so I am worried if I simply make new pull request it will mess up something? Ideally I just want to redo the merging of the two requests.\nIs there some other way to recover from this disaster? I learned the --force is a really, really bad choice. :(\nUpdate, example of what happened:\nI have following branches:\nmaster\nfeature1\norigin/master\norigin/feature1\n\nI integrate two pull requests by using the GitHub's Auto merge pull requests. Then, I didn't fetch the master branch on my local machine. Thus, I think my origin/master is two versions behind the remote master.\nThen I accidentally used git -f push, which overwrote the remote branch and now I lost the commits from the pull requests on remote repository.\nHow can I recover from it without messing up other contributors' history?"
},
{
"role": "assistant",
"content": "When working with github, refer to GHugo's answer which gives a foolproof procedure with github. If you're on an in-house (or other non-github) installation, read on.\nYou can always restore the previously observed state of master, by resetting to the old commit and issuing another push -f. The steps involved typically look like this:\n# work on local master\ngit checkout master\n\n# reset to the previous state of origin/master, as recorded by reflog\ngit reset --hard origin/master@{1}\n\n# at this point verify that this is indeed the desired commit.\n# (if necessary, use git reflog to find the right one, and\n# git reset --hard to that one)\n\n# finally, push the master branch (and only the master branch) to the server\ngit push -f origin master\n\nNote, however, that this restores remote master to the state most recently retrieved by git fetch or equivalent. Any commits pushed by others after the last time you fetched will be lost. However, those commits will still be available in their reflogs, so they can restore them using steps like the above."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is there a difference between git rebase and git merge --ff-only\nFrom what I read, both of them help us get a linear history. \nFrom what I experimented, rebase works all the time. But merge --ff-only works only in scenarios where it can be fast forwarded.\nI also noticed, git merge creates a merge commit, but if we use --ff-only, it gives a linear history which essentially is equal to git rebasing. So --ff-only kills the purpose of git merge, right?\nSo what is the actual difference between them?"
},
{
"role": "assistant",
"content": "Note that git rebase has a different job than git merge (with or without --ff-only). What rebase does is to take existing commits and copy them. Suppose, for instance, that you're on branch1 and have made two commits A and B:\n...-o--o--A--B <-- HEAD=branch1\n \\\n o--C <-- branch2\n\nand you decide that you'd rather have those two commits be on branch2 instead. You can:\n\nget a list of changes you made in A (diff A against its parent)\nget a list of changes you made in B (diff B against A)\nswitch to branch2\nmake the same changes you made in A and commit them, copying your commit message from A; let's call this commit A'\nand then make the same changes you made in B and commit them, copying your commit message from B; let's call this B'.\n\nThere's a git command that does this diff-and-then-copy-and-commit for you: git cherry-pick. So:\ngit checkout branch2 # switch HEAD to branch2 (commit C)\ngit cherry-pick branch1^ # this copies A to A'\ngit cherry-pick branch1 # and this copies B to B'\n\nNow you have this:\n...-o--o--A--B <-- branch1\n \\\n o--C--A'-B' <-- HEAD=branch2\n\nNow you can switch back to branch1 and delete your original A and B, using git reset (I'll use --hard here, it's more convenient that way as it cleans up the work-tree too):\ngit checkout branch1\ngit reset --hard HEAD~2\n\nThis removes the original A and B,1 so now you have:\n...-o--o <-- HEAD=branch1\n \\\n o--C--A'-B' <-- branch2\n\nNow you just need to re-check-out branch2 to continue working there.\nThis is what git rebase does: it \"moves\" commits (though not by actually moving them, because it can't: in git, a commit can never be changed, so even just changing the parent-ID requires copying it to new and slightly different commit).\nIn other words, while git cherry-pick is an automated diff-and-redo of one commit, git rebase is an automated process of redoing multiple commits, plus, at the end, moving labels around to \"forget\" or hide-away the originals.\nThe above illustrates moving commits from one local branch branch1 to another local branch branch2, but git uses the exact same process to move commits when you have a remote-tracking branch that acquires some new commits when you do a git fetch (including the fetch that is the first step of git pull). You might start by working on branch feature, that has an upstream of origin/feature, and make a couple of commits of your own:\n...-o <-- origin/feature\n \\\n A--B <-- HEAD=feature\n\nBut then you decide you should see what has happened upstream, so you run git fetch,2 and, aha, someone upstream wrote a commit C:\n...-o--C <-- origin/feature\n \\\n A--B <-- HEAD=feature\n\nAt this point you can simply rebase your feature's A and B onto C, giving:\n...-o--C <-- origin/feature\n \\\n A'-B' <-- HEAD=feature\n\nThese are copies of your original A and B, with the originals being thrown away (but see footnote 1) after the copies are complete.\n\nSometimes there's nothing to rebase, i.e., no work that you yourself did. That is, the graph before the fetch look like this:\n...-o <-- origin/feature\n `-- HEAD=feature\n\nIf you then git fetch and commit C comes in, though, you're left with your feature branch pointing to the old commit, while origin/feature has moved forward:\n...-o--C <-- origin/feature\n `---- <-- HEAD=feature\n\nThis is where git merge --ff-only comes in: if you ask to merge your current branch feature with origin/feature, git sees that it's possible to just slide the arrow forward, as it were, so that feature points directly to commit C. No actual merge is required.\nIf you had your own commits A and B, though, and you asked to merge those with C, git would do a real merge, making a new merge commit M:\n...-o--C <-- origin/feature\n \\ `-_\n A--B--M <-- feature\n\nHere, --ff-only will stop and give you an error. Rebase, on the other hand, can copy A and B to A' and B' and then hide away the original A and B.\nSo, in short (ok, too late :-) ), they simply do different things. Sometimes the result is the same, and sometimes it's not. If it's OK to copy A and B, you can use git rebase; but if there's some good reason not to copy them, you can use git merge, perhaps with --ff-only, to merge-or-fail as appropriate.\n\n1Git actually keeps the originals for some time—normally a month in this case—but it hides them away. The easiest way to find them is with git's \"reflogs\", which keep a history of where each branch pointed, and where HEAD pointed, before each change that updated the branch and/or HEAD.\nEventually the reflog history entries expire, at which point these commits become eligible for garbage collection.\n2Or, again, you can use git pull, which is a convenience script that starts by running git fetch. Once the fetch is done, the convenience script runs either git merge or git rebase, depending on how you configure and run it."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitlab 6.0.2 Jenkins CI services not showing\n\nI have a gitlab server version \"Gitlab 6.0.2 10b0b8f\". I want to connect \"Jenkins CI\" for build purpose. for this I am following - http://doc.gitlab.com/ee/integration/jenkins.html .But In a project services I am not able to see \"Jenkins CI\". Only I can See \"Gitlab CI\". Can you please help me. Any example will be appriciated."
},
{
"role": "assistant",
"content": "Solved. Jenkins CI support is only included in the Enterprise version (EE). gitlab server version \"Gitlab 6.0.2 10b0b8f\" is not a enterprise edition. so it is not possible. Check \nhttps://github.com/gitlabhq/gitlabhq/issues/7525"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Deleting remote master branch, refused due to being the current branch\nHow do I delete a remote master branch from GitHub/Bitbucket?\nI'm trying:\n# git push bb --delete master\nremote: bb/acl: user is allowed. accepted payload.[K\nremote: error: refusing to delete the current branch: refs/heads/master[K\nTo ssh://[email protected]/user/reponame.git\n ! [remote rejected] master (deletion of the current branch prohibited)\nerror: failed to push some refs to 'ssh://[email protected]/user/reponame.git' \n\nAlso I tried\ngit push bb :master\n\nBut all this does not work."
},
{
"role": "assistant",
"content": "Note: for Bitbucket, you would change the default branch by accessing the settings of your repository, and changing the branch at the \"Main branch\" combo box.\n\nOnce the main branch is no longer master, then you can push and remove master.\nMarsAndBack confirms in the comments this applies to GitHub as well."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to fix: error: '<filename>' does not have a commit checked out fatal: adding files failed when inputting \"git add .\" in command prompt\nI'm trying to add a ruby rails file to my repository in gitlab, but it doesn't allow me to add the file saying that my file does not have a commit checked out.\nI've tried git pull, and making the the file again and git adding it, but it still doesn't work. This is the error message I get:\nerror: '172069/08_lab_routes_controllers_views_172069_172188-Copy/adventure_game/' does not have a commit checked out\nfatal: adding files failed"
},
{
"role": "assistant",
"content": "If you have a subdirectory with a .git directory and try to git add . you will see this message.\nThis can happen if you have a git repo and then create/clone another repo in a subdirectory under that repo."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects %cr"
},
{
"role": "assistant",
"content": "committer date, relative"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-worktree - Manage multiple working trees --expire <time>"
},
{
"role": "assistant",
"content": "With prune , only expire unused worktrees older than <time> . With list , annotate missing worktrees as prunable if they are older than <time> ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options revert.reference"
},
{
"role": "assistant",
"content": "Setting this variable to true makes git revert behave\nas if the --reference option is given."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order --indexed-objects"
},
{
"role": "assistant",
"content": "Pretend as if all trees and blobs used by the index are listed\non the command line. Note that you probably want to use --objects , too."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitfaq - Frequently asked questions about using Git How do I use multiple accounts with the same hosting provider using SSH?"
},
{
"role": "assistant",
"content": "With most hosting providers that support SSH, a single key pair uniquely\nidentifies a user. Therefore, to use multiple accounts, it’s necessary\nto create a key pair for each account. If you’re using a reasonably\nmodern OpenSSH version, you can create a new key pair with something\nlike ssh-keygen -t ed25519 -f ~/.ssh/id_committer . You can then\nregister the public key (in this case, ~/.ssh/id_committer.pub ; note\nthe .pub ) with the hosting provider. Most hosting providers use a single SSH account for pushing; that is, all users\npush to the git account (e.g., [email protected] ). If that’s the case for\nyour provider, you can set up multiple aliases in SSH to make it clear which key\npair to use. For example, you could write something like the following in ~/.ssh/config , substituting the proper private key file: # This is the account for author on git.example.org.\nHost example_author\n\tHostName git.example.org\n\tUser git\n\t# This is the key pair registered for author with git.example.org.\n\tIdentityFile ~/.ssh/id_author\n\tIdentitiesOnly yes\n# This is the account for committer on git.example.org.\nHost example_committer\n\tHostName git.example.org\n\tUser git\n\t# This is the key pair registered for committer with git.example.org.\n\tIdentityFile ~/.ssh/id_committer\n\tIdentitiesOnly yes Then, you can adjust your push URL to use git@example_author or git@example_committer instead of [email protected] (e.g., git remote set-url\ngit@example_author:org1/project1.git )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc default , myers"
},
{
"role": "assistant",
"content": "The basic greedy diff algorithm. Currently, this is the default."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Remove a file from the list that will be committed\nI have a list of changed files in git repository. There is one file I don't wanna commit for the current moment. Can I do:\ngit commit -a\n\nTo commit all files and then somehow remove that file from current commit? After such removing it should still be in the list of uncommited files."
},
{
"role": "assistant",
"content": "You want to do this:\ngit add -u\ngit reset HEAD path/to/file\ngit commit\n\nBe sure and do this from the top level of the repo; add -u adds changes in the current directory (recursively).\nThe key line tells git to reset the version of the given path in the index (the staging area for the commit) to the version from HEAD (the currently checked-out commit).\nAnd advance warning of a gotcha for others reading this: add -u stages all modifications, but doesn't add untracked files. This is the same as what commit -a does. If you want to add untracked files too, use add . to recursively add everything."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitLab email notifications not sending\n\nI just recently install GitLab v5.0 on an Ubuntu 12.04 server and am now having issues with email notifications. I can't get GitLab to send any emails of any kind.\nI've got my config/environments/production.rb file setup to use sendmail as the transport service:\nconfig.action_mailer.delivery_method = :sendmail\nconfig.action_mailer.perform_deliveries = true\nconfig.action_mailer.raise_delivery_errors = true\n\nAnd I can manually use sendmail successfully from the shell as described here: http://scratching.psybermonkey.net/2011/03/sendmail-how-to-test-sending-email.html\nMy config/gitlab.yml file is setup with the following email setting:\nemail_from: [email protected]\n\nI've read that it could be a problem with Sidekiq not running so I ran the following command but nothing has changed.. I still can't send emails:\n$ sudo -u git -H bundle exec rake sidekiq:start RAILS_ENV=production\n$ ps aux |grep -i sidekiq\ngit 2791 2.1 4.2 206476 86620 pts/0 Sl 14:45 0:23 sidekiq 2.7.5 gitlab [0 of 25 busy] \n\nWhich indicates to me that Sidekiq is indeed running... what else could be the issue here? There doesn't seem to be much documentation on GitLab's wiki regarding email settings unfortunately...\nI found the following error being logged in sidekiq.log:\n2013-04-24T21:09:01Z 2791 TID-1jaur8 Sidekiq::Extensions::DelayedMailer JID-21bd3ec0f086351088992396 INFO: start\n2013-04-24T21:09:01Z 2791 TID-1jaur8 Sidekiq::Extensions::DelayedMailer JID-21bd3ec0f086351088992396 INFO: fail: 0.004 sec\n2013-04-24T21:09:01Z 2791 TID-1jaur8 WARN: {\"retry\"=>true, \"queue\"=>\"default\", \"timeout\"=>30, \"class\"=>\"Sidekiq::Extensions::DelayedMailer\", \"args\"=>[\"---\\n- !ruby/class 'Notify'\\n- :new_user_email\\n- - 4\\n - pSzzULp8\\n\"], \"at\"=>1366819034.5969028, \"jid\"=>\"21bd3ec0f086351088992396\", \"error_message\"=>\"Couldn't find User with id=4\", \"error_class\"=>\"ActiveRecord::RecordNotFound\", \"failed_at\"=>\"2013-04-24T15:57:19Z\", \"retry_count\"=>10, \"retried_at\"=>2013-04-24 21:09:01 UTC}\n2013-04-24T21:09:01Z 2791 TID-1jaur8 WARN: Couldn't find User with id=4\n2013-04-24T21:09:01Z 2791 TID-1jaur8 WARN: /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:343:in `find_one'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:314:in `find_with_ids'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:107:in `find'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/querying.rb:5:in `find'\n/home/git/gitlab/app/mailers/notify.rb:23:in `new_user_email'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:167:in `process_action'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:121:in `process'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb:45:in `process'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.13/lib/action_mailer/base.rb:459:in `process'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.13/lib/action_mailer/base.rb:453:in `initialize'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.13/lib/action_mailer/base.rb:439:in `new'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.13/lib/action_mailer/base.rb:439:in `method_missing'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/extensions/action_mailer.rb:20:in `perform'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/processor.rb:45:in `block (3 levels) in process'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/chain.rb:109:in `call'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/chain.rb:109:in `block in invoke'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/server/timeout.rb:11:in `block in call'\n/usr/local/lib/ruby/1.9.1/timeout.rb:68:in `timeout'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/server/timeout.rb:10:in `call'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/chain.rb:111:in `block in invoke'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/server/active_record.rb:6:in `call'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/chain.rb:111:in `block in invoke'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/server/retry_jobs.rb:49:in `call'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/chain.rb:111:in `block in invoke'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/logging.rb:22:in `with_context'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/server/logging.rb:7:in `call'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/chain.rb:111:in `block in invoke'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/chain.rb:114:in `call'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/middleware/chain.rb:114:in `invoke'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/processor.rb:44:in `block (2 levels) in process'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/processor.rb:80:in `stats'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.7.5/lib/sidekiq/processor.rb:43:in `block in process'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/calls.rb:23:in `call'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/calls.rb:23:in `public_send'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/calls.rb:23:in `dispatch'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/future.rb:18:in `block in initialize'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/internal_pool.rb:48:in `call'\n/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/internal_pool.rb:48:in `block in create'\n\nAny ideas?"
},
{
"role": "assistant",
"content": "This is my entries at the end in /config/environment/production.rb and that is working for me.\n\nComment out sendmail options and use external SMTP relays\n ##config.action_mailer.delivery_method = :sendmail ## Comment out this\n # Defaults to:\n ## config.action_mailer.sendmail_settings = {\n ## :location => '/usr/sbin/sendmail',\n ## :arguments => '-i -t'\n ## }\n\n config.action_mailer.perform_deliveries = true\n config.action_mailer.raise_delivery_errors = true\n\n ## SMTP Settings\n config.action_mailer.delivery_method = :smtp\n config.action_mailer.smtp_settings = {\n :address => '10.146.10.90', ## My SMTP Relay/Gateway\n :port => 25, ## SMTP Port\n :domain => 'gitlab.example.com', ## My Domain\n :authentication => :plain, ## Let it be plain as it is inside my LAN\n ##:user_name => '[email protected]', ## This is not required as long as \n ##:password => 'yourPassword', ## SMTP Gateway allows anonymous relay\n ##:enable_starttls_auto => true ## In LAN\n ##:user_name => '',\n ##:password => '',\n :enable_starttls_auto => true\n }\nend"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout - Switch branches or restore working tree files -d --detach"
},
{
"role": "assistant",
"content": "Rather than checking out a branch to work on it, check out a\ncommit for inspection and discardable experiments.\nThis is the default behavior of git checkout <commit> when <commit> is not a branch name. See the \"DETACHED HEAD\" section\nbelow for details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to find the branch from commit id\n\nSo, I am trying to find branch name in which a given commit was made. (c853d8cf3ae34dae9866b874b96c6529515d7e90)\nI have the parent id and commit id referenced on the git issue.\nHow can I find that given commit id was pushed in 'x' branch?"
},
{
"role": "assistant",
"content": "On GitHub specifically, you now can see the branch a given commit is part of.\nThe blog post \"Branch and Tag Labels For Commit Pages\" details:\n\nIf the commit is not on the default branch, the indicator will show the branches which contain the commit.\nIf the commit is part of an unmerged pull request, a link will be shown.\n\n\n\nOnce the commit makes it to the default branch, any tags that contain the commit will be shown, and the default branch will be the only branch listed.\n\n\n\nOriginal answer\nYou can list those branches:\ngit branch --contains <commit>\n\n# in your case\ngit branch --contains <commit> | grep x\n\nMore details in \"Git: Finding what branch a commit came from\".\nDon't forget that a commit can be part of several branches."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to move a project from Git to TFS in Visual Studio\nI have a project that I've been working on for some time now and I just cannot make Git work for me. I've spent a day trying to recover lost code and I am done with Git.\nCan anyone tell me how to move an existing project into TFVC? I have a Visual Studio Online account with a TFVC project all set up for this task, but I cannot figure out how to change the source control settings so that the project is no longer tied to Git.\nI am currently developing on VS 2013.\nAny help is greatly appreciated!"
},
{
"role": "assistant",
"content": "Just delete the .git folder (this one is normally hidden) in the root folder (f.e. via Windows Explorer). This deletes all things related to git. After that add the code to your TFS project and check it in into TFS."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options color.pager"
},
{
"role": "assistant",
"content": "A boolean to specify whether auto color modes should colorize\noutput going to the pager. Defaults to true; set this to false\nif your pager does not understand ANSI color codes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge-base - Find as good common ancestors as possible for a merge"
},
{
"role": "assistant",
"content": "See also git-rev-list , git-show-branch , git-merge"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Bash and Pageant are not using keys\nI've got Git for Windows (configured for MinTTY and PuTTY\\plink.exe) and PuTTY installed, and I am trying to get it to work with a Bitbucket repository. I've got my SSH key loaded, in Pageant and on the website, and yet whenever I attempt to do anything that requires pulling/pushing:\nPermission denied (publickey).\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\nWhen I run the suggested ssh -v [email protected] it uses id_rsa but none of my other keys in ~/.ssh. Trying to use ssh-add ~/.ssh/bitbucket_rsa results in:\nCould not open a connection to your authentication agent.\n\nI've read about configuring PuTTY to allow forwarding, but that's usually where the advice ends, so I just set this option for the default session and saved it there.\nI've run ps to check which applications were running, and ssh-agent was not among them. Running eval 'ssh-agent' starts the daemon, but it makes no difference."
},
{
"role": "assistant",
"content": "This is what ended up working for me.\nBTW, I do have Bash on Windows as well, but I don't think that matters.\nI had Sourcetree installed and pointed at its folder with plink.exe, puttygen.exe, & pageant.exe. You could also download and install these separately as well.\nConfigure Windows Environment Variable\n\nType Environment into your Windows 10 search bar. Otherwise, open up System Properties / Advanced System Settings and find your Environment Variables.\nAdd a new System variable\n\nVariable Name: GIT_SSH\nVariable Value: full path to plink.exe file (you may also have pageant.exe and puttygen.exe in the same folder).\n\nMine was: C:\\Program Files (x86)\\Atlassian\\SourceTree\\tools\\putty\\plink.exe\n\nNote: Newer versions of Sourcetree seem to install ot %localappdata%. The tools are located at %localappdata%\\SourceTree\\app-x.x.x\\tools\\putty\n\nNote: The newer Sourcetree (v2 on Windows) uses versioned directories, so every time you update it, you'll have to update this which is a pain. It is best to just make a copy of plink.exe and put it somewhere that's not going to change.\n\nIf you have any of the above programs running you can always open up task manager, find the process, and open up the folder location to get the path to plink.exe.\n\n\n\n\n\n\nProfit\nMake sure to restart your terminals so that they get the updated environment variables. For me, I was running Bash for my integrated terminal within Visual Studio Code, so I had to restart Visual Studio Code. It would have surely been acceptable to close the integrated terminal and open a new one, but I also wanted the built in git functionality in Visual Studio Code to work as well.\nNote\nGiven that I have Sourcetree installed I was able to use its interface to clone down out of Bitbucket and push through its interface, but trying through terminals was not working, because they were using a different credential set.\nAnother interesting thing to point out is that if you navigate into your project's git configuration located at: ./.git/config, you could swap out your remote from using SSH to HTTPS. You can grab the following values from your Overview on your Bitbucket repository.\n\nssh layout: [email protected]:USERNAME/REPO_NAME.git\nhttps layout: https://[email protected]/USERNAME/REPO_NAME.git\n\nI noticed while using HTTPS on Windows 10 it then will use the Windows Credential Manager (I tried adding my credentials to it while trying to figure this out myself, but I was still using SSH so it didn't matter) When you go to interact with the remote repository it will prompt you for your credentials and store them for later use in Windows Credential Manager :)\nHopefully one of these methods will work out for you. The HTTPS method will skip the whole SSH key generation and pushing it up into Bitbucket, but it feels more secure and portable for me.\nMac OS\nYou may need to add your key to the keychain especially if you're using Visual Studio Code and have a passphrase on your key (currently Visual Studio Code will not allow you to type in a passphrase).\nssh-add -K ~/.ssh/id_rsa\n\nhttps://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#adding-your-ssh-key-to-the-ssh-agent\nAdditions\nI'm not sure if these may be helpful for someone, but I've been following getting SSH support into Visual Studio Code for Windows: https://github.com/Microsoft/vscode/issues/13680.\n\nhttps://github.com/PowerShell/openssh-portable\nhttps://github.com/rupor-github/ssh-agent-wsl"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git move directory to another repository while keeping the history\nFirst - apologies for asking this question. There are a lot of topics about it already. But I'm not having much luck with them. My lack of familiarity with git is not much help.\nI'm moving a folder from one git repo to another (which already exists). e.g.\nrepo-1\n---- dir1\n---- dir2\n---- dir3\n---- dir-to-move\n---- dir5\n\nrepo-2\n---- dir1\n---- dir2\n---- dir3\n\nIn the end I want the repos to look like\nrepo-1\n---- dir1\n---- dir2\n---- dir3\n---- dir-to-move\n---- dir5\n\nrepo-2\n---- dir1\n---- dir2\n---- dir3\n---- dir-to-move\n\ni.e. For a time dir-to-move will exist in both repos. But eventually I'll migrate the latest changes to repo-2 and remove dir-to-move from repo-1. \nMy initial research made me believe that I needed to use filter-branch. e.g.\nHow to move files from one git repo to another preserving history using `git format-patch`and `git am`\nI've since learnt that subtree superseded that approach. However it's not doing what I expected. I thought I'd be able to do something like\nIn repo-1 workspace\ngit subtree split -P dir-to-move -b split\n\nto filter the split branch down to only dir-to-move and it's history.\nThen in repo-2 workspace\ngit remote add repo-1 repo-1-url.git\ngit subtree add --prefix dir-to-move split\n\nThis does move the code across. It also, sort of, includes the history\ne.g.\ncd repo-2\ngit log\n\nShows commits from repo-1\nbut\ncd repo-2\ngit log dir-to-move\n\nShows only an 'Add dir-to-move from commit ....'\ni.e. The history is included but does not show up when checked for the specific files/directories.\nHow can I do this properly?"
},
{
"role": "assistant",
"content": "This is indeed possible using git subtree.\nIn repo-1 create a subtree:\ngit subtree split -P dir-to-move -b <split>\n\nThe split branch will now only contain the dir-to-move directory.\nYou now need to pull the branch from repo-1 into a branch in repo-2.\nIn case repo-2 happens to be a new repository (e.g. just after git init) Things are as easy as checking out a branch with no history and pulling from repo-1.\ncd repo-2\ngit checkout <branch>\ngit pull <path-to-repo-1.git> <split>\n\nHowever if repo-2 is an existing repo where commits have already been made (as is the case in this question), you need to merge from an orphan branch in repo-2:\ncd repo-2\ngit checkout --orphan <temp> # Create a branch with no history\ngit pull <path-to-repo-1.git> <split> # Pull the commits from the subtree\ngit checkout <branch> # Go back to the original branch\ngit merge --allow-unrelated-histories <temp> # Merge the unrelated commits back\ngit branch -d <temp> # Delete the temporary branch"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git warning: push.default is unset; its implicit value is changing\nWhen I push to remote in Git, I get this warning:\nwarning: push.default is unset; its implicit value is changing in\nGit 2.0 from 'matching' to 'simple'. To squelch this message\nand maintain the current behavior after the default changes, use:\n\n git config --global push.default matching\n\nTo squelch this message and adopt the new behavior now, use:\n\n git config --global push.default simple\n\nSee 'git help config' and search for 'push.default' for further information.\n(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode\n'current' instead of 'simple' if you sometimes use older versions of Git)\n\nTo **********************************\n 6b9a6d2..3ab1eab master -> master\n\nWhat does this warning mean and what should be done about it?"
},
{
"role": "assistant",
"content": "This warning was introduced in Git 1.7.11 along with the simple style of pushing. The issue is that the current default, matching, can result in inexperienced users force pushing when some branches are behind their remote equivalent because the branches simply aren't up-to-date. The end result is that they end up rewinding the branch and potentially losing their work or someone else's. The simple mode was introduced as a new push.default behavior and will become the default in Git 2.0 (which should hopefully be out sometime early next year).\nThe new simple behavior is a lot like the upstream setting: it only pushes the current branch that you're currently on, if it has a remote branch that it's tracking. It adds one extra criteria: the remote branch must have the same name as the local one.\nAs you discovered, the way to get rid of the message is to set push.default. To get the new behavior, use:\ngit config --global push.default simple\n\nTo get Git's default behavior but without the warning message, use:\ngit config --global push.default matching\n\nI'd really advise against using matching though. In general, most people really want the new simple behavior, or upstream."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to use git flow in GitLab\n\nWe're using GitLab for our project and we think it's great.\nWe're also using git flow to manage the changes in feature, develop, master branches.\nCan you use the Merge Request build in GitLab to manage the branches in git flow style? \nMeaning when accepting a Merge Request for a release branch, it will merge the release branch into master AND into develop.. \nOr should we always use git flow on our local machines to accept the Merge Requests."
},
{
"role": "assistant",
"content": "Like this issue 1628 illustrates, it is best to use GitLab to publish (push) branches, then to rely on a specific GitLab feature related to a particular workflow like git-flow.\nSo the natural approach is to limit those git-flow features to the local clones, and push to GitLab any branch you want, once the merge request is resolved."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order --grep=<pattern>"
},
{
"role": "assistant",
"content": "Limit the commits output to ones with a log message that\nmatches the specified pattern (regular expression). With\nmore than one --grep=<pattern> , commits whose message\nmatches any of the given patterns are chosen (but see --all-match )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Strategy for preventing or catching git history rewrite\nAlthough I love the git history rewrite feature, how does one go about ensuring history isn't rewritten. \nWe dont mind what a programmer does on their own machine, but we need to ensure that a version is not pushed to the server that changes history.\nie We need to guarantee that a particular version from the past really was that version. So this would include preventing someone going through and permanently removes a file from the history, or permanently alters a file throughout all history."
},
{
"role": "assistant",
"content": "If you can run:\n git config --system receive.denyNonFastforwards true\n\non the server, that should take care of rewriting history case being pushed to said server.\nHowever that is for the all repo, not for a specifc file or group of files.\ngit config:\n\nreceive.denyNonFastForwards\nIf you rebase commits that you’ve already pushed and then try to push again, or otherwise try to push a commit to a remote branch that doesn’t contain the commit that the remote branch currently points to, you’ll be denied. This is generally good policy; but in the case of the rebase, you may determine that you know what you’re doing and can force-update the remote branch with a -f flag to your push command.\nThe other way you can do this is via server-side receive hooks, which I’ll cover in a bit. That approach lets you do more complex things like deny non-fast-forwards to a certain subset of users.\n\n\nAs ebneter (who knows the importance of a coherent repository -- see the answer about SVN to Git migrations [question now deleted, 10K+ users only]) comments:\n\nYou might want to also add receive.denyDeletes true because otherwise, someone can just delete the branch and then push their rewritten one as a new branch, effectively rewriting history.\n\ngit config:\n\nOne of the workarounds to the denyNonFastForwards policy is for the user to delete the branch and then push it back up with the new reference. In newer versions of Git (beginning with version 1.6.1), you can set receive.denyDeletes to true:\n$ git config --system receive.denyDeletes true\nThis denies branch and tag deletion over a push across the board — no user can do it. To remove remote branches, you must remove the ref files from the server manually. There are also more interesting ways to do this on a per-user basis via ACLs, as you’ll learn at the end of this chapter."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "! [remote rejected] errors after mirroring a git repository\nI'm following this documentation:\nhttps://help.github.com/articles/duplicating-a-repository/\ngit clone --mirror https://github.com/exampleuser/repository-to-mirror.git\n\ncd repository-to-mirror.git\n\ngit push --mirror https://github.com/exampleuser/mirrored\n\nThe output shows that the repository is pushed as a mirror, but for some reason I'm getting these errors as well:\n ! [remote rejected] refs/pull/1/head -> refs/pull/1/head (deny updating a hidden ref)\n ! [remote rejected] refs/pull/1/merge -> refs/pull/1/merge (deny updating a hidden ref)\n\nWhat are these errors? Can I assume the repository was mirrored ?"
},
{
"role": "assistant",
"content": "As mentioned in this issue, that happens when you mirror a GitHub repo which has pull requests made to it.\n\nThe refs beginning 'refs/pull' are synthetic read-only refs created by GitHub - you can't update (and therefore 'clean') them, because they reflect branches that may well actually come from other repositories - ones that submitted pull-requests to you.\nSo, while you've pushed all your real refs, the pull requests don't get updated\n\nYou would need to mirror a GitHub repo without their pull requests.\n\nSimply replace the catch-all refspec above with two more specific specs to just include all heads and tags, but not the pulls, and all the remote pull refs will no longer make it into your bare mirror:\n\nfetch = +refs/heads/*:refs/heads/*\nfetch = +refs/tags/*:refs/tags/*\nfetch = +refs/change/*:refs/change/*\n\nIf push still fails, as commented by Ofek Shilon, add the push entries:\npush = +refs/heads/*:refs/heads/*\npush = +refs/tags/*:refs/tags/*\npush = +refs/change/*:refs/change/*\n\nAs mention in Git Refspec:\n\nThe + tells Git to update the reference even if it isn’t a fast-forward.\n\n\nThis change is to be done on the bare repository folder repository-to-mirror.git, using git config --local --edit.\nThe named remote to modify is the default \"origin\" one.\nThe goal is to not fetch the unwanted references, and push only the ones we need."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitattributes - Defining attributes per path Unspecified"
},
{
"role": "assistant",
"content": "If the text attribute is unspecified, Git uses the core.autocrlf configuration variable to determine if the\nfile should be converted."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I clone a large Git repository on an unreliable connection?\nI want to clone LibreOffice. From the official website, this is what's written:\n\nAll our source code is hosted in git:\nClone: $ git clone git://anongit.freedesktop.org/libreoffice/core # (browse)\nClone (http): $ git clone http://anongit.freedesktop.org/git/libreoffice/core.git # slower\nTarballs: http://download.documentfoundation.org/libreoffice/src/\nplease find the latest versions (usually near the bottom)\n\nnow, when I write this command in git bash to clone, it starts fetching. But the repository is so big that after hours I lose connectivity for a few seconds, it rolls back the download, and I get nothing.\nIs there any way I can download the repository smoothly even if interruptions occur?\nP.S. I am a new user of Git and I use a 1 MB DSL internet connection. The repository must be over 1 GB."
},
{
"role": "assistant",
"content": "The repository is accessible via the http protocol (aka dumb protocol) here: http://anongit.freedesktop.org/git/libreoffice/core.git.\nYou can download everything here with wget or another download manager, and you'll have a clone of the repository. After that, you rename the directory from core.git to .git, and use the following command to tell git about the remote url:\n$ git remote add remote http://anongit.freedesktop.org/git/libreoffice/core.git\n$ git reset --hard HEAD"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Use of apostrophe (single-quote) in a Git commit message via command line [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow to escape single quotes within single quoted strings\n\n (25 answers)\n \n\nClosed 11 years ago.\n\n\n\nI am trying to take this one step further. How could this work in a standard Bash shell?\ngit commit -m 'cracked enigma's code'\n\nCould this simply be done with backslash-escaping like the following?\ngit commit -m 'cracked enigma\\'s code'\n\nFurther, how could double-quotes be used? Also by backslash-escaping? Would that be the best way? Are there any good alternative ways?\ngit commit -m 'cracked the \"real\" enigma's code'"
},
{
"role": "assistant",
"content": "Use double quotes:\ngit commit -m \"cracked enigma's code\"\n\nOr, if your message contains other special characters, use double quotes or backslash only for the single quote:\ngit commit -m 'cracked $enigma'\"'\"'s code'\ngit commit -m 'cracked $enigma'\\''s code'"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to handle git gc fatal: bad object refs/remotes/origin/HEAD error?\nI randomly hit this today while trying to run Git garbage collect:\n$ git gc\nfatal: bad object refs/remotes/origin/HEAD\nerror: failed to run repack\n\nHow do I deal with this?"
},
{
"role": "assistant",
"content": "I don't understand the ramifications of this, but as suggested in this thread, when I encountered this I just did\n$ mv .git/refs/remotes/origin/HEAD /tmp\n\n(keeping it around just in case) and then\n$ git gc\n\nworked without complaining; I haven't run into any problems."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Undo last commit/merge\nI have messed up my git repo a little. I worked on a feature in a separate branch. After finishing the work, I switched to the master to merge it into, but my partner pushed a few files which came into conflict with mine. After the merge, the conflict and pushing the new changes, I saw that I committed the older changes of my partner too.\nNow I want to redo this commit/merge. I tried \ngit reset --soft HEAD^ but when I wanted to push, I got this error message Merge the remote changes before pushing again.\nCan anyone help me?"
},
{
"role": "assistant",
"content": "Your feature branch will still point to your work. You will not lose those changes.\nAs plaes said, you can reset master back one with\ngit reset --hard HEAD^\n\nIf you want to grab some specific files from your branch without merging, you can check them out:\ngit checkout yourbranch -- file1 file2 etc\n\nIf you want some files from master from before the merge you can also check these out:\ngit checkout master^ -- file3 file4 etc\n\nThis is not ideal but it is what is needed sometimes. A merge /may/ mean that you reject some changes from either side in a merge. The best way to attain a proper merge is to:\ngit merge --no-commit yourbranch\n\nfrom master, then run the git checkout commands from above and finally commit:\ngit add . -A\ngit commit\n\nWhen you push this branch now, you will need to add the force option\ngit push --force\n\nor\ngit push -f\n\nHope this helps."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index --minimal"
},
{
"role": "assistant",
"content": "Spend extra time to make sure the smallest possible\ndiff is produced."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "how do I pull to a bare repository?\nI have a \"main\" bare repository and a \"personal\" bare repository. I want to update changes form \"main\" to \"personal\", so I run:\n$ git pull\nfatal: /home/gimenero/applib/git/libexec/git-core/git-pull cannot be used without a working tree.\n\nHow do I pull the changes pushed to \"main\"?"
},
{
"role": "assistant",
"content": "A git pull does a fetch followed by a merge, and you can't merge without a working tree. (There would be nowhere to resolve merge conflicts if they should arise.)\nInstead, you could just fetch. Assuming your main repository is configured as a remote called origin on your personal repository:\n$ git fetch origin master:master\n\nNote that this will only be successful if the master branch of your personal repository is mirroring the master branch of the main repository. Otherwise, Git will reject the non-fast-forward fetch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to commit a change with both \"message\" and \"description\" from the command line? [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\n\nGit/GitHub commit with extended message/description\n\n (3 answers)\n \n\nClosed 6 years ago.\n\n\n\nI can push commits to GitHub via git (on the command line, not the Mac app).\nWhen I push commits directly from the GitHub web interface (e.g. quickly fixing a typo), I have the chance to \"comment\" the commit, and GitHub gives me a commit title and a commit description. I find this very useful.\nStill, when I git push from the local machine, git opens my default editor: so I write the commit comment, and then GitHub automatically divides it into title and \"body\". Is there a way to pretty comment commits from terminal too?"
},
{
"role": "assistant",
"content": "There is also another straight and more clear way\ngit commit -m \"Title\" -m \"Description ..........\";"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.