messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git hangs while writing objects\nI'm trying to git push -u origin master And it just hangs at\nWriting objects: 99% (219/220), 12.65 MiB | 97 KiB/s\n\nThe 12.65 part shifts around. When I exit the process and run it again, it resumes at 99% but never finishes, same as before.\nIt's never pushed successfully. This is the initial commit."
},
{
"role": "assistant",
"content": "I followed VonC's advice: \ngit config --global http.postBuffer 524288000\n\n\nFor future references, based on comments:\n500 MB: 524288000 (as posted in the original answer)\n1 GB: 1048576000\n2 GB: 2097152000 (anything higher is rejected as 'out of range')"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "In Git, how can I recover a staged file that was reverted prior to committing?\nI was attempting to pull a change into my repository using Git Tower. When I did so, there was a conflict and I mistakenly hit stage all (as I wanted to commit after resolving the conflict). When I did so, the conflict marked itself as resolved.\nI wanted to manually resolve the change so I hit \"Abort Merge\", however, when I did this, It rolled back all my changes! Is there any way to get them back?"
},
{
"role": "assistant",
"content": "If you had anything staged to git, you probably should be able to get that back. (If you just changed working copy, you wouldn't be able to restore it.)\nFirst of all: Backup your repository and working copy before going ahead. (Make sure to backup the .git directory.) Also avoid closing the terminal where this happened, and/or rebooting — if all fails, you have a chance to find stuff in history / memory. Do not run git gc.\nNext, try:\n\ngit fsck --lost-found\n\nIt will print something like:\n\nChecking object directories: 100% (256/256), done.\nChecking objects: 100% (30165/30165), done.\ndangling blob 8f72c7d79f964b8279da93ca8c05bd685e892756\ndangling commit 4993502a6394491190d3f4d6fb3d1e14019c2e9b\n\nSince you lost staged files and did not do a commit, you're interested in dangling blob entries.\nRun git show <sha> for each one — some of them should be your files."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why is \"MINGW64\" appearing on my Git bash?\nI had to format my laptop, and so I had to install Git again. However it is quite different from the one I had yesterday, the icon is not the default orange one anymore, it looks more like Chrome now.\n\nThe bash is quite different, including a purple \"MINGW64\" in every line. Why is it there?\nIs this the new final version? Or did I download something different?\nI downloaded https://github.com/git-for-windows/git/releases/download/v2.5.1.windows.1/Git-2.5.1-64-bit.exe from https://git-scm.com/downloads .\nThanks!"
},
{
"role": "assistant",
"content": "Easiest way to remove 'MINGW64' is to comment two lines in file:\n\\Git\\etc\\profile.d\\git-prompt.sh\n...\n# PS1=\"$PS1\"'\\[\\033[35m\\]' # change to purple\n# PS1=\"$PS1\"'$MSYSTEM ' # show MSYSTEM"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "502 Whoops, GitLab is taking too much time to respond\n\nI installed Gitlab on Raspberry Pi2, and it had worked well for a couple of months. But since shutting down the power of RPi, it doesn't work anymore. The webpage returns 502 error.\n\n502 Whoops, GitLab is taking too much time to respond.\n\nSo I tried reconfigure (sudo gitlab-ctl reconfigure) but, it failed with the error message:\nFATAL: Errono::EAFNOSUPPORT: Address family not supported by protocol - socket(2)\n\nI don't know how to resolve this problem."
},
{
"role": "assistant",
"content": "I saw issue like this several times.\nIf GitLab has been worked fine please do not touch anything. Just wait. It seems GitLab has not been started properly :(\nI mean that after booting system you have to wait 1-2 minutes before using GitLab. GitLab needs some time for starting."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs git log --since=\"2 weeks ago\" -- gitk"
},
{
"role": "assistant",
"content": "Show the changes during the last two weeks to the file gitk .\nThe -- is necessary to avoid confusion with the branch named gitk"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I check out a specific version of a submodule using 'git submodule'?\nHow would I go about adding a Git submodule for a specific tag or commit?"
},
{
"role": "assistant",
"content": "Submodule repositories stay in a detached HEAD state pointing to a specific commit. Changing that commit simply involves checking out a different tag or commit then adding the change to the parent repository.\n$ cd submodule\n$ git checkout v2.0\nPrevious HEAD position was 5c1277e... bumped version to 2.0.5\nHEAD is now at f0a0036... version 2.0\n\ngit-status on the parent repository will now report a dirty tree: \n# On branch dev [...]\n#\n# modified: submodule (new commits)\n\nAdd the submodule directory and commit to store the new pointer."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why is indentation in empty lines bad?\nEvery FOSS project I know has rules against trailing whitespace in code. But I think it's very natural to continue the current indentation on the next line:\nint main()\n{\n....int a = 42;\n....\n....return a;\n}\n\nBut git for instance throws warnings anyway. So my question is: Why are those tabs inside the current indentation bad?\nI'm not looking for answers like \"It's always done this way\". Let's assume indentation is done consistently in the whole project in question."
},
{
"role": "assistant",
"content": "It is probably because merging patches with useless whitespace is harder than it should be.\ndiff(1) and patch(1) treat spaces and tabs as important content. (Ask any Makefile or .py source file -- they are important!) And if your \"blank line\" has four spaces on it, and my \"blank line\" has eight spaces on it, any attempt to share patches between us will fail for very trivial reasons.\nGranted, if you wholesale change the indentation of a block of code, you'll have to go to some work to make patches apply anyway. But trying to track down merge failures on lines that look blank is painful. (I've wasted too much of my life doing just that. Yes, vim listchars can help, but reading code with listchars on all the time is also annoying.)\nSo people standardize on no trailing whitespace. It might not really make sense to worry about a dozen lost bytes here or there from a storage standpoint, but it really makes merging patches easier. We could probably just as well standardize on adding trailing whitespace, exactly as you have suggested, and be just as happy, but we might as well standardize on the approach that is as parsimonious as possible."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Ignore whitespace in Visual Studio Code git diff view\nIs it possible to ignore white-space when viewing code differences of a file (generated by GIT) in Visual Studio Code? That will be really helpful in checking for actual code additions/deletions before committing."
},
{
"role": "assistant",
"content": "Add on your settings.json:\n\"diffEditor.ignoreTrimWhitespace\": true,"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is \"git remote add ...\" and \"git push origin master\"?\n\nQuite often, Git and Ruby on Rails looks like magic... such as in the first chapter of Ruby on Rails 3 Tutorial book, it talks about Git:\ngit remote add origin [email protected]:peter/first_app.git\ngit push origin master\n\nAnd it pretty much says \"it just works\" without saying too much about what they are and start talking about branching. Searching on the Internet shows that git remote add is to add a \"short name\", such as origin, and it can be any name as well, which is like an alias to a URL.\nAnd origin is the usual path of where the remote repository points to (in http://git-scm.com/book/en/Git-Basics-Working-with-Remotes under \"Adding Remote Repositories\").\nSo why is the URL not git://[email protected]/peter/first_app.git, but in the other syntax -- what syntax is it? Why must it end with .git? I tried not using .git at the end and it works too. If not .git, what else can it be? The git in [email protected] seems to be a user account on the Git server?\nAlso, why does it need to be so verbose to use git push origin master? Can't the default be origin and master? I found that the first time, the origin master is needed, but after a small edit and commit, then git push is all it needs (no need origin master). Can somebody who knows what is going on give some details?\nSometimes it feels like a lot of magic without explanation... and sometimes the person using it is so confident and when asked why, can't explain it, and respond with something like \"that's the way it is\". Sometimes very practical and pragmatic. It is not bad to be practical, but probably not practical to the point to not know what is going on."
},
{
"role": "assistant",
"content": "Git is like Unix. It is user-friendly, but it is picky about its friends. It's about as powerful and as user-friendly as a shell pipeline.\nThat being said, once you understand its paradigms and concepts, it has the same Zenlike clarity that I've come to expect from Unix command-line tools. You should consider taking some time off to read one of the many good Git tutorials available online. The Pro Git book is a good place to start.\nTo answer your first question.\n\nWhat is git remote add ...?\nAs you probably know, Git is a distributed version control system. Most operations are done locally. To communicate with the outside world, Git uses what are called \"remotes\". These are repositories other than the one on your local disk which you can push your changes into (so that other people can see them) or pull from (so that you can get others changes). The command git remote add origin [email protected]:peter/first_app.git creates a new remote called origin located at [email protected]:peter/first_app.git. Once you do this, in your push commands, you can push to origin instead of typing out the whole URL.\n\nWhat is git push origin master?\nThis is a command that says \"push the commits in the local branch named master to the remote named origin\". Once this is executed, all the stuff that you last synchronised with origin will be sent to the remote repository and other people will be able to see them there.\n\n\nNow about transports (i.e., what git://) means. Remote repository URLs can be of many types (file://, https://, etc.). Git simply relies on the authentication mechanism provided by the transport to take care of permissions and stuff. This means that for file:// URLs, it will be Unix file permissions, etc. The git:// scheme is asking Git to use its own internal transport protocol, which is optimised for sending Git changesets around. As for the exact URL, it's the way it is because of the way GitHub has set up its Git server.\nNow the verbosity. The command you've typed is the general one. It's possible to tell Git something like \"the branch called master over here is local mirror of the branch called foo on the remote called bar\". In Git speak, this means that master tracks bar/foo. When you clone for the first time, you will get a branch called master and a remote called origin (where you cloned from) with the local master set to track the master on origin.\nOnce this is set up, you can simply say git push and it'll do it. The longer command is available in case you need it (e.g., git push might push to the official public repository and git push review master can be used to push to a separate remote which your team uses to review code). You can set your branch to be a tracking branch using the --set-upstream option of the git branch command.\nI've felt that Git (unlike most other applications I've used) is better understood from the inside out. Once you understand how data is stored and maintained inside the repository, the commands and what they do become crystal clear. I do agree with you that there's some elitism amongst many Git users, but I also found that with Unix users once upon a time, and it was worth ploughing past them to learn the system. Good luck!"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Deploy to github and gitlab from same local project\n\nI have a number of Gitlab projects that I'd also like to store as repos in Github. How can I initialize a new Github repo for a project with an existing Gitlab git config? \nI read this on mirroring/moving repos, but I don't want to move anything per se, I just want to have the project exist on both Github and Gitlab.\nAnd if I do have a local project with both a Gitlab and Github git config, how can I specify which to push changes to? How would I specify to perhaps push changes to both at the same time?"
},
{
"role": "assistant",
"content": "This is to say you want to be able to deploy to multiple remote repositories\nif that's the case\nTo add new repo's run this command\n\ngit remote add < shortname > < url >\n\n git remote add origin-new [email protected]:username/repo-name.git\n\nwhere:\n\norigin-new is the remote server name (it can be any valid string)\n\n[email protected]:username/repo-name.git is the url to your online repo\n\n\nTo Show Your Remotes\n$ git remote -v\n\norigin https://gitlab.com/username/repo-name (fetch)\norigin https://gitlab.com/username/repo-name (push)\n\norigin-new https://github.com/username/repo-name (fetch)\norigin-new https://github.com/username/repo-name (push)\n\nPushing to Your Remotes\n\ngit push < remote > < branch >\n\n$ git push origin master\n\n$ git push origin-new dev\n\nFetching and Pulling from Your Remotes\n\ngit pull < remote >\n\n\ngit fetch < remote >\n\n$ git pull origin\n\n$ git pull origin-new\n\nfor more checkout out Git Basics Working with Remotes"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-commit-tree - Create a new commit object Git internal format"
},
{
"role": "assistant",
"content": "It is <unix-timestamp> <time-zone-offset> , where <unix-timestamp> is the number of seconds since the UNIX epoch. <time-zone-offset> is a positive or negative offset from UTC.\nFor example CET (which is 1 hour ahead of UTC) is +0100 ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Does Git warn me if a shorthand commit ID can refer to 2 different commits?\nIf cee157 can refer to 2 different commit IDs, such as \ncee157eb799af829a9a0c42c0915f55cd29818d4 and cee1577fecf6fc5369a80bd6e926ac5f864a754b\nwill Git warn me if I type in git log cee157? (or Git 1.8.5.2 (Apple Git-48) allows me to type in git log cee1).\nI think it should, although I can't find any authoritative source that says it would."
},
{
"role": "assistant",
"content": "It should give you something like this:\n$ git log cee157\nerror: short SHA1 cee157 is ambiguous.\nerror: short SHA1 cee157 is ambiguous.\nfatal: ambiguous argument 'cee157': unknown revision or path not in the working tree.\nUse '--' to separate paths from revisions, like this:\n'git <command> [<revision>...] -- [<file>...]'\n\nI just tested this on a real Git repository, by finding commits with duplicate prefixes like this:\ngit rev-list master | cut -c-4 | sort | uniq -c | sort -nr | head\n\nThis takes the list of revisions in master, cuts out the first 4 characters and throws away the rest, count the duplicates and sort numerically. In a my relatively small repository of ~1500 commits I found quite a few revisions with a common 4-digit prefix. I chose a 4-digit prefix because that seems to be the shortest legal length supported by Git. (Doesn't work with 3 digits or less, even if not ambiguous.)\nBtw this was not a typo, I don't know why the error message about ambiguous SHA1 appears twice, regardless of the number of duplicate SHA1 (tried with 2 and 3):\nerror: short SHA1 cee157 is ambiguous.\nerror: short SHA1 cee157 is ambiguous.\n\n(Both on stderr. Actually the entire output is on stderr, nothing on stdout.)\nTested in Windows:\n$ git --version\ngit version 1.8.1.msysgit.1\n\nI think it's safe to say that if your version is >= 1.8.1, Git will warn you of duplicates. (It will refuse to operate with duplicates.) I would guess that much older versions worked this way too.\nUPDATE\nWhen testing this, you need a minimum of 4-digit SHA1, because of int minimum_abbrev = 4 in environment.c. (Thanks @devnull for pointing that out!)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-pack-redundant"
},
{
"role": "assistant",
"content": "Find redundant pack files"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git does not recognize exe file\nI'd like to upload NuGet.exe to github but all exe files are not listed to my local repository.\nI did upload NuGet.exe file about two weeks ago at another project repo, but now I cannot upload any exe file at all. There is no global .gitignore that I specially defined.\nbelow code is my .gitignore file.\nwhat am I missing?\n# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)\n[Bb]in/\n[Oo]bj/\n\n# mstest test results\nTestResults\n\n## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\n\n# User-specific files\n*.suo\n*.user\n*.sln.docstates\n\n# Build results\n[Dd]ebug/\n[Rr]elease/\nx64/\n*_i.c\n*_p.c\n*.ilk\n*.meta\n*.obj\n*.pch\n*.pdb\n*.pgc\n*.pgd\n*.rsp\n*.sbr\n*.tlb\n*.tli\n*.tlh\n*.tmp\n*.log\n*.vspscc\n*.vssscc\n.builds\n\n# Visual C++ cache files\nipch/\n*.aps\n*.ncb\n*.opensdf\n*.sdf\n\n# Visual Studio profiler\n*.psess\n*.vsp\n*.vspx\n\n# Guidance Automation Toolkit\n*.gpState\n\n# ReSharper is a .NET coding add-in\n_ReSharper*\n\n# NCrunch\n*.ncrunch*\n.*crunch*.local.xml\n\n# Installshield output folder \n[Ee]xpress\n\n# DocProject is a documentation generator add-in\nDocProject/buildhelp/\nDocProject/Help/*.HxT\nDocProject/Help/*.HxC\nDocProject/Help/*.hhc\nDocProject/Help/*.hhk\nDocProject/Help/*.hhp\nDocProject/Help/Html2\nDocProject/Help/html\n\n# Click-Once directory\npublish\n\n# Publish Web Output\n*.Publish.xml\n\n# NuGet Packages Directory\npackages\n\n# Windows Azure Build Output\ncsx\n*.build.csdef\n\n# Windows Store app package directory\nAppPackages/\n\n# Others\n[Bb]in\n[Oo]bj\nsql\nTestResults\n[Tt]est[Rr]esult*\n*.Cache\nClientBin\n[Ss]tyle[Cc]op.*\n~$*\n*.dbmdl\nGenerated_Code #added for RIA/Silverlight projects\n\n# Backup & report files from converting an old project file to a newer\n# Visual Studio version. Backup files are not needed, because we have git ;-)\n_UpgradeReport_Files/\nBackup*/\nUpgradeLog*.XML\n\n# Windows-specific files\nThumbs.db\ndesktop.ini\n# Mac-specific things (thanks to Michael Aaron Safyan)\n.DS_Store\n\n-- EDIT --\nsame files under .nuget/ directory .config and .targets files are well treated. I can check git ls-files --others -i --exclude-standard gives NuGet.exe is ignored, but I don't know which rule makes it."
},
{
"role": "assistant",
"content": "First, you can check if a file is locally ignored ion your repo with git check-ignore:\ngit check-ignore -v -- yourFile\n\nSecond, you can force to add that file (bypassing any ignore rule):\ngit add -f yourFile"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: Clear local and remote repo and start over\n\nI accidentally got a repo in a bad state when trying to move a project from using ant to maven. Now, I would like to clear the repo and startover from scratch. Being new to git, I am a little cautious and not sure if I could just checkout then delete all files and folders locally then push to the remote repo or if that was actually a very bad idea. For some reason I'm having a hard time asking the correct questions in google. :D"
},
{
"role": "assistant",
"content": "Simply remove local .git directory, remove repo from server (if it is github - do Repo -> setiings -> remove).\nThen create new repository on server, and locally do:\ngit init\ngit remote add origin [email protected]:user/project.git\ngit add .\ngit commit -m \"Initial commit\"\ngit push -u origin master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to squash commits which have merge-commit in between?\nI am working on a feature branch.\n\nMade several commits. Squashed commits.\nPushed changes to remote branch. Got conflicts.\nMerged changes from master, resolved conflicts on feature branch.\n\ngit fetch origin master\ngit merge FETCH_HEAD\nResolved conflicts manually.\ngit commit\ngit push\n\n\nI made one more commit.\n\nSo, current commit history looks like this.\nFrom current to old:\n\ncommit 3\ncommit M yyy (Merged)\ncommit 2\n\nHow do I squash above 3 commits into 1 before I merge my feature branch to master?"
},
{
"role": "assistant",
"content": "Assuming the feature branch is called feature and the main branch main:\nCreate a temporary branch from main:\ngit checkout -b temp main\n\nSquash the feature branch in:\ngit merge --squash feature\n\nCommit the changes (the commit message contains all squashed commit messages):\ngit commit\n\nGo back to the feature branch and point it to the temp branch:\ngit checkout feature\ngit reset --hard temp\n\nDelete the temporary branch:\ngit branch -d temp"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "VS Code / Bitbucket / SSH - Permission denied (publickey)\nI'm trying to access bitbucket via ssh from vscode but always get permission denied (publickey). \nSSH key(s) are located under ~\\.ssh\\, public key(s) are correctly setup in bitbucket/settings/security/sshkeys. The keys are tested and do work! \nAfter booting, I can access my repository without problems from the windows command prompt and powershell but NOT from git bash or from vscode. Manually setting up ssh in git bash and starting vscode works though:\neval $(ssh-agent)\nssh-add /c/Users/username/.ssh/privatekey\ncode\n\nMy environment:\n\nWindows 10 Enterprise (1803/17134.765)\nVisual Studio Code (1.35.0)\ngit for windows (2.20.1.windows.1)\nbitbucket via ssh\nI think I'm using the ssh-agent that was introduced in one of the later Windows10 updates (not sure how to check, the windows ssh-agent service is running though).\nmy user folder (containing /.ssh) and the working copy of the repo are located on network drives\n\nFor me the problem boils down to one question:\nWhy is vscode not using windows native, correctly setup ssh service and instead relying on git bash ssh agent?\nDisclaimer: I spent hours reading threads about this topic and fiddling with settings. I suspect the problem to be related to the delayed deployment of network drives under Windows10 (a known issue). My windows group policy is set to wait for the network on boot/login."
},
{
"role": "assistant",
"content": "Windows 10 allows using all default OpenSSH tools. However, git was throwing permission denied for every time when I tried to clone repositories from Github, Gitlab or Bitbucket over SSH. You need to perform a few tweaks to make it work.\n\nMake sure ssh-agent service enabled, or run in Powershell (as administrator):\n\nGet-Service -Name ssh-agent | Set-Service -StartupType Manual\n\nssh-agent\nssh-add\ngit config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Disable warning about detached HEAD\nIn git if you checkout a commit directly you get a big fat warning starting with:\n\"You are in 'detached HEAD' state. You can look around ...\"\n\nIt's fine - I intend to be in detached HEAD state. However I am using this in a script and I don't want this warning in the output logs but I do want the normal output.\nMy \"ugly\" workaround now is to run the same command twice, first with -q to hide the warning, and one more time to get the normal output: HEAD is now at deadbeef... Message since the warning is only printed once.\nCan the warning be disabled so I can avoid workarounds or parsing the output ?"
},
{
"role": "assistant",
"content": "Shamelessly copying mjs's comment to post it as an answer on its own:\ngit -c advice.detachedHead=false checkout <refspec>\n\nThe -c advice.detachedHead=false parameter will allow you to suppress the warning without having to change the global config. It will only apply to the executed command. Here's the list of all advice that can be suppressed."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-count-objects"
},
{
"role": "assistant",
"content": "Count unpacked number of objects and their disk consumption"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-restore - Restore working tree files <pathspec>…"
},
{
"role": "assistant",
"content": "Limits the paths affected by the operation. For more details, see the pathspec entry in gitglossary ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Remove a file from a Git Pull Request\nI have added a local changes to an existing file into my PR by mistake.\nI want to revert only this file without deleting this file locally.\nI just want that it doesn't show up in the Pull Request.\nI don't want to create new branch as many people have commented on other files in this PR."
},
{
"role": "assistant",
"content": "If you updated a file that already existed and want to remove it from the PR:\nAssume you're working on a branch off of staging, and you PR'd a file named validate_model.py.\nTo remove this file from the PR and revert its changes, simply do:\ngit checkout staging -- validate_model.py"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Reasons for not working on the master branch in Git\nSo, I'm fairly new to git and I've after a bit of reading around over the last couple of weeks I've read a few people saying that the master branch shouldn't be changed but rather branched from and then merged to.\nI'm happy enough to work with branches but was wondering for the reasons behind not working on the master branch?"
},
{
"role": "assistant",
"content": "Other people have made very good cases for not making changes directly in master, and I agree with them. However, always advocating workflows like this sometimes leads people new to git to believe it is needlessly complex, so I wanted to provide a counterpoint.\nIf you have a one-person or very small team and your development is highly linear, i.e. you rarely work on more than one thing at a time and each feature is usually completed before starting the next, there really is little to no benefit to not work directly out of master. It is very easy to go back and add a branch at any point should the need arise. I highly recommend being aware of the feature branch workflow, but if you feel in your case it's just adding extra steps without buying you anything, I promise I won't tell the git police."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What are the differences between local branch, local tracking branch, remote branch and remote tracking branch?\nI just started using Git and I got really confused between different branches. Can anyone help me to figure out what the following branch types are?\n\nlocal branches\nlocal tracking branches\nremote branches \nremote tracking branches \n\nWhat is the difference between them? And how do they work with each other?\nA quick demo code will be really helpful I guess."
},
{
"role": "assistant",
"content": "Here's the long answer.\nRemotes:\nIf you're using Git collaboratively, you'll probably need to sync your commits with other machines or locations. Each machine or location is called a remote, in Git's terminology, and each one may have one or more branches. Most often, you'll just have one, named origin. To list all the remotes, run git remote:\n$ git remote\nbitbucket\norigin\n\nYou can see which locations these remote names are shortcuts for, by running git remote -v:\n$ git remote -v\nbitbucket [email protected]:flimm/example.git (fetch)\nbitbucket [email protected]:flimm/example.git (push)\norigin [email protected]:Flimm/example.git (fetch)\norigin [email protected]:Flimm/example.git (push)\n\nEach remote has a directory under .git/refs/remotes/:\n$ ls -F .git/refs/remotes/\nbitbucket/ origin/\n\nBranches on your machine:\nTLDR: on your local machine, you've got three types of branches: local non-tracking branches, local tracking branches, and remote-tracking branches. On a remote machine, you've just got one type of branch.\n1. Local branches\nYou can view a list of all the local branches on your machine by running git branch:\n$ git branch\nmaster\nnew-feature\n\nEach local branch has a file under .git/refs/heads/:\n$ ls -F .git/refs/heads/\nmaster new-feature\n\nThere are two types of local branches on your machine: non-tracking local branches, and tracking local branches.\n1.1 Non-tracking local branches\nNon-tracking local branches are not associated with any other branch. You create one by running git branch <branchname>.\n1.2. Tracking local branches\nTracking local branches are associated with another branch, usually a remote-tracking branch. You create one by running git branch --track <branchname> [<start-point>].\nYou can view which one of your local branches are tracking branches using git branch -vv:\n$ git branch -vv\nmaster b31f87c85 [origin/master] Example commit message\nnew-feature b760e04ed Another example commit message\n\nFrom this command's output, you can see that the local branch master is tracking the remote-tracking branch origin/master, and the local branch new-feature is not tracking anything.\nAnother way to see which branches are tracking branches is by having a look at .git/config.\nTracking local branches are useful. They allow you to run git pull and git push, without specifying which upstream branch to use. If the branch is not set up to track another branch, you'll get an error like this one:\n$ git checkout new-feature\n$ git pull\nThere is no tracking information for the current branch.\nPlease specify which branch you want to merge with.\nSee git-pull(1) for details\n\n git pull <remote> <branch>\n\nIf you wish to set tracking information for this branch you can do so with:\n\n git branch --set-upstream new-feature <remote>/<branch>\n\n2. Remote-tracking branches (still on your machine)\nYou can view a list of all the remote-tracking branches on your machine by running git branch -r:\n$ git branch -r\nbitbucket/master\norigin/master\norigin/new-branch\n\nEach remote-tracking branch has a file under .git/refs/remotes/<remote>/:\n$ tree -F .git/refs/remotes/\n.git/refs/remotes/\n├── bitbucket/\n│ └── master\n└── origin/\n ├── master\n └── new-branch\n\nThink of your remote-tracking branches as your local cache for what the remote machines contain. You can update your remote-tracking branches using git fetch, which git pull uses behind the scenes.\nEven though all the data for a remote-tracking branch is stored locally on your machine (like a cache), it's still never called a local branch. (At least, I wouldn't call it that!) It's just called a remote-tracking branch.\nBranches on a remote machine:\nYou can view all the remote branches (that is, the branches on the remote machine), by running git remote show <remote>:\n$ git remote show origin\n* remote origin\n Fetch URL: [email protected]:Flimm/example.git\n Push URL: [email protected]:Flimm/example.git\n HEAD branch: master\n Remote branches:\n io-socket-ip new (next fetch will store in remotes/origin)\n master tracked\n new-branch tracked\n Local ref configured for 'git pull':\n master merges with remote master\n new-branch merges with remote new-branch\n Local ref configured for 'git push':\n master pushes to master (up to date)\n new-branch pushes to new-branch (fast-forwardable)\n\nThis git remote command queries the remote machine over the network about its branches. It does not update the remote-tracking branches on your local machine, use git fetch or git pull for that.\nFrom the output, you can see all the branches that exist on the remote machine by looking under the heading \"Remote branches\" (ignore lines marked as \"stale\").\nIf you could log in to the remote machine and find the repository in the filesystem, you could have a look at all its branches under refs/heads/.\nCheat sheet:\n\nTo delete a local branch, whether tracking or non-tracking, safely:\n git branch -d <branchname>\n\n\nTo delete a local branch, whether tracking or non-tracking, forcefully:\n git branch -D <branchname>\n\n\nTo delete a remote-tracking branch:\n git branch -rd <remote>/<branchname>\n\n\nTo create a new local non-tracking branch:\n git branch <branchname> [<start-point>]\n\n\nTo create a new local tracking branch: (Note that if <start-point> is specified and is a remote-tracking branch like origin/foobar, then the --track flag is automatically included)\n git branch --track <branchname> [<start-point]\n\nExample:\n git branch --track hello-kitty origin/hello-kitty\n\n\nTo delete a branch on a remote machine:\n git push --delete <remote> <branchname>\n\n\nTo delete all remote-tracking branches that are stale, that is, where the corresponding branches on the remote machine no longer exist:\n git remote prune <remote>\n\n\n\n\nYou may have noticed that in some commands, you use <remote>/<branch>, and other commands, <remote> <branch>. Examples: git branch origin/hello-kitty and git push --delete origin hello-kitty.\nIt may seem arbitrary, but there is a simple way to remember when to use a slash and when to use a space. When you're using a slash, you're referring to a remote-tracking branch on your own machine, whereas when you're using a space, you're actually dealing with a branch on a remote machine over the network."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git reflog a specific branch?\nCan I reflog a specific branch?\ngit reflog shows all history on the repo. But I want to check the history of one specific branch, say production. Is there a way to do that?"
},
{
"role": "assistant",
"content": "As noted in the documentation, git reflog takes an action verb (called <subcommand>) and optional modifiers. The action defaults to show, and its optional modifier is the reference name to show.\nThe default is to show operations on HEAD. (Most, but not all, \"everyday\" commands operate on and/or through HEAD in order to operate on any other reference. Therefore the claim that git reflog shows all history is in fact false—but it does show most, which might be close enough.) This gives you an immediate and obvious answer to the question of showing operations applied to the specific branch-name production:\ngit reflog show production\n\nAs the documentation notes, git reflog show is an alias for git log -g --abbrev-commit --pretty=oneline, so you can also run:\ngit log -g --abbrev-commit --pretty=oneline production\n\nto get the exact same output. The key switch here is -g, which directs git log to walk the given ref's reflog, rather than commits reachable from the commit to which the ref points.\n(You can continue to leave out the show verb, since it's still the default, though for this case I would advise including it—for instance, if your branch is named show or expire the name will be mistaken for the verb!)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index --exit-code"
},
{
"role": "assistant",
"content": "Make the program exit with codes similar to diff(1).\nThat is, it exits with 1 if there were differences and\n0 means no differences."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to reduce the depth of an existing git clone?\nI have a clone. I want to reduce the history on it, without cloning from scratch with a reduced depth. Worked example:\n$ git clone [email protected]:apache/spark.git\n# ...\n$ cd spark/\n$ du -hs .git\n193M .git\n\nOK, so that's not so but, but it'll serve for this discussion. If I try gc it gets smaller:\n$ git gc --aggressive\nCounting objects: 380616, done.\nDelta compression using up to 4 threads.\nCompressing objects: 100% (278136/278136), done.\nWriting objects: 100% (380616/380616), done.\nTotal 380616 (delta 182748), reused 192702 (delta 0)\nChecking connectivity: 380616, done.\n$ du -hs .git\n108M .git\n\nStill, pretty big though (git pull suggests that it's still push/pullable to the remote). How about repack?\n$ git repack -a -d --depth=5\nCounting objects: 380616, done.\nDelta compression using up to 4 threads.\nCompressing objects: 100% (95388/95388), done.\nWriting objects: 100% (380616/380616), done.\nTotal 380616 (delta 182748), reused 380616 (delta 182748)\nPauls-MBA:spark paul$ du -hs .git\n108M .git\n\nYup, didn't get any smaller. --depth for repack isn't the same for clone:\n$ git clone --depth 1 [email protected]:apache/spark.git\nCloning into 'spark'...\nremote: Counting objects: 8520, done.\nremote: Compressing objects: 100% (6611/6611), done.\nremote: Total 8520 (delta 1448), reused 5101 (delta 710), pack-reused 0\nReceiving objects: 100% (8520/8520), 14.82 MiB | 3.63 MiB/s, done.\nResolving deltas: 100% (1448/1448), done.\nChecking connectivity... done.\nChecking out files: 100% (13386/13386), done.\n$ cd spark\n$ du -hs .git\n17M .git\n\nGit pull says it's still in step with the remote, which surprises nobody.\nOK - so how to change an existing clone to a shallow clone, without nixing it and checking it out afresh?"
},
{
"role": "assistant",
"content": "git fetch --depth 10\n\nthis will fetch all newer commits from origin and then cut off the local history to depth of 10.\nfor normal purposes your local git history is now at length of 10. but beware that the files of the old commits still occupy space on your disk and that the commits still exist in the remote repository.\nif your aim was to have a shorter log because you currently don't need years worth of commit history then you are done. your log will be short and most common git commands now only see 10 commits.\nif your aim was to free disk space because older commits have huge binary blobs which you don't need to work now then you have to actually remove the files from your disk. see below for a short description how to do so.\nif your aim was to completely remove the old commits (for example to remove a password from old commits) then this is not the correct command to do so. the commits are still visible and accesible for all who have access to the remote repository. you need to remove the commits from the remote repository. see below for links with more info on how to remove commits from a remote repo.\nto undo a --depth and get the entire history again:\ngit fetch --unshallow\n\n\nhow to free disk space\ndata loss warning! read the notes and pay attention to what you are doing.\nafter a git fetch --depth xx the files of the old commits still hang around on disk. git won't remove those files as long as some references are still holding on to those commits. so you need to remove those references. those references are, roughly in order of data pertinence: the reflog, stashes, tags, and branches.\nthe reflog is typically safe to clear. read the notes below for when you might want to think twice before clearing the reflog.\nto clear the reflog:\ngit reflog expire --expire=all --all\n\nstashes should be temporary anyways. so just drop them like it's hot:\ngit stash drop\n\ntags and branches typically hold data you want to keep. so be carefull with the next two commands. read the notes below for more information.\nto remove all tags:\ngit tag -l | xargs git tag -d\n\nto remove a branch:\ngit branch -d branchname\n\nbeware of data loss! read the notes below and think before you delete.\nonce you have removed all references you can call the git garbage collector to actually remove the files of the old commits:\ngit gc --prune=now\n\nnow the files should be removed from disk.\n\nnotes\ntags and branches are often synced with the remote repo. but they can also exists in your local repo only. those that exists on the remote repo can always be fetched again if needed. those that exists only locally will be lost if you delete them.\nthe easiest way to backup your local tags and branches is to copy your entire local repo to another disk. you can also clone your repo locally. but make sure to include all tags and branches as a simple clone will not. see below for a link explaining how to do so.\nthe reflog is something like a local history of past local repository states. it is entirely local to your local repository. many git commands will record the previous state of the local repository in the reflog. with the reflog you can undo some commands or at least retrieve lost data if you made a mistake. so think before you clear the reflog.\nold reflog entries are cleared automatically after a certain time by git garbage collector (about 90 days IIRC). tags and branches however will stay around forever. so if you want to free disk space you have to at least remove the tags and branches manually.\n\nsee also\nhttps://linuxhint.com/git-shallow-clone-and-clone-depth/\nhttp://gitready.com/intermediate/2009/02/09/reflog-your-safety-net.html\nHow do I edit past git commits to remove my password from the commit logs?\nDelete all local git branches\nFully backup a git repo?"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects --summary"
},
{
"role": "assistant",
"content": "Output a condensed summary of extended header information\nsuch as creations, renames and mode changes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab: why \"squash\" merge creates two commits?\n\nTo reproduce it:\n\nCreate issue\nOpen Merge Request (MR) from the issue\nMake changes with multiple commits\nCheck \"squash commits\" and Merge the MR\n\nWhy on earth this creates TWO commits in history with exactly the same changes?\nThe commits titles:\n\nMerge branch '123-branch-name' into 'dev'\nFull Issue name\n\nWhat is the point of that?"
},
{
"role": "assistant",
"content": "Sounds like you create one commit containing your changes (commit Full Issue name) and a merge commit, merging changes from that commit into dev branch.\nThe merge commit is usually created for every merge request. This can be changed in Settings->Merge Request Settings by choosing e.g. Fast Forward Merge instad of Merge Commit. This will lead to only one commit on top of your current dev HEAD, which will only work if dev can be fast forwarded.\nChecking squash commits will squash all commits in the feature branch you want to merge before merging it. Thus, if you had more than one commit in your feature branch, they would be squashed into one commit, which would be merged, creating a merge commit as you described (as long as your merge request settings are set to merge commit, see above).\nThe point of that is that you might want to see that changes were performed on a different branch. This is done by not fast forwarding the branch you merge into, but create a merge request instead. This displays that two lines of development were merged, while a fast forward merge (not creating a merge commit) would not."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options rebase.backend"
},
{
"role": "assistant",
"content": "Default backend to use for rebasing. Possible choices are apply or merge . In the future, if the merge backend gains\nall remaining capabilities of the apply backend, this setting\nmay become unused."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I merge another developer's branch into mine?\nI am relatively new to git. Our organization uses a Fork & Pull Model for managing changes to the master branch. Each developer forks the master and branches from their fork when adding new features. I keep an eye on commits that other developers are making in their own branches, and would sometimes like to merge these changes into my own branch. What steps do I take to accomplish this?"
},
{
"role": "assistant",
"content": "You first need to add the other developer repository as a remote.\ngit remote add otherrep uriToOtherRep\n\nThen you fetch changes from there\ngit fetch otherrep\n\nAnd then you merge the branch from the remote repository into yours\ngit merge otherrep/branchname\n\nHappy merging!"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Update a submodule to the latest commit\nI have a project A which is a library and it is used in a project B.\nBoth projects A and B have a separate repository on github BUT inside B we have a submodule of A.\nI edited some classes on the library, which is in the repo A, I pushed on the remote repo, so the library (repo A) is updated.\nThese updates do not reflect on the \"reference\" (the submodule) the submodule refers to a previous commit.... what should I do in order to update the submodule on git?"
},
{
"role": "assistant",
"content": "Enter the submodule directory: \ncd projB/projA\n\nPull the repo from you project A (will not update the git status of your parent, project B): \ngit pull origin master\n\nGo back to the root directory & check update:\ncd ..\ngit status\n\nIf the submodule updated before, it will show something like below: \n# Not currently on any branch.\n# Changed but not updated:\n# (use \"git add ...\" to update what will be committed)\n# (use \"git checkout -- ...\" to discard changes in working directory)\n#\n# modified: projB/projA (new commits)\n#\n\nThen, commit the update: \ngit add projB/projA\ngit commit -m \"projA submodule updated\"\n\n\nUPDATE\nAs @paul pointed out, since git 1.8, we can use\ngit submodule update --remote --merge\n\nto update the submodule to the latest remote commit. It'll be convenient in most cases."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-ls-tree - List the contents of a tree object"
},
{
"role": "assistant",
"content": "Output Format The output format of ls-tree is determined by either the --format option, or other format-altering options such as --name-only etc.\n(see --format above). The use of certain --format directives is equivalent to using those\noptions, but invoking the full formatting machinery can be slower than\nusing an appropriate formatting option. In cases where the --format would exactly map to an existing option ls-tree will use the appropriate faster path. Thus the default format\nis equivalent to: %(objectmode) %(objecttype) %(objectname)%x09%(path) This output format is compatible with what --index-info --stdin of git update-index expects. When the -l option is used, format changes to %(objectmode) %(objecttype) %(objectname) %(objectsize:padded)%x09%(path) Object size identified by <objectname> is given in bytes, and right-justified\nwith minimum width of 7 characters. Object size is given only for blobs\n(file) entries; for other entries - character is used in place of size. Without the -z option, pathnames with \"unusual\" characters are\nquoted as explained for the configuration variable core.quotePath (see git-config ). Using -z the filename is output\nverbatim and the line is terminated by a NUL byte. Customized format: It is possible to print in a custom format by using the --format option,\nwhich is able to interpolate different fields using a %(fieldname) notation.\nFor example, if you only care about the \"objectname\" and \"path\" fields, you\ncan execute with a specific \"--format\" like git ls-tree --format='%(objectname) %(path)' <tree-ish>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-grep - Print lines matching a pattern grep.lineNumber"
},
{
"role": "assistant",
"content": "If set to true, enable -n option by default."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Repository size limits for GitHub.com\n\nLately I have been using GitHub and I am wondering what is the repository size limit for files hosted on github.com?"
},
{
"role": "assistant",
"content": "Known limits\nThere are multiple repo size limits which apply.\nSoft limit\nAs of 2023, as per the docs, this is 5 GB. If you exceed this limit, is possible that you will receive an email from GitHub Support.\n\nWe recommend repositories remain small, ideally less than 1 GB, and less than 5 GB is strongly recommended.\n\nIf you happen to receive a restricting email from GitHub Support for one or more public repos, please report it as a comment to this answer along with a link to the repos, including the circumstances surrounding it.\ngit push warning limits\nAs of 2020, the archived docs (backup) excerpted below stated the following. It is reasonably assumed that this still applies. This limit can obviously be ignored.\n\nIf you reach 75GB, you'll receive a warning from Git in your terminal the next time you push a change.\n\nAlso, you'll receive a warning in the terminal for each file of over 50MB but under the hard limit.\nHard limits\nAs of 2023, although the docs don't state the per repository hard limit, it is reasonably assumed that the previously documented per repository hard limit of 100 GB still applies, at least until any theoretical email from GitHub Support is received. The docs, also excerpted below, state only the per file hard limit of 100 MB.\n\nIndividual files in a repository are strictly limited to a 100 MB\nmaximum size limit.\n\nAs of 2020, the archived docs excerpted below stated that the hard limit is 100 GB per repository. Again, it is reasonably assumed that this hard limit still applies.\n\nRepositories have a hard size limit of 100GB.\n\nAs of 2018, the documented (archive link) push size limit is 2 GB, although related considerations also apply for large pushes.\n\nwe don’t allow pushes over 2GB\n\nFiles can also be shared as binaries in a release. As of 2020, the documented size limit of each such file is 2 GB.\n\nWe don't limit the total size of the binary files in the release or the bandwidth used to deliver them. However, each individual file must be smaller than 2 GB.\n\nChecking used size\nThe size of each repo to which you directly have Admin access, but not via a team, is shown at https://github.com/settings/repositories. Alternatively, the git-sizer tool can estimate the repo size locally.\nBypassing the file size limit\nCompression can obviously be used for some files if this puts them under the limit.\nLarge files can be split into smaller chunks. If it works for your application, a tool such as tar plus split, or just split alone, can be used to split a large file into smaller parts, such as 90 MB each.\nAlthough Git LFS has separate quotas, it is however strictly advised to not use it, whether for binary or text files. This is due to the meager limits of its free plan as imposed by GitHub. If you made the mistake of using it, its usage can be checked and files can be removed from it.\nNumber of files\nThere is no established limit of the max number of files in a repo. A post from 2015 notes having 1.7 million files in a GitHub repo. Note that having 1 million files would restrict each file to a maximum average of 5 KB as per the soft limit of 5 GB or to 100 KB as per the presumed hard limit of 100 GB.\nNumber of commits\nA user reported having a repo disabled at 22 million commits.\nHow to write\nTo be able to successfully push a large number of bytes using git, it is highly likely that you'll first have to configure http.postBuffer to a sufficiently large value, with enough free system memory available.\nApart from using git, the other way to programmatically write files that are not updated much is to use the v3 REST or the v4 GraphQL APIs using a personal access token. When doing so, ensure that the user-specific hourly rate limit is not exceeded. Unlike with git, this API doesn't however seem to allow submitting an increment or a diff.\nEncryption\nIt is possible to encrypt the contents of the entire repo or just some files while using git, with several caveats.\nComparison\nFor Bitbucket, consider this answer. As feasible, I would personally push to both GitHub and Bitbucket, providing an implicit backup.\nAs of 2022, GitLab (not GitHub) looks to be lowering its free quota from 10 GB per repo to a total of just 5 GB for all repos combined! You can see the total space used in your GitLab account."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to pass values to a Gitlab CI Job\n\nI have a GitLab ci job to download and build few files and then publish to another server. I have done a POC and was successful. The problem is that I would like to customize the job when triggered manually or via API. How can i pass the dynamic values(user given) to reflect in CI job (like a filename, format etc)?\nI am using Windows runner. \nI saw trigger variables and environment variables but can be retrieved while execution once the value is set in UI. I want a bit different where I will get the values from user.\nIs it not possible in GitLab?\nEdit:\nA bit more info on how I'm using the pipeline. My pipeline has two stages - build and deploy. I want the build to run once, but I want to be able to call deploy multiple to deploy to different server. I can use the variable to determine to which server I want to deploy. Through GitLab UI this is possible - i can set variables for pipeline and also for job that overrides the pipeline variable. I just want to do the same thing through API."
},
{
"role": "assistant",
"content": "You can pass variables when starting a pipeline: https://docs.gitlab.com/ee/ci/pipelines/#run-a-pipeline-manually\n\nPipelines can be manually executed, with predefined or manually-specified variables.\n\nThese variables can be also specified on the API call: https://docs.gitlab.com/ee/api/pipelines.html#create-a-new-pipeline\n\nAn array containing the variables available in the pipeline, matching the structure [{ ‘key’ => ‘UPLOAD_TO_S3’, ‘value’ => ‘true’ }]"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-shortlog - Summarize git log output --merges"
},
{
"role": "assistant",
"content": "Print only merge commits. This is exactly the same as --min-parents=2 ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options core.fsyncObjectFiles"
},
{
"role": "assistant",
"content": "This boolean will enable fsync() when writing object files.\nThis setting is deprecated. Use core.fsync instead. This setting affects data added to the Git repository in loose-object\nform. When set to true, Git will issue an fsync or similar system call\nto flush caches so that loose-objects remain consistent in the face\nof a unclean system shutdown."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission --[no-]rename-empty"
},
{
"role": "assistant",
"content": "Whether to use empty blobs as rename source."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to move git commits from master to a different existing branch [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nMove the most recent commit(s) to a new branch with Git\n\n (23 answers)\n \n\n\nIn git, how do I remove a commit from one branch and apply it to a different branch?\n\n (2 answers)\n \n\nClosed 11 years ago.\n\n\n\nI checked in a few commits to master that should have been checked into develop. What git commands do I used to remove those commits from the master branch and include in the develop branch?"
},
{
"role": "assistant",
"content": "If I'm not mistaken, you had two synchronized branches,\nmaster and dev, and simply forgot to switch the branch,\nbefore your commits.\nIf that is the case, we have:\n----------------\ngit log in dev\n\nxxx\nyyy\n...\n----------------\n\nand:\n----------------\ngit log in master\n\nccc\nbbb\naaa\n <---- here you forgot to switch branch\nxxx\nyyy\n...\n----------------\n\nThe solution is:\nFirst, make sure, that:\ngit status -s\n\nreturns empty results.\nNext, get all your new commits from master to dev with:\ngit checkout dev\ngit merge master\n\nNow return to you master:\ngit checkout master\n\nRemove unnecessary commits:\ngit reset --hard HEAD~3\n\nThe number ~3 is the number of commits you want to remove.\nRemember: git status -s have to return empty results.\nOtherwise, git reset --hard can cause data loss."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-notes - Add or inspect object notes"
},
{
"role": "assistant",
"content": "DESCRIPTION Adds, removes, or reads notes attached to objects, without touching\nthe objects themselves. By default, notes are saved to and read from refs/notes/commits , but\nthis default can be overridden. See the OPTIONS, CONFIGURATION, and\nENVIRONMENT sections below. If this ref does not exist, it will be\nquietly created when it is first needed to store a note. A typical use of notes is to supplement a commit message without\nchanging the commit itself. Notes can be shown by git log along with\nthe original commit message. To distinguish these notes from the\nmessage stored in the commit object, the notes are indented like the\nmessage, after an unindented line saying \"Notes (<refname>):\" (or\n\"Notes:\" for refs/notes/commits ). Notes can also be added to patches prepared with git format-patch by\nusing the --notes option. Such notes are added as a patch commentary\nafter a three dash separator line. To change which notes are shown by git log , see the\n\"notes.displayRef\" discussion in CONFIGURATION . See the \"notes.rewrite.<command>\" configuration for a way to carry\nnotes across commands that rewrite commits."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order --relative-date"
},
{
"role": "assistant",
"content": "Synonym for --date=relative ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "\"did you run git update-server-info\" error on a Github repository\nI'm using the github Gui from their website to manage my repos, and I'm getting the following error:\nfatal: https://github.com/TeaCodie/TeaCodie-Website.git/info/refs not found: \ndid you run git update-server-info on the server?\n\nHow can I fix this?"
},
{
"role": "assistant",
"content": "You might have changed your repository name\nIn your local repository edit the file:\n.git/config\n\nThen check:\n[remote \"origin\"]\n url = \n\nthat the URL matches your remote repository"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index -R"
},
{
"role": "assistant",
"content": "Swap two inputs; that is, show differences from index or\non-disk file to tree contents."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I code against one github repo on 2 computers?\nI have two computers from which I want to contribute to one github repo. How can I accomplish this?"
},
{
"role": "assistant",
"content": "To keep both repositories in sync you should to pull the latest changes to your machine whenever you start working on the code. \nTo do this you want to execute\ngit pull\n\n...which is usually set up to pull from the default remote (origin) to your current branch. Git might complain if this isn't the case, and so the longer version will work as well:\ngit pull origin {branch_name}\n\nNote: this is the same process that you would use if two or more people were working on the same repo. Which is essentially what is happening, instead of two different people working on the same repository, you have two different machines working on the same repository.\nIf you are starting out fresh on a new machine all you need to do is clone the repo to it first:\ngit clone {remote_url}\n\nYou get this url from your GitHub repo's home page. This command will make a complete working copy of the repo in a subdirectory."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options pack.useSparse"
},
{
"role": "assistant",
"content": "When true, git will default to using the --sparse option in git pack-objects when the --revs option is present. This\nalgorithm only walks trees that appear in paths that introduce new\nobjects. This can have significant performance benefits when\ncomputing a pack to send a small change. However, it is possible\nthat extra objects are added to the pack-file if the included\ncommits contain certain types of direct renames. Default is true ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitprotocol-common"
},
{
"role": "assistant",
"content": "Things common to various protocols"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database gitmodulesUpdate"
},
{
"role": "assistant",
"content": "(ERROR) Found an invalid submodule update setting."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-tag - Create, list, delete or verify a tag object signed with GPG -i --ignore-case"
},
{
"role": "assistant",
"content": "Sorting and filtering tags are case insensitive."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Am I allowed to use GitLab Community Edition for commercial projects? [closed]\n\nClosed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\n This question does not appear to be about programming within the scope defined in the help center.\n\n\nClosed 9 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI've been just handed the access to a VPS at work, and I thought of installing GitLab CE on it for better teamwork organisation.\nDoes the GitLab CE license allow me to do so?"
},
{
"role": "assistant",
"content": "Yup, it is under the MIT license. There is nothing preventing you from using it for commercial projects. The other editions simply add more features and support."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database gitmodulesUrl"
},
{
"role": "assistant",
"content": "(ERROR) Found an invalid submodule url."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "SourceTree error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version\nI'm using SourceTree and try to clone from a general github repository, but I got this error:\n\nfatal: unable to access 'https://github.com/mfitzp/15-minute-apps.git/': error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version\n Completed with errors, see above.\n\nHow to solve it?"
},
{
"role": "assistant",
"content": "Check Tools > Options > Git in SourceTree, if you're using Use Embedded Git, you can see the git version is 1.9.5 which is old, latest version of git is 2.16.2.\nSo click Use System Git, if you install the newer version of git, after Use system Git it'll show newer version, then try to clone again it should work fine.\nAlso see another answer HERE."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-archive"
},
{
"role": "assistant",
"content": "Create an archive of files from a named tree"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "jenkins trigger build if new tag is released\nI want to configure jenkins so that it starts building if a new tag is released in any branch of an git repository. How do I configure this behaviour?\n\nTriggering:"
},
{
"role": "assistant",
"content": "Set refspec to: +refs/tags/*:refs/remotes/origin/tags/*\nbranch specifier: **\nUnder build triggers check Build when a change is pushed to GitHub"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc -C[<n>] --find-copies[=<n>]"
},
{
"role": "assistant",
"content": "Detect copies as well as renames. See also --find-copies-harder .\nIf n is specified, it has the same meaning as for -M<n> ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options maintenance.strategy"
},
{
"role": "assistant",
"content": "This string config option provides a way to specify one of a few\nrecommended schedules for background maintenance. This only affects\nwhich tasks are run during git maintenance run --schedule=X commands, provided no --task=<task> arguments are provided.\nFurther, if a maintenance.<task>.schedule config value is set,\nthen that value is used instead of the one provided by maintenance.strategy . The possible strategy strings are: none : This default setting implies no tasks are run at any schedule. incremental : This setting optimizes for performing small maintenance\nactivities that do not delete any data. This does not schedule the gc task, but runs the prefetch and commit-graph tasks hourly, the loose-objects and incremental-repack tasks daily, and the pack-refs task weekly."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitHub: Is it possible to collaborate with someone on a private gist?\n\nI have a private gist. If I send the URL to a friend he can view it, but cannot edit it, unless he forks it.\nIs there a way to edit it directly without forking it?"
},
{
"role": "assistant",
"content": "No. Your friend should fork the repo, and make her changes there.\nYou can then merge in your friend’s commits by:\n\nClone your gist repo locally\nAdd your friend’s fork as a remote\n\ne.g. if your friend is named Cindy: git remote add-url cindy https://gist.github.com/cindy/df03bdacaef75a80f310\n\nFetch your friend’s commits: git fetch cindy/master\nMerge your friend’s changes into your repo: git merge cindy/master\nPush the changes back to GitHub: git push origin/master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Adding Only Untracked Files\nOne of the commands I find incredibly useful in Git is git add -u to throw everything but untracked files into the index. Is there an inverse of that?\nSuch as a way to add only the untracked files to the index without identifying them individually?"
},
{
"role": "assistant",
"content": "It's easy with git add -i. Type a (for \"add untracked\"), then * (for \"all\"), then q (to quit) and you're done.\nTo do it with a single command: echo -e \"a\\n*\\nq\\n\"|git add -i"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git clone hangs forever on github\n\nWhen I follow point 5 (Test everything out) in the github guide, the ssh command also hangs forever. According to the guide, I should be presented with a message that \"Github does not provide shell access\". Below is my output from ssh -vT [email protected]\ndebug1: Authentication succeeded (publickey).\nAuthenticated to github.com ([207.97.227.239]:22).\ndebug1: channel 0: new [client-session]\ndebug1: Requesting [email protected]\ndebug1: Entering interactive session.\ndebug1: Sending environment.\ndebug1: Sending env LC_MESSAGES = en_US.UTF-8\ndebug1: Sending env LC_COLLATE = en_US.UTF-8\ndebug1: Sending env LANG = da_DK.UTF-8\ndebug1: Sending env LC_CTYPE = en_US.UTF-8"
},
{
"role": "assistant",
"content": "In my case port 22 was being blocked by a firewall, cloning via https may not work if you have 2-factor authentication enabled. Instead edit your .ssh config to use another port. In your terminal:\nnano ~/.ssh/config\n\nthen add this:\nHost github.com\n Hostname ssh.github.com\n Port 443"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options format.mboxrd"
},
{
"role": "assistant",
"content": "A boolean value which enables the robust \"mboxrd\" format when --stdout is in use to escape \"^>+From \" lines."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --dirstat-by-file[=<param1,param2>…]"
},
{
"role": "assistant",
"content": "Synonym for --dirstat=files,<param1>,<param2>…"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitignore ignore files within a folder that has whitespace in the middle\nI have a folder that have a space in the middle, but have a webconfig file inside it. I want git to ignore the webconfig file but somehow it's not ignoring it because of the space in the folder. Anybody know how to work around this?\nMy FolderName/Web.config\n\nI tried to insert the %20 in the middle but that did not help.\nThank you for your help."
},
{
"role": "assistant",
"content": "Try My\\ FolderName/Web.config or \"My FolderName/Web.config\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is a GitLab instance URL, and how can I get it?\n\nI have tried searching for it everywhere, but I can’t find anything.\nIt would be really awesome if someone could define it straight out of the box.\nI don’t know what an instance of GitLab URL is. I’m asking if someone could clarify what it is, and where can I get it. I am currently trying to add it in Visual Studio Code extension GitLab Workflow. The extension is asking for my GitLab instance URL, and I don’t know where to get it."
},
{
"role": "assistant",
"content": "The instance URL of any GitLab install is basically the link to the GitLab you're trying to connect to.\nFor example, if your project is hosted on gitlab.example.com/yourname/yourproject then for the instance URL enter https://gitlab.example.com.\nAnother example, if your project is hosted on gitlab.com/username/project then the instance URL is https://gitlab.com. Though note that in the VS Code extension specifically, gitlab.com is the default so you can leave it blank in this case."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Reset local repo to be exactly the same as remote repo\nHow do I reset my local git repo to be exactly the same as the remote repo?\nI've tried:\ngit reset --hard HEAD^\n\nBut now git status says I have diverging commits. I basically want to just wipe anything I've got locally and get the exact remote repo on my local machine."
},
{
"role": "assistant",
"content": "git reset --hard HEAD^ will only reset your working copy to the previous (parent) commit. Instead, you want to run\ngit reset --hard origin/master\n\nAssuming remote is origin and the branch you want to reset to is master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to solve \"/usr/bin/env: ruby_executable_hooks: No such file or directory\"?\nI just deploy jekyll in a vps, and config git post-receive hook on it. When I push blog update to vps from my laptop, I run into this error:\nremote: /usr/bin/env: ruby_executable_hooks: No such file or directory\n\nI searched for a while, and tried the method proposed in this post: bundle update: env: ruby_executable_hooks: No such file or directory, i.e., executing the commands below:\nrvm @global do gem regenerate_binstubs\ngem regenerate_binstubs\n\nBut it doesn't help, the error remains. Since I'm not familiar with rvm or ruby, could anyone give me a hint?"
},
{
"role": "assistant",
"content": "use wrappers, example:\n$ which jekyll\n# /path/to/rvm/gems/ruby-version/bin/jekyll\n\nin the returned path replace bin with wrappers so you get:\n/path/to/rvm/gems/ruby-version/wrappers/jekyll\n\nthis is a script that will load proper environment and fix your problem, wrappers are generated automatically withing RVM."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-pull - Fetch from and integrate with another repository or a local branch --stat -n --no-stat"
},
{
"role": "assistant",
"content": "Show a diffstat at the end of the merge. The diffstat is also\ncontrolled by the configuration option merge.stat. With -n or --no-stat do not show a diffstat at the end of the\nmerge."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-restore - Restore working tree files --"
},
{
"role": "assistant",
"content": "Do not interpret any more arguments as options."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-for-each-ref - Output information on each ref --omit-empty"
},
{
"role": "assistant",
"content": "Do not print a newline after formatted refs where the format expands\nto the empty string."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Aborting commit due to empty commit message\nAs a newbie git user, when I try to commit my work with\ngit commit -a -v\n\nand I enter a commit message in my editor, I close the file, and get this error:\nAborting commit due to empty commit message.\n\nI have read nearly all the topics addressing to this issue, changed editors, basically tried everything but nothing helps. What should I do?\nOne thing I noticed, while trying the whole process with notepad++, the file couldn't be saved. \nA possible workaround is this:\ngit commit -am \"SomeComment\"\n\nBut by doing so I feel I am kind of nullifying the purpose of using git. I want to properly document my changes."
},
{
"role": "assistant",
"content": "When you set an editor in the configuration of Git, make sure to pass the parameter \"-w\" to force Git to wait your commit message that you would type on your custom editor.\ngit config --global core.editor \"[your editor] -w\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options diff.guitool"
},
{
"role": "assistant",
"content": "Controls which diff tool is used by git-difftool when\nthe -g/--gui flag is specified. This variable overrides the value\nconfigured in merge.guitool . The list below shows the valid\nbuilt-in values. Any other value is treated as a custom diff tool\nand requires that a corresponding difftool.<guitool>.cmd variable\nis defined."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options push.followTags"
},
{
"role": "assistant",
"content": "If set to true, enable --follow-tags option by default. You\nmay override this configuration at time of push by specifying --no-follow-tags ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --ignore-blank-lines"
},
{
"role": "assistant",
"content": "Ignore changes whose lines are all blank."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options http.proxy"
},
{
"role": "assistant",
"content": "Override the HTTP proxy, normally configured using the http_proxy , https_proxy , and all_proxy environment variables (see curl(1) ). In\naddition to the syntax understood by curl, it is possible to specify a\nproxy string with a user name but no password, in which case git will\nattempt to acquire one in the same way it does for other credentials. See gitcredentials for more information. The syntax thus is [protocol://][user[:password]@]proxyhost[:port] . This can be overridden\non a per-remote basis; see remote.<name>.proxy"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects no"
},
{
"role": "assistant",
"content": "Moved lines are not highlighted."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to change the license for a project at Github? [closed]\n\nClosed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\n This question does not appear to be about programming within the scope defined in the help center.\n\n\nClosed 10 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI have created a simple list API in C and I want to release it via Github.\nIs there any way to change the license after the creation of the repository?"
},
{
"role": "assistant",
"content": "If you release it with a license, you allow people to use it as the licence describes. You can't just say \"no I changed my mind I don't want it to be under GPL\". Of course your future release may be in another license (GPL forces other people's modified versions to be GPL, but you, as the creator, may release new versions of your work under a new license).\nAmendment\nWebsites like choosealicense.com may help you to choose a suitable license. The license picker provides some templates that can be committed to your repository; for an existing repository you can bring it back this way:\n\nbrowse to your repository at GitHub.com\ncreate a new file by pressing the blue + icon (updated to: New File button)\nname it LICENSE.md or LICENSE.txt to show up the license picker again\nchoose a template"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-commit - Record changes to the repository --cleanup=<mode>"
},
{
"role": "assistant",
"content": "This option determines how the supplied commit message should be\ncleaned up before committing. The <mode> can be strip , whitespace , verbatim , scissors or default . strip Strip leading and trailing empty lines, trailing whitespace,\ncommentary and collapse consecutive empty lines. whitespace Same as strip except #commentary is not removed. verbatim Do not change the message at all. scissors Same as whitespace except that everything from (and including)\nthe line found below is truncated, if the message is to be edited.\n\" # \" can be customized with core.commentChar. # ------------------------ >8 ------------------------ default Same as strip if the message is to be edited.\nOtherwise whitespace . The default can be changed by the commit.cleanup configuration\nvariable (see git-config )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %Creset"
},
{
"role": "assistant",
"content": "reset color"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I find out who force pushed in git?\nSomeone used git push --force but I can't tell who did it from the logs. Is there a way to identify the culprit?"
},
{
"role": "assistant",
"content": "Update Nov. 2018: if you are pushing to a centralized Git repository hosting service like GitHub, then you would be able to see who has forced push your branch. But only because GitHub has chosen to surface that event in its GUI.\n\nSee more at \"Find committer of a force push on GitHub\".\n\nOriginal answer 2013: \nAs I mention in \"Distributed Version Control Systems and the Enterprise - a Good mix?\", there is no authorization or authentication with Git alone.\nYou need an authorization layer like Gitolite in order to keep track of who does what. (Gitolite comes with its own audit trail mechanism). \nBut if your repo is accessible through file (or local) protocol, then you cannot know who forced pushed.\n (from motivationalgenerator.com, and wikipedia)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_TRACE_CURL_NO_DATA"
},
{
"role": "assistant",
"content": "When a curl trace is enabled (see GIT_TRACE_CURL above), do not dump\ndata (that is, only dump info lines and headers)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to clone only a folder from a git submodule?\nI'm trying to get just a folder from an external github repo to use in my project.\nI want my project setup to be like this:\n-my_project\n -submodule\n -code.py\n -MY_README\n -.git\n\nAnd I have the remote repo named some-submodule with following structure:\n-submodule\n -code.py\n-README\n-.gitignore\n\nSo I just want the submodule folder added to my project.\nBut I end up with this after git submodule add http://github.com/user/submodule.git submodule\n-my_project\n -submodule\n -submodule\n -code.py\n -README\n -.gitignore\n -MY_README\n -.gitignore\n\nI am new to git so I really don't know if it possible using just git. If it is of some help I'm using msysgit on windows.\nSo, is there anyway that I can get a clean submodule folder in my project from a public repo?\nIf you're curious of exactly what I'm trying to do I'm trying to take directly from their repos these django plugins 1 2 to add them to my project."
},
{
"role": "assistant",
"content": "What you want to do is not feasible because you cannot clone a part of a repository. \nSee details in duplicate How to change a git submodule to point to a subfolder?"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Check that git repository exists\n\nIs there any way how to check whether git repository exist just before perform git clone action? Something like git clone $REMOTE_URL --dry-run?\nI would like to implement fast checking method which will check existence before the clone action will be performed. I expect that connection might be slow and repository might be big even more than 1GB, so I don't want to rely on time extensive operation due to simple validation. The clone will be performed asynchronously in the background when validation passes.\nI found this https://superuser.com/questions/227509/git-ping-check-if-remote-repository-exists but it works from git repository context after initial clone action is done.\nMaybe there is some git call which works without git repository context and return \"some data\" if repository on destination exist or error if doesn't."
},
{
"role": "assistant",
"content": "The answer that you linked does what you want it to do.\nTry running this in a folder without a repository in it:\ngit ls-remote https://github.com/git/git\n\nIt should show you the references on the remote, even though you haven't added a local repository with git init or done a git clone.\nSee more: https://www.kernel.org/pub/software/scm/git/docs/git-ls-remote.html"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitcvs-migration"
},
{
"role": "assistant",
"content": "Git for CVS users"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-parse - Pick out and massage parameters --verify"
},
{
"role": "assistant",
"content": "Verify that exactly one parameter is provided, and that it\ncan be turned into a raw 20-byte SHA-1 that can be used to\naccess the object database. If so, emit it to the standard\noutput; otherwise, error out. If you want to make sure that the output actually names an object in\nyour object database and/or can be used as a specific type of object\nyou require, you can add the ^{type} peeling operator to the parameter.\nFor example, git rev-parse \"$VAR^{commit}\" will make sure $VAR names an existing object that is a commit-ish (i.e. a commit, or an\nannotated tag that points at a commit). To make sure that $VAR names an existing object of any type, git rev-parse \"$VAR^{object}\" can be used. Note that if you are verifying a name from an untrusted source, it is\nwise to use --end-of-options so that the name argument is not mistaken\nfor another option."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git pushing to remote branch\nI tried to follow this post but got confused rather than getting my problem solved. \nHere is the scenario. \nI have created a branch like git checkout -b <branch_name>. I then worked on some changes and did\n\ngit add .\ngit commit -m \"comment\"\n\nNow all those changes are in my uncommitted local <branch_name> branch. What i want to do is to push these changes upstream but i want to push it to a branch which doesn't exist e.g., <branch_name>_test\nI don't want to push it to my <branch_name>. How can i do so."
},
{
"role": "assistant",
"content": "Simply push this branch to a different branch name\n git push -u origin localBranch:remoteBranch\n\nIf you don't want to set-upstream, just\n git push origin localBranch:remoteBranch"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary fast-forward"
},
{
"role": "assistant",
"content": "A fast-forward is a special type of merge where you have a revision and you are \"merging\" another branch 's changes that happen to be a descendant of what\nyou have. In such a case, you do not make a new merge commit but instead just update your branch to point at the same\nrevision as the branch you are merging. This will happen frequently on a remote-tracking branch of a remote repository ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I list just the files that would be committed?\nIs there any way to get a list of files that will be committed when I type the following?\ngit commit -m \"my changes\"\n\ngit status lists too much. I could strip out all the words, but I'd rather not. And I don't want to be told about untracked files.\nI've tried \ngit ls-files -md\n\nbut that doesn't show files that have been recently added, but not yet committed.\nI'm looking for the same output you'd get from \nsvn status -q\n\nFor example\n$ svn status -q\nA file.py\nM dir/database.py\nM start.py"
},
{
"role": "assistant",
"content": "This is what I was looking for. Thanks to notnoop for the lead I needed. I wanted to post back my solution in case it helps others.\ngit diff HEAD --name-only\n\nSince I intended to do \ngit commit -s -F mesage.txt\n\nwith the files found in the first line.\nMy intent is to create a little system that totally ignores the index i.e. that I never need to do git add. (From what I understand, the index is useful when creating patches, which isn't by no means the norm in my workflow.)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc git diff --no-index a b"
},
{
"role": "assistant",
"content": "compares two non-git things (1) and (2)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options am.keepcr"
},
{
"role": "assistant",
"content": "If true, git-am will call git-mailsplit for patches in mbox format\nwith parameter --keep-cr . In this case git-mailsplit will\nnot remove \\r from lines ending with \\r\\n . Can be overridden\nby giving --no-keep-cr from the command line.\nSee git-am , git-mailsplit ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Remove git from project in Xcode 4\nI just created a new project in Xcode 4 and I guess I left the \"Create local git repository for this project\" box checked. Now, I would like to remove this version control since I want to run the project with svn only. Is this possible or do I have to create a new project from scratch?"
},
{
"role": "assistant",
"content": "I had the same problem. Here are the steps to resolving this.\n\nGo to the Organizer (under window menu option)\nGo to Repositories\nLook at the bottom left corner for the minus button\nSelect the project to be removed from GIT\nPress the minus icon\nIt should be removed\n\nThis works, even though the class files still have the symbol next to them. Clicking them then clicking another file gets rid of the icon.\nHope this works."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker"
},
{
"role": "assistant",
"content": "SECURITY Some configuration options and hook files may cause Git to run arbitrary\nshell commands. Because configuration and hooks are not copied using git clone , it is generally safe to clone remote repositories with\nuntrusted content, inspect them with git log , and so on. However, it is not safe to run Git commands in a .git directory (or\nthe working tree that surrounds it) when that .git directory itself\ncomes from an untrusted source. The commands in its config and hooks\nare executed in the usual way. By default, Git will refuse to run when the repository is owned by\nsomeone other than the user running the command. See the entry for safe.directory in git-config . While this can help protect\nyou in a multi-user environment, note that you can also acquire\nuntrusted repositories that are owned by you (for example, if you\nextract a zip file or tarball from an untrusted source). In such cases,\nyou’d need to \"sanitize\" the untrusted repository first. If you have an untrusted .git directory, you should first clone it\nwith git clone --no-local to obtain a clean copy. Git does restrict\nthe set of options and hooks that will be run by upload-pack , which\nhandles the server side of a clone or fetch, but beware that the\nsurface area for attack against upload-pack is large, so this does\ncarry some risk. The safest thing is to serve the repository as an\nunprivileged user (either via git-daemon , ssh, or using\nother tools to change user ids). See the discussion in the SECURITY section of git-upload-pack ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "A way to restrict Git branch access?\n\nI have four branches in my git repository, which is managed using GitHub:\n\nProduction\nStaging\nMaster\n[person's name]-development\n\nIs there a way to restrict write access to only a single branch ([person's name]-development)? How would I do this? \nFor reference, a similar question: How to write a git hook to restrict writing to branch?."
},
{
"role": "assistant",
"content": "When using GitHub, your best option would be for each developer to have their own fork of the master repository. Everybody pushes to their own repository and somebody with push access to the master repository handles pulling from each developer's repository. This is how most open source projects work.\nIf using your own Git server, it should be possible to use hooks to prevent users from pushing to wrong branches."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I stage and commit all files, including newly added files, using a single command?\nHow can I stage and commit all files, including newly added files, using a single command?"
},
{
"role": "assistant",
"content": "Does\ngit add -A && git commit -m \"Your Message\"\n\ncount as a \"single command\"?\nEdit based on @thefinnomenon's answer below\nTo have it as a git alias, use:\ngit config --global alias.coa \"!git add -A && git commit -m\"\n\nand commit all files, including new files, with a message with:\ngit coa \"A bunch of horrible changes\"\n\nExplanation\nFrom git add documentation:\n\n-A, --all, --no-ignore-removal\nUpdate the index not only where the working tree has a file matching but also where the index already has an\nentry. This adds, modifies, and removes index entries to match the\nworking tree.\nIf no <pathspec> is given when -A option is used, all files in the\nentire working tree are updated (old versions of Git used to limit the\nupdate to the current directory and its subdirectories)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge - Join two or more development histories together merge.ff"
},
{
"role": "assistant",
"content": "By default, Git does not create an extra merge commit when merging\na commit that is a descendant of the current commit. Instead, the\ntip of the current branch is fast-forwarded. When set to false ,\nthis variable tells Git to create an extra merge commit in such\na case (equivalent to giving the --no-ff option from the command\nline). When set to only , only such fast-forward merges are\nallowed (equivalent to giving the --ff-only option from the\ncommand line)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Jenkins: Failed to connect to repository\n\nI'm trying to connect jenkins on a github repo.\nWhen I specify the Repo URL jenkins return the following error message: \n\nFailed to connect to repository : Command \"git ls-remote -h [email protected]:adolfosrs/jenkins-test.git HEAD\" returned status code 128:\n stdout:\n stderr: Host key verification failed.\n fatal: Could not read from remote repository.\n Please make sure you have the correct access rights\n and the repository exists.\n\nWhen using the HTTPS:// Url jenkins returns:\n\nFailed to connect to repository : Failed to connect to\n https://github.com/adolfosrs/jenkins-test.git (status = 407)\n\nI could successfully clone the repo at the same machine where jenkins is running and I also run the git ls-remote -h [email protected]:adolfosrs/jenkins-test.git HEAD command. So I have the right SSH at github."
},
{
"role": "assistant",
"content": "The problem was that somehow I created the ssh files with the root user.\nSo the files owner was root. \nThe solution was just change the ownership to the jenkins user. \nchown jenkins id_rsa.pub \nchown jenkins id_rsa"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options index.recordEndOfIndexEntries"
},
{
"role": "assistant",
"content": "Specifies whether the index file should include an \"End Of Index\nEntry\" section. This reduces index load time on multiprocessor\nmachines but produces a message \"ignoring EOIE extension\" when\nreading the index using Git versions before 2.20. Defaults to true if index.threads has been explicitly enabled, false otherwise."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options help.browser"
},
{
"role": "assistant",
"content": "Specify the browser that will be used to display help in the web format. See git-help ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "SSH Private Key Permissions using Git GUI or ssh-keygen are too open\nRecently I've been unable to clone or push to github, and I'm trying to find the root cause.\nThis is on windows\nI have cygwin + git as well as msysgit.\nMsysgit was installed with the following options:\n\nOpenSSH\nUse Git from Windows Command Prompt\n\nThat gives me 4 environments to try to use git in:\n\nWindows cmd prompt\nPowershell\nGit Bash\nCygwin\n\nSomehow I've managed to get myself into a position where when I try to clone a repository using msysgit, cmd.exe, or Powershell, I get the following error:\n> Initialized empty Git repository in\n> C:/sandbox/SomeProject/.git/\n> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n> @ WARNING: UNPROTECTED PRIVATE KEY FILE! @\n> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n> Permissions 0644 for\n> '/c/Users/Ben/.ssh/id_rsa' are too\n> open. It is recommended that your\n> private key files are NOT accessible\n> by others. This private key will be\n> ignored. bad permissions: ignore key:\n> /c/Users/Ben/.ssh/id_rsa Permission\n> denied (publickey). fatal: The remote\n> end hung up unexpectedly\n\nThis is using the .ssh folder in my c:\\users\\ben\\ folder, which is what is used by msysgit. I suspect cygwin works because the .ssh folder is located elsewhere, but I'm not sure why\nIn Git Bash, I check the permissions:\n$ ls -l -a ~/.ssh\n\nWhich gives me:\ndrwxr-xr-x 2 Ben Administ 0 Oct 12 13:09 . \ndrwxr-xr-x 34 Ben Administ 8192 Oct 12 13:15 .. \n-rw-r--r-- 1 Ben Administ 1743 Oct 12 12:36 id_rsa\n-rw-r--r-- 1 Ben Administ 399 Oct 12 12:36 id_rsa.pub \n-rw-r--r-- 1 Ben Administ 407 Oct 12 13:09 known_hosts\n\nThese permissions are apparently too relaxed. How they got this way, I have no idea.\nI can try to change them...\n$ chmod -v -R 600 ~/.ssh\n\nwhich tells me:\nmode of `.ssh' changed to 0600 (rw-------)\nmode of `.ssh/id_rsa' changed to 0600 (rw-------)\nmode of `.ssh/id_rsa.pub' changed to 0600 (rw-------)\nmode of `.ssh/known_hosts' changed to 0600 (rw-------)\n\nBut it seems to have no effect. I still get the same error, and doing \n$ ls -l -a ~/.ssh\n\nyields the same permissions as before.\nUPDATE:\nI tried to fix the permissions to those files in cygwin, and cygwin reports their permissions correctly, gitbash does not:\nalt text http://cdn.cloudfiles.mosso.com/c54102/app7962031255448924.jpg\nAny ideas on how I can really fix these permissions?"
},
{
"role": "assistant",
"content": "You changed the permissions on the whole directory, which I agree with Splash is a bad idea. If you can remember what the original permissions for the directory are, I would try to set them back to that and then do the following\ncd ~/.ssh\nchmod 700 id_rsa\n\ninside the .ssh folder. That will set the id_rsa file to rwx (read, write, execute) for the owner (you) only, and zero access for everyone else.\nIf you can't remember what the original settings are, add a new user and create a set of SSH keys for that user, thus creating a new .ssh folder which will have default permissions. You can use that new .ssh folder as the reference for permissions to reset your .ssh folder and files to.\nIf that doesn't work, I would try doing an uninstall of msysgit, deleting ALL .ssh folders on the computer (just for safe measure), then reinstalling msysgit with your desired settings and try starting over completely (though I think you told me you tried this already).\nEdited: Also just found this link via Google -- Fixing \"WARNING: UNPROTECTED PRIVATE KEY FILE!\" on Linux While it's targeted at linux, it might help since we're talking liunx permissions and such."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to integrate UML diagrams into GitLab or GitHub\n\nI want to publish some programming documentation I have in a public available repository. This documentation has formatted text, some UML diagrams, and a lot of code examples. I think that GitHub or GitLab are good places to publish this.\nTo publish the UML diagrams, I would like to have some easy way to keep them updated into the repository and visible as images in the wiki. I don't want to keep the diagrams in my computer (or on the cloud), edit them, generate an image, and then publish it every time.\nIs there a way to put the diagrams in the repository (in PlantUML syntax would be ideal), link them in the markdown text, and make the images auto-update every time the diagram is updated?"
},
{
"role": "assistant",
"content": "Edit: Alternative with Proxy service\nThis way is significantly different and simpler than the answer below; it uses the PlantUML proxy service:\nhttp://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.github.com/plantuml/plantuml-server/master/src/main/webapp/resource/test2diagrams.txt\n\nThe GitHub markdown for this would be:\n\n\nThis method suffers from not being able to specify the SVG format (it defaults to PNG), and it is perhaps not possible to work-around the caching bug mentioned in the comments.\n\nAfter trying the other answer, I discovered the service to be slow and seemingly not up to the latest version of PlantUML.\nI've found a different way that's not quite as straightforward, but it works via PlantUML.com's server (in the cloud). As such, it should work anywhere you can hotlink to an image.\nIt exploits the !includeurl function and is essentially an indirection. The markdown file links to a PlantUML source that includes the diagram's source. This method allows modifying the source in GitHub, and any images in the GitHub markdown files will automatically update. But it requires a tricky step to create the URL to the indirection.\n\n\nGet the URL to the raw PlantUML source, e.g., https://raw.githubusercontent.com/linux-china/plantuml-gist/master/src/main/uml/plantuml_gist.puml (using the example in the joanq's answer)\n\nGo to http://plantuml.com/plantuml/form (or PlantText.com) and create a one-line PlantUML source that uses the !includeurl URL-TO-RAW-PLANTUML-SOURCE-ON-GITHUB operation. Continuing with the example URL, the PlantUML (meta)source is:\n!includeurl https://raw.githubusercontent.com/linux-china/plantuml-gist/master/src/main/uml/plantuml_gist.puml\n\n\nCopy the image URL from PlantUML.com's image, e.g., http://plantuml.com:80/plantuml/png/FSfB2e0m303Hg-W1RFPUHceiDf36aWzwVEl6tOEPcGGvZXBAKtNljW9eljD9NcCFAugNU15FU3LWadWMh2GPEcVnQBoSP0ujcnS5KnmaWH7-O_kEr8TU and paste it into your GitHub markdown file. This URL won't change.\n\n\n\n\nBonus: You can even get access to the SVG format by modifying the plantuml/png/ part of the URL to be plantuml/svg/ as follows\n\n\nExample on GitHub\nhttps://github.com/fuhrmanator/course-activity-planner/blob/master/ooad/overview.md\nCaveat with private repos\nAs davidbak pointed out in a comment, the raw file in a private repo will have a URL with token=<LONGSTRINGHERE> in it, and this token changes as the source file updates. Unfortunately, the markdown breaks when this happens, so you have to update the Readme file after you commit the file to GitHub, which is not a great solution."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab Runner - New folder for each build\n\nI'm using Gitlab CI for my project. When I push on develop branch, it runs tests and update the code on my test environment (a remote server).\nBut the gitlab runner is already using the same build folder : builds/a3ac64e9/0/myproject/myproject\nBut I would like to create a now folder every time : \n\nbuilds/a3ac64e9/1/yproject/myproject\nbuilds/a3ac64e9/2/yproject/myproject\nbuilds/a3ac64e9/3/yproject/myproject\nand so on\n\nUsing this, I could just update my website by changing a symbolic link pointing to the last runner directory.\nIs there a way to configure Gitlab Runner this way ?"
},
{
"role": "assistant",
"content": "While it doesn't make sense to use your build directory as your deployment directory, you can setup a custom build directory\nOpen config.toml in a text editor: (more info on where to find it here)\nSet enabled = true under [runners.custom_build_dir] (more info here)\n[runners.custom_build_dir]\n enabled = true\n\nIn your .gitlab-ci.yml file, under variables set GIT_CLONE_PATH. It must start with $CI_BUILDS_DIR/, e.g. $CI_BUILDS_DIR/$CI_JOB_ID/$CI_PROJECT_NAME, which will probably give you what you're looking for, although if you have multiple stages, they will have different job IDs. Alternatively, you could try $CI_BUILDS_DIR/$CI_COMMIT_SHA, which would give you a unique folder for each commit. (More info here)\nvariables:\n GIT_CLONE_PATH: '$CI_BUILDS_DIR/$CI_JOB_ID/$CI_PROJECT_NAME'\n\n\nUnfortunately there is currently an issue with using GIT_BUILDS_DIR in GIT_CLONE_PATH, if you're using Windows and Powershell, so you may have to do something like this as a work-around, if all your runners have the same build directory: GIT_CLONE_PATH: 'C:\\GitLab-Runner/builds/$CI_JOB_ID/$CI_PROJECT_NAME'\n\nYou may want to take a look at the variables available to you (predefined variables) to find the most suitable variables for your path."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can you combine git add patch -p mode with diff's ignore-all-space\nHow can I do git add with patch mode but ignoring whitespace changes.\nThe use case is for when you've reformatted a file and also made changes to it. I want to commit the real code changes separately first (as shown by git diff -w path) and then commit the reformatting as a separate commit."
},
{
"role": "assistant",
"content": "Here's an adaptation from a related question.\ngit diff -w --no-color | git apply --cached --ignore-whitespace\n\nIt has the benefit that you don't need to use stash, temporary files, or perform a reset --hard on your working folders.\nAddendum\nThe solution above only stages changes except whitespace-only edits. This did not address patch, though using --patch to stage isn't straight forward in this situation.\nPatch Option 1: Edit the diff in a text editor\nThere are many ways to implement this using a text editor. Vim is especially suited to this.\nIn the root directory of your repository, start Vim.\nIn normal mode, load the diff into an empty buffer with...\n:r !git diff -w --no-color\n:set ft=diff # if you want syntax highlighting\n\nEdit the diff and remove the parts you don't want to stage.\nTo stage the contents of the vim buffer, run the vim ex command...\n:w !git apply --cached --ignore-whitespace\n\nIf you're a Vim afficionado, you could use visual mode to stage, too!\n:<',>'w !git apply --cached --ignore-whitespace\n\nYou can commit the staged changes with the ex command...\n:!git commit -m \"message\"\n# or\n:!git commit\n\nClear the buffer, read the unstaged changes, and repeat\n:bd! | set ft=diff | r !git diff -w --no-color\n\nEventually, you'll be left with only whitespace changes to commit.\nIf you don't use Vim, you could also dump git diff into a file, edit the file, save, then feed the file into git apply. Commit and repeat until done. It's a bit tedious, but functional.\nPatch Option 2: Patch reset\nIt's backwards from git add --patch, but once you've staged non-whitespace changes with...\ngit diff -w --no-color | git apply --cached --ignore-whitespace\n\n...you can unstage chunks in patch mode with...\ngit reset --patch .\n\nKeep in mind you're removing the changes that you want to keep staged. Repeat and commit as necessary until you only have whitespace changes left."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I get the commit diff in Gitlab CI?\n\nI use Gitlab CI for checking a code quality of my project. Sometime I want to check only new code ( new commit ).\nHow can I get diff from Gitlab CI ?"
},
{
"role": "assistant",
"content": "I found out solution, it was obvious, but not for me\n diff:\n script:\n - git diff ${CI_COMMIT_SHA} master\n except:\n - master"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.