Hi guys, I wanted to share with you how I do version control locally.
Git can help you track the changes on your project. At anytime you can go back and check out a previous version. It allows you to create new branches of your app so you can try out new things, and if you don't like how the new features turned out, you don't have to commit those changes to the master branch.
First install Git on your computer. Create a project folder. Open Git Bash, type the path to the project folder. (I'm sure there are other ways to do it, this is just how I like to do it)
$ cd Desktop/tutorial/
- To initialize an empty Git repo in that folder
$ git init
- Create a file in the repo
$ touch index.html
- Add a file that should be tracked
$ git add index.html
You can also add multiple files, just type
$ git add .
And it will start tracking all the files in the folder.
- To check the files in the folder
$ ls -a
- Check the status of the files in the repo. To see which files have been modified
$ git status
- Commit the changes
$ git commit-m "Commit message"
- To see all the commits(previous versions of the app).
$ git log
You'll see something like this
commit f65881c0e1a7866b15da23576ccf176a184561234 (HEAD -> master)
Date: Date of the commit
You see this long "number"? It's called hash
- To go back to a previous version type
$ git checkout f65881c0e1a7866b15da23576ccf176a184561234
- Now if we want to create a new branch to see how pink background would look like in our app. We can just create a new branch.
$ git branch pinkbg
- Switch to the pinkbg branch and start coding
$ git checkout pinkbg
- See all the branches
$ git branch
- Merge branch with master
$ git merge pinkbg