It was around 3 years back, I was with one of my seniors , I asked him what is github? The answer was it is a website and don’t you mix it with git. Then obvious next question was then what is git. His answer “Git is used for version control” And that is the statement I still remember.
1. In short Git is used for Version Control.
2. Git is a software that is used to maintain repository(your codes) and made it possible for many users to work at the same time.
3. You can revert your code anytime
4. You can work on many branches at the same time (like software for different schools)
5. As the your code(say software ) evolves, you can release new versions from git , maintaining all the information of the previous versions and bugs and issues.
Lets start with basic functionality:
1. Git init:
It is used to initialize a folder as a git repository.
2. Add :
It is used to add the new files that you create.
your_repository_folder>> git add filesname
For adding all files :
your_repository_folder>> git add .
It is just like indexing . This command will index your changes and will not make any change in the main repository. It only changes locally. When you push (which will come further) the changes will be published to the main repository.
your_repository_folder>> git commit -m "comment "
It is for making permanent changes to the source code.You can still revert to previous code
git push --all
I will suggest this –all
5.Pull: Fetch from and merge with another repository or a local branch
** before using anything like git pull –rebase please please take a look what harms it can do.
It is used to clone the git repository at any folder for making changes. It makes a new fork and only admin can allow to make the modification in the main Branch.
git clone repository_location your_folder_location
These are Basic Operations that you must know if you are in software industry.
Now an example to show how to make a local repository
First you need to create a bare repository on H:. With git you usually name your bare repository with .git, so projectname.git in this case:
>> cd \Projects\ mkdir projectname.git cd projectname.git git init --bare
When this is done you change to c to create your repository:
>> cd \Users\xxx\AptanaProjects
\projectname git init git add . git commit -m "First commit"
After this you need to setup the bare repo on h: as the remote repository so you can push up the code you just commited to the repo on c.
>> git remote add origin H:\Projects\projectname.g
it git push origin master
Now, someone else can clone from H: to get your changes, and their repos will automatically be setup with the repo on H: as their origin.
Here are Few Websites that provide free git hosting:
Github: making repository is free but code is visible to others. there are payment method also. (very famous in open source)
Bitbucket: Free private hosting upto 5 members i thinks.
Gitlab: All free I guess.
Thats all for today.
I will suggest to make a git repository for all your c programs . You will learn how to use git .
[…] You can create project now and host code. Also you can create users groups manage permissions and many more. You are totally ready to explore what all you can do with this local hosted version of gitlab. You can read below articles to get more use to gitlab. More about git. […]