messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to close git commit editor?\nI just executed a command $ git commit and it opens a new editor. But I'm trying to close that new commit editor. How to do this? I'm using Git for Windows."
},
{
"role": "assistant",
"content": "Save the file in the editor. If it's Emacs: CTRLX CTRLS to save then CTRLX CTRLC to quit or if it's vi: :wq\nPress esc first to get out from editing. (in windows/vi)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitfaq - Frequently asked questions about using Git I’m on Windows and my text files are detected as binary."
},
{
"role": "assistant",
"content": "Git works best when you store text files as UTF-8. Many programs on\nWindows support UTF-8, but some do not and only use the little-endian\nUTF-16 format, which Git detects as binary. If you can’t use UTF-8 with\nyour programs, you can specify a working tree encoding that indicates\nwhich encoding your files should be checked out with, while still\nstoring these files as UTF-8 in the repository. This allows tools like git-diff to work as expected, while still allowing your tools\nto work. To do so, you can specify a gitattributes pattern with the working-tree-encoding attribute. For example, the following pattern sets all\nC files to use UTF-16LE-BOM, which is a common encoding on Windows: *.c\tworking-tree-encoding=UTF-16LE-BOM You will need to run git add --renormalize to have this take effect. Note\nthat if you are making these changes on a project that is used across platforms,\nyou’ll probably want to make it in a per-user configuration file or in the one\nin $GIT_DIR/info/attributes , since making it in a .gitattributes file in the\nrepository will apply to all users of the repository. See the following entry for information about normalizing line endings as well,\nand see gitattributes for more information about attribute files."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to use Git on Android?\nI have a desktop application using git for synchronization. I have also an android application which do the same as the desktop, but I don't know how to do the synchronization part on it. I haven't found any implementation of git on android. I found a jgit, but its unwell documented and I was not able to do even a commit with that. \nI was thinking about remote commands to my git server from my android app, but this is really a tease for me. \nCould you tell me if any other git implementation which can be used on android exists? If you have any idea how to solve that, please tell me."
},
{
"role": "assistant",
"content": "Since this question was first posted, an Android app has been added to the market that can checkout Git repos, called Agit. It can't commit or push yet, but the clone/fetch/pull functionality is useful. The other issue is that a patched version of ConnectBot needs to be installed before Agit if you want to use SSH keys. If you already have ConnectBot, uninstall it first. I did not do this and ran into problems.\nEdit: As of April 2021, the ability to push and pull has been added, however, it does seem to be very buggy as I have only been able to pull changes, but never push them."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects -I<regex> --ignore-matching-lines=<regex>"
},
{
"role": "assistant",
"content": "Ignore changes whose all lines match <regex>. This option may\nbe specified more than once."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fetch - Download objects and refs from another repository fetch.fsck.skipList"
},
{
"role": "assistant",
"content": "Acts like fsck.skipList , but is used by git-fetch-pack instead of git-fsck . See\nthe fsck.skipList documentation for details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I move a Git repository with all branches from Bitbucket to GitHub?\n\nWhat is the best way to move a Git repository with all branches and full history from Bitbucket to GitHub?\nIs there a script or a list of commands I have to use?"
},
{
"role": "assistant",
"content": "It's very simple.\n\nCreate a new empty repository in GitHub (without a README or license, you can add them later) and the following screen will show.\n\nIn the import code option, paste your Bitbucket repository's URL and voilà!!"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc -W --function-context"
},
{
"role": "assistant",
"content": "Show whole function as context lines for each change.\nThe function names are determined in the same way as git diff works out patch hunk headers (see Defining a\ncustom hunk-header in gitattributes )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Android Studio - Push failed: fatal: Could not read from remote repository\nI have a git project at Android Studio and a remote at BitBucket and I changed it to use SSH instead of HTTPS. I can make everything work using Atlassian's SourceTree, but in Android Studio every time I try to push the project it says \n\nPush failed: fatal: Could not read from remote repository.\n\nDoes anyone have a clue about what could be happening?"
},
{
"role": "assistant",
"content": "This is probably an Intellij problem. Your key are managed natively by ssh, and Intellij has it's own ssh program.\nGo to the settings, search git->ssh executable then choose native\nAs seen here : git with IntelliJ IDEA: Could not read from remote repository"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-ls-files"
},
{
"role": "assistant",
"content": "Show information about files in the index and the working tree"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": ".gitignore file, where should I put it in my xcode project?\nI want git to ignore my UserInterfaceState.xcuserstate file in my XCode4 project, but where should I put the .gitignore file?, is it inside the .git folder? or out? The .git is in same folder with the ProjectName.xcodeproj file"
},
{
"role": "assistant",
"content": "You can have a .gitignore in every single directory of your project. \nHowever, the best practice is to have one single .gitignore file on the project root directory, and place all files that you want to ignore in it, like this:\nignoredFile.whatever\nignoredDirectory/*\ndirectory/ignoredFileInsideDirectory\n.svn\n\nOnce you create the .gitignore file, the ignore files that have changes or are new into the repository will not be shown to as waiting for commit.\nYou can also have one global local git ignore file, that will manage all of your git repositories.\ngit config --global core.excludesfile ~/.gitignore_global\nThis alternative is particularly interesting for ignored files that are non-project related, such as IDE related files and so on."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-cat-file - Provide contents or details of repository objects -Z"
},
{
"role": "assistant",
"content": "Only meaningful with --batch , --batch-check , or --batch-command ; input and output is NUL-delimited instead of\nnewline-delimited."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the best way to do CI/CD with AWS CDK (python) using GitLab CI?\n\nI am using AWS CDK (with Python) for a containerized application that runs on Fargate. I would like to run cdk deploy in a GitLab CI process and pass the git tag as an environment variable that replaces the container running in Fargate. I am currently doing something similar with CloudFormation (aws cloudformation update-stack ...). Is anyone else doing CI/CD with AWS CDK in this way? Is there a better way to do it? \nAlso, what should I use for my base image for this job? I was thinking that I can either start with a python container and install node or vice versa. Or maybe there is prebuilt container somewhere that I haven't been able to find yet. \nHere is start that seems to be working well:\nCDK:\n image: python:3.8\n stage: deploy\n before_script:\n - apt-get -qq update && apt-get -y install nodejs npm\n - node -v\n - npm i -g aws-cdk\n - cd awscdk\n - pip3 install -r requirements.txt\n script:\n - cdk diff\n - cdk deploy --require-approval never\n\nEdit 2020-05-04:\nCDK can build docker images during cdk deploy, but it needs access to docker. If you don't need docker, the above CI job definition should be fine. Here's the current CI job I'm using: \ncdk deploy:\n image: docker:19.03.1\n services:\n - docker:19.03.5-dind\n stage: deploy\n only:\n - master\n before_script:\n - apk add --no-cache python3\n - python3 -V\n - pip3 -V\n - apk add nodejs-current npm\n - node -v\n - npm i -g aws-cdk\n - cd awscdk\n - pip3 install -r requirements.txt\n script:\n - cdk bootstrap aws://$AWS_ACCOUNT_ID/$AWS_DEFAULT_REGION\n - cdk deploy --require-approval never\n\nThe cdk bootstrap is needed because I am using assets in my cdk code:\n self.backend_task.add_container(\n \"DjangoBackend\",\n image=ecs.AssetImage(\n \"../backend\",\n file=\"scripts/prod/Dockerfile\",\n target=\"production\",\n ),\n logging=ecs.LogDrivers.aws_logs(stream_prefix=\"Backend\"),\n environment=environment_variables,\n command=[\"/start_prod.sh\"],\n )\n\nHere's more information on cdk bootstrap: https://github.com/aws/aws-cdk/blob/master/design/cdk-bootstrap.md"
},
{
"role": "assistant",
"content": "you definitely have to use CDK deploy inside the CI/CD pipeline if you have lambda or ECS assets, otherwise, you could run CDK synth and pass the resulting Cloudformation to AWS Code Deploy. That means a lot of your CI/CD will be spent deploying which might drain your free tier build minutes or just means you pay more (AWS Code Deploy is free)\nI do something similar with Golang in CircleCi. I use the Go base image and install nodejs and cdk. I use this base image to build all my go binaries, the vuejs frontend and compile cdk typescript and deploy it.\nFROM golang:1.13\n\nRUN go get -u -d github.com/magefile/mage\nWORKDIR $GOPATH/src/github.com/magefile/mage\nRUN go run bootstrap.go\n\nRUN curl -sL https://deb.nodesource.com/setup_12.x | bash -\nRUN apt-get install -y nodejs\nRUN npm i -g [email protected]\nRUN npm i -g typescript\nRUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -\nRUN echo \"deb https://dl.yarnpkg.com/debian/ stable main\" | tee /etc/apt/sources.list.d/yarn.list\nRUN apt update && apt install yarn\n\nI hope that helps."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git, rewrite previous commit usernames and emails\nI've committed a bunch of commits to a project on Github, however I realized I hadn't set up the proper email and committer full name on the computer I'm currently using to make my commits and therefore the users avatar and email address are not there.\nHow can I rewrite all past commit email and usernames?"
},
{
"role": "assistant",
"content": "You can add this alias:\ngit config --global alias.change-commits '!'\"f() { VAR=\\$1; OLD=\\$2; NEW=\\$3; shift 3; git filter-branch --env-filter \\\"if [[ \\\\\\\"\\$\\`echo \\$VAR\\`\\\\\\\" = '\\$OLD' ]]; then export \\$VAR='\\$NEW'; fi\\\" \\$@; }; f\"\n\nTo change the author name:\ngit change-commits GIT_AUTHOR_NAME \"old name\" \"new name\"\n\nor the email for only the last 10 commits:\ngit change-commits GIT_AUTHOR_EMAIL \"[email protected]\" \"[email protected]\" HEAD~10..HEAD\n\nAlias:\nchange-commits=\"!f() { VAR=$1; OLD=$2; NEW=$3; shift 3; git filter-branch --env-filter \\\"if [[ \\\\\\\"$`echo $VAR`\\\\\\\" = '$OLD' ]]; then export $VAR='$NEW'; fi\\\" \\$@; }; f\"\n\nSource: https://github.com/brauliobo/gitconfig/blob/master/configs/.gitconfig"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-cat-file - Provide contents or details of repository objects --path=<path>"
},
{
"role": "assistant",
"content": "For use with --textconv or --filters , to allow specifying an object\nname and a path separately, e.g. when it is difficult to figure out\nthe revision from which the blob came."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-show-index"
},
{
"role": "assistant",
"content": "Show packed archive index"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I create a new GitHub repo from a branch in an existing repo?\n\nI have master and new-project branches. And now I'd like to create a brand new repo with its master based on the new-project branch.\nBackground: I have one repository which contains three independent applications. It didn't start out this way. There was originally just one app in the repo. Over time, however, business needs have changed. One app became two (a legacy version and a re-write.) A web service was added. Separate branches were used to contain the three projects. However, they don't share any code. And so it'd be simpler to have them split out into their own repos."
},
{
"role": "assistant",
"content": "I started with @user292677's idea, and refined it to solve my problem:\n\nCreate the new-repo in github.\ncd to your local copy of the old repo you want to extract from, which is set up to track the new-project branch that will become the new-repo's master.\n$ git push https://github.com/accountname/new-repo.git +new-project:master \n\nThe new Github repo is finished. The result is;\n\na new Github repository named new-repo,\nwhose master corresponds to the old repo's new-project, with\nall history preserved.\n\nIn fact, I found that by using this method, I could create the new repo with a hand-picked selection of branches, renamed as I wanted:\n$ git push [email protected]:accountname/new_repo +new-project:master +site3a:rails3\nThe result is that the pre-existing site3a branch is now also moved to the new repo and will appear as rails3. This works really well: the network diagram shows the new master and rails3 with full history and in their correct relationship to each other.\nUpdate 2013-12-07: Used this with another project, and verified that this recipe still works.\nUpdate 2018-01-11: Updated step 3. to use GitHub recommendation for https protocol. Recipe still works."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database <object>"
},
{
"role": "assistant",
"content": "An object to treat as the head of an unreachability trace. If no objects are given, git fsck defaults to using the\nindex file, all SHA-1 references in the refs namespace, and all reflogs\n(unless --no-reflogs is given) as heads."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "go get results in 'terminal prompts disabled' error for github private repo\nI created the private repo examplesite/myprivaterepo using the Github UI from my browser.\nThen I went to my go directory (on the desktop) and cloned it:\n$ cd $GOPATH\n$ go get github.com/examplesite/myprivaterepo\n\nSo far so good. Created the file scheduler.go, added to repo, and pushed.\n$ vim scheduler.go\n$ git add scheduler.go\n$ git commit\n$ git push\n\nEverythng's OK. But when I went to a clean laptop and tried to clone the repo, I got an error:\n# Now on laptop, which doesn't yet know about the repo\n$ cd $GOPATH\n$ go get github.com/examplesite/myprivaterepo\n# At this point it should ask for my user ID and password ,right? But it doesn't.\n# Instead, this error occurs:\ncd .; git clone https://github.com/examplesite/myprivaterepo /Users/tom/go/src/github.com/examplesite/myprivaterepo\nCloning into '/Users/tom/go/src/github.com/examplesite/myprivaterepo'...\nfatal: could not read Username for 'https://github.com': terminal prompts disabled\npackage github.com/examplesite/myprivaterepo: exit status 128\n\nWhy is my laptop hating on my own repo and how can I get it to accept its fate? Thanks."
},
{
"role": "assistant",
"content": "I found this extremely helpful, and it solved my problem. This command will allow your 2FA to do its thing (and save you the trouble of entering your username and password):\nFor Github:\ngit config --global --add url.\"[email protected]:\".insteadOf \"https://github.com/\"\n\nFor Gitlab:\ngit config --global --add url.\"[email protected]:\".insteadOf \"https://gitlab.com/\"\n\nSource: http://albertech.blogspot.com/2016/11/fix-git-error-could-not-read-username.html\nIf you're not using 2FA, you can still use SSH and this will work.\nResulting .gitconfig will be like:\n[url \"[email protected]:\"]\n insteadOf = https://github.com/"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-tag - Create, list, delete or verify a tag object signed with GPG --no-contains [<commit>]"
},
{
"role": "assistant",
"content": "Only list tags which don’t contain the specified commit (HEAD if\nnot specified). Implies --list ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc git diff [<options>] --no-index [--] <path> <path>"
},
{
"role": "assistant",
"content": "This form is to compare the given two paths on the\nfilesystem. You can omit the --no-index option when\nrunning the command in a working tree controlled by Git and\nat least one of the paths points outside the working tree,\nor when running the command outside a working tree\ncontrolled by Git. This form implies --exit-code ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitformat-index"
},
{
"role": "assistant",
"content": "Git index format"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "understanding git fetch then merge\nComing from an svn background, I had this question:\ngit equivalent of svn status -u\n(what is the git equivalent of svn status -u)\nAnd I understand, you do:\ngit fetch\ngit log ..origin/master\n\nBut, I'm guessing the origin/master part depends on the branch? It wouldn't necessarily be master if I was tracking a remote branch?\nI also don't understand the git merge origin/master precisely. I'm guessing that just means that git fetch grabbed the changes from the remote and put them into the git database system as origin/master and I'm in just master? What if I fetched changes, check what was done, am horrified by the changes and don't want to merge? How do I basically abandon them?"
},
{
"role": "assistant",
"content": "git fetch\ngit fetch grabs changes from remote repository and puts it in your repository's object database. It also fetches branches from remote repository and stores them as remote-tracking branches. \nWhen you are fetching git tells you where it stores each branch on remote repository it fetches. For example you should see something like\n 7987baa..2086e7b master -> origin/master\n\nwhen fetching. This means that 'origin/master' stores where 'master' is on 'origin' repository.\nIf you examine .git/config file, you would see the following fragment:\n\n[remote \"origin\"]\n url = git://git.example.com/repo.git\n fetch = +refs/heads/*:refs/remotes/origin/*\n\nThis (among others) means that any branch 'A' ('refs/heads/A') in origin remote (repository you cloned from) would be saved as 'origin/A' ('refs/remotes/origin/A').\ngit log ..origin/master\nAs you can see 'origin/master' is 'master' in origin. If you are on (default) 'master' branch, then git log ..origin/master, which is equivalent to git log HEAD..origin/master, which when on 'master' branch is equivalent to git log master..origin/master would list all commits that are on 'master' branch in remote repository and are not in local 'master' branch where you do your work.\nThe more generic version in modern git (assuming that upstream / tracking information exists) would be to use simply\n$ git log ..@{u}\n\n(Here @{u} is synonym for @{upstream}, see gitrevisions manpage).\ngit merge origin/master\ngit merge is used to join two lines of history. If one of sides didn't do any work since last branching point (since merge base), the situation is either fast-forward (the branch you are on is simply updated to the tip of the branch you are merging), or up-to-date (there is nothing new to merge, and the branch you are on stays unchanged).\ngit fetch followed by git merge origin/master, when on 'master' branch, is equivalent to issuing\n$ git pull\n\n\nIf you don't want to merge, you don't need to. Note that you can use e.g. git reset --hard HEAD@{1} to go back and discard result of git pull if you don't like it."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Get commit message in Git hook\nI would like to check the commit message before Git commit.\nI use a pre-commit hook to do that, but I couldn't find the way to get the commit message in the .git/pre-commit script.\nHow could I get it?"
},
{
"role": "assistant",
"content": "In the pre-commit hook, the commit message usually hasn't been created yet 1. You probably want to use one of the prepare-commit-msg or commit-msg hooks instead. There's a nice section in Pro Git on the order in which these hooks are run, and what you typically might do with them.\n\n1. The exception is that the committer might have supplied a commit message with -m, but the message still isn't accessible to the pre-commit hook, whereas it is to prepare-commit-msg or commit-msg"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to remove commits from a pull request\n\nI did a pull request but after that I made some commits to the project locally which ended polluting my pull request, I tried to remove it but without any luck.\nI found some similar questions on StackOverflow but I can't apply what's in there.\nIt's my first pull request on GitHub so it's kinda strange to me how all of this works.\nThe highlighted commit is the one I need to keep and remove all the other stuff.\nIt becomes the fourth commit in the history because I make some merge stuff.\n\nmy git log\n\nCan someone please explain what's going on and how to fix this problem?"
},
{
"role": "assistant",
"content": "People wouldn't like to see a wrong commit and a revert commit to undo changes of the wrong commit. This pollutes commit history.\nHere is a simple way for removing the wrong commit instead of undoing changes with a revert commit.\n\ngit checkout my-pull-request-branch\n\ngit rebase -i HEAD~n // where n is the number of last commits you want to include in interactive\nrebase.\n\nReplace pick with drop for commits you want to discard.\n\nSave and exit.\n\ngit push --force-with-lease (safer force push, pointed out by @George)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I undo discard changes in GitHub Desktop?\n\nIs there any way to undo discard changes in GitHub Desktop, after the Undo button has disappeared?\n\nI am talking about GitHub Desktop's undo feature, not git in general."
},
{
"role": "assistant",
"content": "As of 5/8/18, and if you're using the latest version of github desktop or github desktop beta, uncommitted discarded changes are now copied over as new files and put into your trash/recycling bin. \nThis is what the current prompt looks like:"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to undo a git pull?\nI would like to undo my git pull on account of unwanted commits on the remote origin, but I don't know to which revision I have to reset back to.\nHow can I just go back to the state before I did the git pull on the remote origin?"
},
{
"role": "assistant",
"content": "Or to make it more explicit than the other answer:\ngit pull \n\nwhoops?\ngit reset --keep HEAD@{1}\n\nVersions of git older than 1.7.1 do not have --keep. If you use such version, you could use --hard - but that is a dangerous operation because it loses any local changes.\n\nTo the commenter\n\nORIG_HEAD is previous state of HEAD, set by commands that have possibly dangerous behavior, to be easy to revert them. It is less useful now that Git has reflog: HEAD@{1} is roughly equivalent to ORIG_HEAD (HEAD@{1} is always last value of HEAD, ORIG_HEAD is last value of HEAD before dangerous operation)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "github: server certificate verification failed\n\nI just created a github account and a repository therein, but when trying to create a local working copy using the recommende url via\ngit clone https://github.com/<user>/<project>.git\n\nI get an error like\n\nfatal: unable to access 'https://github.com/<user>/<project>.git': server certificate verification failed. CAfile: /home/<user>/.ssl/trusted.pem CRLfile: none\n\nI'm on Debian Jessie, and I would have expected both Debian and GitHub to provide / rely on a selection of commonly accepted CAs, but apparently my system doesn't trust GibHub's certificate.\nAny simple way to fix this (without the frequently recommended \"GIT_SSL_NO_VERIFY=true\" hack and similar work-arounds)?\nEDIT:\nAdditional information:\n\nThe ca-certificate package is installed.\n\nInstalling cacert.org's certificates as\nsuggested by @VonC didn't change anything.\n\nMy personal ~/.ssl/trusted.pem file does contain a couple of entries, but to be\nhonest, I don't remember where the added certificates came from...\n\nWhen removing ~/.ssl/trusted.pem, the git error message changes to\n fatal: unable to access 'https://github.com/tcrass/scans2jpg.git/': Problem with the SSL CA cert (path? access rights?)"
},
{
"role": "assistant",
"content": "2016: Make sure first that you have certificates installed on your Debian in /etc/ssl/certs.\nIf not, reinstall them:\nsudo apt-get install --reinstall ca-certificates\n\nSince that package does not include root certificates, add:\nsudo mkdir /usr/local/share/ca-certificates/cacert.org\nsudo wget -P /usr/local/share/ca-certificates/cacert.org http://www.cacert.org/certs/root.crt http://www.cacert.org/certs/class3.crt\nsudo update-ca-certificates\n\nMake sure your git does reference those CA:\ngit config --global http.sslCAinfo /etc/ssl/certs/ca-certificates.crt\n\n\nJason C mentions another potential cause (in the comments):\n\nIt was the clock. The NTP server was down, the system clock wasn't set properly, I didn't notice or think to check initially, and the incorrect time was causing verification to fail.\n\nCertificates are time-sensitive.\ndopamane confirms in the comments:\n\nThis was the issue for me on WSL.\nRan sudo hwclock -s, and I could successfully clone the submodule.\n\n\n2022: Auspex adds in the comments:\n\nca-certificates does indeed contain root certificates.\nIt doesn't contain the CAcert root certificates.\nThis might have been a good answer 6 1/2 years ago, but those certificates were suspect way back then and haven't improved.\nThere's a reason they're not in the ca-certificates package.\nThese days we have LetsEncrypt, so everyone has certificates with reliable auditing and nobody needs to rely on CAcert."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-branch - List, create, or delete branches --create-reflog"
},
{
"role": "assistant",
"content": "Create the branch’s reflog. This activates recording of\nall changes made to the branch ref, enabling use of date\nbased sha1 expressions such as \"<branchname>@{yesterday}\".\nNote that in non-bare repositories, reflogs are usually\nenabled by default by the core.logAllRefUpdates config option.\nThe negated form --no-create-reflog only overrides an earlier --create-reflog , but currently does not negate the setting of core.logAllRefUpdates ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index --no-ext-diff"
},
{
"role": "assistant",
"content": "Disallow external diff drivers."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options receive.denyDeleteCurrent"
},
{
"role": "assistant",
"content": "If set to true, git-receive-pack will deny a ref update that\ndeletes the currently checked out branch of a non-bare repository."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-parse - Pick out and massage parameters --git-path <path>"
},
{
"role": "assistant",
"content": "Resolve \"$GIT_DIR/<path>\" and takes other path relocation\nvariables such as $GIT_OBJECT_DIRECTORY,\n$GIT_INDEX_FILE… into account. For example, if\n$GIT_OBJECT_DIRECTORY is set to /foo/bar then \"git rev-parse\n--git-path objects/abc\" returns /foo/bar/abc."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout - Switch branches or restore working tree files"
},
{
"role": "assistant",
"content": "EXAMPLES 1. Paths The following sequence checks out the master branch, reverts\nthe Makefile to two revisions back, deletes hello.c by\nmistake, and gets it back from the index. $ git checkout master (1) $ git checkout master~2 Makefile (2) $ rm -f hello.c\n$ git checkout hello.c (3) switch branch take a file out of another commit restore hello.c from the index If you want to check out all C source files out of the index,\nyou can say $ git checkout -- '*.c' Note the quotes around *.c . The file hello.c will also be\nchecked out, even though it is no longer in the working tree,\nbecause the file globbing is used to match entries in the index\n(not in the working tree by the shell). If you have an unfortunate branch that is named hello.c , this\nstep would be confused as an instruction to switch to that branch.\nYou should instead write: $ git checkout -- hello.c 2. Merge After working in the wrong branch, switching to the correct\nbranch would be done using: $ git checkout mytopic However, your \"wrong\" branch and correct mytopic branch may\ndiffer in files that you have modified locally, in which case\nthe above checkout would fail like this: $ git checkout mytopic\nerror: You have local changes to 'frotz'; not switching branches. You can give the -m flag to the command, which would try a\nthree-way merge: $ git checkout -m mytopic\nAuto-merging frotz After this three-way merge, the local modifications are not registered in your index file, so git diff would show you what\nchanges you made since the tip of the new branch. 3. Merge conflict When a merge conflict happens during switching branches with\nthe -m option, you would see something like this: $ git checkout -m mytopic\nAuto-merging frotz\nERROR: Merge conflict in frotz\nfatal: merge program failed At this point, git diff shows the changes cleanly merged as in\nthe previous example, as well as the changes in the conflicted\nfiles. Edit and resolve the conflict and mark it resolved with git add as usual: $ edit frotz\n$ git add frotz"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options imap.folder"
},
{
"role": "assistant",
"content": "The folder to drop the mails into, which is typically the Drafts\nfolder. For example: \"INBOX.Drafts\", \"INBOX/Drafts\" or\n\"[Gmail]/Drafts\". Required."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-commit - Record changes to the repository -c <commit> --reedit-message=<commit>"
},
{
"role": "assistant",
"content": "Like -C , but with -c the editor is invoked, so that\nthe user can further edit the commit message."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What does Linus Torvalds mean when he says that Git \"never ever\" tracks a file?\nQuoting Linus Torvalds when asked how many files Git can handle during his Tech Talk at Google in 2007 (43:09):\n\n…Git tracks your content. It never ever tracks a single file. You cannot track a file in Git. What you can do is you can track a project that has a single file, but if your project has a single file, sure do that and you can do it, but if you track 10,000 files, Git never ever sees those as individual files. Git thinks everything as the full content. All history in Git is based on the history of the whole project…\n\n(Transcripts here.)\nYet, when you dive into the Git book, the first thing you are told is that a file in Git can be either tracked or untracked. Furthermore, it seems to me like the whole Git experience is geared towards file versioning. When using git diff or git status output is presented on a per file basis. When using git add you also get to choose on a per file basis. You can even review history on a file basis and is lightning fast.\nHow should this statement be interpreted? In terms of file tracking, how is Git different from other source control systems, such as CVS?"
},
{
"role": "assistant",
"content": "In CVS, history was tracked on a per-file basis. A branch might consist of various files with their own various revisions, each with its own version number. CVS was based on RCS (Revision Control System), which tracked individual files in a similar way.\nOn the other hand, Git takes snapshots of the state of the whole project. Files are not tracked and versioned independently; a revision in the repository refers to a state of the whole project, not one file.\nWhen Git refers to tracking a file, it means simply that it is to be included in the history of the project. Linus's talk was not referring to tracking files in the Git context, but was contrasting the CVS and RCS model with the snapshot-based model used in Git."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc -U<n> --unified=<n>"
},
{
"role": "assistant",
"content": "Generate diffs with <n> lines of context instead of\nthe usual three.\nImplies --patch ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-pull - Fetch from and integrate with another repository or a local branch -a --append"
},
{
"role": "assistant",
"content": "Append ref names and object names of fetched refs to the\nexisting contents of .git/FETCH_HEAD . Without this\noption old data in .git/FETCH_HEAD will be overwritten."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fetch - Download objects and refs from another repository fetch.unpackLimit"
},
{
"role": "assistant",
"content": "If the number of objects fetched over the Git native\ntransfer is below this\nlimit, then the objects will be unpacked into loose object\nfiles. However if the number of received objects equals or\nexceeds this limit then the received pack will be stored as\na pack, after adding any missing delta bases. Storing the\npack from a push can make the push operation complete faster,\nespecially on slow filesystems. If not set, the value of transfer.unpackLimit is used instead."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index patience"
},
{
"role": "assistant",
"content": "Use \"patience diff\" algorithm when generating patches."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge - Join two or more development histories together merge.<driver>.recursive"
},
{
"role": "assistant",
"content": "Names a low-level merge driver to be used when\nperforming an internal merge between common ancestors.\nSee gitattributes for details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can you and is it advisable to use the same ssh key for github and gitlab/gitbucket\n\nCan you use the same ssh key for different version control hosting services? \nAnd if you can, what are the pros and cons?\nScenario: I have ssh keys that I am using on my computer, can I and should I use the same ssh keys with gitlab/gitbucket on the same computer?"
},
{
"role": "assistant",
"content": "No, it is not advisable: a private key should remain used for only one service, that way you can revoke/change it just for that service.\nWhat you can do is set up a ~/.ssh/config file in which you can associate the right private key with the right host, as explained here."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to see contributor's email address on Git commit chain?\nI can't see how to email a contributor on github after lengthy attempts, and google searches. Why does every beginners guide encourage us to immediately configure our user.email such that it is sent with every commit if its so difficult to view the contributors' email addresses on the commit chain in GitHub?"
},
{
"role": "assistant",
"content": "Add .patch to the end of the commit url to open patch view.\nhttps://github.com/torvalds/test-tlb/commit/4210d1cfc58f2d8a3da0730389ee63d68c6fe914.patch\n\nhttps://www.thereach.io/blog/articles/how-to-find-github-user-email-addresses"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to read the mode field of git-ls-tree's output\n$ git ls-tree fb3a8bdd0ce\n100644 blob 63c918c667fa005ff12ad89437f2fdc80926e21c .gitignore\n100644 blob 5529b198e8d14decbe4ad99db3f7fb632de0439d .mailmap\n100644 blob 6ff87c4664981e4397625791c8ea3bbb5f2279a3 COPYING\n040000 tree 2fb783e477100ce076f6bf57e4a6f026013dc745 Documentation\n100755 blob 3c0032cec592a765692234f1cba47dfdcc3a9200 GIT-VERSION-GEN\n100644 blob 289b046a443c0647624607d471289b2c7dcd470b INSTALL\n100644 blob 4eb463797adc693dc168b926b6932ff53f17d0b1 Makefile\n100644 blob 548142c327a6790ff8821d67c2ee1eff7a656b52 README\n...\n\nI know the last 3 oct digits are file mode, but what are the first 3 digits for?\nI can't find it out in git user's manual."
},
{
"role": "assistant",
"content": "From gitformat-index(5) / the Reference Documentations The Git index file format (¹, ²), regarding the mode:\n32-bit mode, split into (high to low bits)\n\n 4-bit object type\n valid values in binary are 1000 (regular file), 1010 (symbolic link)\n and 1110 (gitlink)\n\n 3-bit unused\n\n 9-bit unix permission. Only 0755 and 0644 are valid for regular files.\n Symbolic links and gitlinks have value 0 in this field.\n\nAlso, a directory object type (binary 0100) and group-writeable (0664 permissions) regular file are allowed as indicated by the fsck.c fsck_tree method. The regular non-executable group-writeable file is a non-standard mode that was supported in earlier versions of Git.\nThis makes valid modes (as binary and octal):\n\n0100000000000000 (040000): Directory\n1000000110100100 (100644): Regular non-executable file\n1000000110110100 (100664): Regular non-executable group-writeable file\n1000000111101101 (100755): Regular executable file\n1010000000000000 (120000): Symbolic link\n1110000000000000 (160000): Gitlink\n\n\n\n(Source) docs: move index format docs to man section 5 — 00d3e8d\n(Archived copy on Microsoft Github) docs: move index format docs to man section 5 — 00d3e8d"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "The following untracked working tree files would be overwritten by merge, but I don't care\nOn my branch I had some files in .gitignore\nOn a different branch those files are not.\nI want to merge the different branch into mine, and I don't care if those files are no longer ignored or not.\nUnfortunately I get this: \n\nThe following untracked working tree files would be overwritten by merge\n\nHow would I modify my pull command to overwrite those files, without me having to find, move or delete those files myself?"
},
{
"role": "assistant",
"content": "The problem is that you are not tracking the files locally but identical files are tracked remotely so in order to \"pull\" your system would be forced to overwrite the local files which are not version controlled.\nTry running\ngit add *\ngit stash\ngit pull\n\nThis will track all files, remove all of your local changes to those files, and then get the files from the server."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects --abbrev[=<n>]"
},
{
"role": "assistant",
"content": "Instead of showing the full 40-byte hexadecimal object\nname in diff-raw format output and diff-tree header\nlines, show the shortest prefix that is at least <n> hexdigits long that uniquely refers the object.\nIn diff-patch output format, --full-index takes higher\nprecedence, i.e. if --full-index is specified, full blob\nnames will be shown regardless of --abbrev .\nNon default number of digits can be specified with --abbrev=<n> ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Replay the last N git commits on a different branch\nI accidentally made 10 commits on branch \"testing\" when I intended to commit them on branch \"master\". The other commits on the \"testing\" branch are garbage, so I don't want to merge it with \"master\". Instead, I just want to replay the last 10 commits on master."
},
{
"role": "assistant",
"content": "Rebase should do it.\ngit rebase -p --onto master testing~10 testing\n\nThis will copy the last ten commits on testing to master and make that the new testing (the old testing will be an orphan). Then you can merge master to testing as a fast-forward.\ngit checkout master\ngit merge testing"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git hunk edit mode - how to remove a '-' line?\n+ bbb\n- aaa\n\n# ---\n# To remove '-' lines, make them ' ' lines (context).\n# To remove '+' lines, delete them.\n# Lines starting with # will be removed.\n#\n# If the patch applies cleanly, the edited hunk will immediately be\n# marked for staging. If it does not apply cleanly, you will be given\n# an opportunity to edit again. If all lines of the hunk are removed,\n# then the edit is aborted and the hunk is left unchanged.\n\nI simply don't understand what make them ' ' lines means. How to apply + bbb only but not - aaa?"
},
{
"role": "assistant",
"content": "make them ' ' lines means you need to replace the - in front of the line with a (space)."
}
] |
[
{
"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": "Getting 'fatal: empty ident name not allowed' when doing 'Git commit --amend'\nI am doing a git commit --amend and I get this error:\n\nfatal: empty ident name (for <>) not allowed\n\nI've found a bunch of stuff saying I need to set my user.email and user.name, but I have. This is the the result when I do a git config --global --list:\n\ncore.exludesfile=/home/dzou/.gitignore\ncore.editor=vim\n[email protected]\nuser.name=dzou\n\nWhat is going on here?"
},
{
"role": "assistant",
"content": "Set global user.name and user.email first by order like below. \n$ git config --global user.name \"dzou\"\n$ git config --global user.email \"[email protected]\"\n\nNB: careful, use double quote instead of single quotes"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to disable ^M line endings in VS Code? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow can I make all line endings (EOLs) in all files in Visual Studio Code, Unix-like?\n\n (13 answers)\n \n\n\nCan I set the VS Code default EOL based on file type?\n\n (3 answers)\n \n\nClosed last month.\n\n\n\nVS Code has decided to start adding ^M characters to the end of any\nline I edit.\nThey're not visible in the editor but git diff picks them up.\n\nIt wasn't doing this before, so I'm guessing I accidentally bumped some\nkeyboard shortcut.\nDoes anyone know how to turn this off and have it just use regular line\nendings?"
},
{
"role": "assistant",
"content": "That's caused by the different standards used in line endings (LineFeed or LF in Linux and CarriageReturn + LineFeed or CRLF in Windows).\nYou can set the encoding you want by either of the following ways:\n\nClick the LF or CRLF button on the status bar (near the bottom right corner), then select LF or CRLF.\n\n\nGo to the command palette (SHIFT+CTRL+p) and type \"end of line\" (that's the mnemonic I use) until you find the command Change End of Line Sequence."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git and Mercurial - Compare and Contrast\nFor a while now I've been using subversion for my personal projects.\nMore and more I keep hearing great things about Git and Mercurial, and DVCS in general.\nI'd like to give the whole DVCS thing a whirl, but I'm not too familiar with either option.\nWhat are some of the differences between Mercurial and Git?\nNote: I'm not trying to find out which one is \"best\" or even which one I should start with. I'm mainly looking for key areas where they are similar, and where they are different, because I am interested to know how they differ in terms of implementation and philosophy."
},
{
"role": "assistant",
"content": "Disclaimer: I use Git, follow Git development on git mailing list, and even contribute a bit to Git (gitweb mainly). I know Mercurial from documentation and some from discussion on #revctrl IRC channel on FreeNode.\nThanks to all people on on #mercurial IRC channel who provided help about Mercurial for this writeup\n\n\nSummary\nHere it would be nice to have some syntax for table, something like in PHPMarkdown / MultiMarkdown / Maruku extension of Markdown\n\nRepository structure: Mercurial doesn't allow octopus merges (with more than two parents), nor tagging non-commit objects.\nTags: Mercurial uses versioned .hgtags file with special rules for per-repository tags, and has also support for local tags in .hg/localtags; in Git tags are refs residing in refs/tags/ namespace, and by default are autofollowed on fetching and require explicit pushing.\nBranches: In Mercurial basic workflow is based on anonymous heads; Git uses lightweight named branches, and has special kind of branches (remote-tracking branches) that follow branches in remote repository.\nRevision naming and ranges: Mercurial provides revision numbers, local to repository, and bases relative revisions (counting from tip, i.e. current branch) and revision ranges on this local numbering; Git provides a way to refer to revision relative to branch tip, and revision ranges are topological (based on graph of revisions)\nMercurial uses rename tracking, while Git uses rename detection to deal with file renames\nNetwork: Mercurial supports SSH and HTTP \"smart\" protocols, and static HTTP protocol; modern Git supports SSH, HTTP and GIT \"smart\" protocols, and HTTP(S) \"dumb\" protocol. Both have support for bundles files for off-line transport.\nMercurial uses extensions (plugins) and established API; Git has scriptability and established formats.\n\n\nThere are a few things that differ Mercurial from Git, but there are other things that make them similar. Both projects borrow ideas from each other. For example hg bisect command in Mercurial (formerly bisect extension) was inspired by git bisect command in Git, while idea of git bundle was inspired by hg bundle.\nRepository structure, storing revisions\nIn Git there are four types of objects in its object database: blob objects which contain contents of a file, hierarchical tree objects which store directory structure, including file names and relevant parts of file permissions (executable permission for files, being a symbolic link), commit object which contain authorship info, pointer to snapshot of state of repository at revision represented by a commit (via a tree object of top directory of project) and references to zero or more parent commits, and tag objects which reference other objects and can be signed using PGP / GPG.\nGit uses two ways of storing objects: loose format, where each object is stored in a separate file (those files are written once, and never modified), and packed format where many objects are stored delta-compressed in a single file. Atomicity of operations is provided by the fact, that reference to a new object is written (atomically, using create + rename trick) after writing an object.\nGit repositories require periodic maintenance using git gc (to reduce disk space and improve performance), although nowadays Git does that automatically. (This method provides better compression of repositories.)\nMercurial (as far as I understand it) stores history of a file in a filelog (together, I think, with extra metadata like rename tracking, and some helper information); it uses flat structure called manifest to store directory structure, and structure called changelog which store information about changesets (revisions), including commit message and zero, one or two parents.\nMercurial uses transaction journal to provide atomicity of operations, and relies on truncating files to clean-up after failed or interrupted operation. Revlogs are append-only.\nLooking at repository structure in Git versus in Mercurial, one can see that Git is more like object database (or a content-addressed filesystem), and Mercurial more like traditional fixed-field relational database.\nDifferences:\nIn Git the tree objects form a hierarchical structure; in Mercurial manifest file is flat structure. In Git blob object store one version of a contents of a file; in Mercurial filelog stores whole history of a single file (if we do not take into account here any complications with renames). This means that there are different areas of operations where Git would be faster than Mercurial, all other things considered equal (like merges, or showing history of a project), and areas where Mercurial would be faster than Git (like applying patches, or showing history of a single file). This issue might be not important for end user. \nBecause of the fixed-record structure of Mercurial's changelog structure, commits in Mercurial can have only up to two parents; commits in Git can have more than two parents (so called \"octopus merge\"). While you can (in theory) replace octopus merge by a series of two-parent merges, this might cause complications when converting between Mercurial and Git repositories.\nAs far as I know Mercurial doesn't have equivalent of annotated tags (tag objects) from Git. A special case of annotated tags are signed tags (with PGP / GPG signature); equivalent in Mercurial can be done using GpgExtension, which extension is being distributed along with Mercurial. You can't tag non-commit object in Mercurial like you can in Git, but that is not very important, I think (some git repositories use tagged blob to distribute public PGP key to use to verify signed tags).\nReferences: branches and tags\nIn Git references (branches, remote-tracking branches and tags) reside outside DAG of commits (as they should). References in refs/heads/ namespace (local branches) point to commits, and are usually updated by \"git commit\"; they point to the tip (head) of branch, that's why such name. References in refs/remotes/<remotename>/ namespace (remote-tracking branches) point to commit, follow branches in remote repository <remotename>, and are updated by \"git fetch\" or equivalent. References in refs/tags/ namespace (tags) point usually to commits (lightweight tags) or tag objects (annotated and signed tags), and are not meant to change.\nTags\nIn Mercurial you can give persistent name to revision using tag; tags are stored similarly to the ignore patterns. It means that globally visible tags are stored in revision-controlled .hgtags file in your repository. That has two consequences: first, Mercurial has to use special rules for this file to get current list of all tags and to update such file (e.g. it reads the most recently committed revision of the file, not currently checked out version); second, you have to commit changes to this file to have new tag visible to other users / other repositories (as far as I understand it).\nMercurial also supports local tags, stored in hg/localtags, which are not visible to others (and of course are not transferable)\nIn Git tags are fixed (constant) named references to other objects (usually tag objects, which in turn point to commits) stored in refs/tags/ namespace. By default when fetching or pushing a set of revision, git automatically fetches or pushes tags which point to revisions being fetched or pushed. Nevertheless you can control to some extent which tags are fetched or pushed.\nGit treats lightweight tags (pointing directly to commits) and annotated tags (pointing to tag objects, which contain tag message which optionally includes PGP signature, which in turn point to commit) slightly differently, for example by default it considers only annotated tags when describing commits using \"git describe\".\nGit doesn't have a strict equivalent of local tags in Mercurial. Nevertheless git best practices recommend to setup separate public bare repository, into which you push ready changes, and from which others clone and fetch. This means that tags (and branches) that you don't push, are private to your repository. On the other hand you can also use namespace other than heads, remotes or tags, for example local-tags for local tags.\nPersonal opinion: In my opinion tags should reside outside revision graph, as they are external to it (they are pointers into graph of revisions). Tags should be non-versioned, but transferable. Mercurial's choice of using a mechanism similar to the one for ignoring files, means that it either has to treat .hgtags specially (file in-tree is transferable, but ordinary it is versioned), or have tags which are local only (.hg/localtags is non-versioned, but untransferable).\nBranches\nIn Git local branch (branch tip, or branch head) is a named reference to a commit, where one can grow new commits. Branch can also mean active line of development, i.e. all commits reachable from branch tip. Local branches reside in refs/heads/ namespace, so e.g. fully qualified name of 'master' branch is 'refs/heads/master'.\nCurrent branch in Git (meaning checked out branch, and branch where new commit will go) is the branch which is referenced by the HEAD ref. One can have HEAD pointing directly to a commit, rather than being symbolic reference; this situation of being on an anonymous unnamed branch is called detached HEAD (\"git branch\" shows that you are on '(no branch)').\nIn Mercurial there are anonymous branches (branch heads), and one can use bookmarks (via bookmark extension). Such bookmark branches are purely local, and those names were (up to version 1.6) not transferable using Mercurial. You can use rsync or scp to copy the .hg/bookmarks file to a remote repository. You can also use hg id -r <bookmark> <url> to get the revision id of a current tip of a bookmark.\nSince 1.6 bookmarks can be pushed/pulled. The BookmarksExtension page has a section on Working With Remote Repositories. There is a difference in that in Mercurial bookmark names are global, while definition of 'remote' in Git describes also mapping of branch names from the names in remote repository to the names of local remote-tracking branches; for example refs/heads/*:refs/remotes/origin/* mapping means that one can find state of 'master' branch ('refs/heads/master') in the remote repository in the 'origin/master' remote-tracking branch ('refs/remotes/origin/master').\nMercurial has also so called named branches, where the branch name is embedded in a commit (in a changeset). Such name is global (transferred on fetch). Those branch names are permanently recorded as part of the changeset\\u2019s metadata. With modern Mercurial you can close \"named branch\" and stop recording branch name. In this mechanism tips of branches are calculated on the fly.\nMercurial's \"named branches\" should in my opinion be called commit labels instead, because it is what they are. There are situations where \"named branch\" can have multiple tips (multiple childless commits), and can also consist of several disjoint parts of graph of revisions.\nThere is no equivalent of those Mercurial \"embedded branches\" in Git; moreover Git's philosophy is that while one can say that branch includes some commit, it doesn't mean that a commit belongs to some branch.\nNote that Mercurial documentation still proposes to use separate clones (separate repositories) at least for long-lived branches (single branch per repository workflow), aka branching by cloning.\nBranches in pushing\nMercurial by default pushes all heads. If you want to push a single branch (single head), you have to specify tip revision of the branch you want to push. You can specify branch tip by its revision number (local to repository), by revision identifier, by bookmark name (local to repository, doesn't get transferred), or by embedded branch name (named branch).\nAs far as I understand it, if you push a range of revisions that contain commits marked as being on some \"named branch\" in Mercurial parlance, you will have this \"named branch\" in the repository you push to. This means that names of such embedded branches (\"named branches\") are global (with respect to clones of given repository / project).\nBy default (subject to push.default configuration variable) \"git push\" or \"git push <remote>\" Git would push matching branches, i.e. only those local branches that have their equivalent already present in remote repository you push into. You can use --all option to git-push (\"git push --all\") to push all branches, you can use \"git push <remote> <branch>\" to push a given single branch, and you can use \"git push <remote> HEAD\" to push current branch.\nAll of the above assumes that Git isn't configured which branches to push via remote.<remotename>.push configuration variables.\nBranches in fetching\nNote: here I use Git terminology where \"fetch\" means downloading changes from remote repository without integrating those changes with local work. This is what \"git fetch\" and \"hg pull\" does.\nIf I understand it correctly, by default Mercurial fetches all heads from remote repository, but you can specify branch to fetch via \"hg pull --rev <rev> <url>\" or \"hg pull <url>#<rev>\" to get single branch. You can specify <rev> using revision identifier, \"named branch\" name (branch embedded in changelog), or bookmark name. Bookmark name however (at least currently) doesn't get transferred. All \"named branches\" revisions you get belong to get transferred. \"hg pull\" stores tips of branches it fetched as anonymous, unnamed heads.\nIn Git by default (for 'origin' remote created by \"git clone\", and for remotes created using \"git remote add\") \"git fetch\" (or \"git fetch <remote>\") gets all branches from remote repository (from refs/heads/ namespace), and stores them in refs/remotes/ namespace. This means for example that branch named 'master' (full name: 'refs/heads/master') in remote 'origin' would get stored (saved) as 'origin/master' remote-tracking branch (full name: 'refs/remotes/origin/master').\nYou can fetch single branch in Git by using git fetch <remote> <branch> - Git would store requested branch(es) in FETCH_HEAD, which is something similar to Mercurial unnamed heads.\nThose are but examples of default cases of powerful refspec Git syntax: with refspecs you can specify and/or configure which branches one want to fetch, and where to store them. For example default \"fetch all branches\" case is represented by '+refs/heads/*:refs/remotes/origin/*' wildcard refspec, and \"fetch single branch\" is shorthand for 'refs/heads/<branch>:'. Refspecs are used to map names of branches (refs) in remote repository to local refs names. But you don't need to know (much) about refspecs to be able to work effectively with Git (thanks mainly to \"git remote\" command).\nPersonal opinion: I personally think that \"named branches\" (with branch names embedded in changeset metadata) in Mercurial are misguided design with its global namespace, especially for a distributed version control system. For example let's take case where both Alice and Bob have \"named branch\" named 'for-joe' in their repositories, branches which have nothing in common. In Joe's repository however those two branches would be mistreated as a single branch. So you have somehow come up with convention protecting against branch name clashes. This is not problem with Git, where in Joe's repository 'for-joe' branch from Alice would be 'alice/for-joe', and from Bob it would be 'bob/for-joe'. See also Separating branch name from branch identity issue raised on Mercurial wiki.\nMercurial's \"bookmark branches\" currently lack in-core distribution mechanism.\nDifferences:\nThis area is one of the main differences between Mercurial and Git, as james woodyatt and Steve Losh said in their answers. Mercurial, by default, uses anonymous lightweight codelines, which in its terminology are called \"heads\". Git uses lightweight named branches, with injective mapping to map names of branches in remote repository to names of remote-tracking branches. Git \"forces\" you to name branches (well, with exception of single unnamed branch, situation called detached HEAD), but I think this works better with branch-heavy workflows such as topic branch workflow, meaning multiple branches in single repository paradigm.\nNaming revisions\nIn Git there are many ways of naming revisions (described e.g. in git rev-parse manpage):\n\nThe full SHA1 object name (40-byte hexadecimal string), or a substring of such that is unique within the repository\nA symbolic ref name, e.g. 'master' (referring to 'master' branch), or 'v1.5.0' (referring to tag), or 'origin/next' (referring to remote-tracking branch)\nA suffix ^ to revision parameter means the first parent of a commit object, ^n means n-th parent of a merge commit. A suffix ~n to revision parameter means n-th ancestor of a commit in straight first-parent line. Those suffixes can be combined, to form revision specifier following path from a symbolic reference, e.g. 'pu~3^2~3'\nOutput of \"git describe\", i.e. a closest tag, optionally followed by a dash and a number of commits, followed by a dash, a 'g', and an abbreviated object name, for example 'v1.6.5.1-75-g5bf8097'.\n\nThere are also revision specifiers involving reflog, not mentioned here. In Git each object, be it commit, tag, tree or blob has its SHA-1 identifier; there is special syntax like e.g. 'next:Documentation' or 'next:README' to refer to tree (directory) or blob (file contents) at specified revision.\nMercurial also has many ways of naming changesets (described e.g. in hg manpage):\n\nA plain integer is treated as a revision number. One need to remember that revision numbers are local to given repository; in other repository they can be different.\nNegative integers are treated as sequential offsets from the tip, with -1 denoting the tip, -2 denoting the revision prior to the tip, and so forth. They are also local to repository.\nAn unique revision identifier (40-digit hexadecimal string) or its unique prefix.\nA tag name (symbolic name associated with given revision), or a bookmark name (with extension: symbolic name associated with given head, local to repository), or a \"named branch\" (commit label; revision given by \"named branch\" is tip (childless commit) of all commits with given commit label, with largest revision number if there are more than one such tip)\nThe reserved name \"tip\" is a special tag that always identifies the most recent revision.\nThe reserved name \"null\" indicates the null revision.\nThe reserved name \".\" indicates the working directory parent.\n\nDifferences\nAs you can see comparing above lists Mercurial offers revision numbers, local to repository, while Git doesn't. On the other hand Mercurial offers relative offsets only from 'tip' (current branch), which are local to repository (at least without ParentrevspecExtension), while Git allows to specify any commit following from any tip.\nThe most recent revision is named HEAD in Git, and \"tip\" in Mercurial; there is no null revision in Git. Both Mercurial and Git can have many root (can have more than one parentless commits; this is usually result of formerly separate projects joining).\nSee also: Many different kinds of revision specifiers article on Elijah's Blog (newren's).\nPersonal opinion: I think that revision numbers are overrated (at least for distributed development and/or nonlinear / branchy history). First, for a distributed version control system they have to be either local to repository, or require treating some repository in a special way as a central numbering authority. Second, larger projects, with longer history, can have number of revisions in 5 digits range so they are offer only slight advantage over shortened to 6-7 character revision identifiers, and imply strict ordering while revisions are only partially ordered (I mean here that revisions n and n+1 doesn't need to be parent and child).\nRevision ranges\nIn Git revision ranges are topological. Commonly seen A..B syntax, which for linear history means revision range starting at A (but excluding A), and ending at B (i.e. range is open from below), is shorthand (\"syntactic sugar\") for ^A B, which for history traversing commands mean all commits reachable from B, excluding those reachable from A. This means that the behavior of A..B range is entirely predictable (and quite useful) even if A is not ancestor of B: A..B means then range of revisions from common ancestor of A and B (merge base) to revision B.\nIn Mercurial revision ranges are based on range of revision numbers. Range is specified using A:B syntax, and contrary to Git range acts as a closed interval. Also range B:A is the range A:B in reverse order, which is not the case in Git (but see below note on A...B syntax). But such simplicity comes with a price: revision range A:B makes sense only if A is ancestor of B or vice versa, i.e. with linear history; otherwise (I guess that) the range is unpredictable, and the result is local to repository (because revision numbers are local to repository).\nThis is fixed with Mercurial 1.6, which has new topological revision range, where 'A..B' (or 'A::B') is understood as the set of changesets that are both descendants of X and ancestors of Y. This is, I guess, equivalent to '--ancestry-path A..B' in Git.\nGit also has notation A...B for symmetric difference of revisions; it means A B --not $(git merge-base A B), which means all commits reachable from either A or B, but excluding all commits reachable from both of them (reachable from common ancestors).\nRenames\nMercurial uses rename tracking to deal with file renames. This means that the information about the fact that a file was renamed is saved at the commit time; in Mercurial this information is saved in the \"enhanced diff\" form in filelog (file revlog) metadata. The consequence of this is that you have to use hg rename / hg mv... or you need to remember to run hg addremove to do similarity based rename detection.\nGit is unique among version control systems in that it uses rename detection to deal with file renames. This means that the fact that file was renamed is detected at time it is needed: when doing a merge, or when showing a diff (if requested / configured). This has the advantage that rename detection algorithm can be improved, and is not frozen at time of commit.\nBoth Git and Mercurial require using --follow option to follow renames when showing history of a single file. Both can follow renames when showing line-wise history of a file in git blame / hg annotate.\nIn Git the git blame command is able to follow code movement, also moving (or copying) code from one file to the other, even if the code movement is not part of wholesome file rename. As far as I know this feature is unique to Git (at the time of writing, October 2009).\nNetwork protocols\nBoth Mercurial and Git have support for fetching from and pushing to repositories on the same filesystem, where repository URL is just a filesystem path to repository. Both also have support for fetching from bundle files.\nMercurial support fetching and pushing via SSH and via HTTP protocols. For SSH one needs an accessible shell account on the destination machine and a copy of hg installed / available. For HTTP access the hg-serve or Mercurial CGI script running is required, and Mercurial needs to be installed on server machine.\nGit supports two kinds of protocols used to access remote repository:\n\n\"smart\" protocols, which include access via SSH and via custom git:// protocol (by git-daemon), require having git installed on server. The exchange in those protocols consist of client and server negotiating about what objects they have in common, and then generating and sending a packfile. Modern Git includes support for \"smart\" HTTP protocol.\n\"dumb\" protocols, which include HTTP and FTP (only for fetching), and HTTPS (for pushing via WebDAV), do not require git installed on server, but they do require that repository contains extra information generated by git update-server-info (usually run from a hook). The exchange consist of client walking the commit chain and downloading loose objects and packfiles as needed. The downside is that it downloads more than strictly required (e.g. in corner case when there is only single packfile it would get downloaded whole even when fetching only a few revisions), and that it can require many connections to finish.\n\nExtending: scriptability vs extensions (plugins)\nMercurial is implemented in Python, with some core code written in C for performance. It provides API for writing extensions (plugins) as a way of adding extra features. Some of functionality, like \"bookmark branches\" or signing revisions, is provided in extensions distributed with Mercurial and requires turning it on.\nGit is implemented in C, Perl and shell scripts. Git provides many low level commands (plumbing) suitable to use in scripts. The usual way of introducing new feature is to write it as Perl or shell script, and when user interface stabilizes rewrite it in C for performance, portability, and in the case of shell script avoiding corner cases (this procedure is called builtinification).\nGit relies and is built around [repository] formats and [network] protocols. Instead of language bindings there are (partial or complete) reimplementations of Git in other languages (some of those are partially reimplementations, and partially wrappers around git commands): JGit (Java, used by EGit, Eclipse Git Plugin), Grit (Ruby), Dulwich (Python), git# (C#).\n\nTL;DR"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Add Xcode project to github repo?\nI have JUST created a new github repo on the website. Keep in mind that I am a noob but can do basic things in terminal. Anyway, so I just created the repo on my account on github.com and didn't do a single thing to it yet.\nSo all I want to do is take my Xcode project folder and upload it to my new github repo. How do I do this via terminal?"
},
{
"role": "assistant",
"content": "The best way really is to follow the instructions GitHub gives you:\nFirst, go the correct directory\ncd <directory of your Xcode project>\n\nIt sound like you've already got a local Git project from Xcode. If that's true, skip this code block.\ngit init .\ngit add .\ngit commit -s\n<type in a commit message>\n\nLast, push into your repository. The following is copied directly from my own github account, after I created a new \"test\" repo. Change the \"dhalperi/test\" part.\n\nPush an existing repository from the command line\ngit remote add origin [email protected]:dhalperi/test.git\ngit push -u origin master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to revert initial git commit?\nI commit to a git repository for the first time; I then regret the commit and want to revert it. I try\n# git reset --hard HEAD~1\n\nI get this message:\nfatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree.\n\nThis commit is the first commit of the repository. Any idea how to undo git's initial commit?"
},
{
"role": "assistant",
"content": "You just need to delete the branch you are on. You can't use git branch -D as this has a safety check against doing this. You can use update-ref to do this.\ngit update-ref -d HEAD\n\nDo not use rm -rf .git or anything like this as this will completely wipe your entire repository including all other branches as well as the branch that you are trying to reset."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to install a pod from a specific branch?\nI'm trying add add a pod by cocoapods, and I am using swift 3, while the pod(SQlite.swift).\nI am trying to use doesn't have a master of the latest swift version, however there is a branch for swift 3. \nSo how should I set my podfile to download the specific branch? Is it possible?\nHere is my podfile:\nplatform :ios, '10.0'\n\ntarget 'RedShirt' do\n use_frameworks!\n\n # Pods for RedShirt\n pod 'SQLite.swift', :git => 'https://github.com/stephencelis/SQLite.swift.git'\nend\n\npost_install do |installer|\n installer.pods_project.targets.each do |target|\n target.build_configurations.each do |config|\n config.build_settings['SWIFT_VERSION'] = '3.0'\n end\n end\nend"
},
{
"role": "assistant",
"content": "The podfile guide mentions the following syntax:\n\nTo use a different branch of the repo:\n\npod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'dev'\n ^^^\n (the space is important)\n\nSo in your case, that would be:\npod 'SQLite.swift', :git => 'https://github.com/stephencelis/SQLite.swift.git', :branch => 'swift3-mariotaku'"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker <commit>"
},
{
"role": "assistant",
"content": "Indicates a commit object name."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "how to git commit a whole folder?\nHere is a folder, which contains a lot of .java files.\nHow can I git commit this folder?\nIf I do the following commands\ngit add folder_name\ngit commit folder_name -m \"commit operation\"\n\nI will see the messages\nnothing added to commit but untracked files present (use \"git add\" to track)"
},
{
"role": "assistant",
"content": "You don't \"commit the folder\" - you add the folder, as you have done, and then simply commit all changes. The command should be:\ngit add foldername\ngit commit -m \"commit operation\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to import gitlab repository to bitbucket Repository\n\nI have a gitlab Repository and I want it to update it on the bitbucket account.\n\nPlease provide me steps to follow, so that it can be helpful to me to\n migrate it in bitbucket from Gitlab."
},
{
"role": "assistant",
"content": "1) Create the repository in Bitbucket using the UI\n2) Clone the Gitlab repository using the \"--bare\" option\ngit clone --bare GITLAB-URL\n\n3) Add the Bitbucket remote\ncd REPO-NAME\ngit remote add bitbucket BITBUCKET-URL\n\n4) Push all commits, branches and tags to Bitbucket\ngit push --all bitbucket\ngit push --tags bitbucket\n\n5) Remove the temp repository\ncd ..\nrm -rf REPO-NAME"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: Correct way to change Active Branch in a bare repository?\nI have a bare repository that's used as the central store for my project. All the developers do git clone <repo> to share with it. When they do the clone, they get a checkout of the master branch (unless they do git clone -n) because repo.git/HEAD contains ref: refs/heads/master, making this the Active Branch.\nThe question is, how do I change the Active Branch properly? I could simply hack the repo.git/HEAD file directly, but that seems nasty and, well, hacky.\nI tried doing git checkout <otherbranch> in the repo .git directory, but that failed because I wasn't in a work tree.\nI tried git update-ref HEAD refs/heads/otherbranch but that just updated refs/heads/master to be the same as refs/heads/otherbranch (okay, I did that one in a dummy repository, not my production one!)\nI tried git update-ref --no-deref HEAD refs/heads/otherbranch and that almost worked. It updated the HEAD file, but it set it to the SHA1 of the commit pointed to by refs/heads/otherbranch.\nI'm testing with git version 1.7.0.2.msysgit.0.\nI'm guessing there's no way to do this through git push, as allowing all and sundry to change your default branch seems a bit unsafe (!), but surely there's a better way to do it in the repo .git directory than directly hacking the HEAD file."
},
{
"role": "assistant",
"content": "If you have access to the remote bare repo, this article suggests:\ngit symbolic-ref HEAD refs/heads/mybranch\n\n\nWhich will update the HEAD file in your repository so that it contains:\n\nref: refs/heads/mybranch\n\nas documented in the git-symbolic-ref\n\nIf you don't have access to the remote repo, see my previous answer.\n\nRemember that a command like git remote set-head:\n\ndoesn't change the default branch of the remote repo.\nIt only changes a remote tracking branch stored in your local repo as refs/remotes/<name>/HEAD\ndoesn't change HEAD itself (again, only refs/remotes/<name>/HEAD), hence the need for \ngit symbolic-ref.\n\nSo git remote set-head is not the answer here.\ngit symbolic-ref HEAD is, if you have direct access to the remote repo."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options http.schannelCheckRevoke"
},
{
"role": "assistant",
"content": "Used to enforce or disable certificate revocation checks in cURL\nwhen http.sslBackend is set to \"schannel\". Defaults to true if\nunset. Only necessary to disable this if Git consistently errors\nand the message is about checking the revocation status of a\ncertificate. This option is ignored if cURL lacks support for\nsetting the relevant SSL option at runtime."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Forking Git repository from GitHub to GitLab\n\nSuppose that I would like to implement a fix to a project of someone else. That project resides on GitHub.\nI could create a fork on GitHub and implement the fix.\nHowever, I would like to create my fork on GitLab rather than on GitHub.\nIs that possible? How?\nI have read this article:\nhttps://about.gitlab.com/2016/12/01/how-to-keep-your-fork-up-to-date-with-its-origin/\nAnyway, I am not sure what should I do in my case.\n\nShould I just create a fork on GitLab of the project from GitHub somehow?\nOr should I create a mirror on GitLab of the project from GitHub?\nOr should I create a mirror on GitLab and then fork the mirror?\nOr should I do something completely different?\n\nWhat is the correct approach.\nThanks.\nUPDATE\nRepository mirroring on GitLab does not make sense probably. I can create a mirror of MY GitHub repository on GitLab but I cannot create a mirror of a repository of someone else.\nhttps://docs.gitlab.com/ee/user/project/repository/mirror/\nThis is what I have done so far:\nI have cloned the original GitHub project to my local machine. I have commited the fix to a new branch in my local repository. I have created an empty project on GitLab. I have set origin in my local repository to that empty project on GitLab and pushed both branches to GitLab. I have set upstream in my local repository to the GitHub repository.\nWhen I want to get new commits from the original GitHub repository to the repository on GitLab (i.e. sync the repositories), I can do this using my local repo as an intermediate step. However, there is no direct connection between the repo on GitHub and the repo on GitLab. Is my setup correct? Is there any difference if I make a fork on GitHub?"
},
{
"role": "assistant",
"content": "If you just want to track changes, first make an empty repository in GitLab (or whatever else you may be using) and clone it to your computer.\nThen add the GitHub project as the \"upstream\" remote with:\ngit remote add upstream https://github.com/user/repo\n\nNow you can fetch and pull from the upstream should there be any changes. (You can also push or merge to it if you have access rights.)\ngit pull upstream master\n\nFinally, push back to your own GitLab repository:\ngit push origin master\n\nIf you don't want to manually pull upstream/push origin, GitLab offers a mirroring ability in Settings => Repository => Mirroring repositories."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to transfer project from one group to a user in gitlab CE 9?\n\nI want to transfer a project from a group to another user. For e.g from https://gitlab.local/groupname/projectname to https://gitlab.local/userA/projectname\nHow can I achieve this? I have gitadmin permissions."
},
{
"role": "assistant",
"content": "Go to\nSettings ▶ General ▶ Advanced ▶ Transfer project\n▶ Select a new namespace"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitHub and Visual Studio [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\nClosed 12 years ago.\n\n\n\n\nPossible Duplicate:\nUsing Git with Visual Studio \n\nWhat's the most painless way for the Visual Studio developer to start using GitHub? Ideally the answer would involve a Visual Studio plugin, or some other integration app?\n\nWhat solutions are available today to view/update GitHub repositories? \nCan you rely or expect the same functionality as compared to other VS integrated source control plugins? \nWhat processes would you change, as a user, when approaching this use-case from the TFS or SourceGear Vault scenarios?\nThe current use case is in single-developer mode, but certainly this question is open to single dev and teams of any size. \nAny tools that are Visual Studio plug-ins would be considered 'top of the list'"
},
{
"role": "assistant",
"content": "See this question for general hints using git with Visual Studio.\nThe accepted answer was the Git Extensions project.\nI'm not aware that github would require any specific extras beyond that."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --notes[=<ref>]"
},
{
"role": "assistant",
"content": "Show the notes (see git-notes ) that annotate the\ncommit, when showing the commit log message. This is the default\nfor git log , git show and git whatchanged commands when\nthere is no --pretty , --format , or --oneline option given\non the command line. By default, the notes shown are from the notes refs listed in the core.notesRef and notes.displayRef variables (or corresponding\nenvironment overrides). See git-config for more details. With an optional <ref> argument, use the ref to find the notes\nto display. The ref can specify the full refname when it begins\nwith refs/notes/ ; when it begins with notes/ , refs/ and otherwise refs/notes/ is prefixed to form the full name of the ref. Multiple --notes options can be combined to control which notes are\nbeing displayed. Examples: \"--notes=foo\" will show only notes from\n\"refs/notes/foo\"; \"--notes=foo --notes\" will show both notes from\n\"refs/notes/foo\" and from the default notes ref(s)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why am I getting \"Pipeline failed due to the user not being verified\" & \"Detached merge request pipeline\" on a Gitlab merge request?\n\nWhen a non-owner dev pushes a branch to our Gitlab repo, it returns a \"pipeline failed\" message, with the detail \"Pipeline failed due to the user not being verified\". On the dev's account, he's getting a prompt to add a credit card to verify him to be eligible for free pipeline minutes.\nBut I haven't set up any pipelines - I don't have a gitlab-ci.yml file in my repo, neither does the new branch. There are no jobs or schedules under the CI/CD tab of the project on Gitlab. So why is there a marker saying the branch failed in the pipeline?"
},
{
"role": "assistant",
"content": "In my case, I was using my own runner for my project. In that case also, I got this error.\nI fixed the error by disabling the shared runner in my project.\nUnder\nSetting -> CICD -> Runner (Expand) -> Under the shared runner section, disable Shared runner."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary index entry"
},
{
"role": "assistant",
"content": "The information regarding a particular file, stored in the index . An index entry can be unmerged, if a merge was started, but not yet finished (i.e. if\nthe index contains multiple versions of that file)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options extensions.worktreeConfig"
},
{
"role": "assistant",
"content": "If enabled, then worktrees will load config settings from the $GIT_DIR/config.worktree file in addition to the $GIT_COMMON_DIR/config file. Note that $GIT_COMMON_DIR and $GIT_DIR are the same for the main working tree, while other\nworking trees have $GIT_DIR equal to $GIT_COMMON_DIR/worktrees/<id>/ . The settings in the config.worktree file will override settings from any other\nconfig files. When enabling extensions.worktreeConfig , you must be careful to move\ncertain values from the common config file to the main working tree’s config.worktree file, if present: core.worktree must be moved from $GIT_COMMON_DIR/config to $GIT_COMMON_DIR/config.worktree . If core.bare is true, then it must be moved from $GIT_COMMON_DIR/config to $GIT_COMMON_DIR/config.worktree . It may also be beneficial to adjust the locations of core.sparseCheckout and core.sparseCheckoutCone depending on your desire for customizable\nsparse-checkout settings for each worktree. By default, the git\nsparse-checkout builtin enables extensions.worktreeConfig , assigns\nthese config values on a per-worktree basis, and uses the $GIT_DIR/info/sparse-checkout file to specify the sparsity for each\nworktree independently. See git-sparse-checkout for more\ndetails. For historical reasons, extensions.worktreeConfig is respected\nregardless of the core.repositoryFormatVersion setting."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: Who has modified this line?\nIf I found a bug in my application, sometimes I need to know which commits have affected to the bug source code line. I'm wondering which is the best approach to do it with Git."
},
{
"role": "assistant",
"content": "To see commits affecting line 40 of file foo:\ngit blame -L 40,+1 foo\n\nThe +1 means exactly one line. To see changes for lines 40-60, it's:\ngit blame -L 40,+21 foo\n\nOR\ngit blame -L 40,60 foo\n\nThe second number can be an offset designated with a '+', or a line number. git blame docs"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitignore"
},
{
"role": "assistant",
"content": "Specifies intentionally untracked files to ignore"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can't clone gitlab's repo via ssh, via http - OK\n\nI'm new to gitlab and CI so i had tons of questions but some of them solved via google, SO, git mans, but not the last ...\nI can't clone repo via ssh =(\nIf i try to clone repo via http:\nlesha@lesha-SeoTeam:/var/www$ git clone http://gitlab.vbox/root/virtualboxgitlab.git\nCloning into 'virtualboxgitlab'...\nUsername for 'http://gitlab.vbox': root\nPassword for 'http://[email protected]':\nwarning: You appear to have cloned an empty repository.\n\nThat's OK!\nBut via ssh ...\nlesha@lesha-SeoTeam:/var/www$ git clone [email protected]:root/virtualboxgitlab.git\nCloning into virtualbox 'gitlab'\n[email protected]'s password:<br /> \n\nIt prompts me git's password which I didn't create during install (as I had in man)\nrsa keys\n\nI added my key via gitlab's web (to account root, actually I didn't create any other accounts)\nAnd also I added key by \"cat my_rsa.pub >> authorized_keys\"\nI read few posts here about ssh troubles, but most have gitolite installed\nI installed gitlab 5.3 without gitolite (as in manual), may be I should ?\nAlso I tried ssh -vT [email protected] and it outputs :\n....\ndebug1: Server host key: ECDSA 48:83:ba:b3:37:72:a0:dc:ca:2c:a3:b8:78:a1:c4:ad\ndebug1: Host 'gitlab.vbox' is known and matches the ECDSA host key.\ndebug1: Found key in /home/lesha/.ssh/known_hosts:2\ndebug1: ssh_ecdsa_verify: signature correct\ndebug1: SSH2_MSG_NEWKEYS sent\ndebug1: expecting SSH2_MSG_NEWKEYS\ndebug1: SSH2_MSG_NEWKEYS received\ndebug1: Roaming not allowed by server\ndebug1: SSH2_MSG_SERVICE_REQUEST sent\ndebug1: SSH2_MSG_SERVICE_ACCEPT received\ndebug1: Authentications that can continue: publickey,password\ndebug1: Next authentication method: publickey\ndebug1: Offering RSA public key: /home/lesha/.ssh/id_rsa\ndebug1: Authentications that can continue: publickey,password\ndebug1: Trying private key: /home/lesha/.ssh/id_dsa\ndebug1: Trying private key: /home/lesha/.ssh/id_ecdsa\ndebug1: Next authentication method: password\n[email protected]'s password:\n\n\nroot@seotm-server:/home/git/.ssh# ls -l\nитого 4\n-rw------- 1 git git 922 Июл 18 21:05 authorized_keys\n\nenvironmetnt: \ndebian 7, nginx + passenger, gitlab 5.3, ruby 2.0.0p247 , without gitolite, puma against unicorn\nplease help!=) i'm stuck ...\n\nsome additions (20.07.2013):\nI created user git as in manual install\nsudo adduser --disabled-login --gecos 'GitLab' git\n\nThe next day, I tried to kill git and re-add simply by useradd command, after that my keys are working but i'm still not happy because:\nlesha@lesha-SeoTeam:/var/www$ git clone [email protected]:root/virtualboxgitlab.git\nCloning into 'virtualboxgitlab'...\nfatal: 'root/virtualboxgitlab.git' does not appear to be a git repository\nfatal: The remote end hung up unexpectedly\n\nand http works as well as previous:\nlesha@lesha-SeoTeam:/var/www$ git clone http://gitlab.vbox/root/virtualboxgitlab.git\nCloning into 'virtualboxgitlab'...\nUsername for 'http://gitlab.vbox': root\nPassword for 'http://[email protected]': \nwarning: You appear to have cloned an empty repository.\n\nSo, now I don't have auth problems but have another one.\nHow would you troubleshoot this issue from there?"
},
{
"role": "assistant",
"content": "GitLab 5.x doesn't use gitolite anymore, but gitlab-shell.\nI would advise to create a dedicated account, as recommended in the installation process. \nssh [email protected]\n\nThat ssh commands means you are asking for a secure shell on 'gitlab.vbox' as user 'git'. If that user doesn't exist... it won't work.\nThere is no need to try and clone repo is the tests doesn't run properly:\nsudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production\n\nThe OP reports ssh works better after creating the git user and adding the keys, but:\n\nfirst make sure you create your keys on a 'client' account', not in ~git/.ssh/id_rsa: you are trying to open a session as git, from a client account. git is the account in which gitlab is installed.\nYou should then register your public key in the ssh page of the user account you declare through the gitlab gui. You should not \"useradd\" an ssh to root.\n\nIf you see this:\nlesha@lesha-SeoTeam:/var/www$ git clone [email protected]:root/virtualboxgitlab.git\nCloning into 'virtualboxgitlab'...\nfatal: 'root/virtualboxgitlab.git' does not appear to be a git repository\nfatal: The remote end hung up unexpectedly\n\nThat also means you shouldn't specify the path of the repo (root/):\n git clone [email protected]:virtualboxgitlab.git\n\nIt is gitlab job to know where virtualboxgitlab.git is stored (as specified in its gitlab.yml config file)\nBasically, forget root, and do the full installation of gitlab as it was intended: in a 'git' account.\nThe OP made it work, commenting that:\n\n\"root\" is administrators namespace, gitlab creates this url automatically and without it clone doesn't work, now everything clones and I begin to install gitlab CI,\n\nThe OP had to:\n\nadd my user to sudo group, made clean install, received error \n\n/usr/local/lib/ruby/2.0.0/net/http.rb:878:in initialize': getaddrinfo: \n Name or service not known (SocketError)\n\nwhich can't resolve hostname, added gitlab.vbox to /etc/hosts"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitfaq - Frequently asked questions about using Git How do I use multiple accounts with the same hosting provider using HTTP?"
},
{
"role": "assistant",
"content": "Usually the easiest way to distinguish between these accounts is to use\nthe username in the URL. For example, if you have the accounts author and committer on git.example.org , you can use the URLs https://[email protected]/org1/project1.git and https://[email protected]/org2/project2.git . This way, when you\nuse a credential helper, it will automatically try to look up the\ncorrect credentials for your account. If you already have a remote set\nup, you can change the URL with something like git remote set-url\norigin https://[email protected]/org1/project1.git (see git-remote for details)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I solve \"fatal: Invalid credentials\" error when pushing to Bitbucket?\nWant to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.\n \n \n\n\n\n\n\n\nMy Bitbucket password is correct because I can easily log in with this password. When I try to push a project or file to Bitbucket it shows \"Invalid credentials error\".\ngit push -u origin master\n\nfatal: Invalid credentials\nPassword for 'https://[email protected]':\nremote: Bitbucket Cloud recently stopped supporting account passwords for Git authentication.\nremote: See our community post for more details: https://atlassian.community/t5/x/x/ba-p/1948231\nremote: App passwords are recommended for most use cases and can be created in your Personal settings:\nremote: https://bitbucket.org/account/settings/app-passwords/\nfatal: Authentication failed for 'https://bitbucket.org/username/demo.git/'\n\nHow can I solve this issue?"
},
{
"role": "assistant",
"content": "When prompted to log in, use your username, but instead of your usual account password, use the app password:\nTo get the app password\n\nGo to the bitbucket.org website and log in\nFrom your gear in the upper right, and click Personal Bitbucket settings\nClick App passwords under Access management\nClick Create app password\nGive the app password sufficient rights (probably write on the repo at a minimum), and a label related to the application that will use the password\nDon't forget to save that password"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-blame - Show what revision and author last modified each line of a file"
},
{
"role": "assistant",
"content": "INCREMENTAL OUTPUT When called with --incremental option, the command outputs the\nresult as it is built. The output generally will talk about\nlines touched by more recent commits first (i.e. the lines will\nbe annotated out of order) and is meant to be used by\ninteractive viewers. The output format is similar to the Porcelain format, but it\ndoes not contain the actual lines from the file that is being\nannotated. Each blame entry always starts with a line of: <40-byte-hex-sha1> <sourceline> <resultline> <num-lines> Line numbers count from 1. The first time that a commit shows up in the stream, it has various\nother information about it printed out with a one-word tag at the\nbeginning of each line describing the extra commit information (author,\nemail, committer, dates, summary, etc.). Unlike the Porcelain format, the filename information is always\ngiven and terminates the entry: \"filename\" <whitespace-quoted-filename-goes-here> and thus it is really quite easy to parse for some line- and word-oriented\nparser (which should be quite natural for most scripting languages). Note For people who do parsing: to make it more robust, just ignore any\nlines between the first and last one (\"<sha1>\" and \"filename\" lines)\nwhere you do not recognize the tag words (or care about that particular\none) at the beginning of the \"extended information\" lines. That way, if\nthere is ever added information (like the commit encoding or extended\ncommit commentary), a blame viewer will not care."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab Personal Access Token - where to keep the token for seamless clone / pull / push\n\nCan anyone tell where to put the Gitlab PAT - Personal Access Token?\nDownloading git::https://gitlab.com/mycompany/myproject.git?ref=v0.0.1 - unable to download - I can't change the URL as its fixed in project repo.\nI tried to set it in my git config --global\ngitlab.accesstoken=abcdef1233TVHEPkNxyz\nalso as environment variable\nTOKEN=abcdef1233TVHEPkNxyz\nPRIVATE_TOKEN=abcdef1233TVHEPkNxyz\nAny advice please?"
},
{
"role": "assistant",
"content": "Basically we need to:\n\nGenerate PAT https://gitlab.com/profile/personal_access_tokens [permissions as per requirement]\ngit clone https://oauth2:[email protected]/mycompany/myproject.git?ref=v0.0.1\n\nHowever, if we can not change the url from: git::https://gitlab.com/mycompany/myproject.git?ref=v0.0.1 to the above format or we want to avoid entering the token each time we clone a repo or use GitLab APIs, we need to do the following:\n\nSetup a credential store, example on Ubuntu:\n`sudo apt-get install libsecret-1-0 libsecret-1-dev`\n`sudo make --directory=/usr/share/doc/git/contrib/credential/libsecret`\n`git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret`\n\n\nGit clone a http url:\n`git clone https://gitlab.com/mycompany/myproject.git?ref=v0.0.1`\n\n\n\nwhen prompted for password use PAT instead. The PAT will be stored in the libsecret store for default 15 minutes. use git config --global credential.helper 'cache --timeout=1800' to change the timeout duration.\nRefer: https://www.softwaredeveloper.blog/git-credential-storage-libsecret"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Getting \"Repositroy test has failed\" error while cloning repository from Gitlab in Android Studio?\n\nI will like to clone my android code from gitlab repository in Android Studio 0.8.1.I checked into VCS >> Checked out from Version Control >> Git >> Added HTTP url here.It prompts me that \"Repositroy test has failed\".Kindly help me to sort out the issue.I have checked the plugins as well.Thanks a lot."
},
{
"role": "assistant",
"content": "You need to download and install git from http://git-scm.com/downloads\nThen you need to track the git.exe on AndroidStudio:\n\nGo to Settings > Project Settings > Version Control > VCSs > Git > Path to Git executable\nSelect (or type) executable path, eg: D:\\Program Files (x86)\\Git\\cmd\\git.exe\n\nIf you installed GitHub Desktop for Windows\nIn case you have GitHub Desktop for Windows, git.exe will be found at C:\\Users\\YOUR_USER_NAME\\AppData\\Local\\GitHub\\PortableGit_c7e0cbde92ba565zz218z5214zzz0e854zzza28\\cmd."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-var"
},
{
"role": "assistant",
"content": "Show a Git logical variable"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --dst-prefix=<prefix>"
},
{
"role": "assistant",
"content": "Show the given destination prefix instead of \"b/\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is it possible to have a custom .gitignore? Read only access?\nI am working in a team environment, and there is already a .gitignore file.\nI want to add more items to the .gitignore file, but I don't want to check this file in either. It is possible to set custom ignore files which only apply to me?\nAlso, I want to give someone read only access to a private git repository on our server, if I add their SSH key to our server they will get full access like everyone else. How can I limit it to read-only, no commits allowed."
},
{
"role": "assistant",
"content": "Put your private ignore rules in .git/info/exclude. See gitignore(5).\nFor read-only access, use git-daemon, a web server, or Gitosis, or Gitolite."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I show what a commit did?\nA stupid way I know is:\ngit diff commit-number1 commit-number2\n\nIs there a better way?\nI mean, I want to know the commit1 itself. I don't want to add the commit2 before it as a parameter."
},
{
"role": "assistant",
"content": "git show <commit-id>\n\nDocumentation for git show"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Fix GitLab error: \"you are not allowed to push code to protected branches on this project\"?\n\nI have a problem when I push my code to git while I have developer access in my project, but everything is okay when I have master access. Where is the problem come from? And how to fix it?\nError message:\n\nerror: You are not allowed to push code to protected branches on this project.\n...\nerror: failed to push some refs to ..."
},
{
"role": "assistant",
"content": "there's no problem - everything works as expected.\nIn GitLab some branches can be protected. By default only Maintainer/Owner users can commit to protected branches (see permissions docs). master branch is protected by default - it forces developers to issue merge requests to be validated by project maintainers before integrating them into main code.\nYou can turn on and off protection on selected branches in Project Settings (where exactly depends on GitLab version - see instructions below). \nOn the same settings page you can also allow developers to push into the protected branches. With this setting on, protection will be limited to rejecting operations requiring git push --force (rebase etc.)\nSince GitLab 9.3\nGo to project: \"Settings\" → \"Repository\" → \"Expand\" on \"Protected branches\"\n\nI'm not really sure when this change was introduced, screenshots are from 10.3 version.\nNow you can select who is allowed to merge or push into selected branches (for example: you can turn off pushes to master at all, forcing all changes to branch to be made via Merge Requests). Or you can click \"Unprotect\" to completely remove protection from branch.\nSince GitLab 9.0\nSimilarly to GitLab 9.3, but no need to click \"Expand\" - everything is already expanded:\nGo to project: \"Settings\" → \"Repository\" → scroll down to \"Protected branches\".\n\nPre GitLab 9.0\nProject: \"Settings\" → \"Protected branches\" (if you are at least 'Master' of given project).\n\nThen click on \"Unprotect\" or \"Developers can push\":"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to find the tag associated with a given git commit?\nFor releases I usually tag with something like v1.1.0. During my build script I am creating a fwVersion.c file that contains the current git info. Currently, I have commit, and branch info in the file, but I would like to add the tag.\nIs this possible?"
},
{
"role": "assistant",
"content": "Check the documentation for git describe. It finds the nearest tag to a given commit (that is a tag which points to an ancestor of the commit) and describes that commit in terms of the tag.\nIf you only want to know if the commit is pointed to by a tag then you can check the output of:\ngit describe --exact-match <commit-id>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "can't push to branch after rebase\nWe use git and have a master branch and developer branches. I need to add a new feature and then rebase the commits to master, then push master to CI server.\nThe problem is that if I have conflicts during rebase I cannot push to my remote developer branch (on Github) after the rebase is complete, until I pull my remote branch. This causes duplicate commits. When there are no conflicts, works as expected.\nquestion: after rebase and conflict resolution, how do I sync up my local and remote developer branches without creating duplicate commits\nSetup:\n// master branch is the main branch\ngit checkout master\ngit checkout -b myNewFeature\n\n// I will work on this at work and at home\ngit push origin myNewFeature\n\n// work work work on myNewFeature\n// master branch has been updated and will conflict with myNewFeature\ngit pull --rebase origin master\n\n// we have conflicts\n// solve conflict\ngit rebase --continue\n\n//repeat until rebase is complete\ngit push origin myNewFeature\n\n//ERROR\nerror: failed to push some refs to '[email protected]:ariklevy/dropLocker.git'\nhint: Updates were rejected because the tip of your current branch is behind\nhint: its remote counterpart. Merge the remote changes (e.g. 'git pull')\nhint: before pushing again.\nhint: See the 'Note about fast-forwards' in 'git push --help' for details.\n\n// do what git says and pull\ngit pull origin myNewFeature\n\ngit push origin myNewFeature\n\n// Now I have duplicate commits on the remote branch myNewFeature\n\nEDIT\nSo it sounds like this will break the workflow:\ndeveloper1 working on myNewFeature\ndeveloper2 working on hisNewFeature\nboth use master as main branch\ndeveloper2 merges myNewFeature into hisNewFeature\ndeveloper1 rebases, resolves conflicts, then force pushes to remote branch for myNewFeature\na couple days later, developer2, merges myNewFeature into hisNewFeature again\nWill this cause the other developers to hate developer1?"
},
{
"role": "assistant",
"content": "First, you and those you're working with need to agree whether a topic/devel branch is for shared development or just your own. Other developers know not to merge on my development branches because they'll be rebased at any time. Usually the workflow is as follows:\no-----o-----o-----o-----o-----o master\n \\\n o-----o-----o devel0\n \\\n o-----o-----o devel1\n\nThen to stay up-to-date with remote I'll do the following:\n git fetch origin\n git checkout master\n git merge --ff origin/master\n\nI do this for two reasons. First because it allows me to see if there are remote changes without needing to switch from my devel branch. Second it's a safety mechanism to make sure I don't overwrite any un-stashed/committed changes. Also, if I can't fast-forward merge to the master branch that means either someone has rebased the remote master (for which they need to be flogged severely) or I accidentally committed to master and need to clean up my end.\nThen when remote has changes and I've fast forwarded to the latest I'll rebase:\ngit checkout devel0\ngit rebase master\ngit push -f origin devel0\n\nOther developers then know they'll need to rebase their devel branches off my latest:\ngit fetch <remote>\ngit checkout devel1\ngit rebase <remote>/devel0\n\nWhich results in much cleaner history:\no-----o master\n \\\n o-----o-----o devel0\n \\\n o-----o-----o devel1\n\nDon't merge commits back and forth at your whim. Not only does it create duplicate commits and make history impossible to follow, finding regressions from a specific change becomes near impossible (which is why you're using version control in the first place, right?). The problem you're having is the result of doing just this.\nAlso it sounds like other developers may be making commits to your devel branches. Can you confirm this?\nThe only time to merge is when your topic branch is ready to be accepted into master.\nOn a side note. If multiple developers are committing to the same repository you should all consider having named branches to distinguish between developers devel branches. For example:\ngit branch 'my-name/devel-branch'\n\nSo all developers topic branches reside within their own nested set."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "OpenSSL SSL_connect: Connection was reset in connection to github.com:443 while try to git push\nfatal: unable to access 'https://github.com/XXX/XXXXX.git/': OpenSSL SSL_connect: Connection was reset in connection to github.com:443\n\nSuddenly I'm getting above error while I try to git pull, git push, or clone the repo."
},
{
"role": "assistant",
"content": "I also encountered a similar situation; that's when I came across an answer on Code Grepper by Shibbir Ahmed, where he provided this:\ngit config --global --unset-all remote.origin.proxy\nThat solved the issue for me."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Remove a modified file from pull request\n\nI have 3 modified files (no new files) in a pull request at the moment. \nI would like to remove one of those files from the pull request, so that the pull request only contains changes to two files and leaves the third in its original, untouched state. \nI have tried a couple things (checking out the original version of the file, etc...) but it still shows as a changed file in the PR.\nIs there a solution to this?"
},
{
"role": "assistant",
"content": "Switch to the branch from which you created the pull request:\n$ git checkout pull-request-branch\n\nOverwrite the modified file(s) with the file in another branch, let's consider it's master:\ngit checkout origin/master -- src/main/java/HelloWorld.java\n\nCommit and push it to the remote:\ngit commit -m \"Removed a modified file from pull request\"\ngit push origin pull-request-branch\n\n\nReference:\nSee git checkout docs:\ngit checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <pathspec>…\n\n\nOverwrite the contents of the files that match the pathspec. When the <tree-ish> (most often a commit) is not given, overwrite working tree with the contents in the index. When the <tree-ish> is given, overwrite both the index and the working tree with the contents at the <tree-ish>.\n\nAnything within [] is optional. In our case, we want to overwrite items identified by a specific pathspec with its respective content at a different branch/commit/tag"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Determine if directory is under git control\nHow can I tell if a given directory is part of a git respository?\n(The following is in python, but bash or something would be fine.)\nos.path.isdir('.svn')\n\nwill tell you if the current directory is controlled by Subversion. Mercurial and Git just have a .hg/.git at the top of the repository, so for hg I can use\nos.system('hg -q stat 2> /dev/null > /dev/null') == 0)\n\nbut git status returns a nonzero (error) exit status if nothing's changed.\nIs iterating up the path looking for .git myself the best I can do?"
},
{
"role": "assistant",
"content": "Just found this in git help rev-parse\ngit rev-parse --is-inside-work-tree\n\nprints true if it is in the work tree, false if it's in the .git tree, and fatal error if it's neither. Both true and false are printed on stdout with an exit status of 0, the fatal error is printed on stderr with an exit status of 128."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Github API - create branch?\n\nSeems like it's missing from the \"Repos\" docs for v1, v2, and v3...how do I create a branch using the Github API?"
},
{
"role": "assistant",
"content": "The V3 API mentions branches in its reference page\n\nThe ref in the URL must be formatted as heads/branch, not just branch.\nFor example, the call to get the data for a branch named sc/featureA would be:\n\nGET /repos/:user/:repo/git/refs/heads/sc/featureA\n\nCreate a Reference\nPOST /repos/:user/:repo/git/refs\n\nParameters\nref\n\n\nString of the name of the fully qualified reference (ie: refs/heads/master). If it doesn’t start with ‘refs’ and have at least two slashes, it will be rejected.\n\nsha\n\n\nString of the SHA1 value to set this reference to\n\nSo it should be possible to create a new branch, by naming a new '/heads' in the ref parameter.\n\nPotherca points out to a working test, using the service of www.hurl.it (which makes HTTP requests)\n\n\nFind the revision you want to branch from.\nEither on Github itself or by doing a GET request from Hurl:\nhttps://api.github.com/repos/<AUTHOR>/<REPO>/git/refs/heads\n\nCopy the revision hash\n\nDo a POST request from Hurl to https://api.github.com/repos/<AUTHOR>/<REPO>/git/refs with the following as the POST body :\n {\n \"ref\": \"refs/heads/<NEW-BRANCH-NAME>\",\n \"sha\": \"<HASH-TO-BRANCH-FROM>\"\n }\n\n(obviously replacing the <NEW-BRANCH-NAME> with the name your want the new branch to have and the <HASH-TO-BRANCH-FROM> with, you know, the hash of the revision you want to branch from)\nYou will need to use HTTP basic and fill in your Github credentials to access the Github API.\n\nPress the Send button and your branch will be created!\n\n\n\n\nIn 2022, you can also use gh api\ngh api \\\n --method POST \\\n -H \"Accept: application/vnd.github.v3+json\" \\\n /repos/OWNER/REPO/git/refs \\\n -f ref='refs/heads/featureA'\n -f sha='aa218f56b14c9653891f9e74264a383fa43fefbd'"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "See Repositories where I am Collaborator\n\nI am a collaborator on a private repo, but it doesn't show up under my repositories. I also cannot see it on the other user's repository listing because it is private. I have confirmed that I am able to push/pull to the repo. Is there a way to access this repository using Github without typing in the full URL ?"
},
{
"role": "assistant",
"content": "You can see the repositories where you're a collaborator. To do this, head to the Repositories section of your account's settings (https://github.com/settings/repositories).\nThere should be a Leave action button aside each repository you're a collaborator on."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options core.ignoreCase"
},
{
"role": "assistant",
"content": "Internal variable which enables various workarounds to enable\nGit to work better on filesystems that are not case sensitive,\nlike APFS, HFS+, FAT, NTFS, etc. For example, if a directory listing\nfinds \"makefile\" when Git expects \"Makefile\", Git will assume\nit is really the same file, and continue to remember it as\n\"Makefile\". The default is false, except git-clone or git-init will probe and set core.ignoreCase true if appropriate when the repository\nis created. Git relies on the proper configuration of this variable for your operating\nand file system. Modifying this value may result in unexpected behavior."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Troubleshooting git push - it asks for a user/pass\nI'm using git on a new git linux computer. When I do git push, it me asks for user/password.\nI've setup git properly, and in fact cloning the repo from github into a new folder works perfectly (using my public key, not the readonly copy). When I try to push from a previous clone I made to the same repo I get prompted for a user/pass.\nOf course sshing into [email protected] works, and I made sure my public key is configured in github. Any ideas how to continue debugging?"
},
{
"role": "assistant",
"content": "this occurs because you did\ngit clone https://github.com/username/repo\n\ninstead of \ngit clone [email protected]:username/repo.git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-clean - Remove untracked files from the working tree ask each"
},
{
"role": "assistant",
"content": "This will start to clean, and you must confirm one by one in order\nto delete items. Please note that this action is not as efficient\nas the above two actions."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "remove git submodule but keep files\nI have a git submodule that I would like to become part of my main project (since I have a lot of project specific code that will go into the submodule). \nSo I'd like to remove the git references to the submodule and add the files to my main git repository.\nBut how ?"
},
{
"role": "assistant",
"content": "You must remove the gitlink entry in your index:\nmv subfolder subfolder_tmp\ngit submodule deinit subfolder\ngit rm --cached subfolder\nmv subfolder_tmp subfolder\ngit add subfolder\n\nReplace subfolder with the name of the folder for your submodule, and make sure to not add any trailing slash.\nThis is what I detail in \"Remove a Git submodule?\" and \"un-submodule a git submodule\".\nThe --cached option allows you to keep the subfolder content in your disk... except git submodule deinit would already have removed that content anyway. Hence the mv part.\nYou then can add and commit that subfolder."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitformat-bundle"
},
{
"role": "assistant",
"content": "The bundle file format"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-grep - Print lines matching a pattern -w --word-regexp"
},
{
"role": "assistant",
"content": "Match the pattern only at word boundary (either begin at the\nbeginning of a line, or preceded by a non-word character; end at\nthe end of a line or followed by a non-word character)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-update-ref - Update the object name stored in a ref safely update"
},
{
"role": "assistant",
"content": "Set <ref> to <new-oid> after verifying <old-oid>, if given.\nSpecify a zero <new-oid> to ensure the ref does not exist\nafter the update and/or a zero <old-oid> to make sure the\nref does not exist before the update."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options remote.<name>.vcs"
},
{
"role": "assistant",
"content": "Setting this to a value <vcs> will cause Git to interact with\nthe remote with the git-remote-<vcs> helper."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Github Action: Split Long Command into Multiple Lines\n\nI have a Github action command that is really long:\nname: build\n\non: [push]\n\njobs:\n build:\n runs-on: ubuntu-18.04\n steps:\n - uses: actions/checkout@v1\n - name: Install Prerequisites\n run: |\n sudo apt-get update\n sudo apt-get install -y --no-install-recommends \"a very very long list of prerequisites\"\n\nMay I know whether it is possible to split the long command into multiple lines for better readability? I have tried the separator '' but it does not work."
},
{
"role": "assistant",
"content": "I have a multi line command using backslash to separate the lines as follows:\n- name: Configure functions\n run: |\n firebase functions:config:set \\\n some.key1=\"${{ secrets.SOME_KEY_1 }}\" \\\n some.key2=\"${{ secrets.SOME_KEY_2 }}\" \\\n ... \n\n\nNote the preceding '|' character, and make sure the subsequent lines after the first one are indented (tabulated)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git push error '[remote rejected] master -> master (branch is currently checked out)'\nYesterday, I posted a question on how to clone a Git repository from one of my machines to another, How can I 'git clone' from another machine?.\nI am now able to successfully clone a Git repository from my source (192.168.1.2) to my destination (192.168.1.1).\nBut when I did an edit to a file, a git commit -a -m \"test\" and a git push, I get this error on my destination (192.168.1.1):\ngit push \n[email protected]'s password: \nCounting objects: 21, done.\nCompressing objects: 100% (11/11), done.\nWriting objects: 100% (11/11), 1010 bytes, done.\nTotal 11 (delta 9), reused 0 (delta 0)\nerror: refusing to update checked out branch: refs/heads/master\nerror: By default, updating the current branch in a non-bare repository\nerror: is denied, because it will make the index and work tree inconsistent\nerror: with what you pushed, and will require 'git reset --hard' to match\nerror: the work tree to HEAD.\nerror: \nerror: You can set 'receive.denyCurrentBranch' configuration variable to\nerror: 'ignore' or 'warn' in the remote repository to allow pushing into\nerror: its current branch; however, this is not recommended unless you\nerror: arranged to update its work tree to match what you pushed in some\nerror: other way.\nerror: \nerror: To squelch this message and still keep the default behaviour, set\nerror: 'receive.denyCurrentBranch' configuration variable to 'refuse'.\nTo git+ssh://[email protected]/media/LINUXDATA/working\n! [remote rejected] master -> master (branch is currently checked out)\nerror: failed to push some refs to 'git+ssh://[email protected]/media/LINUXDATA/working'\n\nI'm using two different versions of Git (1.7 on the remote and 1.5 on the local machine). Is that a possible reason?"
},
{
"role": "assistant",
"content": "The error message error: refusing to update checked out branch: refs/heads/master is emitted by the remote repository and it means you're trying to push code to remote non-bare repository that has different code currently checked out in the working directory. The best way to avoid this problem is to push to bare repositories only - this problem cannot ever happen with a bare repository.\nYou can simply convert your remote repository to bare repository (there is no working copy in the bare repository - the folder contains only the actual repository data).\nExecute the following command in your remote repository folder:\ngit config --bool core.bare true\n\nThen delete all the files except .git in that folder. And then you will be able to perform git push to the remote repository without any errors."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Clone: Just the files, please?\nI want to clone a GIT repo and NOT end up with a .git directory. In other words I just want the files. Is there a way to do this? \ngit clone --no-checkout did the exact opposite of what I want (gave me just the .git directory).\nI am trying to do that for a remote repo, not a local one, meaning this is not a duplicate of \"How to do a “git export” (like “svn export”)\" (even though the solution might end up being the same)."
},
{
"role": "assistant",
"content": "The git command that would be the closest from what you are looking for would by git archive.\nSee backing up project which uses git: it will include in an archive all files (including submodules if you are using the git-archive-all script)\nYou can then use that archive anywhere, giving you back only files, no .git directory.\ngit archive --remote=<repository URL> | tar -t\n\nIf you need folders and files just from the first level:\ngit archive --remote=<repository URL> | tar -t --exclude=\"*/*\"\n\nTo list only first-level folders of a remote repo:\ngit archive --remote=<repository URL> | tar -t --exclude=\"*/*\" | grep \"/\"\n\nNote: that does not work for GitHub (not supported)\nSo you would need to clone (shallow to quicken the clone step), and then archive locally:\ngit clone --depth=1 [email protected]:xxx/yyy.git\ncd yyy\ngit archive --format=tar aTag -o aTag.tar\n\n\nAnother option would be to do a shallow clone (as mentioned below), but locating the .git folder elsewhere.\ngit --git-dir=/path/to/another/folder.git clone --depth=1 /url/to/repo\n\nThe repo folder would include only the file, without .git.\nNote: git --git-dir is an option of the command git, not git clone.\n\nUpdate with Git 2.14.X/2.15 (Q4 2017): it will make sure to avoid adding empty folders.\n\n\"git archive\", especially when used with pathspec, stored an empty\n directory in its output, even though Git itself never does so.\n This has been fixed.\n\nSee commit 4318094 (12 Sep 2017) by René Scharfe (``).\nSuggested-by: Jeff King (peff).\n(Merged by Junio C Hamano -- gitster -- in commit 62b1cb7, 25 Sep 2017) \n\narchive: don't add empty directories to archives\nWhile git doesn't track empty directories, git archive can be tricked into putting some into archives.\n While that is supported by the object database, it can't be represented in the index and thus it's unlikely to occur in the wild.\nAs empty directories are not supported by git, they should also not be\n written into archives.\n If an empty directory is really needed then it can be tracked and archived by placing an empty .gitignore file in it."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-bundle - Move objects and refs by archive"
},
{
"role": "assistant",
"content": "FILE FORMAT See gitformat-bundle ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs -w --ignore-all-space"
},
{
"role": "assistant",
"content": "Ignore whitespace when comparing lines. This ignores\ndifferences even if one line has whitespace where the other\nline has none."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git rollback 1 pull\nI have a web server that serves a project that is a git repository. When I do some changes to the code I then do a git pull from the server. Sometimes the new code just crashes, I would like to be able to do a rollback to the latest pull, the one just before. I want to do that with a script, without having to search what is the latest sha. How can I do that?\nEdit: Just to clarify, I just want to have to do one action, like pushing a button that says \"oops! this latest pull I just did was a mistake, I wish I didn't do that\". I don't want to have to look for sha or tags or anything else in this situation, it's more like an 'undo' function.\nThen I want to be able to continue working on the code and the next pull on the server needs to bring the latest changes."
},
{
"role": "assistant",
"content": "git reset --hard HEAD^1 will take you back one commit from what you pulled. If you want it back to the state it was in before you pulled, use git reset --hard HEAD@{1}. The @{1} tracks where the head was at before the last operation that changed it in your local repo, so it will go back several commits if several were pushed before you did your pull. Also see git reflog to show the entire list."
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.