echo "# sample_git_tweak" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:nipunsadvilkar/sample_git_tweak.git
git push -u origin master
Create repository in Github or any other repository hub website and use its ssh/HTTP link below.
git remote add origin git@github.com:nipunsadvilkar/sample_git_tweak.git
git push -u origin master
The push command tells Git where to put our commits when we're ready, and boy we're ready. So let's push our local changes to our origin repo (on GitHub).
The name of our remote is origin and the default local branch name is master. The -u tells Git to remember the parameters, so that next time we can simply run git push and Git will know what to do. Go ahead and push it!
git push -u origin master
Let's pretend some time has passed. We've invited other people to our GitHub project who have pulled your changes, made their own commits, and pushed them.
We can check for changes on our GitHub repository and pull down any new changes by running:
git pull origin master
Uh oh, looks like there have been some additions and changes to the octocat family. Let's take a look at what is different from our last commit by using the git diff command.
In this case we want the diff of our most recent commit, which we can refer to using the HEAD pointer.
git diff HEAD
In case you remove file with
$git rm filename
you can revert it by using command:
$git reset --hard HEAD
hard reset to previous branches instead of doing revert many times, use:
git checkout [revision] .
where [revision] is the commit hash (for example: 12345678901234567890123456789012345678ab).
Don't forget the . at the end, very important. This will apply changes to the whole tree. Then commit and you should be good.
You can undo this by
git reset --hard;
that will delete all modifications from the working directory and staging area.
Refer: http://stackoverflow.com/questions/2007662/rollback-to-an-old-git-commit-in-a-public-repo