To make a directory part of git, go to the directory and run command
git init
To add this directory do
git add .
To see list of files that are git
git ls-files
To remove a file from git repository
git rm filename
To see all your commit messages in git
git log
To see log messages in one line
git log --pretty=oneline
To limit the number of commit messages to 30 and only see commits till yesterday - 30 days
git log -n 30 --since="1 month ago" --until=yesterday --author="apsingh"
git log -n 20 --pretty=oneline --since="-5 hours"To see which git branch you are working on
git branch --color
To create a branch
git branch human
To start working on a branch or checkout a branch
git checkout human
To create a brach and switch to it
git checkout -b human
To see diff between 2 branches
git diff master human
To delete a branch
git branch -d human
To merge a branch, say human back to master
git co master
git merge human
In case of conflicts during a merge process, you can abort them
git merge --abort
To revert the merge you just made
git reset --hard ORIG_HEAD
To rebase a branch changes made in master, checkout the branch you want to rebase
git rebase master
In case a merge of a branch to master fails then command
git show :1:filename
shows common ancestor; command
git show :2:filename
shows HEAD version (contents of the file in master); command
git show :3:filename
shows MERGE_HEAD version (contents of the file in the branch)
To checkout directry from remote server to your local directory
git clone git@remoteServer:/var/git/tmp
Now to synchronize to remote server
git push
To push to remote server "laptop", branch "dog"
git push laptop dog
To push a branch to origin server
git push origin dog
To update local from remote server
git pull
To create a tracking branch (for easy push and pull)
git branch --track fish origin/fish
To create a tracking branch manually add the the following lines to .git/config
[branch "fish"]
remote = origin
merge = refs/head/fish
To ignore files, in the project base directory, create a file
vi .gitignore
and lines like
*.log
db/schema.rb
db/schema.sql



