Undo git update-index --assume-unchanged
2022-04-05
Question I have run the following command to ignore watching/tracking a particular directory/file: git update-index --assume-unchanged <file> How can I undo this, so that <file> is watched/tracked again? Answer To get undo/show dir's/files that are set to assume-unchanged run this: git update-index --no-assume-unchanged <file> To get a list of dir's/files that are assume-unchanged run this in a unix shell: git ls-files -v | grep '^h' or in a PowerShell: git ls-files -v | Select-String -CaseSensitive '^h'
What is the meaning of git reset --hard origin/master?
2022-04-04
Question I did a git pull and got an error: The following working tree files would be overwritten by merge... Please move or remove them before you can merge. To resolve this I did the following: git fetch git reset --hard origin/master Now when I do git pull, it says everything up to date. I want to know what exactly happens when I run these commands. I know git fetch fetches the changes from the remote repo without merging them into my local repo.…
How to convert a normal Git repository to a bare one?
2022-04-03
Question How can I convert a 'normal' Git repository to a bare one? The main difference seems to be: in the normal Git repository, you have a .git folder inside the repository containing all relevant data and all other files making up your working copy in a bare Git repository, there is no working copy and the folder (let's call it repo.git) contains the actual repository data Answer In short: replace the contents of repo with the contents of repo/.…
How to use private Github repo as npm dependency
2022-04-03
Question How do I list a private Github repo as a "dependency" in package.json? I tried npm's Github URLs syntaxes like ryanve/example, but doing npm install in the package folder gives "could not install" errors for the private dependencies. Is there a special syntax (or some other mechanism) for depending on private repos? Answer It can be done via https and oauth or ssh. https and oauth: create an access token that has "…
Deploy a project using Git push
2022-04-02
Question Is it possible to deploy a website using git push? I have a hunch it has something to do with using git hooks to perform a git reset --hard on the server side, but how would I go about accomplishing this? Answer I found this script on this site and it seems to work quite well. Copy over your .git directory to your web server On your local copy, modify your .…
Find out which remote branch a local branch is tracking
2022-04-01
Question See also: How can I see which Git branches are tracking which remote / upstream branch? How can I find out which remote branch a local branch is tracking? Do I need to parse git config output, or is there a command that would do this for me? Answer Here is a command that gives you all tracking branches (configured for 'pull'), see: $ git branch -vv main aaf02f0 [main/master: ahead 25] Some other commit * master add0a03 [jdsumsion/master] Some commit You have to wade through the SHA and any long-wrapping commit messages, but it's quick to type and I get the tracking branches aligned vertically in the 3rd column.…
merge one local branch into another local branch
2022-04-01
Question I have multiple branches which are branched off the master (each in a separate subdirectory). Branch1: new development, not yet completely finished Branch2: hotfix for a problem, but still under test Branch3: mess around branch, which I will not restore Before testing of the hotfix is finished I would like to have the code already available in Branch1, so I can continue developing with the fix in place. (But since my experience with git is not that much I first started to play around with merge in a 3rd branch, especially created to mess around in, before I mess up either Branch1 or Branch2)…