# Getting started with GIT on the Command Line

Coming from an SVN versioning system to GIT has been a long strange trip; at first, SVN commands made more sense, like checkout and update, but then when you think about it, they're backward.

Whereas with Git, I'm noticing it's more like \*nix CLI commands to deal with files, commits, etc.

### Remove a file

```bash
#Note pass -r for recursive to remove folder
#Note pass -f to force removal, you can combine these like -rf
git rm filename
```

### Rename / Move a file

```bash
git mv filename
```

### Add File or Files for Commit

```bash
## Add all files 
git add ./ 

## Add just filenames
git add filename
```

### Commit with message

```bash
git commit -m "Useful message"

# Better commit but know your editor it normally opens VIM, NANO, or whatever you setup as EDITOR 
# in your .bashrc or .zshrc
git commit
```

### Pull From Server

```bash
# Pulls the currently tracked branch
git pull
```

### Change Branch and Pull From Server

```bash
#example git checkout -b < new_branch > origin/< new_branch >
git checkout -b newbranch origin/newbranch
```

### Push to the server, replace master with branch

```bash

    git push origin master
    git push remote branch
```

* Switch branches
    

```bash

    git checkout branchname
```

* Create a tag
    

```bash
      
  git tag tagname
  git push origin :refs/tags/tagname
```

* Push a tag
    

```bash
      
git push --tags
```

* Delete a tag
    

```bash
      
    git tag -d tagname
    git push origin :refs/tags/tagname
```

* Adding Remote Repo
    

```plaintext

     git remote add **alias** **url**
    
    #Example
     git remote add upstream git://github.com/octocat/Spoon-Knife.git
     git fetch upstream
     git merge upstream/develop
```

There's more, but that'll do for this post.

Highly suggest learning git-flow
