You have not concluded your merge (MERGE_HEAD exists)
2023-06-27
Question I made a branch called 'f' and did a checkout to master. When I tried the git pull command I got this message: You have not concluded your merge (MERGE_HEAD exists). Please, commit your changes before you can merge. When I try the git status, it gave me the following: On branch master # Your branch and 'origin/master' have diverged, # and have 1 and 13 different commit(s) each, respectively.…
List of remotes for a Git repository?
2023-06-25
Question I have a Git repository. This repository has multiple remote repositories (I think). How can I get a list of the remote repositories that belong to said repository? Like git list --remotes or something like that? Answer You can get a list of any configured remote URLs with the command: git remote -v This will give you something like the following: base /home/***/htdocs/base (fetch) base /home/***/htdocs/base (push) origin git@bitbucket.org:*** (fetch) origin git@bitbucket.…
How do I delete a file from a Git repository?
2023-06-24
Question How can I delete "file1.txt" from my repository? Answer Use git rm. If you want to remove the file from the Git repository and the filesystem, use: git rm file1.txt git commit -m "remove file1.txt" But if you want to remove the file only from the Git repository and not remove it from the filesystem, use: git rm --cached file1.txt git commit -m "remove file1.txt" And to push changes to remote repo…
Make the current commit the only (initial) commit in a Git repository?
2023-06-24
Question I currently have a local Git repository, which I push to a Github repository. The local repository has ~10 commits, and the Github repository is a synchronised duplicate of this. What I'd like to do is remove ALL the version history from the local Git repository, so the current contents of the repository appear as the only commit (and therefore older versions of files within the repository are not stored).…
How do I rename a local Git branch?
2023-06-21
Question How do I rename a local branch which has not yet been pushed to a remote repository? Related: Rename master branch for both local and remote Git repositories How do I rename both a Git local and remote branch name? Answer To rename the current branch: git branch -m <newname> To rename a branch while pointed to any branch: git branch -m <oldname> <newname> -m is short for --move.…
How to prune local tracking branches that do not exist on remote anymore?
2023-06-21
Question With git remote prune origin I can remove the local branches that are not on the remote any more. But I also want to remove local branches that were created from those remote branches (a check if they are unmerged would be nice). How can I do this? Answer After pruning, you can get the list of remote branches with git branch -r. The list of branches with their remote tracking branch can be retrieved with git branch -vv.…
SSH Key - Still asking for password and passphrase
2023-06-20
Question I've been somewhat 'putting up' with Github always asking for my username and password when I clone a repository. I want to bypass this step because it is an annoyance within my workflow. I tried setting up an SSH key (which I successfully did) using this guide. https://help.github.com/articles/generating-ssh-keys and I was successful. My problem is that I am still asked for my github password and passphrase when cloning a repository (using SSH).…