A Quick Note on Using Git

In his post I will summarize what I gathered from the Atlassian Git tutorial that had lots of really great examples and explanations. I’ll assume you’ve already configured your Git installation and account, but aren’t sure where to go from there. I’ll also assume you’re using linux.

First you want to create a directory, move into it, and initialize Git.

mkdir newproject
cd newproject
git init

Then you’ll grab some code from GitHub, create a branch, and switch to (checkout) that new branch.

git clone https://github.com/cjohnson318/geostatsmodels
git branch newbranch
git checkout newbranch

Then you’ll edit your code using vim or something, you’ll add and commit new pieces, and then check the status of everything.

git add newthing.py
git commit newthing.py -m "Here are some commit somments"
git status

Next you’ll merge your branch with the master version

git checkout master
git merge newbranch
git branch -d newbranch

Finally, you’ll push everything back to GitHub.

git fetch origin master
git rebase -i origin/master
git push origin master

One thought on “A Quick Note on Using Git”

Leave a Reply

Your email address will not be published. Required fields are marked *