SlideShare a Scribd company logo
GIT SETUP ON LINUX WITH BITBUCKET
Step 1. Install git on your PC
→ Open Terminal (ctrl+alt+t)
→ $ sudo apt-get install git
Verify the installation was successful by typing which git at the command line.
→ $ which git
“/usr/bin/git”
Configure your username using the following command.
→ $ git config --global user.name “Git_USER_NAME”
Configure your email address using the following command.
→ $ git config --global user.email “xyz@atlassian.com"
CREATE BITBUCKET REPOSITORY
Step 2. Create a repository on Bit-bucket
To create a repository, follow these steps:
1. Log into Bit-bucket Cloud under your individual account on https://bitbucket.org
2. Click Repositories > Create repository or the Create new repository link.
3. Choose a repository Owner.
This only appears if you are creating under an account with membership in one or more
teams.
4. Enter a Name and Description for your repository.
5. Tick Private if you want to hide your repository from the general public, so that only
selected people can see it.
6. Select the Repository type.
7. Click Create repository.
Step 3. Repository setup
→ $ mkdir /path/to/your/project
→ $ cd /path/to/your/project
→ $ git init
→ $ git add —all
Note: check status of adding file “Green files means chosen for repository”
→ git status
→ $ git remote add origin https://user_name@bitbucket.org/yourRepos.git
This is repositories path
→ $git commit -m 'Initial commit with contributors’
→ $git push -u origin master
Step 4. Create Branch on Bit-bucket
Branch-> Create Branch
Step 5. Clone Repositories
→ $ git clone https://user_name@bitbucket.org/yourRepos.git(remote
address)
Step 6. Using Git to checkout a branch on the command line
→ $ cd gitProject
→ $ git fetch && git checkout yourBranchName (Most Imp to change
branch for fetch & checkout)
→ $git branch -a
* yourBranchName
remotes/origin/HEAD -> origin/master
remotes/origin/abc_dev
remotes/origin/development
remotes/origin/master
remotes/origin/ yourBranchName
(The green colour of text with asterisk before it, showing that your current branch on which
you are.)
Step 7. Changes staging for commit
→ git add <file>( make a .gitignore file and add file names which
you don't want to commit on remote, and add into your project.)
→ git status
green files means added for commit
→ $ git commit -m 'commit message'
→ $ git push origin branch_name(on which you want to push code)
Provide username & password
Step 8. Pull (Daily Basis before push)
→ $ git pull origin branch_name (from which you want to pull)
DIFFERENCE B/W CHECKOUT & CLONE
To sum it up, clone is for fetching repositories you don't have, checkout is for switching
between branches in a repository you already have.
→ $ git checkout branch_name(from where you want to check out)
Once you completed all the above now follow the steps below…
1.Open your project on any editor (for eg. VSCode).
2. Make some changes in your files.
3. On the left menu on VSCode you find an option for git (or shortcut->> ctrl+shift+G). now you
can see the files on which you changed the code, once you ensure the changes, you need to commit
the code, now open terminal ( press ctrl+alt+t).
i. $ cd /path/to/your/project
ii . $ git status
(this will show you modified file names with path)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: app/folderName/file1.js
modified: app/folderName/file2.js
if you added new file in project which you didn't push yet that will show like this Untracked files:
(use "git add < file>..." to include in what will be committed)
newFile.js
iii. $ git add <fileName> (on which changes done -->> git add app/projectFolder/xyz.js ).
check status after add new files
iv. git status (After Adding)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: app/projectFolder/xyz.js
Changes not staged for commit:
(use "git add < file>..." to update what will be committed)
(use "git checkout -- < file>..." to discard changes in working directory)
modified: app/projectFolder/abc.js
Untracked files:
(use "git add < file>..." to include in what will be committed)
newFolder/newFile.js
(you can add files for commit as above)
v. $ git commit -m 'changes in xyz page'
“[your_branch_name ab3caa3] changes in xyz page
1 file changed, 9 insertions(+), 9 deletions(-)”
(you can also check the status of you commit by entering command $ git status )
iv. you can see the logs by entering command
$ git log
(show all commits in the current branch’s history, press 'q' from exit log window)
you can see the difference by entering command
$ git diff
(this will show you the difference between files, diff of what is changed but not staged press 'q'
for exit )
vi. now push your code to remote.
Before push code you can set your bit bucket password into your git config file
run commands
$ gedit .git/config
(This will open your git config file in editor now you can set or change password from here.)
[remote “origin"]
url = https://user_name:password@bitbucket.org/daffodilsoftware/yourRepos.git
fetch = +refs/heads/*:refs/remotes/origin/*
(Note : Do not use '@' in your password it will give error while pushing)
$ git push
(Transmit local branch commits to the remote repository branch)
Message on terminal—>>
“Counting objects: 16, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 483 bytes | 0 bytes/s, done.
Total 5 (delta 4), reused 0 (delta 0)
remote:
remote: Create pull request for yourBranchName:
remote https://bitbucket.org/daffodilsoftware/yourRepos/pull-requests/new?
source=YourBranchName&t=1
remote:
To https://userName:Password@bitbucket.org/daffodilsoftware/yourRepos.git
commit Id YourBranchName - > YourBranchName”
vii. Now its time to merge the code to your master branch or the branch you want
$ git merge [alias]/[branch]
merge a remote branch into your current branch to bring it up to date .
viii. $ git pull
'fetch and merge any commits from the tracking remote branch'
Some other useful command
REWRITE HISTORY
Rewriting branches, updating commits and clearing history
$ git rebase [branch]
apply any commits of current branch ahead of specified one
$ git reset --hard [commit]
clear staging area, rewrite working tree from specified commit
$ git log branchB..branchA
show the commits on branchA that are not on branchB
git show
show any object in Git in human-readable format
git reset [file]
Unstage a file while retaining the changes in working directory.
Remove git initialization
$ rm -rf .git
Display current git configuration
$ cat .git/con g
$ git con g user.name “username”
$ git config user.email “email”

More Related Content

DOCX
anugula2setupbyshubham
DOCX
Angular2RoutingSetupByShubham
PDF
SocketIOSetupWithAngularJSAppByShubham
PPTX
2. auto deploy to tomcat on jenkins
PDF
Angular2 - In Action
PPTX
ADF in action 1.2
PPTX
Magento2 From Setup To Deployment. Automate Everything
PPTX
Ng2 cli
anugula2setupbyshubham
Angular2RoutingSetupByShubham
SocketIOSetupWithAngularJSAppByShubham
2. auto deploy to tomcat on jenkins
Angular2 - In Action
ADF in action 1.2
Magento2 From Setup To Deployment. Automate Everything
Ng2 cli

What's hot (20)

PDF
HotPush with Ionic 2 and CodePush
PPTX
Web components Introduction
PPT
Elefrant [ng-Poznan]
ODP
Satellite Apps around the Cloud: Integrating your infrastructure with JIRA St...
ODP
Chef training Day5
PPT
Auto Build
PDF
Pundit
PDF
Continuous Web Performance Monitoring with Jenkins
PPTX
Laravel Beginners Tutorial 2
KEY
The Joy of Gems: Cooking up Rails Plugins
PPTX
Devise and Rails
PPTX
Play with Alfresco ADF 2.0.0 Angular
PPTX
Bugzilla Installation Process
PPT
sbt 0.10 for beginners?
PDF
Modern Web Developement
PDF
Laravel 101
PDF
React on es6+
PDF
EuroPython 2013 - Python3 TurboGears Training
PDF
Creating a WYSIWYG Editor with React
PDF
Simple restfull app_s
HotPush with Ionic 2 and CodePush
Web components Introduction
Elefrant [ng-Poznan]
Satellite Apps around the Cloud: Integrating your infrastructure with JIRA St...
Chef training Day5
Auto Build
Pundit
Continuous Web Performance Monitoring with Jenkins
Laravel Beginners Tutorial 2
The Joy of Gems: Cooking up Rails Plugins
Devise and Rails
Play with Alfresco ADF 2.0.0 Angular
Bugzilla Installation Process
sbt 0.10 for beginners?
Modern Web Developement
Laravel 101
React on es6+
EuroPython 2013 - Python3 TurboGears Training
Creating a WYSIWYG Editor with React
Simple restfull app_s
Ad

Viewers also liked (7)

PPTX
как люди научились считать 6 класс 1
PDF
They say bad news comes in threes: After Nokia and Blackberry, now it’s HTC’...
PDF
Apple's acquisition of beats what the doctor ordered
PDF
How Ellen Pao became Reddit’s Lee Harvey Oswald
DOC
Cuadrante exámenes de septiembre
PDF
Periscope and Meerkat: Why broadcasters should stop worrying and learn to lov...
PDF
AN INTERVIEW WITH JASON FERNANDES, WHO PROVES THAT DISABILITY OR OTHERWISE, T...
как люди научились считать 6 класс 1
They say bad news comes in threes: After Nokia and Blackberry, now it’s HTC’...
Apple's acquisition of beats what the doctor ordered
How Ellen Pao became Reddit’s Lee Harvey Oswald
Cuadrante exámenes de septiembre
Periscope and Meerkat: Why broadcasters should stop worrying and learn to lov...
AN INTERVIEW WITH JASON FERNANDES, WHO PROVES THAT DISABILITY OR OTHERWISE, T...
Ad

Similar to Git setuplinux (20)

PDF
Bitbucket and Git
PDF
Git Developer Cheatsheet
PPTX
Git presentation, Viktor Pyskunov
PDF
Git for beginners
PPTX
Git and GitHub workshop of GDG on Campus UNSTPB
DOCX
Git github
PPTX
Git and GitHub Workshop of GDG on Campus UNSTPB
PDF
Git & GitHub WorkShop
PPTX
GitHub Event.pptx
PDF
Git and github 101
PPTX
Version control git day02
KEY
Let's Git this Party Started: An Introduction to Git and GitHub
PDF
Git Init (Introduction to Git)
PPTX
Git learn from scratch
PPTX
Git and GitHub Workshop of GDG on Campus UNSTPB
PPTX
Git and Github workshop GDSC MLRITM
PPTX
Version control git day03
PPT
B4usolution git git-hub
PDF
Git the Docs: A fun, hands-on introduction to version control
Bitbucket and Git
Git Developer Cheatsheet
Git presentation, Viktor Pyskunov
Git for beginners
Git and GitHub workshop of GDG on Campus UNSTPB
Git github
Git and GitHub Workshop of GDG on Campus UNSTPB
Git & GitHub WorkShop
GitHub Event.pptx
Git and github 101
Version control git day02
Let's Git this Party Started: An Introduction to Git and GitHub
Git Init (Introduction to Git)
Git learn from scratch
Git and GitHub Workshop of GDG on Campus UNSTPB
Git and Github workshop GDSC MLRITM
Version control git day03
B4usolution git git-hub
Git the Docs: A fun, hands-on introduction to version control

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
KodekX | Application Modernization Development
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Cloud computing and distributed systems.
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
Unlocking AI with Model Context Protocol (MCP)
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
sap open course for s4hana steps from ECC to s4
Diabetes mellitus diagnosis method based random forest with bat algorithm
The Rise and Fall of 3GPP – Time for a Sabbatical?
Understanding_Digital_Forensics_Presentation.pptx
Spectroscopy.pptx food analysis technology
Per capita expenditure prediction using model stacking based on satellite ima...
Digital-Transformation-Roadmap-for-Companies.pptx
Review of recent advances in non-invasive hemoglobin estimation
KodekX | Application Modernization Development
“AI and Expert System Decision Support & Business Intelligence Systems”
Spectral efficient network and resource selection model in 5G networks
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Programs and apps: productivity, graphics, security and other tools
Reach Out and Touch Someone: Haptics and Empathic Computing
Cloud computing and distributed systems.
Building Integrated photovoltaic BIPV_UPV.pdf

Git setuplinux

  • 1. GIT SETUP ON LINUX WITH BITBUCKET Step 1. Install git on your PC → Open Terminal (ctrl+alt+t) → $ sudo apt-get install git Verify the installation was successful by typing which git at the command line. → $ which git “/usr/bin/git” Configure your username using the following command. → $ git config --global user.name “Git_USER_NAME” Configure your email address using the following command. → $ git config --global user.email “xyz@atlassian.com" CREATE BITBUCKET REPOSITORY Step 2. Create a repository on Bit-bucket To create a repository, follow these steps: 1. Log into Bit-bucket Cloud under your individual account on https://bitbucket.org 2. Click Repositories > Create repository or the Create new repository link. 3. Choose a repository Owner. This only appears if you are creating under an account with membership in one or more teams. 4. Enter a Name and Description for your repository. 5. Tick Private if you want to hide your repository from the general public, so that only selected people can see it. 6. Select the Repository type. 7. Click Create repository. Step 3. Repository setup → $ mkdir /path/to/your/project → $ cd /path/to/your/project → $ git init → $ git add —all Note: check status of adding file “Green files means chosen for repository” → git status → $ git remote add origin https://user_name@bitbucket.org/yourRepos.git This is repositories path → $git commit -m 'Initial commit with contributors’ → $git push -u origin master Step 4. Create Branch on Bit-bucket
  • 2. Branch-> Create Branch Step 5. Clone Repositories → $ git clone https://user_name@bitbucket.org/yourRepos.git(remote address) Step 6. Using Git to checkout a branch on the command line → $ cd gitProject → $ git fetch && git checkout yourBranchName (Most Imp to change branch for fetch & checkout) → $git branch -a * yourBranchName remotes/origin/HEAD -> origin/master remotes/origin/abc_dev remotes/origin/development remotes/origin/master remotes/origin/ yourBranchName (The green colour of text with asterisk before it, showing that your current branch on which you are.) Step 7. Changes staging for commit → git add <file>( make a .gitignore file and add file names which you don't want to commit on remote, and add into your project.) → git status green files means added for commit → $ git commit -m 'commit message' → $ git push origin branch_name(on which you want to push code) Provide username & password Step 8. Pull (Daily Basis before push) → $ git pull origin branch_name (from which you want to pull) DIFFERENCE B/W CHECKOUT & CLONE To sum it up, clone is for fetching repositories you don't have, checkout is for switching between branches in a repository you already have. → $ git checkout branch_name(from where you want to check out)
  • 3. Once you completed all the above now follow the steps below… 1.Open your project on any editor (for eg. VSCode). 2. Make some changes in your files. 3. On the left menu on VSCode you find an option for git (or shortcut->> ctrl+shift+G). now you can see the files on which you changed the code, once you ensure the changes, you need to commit the code, now open terminal ( press ctrl+alt+t). i. $ cd /path/to/your/project ii . $ git status (this will show you modified file names with path) Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: app/folderName/file1.js modified: app/folderName/file2.js if you added new file in project which you didn't push yet that will show like this Untracked files: (use "git add < file>..." to include in what will be committed) newFile.js iii. $ git add <fileName> (on which changes done -->> git add app/projectFolder/xyz.js ). check status after add new files iv. git status (After Adding) Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: app/projectFolder/xyz.js Changes not staged for commit: (use "git add < file>..." to update what will be committed) (use "git checkout -- < file>..." to discard changes in working directory) modified: app/projectFolder/abc.js Untracked files: (use "git add < file>..." to include in what will be committed) newFolder/newFile.js (you can add files for commit as above) v. $ git commit -m 'changes in xyz page' “[your_branch_name ab3caa3] changes in xyz page 1 file changed, 9 insertions(+), 9 deletions(-)” (you can also check the status of you commit by entering command $ git status ) iv. you can see the logs by entering command $ git log (show all commits in the current branch’s history, press 'q' from exit log window) you can see the difference by entering command $ git diff
  • 4. (this will show you the difference between files, diff of what is changed but not staged press 'q' for exit ) vi. now push your code to remote. Before push code you can set your bit bucket password into your git config file run commands $ gedit .git/config (This will open your git config file in editor now you can set or change password from here.) [remote “origin"] url = https://user_name:password@bitbucket.org/daffodilsoftware/yourRepos.git fetch = +refs/heads/*:refs/remotes/origin/* (Note : Do not use '@' in your password it will give error while pushing) $ git push (Transmit local branch commits to the remote repository branch) Message on terminal—>> “Counting objects: 16, done. Delta compression using up to 4 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 483 bytes | 0 bytes/s, done. Total 5 (delta 4), reused 0 (delta 0) remote: remote: Create pull request for yourBranchName: remote https://bitbucket.org/daffodilsoftware/yourRepos/pull-requests/new? source=YourBranchName&t=1 remote: To https://userName:Password@bitbucket.org/daffodilsoftware/yourRepos.git commit Id YourBranchName - > YourBranchName” vii. Now its time to merge the code to your master branch or the branch you want $ git merge [alias]/[branch] merge a remote branch into your current branch to bring it up to date . viii. $ git pull 'fetch and merge any commits from the tracking remote branch'
  • 5. Some other useful command REWRITE HISTORY Rewriting branches, updating commits and clearing history $ git rebase [branch] apply any commits of current branch ahead of specified one $ git reset --hard [commit] clear staging area, rewrite working tree from specified commit $ git log branchB..branchA show the commits on branchA that are not on branchB git show show any object in Git in human-readable format git reset [file] Unstage a file while retaining the changes in working directory. Remove git initialization $ rm -rf .git Display current git configuration $ cat .git/con g $ git con g user.name “username” $ git config user.email “email”