Make the current Git branch a master branch

The problem with the other two answers is that the new master doesn’t have the old master as an ancestor, so when you push it, everyone else will get messed up. This is what you want to do: git checkout better_branch git merge –strategy=ours master # keep the content of this branch, but record a … Read more

How to compare files from two different branches

git diff can show you the difference between two commits: git diff mybranch master — myfile.cs Or, equivalently: git diff mybranch..master — myfile.cs Note you must specify the relative path to the file. So if the file were in the src directory, you’d say src/myfile.cs instead of myfile.cs. Using the latter syntax, if either side … Read more

How to replace master branch in Git, entirely, from another branch? [duplicate]

You should be able to use the “ours” merge strategy to overwrite master with seotweaks like this: git checkout seotweaks git merge -s ours master git checkout master git merge seotweaks The result should be your master is now essentially seotweaks. (-s ours is short for –strategy=ours) From the docs about the ‘ours’ strategy: This … Read more

How do you merge two Git repositories?

If you want to merge project-a into project-b: cd path/to/project-b git remote add project-a /path/to/project-a git fetch project-a –tags git merge –allow-unrelated-histories project-a/master # or whichever branch you want to merge git remote remove project-a Taken from: git merge different repositories? This method worked pretty well for me, it’s shorter and in my opinion a … Read more

Remove file from latest commit

I think other answers here are wrong, because this is a question of moving the mistakenly committed files back to the staging area from the previous commit, without cancelling the changes done to them. This can be done like Paritosh Singh suggested: git reset –soft HEAD^ or git reset –soft HEAD~1 Then reset the unwanted … Read more

Is there a way to cache https credentials for pushing commits?

Since Git 1.7.9 (released 2012), there is a neat mechanism in Git to avoid having to type your password all the time for HTTP / HTTPS, called credential helpers. You can just use one of the following credential helpers: git config –global credential.helper cache The credential.helper cache value tells Git to keep your password cached … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)