messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-submodule - Initialize, update or inspect submodules --files"
},
{
"role": "assistant",
"content": "This option is only valid for the summary command. This command\ncompares the commit in the index with that in the submodule HEAD\nwhen this option is used."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fetch - Download objects and refs from another repository --negotiate-only"
},
{
"role": "assistant",
"content": "Do not fetch anything from the server, and instead print the\nancestors of the provided --negotiation-tip=* arguments,\nwhich we have in common with the server. This is incompatible with --recurse-submodules=[yes|on-demand] .\nInternally this is used to implement the push.negotiate option, see git-config ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to get the path of a file relative to the Git repository root?\nExample:\n$ cd lib\n$ git absolute-path test.c # how to do this?\nlib/test.c"
},
{
"role": "assistant",
"content": "Use git ls-files:\n$ cd lib\n$ git ls-files --full-name test.c\nlib/test.c\n\nThis only works for files that have been committed into the repo, but it's better than nothing."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the point in signing tags in git?\nI am quite new in git, and I have seen that it is possible to sign the tags with gpg. I understand how public key cryptography works, and I understand how to do sign the tags, but what is the point in doing it?"
},
{
"role": "assistant",
"content": "The point of signing a tag is that now anyone who has your public key can prove that you have approved that particular commit as being that particular version of the program. If they happen to trust you as being the official source of releases for that package, then they know that they got an official version of that package, not some random version that might have been backdoored by an attacker or corrupted in transit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Unfork a GitHub fork without deleting\n\nI would like to \"unfork\" a GitHub fork without deleting + recreating it. Is this possible?\nMy reason is that my project now has a completely different use to the source of the fork, and makes no sense to be showing number of commits ahead, or the pull request button (or at least, with such prominence). With hindsight, I think I would have just git cloned the original, rather than made a fork.\nI would like to not delete my fork in order to keep the issues + history of pull requests made.\nI am happy to keep the history of commits, it's just the removal of the fork status that I'm after."
},
{
"role": "assistant",
"content": "Note: The following does not migrate GitHub specific metadata (issues, pull requests, wikis, releases, etc).\nUndoubtedly, there's no way but make a bare copy of all of the codes. However, the copy procedure can be done by GitHub itself. So, no pain of mirroring the code with our own bandwidth.\nStep by step:\n\nClick the \"+\" on top right corner, select \"Import repository\"\nPaste the old repo url (like https://github.com/user/repo) and enter a new name.\nClick \"Begin import\"\n\nDone. GitHub will even give you an email notification when copy'n'paste is done.\n\nUpdates on Jan, 2023.\nGithub support now provide \"unfork\" operation upon request. Just open a support ticket at https://support.github.com/contact?tags=rr-forks"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-ls-tree"
},
{
"role": "assistant",
"content": "List the contents of a tree object"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to upgrade Git to latest version on macOS?\nI just bought a new Mac and I checked in the Terminal what version of git is installed by default. I got the answer\ngit --version\n> git version 1.7.5.4\n\nI would like to upgrade git to the latest version 1.7.8.3, so I downloaded the dmg installer \"git-1.7.8.3-intel-universal-snow-leopard.dmg\" and I launched it.\nAfter the install, the Terminal still says that the version is 1.7.5.4. What am I doing wrong?"
},
{
"role": "assistant",
"content": "It's simple if you already have Homebrew:\nAssuming you have homebrew installed, type the following:\nbrew install git\n\nThis should automatically install git and set it in your path, replacing the Apple one.\nNow quit and restart your terminal.\nThen check git version to confirm.\ngit --version\n\nIf the output of the above command shows the latest version and does not mention Apple with the version details, then you are all set.\nIf however you still see apple version, then type the following two lines, which will manually set our path to the local git distro instead of the Apple one.\nexport PATH=/usr/local/bin:$PATH\ngit --version\n\nIF YOU DON'T HAVE HOMEBREW, FOLLOW THESE STEPS\nCheck version\n$ git --version\nBackup (or remove) Apple git (Optional)\n$ sudo mv /usr/bin/git /usr/bin/git-apple\nInstall Homebrew if you didn’t have\n$ /usr/bin/ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"\nOr update if you already have\n$ brew update && brew upgrade\nInstall Git with Homebrew\n$ brew install git\nSymbolic link\n$ brew link --force git\nQuit terminal and open a new terminal, then check version.\n$ git --version\nYou should see…\ngit version <latest version>\nNice! We’re safe now! And next time you can just…\n$ brew update && brew upgrade"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-ls-files - Show information about files in the index and the working tree --no-empty-directory"
},
{
"role": "assistant",
"content": "Do not list empty directories. Has no effect without --directory."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission --rfc"
},
{
"role": "assistant",
"content": "Prepends \"RFC\" to the subject prefix (producing \"RFC PATCH\" by\ndefault). RFC means \"Request For Comments\"; use this when sending\nan experimental patch for discussion rather than application."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Could I change my name and surname in all previous commits?\nI would like to change my name, surname and email in my all commits, is it possible?"
},
{
"role": "assistant",
"content": "Use git-filter-branch.\ngit filter-branch --commit-filter 'if [ \"$GIT_AUTHOR_NAME\" = \"Josh Lee\" ];\n then export GIT_AUTHOR_NAME=\"Hobo Bob\"; export [email protected];\n fi; git commit-tree \"$@\"'\n\nThis only affects the author, not the committer (which for most commits will be the same as the author). If you want to rewrite those as well, set the GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL variables.\nThe standard warning about rewriting history applies; only do it to history that has not yet been shared.\nJune 2018 Update\nThe manual now includes a solution, using --env-filter, in its examples: https://git-scm.com/docs/git-filter-branch#_examples : \ngit filter-branch --env-filter '\n if test \"$GIT_AUTHOR_EMAIL\" = \"root@localhost\"\n then\n [email protected]\n fi\n if test \"$GIT_COMMITTER_EMAIL\" = \"root@localhost\"\n then\n [email protected]\n fi\n' -- --all"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to hide connection string, user name, pw when using source control?\n\nI'm working on a small side-project and I'm using connection strings and also api keys and values that should not be seen or used by other people. I use a public GitHub account for source control. What is the usual method for using source control when these values are in plain text in web.config?\nDo I need to remove the values manually before checking in code?"
},
{
"role": "assistant",
"content": "What I find works is to check in a version of the file with blanked or dummy values and then to run:\ngit update-index --assume-unchanged [fileName]\n\nGit will then stop monitoring changes to that file allowing you to put the real config info into it without fear of checking it in.\nIf you later make changes that you DO want to check in you can run:\ngit update-index --no-assume-unchanged [fileName]"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to fail a build on Gitlab CI shell runner\n\nI have a Gitlab CI runner running on windows 10:\nbefore_script:\n - \"echo off\"\n - 'call \"%VS120COMNTOOLS%\\vsvars32.bat\"'\n - echo.\n - set\n - echo.\n\nstages:\n - build\n\nbuild:\n stage: build\n script:\n - 'StatusTest.exe'\n #- msbuild...\n\nI am trying to fail the build with StatusText.exe (I tried returning status codes -1,0,1; throwing an exception, etc.) But Runner only logs the exception and continues with following steps.\nWhat determines that CI shell runner should fail the build and not proceed to next step?\nOutput:\n...\nwindows_tracing_logfile=C:\\BVTBin\\Tests\\installpackage\\csilogfile.log\n$ echo.\n\n$ StatusTest.exe\n\nUnhandled Exception: System.Exception: tralala\n at StatusTest.Program.Main(String[] args)\n$ echo \"Restoring NuGet Packages...\"\n..."
},
{
"role": "assistant",
"content": "What determines that CI shell runner should fail the build and not\nproceed to next step?\n\nIf a pipeline job exits with the code other than 0 then that job fails causing all the following jobs in the pipeline to be skipped.\nThis behaviour can be changed on a per job basis with allow_failure job keyword.\nTo make a job to fail forcefully you need to artificially exit from a job with code other than 0. Here is an gitlab-ci.yml job example :\nsome-example-job:\n script:\n - # ....\n - exit 1\n\n\nSee the GitLab CI UI sreeenshot example. The third job has failed.\n\nOn the opposite remove exit 0 and your job would succeed if the remaining script section commands do not exit with code other than 0.\nNow see all the jobs & the entire pipeline finished successfully."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Running Gitlab Docker\n\nI'm following these instructions:\nhttp://doc.gitlab.com/omnibus/docker\nHowever http://localhost is says Webpage is not available. \nHere are the commands that I'm running (Ubuntu 14.04 LTS):\n ole@MKI:~$ docker version\n Client:\n Version: 1.9.1\n API version: 1.21\n Go version: go1.4.3\n Git commit: a34a1d5\n Built: Fri Nov 20 17:56:04 UTC 2015\n OS/Arch: linux/amd64\n\n Server:\n Version: 1.9.1\n API version: 1.21\n Go version: go1.4.3\n Git commit: a34a1d5\n Built: Fri Nov 20 17:56:04 UTC 2015\n OS/Arch: linux/amd64\n\n ole@MKI:~$ sudo docker run --detach \\\n > --hostname gitlab.example.com \\\n > --publish 443:443 --publish 80:80 --publish 22:22 \\\n > --name gitlab \\\n > --restart always \\\n > --volume /srv/gitlab/config:/etc/gitlab \\\n > --volume /srv/gitlab/logs:/var/log/gitlab \\\n > --volume /srv/gitlab/data:/var/opt/gitlab \\\n > gitlab/gitlab-ce:latest\n 613d4d2d612f977d3d25746a169d9209acb864e57c5184083dccd02b1e4a157c\n\n ole@MKI:~$ docker ps\n CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES\n 613d4d2d612f gitlab/gitlab-ce:latest \"/assets/wrapper\" 4 seconds ago Up 2 seconds 0.0.0.0:22->22/tcp, 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp gitlab\n\nIf I rerun docker ps I get this:\n CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES\n 613d4d2d612f gitlab/gitlab-ce:latest \"/assets/wrapper\" 9 minutes ago Restarting (1) About a minute ago 0.0.0.0:22->22/tcp, 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp gitlab\n\nIt says Restarting about a minute ago... ... does that mean there is something wrong internally?\n[EDIT - ADDING LOGS]\n ole@MKI:~$ sudo mkdir -p /var/log/gitlab/reconfigure\n\n ole@MKI:~$ sudo docker run --detach \\\n > --hostname gitlab.example.com \\\n > --publish 443:443 --publish 80:80 --publish 22:22 \\\n > --name gitlab \\\n > --restart always \\\n > --volume /srv/gitlab/config:/etc/gitlab \\\n > --volume /srv/gitlab/logs:/var/log/gitlab \\\n > --volume /srv/gitlab/data:/var/opt/gitlab \\\n > gitlab/gitlab-ce:latest\n f4dee0a603bdc95594e8a77d51762f2d78d44ec077f2d57645e651ed628a4d6b\n\n ole@MKI:~$ docker logs\n docker: \"logs\" requires 1 argument.\n See 'docker logs --help'.\n\n Usage: docker logs [OPTIONS] CONTAINER\n\n Fetch the logs of a container\n\n ole@MKI:~$ docker logs gitlab\n Thank you for using GitLab Docker Image!\n Current version: gitlab-ce=8.5.0-ce.1\n\n Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file\n And restart this container to reload settings.\n To do it use docker exec:\n\n docker exec -it gitlab vim /etc/gitlab/gitlab.rb\n docker restart gitlab\n\n For a comprehensive list of configuration options please see the Omnibus GitLab readme\n https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md\n\n If this container fails to start due to permission problems try to fix it by executing:\n\n docker exec -it gitlab update-permissions\n docker restart gitlab\n\n Preparing services...\n Starting services...\n Configuring GitLab...\n /opt/gitlab/embedded/bin/runsvdir-start: line 34: ulimit: max user processes: cannot modify limit: Operation not permitted\n /opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system\n [2016-02-23T01:16:47+00:00] FATAL: Failed to open or create log file at /var/log/gitlab/reconfigure/1456190207.log: Errno::ENOENT (No such file or directory @ rb_sysopen - /var/log/gitlab/reconfigure/1456190207.log)\n [2016-02-23T01:16:47+00:00] FATAL: Aborting due to invalid 'log_location' configuration\n Thank you for using GitLab Docker Image!\n Current version: gitlab-ce=8.5.0-ce.1\n\n Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file\n And restart this container to reload settings.\n To do it use docker exec:\n\n docker exec -it gitlab vim /etc/gitlab/gitlab.rb\n docker restart gitlab\n\n For a comprehensive list of configuration options please see the Omnibus GitLab readme\n https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md\n\n If this container fails to start due to permission problems try to fix it by executing:\n\n docker exec -it gitlab update-permissions\n docker restart gitlab\n\n Preparing services...\n Starting services...\n Configuring GitLab...\n /opt/gitlab/embedded/bin/runsvdir-start: line 34: ulimit: max user processes: cannot modify limit: Operation not permitted\n /opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system\n [2016-02-23T01:16:51+00:00] FATAL: Failed to open or create log file at /var/log/gitlab/reconfigure/1456190211.log: Errno::ENOENT (No such file or directory @ rb_sysopen - /var/log/gitlab/reconfigure/1456190211.log)\n [2016-02-23T01:16:51+00:00] FATAL: Aborting due to invalid 'log_location' configuration\n Thank you for using GitLab Docker Image!\n Current version: gitlab-ce=8.5.0-ce.1\n\n Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file\n And restart this container to reload settings.\n To do it use docker exec:\n\n docker exec -it gitlab vim /etc/gitlab/gitlab.rb\n docker restart gitlab\n\n For a comprehensive list of configuration options please see the Omnibus GitLab readme\n https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md\n\n If this container fails to start due to permission problems try to fix it by executing:\n\n docker exec -it gitlab update-permissions\n docker restart gitlab\n\n Preparing services...\n Starting services...\n Configuring GitLab...\n /opt/gitlab/embedded/bin/runsvdir-start: line 34: ulimit: max user processes: cannot modify limit: Operation not permitted\n /opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system\n [2016-02-23T01:16:56+00:00] FATAL: Failed to open or create log file at /var/log/gitlab/reconfigure/1456190216.log: Errno::ENOENT (No such file or directory @ rb_sysopen - /var/log/gitlab/reconfigure/1456190216.log)\n [2016-02-23T01:16:56+00:00] FATAL: Aborting due to invalid 'log_location' configuration\n Thank you for using GitLab Docker Image!\n Current version: gitlab-ce=8.5.0-ce.1\n\n Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file\n And restart this container to reload settings.\n To do it use docker exec:\n\n docker exec -it gitlab vim /etc/gitlab/gitlab.rb\n docker restart gitlab\n\n For a comprehensive list of configuration options please see the Omnibus GitLab readme\n https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md\n\n If this container fails to start due to permission problems try to fix it by executing:\n\n docker exec -it gitlab update-permissions\n docker restart gitlab\n\n Preparing services...\n Starting services...\n Configuring GitLab...\n /opt/gitlab/embedded/bin/runsvdir-start: line 34: ulimit: max user processes: cannot modify limit: Operation not permitted\n /opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system\n [2016-02-23T01:17:02+00:00] FATAL: Failed to open or create log file at /var/log/gitlab/reconfigure/1456190222.log: Errno::ENOENT (No such file or directory @ rb_sysopen - /var/log/gitlab/reconfigure/1456190222.log)\n [2016-02-23T01:17:02+00:00] FATAL: Aborting due to invalid 'log_location' configuration\n Thank you for using GitLab Docker Image!\n Current version: gitlab-ce=8.5.0-ce.1\n\n Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file\n And restart this container to reload settings.\n To do it use docker exec:\n\n docker exec -it gitlab vim /etc/gitlab/gitlab.rb\n docker restart gitlab\n\n For a comprehensive list of configuration options please see the Omnibus GitLab readme\n https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md\n\n If this container fails to start due to permission problems try to fix it by executing:\n\n docker exec -it gitlab update-permissions\n docker restart gitlab\n\n\n ole@MKI:~$ docker ps\n CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES\n f4dee0a603bd gitlab/gitlab-ce:latest \"/assets/wrapper\" 39 seconds ago Restarting (1) 4 seconds ago 0.0.0.0:22->22/tcp, 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp gitlab\n\nIt still does not boot, even after creating /var/log/gitlab/reconfigure manually."
},
{
"role": "assistant",
"content": "Modifying the docker command to the following resolved the issue for me:\nsudo docker run -i \\\n --hostname ubuntu \\\n --publish 443:443 --publish 80:80 --publish 2222:22 \\\n --name gitlab \\\n --restart always \\\n --volume /srv/gitlab/config:/etc/gitlab \\\n --volume /srv/gitlab/logs:/var/log/gitlab \\\n --volume /srv/gitlab/data:/var/opt/gitlab \\\n --volume /srv/gitlab/logs/reconfigure:/var/log/gitlab/reconfigure \\\n gitlab/gitlab-ce:latest\n\nNote I used -i so I could watch it start up, but you can set it back to --detach."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git ls-files in bare repository\nI want to access a bare git repository, and I want to list all files in the repository.\nOn a normal git repository I can easily do that by running git ls-files. \nExample output:\n$ git ls-files\nREADME.md\nfile1.js\nfile2.js\nfile3.js\nfolder1/file4.js\nfolder2/file5.js\n\nIn a bare git repository this fails silently. It just doesn't return any files (but exits successfully):\n$ cd my-bare-repository\n$ git ls-files #returns nothing\n$ echo $? #print exit code from previous command\n$ 0\n\nNow I am aware that I have to provide a meaningful branch or master to display. But how can I actually get this list of the files that I know are in my repository?"
},
{
"role": "assistant",
"content": "You can try the other command which list files:\ngit ls-tree --full-tree -r HEAD\n\nAccording to this comment, the command git ls-tree works in bare repo."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git status shows modifications even with autocrlf=false\nI'm experiencing the same issues as in this question: git status shows modifications, git checkout -- <file> doesn't remove them\nGit continues to show working directory modifications, even with git config --global core.autocrlf false:\nE:\\_dev\\github\\Core [master +0 ~93 -0]> git config --get-all core.autocrlf\nfalse\nfalse\n\n(Note that I've even set the --system setting to be false)\nWhy does it appear that Git is still modifying my end of lines?\nAttempts to get rid of modifications\nBaseline\nE:\\_dev\\github\\Core [master +0 ~93 -0]> git status\n# On branch master\n# Changes not staged for commit:\n# (use \"git add <file>...\" to update what will be committed)\n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n# modified: tools/StatLight/StatLight.EULA.txt\n... more changes ...\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\ngit checkout -- .\nE:\\_dev\\github\\Core [master +0 ~93 -0]> git checkout -- .\nE:\\_dev\\github\\Core [master +0 ~93 -0]> git status\n# On branch master\n# Changes not staged for commit:\n# (use \"git add <file>...\" to update what will be committed) \n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n# modified: tools/StatLight/StatLight.EULA.txt\n... more changes ...\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nOccasionally this will have an effect in an odd way:\nE:\\_dev\\github\\Core [master +0 ~628 -0]> git checkout -- .\nE:\\_dev\\github\\Core [master +0 ~361 -0]> git checkout -- .\nE:\\_dev\\github\\Core [master +0 ~93 -0]> git checkout -- .\nE:\\_dev\\github\\Core [master +0 ~93 -0]> git checkout -- .\nE:\\_dev\\github\\Core [master +0 ~93 -0]> git checkout -- .\n\ngit reset --hard\nE:\\_dev\\github\\Core [master +0 ~93 -0]> git reset --hard\nHEAD is now at 11a7f9a Merge pull request #8 from RemiBou/master\nE:\\_dev\\github\\Core [master +0 ~93 -0]>\n\ngit add .; git stash; git stash drop\nE:\\_dev\\github\\Core [master +0 ~93 -0]> git add .\n... warnings ....\nwarning: CRLF will be replaced by LF in tools/StatLight/StatLight.EULA.txt.\nThe file will have its original line endings in your working directory.\n\nE:\\_dev\\github\\Core [master +0 ~93 -0]> git stash\nSaved working directory and index state WIP on master: 11a7f9a Merge pull request #8 from \nRemiBou/master\nHEAD is now at 11a7f9a Merge pull request #8 from RemiBou/master\n\nE:\\_dev\\github\\Core [master +0 ~93 -0]> git stash drop\nDropped refs/stash@{0} (de4c3c863dbad789aeaf563b4826b3aa41bf11b7)\n\nE:\\_dev\\github\\Core [master +0 ~93 -0]> git status .\\tools\\StatLight\\StatLight.EULA.txt\n# On branch master\n# Changes not staged for commit:\n# (use \"git add <file>...\" to update what will be committed)\n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n# modified: tools/StatLight/StatLight.EULA.txt\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")"
},
{
"role": "assistant",
"content": "This seems like a bug in msysgit indeed. As a workaround, try creating a .gitattributes file containing\n* -text\n\nThis will tell git not to perform EOL conversions on any files."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --no-prefix"
},
{
"role": "assistant",
"content": "Do not show any source or destination prefix."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show-ref - List references in a local repository"
},
{
"role": "assistant",
"content": "OUTPUT The output is in the format: <oid> SP <ref> LF For example, $ git show-ref --head --dereference\n832e76a9899f560a90ffd62ae2ce83bbeff58f54 HEAD\n832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/master\n832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/origin\n3521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0.99.9c\n6ddc0964034342519a87fe013781abf31c6db6ad refs/tags/v0.99.9c^{}\n055e4ae3ae6eb344cbabf2a5256a49ea66040131 refs/tags/v1.0rc4\n423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1.0rc4^{}\n... When using --hash (and not --dereference ), the output is in the format: <oid> LF For example, $ git show-ref --heads --hash\n2e3ba0114a1f52b47df29743d6915d056be13278\n185008ae97960c8d551adcd9e23565194651b5d1\n03adf42c988195b50e1a1935ba5fcbc39b2b029b\n..."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to install Python on Gitlab-CI\n\nHow do you install various versions of Python on Gitlab-CI?\nIn my previous experience with Travis-CI, I simply run the normal Ubuntu/Debian commands to install the deadsnakes repo and then install whatever version I need like:\nsudo add-apt-repository -y ppa:fkrull/deadsnakes\nsudo apt-get -yq update\nsudo apt-get -yq install python2.7 python2.7-dev python3.4 python3.4-dev python3.6 python3.6-dev python3.7 python3.7-dev\n\nI've tried this similar configuration with Gitlab-CI:\nimage: ubuntu:latest\n\nbefore_script:\n - add-apt-repository -y ppa:fkrull/deadsnakes\n - apt-get -yq update\n - apt-get -yq install python2.7 python2.7-dev python3.4 python3.4-dev python3.6 python3.6-dev python3.7 python3.7-dev\n - python -V\n\ntest:\n script:\n - ./run_my_tests.sh\n\nbut this fails with:\n/bin/bash: line 82: add-apt-repository: command not found\n\nI can only assume that even though I'm running an Ubuntu image, Gitlab restricts the commands available. What's the equivalent way to install Python in Gitlab-CI?"
},
{
"role": "assistant",
"content": "You should use a base image containing everything you need. Installing something by hand should work in principle, but will unnecessarily cost you GitLab CI pipeline minutes.\nFor python 3.7 you could do the following:\nimage: python:3.7-alpine3.9\n\nCheck DockerHub for a list of all available python images: https://hub.docker.com/_/python\nIf you need to test with different python versions, I recommend to split your tasks into different GitLab CI jobs, each using a different python base image:\ntest-python-3-7:\n image: python:3.7-alpine3.9\n script:\n - ./run_my_tests.sh\n\ntest-python-2.7:\n image: python:2.7.16-alpine3.8\n script:\n - ./run_my_tests.sh\n\nIf you absolutely need to install stuff by yourself, because there is no appropriate image, I would still suggest you create an image with everything you need, upload it to DockerHub or your own GitLab container registry, and then use it in your CI pipelines."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do you create a project in a specific group via GitLab API?\n\nI tried to use GitLab API to create a new project. This worked, but this is in my user space:\n curl \\\n --header \"Authorization: Bearer ${GITLAB_API_TOKEN}\" \\\n --request POST \\\n \"https://gitlab.com/api/v4/projects/?name=$test-proj\"\n\nBut I wanted to do it under a specific group with group_id <group_id> (I blanked it here). The most sensible approach that occured to me was:\n curl \\\n --header \"Authorization: Bearer ${GITLAB_API_TOKEN}\" \\\n --request POST \\\n \"https://gitlab.com/api/v4/groups/<group_id>/projects/?name=test-proj\n\nBut this did not work. Are there any suggestions on how I could achieve this?\nI consulted the following references\n\nhttps://forum.gitlab.com/t/create-a-new-project-in-a-group-using-api/1552\nhttps://docs.gitlab.com/ee/api/projects.html#create-project\n\nThe GitLab documentation mentions the path or namespace_id attribute (although I would actually be in search of a group_id attribute). I am not sure about path and how to specify that. I tried - without success - to retrieve the namespace_id via\ncurl --header \"PRIVATE-TOKEN: ${GITLAB_API_TOKEN}\" \"https://gitlab.example.com/api/v4/namespaces\"\n\nIt is well possible that I might not have the rights to do the required operation. Therefore a reference to an official (GitLab) documentation together with a test curl command that works would be very helpful to me - thank you!"
},
{
"role": "assistant",
"content": "For anyone looking for the direct command:\nSTEP 1:\nNavigate as below and identify the group ID from GUI:\nAdmin Area -> Groups -> GroupName\n\nSTEP 2:\nConstruct the command with two parameters viz., name, namespace_id\ncurl --header \"PRIVATE-TOKEN: <myprivatetoken>\" -X POST \"https://gitlab.com/api/v4/projects?name=myexpectedrepo&namespace_id=38\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Verifying signed git commits?\nWith newer versions of git it's possible to sign individual commits (in addition to tags) with a PGP key:\ngit commit -m \"some message\" -S\n\nAnd you can show these signatures in the output of git log with the --show-signature option:\n$ git log --show-signature\ncommit 93bd0a7529ef347f8dbca7efde43f7e99ab89515\ngpg: Signature made Fri 28 Jun 2013 02:28:41 PM EDT using RSA key ID AC1964A8\ngpg: Good signature from \"Lars Kellogg-Stedman <[email protected]>\"\nAuthor: Lars Kellogg-Stedman <[email protected]>\nDate: Fri Jun 28 14:28:41 2013 -0400\n\n this is a test\n\nBut is there a way to programatically verify the signature on a given commit other than by grepping the output of git log? I'm looking for the commit equivalent of git tag -v -- something that will provide an exit code indicating whether or not there was a valid signature on a given commit."
},
{
"role": "assistant",
"content": "Just in case someone comes to this page through a search engine, like I did: New tools have been made available in the two years since the question was posted.\nThere are now git commands for this task: git verify-commit and git verify-tag can be used to verify commits and tags, respectively."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to delete a gist on GitHub?\n\nIs there a way I can remove a gist on GitHub? Created a gist earlier, but don't really want it there anymore."
},
{
"role": "assistant",
"content": "Currently:\nThere's a \"delete\" button at the top of each gist now:\n\nPreviously...\nPreviously there was \"delete this gist\" link at the bottom of the gist's page, as below - thanks to Daniel Smith for pointing out in the comments below that this has been changed."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs color"
},
{
"role": "assistant",
"content": "Highlight changed words using only colors. Implies --color ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc git-diff-index --cached <tree-ish>"
},
{
"role": "assistant",
"content": "compares the <tree-ish> and the index."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Cherry pick using TortoiseGit\nHow do I run the cherry pick command using TortoiseGit UI?"
},
{
"role": "assistant",
"content": "Open the log in a repository with the target branch checked out.\nUse the top-left blue branch name to select the source branch.\nSelect the commit(s) you want.\nRight click and select Cherry Pick this commit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options blame.markIgnoredLines"
},
{
"role": "assistant",
"content": "Mark lines that were changed by an ignored revision that we attributed to\nanother commit with a ? in the output of git-blame ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What to gitignore from the .idea folder?\nPossible Duplicate:\nIntellij Idea 9/10, what folders to check into (or not check into) source control? \n\nI started using WebStorm for web development and am not sure what to add and what to exclude from our Git repository. Clearly some files inside the .idea folder are meant to be version controlled like the external library settings (jsLibraryMappings.xml) but others will probably change very often and are developer-specific (e.g., workspace.xml).\nWhat is the recommended .gitignore pattern for WebStorm / IntelliJ IDEA?\nP.S. There are already questions about this but usually focus only on whether to include the whole .idea folder or whether to fully exclude it. I think some of the files inside the .idea folder should be version controlled while others shouldn't and I'm trying to find out which ones."
},
{
"role": "assistant",
"content": "The official support page should answer your question.\nSo in your .gitignore you might ignore the files ending with .iws, and the workspace.xml and tasks.xml files."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the Sign Off feature in Git for?\nWhat's the point of the Sign Off feature in Git?\ngit commit --signoff\n\nWhen should I use it, if at all?"
},
{
"role": "assistant",
"content": "Sign-off is a requirement for getting patches into the Linux kernel and a few other projects, but most projects don't actually use it.\nIt was introduced in the wake of the SCO lawsuit, (and other accusations of copyright infringement from SCO, most of which they never actually took to court), as a Developers Certificate of Origin. It is used to say that you certify that you have created the patch in question, or that you certify that to the best of your knowledge, it was created under an appropriate open-source license, or that it has been provided to you by someone else under those terms. This can help establish a chain of people who take responsibility for the copyright status of the code in question, to help ensure that copyrighted code not released under an appropriate free software (open source) license is not included in the kernel."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-cat-file - Provide contents or details of repository objects"
},
{
"role": "assistant",
"content": "NAME git-cat-file - Provide contents or details of repository objects"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout-index - Copy files from the index to the working tree -a --all"
},
{
"role": "assistant",
"content": "checks out all files in the index except for those with the\nskip-worktree bit set (see --ignore-skip-worktree-bits ).\nCannot be used together with explicit filenames."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects %cE"
},
{
"role": "assistant",
"content": "committer email (respecting .mailmap, see git-shortlog or git-blame )"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git is refusing to merge unrelated histories. What are 'unrelated histories'?\nI created a local repo with git remote origin https:////....\nThen, in that local repo, I made a new text file → git add newfile.txt → git commit -m \"...\" → git pull origin master → ERROR!\n\"refusing to merge unrelated histories\".\nWhat are unrelated histories?\nWhat are related histories?"
},
{
"role": "assistant",
"content": "I think you have committed in the remote repository, and when you pull, this error happens.\nUse this command:\ngit pull origin master --allow-unrelated-histories\ngit merge origin origin/master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index -O<orderfile>"
},
{
"role": "assistant",
"content": "Control the order in which files appear in the output.\nThis overrides the diff.orderFile configuration variable\n(see git-config ). To cancel diff.orderFile ,\nuse -O/dev/null . The output order is determined by the order of glob patterns in\n<orderfile>.\nAll files with pathnames that match the first pattern are output\nfirst, all files with pathnames that match the second pattern (but not\nthe first) are output next, and so on.\nAll files with pathnames that do not match any pattern are output\nlast, as if there was an implicit match-all pattern at the end of the\nfile.\nIf multiple pathnames have the same rank (they match the same pattern\nbut no earlier patterns), their output order relative to each other is\nthe normal order. <orderfile> is parsed as follows: Blank lines are ignored, so they can be used as separators for\nreadability. Lines starting with a hash (\" # \") are ignored, so they can be used\nfor comments. Add a backslash (\" \\ \") to the beginning of the\npattern if it starts with a hash. Each other line contains a single pattern. Patterns have the same syntax and semantics as patterns used for\nfnmatch(3) without the FNM_PATHNAME flag, except a pathname also\nmatches a pattern if removing any number of the final pathname\ncomponents matches the pattern. For example, the pattern \" foo*bar \"\nmatches \" fooasdfbar \" and \" foo/bar/baz/asdf \" but not \" foobarx \"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I rebase while skipping a particular commit?\nIs there a way to rebase a branch onto another while skipping a particular (conflicting) commit on the other branch?\nFor example, I want to rebase mybranch onto master, but master contains a commit that will conflict with the commits in master, so I prefer to undo that commit completely.\n-o-o-o-o-o-x-o-o-o-o master\n |\n o-o-o-o mybranch\n\nx marks the conflicting commit."
},
{
"role": "assistant",
"content": "Use interactive rebase:\ngit rebase -i master\n\nAn editor will open and you will have a list of commits like this:\npick b8f7c25 Fix 1\npick 273b0bb Fix 2\npick 6aaea1b Fix 3\n\nJust delete the commit you want to skip. It will be omitted while rebasing your branch onto master.\nP.S. If you cannot see the editor, please, refer to this question for solution: How can I set up an editor to work with Git on Windows?"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-cat-file - Provide contents or details of repository objects --batch-check --batch-check=<format>"
},
{
"role": "assistant",
"content": "Print object information for each object provided on stdin. May not be\ncombined with any other options or arguments except --textconv , --filters or --use-mailmap . When used with --textconv or --filters , the input lines must\nspecify the path, separated by whitespace. See the section BATCH OUTPUT below for details. When used with --use-mailmap , for commit and tag objects, the\nprinted object information shows the size of the object as if the\nidentities recorded in it were replaced by the mailmap mechanism."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Install Gitlab runner on ECS Cluster\n\nWe are running AWS ECS/ECR with Gitlab CI as CI/CD.\nDue to load increase we are searching for the best way to autoscale the runner on AWS. \nI know Gitlab supports Autoscaling for its ci-runner. https://docs.gitlab.com/runner/configuration/runner_autoscale_aws/\nBut I'm wondering if it would be possible to leverage the ECS cluster on AWS for this purpose. Has anybody ever set up the runner on an ECS cluster with Loadbalancer and Autoscaling on ECS side and could provide some insights regarding such a setup?\nmerci in advance\nA"
},
{
"role": "assistant",
"content": "Since each CI task is usually run in a container (or other isolated environment), this would require the GitLab runner to natively talk to ECS to spin up new containers for jobs\nI don't think it's gonna happen; GL supports Kubernetes, which is more versatile in that it's not tied to AWS, and also support EC2 autoscaling for AWS. ECS sounds like a lot of extra effort for a very narrow benefit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git: merge branch and use meaningful merge commit message?\nAfter I merge a feature branch back to main branch I usually need to do a merge commit by default. But I'd like to use the original commit messages from my feature branch in this commit instead of \"merge branch XXX\". \nHow should I do that?"
},
{
"role": "assistant",
"content": "Just pass the -m and --no-ff parameters to the merge command:\n$ git merge other-branch -m \"Commit Message\" --no-ff\n\nThe --no-ff parameter is required to prevent merging as a fast-forward without merge commit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I fix a reverted git commit?\nI've committed a bunch of changes to a repository, and they were reverted by someone else (they compile on windows but not on linux). I think that the changes are still in the history, but how can I get those changes back, fix them, and then resubmit?"
},
{
"role": "assistant",
"content": "Have you tried reverting the revert?\nThey reverted your commit using\ngit revert <your commit id>\n\nThe revert itself is a commit and has its own commit id. So now you need to do\ngit revert <the commit id of his revert-commit>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Access env variables in node js app when using gitlab ci cd pipeline\n\nI am using gitlab ci cd pipe line to deploy my application to ubuntu server. I have different .env file for local and for dev env and its not a part of git repo (included in gitignore) how to get env variables in my app when deployed to ubuntu server\nmy gitlab-ci.yml\nstages:\n - deploy\ncache:\n paths:\n - node_modules/\ndeploy:\n stage: deploy\n script:\n - npm install\n - sudo pm2 delete lknodeapi || true\n - sudo pm2 start server.js --name lknodeapi"
},
{
"role": "assistant",
"content": "I guess you are looking for this -Create Variables Gitlab.You can create your environment variables in the ui and then change your gitlab-ci.yml like below\nstages:\n - deploy\ncache:\n paths:\n - node_modules/\ndeploy:\n stage: deploy\n script:\n - echo \"NGINX_REPO_KEY\"=$NGINX_REPO_KEY >> \".env\"\n - npm install\n - sudo pm2 delete lknodeapi || true\n - sudo pm2 start server.js --name lknodeapi\n\nThis will create a .env file in root folder and put your variables in it."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options gitcvs.enabled"
},
{
"role": "assistant",
"content": "Whether the CVS server interface is enabled for this repository.\nSee git-cvsserver ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Deleting Files using Git/GitHub\nFirst off, I'm new to Git.\nI deleted a bunch of files locally on my Mac using Finder. I want the files that I deleted to no longer show in the current branch, but they do. \nAny Git users know a command to update the index?"
},
{
"role": "assistant",
"content": "I think this would be a simpler way to do what you want:\ngit add . -A \n\nThen you would just do:\ngit commit -m \"removed some files\"\n\nAs noted above."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc"
},
{
"role": "assistant",
"content": "diff format for merges \"git-diff-tree\", \"git-diff-files\" and \"git-diff --raw\"\ncan take -c or --cc option\nto generate diff output also for merge commits. The output differs\nfrom the format described above in the following way: there is a colon for each parent there are more \"src\" modes and \"src\" sha1 status is concatenated status characters for each parent no optional \"score\" number tab-separated pathname(s) of the file For -c and --cc , only the destination or final path is shown even\nif the file was renamed on any side of history. With --combined-all-paths , the name of the path in each parent is shown\nfollowed by the name of the path in the merge commit. Examples for -c and --cc without --combined-all-paths : ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM\tdesc.c\n::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM\tbar.sh\n::100644 100644 100644 e07d6c5 9042e82 ee91881 RR\tphooey.c Examples when --combined-all-paths added to either -c or --cc : ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM\tdesc.c\tdesc.c\tdesc.c\n::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM\tfoo.sh\tbar.sh\tbar.sh\n::100644 100644 100644 e07d6c5 9042e82 ee91881 RR\tfooey.c\tfuey.c\tphooey.c Note that combined diff lists only files which were modified from\nall parents."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-gc - Cleanup unnecessary files and optimize the local repository"
},
{
"role": "assistant",
"content": "HOOKS The git gc --auto command will run the pre-auto-gc hook. See githooks for more information."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fetch - Download objects and refs from another repository --dry-run"
},
{
"role": "assistant",
"content": "Show what would be done, without making any changes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "rebase in progress. Cannot commit. How to proceed or stop (abort)?\nWhen I run: \ngit status\n\nI see this:\nrebase in progress; onto 9c168a5\nYou are currently rebasing branch 'master' on '9c168a5'.\n(all conflicts fixed: run \"git rebase --continue\")\nnothing to commit, working directory clean\n\nWhen I do: \nls `git rev-parse --git-dir` | grep rebase || echo no rebase\n\nI see: rebase-apply\nI can't commit to origin. \ngit branch\n\nShows:\n* (no branch, rebasing master)\n develop\n master\n\nI'm stuck. I don't know what to do? Does it really take this long to rebase? git rebase --continue doesn't do anything. I don't have anything in git status.. I'm just waiting for the rebase. What can I do?\nUDATE:\nThis is the output of: git rebase --continue\nApplying: no message\nNo changes - did you forget to use 'git add'?\nIf there is nothing left to stage, chances are that something else\nalready introduced the same changes; you might want to skip this patch.\n\nWhen you have resolved this problem, run \"git rebase --continue\".\nIf you prefer to skip this patch, run \"git rebase --skip\" instead.\nTo check out the original branch and stop rebasing, run \"git rebase --abort\".\n\ngit add . has nothing."
},
{
"role": "assistant",
"content": "Rebase doesn't happen in the background. \"rebase in progress\" means that you started a rebase, and the rebase got interrupted because of conflict. You have to resume the rebase \n(git rebase --continue) or abort it (git rebase --abort).\nAs the error message from git rebase --continue suggests, you asked git to apply a patch that results in an empty patch. Most likely, this means the patch was already applied and you want to drop it using git rebase --skip."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Transfer git repositories from GitLab to GitHub - can we, how to and pitfalls (if any)?\n\nCan one transfer repositories from GitLab to GitHub if the need be. If so, how exactly can I go about doing the same?\nAlso, are there any pitfalls in doing so or precautionary measures that I need to keep in mind before doing so given that I may decide to eventually move them to GitHub (as it has more features at the moment that I might find handy for my project)."
},
{
"role": "assistant",
"content": "You can transfer those (simply by adding a remote to a GitHub repo and pushing them)\n\ncreate an empty repo on GitHub\ngit remote add github https://[email protected]/yourLogin/yourRepoName.git\ngit push --mirror github\n\nThe history will be the same.\nBut you will lose the access control (teams defined in GitLab with specific access rights on your repo)\nIf you face any issue with the https URL of the GitHub repo:\nThe requested URL returned an error: 403\n\nAll you need to do is to enter your GitHub password, but the OP suggests:\n\nThen you might need to push it the ssh way. You can read more on how to do it here.\n\nSee \"Pushing to Git returning Error Code 403 fatal: HTTP request failed\".\n\nNote that mike also adds in the comments:\n\nGitLab can also be set to push mirror to downstream repositories, and there are specific instructions for push mirroring to GitHub.\nThis can use a GitHub Personal Access Token and also be set to periodically push.\nYou might use this option to share on GitHub, but keep your main development activity in your GitLab instance.\n\n\ntswaehn suggests in the comments the tool piceaTech/node-gitlab-2-github\n\nIt is possible to migrate issues, labels, ... with this tool github.com/piceaTech/node-gitlab-2-github: I tested it, not bad.\nBut had issues when transferring attachments of the issues itself.\nStill worth a try, maybe.\n\nFrotz notes in the comments that:\n\nI've since discovered that there's a wait option available to use in the user-editable settings.ts file that's not documented anywhere.\nI discovered it while implementing my own quick-and-dirty delay, which did work in stopping the \"Abuse detected\" slowdowns\n\n\n\nDoes this mean that when I want to push new changes I would have to do git push github [branch_name] instead of using origin?\n\nNo, you can:\n\ndelete origin, (git remote remove origin),\nrename github remote as origin (git remote rename github origin), and\ngo on git push (to origin, which is now GitHub): the transfer from GitLab to GitHub is complete."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab 'fatal: repository '...' not found' - unable to push to a newly created project\n\nCan anyone spot what I could possibly be doing wrong? You can browser zoom in to see image details. \nThis is a fresh account, new project, owner of group and I am simply unable to push (HTTPS) following instructions provided."
},
{
"role": "assistant",
"content": "When adding the remote URL to the initial configuration, instead of using the URL that Gitlab gives you, try adding the following URL instead and replace the details below as mentioned, to reflect your info & your project info:\nREMOTE URL FORMAT:\nhttps://YOUR_USER_NAME:[email protected]/YOUR_USER_NAME/YOUR_PROJECT_NAME.git/\n\nREPLACEMENTS IN THE ABOVE URL:\nYOUR_USER_NAME - Replace this with your gitlab username\nPASSWORD - Replace this with your gitlab password\nYOUR_PROJECT_NAME - Replace this with your gitlab project name (whatever is generated for you)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "On Premise Gitlab Pages: How to increase/debug public folder allowed size // ERROR: Uploading artifacts to coordinator... too large archive\n\nI'm creating a big (satis) package repository in a GitLab CI build step and wanted to just host it in GitLab Pages (on premise install). This works flawlessly, until the public folder size gets big, as soon as not only package versions, but downloads are stored in it as well. I added a last step to the pages task to show folder size:\n$ du -h public\n2.7G public\nCreating cache default...\npublic: found 564 matching files \nvendor: found 3808 matching files \nCreated cache\nUploading artifacts...\npublic: found 564 matching files \nERROR: Uploading artifacts to coordinator... too large archive id=494 responseStatus=413 Request Entity Too Large status=413 Request Entity Too Large token=kDf7gQEd\nFATAL: Too large \nERROR: Job failed: exit code 1\n\nOf course that is a whole lot. I managed to delete some outdated minor version and was at\n950MB public\n\nStill the same problem. After some investigation there seem to be two relevant limits:\n\nGitlab Pages System Configuration: Max Pages Size (was set to 0 for unlimited)\nNGINX max post size in /etc/gitlab/gitlab.rb (was set to disabled, seems to default to 250M). Which I changed to nginx['client_max_body_size'] = '1024m'\n\nStill the same problem. Even after deleting even more versions down to 580M folder size the same error resides.\nAs soon as I disable downloads and thus only have <10Meverything works.\nHow can I debug the cause of this? Or is there some other hidden configuration?"
},
{
"role": "assistant",
"content": "Since GitLab 12.7 (Jan 2020) it is possible for GitLab administrators to set the maximum pages size for individual groups and projects directly in the project/group settings.\nIn the project under settings -> pages, you can set the \"Maximum size of pages\" in MB.\n\nAdministrators can also set the global limit under Admin -> Settings -> Preferences -> Pages."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-status - Show the working tree status --find-renames[=<n>]"
},
{
"role": "assistant",
"content": "Turn on rename detection, optionally setting the similarity\nthreshold.\nSee also git-diff --find-renames ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git add . -> still \"nothing to commit\" with new files\nI am struggling with Git, I can't seem to add my files. I ran ls to show that the files are in the current directory, then ran git add . then git status which showed \"nothing to commit\".\nJJ-Computer:first_app JJ$ git init\n\nReinitialized existing Git repository in /Users/JJ/rails_projects/first_app/.git/\n\nJJ-Computer:first_app JJ$ ls\n\nDiary.txt README.rdoc config.ru log tmp\nGemfile Rakefile db public vendor\nGemfile.lock app doc script\nREADME config lib test\n\nJJ-Computer:first_app JJ$ git add .\n\nJJ-Computer:first_app Jenn$ git status\n\n# On branch master\nnothing to commit (working directory clean)\n\nJJ-Computer:first_app JJ$"
},
{
"role": "assistant",
"content": "Your commands look correct (I've done them many times that way). \nFirst try\ngit add --all\n\nand then try git status. I don't think that will solve it, but worth trying next.\nNext try looking at your .gitignore file, if you have one (in the top level where you did git init).\ncat .gitignore\n\nRemove any listings there that are causing your files to be ignored. For example is there an entry with just *?\nNext try:\ngit add --force\n\nand then try git status.\nIf none of those work, I notice that your output from git init says \"reinitialized\" rather than \"initialized\", so something may have gotten messed up. If you've just initialized it and don't mind losing history, start over by removing the .git dir:\nrm -rf .git\n\nAnd then reexecute your same commands above. If that doesn't work, some more information about your setup will be required. For example, you might have a global .gitignore file: ~/.gitignore_global that needs to edited (or removed if you don't want it)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to modify existing, unpushed commit messages?\nThis question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.\n \n \n\n\n\n\n\n\nI wrote the wrong thing in a commit message.\nHow can I change the message? The commit has not been pushed yet."
},
{
"role": "assistant",
"content": "Amending the most recent commit message\ngit commit --amend\n\nwill open your editor, allowing you to change the commit message of the most recent commit. Additionally, you can set the commit message directly in the command line with:\ngit commit --amend -m \"New commit message\"\n\n…however, this can make multi-line commit messages or small corrections more cumbersome to enter.\nMake sure you don't have any working copy changes staged before doing this or they will get committed too. (Unstaged changes will not get committed.)\nChanging the message of a commit that you've already pushed to your remote branch\nIf you've already pushed your commit up to your remote branch, then - after amending your commit locally (as described above) - you'll also need to force push the commit with:\ngit push <remote> <branch> --force\n# Or\ngit push <remote> <branch> -f\n\nWarning: force-pushing will overwrite the remote branch with the state of your local one. If there are commits on the remote branch that you don't have in your local branch, you will lose those commits.\nWarning: be cautious about amending commits that you have already shared with other people. Amending commits essentially rewrites them to have different SHA IDs, which poses a problem if other people have copies of the old commit that you've rewritten. Anyone who has a copy of the old commit will need to synchronize their work with your newly re-written commit, which can sometimes be difficult, so make sure you coordinate with others when attempting to rewrite shared commit history, or just avoid rewriting shared commits altogether.\n\nPerform an interactive rebase\nAnother option is to use interactive rebase.\nThis allows you to edit any message you want to update even if it's not the latest message.\nIn order to do a Git squash, follow these steps:\n// n is the number of commits up to the last commit you want to be able to edit\ngit rebase -i HEAD~n\n\nOnce you squash your commits - choose the e/r for editing the message:\n\nImportant note about interactive rebase\nWhen you use git rebase -i HEAD~n there can be more than n commits. Git will \"collect\" all the commits in the last n commits, and if there was a merge somewhere in between that range you will see all the commits as well, so the outcome will be n + .\nGood tip:\nIf you have to do it for more than a single branch and you might face conflicts when amending the content, set up git rerere and let Git resolve those conflicts automatically for you.\n\nDocumentation\n\ngit-commit(1) Manual Page\n\ngit-rebase(1) Manual Page\n\ngit-push(1) Manual Page"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-pull - Fetch from and integrate with another repository or a local branch --no-show-forced-updates"
},
{
"role": "assistant",
"content": "By default, git checks if a branch is force-updated during\nfetch. Pass --no-show-forced-updates or set fetch.showForcedUpdates\nto false to skip this check for performance reasons. If used during git-pull the --ff-only option will still check for forced updates\nbefore attempting a fast-forward update. See git-config ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Authentication failed for https://xxx.visualstudio.com/DefaultCollection/_git/project\nI am trying to use git to push my repository to a visual studio team services project, but I get the error:\nfatal: Authentication failed for (url of team project)\n\nI am using the commands:\ngit remote add origin\n https://XXXXXXX.visualstudio.com/DefaultCollection/_git/project\n\ngit push -u origin -–all\n\nAny idea of the fix for this?"
},
{
"role": "assistant",
"content": "I had a same issue recently (visual studio 2017 & Windows 10), and solved it using the following method:\nControl Panel --> Credential Manager --> Manage Windows Credentials --> Choose the entry of the git repository, and Edit the user and password. \nDone."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "The authenticity of host can't be established\nI am doing a git pull for the first time and have been prompted in git that the authenticity of host can't be established, the RSA key fingerprint isn't correct compared to the private key I generated. I was just wondering how I can update this so it reads the correct file and why does it read the wrong fingerprint in the first place?"
},
{
"role": "assistant",
"content": "I had similar issue, which means that the remote host is unknown /untrusted. The fix is to have the remote host entry in the known_hosts file.\nThis is what I have done:\n\nGenerate (or use existing) RSA keys and store them in the <USER.HOME>/.ssh file. If you are using eclipse, you can generate RSA keys using Preferences; \n\nGeneral -> Network Connections -> SSH2 and then select the Key Management. \nNow Click Generate RSA Key... \nAnd then Save Private Key... in the .ssh folder\n\nNow your <USER.HOME>/.ssh would contain file; private key, public key and known_hosts\nshare your public key with your trusted hosts.\nOpen Git Bash Promp (command prompt) and enter below command.\n\nssh -vt <user>@<hostname>\nFor Example: ssh -vt [email protected]\n\nWhen it prompts error ... Are you sure you want to continue connecting (yes/no)?\nSay 'yes'\nNow your remote host is added to the known_hosts\nDone.\n\nNow if you try pushing the file to remote, you don't see any errors."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is there a way to get the git root directory in one command?\nMercurial has a way of printing the root directory (that contains .hg) via\nhg root\n\nIs there something equivalent in git to get the directory that contains the .git directory?"
},
{
"role": "assistant",
"content": "Yes:\ngit rev-parse --show-toplevel\n\nIf you want to replicate the Mercurial command more directly, you can create an alias:\ngit config --global alias.root 'rev-parse --show-toplevel'\n\nand now git root will function just as hg root.\n\nNote: In a submodule this will display the root directory of the submodule and not the parent repository. If you are using Git >=2.13 or above, there is a way that submodules can show the superproject's root directory. If your git is older than that, see this other answer."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GKE Cluster can't pull (ErrImagePull) from GCR Registry in same project (GitLab Kubernetes Integration): Why?\n\nSo after googling a little bit (which is polluted by people having trouble with Pull Secrets) I am posting this here — and to GCP Support (will update as I hear).\nI created a Cluster from GitLab Kubernetes integration (docs: https://about.gitlab.com/solutions/kubernetes) within the same project as my GCR registry / images. \nWhen I add a new service / deployment to this Cluster using Kubectl (which relies on a private image within the GCR Registry in this project) the pods in the GitLab created cluster fail to pull from GCR with: ErrImagePull.\nTo be clear — I am NOT pulling from a GitLab private registry, I am attempting to pull from a GCR Registry within the same project as the GKE cluster created from GitLab (which should not require a Pull Secret).\nOther Clusters (created from GCP console) within this project can properly access the same image so my thinking is that there is some difference between Clusters created via an API (in this case from GitLab) vs Clusters created from the GCP console.\nI am hoping someone has run into this in the past — or can explain the differences in the Service Accounts etc that could be causing the problem. \n\nI am going to attempt to create a service account and manually grant it Project Viewer role to see if that solves the problem.\n\nUpdate: manually configured Service Account did not solve issue.\nNote: I am trying to pull an image into the Cluster NOT into a GitLab Runner that is running on the Cluster. Ie. I want a separate Service / Deployment to be running along side my GitLab infrastructure."
},
{
"role": "assistant",
"content": "TL;DR — Clusters created by GitLab-Ci Kubernetes Integration will not be able to pull an image from a GCR Registry in the same project as the container images — without modifying the Node(s) permissions (scopes).\n\nWhile you CAN manually modify the permissions on an Individual Node machine(s) to grant the Application Default Credentials (see: https://developers.google.com/identity/protocols/application-default-credentials) the proper scopes in real time — doing it this way would mean that if your node is re-created at some point in the future it WOULD NOT have your modified scopes and things would break.\n\nInstead of modifying the permissions manually — create a new Node pool that has the proper Scope(s) to access your required GCP services.\nHere are some resources I used for reference:\n\nhttps://medium.com/google-cloud/updating-google-container-engine-vm-scopes-with-zero-downtime-50bff87e5f80\nhttps://adilsoncarvalho.com/changing-a-running-kubernetes-cluster-permissions-a-k-a-scopes-3e90a3b95636\n\nCreating a properly Scoped Node Pool Generally looks like this\ngcloud container node-pools create [new pool name] \\\n --cluster [cluster name] \\\n --machine-type [your desired machine type] \\\n --num-nodes [same-number-nodes] \\\n --scopes [your new set of scopes]\n\nIf you aren't sure what the names of your required Scopes are — You can see a full list of Scopes AND Scope Aliases over here: https://cloud.google.com/sdk/gcloud/reference/container/node-pools/create\nFor me I did gke-default (same as my other cluster) and sql-admin. The reason for this being that I need to be able to access an SQL Database in Cloud SQL during part of my build and I don't want to have to connect to a pubic IP to do that.\ngke-default Scopes (for reference)\n\nhttps://www.googleapis.com/auth/devstorage.read_only (allows you to pull)\nhttps://www.googleapis.com/auth/logging.write\nhttps://www.googleapis.com/auth/monitoring\nhttps://www.googleapis.com/auth/service.management.readonly\nhttps://www.googleapis.com/auth/servicecontrol\nhttps://www.googleapis.com/auth/trace.append\n\nContrast the above with more locked down permissions from a GitLab-Ci created cluster ( ONLY these two: https://www.googleapis.com/auth/logging.write, https://www.googleapis.com/auth/monitoring):\nObviosuly configuring your cluster to ONLY the minimum permissions needed is for sure the way to go here. Once you figure out what that is and create your new properly scoped Node Pool...\nList your nodes with:\nkubectl get nodes\n\nThe one you just created (most recent) is has the new settings while the older option is the default gitlab cluster that can pull from the GCR.\nThen: \nkubectl cordon [your-node-name-here]\n\nAfter that you want to drain:\nkubectl drain [your-node-name-here] --force\n\nI ran into issues where the fact that I had a GitLab Runner installed meant that I couldn't drain the pods normally due to the local data / daemon set that was used to control it. \nFor that reason once I cordon'd my Node I just deleted the node from Kubectl (not sure if this will cause problems — but it was fine for me). Once your node is deleted you need to delete the 'default-pool' node pool created by GitLab.\nList your node-pools:\ngcloud container node-pools list --cluster [CLUSTER_NAME]\n\nSee the old scopes created by gitlab:\ngcloud container node-pools describe default-pool \\\n --cluster [CLUSTER_NAME]\n\nCheck to see if you have the correct new scopes (that you just added):\ngcloud container node-pools describe [NEW_POOL_NAME] \\\n --cluster [CLUSTER_NAME]\n\nIf your new Node Pool has the right scopes your deployments can now delete the default pool with:\ngcloud container node-pools delete default-pool \\\n --cluster <YOUR_CLUSTER_NAME> --zone <YOUR_ZONE>\n\nIn my personal case I am still trying to figure out how to allow access to the private network (ie. get to Cloud SQL via private IP) but I can pull my images now so I am half way there. \nI think that's it — hope it saved you a few minutes!"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can't remove file from git commit\n\nHow do I discard all git commits that haven't been pushed and then force git to not commit anything in the data/ directory?\nI'm trying to force overwrite all changes to a project stored on github from my c9.io project. I accidentally git added some mongodb data files. I tried to add the data/ directory to .gitignore. I pulled from github to get the updated .gitignore, however when I try and git push, these stubborn files in data/ are still staged for commit. I also tried git reset, git rebase, git clean and this where I changed dmpfile.sql to pi/data/node-login.1.\nPlease help I've been at this for hours and I'm really frustrated\nCounting objects: 15, done.\nDelta compression using up to 2 threads.\nCompressing objects: 100% (13/13), done.\nWriting objects: 100% (13/13), 150.22 KiB | 92 KiB/s, done.\nTotal 13 (delta 6), reused 0 (delta 0)\nremote: warning: File pi/data/local.0 is 64.00 MB; this is larger than GitHub's recommended maximum file size of 50 MB\nremote: warning: File pi/data/node-login.0 is 64.00 MB; this is larger than GitHub's recommended maximum file size of 50 MB\nremote: error: GH001: Large files detected.\nremote: error: Trace: e6ade98208c08b634ed28aefea36dfbb\nremote: error: See http://git.io/iEPt8g for more information.\nremote: error: File pi/data/node-login.1 is 128.00 MB; this exceeds GitHub's file size limit of 100 MB\nTo [email protected]:bobbyg603/goddard.git\n ! [remote rejected] master -> master (pre-receive hook declined)\nerror: failed to push some refs to '[email protected]:bobbyg603/goddard.git'\n\n.gitignore:\nlib-cov\n*.seed\n*.log\n*.csv\n*.dat\n*.out\n*.pid\n*.gz\n\ndata/\n\npids\nlogs\nresults\n\nnpm-debug.log\nnode_modules\n\n.project\n.settings\n\nThanks,\nBobby"
},
{
"role": "assistant",
"content": "Thanks to Chris I was able to fix this by running the following:\n\ngit filter-branch -f --index-filter 'git rm --cached --ignore-unmatch pi/data/node-login.0'\ngit filter-branch -f --index-filter 'git rm --cached --ignore-unmatch pi/data/node-login.1'\ngit filter-branch -f --index-filter 'git rm --cached --ignore-unmatch pi/data/local.0'"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database --name-objects"
},
{
"role": "assistant",
"content": "When displaying names of reachable objects, in addition to the\nSHA-1 also display a name that describes how they are reachable,\ncompatible with git-rev-parse , e.g. HEAD@{1234567890}~25^2:src/ ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What happens when I clone a repository with symlinks on Windows?\nThere's been a lot of questions about adding support for symlinks on Windows. But, what actually happens when I clone a repository with symlinks on Windows?"
},
{
"role": "assistant",
"content": "Since version 1.5.3 of the native Git client git clone and git init will probe the target file system for symlink support and set the local repository configuration for core.symlinks accordingly, i.e. to false for FAT or NTFS. This makes symlinks created and committed e.g. under Linux appear as plain text files that contain the link text under Windows (see the git config documentation on core.symlinks for details).\nSince Git for Windows version 2.10.2 the installer has an explicit option to enable symbolic link support.\nIn older versions of Git for Windows you can manually set core.symlinks to true which enabled Git to create symbolic links under the following constraints:\n\nSymbolic links are only available on Windows Vista and later.\nSymbolic links will only work on NTFS, not on FAT.\nYou need to be an admin and / or have the SeCreateSymbolicLinkPrivilege privilege.\nSymbolic links on remote filesystems are disabled by default.\nWindows' symbolic links are typed.\nMany programs do not understand symbolic links (that includes older version of Windows Explorer).\n\nMore details are available in the Git for Windows wiki.\nIn older versions of Git for Windows manually setting core.symlinks manually to true after cloning and reset your working tree, you would get error messages similar to\n$ git reset --hard HEAD\nerror: unable to create symlink directory (Function not implemented)\nerror: unable to create symlink linux-links/this_is_a_symbolic_link_to_file (Function not implemented)\nfatal: Could not reset index file to revision 'HEAD'.\n\nAs a side note, the JGit client did not probe the target file system for symlink support until its version 3.3, so the core.symlinks setting was falling back to whatever the system / global Git configuration was. Starting with version 3.3 JGit probes for symlink support but seems to be too conservative, setting core.symlinks = false in some cases where symlinks would be in fact supported.\nYou can checkout https://github.com/sschuberth/git-playground which contains a bunch of links created on Linux for testing."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker <commit>"
},
{
"role": "assistant",
"content": "Indicates a commit object name."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to backup a local Git repository?\nI am using git on a relatively small project and I find that zipping the .git directory's contents might be a fine way to back up the project. But this is kind of weird because, when I restore, the first thing I need to do is git reset --hard.\nAre there any problems with backing up a git repo this way? Also, is there any better way to do it (e.g., a portable git format or something similar?)?"
},
{
"role": "assistant",
"content": "The other official way would be using git bundle\nThat will create a file that supports git fetch and git pull to update your second repo.\nUseful for incremental backup and restore.\nBut if you need to backup everything (because you do not have a second repo with some older content already in place), the backup is a bit more elaborate to do, as mentioned in my other answer, after Kent Fredric's comment:\n$ git bundle create /tmp/foo master\n$ git bundle create /tmp/foo-all --all\n$ git bundle list-heads /tmp/foo\n$ git bundle list-heads /tmp/foo-all\n\n(It is an atomic operation, as opposed to making an archive from the .git folder, as commented by fantabolous)\n\nWarning: I wouldn't recommend Pat Notz's solution, which is cloning the repo.\nBackup many files are always more tricky than backing up or updating... just one.\nIf you look at the history of edits of the OP Yar answer, you would see that Yar used at first a clone --mirror, ... with the edit:\n\nUsing this with Dropbox is a total mess.\nYou will have sync errors, and you CANNOT ROLL A DIRECTORY BACK IN DROPBOX.\nUse git bundle if you want to back up to your dropbox.\n\nYar's current solution uses a git bundle.\nI rest my case."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-apply - Apply a patch to files and/or to the index --build-fake-ancestor=<file>"
},
{
"role": "assistant",
"content": "Newer git diff output has embedded index information for each blob to help identify the original version that\nthe patch applies to. When this flag is given, and if\nthe original versions of the blobs are available locally,\nbuilds a temporary index containing those blobs. When a pure mode change is encountered (which has no index information),\nthe information is read from the current index instead."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Moving Git repository content to another repository preserving history\nI am trying to move only the contents of one repository (repo1) to another existing repository (repo2) using the following commands:\ngit clone repo1\ngit clone repo2\ncd repo1\ngit remote rm origin\ngit remote add repo1\ngit push\n\nBut it's not working. I reviewed a similar post, but I only found one moving the folder, not the contents."
},
{
"role": "assistant",
"content": "I think the commands you are looking for are:\ncd repo2\ngit checkout master\ngit remote add r1remote **url-of-repo1**\ngit fetch r1remote\ngit merge r1remote/master --allow-unrelated-histories\ngit remote rm r1remote\n\nAfter that repo2/master will contain everything from repo2/master and repo1/master, and will also have the history of both of them."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Do I need to do 'git init' before doing 'git clone' on a project\nI'm doing a git clone on a project following the instructions. But, do I need to do an init in the directory beforehand?"
},
{
"role": "assistant",
"content": "git clone is basically a combination of:\n\ngit init (create the local repository)\ngit remote add (add the URL to that repository)\ngit fetch (fetch all branches from that URL to your local repository)\ngit checkout (create all the files of the main branch in your working tree)\n\nTherefore, no, you don't have to do a git init, because it is already done by git clone."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --anchored=<text>"
},
{
"role": "assistant",
"content": "Generate a diff using the \"anchored diff\" algorithm. This option may be specified more than once. If a line exists in both the source and destination, exists only once,\nand starts with this text, this algorithm attempts to prevent it from\nappearing as a deletion or addition in the output. It uses the \"patience\ndiff\" algorithm internally."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-merge-tree"
},
{
"role": "assistant",
"content": "Perform merge without touching index or working tree"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitHub \"Failed to publish this branch\" error on Windows\n\nI'm new to Git, and I just downloaded it yesterday. As a test for my first online (not local) repository, I committed a useless text file and then hit publish. After a short while, I got this very non-descriptive error:\n\nSo I know that I can't publish to this branch. There's only one and it's the master branch. Is there any further information on what might be causing this error?\nAs a side note, my partner has successfully uploaded files to the same repository, but I haven't gotten any sort of indication that this has happened. Does this mean I'm not connected to the repository properly in some way? I was the one who set it up!"
},
{
"role": "assistant",
"content": "In Windows, right click on your repository → click on Open a shell here.\nYou will see a command prompt.\nType git push in it. (been aware after seeing SimonBoudrias comment)\nThe command prompt will suggest you to type some other command or shows an error.\nIf the command prompt suggest you to type something else, then type that. It will work. \nIf the command prompt shows an error, then please post the detailed error here.\nInformation: You might want to check this app"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Cross-referencing commits in github\n\nI'd like to reference commits in other repos (in this case submodules) in the github issues of my main repo. Is it possible to do so without typing the full hyperlink in a way similar to how github creates a shortened hyperlink from the commit number?"
},
{
"role": "assistant",
"content": "The answer, so us lazy people can find it without following the link to the Autolinked References and URLs section of the GitHub help:\nUser/Project@SHA\n\nFor example:\nmojombo/god@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2\n\nShort SHAs work as well (as long as they are unique):\nmojombo/god@be6a8cc"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Remove remote git tags older than X months\n\nI am trying to delete git tags that are older than X months\nWe have release tags that we need to retain, they are all tagged release-* where * = date\nI know how to delete a singular tag git push origin :refs/tags/<tagName>\nSo I extrapolated to get all the remote tags to delete them\ngit ls-remote --tags origin | xargs git push origin :$1\nTo skip the release tags I was planning on using egrep -v making the command\ngit ls-remote --tags origin | egrep -v \"(^\\*|release*)\" | xargs git push origin :$1\nBut I still haven't figured out how to do it by date.\nLocally I can order things by date like so git for-each-ref --sort=taggerdate --format '%(refname)' refs/tags | egrep -v \"(^\\*|release*)\" but that does not help me with remote tags.\nIf it helps I don't mind deleted or not deleting local tags in order to delete the remote ones.\nFinally we use gitlab if it provides a better way of cleanup?\nRegardless this needs to be something that can be run like a script through Jenkins to help with our git cleanup needs.\nUpdate\nSince we have thousand of git tags I realized that xargs is going to be rather slow.\nI believe the way to delete will more likely be something like\ngit push origin $(< git tag | <sorting_by_date + exclude release> \\\n| sed -e 's/^/:/' | paste -sd \" \")\nThat way the command will basically be appending :refs/tags/tag1 :refs/tags/tag2 into a single command instead of doing a unique delete for every tag and contacting the remote."
},
{
"role": "assistant",
"content": "After working on this for the past couple of days I figured out a solution that works quite well.\nFirst collect all the git tags by chronological order, I excluded release* tags\ngit for-each-ref --sort=taggerdate --format '%(refname:short) %(taggerdate:short)' refs/tags | egrep -v \"(^\\*|release*)\"\nThis will give the following output\nmaster_7 2017-12-05\nmaster_8 2017-12-05\nmaster_9 2017-12-07\nmaster_10 2017-12-08\nmaster_11 2017-12-08\nupdate_framework_1 2017-12-12\nmaster_12 2017-12-12\nmaster_13 2017-12-13\n\nSo it's the name of the tag separated by a space and then the date in YYYY-MM-DD format. If you want a full date or something specific update taggerdate:short with something appropriate.\nI then took the output and processed it line by line looking at the date and comparing it with my cut off date.\nThis allowed me to generate a list of tags to delete.\nThen I run the deletions by looping through the tag list and performing the following command\ngit push origin :refs/tags/<tag1> :refs/tags/<tag2>\nI played it safe and run the command every 50 tags, but git didn't seem to have any problems with this.\nFinally after all the deletions are complete I run\ngit fetch --prune origin +refs/tags/*:refs/tags/* which deletes all local tags that do not exist in the remote.\nAnd there you have it all tags are cleaned up."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to obtain GitLab Personal Access Token from command line\n\nIs there any possibility to get Personal Access Token for Gitlab API via command line rather than web interface? I'm working on some integration tests, and Gitlab deployment into the clean environment is a part of test session setup. After deployment test user is doing some work with Gitlab API. In order to access API, test user need to provide Personal Access Token.\nI managed to dump traffic, and I see that token is provided within a rendered HTML template in response to POST request:\n00:06:40.616996 IP6 localhost.amanda > localhost.53808: Flags [P.], seq 1:580, ack 1054, win 497, options [nop,nop,TS val 3133641719 ecr 3133641673], length 579\n`..U.c.@................................'`.0...y.eIz.....k.....\n........HTTP/1.1 302 Found\nServer: nginx\nDate: Tue, 21 Nov 2017 21:06:40 GMT\nContent-Type: text/html; charset=utf-8\nContent-Length: 119\nConnection: keep-alive\nCache-Control: no-cache\nLocation: http://localhost:10080/profile/personal_access_tokens\nX-Content-Type-Options: nosniff\nX-Frame-Options: DENY\nX-Request-Id: 88178813-95ad-419a-b56b-5a5ddb183885\nX-Runtime: 0.044209\nX-Ua-Compatible: IE=edge\nX-Xss-Protection: 1; mode=block\nX-Accel-Buffering: no\n\nDeep inside response:\n<input type=\"text\" name=\"created-personal-access-token\" id=\"created-personal-access-token\" value=\"j1WZujuaKVVEkh8h8Fej\" readonly=\"readonly\" class=\"form-control js-select-on-focus\" aria-describedby=\"created-personal-access-token-help-block\" />\n\nHowever, it seems too be dirty to POST HTML Form and then parse resulting HTML in order to get the token. Can anyone share the secret how to do it right?"
},
{
"role": "assistant",
"content": "Workaround based on HTML parsing: https://github.com/vitalyisaev2/gitlab_token"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Swap git submodule with own fork\n\nI added a submodule to my git repo like this:\n$ git submodule add git://github.com/user/some-library some-library\n\nI've decided I want to create a fork of that library to do some adjustments. How can i swap that submodule so that it points to my own github fork instead?"
},
{
"role": "assistant",
"content": "The submodules are stored in .gitmodules:\n$ cat .gitmodules\n[submodule \"ext/google-maps\"]\n path = ext/google-maps\n url = git://git.naquadah.org/google-maps.git\n\nIf you edit the url with a text editor, you need to run the following:\n$ git submodule sync\n\nThis updates .git/config which contains a copy of this submodule list (you could also just edit the relevant [submodule] section of .git/config manually)\nThere might be a way to do it with only git commands, although the submodule system seems a bit incomplete (e.g see the instructions to remove a submodule)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Error when push commits with Github: fatal: could not read Username\nSince few time, I use Github for my projects and I have an issue when I want to push commits. \nTo beginning, I have forked a repository. Then I have cloned the fork (with command line git clone https://github.com/ ...) and, after doing modifications, I have committed with success (git commit -a).\nAfter this, I have tried to push commits with command line git push but I obtain the following error:\nfatal: could not read Username for 'https://github.com': No such file or directory\n\nHave you got an idea to resolve this issue?"
},
{
"role": "assistant",
"content": "What I had to do was:\ngit remote rm origin\ngit remote add origin '[email protected]:username/repo.git'\nThen, I was able to push my changes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git - how to verify if and where Git is installed on Ubuntu\nI am new to Ubuntu and Git. How I can verify that I have installed git on my machine? When I tried apt-get I got:\nroot@ubuntu:/home/nebojsa# apt-get install git\nReading package lists... Done\nBuilding dependency tree \nReading state information... Done\ngit is already the newest version.\nThe following packages were automatically installed and are no longer required:\n linux-headers-3.13.0-24 linux-headers-3.13.0-24-generic\n linux-headers-3.13.0-39 linux-headers-3.13.0-39-generic\n linux-headers-3.13.0-40 linux-headers-3.13.0-40-generic\n linux-headers-3.13.0-43 linux-headers-3.13.0-43-generic\n linux-image-3.13.0-24-generic linux-image-3.13.0-39-generic\n linux-image-3.13.0-40-generic linux-image-3.13.0-43-generic\n linux-image-extra-3.13.0-24-generic linux-image-extra-3.13.0-39-generic\n linux-image-extra-3.13.0-40-generic linux-image-extra-3.13.0-43-generic\nUse 'apt-get autoremove' to remove them.\n0 upgraded, 0 newly installed, 0 to remove and 133 not upgraded.\n\nbut I don't know where are the packages installed.\nThanks for your help!"
},
{
"role": "assistant",
"content": "Type which git. It should return the path to the executable\nIf you want to see more details: https://serverfault.com/questions/96964/list-of-files-installed-from-apt-package"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission --no-attach"
},
{
"role": "assistant",
"content": "Disable the creation of an attachment, overriding the\nconfiguration setting."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitFlow: merge to master first or after prod release?\nLearning GitFlow and I have some concerns that I don't see addressed in any of the docs/articles I've read about it.\nAt some point code on the develop branch needs to be deployed to a QA/staging environment and tested rigorously. So with GitFlow you cut a release branch off of develop, and then you deploy release to said staging environment.\nFirst, just wanted to clarify something real quick: the very first time a particular project/repo goes through this process, you'll actually be forking/creating this new release branch from develop, yes? And that all other times in the future, you're simply merging develop into release, yes?\nSo then QA tests the release branch on the staging env, all looks good, and we're ready to deploy to prod. Do you:\n\nDeploy to prod and then merge release into master? ; or\nMerge release to master and then deploy to prod?\n\nI ask because it seems like in the former case you would need to deploy the release branch to prod, then deploy to prod, and then merge to master. Which sounds OK, but often prod and non-prod environments are not identical and code that runs perfectly fine in staging chokes the second it fires up on prod servers. I know GitFlow supports the concepts of hotfix branches but they are reserved for minor fixes. In the case of a complicated fix that requires a rollback/backout release, we now have \"dirty code\" (code that breaks prod for some reason) merged into master.\nAnd in the latter case, it might take hours or even days (especially if you need to involve IT/Ops to do prod deploys) from the time you merge and put in the prod release request in, to the time the prod deploy actually occurs. And during this time you have a master branch that says \"features X, Y and Z are in prod\" but they are actually not.\nI'm wondering if GitFlow actually solves this somehow or what the known workarounds to either case are."
},
{
"role": "assistant",
"content": "The project I work in is very chaotic, decisions change in a matter of minutes, so my strategy is to procrastinate as much as possible software configuration management decisions.\nParticularly, merging into master: we only merge to master after we deployed in production and we have a confirmation e-mail that smoke tests worked fine. This way we embrace chaos by managing the risk of decision changes, rollbacks in the deploy, technical problems or whichever issue may happen.\nAt the beginning we merged into master before going into production, but technical issues, rollbacks, management decisions at the very last minute... caused lots of problems to us, so we changed the strategy, and it's been working fine for the last 3 years.\nIf, eventually, after going to production some regression is found, that's a hotfix and must be handled like that :)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.dstPrefix"
},
{
"role": "assistant",
"content": "If set, git diff uses this destination prefix. Defaults to \"b/\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I move an existing Git submodule within a Git repository?\nI would like to change the directory name of a Git submodule in my Git superproject.\nLets suppose I have the following entry in my .gitmodules file:\n[submodule \".emacs.d/vimpulse\"] \npath = .emacs.d/vimpulse \nurl = git://gitorious.org/vimpulse/vimpulse.git\n\nWhat do I have to type to move the .emacs.d/vimpulse directory to .emacs.d/vendor/vimpulse without deleting it first (explained \n here and here) and then re-adding it.\nDoes Git really need the whole path in the submodule tag\n[submodule \".emacs.d/vimpulse\"]\n\nor is it also possible to store just the name of the subproject?\n[submodule \"vimpulse\"]"
},
{
"role": "assistant",
"content": "Newer versions of git\nGit now has native support for moving submodules:\n\nSince git 1.8.5, git mv old/submod new/submod works as expected and does all the plumbing for you. You might want to use git 1.9.3 or newer, because it includes fixes for submodule moving.\n\nOlder versions of git\nAs mentioned in the comments, this answer refers to the steps needed with older versions of git.\nThe process is similar to how you'd remove a submodule (see How do I remove a submodule?):\n\nEdit .gitmodules and change the path of the submodule appropriately, and put it in the index with git add .gitmodules.\n\nIf needed, create the parent directory of the new location of the submodule (mkdir -p new/parent).\n\nMove all content from the old to the new directory (mv -vi old/parent/submodule new/parent/submodule).\n\nMake sure Git tracks this directory (git add new/parent).\n\nRemove the old directory with git rm --cached old/parent/submodule.\n\nMove the directory .git/modules/old/parent/submodule with all its content to .git/modules/new/parent/submodule.\n\nEdit the .git/modules/new/parent/config file, make sure that worktree item points to the new locations, so in this example it should be worktree = ../../../../../new/parent/module. Typically there should be two more .. than directories in the direct path in that place.\n\nEdit the file new/parent/module/.git, make sure that the path in it points to the correct new location inside the main project .git folder, so in this example gitdir: ../../../.git/modules/new/parent/submodule.\ngit status output looks like this for me afterwards:\n # On branch master\n # Changes to be committed:\n # (use \"git reset HEAD <file>...\" to unstage)\n #\n # modified: .gitmodules\n # renamed: old/parent/submodule -> new/parent/submodule\n #\n\n\nFinally, commit the changes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Mounting a volume for a gitlab service\n\nI'm trying to run a gitlab service running wiremock on my gitlab ci.\nI want to take my json files for configure wiremock from the repository and mount as a volume to the wiremock image that run as an service on gitlab ci\n.gitlab-ci.yml\nvariables:\n SHARED_PATH: $CI_PROJECT_PATH/src/main/resources\n\nservices:\n - name: wiremock/wiremock\n alias: wiremock\n \nimage: openjdk:11\n\ndeploy:jdk11:\n stage: deploy\n script:\n - 'curl -X POST http://wiremock:8080/'\n\nI want to mount the SHARED_PATH as a volume for the wiremock service"
},
{
"role": "assistant",
"content": "Currently there is no possibility to mount a volume.\nSee this in the Gitlab issue tracker: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/28121"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is a \"grafted\" commit in a shallow clone?\nWhen doing a shallow clone in git (using the --depth option), the root commit is marked as grafted.\n\nGoogling didn't lead to any satisfacting documentation.\nIt doesn't seem to have anything to do with git grafts, which the similar terminology would imply.\nIs it just a flag to signal that this commit actually has more parents and isn't the \"real\" root commit? Or is there something more special about it?"
},
{
"role": "assistant",
"content": "From your link:\n\nIt works by letting users record fake ancestry information for commits. This way you can make git pretend the set of parents a commit has is different from what was recorded when the commit was created.\n\nIn a shallow clone, your root commit is one that should have parents, but not in your repo. So it seems a good use case for grafting.\nIn effect:\n\nDef.: Shallow commits do have parents, but not in the shallow\nrepo, and therefore grafts are introduced pretending that\nthese commits have no parents."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Create a remote branch on GitHub\nIn SVN I have at least two ways to create a branch:\nsvn cp /home/me/localcheckout/trunk /home/me/localcheckout/branches/newbranch\nsvn cp http://server/trunk http://server/branches/newbranch\n\nThe first creates it locally then I have to commit the whole branch.\nThe second creates it on the server.\nThe benefit of the second is that I can svn switch my local trunk, make a few changes to some files and commit just a few KB.\nIs it possible to achieve that using Git?\nIs there a way of creating a remote branch on GitHub then pull them to my local repo?\nThe reason that I ask is that I am trying to push a couple of KB to a new remote branch from master using my phones internet connection but when I push it wants to push about 400 MB!\n\nWriting objects: 22% (54080/245586), 86.74 MiB | 13 KiB/s\n\nSee Git - pushing a remote branch for a large project is really slow for a similar question."
},
{
"role": "assistant",
"content": "It looks like github has a simple UI for creating branches. I opened the branch drop-down and it prompts me to \"Find or create a branch ...\". Type the name of your new branch, then click the \"create\" button that appears.\nTo retrieve your new branch from github, use the standard git fetch command.\n\nI'm not sure this will help your underlying problem, though, since the underlying data being pushed to the server (the commit objects) is the same no matter what branch it's being pushed to."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index --word-diff[=<mode>]"
},
{
"role": "assistant",
"content": "Show a word diff, using the <mode> to delimit changed words.\nBy default, words are delimited by whitespace; see --word-diff-regex below. The <mode> defaults to plain , and\nmust be one of: color Highlight changed words using only colors. Implies --color . plain Show words as [-removed-] and {+added+} . Makes no\nattempts to escape the delimiters if they appear in the input,\nso the output may be ambiguous. porcelain Use a special line-based format intended for script\nconsumption. Added/removed/unchanged runs are printed in the\nusual unified diff format, starting with a + / - /` `\ncharacter at the beginning of the line and extending to the\nend of the line. Newlines in the input are represented by a\ntilde ~ on a line of its own. none Disable word diff again. Note that despite the name of the first mode, color is used to\nhighlight the changed parts in all modes if enabled."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "No \"accept merge request\" button with developer level access\n\nI'm not seeing an \"Accept Merge Request\" button in gitlab despite having \"Developer\" level access. Instead there is this message:\nReady to be merged automatically\n\nAsk someone with write access to this repository to merge this request.\n\nAccording to the documentation, users with \"Developer\" access have the ability to \"manage merge requests\", but this doesn't seem possible in this case. I have two \"Developer\" level users that are seeing this problem, one of which pushed the project to the gitlab instance to begin with. I assume he must have write access?\nVersion information below\nGitLab 7.14.3\nGitLab Shell 2.6.5\nGitLab API v3\nRuby 2.1.6p336\nRails 4.1.11 \n\nPlease let me know if any more info is required."
},
{
"role": "assistant",
"content": "Developers can accept merge requests. However, it depends on how the project is configured, too.\nDevelopers can accept merge requests when:\n\nThe merge target is not a protected branch.\nThe merge target is a protected branch, if an owner/maintainer has checked the 'Developers can push' checkbox on the protected branch setting.\n\nIf a developer is seeing the message you describe it is probably because of a protected branch and the 'Developers can push' box is unchecked."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rm - Remove files from the working tree and from the index"
},
{
"role": "assistant",
"content": "REMOVING FILES THAT HAVE DISAPPEARED FROM THE FILESYSTEM There is no option for git rm to remove from the index only\nthe paths that have disappeared from the filesystem. However,\ndepending on the use case, there are several ways that can be\ndone. Using “git commit -a” If you intend that your next commit should record all modifications\nof tracked files in the working tree and record all removals of\nfiles that have been removed from the working tree with rm (as opposed to git rm ), use git commit -a , as it will\nautomatically notice and record all removals. You can also have a\nsimilar effect without committing by using git add -u . Using “git add -A” When accepting a new code drop for a vendor branch, you probably\nwant to record both the removal of paths and additions of new paths\nas well as modifications of existing paths. Typically you would first remove all tracked files from the working\ntree using this command: git ls-files -z | xargs -0 rm -f and then untar the new code in the working tree. Alternately\nyou could rsync the changes into the working tree. After that, the easiest way to record all removals, additions, and\nmodifications in the working tree is: git add -A See git-add . Other ways If all you really want to do is to remove from the index the files\nthat are no longer present in the working tree (perhaps because\nyour working tree is dirty so that you cannot use git commit -a ),\nuse the following command: git diff --name-only --diff-filter=D -z | xargs -0 git rm --cached"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Creating a GitHub repository with only a subset of a local repository's history\nThe background: I'm moving closer to open sourcing a personal research code I've been working on for more than two years. It started life as an SVN repository, but I moved to Git about a year ago, and I'd like to share the code on GitHub. However, it accumulated a lot of cruft over the years, and I'd prefer that the public version begin its life at its current status. However, I'd still like to contribute to it and incorporate other people's potential contributions.\nThe question: is there a way to \"fork\" a Git repository such that no history is retained on the fork (which lives on GitHub), but that my local repository still has a complete history, and I can pull/push to GitHub?\nI don't have any experience in the administrating end of large repositories, so detail is very much appreciated."
},
{
"role": "assistant",
"content": "You can create a new, fresh history quite easily in Git. Let’s say you want your master branch to be the one that you will push to GitHub, and your full history to be stored in old-master. You can just move your master branch to old-master, and then start a fresh new branch with no history using git checkout --orphan:\ngit branch -m master old-master\ngit checkout --orphan master\ngit commit -m \"Import clean version of my code\"\n\nNow you have a new master branch with no history, which you can push to GitHub. But, as you say, you would like to be able to see all of the old history in your local repository; and would probably like for it to not be disconnected.\nYou can do this using git replace. A replacement ref is a way of specifying an alternate commit any time Git looks at a given commit. So you can tell Git to look at the last commit of your old branch, instead of the first commit of your new branch, when looking at history. In order to do this, you need to bring in the disconnected history from the old repository.\ngit replace master old-master\n\nNow you have your new branch, in which you can see all of your history, but the actual commit objects are disconnected from the old history, and so you can push the new commits to GitHub without the old commits coming along. Push your master branch to GitHub, and only the new commits will go to GitHub. But take a look at the history in gitk or git log, and you'll see the full history.\ngit push github master:master\ngitk --all\n\nGotchas\nIf you ever base any new branches on the old commits, you will have to be careful to keep the history separate; otherwise, new commits on those branches will really have the old commits in their history, and so you'll pull the whole history along if you push it up to GitHub. As long as you keep all of your new commits based on your new master, though, you'll be fine.\nIf you ever run git push --tags github, that will push all of your tags, including old ones, which will cause all of your old history to be pulled along with it. You could deal with this by deleting all of your old tags (git tag -d $(git tag -l)), or by never using git push --tags but only ever pushing tags manually, or by using two repositories as described below.\nThe basic problem underlying both of these gotchas is that if you ever push any ref which connects to any of the old history (other than via the replaced commits), you will push up all of the old history. Probably the best way of avoiding this is by using two repositories, one which contains only the new commits, and one which contains both the old and new history, for the purpose of inspecting the full history. You do all of your work, your committing, your pushing and pulling from GitHub, in the repository with just the new commits; that way, you can't possibly accidentally push your old commits up.\nYou then pull all of your new commits into your repository that has the full history, whenever you need to look at the entire thing. You can either pull from GitHub or your other local repository, whichever is more convenient. It will be your archive, but to avoid accidentally publishing your old history, you don't ever push to GitHub from it. Here's how you can set it up:\n\n~$ mkdir newrepo\n~$ cd newrepo\nnewrepo$ git init\nnewrepo$ git pull ~/oldrepo master\n# Now newrepo has just the new history; we can set up oldrepo to pull from it\nnewrepo$ cd ~/oldrepo\noldrepo$ git remote add newrepo ~/newrepo\noldrepo$ git remote update\noldrepo$ git branch --set-upstream master newrepo/master\n# ... do work in newrepo, commit, push to GitHub, etc.\n# Now if we want to look at the full history in oldrepo:\noldrepo$ git pull\n\nIf you're on Git older than 1.7.2\nYou don't have git checkout --orphan, so you'll have to do it manually by creating a fresh repository from the current revision of your existing repository, and then pulling in your old disconnected history. You can do this with, for example:\n\noldrepo$ mkdir ~/newrepo\noldrepo$ cp $(git ls-files) ~/newrepo\noldrepo$ cd ~/newrepo\nnewrepo$ git init\nnewrepo$ git add .\nnewrepo$ git commit -m \"Import clean version of my code\"\nnewrepo$ git fetch ~/oldrepo master:old-master\n\nIf you're on Git older than 1.6.5\ngit replace and replace refs were added in 1.6.5, so you'll have to use an older, somewhat less flexible mechanism known as grafts, which allow you to specify alternate parents for a given commit. Instead of the git replace command, run:\necho $(git rev-parse master) $(git rev-parse old-master) >> .git/info/grafts\n\nThis will make it look, locally, as if the master commit has the old-master commit as its parent, so you will see one more commit than you would with git replace."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to undo local changes to a specific file [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nUndo working copy modifications of one file in Git\n\n (15 answers)\n \n\nClosed 6 years ago.\n\n\n\nI'm trying to undo local changes to a specific file. Nothing has been committed.\nWhen I want to revert all changes, I can perform git revert --reset HEAD. However, in this case, I don't want to revert all changes to all files.\nIts not clear or obvious to me how to revert just a file, even after reading the git-revert(3) man page:\nNAME\n git-revert - Revert some existing commits\n\nSYNOPSIS\n git revert [--[no-]edit] [-n] [-m parent-number] [-s] <commit>...\n git revert --continue\n git revert --quit\n git revert --abort\n...\n\nThis is similar to How to revert a specific file in a old commit on git, but no commits have been performed. And unlike OP, who wants to go back to an arbitrary commit, I just want the file to return to MASTER's copy of it.\nUnder SVN, I would just delete the file in question and then perform a svn update.\nHow do I revert changes to a single file?"
},
{
"role": "assistant",
"content": "You don't want git revert. That undoes a previous commit. You want git checkout to get git's version of the file from master.\ngit checkout -- filename.txt\nIn general, when you want to perform a git operation on a single file, use -- filename.\n\n\ngit-checkout Documentation\ngit-revert Documentation\n\n\n2020 Update\nGit introduced a new command git restore in version 2.23.0. Therefore, if you have git version 2.23.0+, you can simply git restore filename.txt - which does the same thing as git checkout -- filename.txt. The docs for this command do note that it is currently experimental.\n\ngit-restore Documentation"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-pack-refs"
},
{
"role": "assistant",
"content": "Pack heads and tags for efficient repository access"
}
] |
[
{
"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": "git-config - Get and set repository or global options http.sslVersion"
},
{
"role": "assistant",
"content": "The SSL version to use when negotiating an SSL connection, if you\nwant to force the default. The available and default version\ndepend on whether libcurl was built against NSS or OpenSSL and the\nparticular configuration of the crypto library in use. Internally\nthis sets the CURLOPT_SSL_VERSION option; see the libcurl\ndocumentation for more details on the format of this option and\nfor the ssl version supported. Currently the possible values of\nthis option are: sslv2 sslv3 tlsv1 tlsv1.0 tlsv1.1 tlsv1.2 tlsv1.3 Can be overridden by the GIT_SSL_VERSION environment variable.\nTo force git to use libcurl’s default ssl version and ignore any\nexplicit http.sslversion option, set GIT_SSL_VERSION to the\nempty string."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git - Pushing code to two remotes\n\nI have two remote git repositories. origin and github\nI push my branch devel to both repositories.\ngit push -u origin devel\ngit push -u github devel\n\nBut then, when I do. git push It would only get pushed to github.\nIs there anyway I can set up my two remotes, so that I can push changes to both repositories with one command ?"
},
{
"role": "assistant",
"content": "In recent versions of Git you can add multiple pushurls for a given remote. Use the following to add two pushurls to your origin:\ngit remote set-url --add --push origin git://original/repo.git\ngit remote set-url --add --push origin git://another/repo.git\n\nSo when you push to origin, it will push to both repositories.\nUPDATE 1: Git 1.8.0.1 and 1.8.1 (and possibly other versions) seem to have a bug that causes --add to replace the original URL the first time you use it, so you need to re-add the original URL using the same command. Doing git remote -v should reveal the current URLs for each remote.\nUPDATE 2: Junio C. Hamano, the Git maintainer, explained it's how it was designed. Doing git remote set-url --add --push <remote_name> <url> adds a pushurl for a given remote, which overrides the default URL for pushes. However, you may add multiple pushurls for a given remote, which then allows you to push to multiple remotes using a single git push. You can verify this behavior below:\n$ git clone git://original/repo.git\n$ git remote -v\norigin git://original/repo.git (fetch)\norigin git://original/repo.git (push)\n$ git config -l | grep '^remote\\.'\nremote.origin.url=git://original/repo.git\nremote.origin.fetch=+refs/heads/*:refs/remotes/origin/*\n\nNow, if you want to push to two or more repositories using a single command, you may create a new remote named all (as suggested by @Adam Nelson in comments), or keep using the origin, though the latter name is less descriptive for this purpose. If you still want to use origin, skip the following step, and use origin instead of all in all other steps.\nSo let's add a new remote called all that we'll reference later when pushing to multiple repositories:\n$ git remote add all git://original/repo.git\n$ git remote -v\nall git://original/repo.git (fetch) <-- ADDED\nall git://original/repo.git (push) <-- ADDED\norigin git://original/repo.git (fetch)\norigin git://original/repo.git (push)\n$ git config -l | grep '^remote\\.all'\nremote.all.url=git://original/repo.git <-- ADDED\nremote.all.fetch=+refs/heads/*:refs/remotes/all/* <-- ADDED\n\nThen let's add a pushurl to the all remote, pointing to another repository:\n$ git remote set-url --add --push all git://another/repo.git\n$ git remote -v\nall git://original/repo.git (fetch)\nall git://another/repo.git (push) <-- CHANGED\norigin git://original/repo.git (fetch)\norigin git://original/repo.git (push)\n$ git config -l | grep '^remote\\.all'\nremote.all.url=git://original/repo.git\nremote.all.fetch=+refs/heads/*:refs/remotes/all/*\nremote.all.pushurl=git://another/repo.git <-- ADDED\n\nHere git remote -v shows the new pushurl for push, so if you do git push all master, it will push the master branch to git://another/repo.git only. This shows how pushurl overrides the default url (remote.all.url).\nNow let's add another pushurl pointing to the original repository:\n$ git remote set-url --add --push all git://original/repo.git\n$ git remote -v\nall git://original/repo.git (fetch)\nall git://another/repo.git (push)\nall git://original/repo.git (push) <-- ADDED\norigin git://original/repo.git (fetch)\norigin git://original/repo.git (push)\n$ git config -l | grep '^remote\\.all'\nremote.all.url=git://original/repo.git\nremote.all.fetch=+refs/heads/*:refs/remotes/all/*\nremote.all.pushurl=git://another/repo.git\nremote.all.pushurl=git://original/repo.git <-- ADDED\n\nYou see both pushurls we added are kept. Now a single git push all master will push the master branch to both git://another/repo.git and git://original/repo.git.\nIMPORTANT NOTE: If your remotes have distinct rules (hooks) to accept/reject a push, one remote may accept it while the other doesn't. Therefore, if you want them to have the exact same history, you'll need to fix your commits locally to make them acceptable by both remotes and push again, or you might end up in a situation where you can only fix it by rewriting history (using push -f), and that could cause problems for people that have already pulled your previous changes from the repo."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-difftool - Show changes using common diff tools difftool.prompt"
},
{
"role": "assistant",
"content": "Prompt before each invocation of the diff tool."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.renames"
},
{
"role": "assistant",
"content": "Whether and how Git detects renames. If set to \"false\",\nrename detection is disabled. If set to \"true\", basic rename\ndetection is enabled. If set to \"copies\" or \"copy\", Git will\ndetect copies, as well. Defaults to true. Note that this\naffects only git diff Porcelain like git-diff and git-log , and not lower level commands such as git-diff-files ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I tell git-svn about a remote branch created after I fetched the repo?\nI'm using git-svn to work against my company's central Subversion repository. We've recently created a new feature branch in the central repo. \nHow do I tell Git about it? When I run git branch -r I can only see the branches that existed when I ran fetch against the Subversion repo to initialize my Git repo?"
},
{
"role": "assistant",
"content": "You can manually add the remote branch,\ngit config --add svn-remote.newbranch.url https://svn/path_to_newbranch/\ngit config --add svn-remote.newbranch.fetch :refs/remotes/newbranch\ngit svn fetch newbranch [-r<rev>]\ngit checkout -b local-newbranch -t newbranch\ngit svn rebase newbranch"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to store node modules between jobs and stages in gitlab with continuous integration\n\nI am fairly new to GitLab CI and I've been trying different approaches to use the node_modules directory in my entire pipeline. From what I've read in the official docs, cache and artifacts seem to be valid approaches to pass on files between jobs:\n\ncache is used to specify a list of files and directories which should\n be cached between jobs. You can only use paths that are within the\n project workspace.\n\nHowever, my issue with the caching method is that the node_modules would be persisted between pipelines by default:\n\n\ncache can be set globally and per-job.\nfrom GitLab 9.0, caching is enabled and shared between pipelines and jobs by default.\n\n\nI do not want to persist the node_modules between pipelines. What I actually want is to trigger a fresh install with npm in my setup stage and then allow all further jobs in the pipeline to use these modules. Hence, I started using artifacts instead of cache, which is described similarly:\n\nartifacts is used to specify a list of files and directories which\n should be attached to the job after success. [...]\nThe artifacts will be sent to GitLab after the job finishes\n successfully and will be available for download in the GitLab UI.\n The dependency feature should be used in conjunction with artifacts\n and allows you to define the artifacts to pass between different jobs.\n\nThe artifact-dependency method seems to be usable in my case. However, both cache and artifacts are extremely inefficient and slow. The node_modules are installed and usable, but the entire directory then gets uploaded somewhere and is re-downloaded between each job. (I would really love to know what happens here... Where do the modules go?)\nIs there a better approach to run npm install only once at the beginning of the pipeline and then keep the node_modules in the pipeline during its entire runtime? I do not want to keep the node_modules after all jobs are finished so they don't need to be uploaded or downloaded anywhere.\nSample pipeline configuration file to reproduce the behavior:\nimage: node:lts\n\nstages:\n - setup\n - build\n - test\n\nnode:\n stage: setup\n script:\n - npm install\n artifacts:\n paths:\n - node_modules/\n\nbuild:\n stage: build\n script:\n - npm run build\n dependencies:\n - node\n\ntest:\n stage: test\n script:\n - npm run lint\n - npm run test\n dependencies:\n - node"
},
{
"role": "assistant",
"content": "Where do the modules go?\n\nBy default artifacts are saved on the main gitlab machine:\n/var/opt/gitlab/gitlab-rails/shared/artifacts\n\nIs there a better approach to run npm install only once at the beginning of the pipeline and then keep the node_modules in the pipeline during its entire runtime?\n\nThere are some options that you can try:\n\nMerge setup and build stages to one stage.\nLocal npm cache on builder machines. Faster npm install times. Or use private npm proxy registry (for example - Nexus/Artifactory)\nCheck if gitlab main machine and the builders are in the same network so the upload/download will be faster\nConsider packaging your build in docker. You will get reusable docker images between your gitlab stages. (Of course that there is an overhead of uploading the images to docker registry)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order --show-pulls"
},
{
"role": "assistant",
"content": "In addition to the commits shown in the default history, show\neach merge commit that is not TREESAME to its first parent but\nis TREESAME to a later parent. When a merge commit is included by --show-pulls , the merge is\ntreated as if it \"pulled\" the change from another branch. When using --show-pulls on this example (and no other options) the resulting\ngraph is: I---X---R---N Here, the merge commits R and N are included because they pulled\nthe commits X and R into the base branch, respectively. These\nmerges are the reason the commits A and B do not appear in the\ndefault history. When --show-pulls is paired with --simplify-merges , the\ngraph includes all of the necessary information: .-A---M--. N\n\t / / \\ /\n\tI B R\n\t \\ / /\n\t \\ / /\n\t `---X--' Notice that since M is reachable from R , the edge from N to M was simplified away. However, N still appears in the history as an\nimportant commit because it \"pulled\" the change R into the main\nbranch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options pack.windowMemory"
},
{
"role": "assistant",
"content": "The maximum size of memory that is consumed by each thread\nin git-pack-objects for pack window memory when\nno limit is given on the command line. The value can be\nsuffixed with \"k\", \"m\", or \"g\". When left unconfigured (or\nset explicitly to 0), there will be no limit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "github linking with other repos\nI have a project that relies on two repos in github to function. \nWhen I submit my project to github how do I link to these two repos? \nShould I duplicate the files in my own repo or link to the other repo at a specific revision as I don't want it to update and cause incompatibility.\nI already created my github repo what should I do?"
},
{
"role": "assistant",
"content": "You can use git submodules to \"link\" to other projects.\nSee here - https://github.blog/2016-02-01-working-with-submodules/"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Change from master to a new default branch git\nHere is a scenerio:\nWe have a default branch master and we work off from this, creating branches and pushing up etc...\nWe have now created a develop branch off master and set this as a default development branch.\nWhat I would like to know is, how do I now know if my git pull command is requesting changes from the default branch via the command line? or point to this new default branch?\nWhat I have done:\n\nSince creating a new default branch git pull into master from origin/master\n\nAlso, any new branch, will it be from master or develop?\nAs you can see\nOn branch master\nYour branch is up to date with 'origin/master'.\n\nnothing to commit, working tree clean\nPS C:\\Users\\dir\\Documents\\GitHub\\repo> git log\ncommit 867cxx\n\nfd956f73dc91d0022b (HEAD -> master, origin/master, origin/develop, origin/HEAD)\n\nupdate:\nthis change of default branch occurred after cloning the repo."
},
{
"role": "assistant",
"content": "With git 2.28 you can set a global config with this command\ngit config --global init.defaultBranch {branchName}\nReplace {branchName} with the default branch name\nand now whenever you create a new git repo, the default branch will be this.\nMore details in my video here: https://www.youtube.com/watch?v=YccHk6QlRss"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_PROGRESS_DELAY"
},
{
"role": "assistant",
"content": "A number controlling how many seconds to delay before showing\noptional progress indicators. Defaults to 2."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitrevisions - Specifying revisions and ranges for Git :/<text> , e.g. :/fix nasty bug"
},
{
"role": "assistant",
"content": "A colon, followed by a slash, followed by a text, names\na commit whose commit message matches the specified regular expression.\nThis name returns the youngest matching commit which is\nreachable from any ref, including HEAD.\nThe regular expression can match any part of the\ncommit message. To match messages starting with a string, one can use\ne.g. :/^foo . The special sequence :/! is reserved for modifiers to what\nis matched. :/!-foo performs a negative match, while :/!!foo matches a\nliteral ! character, followed by foo . Any other sequence beginning with :/! is reserved for now.\nDepending on the given text, the shell’s word splitting rules might\nrequire additional quoting."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs -<number> -n <number> --max-count=<number>"
},
{
"role": "assistant",
"content": "Limit the number of commits to output."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git clone with custom SSH using GIT_SSH error\nI am trying to clone a Git repo using a custom SSH command. I set the SSH command in the GIT_SSH environmental variably be running \nexport GIT_SSH=\"/usr/bin/ssh -o StrictHostKeyChecking=no -i /home/me/my_private_key\". \nBut when, after the previous command I run \ngit clone [email protected]:uname/test-git-repo.git, I get the following weird error\nerror: cannot run /usr/bin/ssh -o StrictHostKeyChecking=no -i /home/me/my_private_key\nfatal: unable to fork\n\nCan you please help me out solve this issue?"
},
{
"role": "assistant",
"content": "You cannot provide options in the GIT_SSH environment variable; from the git man page:\n GIT_SSH\n If this environment variable is set then git fetch and git push will use this command instead of ssh when they need to connect\n to a remote system. The $GIT_SSH command will be given exactly two arguments: the username@host (or just host) from the URL\n and the shell command to execute on that remote system.\n\n To pass options to the program that you want to list in GIT_SSH you will need to wrap the program and options into a shell\n script, then set GIT_SSH to refer to the shell script.\n\nOne option is to add a stanza to your .ssh/config file with the appropriate configuration:\nHost bitbucket.org\n StrictHostKeyChecking no\n IdentityFile /home/me/my_private_key\n\nAnother option is to point GIT_SSH to a shell script that does what you want. E.g., in /home/me/bin/bitbucket_ssh, put:\n#!/bin/sh\nexec /usr/bin/ssh -o StrictHostKeyChecking=no -i /home/me/my_private_key \"$@\"\n\nAnd then point GIT_SSH at /home/me/bin/bitbucket_ssh.\nI prefer using .ssh/config when possible, because this avoids the need to create a per-destination script for each remote."
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.