How do I check out a remote Git branch?
2023-01-25
Question Somebody pushed a branch called test with git push origin test to a shared repository. I can see the branch with git branch -r. How do I check out the remote test branch? I've tried: git checkout test, which does nothing git checkout origin/test gives * (no branch) Answer The answer has been split depending on whether there is one remote repository configured or multiple. The reason for this is that for the single remote case, some of the commands can be simplified as there is less ambiguity.…
How to know the git username and email saved during configuration?
2023-01-24
Question While configuring git I ran these two commands: git config --global user.name "My Name" git config –global user.email “myemail@example.com” However, I doubt whether I made a typo or not. So, is there any command to know the name and email which git saved during configuration? Obviously, I can know that using the git log command by looking at the commit history. But for that I have to make commits, right?…
Git: What's the best practice to git clone into an existing folder?
2023-01-23
Question I have a working copy of the project, without any source control meta data. Now, I'd like to do the equivalent of git-clone into this folder, and keep my local changes. git-clone doesn't allow me to clone into an existing folder. What is the best practice here? Answer This can be done by cloning to a new directory, then moving the .git directory into your existing directory. If your existing directory is named "…
How to do a GitHub pull request
2023-01-23
Question How do I create and/or send a pull request to another repository hosted on GitHub? Answer (In addition to the official "GitHub Help 'Using pull requests' page", see also "Forking vs. Branching in GitHub", "What is the difference between origin and upstream in GitHub") Couple tips on pull-requests: Assuming that you have first forked a repo, here is what you should do in that fork that you own: create a branch: isolate your modifications in a branch.…
Should you commit .gitignore into the Git repos?
2023-01-23
Question Do you think it is a good practice to commit .gitignore into a Git repo? Some people don't like it, but I think it is good as you can track the file's history. Isn't it? Answer Normally yes, .gitignore is useful for everyone who wants to work with the repository. On occasion you'll want to ignore more private things (maybe you often create LOG or something. In those cases you probably don't want to force that on anyone else.…
Where is git.exe located?
2023-01-23
Question I have PyCharm and I am looking around trying to find git.exe to set it up with my repo. What is the PATH to git.exe? Answer If you're using GitHub for Windows, git.exe may not be in your PATH, but you may find it in a location like: C:\Users\<username>\AppData\Local\GitHub\PortableGit_<numbersandletters>\bin\git.exe That's the situation for me, in Windows 7 + version 1.0 of GitHub for Windows. In Windows 10 it appears to be in:…
How to list all tags that contain a commit?
2023-01-22
Question This question is similar to How to list all tags pointing to a specific commit in git, but with one difference: I wish to search for all tags that contain a specific commit within the tree of each tag, not specifically the files marked in the tag itself (in this case, only the Makefile change has been tagged). Answer git tag --contains <commit>