Basic Git Commands

Some Useful Git Commands

Create local git repository
git init

Add all files to git
git add .

Remove remove file from git (this command doesnt delete your file from disk)
git rm --cached <file path>

Make your first commit
git commit -a -m "<commit message>"

Changing latest commit message
git commit --amend -m "<commit message>"

Setup your remote repo
git remote add <remote name> <remote url>

Push local resources to remote repo
git push -u <remote name> <branch name>

Remove remote:
git remote rm <remote name>

Clone remote repository
git clone <url>


List branches
git branch

Create branch
git branch <branch name>

Switch branch
git checkout <branch name>

Create and switch that branch
git checkout -b <branch name>

Delete branch
git branch -d <branch name>

Delete remote branch
git push <remote name> :<branch name>
Rename branch
git branch -m <old branch name> <new bracnh name>

Add tag
git tag -a v1.0 -m <description message>

Push tag
git push <remote name> <tag name>

Push all tags
git push <remote name> --tags

Delete tag
git tag -d <tag name>

Delete remote tag
git push <remote name> :refs/tags/<tag name>

No comments:

Post a Comment