I have tried these in Ubuntu but they would be almost similar in all OS'es.
Installing in Ubuntu
apt-get install git-core
You can use them along with SVN too. Use
sudo apt-get install git-svn
Setting up your identity
Sets your intial configuration at a global level. You can use /etc/gitconfig file for making these changes
git config --global user.name " Your Name "
git config --global user.email "someone@domain.com"
git config --global core.editor emacs
git config --global merge.tool meld
git config --global user.email "someone@domain.com"
git config --list
Start with existing github.com
Sign up with github.com and you can start working on these command rightaway.
git clone git://github.com/path/myproject.git
The above url uses git protocol but you can use https if you are using remote repository like github.com Basic commands
git remote add github git@github.com:dddd/dd.git ( Adds the remote url so that you can checkin)
git add . ( Add the files or folder which sets the stage )
git commit -m "commit comments" ( commits them locally )
git push ( pushes into the server)
git diff
git tag
git pull
When you add a file GIT stores them locally (rather STAGES them). Commit will commit them locally. Push will push to the server. Branching and Merging
git branch { branch_name } ( Creates branches )
git merge { branch_name } (Merges files from the mentioned branch
to current branch where you are firing this command)
git rebase { branch_name }
git checkout -b { branch_name } ( creates a branch and checks out.
Helps switching branch too)
git log
git status ( Shows branch names and staged files)
git cherry-pick rev ( For commiting a file to be merged from a
different branch)
The best part of GIT is the git checkout which helps switching branches almost instantaneously. Stashing
Stashing helps in not committing to the repository but still save a copy of the changes you have made and switch to another branch. Get back to this branch and you can use Stash command to get back the changes you didn't commit earlier. List of commands associates are
git stash ( Stores a local copy of the changes without losing
the changes but doesn’t commit)
git stash list
git stash branch {branch_name}
git stash apply
git stash apply --index
git stash drop stash@{0}
No comments :
Post a Comment