Configuration
Configure user name and email
git config -global user.name “SHAAN”
git config -global user.email shaan@gmail.com
Create new Local git repo
git init
Connect your local repository to a remote server (First time)
git remote add origin <server>
List all configured remote repo
git remote -v
Operations
Checkout a repo
git clone /path/to/repository
git clone username@host:/path/to/repository
List changed files at your side
git status
git add <filename>git add *
Commit changes to head of the local repo
git commit -m “Commit message”
Commit all changes (to local repo)
git commit -a
Push changes to master branch of Remote repo
git push origin master
Branches
List all branches
git branch
Create new branch and switch to it
git checkout -b <branchname>
Switch to other branch
git checkout <branchname>
Delete branch
git branch -d <branchname>
Push branch to remote repo
git push —all origin
Delete a branch from remote repo
git push origin :<branchname>
Fetch the changes from remote repo
git pull
Merge a different branch in your branch
git merge <branchname>
Tagging
Create a tag
git tag 1.0.0 <commitID>
Push all tags to remote repo
git push —tags origin
Revert back the local changes
git checkout — <filename>
No comments:
Post a Comment
Note: only a member of this blog may post a comment.