Git Push Error: insufficient permission for adding an object to repository database
2022-03-07
Question When I try to push to a shared git remote, I get the following error: insufficient permission for adding an object to repository database Then I read about a fix here: Fix This worked for the next push, since all of the files were of the correct group, but the next time someone pushed up a change it made a new item in the objects folder that had their default group as the group.…
How do I copy a version of a single file from one Git branch to another?
2022-03-06
Question I've got two branches that are fully merged together. However, after the merge is done, I realise that one file has been messed up by the merge (someone else did an auto-format, gah), and it would just be easier to change to the new version in the other branch, and then reinsert my one line change after bringing it over into my branch. So what's the easiest way in Git to do this?…
How do I get git to default to ssh and not https for new repositories
2022-03-06
Question These days when I create a new repository on GitHub on the setup page I get: git remote add origin https://github.com/nikhilbhardwaj/abc.git git push -u origin master And whenever I have to push a commit I need to enter my GitHub username and password. I can manually change that to git@github.com:nikhilbhardwaj/abc.git in the .git/config. I find this quite irritating - is there some way I can configure git to use SSH by default?…
How to compare a local Git branch with its remote branch
2022-03-06
Question How can I see the diff between a local branch and a remote branch? Answer git diff <local branch> <remote>/<remote branch> For example, git diff main origin/main, or git diff featureA origin/next Of course to have said remote-tracking branch you need to git fetch first; and you need it to have up-to-date information about branches in the remote repository.
Should composer.lock be committed to version control?
2022-03-06
Question I'm a little confused with composer.lock used in an application with a repository. I saw many people saying that we should not .gitignore composer.lock from the repository. If I update my libraries in my dev environment, I will have a new composer.lock but I will not be able to update them into production, will I ? Won't it generate conflicts on this file ? Answer If you update your libs, you want to commit the lockfile too.…
Pull a certain branch from the remote server
2022-03-05
Question Say that someone created a branch xyz. How do I pull the branch xyz from the remote server (e.g. GitHub) and merge it into an existing branch xyz in my local repo? The answer to Push branches to Git gives me the error "! [rejected]" and mentions "non fast forward". Answer But I get an error "! [rejected]" and something about "non fast forward" That's because Git can't merge the changes from the branches into your current master.…
Git merge errors
2022-03-04
Question I have a git branch called 9-sign-in-out with perfectly working code, and I want to turn it into the master. I'm currently on the master branch. $ git branch 9-sign-in-out * master I'm trying to switch to 9-sign-in-out branch, but it doesn't allow me to: $ git checkout 9-sign-in-out app/helpers/application_helper.rb: needs merge config/routes.rb: needs merge error: you need to resolve your current index first Any idea how can I ignore all the master branch errors and turn the 9-sign-in-out branch into the master?…