Git Basics.txt - Notepad

Git Basics

Git is an open source version control system.
After installing Git your first step will be to create your Git username:
git config --global "insert_name"
git config --global

Create a directory and cd to it. Clone your intended repo into this directory with:
git clone ssh://git@bitbucket:22/repo.git

If you accidently cloned the repo using HTTPS rather than SSH (or vice-versa), you can change this using:
git remote set-url origin https://git@bitbucket:443/repo.git

When running GIT commands make sure that your current working directory is where you mounted the repo that you want to work on. After mounting the repo, you will need to checkout the appropriate branch that you are working on. To list available branches in the repo type:
git branch

To checkout the branch that you want to work on type:
git checkout_branchname

The "git status" command will give you an overview of any outstanding adds or commits you have in the pipeline. After making a change to an existing file or creating a new file you can add the change using the add parameter:
git add file.txt

You can then commit this change using the commit switch. Make sure you include a comment briefly saying what you have done:
git commit file.txt -m "comment"

Finally to push these changes back up to Bitbucket type:
git push

If you wanted to confirm which repo you were connected to prior to the push type:
git remote -v

To pull down the latest changes from the repo use:
git fetch

To pull down the latest changes from ther repo and merge them into your local repo type:
git pull

To show a history of your git activity type:
git log -a

More on Branches
Branches allows each developer to branch out from the original code base and isolate their work from others. Another good thing about branches is that they help Git to easily merge the versions later on. To create a branch type:
git branch new_branch_name

To remove a branch type:
git branch -d branch_name