Tuesday, December 8, 2015

Using Git

A long time ago, I created a program to simulate a simple MIPS 5 stage pipeline. This was done as a mini project in my undergraduate days and was implemented using C++, flex and bison. The project included
  1. the 5 stage pipeline simulator
  2. a framework for simulating caches
  3. an assembler for MIPS (which is why flex and bison)
  4. a very minimal terminal to interact with the simulated machine
Recently, I decided to try put up the project on github.com maybe, and even develop it either into a product, or an educational application. (A part of me would also like to develop a homegrown board - like the arduino - to match the simulator, but that might be too much to try).

So, on that note, I decided to try and learn git. (I use SVN, so the concepts are all pretty familiar to me.) Found this online tutorial: https://www.youtube.com/watch?v=Kp5BSBoOw8k
 This blog post is just my notes from the tutorial.

1. Creating a git repository in a folder
git init
2. See the status
git status
3. Add files / content to git
git add [filename]
or
git add .   // to add everything in the current directory
4. Set user name and email
git config --global user.name "[user's name]" 
git config --global user.email "[email]"
5. Commit changes
git commit
or
git commit -m "[change comment]"
6. Clone another repository
git clone [path]
or
git clone https://github.com/[username]/[repository].git
7. pull changes from the source you cloned from
git pull
8. push commits to the source you cloned from
git push
9. if you have a local repository, specify a remote repository as origin
git remote add origin https://github.com/[username]/[repository].git
10. Create a branch
git branch [branchname]
11. List all branches
git branch
or
git branch -v
12. Switch to branch
git checkout [branchname]
or if you want to create and switch simultaneously
git checkout -b [branchname]
13. Push local branch to remote origin
git push -u origin [branchname]
14. reintegrating branches
To reintegrate, you first switch to master
git checkout master
then merge the branch onto master
git merge [branchname]
finally push changes if needed
git push
15. Delete a branch
git branch -d [branchname]
To delete on origin (Note below that  branchname is prefixed with a colon)
git push origin :[branchname]
16. Show log
git log
17. Tag a point in history as important
git tag -a [comment]
18. Any folder may contain a file named .gitignore which lists out one filename to ignore per line. The filenames listed can be unix filename regular expressions such as *.o.

Another reference: http://gitref.org/branching/

.

No comments: