Thursday, March 3, 2011

Fast Version Control with GIT for total beginners [part 2]

Ok in this tutorial we are going to continue to talk about GIT in depth.

Ok now if you know from the first tutorial we use the command git add and then the name of the file which we want to track. But if you want to add all the files in the project you can do it by using this simple command:
git add .

and as you know you can use branches its like a name of the version you want to work for example you can make one branch and call it version 1 then after a month you make a new branch and call it version two.
to switch to a different branch or to master branch you can use the following command:

git checkout [here you need to write the name of the branch you want to switch to]

for example: git checkout version2

so if you have a folder called Web_project and you navigate to it and type in git branch and you will see a tree of your branches, for example if you have two branches it will be like this: 
version1
*version2

the asteriks (*) means that you are currently working on the branch with the name version2, if you want to switch to version1 then you will type
git checkout version1
  
And finally you can work on the version1 or you can switch to version2 the same way.
If you want to transfer all your changes from the branch version2 to version1 (or master branch) then you can do it by using the command:
git merge [the branch that you want to transfer here]
for example while you are on the version1 branch: git merge version2
Now everything you have been working on version2 will be transfered to version1 and they will be identical.
You can use this for a master branch which you know its stable and doesnt have any bugs and you have another branch where you add more features to it, and then after you finish your job in the branch for more features you test it and if you think its all ok then you merge it to the master or stable version.

[This was was part 2 of GIT for total beginners and there is a lot more what GIT can do! stay tuned for upcoming parts...]

No comments:

Post a Comment