Skip to content

Instantly share code, notes, and snippets.

@fsodogandji
Last active January 1, 2016 07:29
Show Gist options
  • Select an option

  • Save fsodogandji/8111885 to your computer and use it in GitHub Desktop.

Select an option

Save fsodogandji/8111885 to your computer and use it in GitHub Desktop.
Install the last version ogf git

####Install git with git mainteners ppa

sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
Enabling colors in git command-line interface
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

Showing which files have changed between git branches

git diff --name-status master..my_branch

What's the simplest way to git a list of conflicted files after a merge ?

git diff --name-only --diff-filter=U

or

git ls-files -u

Rollback file to much earlier version using Git

git reset <commit hash> <filename>

git merge dry-run

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment