User:Jayprakash12345/Mediawiki/Git
Appearance
From mediawiki.org
(Redirected from User:Jayprakash12345/Mediawiki 2018/Git)
Create Account
[edit]-
Step: 1 Goto https://wikitech.wikimedia.org And Click on "Create Account". Now Fill ther Form. One thing You will Ask What is Instance shell account name? So Instance shell account name is required for assign you a unique name in Gerrit repo. You will understand it later. In other Word Instance shell account name is your Gerrit Username.
-
Step: 2 Now You will receive Successful Account Creation Message.
-
Step: 3 Goto https://gerrit.wikimedia.org And CLick on Sign In at upper corner. And Sign In by Username And password, Which you make on wikitech.
-
Step: 4 Your name show at upper corner after successfully Login.
Install Git and Git-review
[edit]In Linux
[edit]-
Step-1:- First of all, Open the Terminal. If You are using Debian/Ubuntu Based Linux then For opening the Terminal by Ctrl + Alt + T. And then For Installing Git type
sudo apt-get install git
And Press the Enter. -
Step-2:-Now your pc will demand the password. Enter the Operating System Password. And Hit the Enter. As you can see New message will come "Do you want to continue? [Y/n]". Pres "y" and Hit the Enter Key. The Process of installing will start.
-
Step-3:-After the Installation of Git. You need to Configure Git. #First, Configure Your Email By
git config --global user.email "your_email@youremail.com"
#Second, Configure Your Username bygit config --global user.name "example"
. And Finally Typegit config -l
And press Enter Key to confirm the things were done Succesfully. -
Step-4:-Now You need to check that SSH key present on your local machine or not. For This Purpose Type
ls ~/.ssh
And Hit the Enter. If you see a file called id_rsa.pub here. the Skip Next Step Step-5, Where We Generate id_rsa.pub file. -
Step-5:- To generate a new SSH key. Type
ssh-keygen -t rsa -C "your_email@youremail.com"
And Hit the Enter. After that, We want the default settings so when asked to enter a file in which to save the key, just press enter. Then Terminal will demand "passphrases". passphrases are just like a password. It will use when You clone the Repo. So type memorable passphrase and press enter. Now Key will Successfully Generate. -
Step-6:- Now, Open the https://gerrit.wikimedia.org and get the login by your Wikitech Account. Now you can see Your Name at Uppar-Right Corner. Click on that and then Setting.
-
Step-7:- Click on SSH Public Keys, Now the Time is to upload Your SSH key in Gerrit. For this Propose you need to go to Terminal and type
cat ~/.ssh/id_rsa.pub
and press the Enter. Now you can see your lengthy SSH key in your Terminal. Copy the text ssh-rsa............your_email@youremail.com and Paste Into Gerrit SSH Public Keys. And then Click on Add. Now your key has added into Gerrit. -
Step-8:- Now type the
eval `ssh-agent`
and press the Enter. then typessh-add .ssh/id_rsa
and press the Enter. Now We are at this stage where We can make Connection to gerrit.wikimedia.org. For this Purpose, You need to typessh -p 29418 <USERNAME>@gerrit.wikimedia.org
Here <USERNAME> means your Shell Name. The Massege Are you sure you want to continue connecting (yes/no)? will Come, type yes and Press the Enter. Now you have successfully connected over SSH. -
Step-8:- Now to need to Install and Setup git-review for Uploading the Patch. Just go to terminal and Type
sudo apt-get install git-review
and press the Enter. Now your pc will demand the password. Enter the Operating System Password. And Hit the Enter. As you can see New message will come "Do you want to continue? [Y/n]". Pres "y" and Hit the Enter Key. The Process of installing will start. -
Now git-review will Successfully Install.
-
Now this time to Config git-review. Type
git config --global gitreview.remote origin
, press Enter and then typegit config --global gitreview.username <USERNAME>
, Replace <USERNAME> with your Wikitech Username.
Via Git
[edit]In this session, We Will learn How to upload the Patch Via Git.
-
Step 1 Clone the repo from Gerrit. You will find the relevant projects at https://gerrit.wikimedia.org/r/#/admin/projects/. Just find the project by typing and copy git clone command from there. Make sure you are log in.
-
Step 2 Update the repo by
git pull origin master
, if you just clone it, then ignore it. The Repo will already be updated. -
Step 3 Create and checkout the branch by
git checkout -b <BRANCH_NAME> origin/master
, ussally <BRANCH_NAME> will phab task number. -
Step 4 Check current branch, wherein you are working.
-
Step 5 Make changes in code. And see the difference by
git diff
. -
Step 6 Check the status of repo by
git status
. It will tell you which files have modified/Added/Deleted. If you satisfied with the modification just rungit add .
to add all files in staging area. Or you can add them one by one throughgit add <FILENAME>
. -
Step 7 Now time is to commit the changes. Run
git commit
. -
Step 8 Then type the Commit messages. Make sure you write
Bug: TXXXX
. Here TXXXX is the phab task number. Exit from nano editor by Ctrl+O then Ctrl + X. -
Step 9 Now rebase the commit before pushing it to the Gerrit by
git pull --rebase origin master
. -
Step 10 Now push it into the Gerrit. Do that by
git review -R
. Please make sure you have git-review package in your OS. if it is not in there. Install it bysudo pip install git-review
-
Step 11 See the patch on gerrit.wikimedia.org.
You ca use https://gerrit.wikimedia.org/r/#/admin/projects/sandbox project for testing pupose.
Via Publish Edit
[edit]In this session, We Will learn How to upload the Patch Via Gerrit UI.