$ git clone ssh://bjohns@gerrit.********.com:29418/dhg/myharmony
$ scp -p -P 29418 bjohns@gerrit.********.com:hooks/commit-msg .git/hooks
$ git add win/Assemblies/Newtonsoft.Json.dll -f (-f pipe adds excluded files)
$ git commit -m "[PRO-187] - Chrome Browser [Mh App] In windows 8, the Mh app is not launched."
$ git status
$ git push origin HEAD:refs/for/master (Master here is the remote master)
To clone a particular branch alone:
$ git clone -b my-branch https://git@github.com/username/myproject.git
$ git clone -b 2.4 --single-branch https://github.com/Itseez/opencv.git opencv-2.4 (With Git 1.7.10 and later, add --single-branch to prevent fetching of all branches.
Example, with OpenCV 2.4 branch)
To get the latest(warning if overwrite chances and don't care if any untracked files present)
git pull
Force overwrite local files from remote repository:
$ git fetch --all
Revert changes made to a file:
git checkout
To move to a particular branch:
git checkout
Undo local changes:
git checkout .
Force overwrite with delete of untracked files in GIT:
git clean -f -d
$ git reset --hard HEAD
$ git reset --hard origin/master
git pull
Find changes that happened in a file:
git diff app/cefclient/cefclient.rc
Merging of changes from One branch to Another:
You have made somme changes in "dev" branch that you want to merge to "master" branch.
And you are in master branch right now.
$ git merge dev
Undoing Staging(Remove the file from Index):
git reset => unstage all files staged.
git reset => to unstage a particular file
Undoing a Commit:
git reset --hard HEAD~1 => nuke commit and never see it again.
git reset HEAD~1 => undo the commit but keep your changes for a bit of editing before you do a better commit.
git reset --soft HEAD~1 => undo your commit but leave your files and your index. Meaning we dont need to "git add" again.
Create new Local Branch:
git checkout -b development.
Now setting upstream for the development branch:
git branch --set-upstream-to origin/development
Geting latest of a particular file:
$ git checkout origin/master
git pull equivalent to git fetch and git merge.
Change Origin URL:
git remote set-url origin git://new.url.here
Deleting a remote branch:
git push origin --delete # Git version 1.7.0 or newer
git push origin : # Git versions older than 1.7.0
Deleting a local branch:
git branch --delete
git branch -d # Shorter version
git branch -D # Force delete un-merged branches
Deleting a local remote-tracking branch:
git branch --delete --remotes /
git branch -dr / # Shorter
git fetch --prune # Delete multiple obsolete tracking branches
git fetch -p # Shorter
Revert commit of a particular file:
If you want to revert to the commit before c5f567, append ~1 (works with any number):
git checkout c5f567~1 -- lib/util.js
Merge from one remote branch(node_cluster_support) to another remote branch(master) was not working, using BitBucket.
So i merged the changes from remote branch(node_cluster_support) to local(master branch).
>git merge --no-ff -m "Merged in node_cluster_support (pull request #40)" remote/origin/node_cluster_support
>git commit
>git push
This created a merge commit in master, where the node_cluster_support branch merged in with the master.
Reverting a pushed commit:
git revert