####Install git with git mainteners ppa
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
git config color.ui true
####Rename a local repository according the remote/origin
git remote set-url origin git@github.com.com:my_repo/my_project.git
####I have two branches A and B and, I want to merge branch A's single file with Branch B's corresponding file
I have two branches A and B with the same files but a different programming interface in some files. Thus, I need to merge just file f of branch B into file f of branch A.
The first command switches into branch A, into where I want to merge B's version of the file f. The second command patches the file f with f of HEAD of B. You may even accept/discard single parts of the patch. Instead of B you can specify any commit here, it does not have to be HEAD.
git checkout A
git checkout --patch B f
git diff --name-status master..my_branch
git diff --name-only --diff-filter=U
or
git ls-files -u
git reset <commit hash> <filename>
As noted previously, pass in the --no-commit flag, but to avoid a fast-forward commit, also pass in --no-ff, like so:
$ git merge --no-commit --no-ff $BRANCH