This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
version_control [2012/05/29 07:05] naveen created |
version_control [2018/03/24 11:13] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ========Version Control ======== | ||
| + | - Practise the following git excercise | ||
| + | [[ http://try.github.io/levels/1/challenges/1]] | ||
| + | Please do this as team wise. | ||
| + | |||
| + | - Do the following | ||
| + | - Install git in your local machine as root user( use apt-get install ) | ||
| + | - Set your identity(Root required) | ||
| + | - git config --global user.name "yourname" | ||
| + | - git config --global user.email youremailid | ||
| + | - Go to normal user(ctrl+d) or exit from root user | ||
| + | - Create a git folder in your local machine | ||
| + | - mkdir git | ||
| + | - cd git | ||
| + | - Clone the repository to your local machine | ||
| + | - git clone [email protected]:/home/git/camp/team$ team$ ($ represents team no.) | ||
| + | - Change the directory to team$ | ||
| + | - cd team$ | ||
| + | - Create a folder with your name in team$ folder | ||
| + | - Add the folder that you created to git | ||
| + | - git add <folder-name> | ||
| + | - Change the directory to your name-folder that you created | ||
| + | - cd your-name | ||
| + | - Create files that you wish to do and add it to git | ||
| + | - git add <file-name> | ||
| + | - Check the status of the Git repo | ||
| + | - git status | ||
| + | - Commit the changes that you made | ||
| + | - git commit -m "message-you-wish-to-give" | ||
| + | - Check the status | ||
| + | - git status | ||
| + | - To check the log | ||
| + | - git log | ||
| + | - Repeat the above process for each time you create/change the file | ||
| + | - Once you are done with file modifications, then push it to the main git-server | ||
| + | - git push origin master | ||
| + | - Check yourself how git diff, git show, git branch works | ||
| + | |||
| + | **Happy Gitting** | ||
| http://en.wikipedia.org/wiki/Revision_control | http://en.wikipedia.org/wiki/Revision_control | ||
| Line 14: | Line 53: | ||
| Git reference | Git reference | ||
| http://gitref.org/ | http://gitref.org/ | ||
| + | |||
| + | Git commands: | ||
| + | |||
| + | - Why Branching?? | ||
| + | |||
| + | Branching makes the work more efficient as the branch you create doesnt exist | ||
| + | in the remote repo and you can test out new features and bug fixes without breaking | ||
| + | whats already working. | ||
| + | |||
| + | |||
| + | - To create a branch all we need to do is go to the repo(working directory) and then type following command | ||
| + | |||
| + | git branch branchname | ||
| + | |||
| + | then by using the 'git checkout' command you can switch to your branch. | ||
| + | |||
| + | |||
| + | -Working on branches | ||
| + | |||
| + | * git branch (lists all local branches) | ||
| + | |||
| + | * git branch 'branchname' (to create branch) | ||
| + | |||
| + | * git checkout -b 'branchname' (to create a branch n switch to it) | ||
| + | |||
| + | * git branch -d 'branchname' (to delete a branch) | ||
| + | |||
| + | * git branch -v (to list the last commit of each branch) | ||
| + | |||
| + | - Basic Merging : | ||
| + | |||
| + | After working on a branch on a particular issue if you wanna apply those changes to the main file then what you need to do is to checkout to that file using following command | ||
| + | |||
| + | |||
| + | - git checkout 'filename' | ||
| + | |||
| + | and then you can run following command | ||
| + | |||
| + | - git merge 'branchname' | ||
| + | and then use commit command to finalise the changes. | ||
| + | |||
| + | |||
| + | |||
| + | - Merge Commands : | ||
| + | |||
| + | * git branch --merged (to see which branches are already merged into branch you are on) | ||
| + | |||
| + | * git branch --no--merged (to see all branches that contain work you havent yet merged in) | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | -Merging Conflicts : | ||
| + | |||
| + | Whenever same part of the file is changed in two different branches and if those are | ||
| + | merged then GIT wont be able to merge them cleanly. Then that confilct is to be resolved and | ||
| + | then we must execute the above commands. | ||
| + | |||
| + | |||