Git install-able files can be download from here. Install Git on your local system.
1. Create new folder in any of your
drive. For example, I created TestRepo.
2. Go to TestRepo folder and run git
bash.
3. Cloning a remote repo.
Command: git clone <URL> <where to clone>
Where
<Url> is remote repository and <where to clone> is local repository
where you will do development.
Run command: git clone
//20.XXX.58.XX/XXXX
4. After successfully clone, you will
have all remote repository files. Our project is in some folder so I
run cd command, if you don’t have
than no need to run cd command.
5. Viewing information about the remote repository.
Command: git remote -v –-> This
commands gives the information about remote repository
: git branch -a --> This commands gives the information
about all local and remote branches.
6. Create a branch according to your
work. For example, I created test_new, this branch created locally, this is not
available on remote repository. Now me or other developer will work on this
branch.
Command: git branch test_new
7. If I will run git branch, this shows
currently I am working on Master branch.
13. Now our local branch “test_new” shold
be visible on remote repository.
14. Now we will merge branch with master. First we will checkout local master
branch.
15. We will pull code from master
repository and will check if any other developer has been checked their code or
not. If we will get as “Already up-to-date” means no other developer commit
their code in master repository.
Command: git pull origin master
or git pull --no-edit origin master
If you use git pull origin master
and if no changes made on central repository than no editor pop will come, if
any changes made on central repository than you will get editor pop, you need
to press shift and : together and write
q. this will exit from editor command.
Or you can use git pull --no-edit
origin master, this command will not pop up editor.
Now you need to merge code with your code if any changes made on central
repository code. After changes need to only commit, this will commit in master
branch.
a. If central repository have no change than you don't required to do anything.
b. If automatic merge failed, you will receive below message than you need to remove conflicts by using "git mergetool".
Click enter and one window will pop up, you need to merge your code , save and close merging tool.
16. After successfully merge. Now
we will check our code is merged with in so far.
17. Above command says, our code is
merged with only local master branch. Now we will merge our branch test_new
with local master branch.
18. If you will run branch merged
command, this will show all branches which has been merged and ready to push
into central repository.
19. We will push our merged code to central
repository. Now updated code available to all developer from central
repository.
Delete
a branch
1. After successfully merge and push updated code
to central repository we don’t need newly created branch.
2. Check once again if your branch has been merged
with master or not. If this shows than you are good to delete newly created
branch.
3. Delete branch locally.
4. Check if branch deleted from local or not. We
have only master branch. But still we have branch in remote location.
5. Delete branch from remote.