Git Sophisticated Commands
- Compare two branches: branch_1 and branch_2:
git diff branch_1…branch_2
- Merge specified files of one branch(e.g. branch_name) into current branch:
git checkout branch_name ./src/…/file1 ./src/…/file2 ./src/…/file3
- Change the committed comments:
git commit --amend
-
Reset and delete the remote URL:
git remote set-url origin git://new.url.here git remote remove origin
-
Clone a single branch:
git clone -b <branch> <remote_repo> git clone -b my-branch git@github.com:user/myproject.git
-
Ignore history after one commit and preserve changes locally:
git reset <commit>