October 30, 2015

Git commands simplified


Adding remote branch:

git remote add remote_branch_name remote_branch_url

Ex:
git remote add upstream https://github.com/user/repo.git

Checking remote branches added:

git config -l

Sample:
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
remote.upstream.url=https://github.com/user/repo.git
remote.upstream.fetch=+refs/heads/*:refs/remotes/upstream/*

Pull file from remote:

git fetch remote_branch_name
git merge remote_branch_name/branch_name

Ex: 
git fetch upstream
git fetch upstream/develop

git merge can give merge conflicts, solve the merge conflicts then commit to pass through the merging process.

Push to remote:

git push remote_branch_name branch_name

Ex:
git push upstream develop

Cherry-picking:

git cherry-pick commit_id

Ex:
git cherry-pick 7c5fb9c348c85448e73e7807a7b7f445d1773b9d

git cherry-pick can give merge conflicts, solve the merge conflicts then commit to pass through the cherry-picking process.




0 comments:

Post a Comment