git init //create a new repository clone with HTTPS //git clone <git_url> git clone & checkout to your own desired branch //git clone <git_url> my-own-branch git clone username@host:/path/to/repository //When clone with remote server git clone -b <git_url> --single-branch //Clone and switch new branch git checkout -b <feature_name> //Create and checkout to a new branch "feature_name" git checkout master //Checkout to master git branch -d <feature_name> //Delete the "feature_name" branch git branch -d branch1 branch2 branch3 branch4 //Delete multiple branches at a time git branch -u origin/mybranch //Delete local branch git branch -m [<old-branch-name>] <new-branch-name> //Rebases 'feature' to 'master' and merges it in to master git add <filename> //To add files git add . //To add all unstage files git add <yourfolder/filename> //To add folder to repository git commit -m "Commit message" //Now the file is committed to the HEAD, but not in your remote repository yet. git commit -am "my commit message" //To stage and commit with message git push origin master //pushing changes - Your changes are now in the HEAD of your local working copy. To send those changes to your remote git remote add origin <server> //If you have not cloned an existing repository and want to connect your repository to a remote server, you need to add it with - Now you are able to push your changes to the selected remote server git pull //Update local repository to latest commit. git merge <branch> //Merge another branch into your active branch. git commit -v --amend //See commit history for just the current branch git branch -a //Get only remote branches git stash -- //remove unwanted changes git stash save //Saving current state of unstaged changes to tracked files git stash --all git stash save --all //Show list of all saved stashes git ls-files -t //Show all untracked files git ls-files --others //Show all ignored files git clean -n //Forcefully remove untracked files git clean -f //Forcefully remove untracked directory git clean -X -f //Restore deleted file. git config --list //Make git case sensitive. git checkout --orphan <branch_name> //Extract file from another branch. git push -f <remote-name> <branch-name> //Adding remote name git diff //diff of what is changed but not staged git log //show all commits in the current branch’s history git help gc //manual housekeeping
git add . git add -AAdd all files to index/commit
git statusReview your changes
git pullGet latest version
git commit -am "my commit message"
To stage and commit with message