link for gitlab is : https://gitlab.com
Now, lets go deeper in it...
when yo have your own git account and you have created your project, after creating a project you can easily follow the steps that will be provided below your project just you have created for first time.
After following those steps you will push your project for first time in your git repo,
Now what after it ? what more? i will describe in best way:
Steps to follow:
1. for first time , when your team member want to get your project :
Approach 1:
Go to the directory where you want to put your project and open git bash there and use following command:
git clone https://gitlab.com/...
git clone and after that get the git cloning address from the git and paste that .
| copy clone address shown |
Now you will have a local copy of the project within your distination folder.
Approach 2:
By this approach every thing is done from git bash, or you also can use cmd
- mkdir FolderName
- cd FolderName
- git init
- git remote add origin https://gitlab.com/...
- git pull origin master
2. never work on master branch directly, i.e create your own branch and push that branch to git so you can work on your own branch
for creating branch from command line
git checkout -b new_branch_name
Now you have switched to your own branch , it is the copy of you master branch and you can do code you portion on that branch ,
after completion your day or targeted mission now, its time to push your branch to the git
For that:
git remote add origin https://gitlab.com/...
after using this command now instead of writting whole url every time , simply you can use word origin .
- git add -A
- git commit -m "Commit message"
- git push origin branch_name
branch_name refers to the branch name that you have created earlier ...
now you have pushed your code to the git with new branch with branch name you just created above.
now , its time to merge your work to the master branch :
for that:
Create the merge request and see whether there is any conflict on merging or not , if no conflict then, you are luckey one, just merge you branch
if there is conflict then, nothing to be done from my side, now its your turn to fix those conflict, but no worries git will provide you guideline to manage conflict.
After Successfull merge , now just delete your branch from git , now you are going to clone that master branch and use it again.
Every day workflow:
git remote add origin https://gitlab.com/...
- git pull origin master
- git checkout -b new_branch_name
- git add -A
- git commit -m "Commit message"
- git push origin branch_name
When conflict arrises, i.e 2 commit behinds ... then:
first git pull origin master
- solve the conflict locally on your file
- commit the file to your branch
then merge your branch to the master then it will work fine
No comments:
Post a Comment