Git
Merge two Git repositories
https://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories
Link local repo to remote
git remote add origin <link_to_remote_repo>
For example,
git remote add origin git@github.com:vutang/test_git_repo.git
All remote repo can be listed by using:
git remote -v
The results look like:
origin git@github.com:vutang/test_git_repo.git (fetch)
origin git@github.com:vutang/test_git_repo.git (push)
Branches
When a first commit is commited by git commit -m "mesage"
. A master branch is created.
git push origin master
will push your local branch to remote.
- Create a new local branch:
git branch <branch-name>
. - Switch to new branch:
git checkout <branch-name>
- Push to remote repo:
git push <remote-name> <branch-name>
- Pull a remote branch to local:
git checkout <branch-name>
Before,
* master
remotes/origin/HEAD -> origin/master
remotes/origin/branch1
remotes/origin/master
After,
* branch1
master
remotes/origin/HEAD -> origin/master
remotes/origin/branch1
remotes/origin/master
-
merge branches
git merge <source> <dest>
Commit
- Revert a commit in a branch:
git reset --hard <commit-hash-value>