When would you use the different git merge strategies?
2023-05-22
Question From the man page on git-merge, there are a number of merge strategies you can use. resolve - This can only resolve two heads (i.e. the current branch and another branch you pulled from) using 3-way merge algorithm. It tries to carefully detect criss-cross merge ambiguities and is considered generally safe and fast. recursive - This can only resolve two heads using 3-way merge algorithm. When there are more than one common ancestors that can be used for 3-way merge, it creates a merged tree of the common ancestors and uses that as the reference tree for the 3-way merge.…
Multiple GitHub accounts on the same computer?
2023-05-19
Question Trying to work on both my actual "work" repos, and my repos on GitHub, from my computer. The work account was set up first, and everything works flawlessly. My account, however, cannot seem to push to my repo, which is set up under a different account/email. I've tried copying my work key up to my account, but that throws an error because of course a key can only be attached to one account.…
Another Git process seems to be running in this repository
2023-05-18
Question I'm trying to learn how to use Git and have created a small project with an HTML, CSS, and JavaScript file. I made a branch from my basically empty project and then made some changes to my code. I tried staging the changes, but I get the following error message: Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again.…
Git: How to solve Permission denied (publickey) error when using Git?
2023-05-18
Question I'm on Mac Snow Leopard and I just installed git. I just tried git clone git@thechaw.com:cakebook.git but that gives me this error: Initialized empty Git repository in `/Users/username/Documents/cakebook/.git/` Permission denied (publickey). fatal: The remote end hung up unexpectedly What am I missing? I've also tried doing ssh-keygen with no passphase but still same error. Answer If the user has not generated a ssh public/private key pair set before This info is working on theChaw but can be applied to all other git repositories which support SSH pubkey authentications.…
What does each of the [y,n,q,a,d,/,K,j,J,g,e,?] stand for in context of git -p
2023-05-18
Question When using -p mode of git add -p or git stash -p what does each of the letters stand for? I'm guessing y is yes and n is no. What are the rest? [y,n,q,a,d,/,K,j,J,g,e,?] Answer The -p mode means patch, the help for which is hard-ish to find, but if you check git add --help you'll find the following patch This lets you choose one path out of a status like selection.…
Count number of lines in a git repository
2023-05-17
Question How would I count the total number of lines present in all the files in a git repository? git ls-files gives me a list of files tracked by git. I'm looking for a command to cat all those files. Something like git ls-files | [cat all these files] | wc -l Answer xargs will let you cat all the files together before passing them to wc, like you asked:…
What is the difference between git clone and checkout?
2023-05-17
Question What is the difference between git clone and git checkout? Answer The man page for checkout: http://git-scm.com/docs/git-checkout The man page for clone: http://git-scm.com/docs/git-clone To sum it up, clone is for fetching repositories you don't have, checkout is for switching between branches in a repository you already have. Note: for those who have a SVN/CVS background and new to Git, the equivalent of git clone in SVN/CVS is checkout. The same wording of different terms is often confusing.…