Useful GIT Commands
Initiate Git
git init
Set configuration values
git config — global user.name your name
git config — global user.email your email
Check current status of Git
git status
Add single file in Git
git add filename
Add all file changes to the staging area
git add .
Add all modified / created files in Git
git add *
Check the unstaged changed
git diff
Remove all deleted files from Git repository
git ls-files –deleted -z | xargs -0 git rm
Remove single file from Git repository
git rm filename
Commit
git commit -m “Your comments”
List the commit history
git log
Check the meta data and content changes of the commit
git show commit-hash
List all local branches
git branch
Create a new branch
git branch branch-name
Rename the current branch
git branch -m new-branch-name
Delete a branch
git branch -d branch-name
Switch to another branch
git checkout branch-name
Merge specified branch to the current branch
git merge branch-name
Connect to a remote repository
git remote add name repository-url
Push
git push remote branch
Or
git push -u origin master
Download the content from remote repository
git pull repository-url
Cleanup unnecessary files and optimize local repository
git gc
Temporarily remove uncommitted changes and save those for later use
git stash
Reapply previously stashed changes
git stash apply
Comments
Post a Comment