0% found this document useful (0 votes)
112 views19 pages

Prepared By: Mohammed Jabari

Git is a version control system that allows developers to track changes to code over time and collaborate with others. It addresses the problem of managing multiple copies of code by providing a way to commit changes locally and share them through remote repositories on services like GitHub. The document outlines basic Git commands like init, add, commit, status, and log for managing a local repository, and push and pull for syncing with remote repositories. It provides a step-by-step example workflow for setting up and using a new Git repository.

Uploaded by

alaa abu madi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views19 pages

Prepared By: Mohammed Jabari

Git is a version control system that allows developers to track changes to code over time and collaborate with others. It addresses the problem of managing multiple copies of code by providing a way to commit changes locally and share them through remote repositories on services like GitHub. The document outlines basic Git commands like init, add, commit, status, and log for managing a local repository, and push and pull for syncing with remote repositories. It provides a step-by-step example workflow for setting up and using a new Git repository.

Uploaded by

alaa abu madi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

GIT

Prepared by: Mohammed Jabari

1
The Problem
• Code changes all the time!
• Whenever we have a working version, we make a copy
• Code changes again! Make another copy, call it copy1.1
• Team member makes a new change to code
• My own copy is not in sync with the one with my team.
• Manually merge the changes he made with mine, make a new copy!
• Code changes again!!!!

2
What is GIT?
• Git is a version control system that allows developers to track changes
to their code over time.
• It provides a way to keep track of different versions of files and
collaborate with others on a project.

3
GIT Basic Commands
1. git init: Initializes a new Git repository in the current directory.
2. git add <file> : Adds a file to the staging area, which means it's
ready to be committed.
3. git commit -m "commit message” : Commits changes to the
repository with a commit message that describes the changes made.

4
GIT Basic Commands
4. git status: Shows the current status of the repository, including
which files have been modified, added, or deleted.
5. git log: Shows a list of all commits made to the repository, along
with their commit messages and other information.
6. git diff <file> : Shows the differences between the current version of
a file and the previous version.

5
GIT Basic Commands
7. git branch: Shows a list of all branches in the repository.
8. git checkout <branch> : Switches to the specified branch.
9. git merge <branch> : Merges changes from the specified branch into
the current branch.
10. git push: Pushes changes to a remote repository.
11. git pull: Pulls changes from a remote repository.

6
Local and Remote Repos
• A local repository is a Git repository that is stored on your local
computer.
• When you create a new Git repository using the "git init" command,
Git initializes a local repository in the current directory.
• All changes made to the files in the local repository are tracked by Git
and can be committed, branched, merged, and pushed to remote
repositories.

7
Local and Remote Repos
• A remote repository is a Git repository that is stored on a remote
server or hosting service, such as GitHub, GitLab, or Bitbucket.
• Remote repositories are used for collaboration and backup purposes.
• Developers can push changes from their local repository to a remote
repository and pull changes from a remote repository to their local
repository.

8
Git Workflow
• In a typical Git workflow, developers
make changes to files in their local
repository, commit those changes,
and then push them to a remote
repository.
• Other developers can then pull those
changes from the remote repository
to their own local repositories and
make changes of their own.
• This allows for collaborative
development and version control.
9
In Case of Fire

10
Using Git: step-by-step
1. Install Git on your computer: You can download Git from the
official website: https://git-scm.com/downloads. Once you have
installed Git, open up your command prompt or terminal.
2. Create a new repository: Navigate to the directory where you want
to create your new repository, and type the following command:

This will create a new Git repository in the current directory.

11
Using Git: step-by-step
3. Add files to the repository: Add the files that you want to track in the
repository by using the following command:

You can also use the following command to add all the files in the
directory:

12
Using Git: step-by-step
4. Commit changes: Once you have added the files, you need to
commit the changes by using the following command:

The commit message should be a short description of the changes you


have made.
So far, all changes to the repo are saved locally

13
Using Git: step-by-step
5. Create a remote repository: Create a remote repository on a Git
hosting service like GitHub, GitLab, or Bitbucket.

You will need to have an account on one of the above and create an
application secret toket to use when pushing changes to the remote
repo.

14
Using Git: step-by-step
6. Add a remote repository: To add a remote repository, use the
following command:

Replace <remote-repository-url> with the URL of your remote


repository.
This command will add a remote repo, specified by the url, and name it
origin

15
Using Git: step-by-step
7. Push changes to the remote repository: To push the changes from
your local repository to the remote repository, use the following
command:

This command will push the changes from the "master" branch to the
"origin" remote repository.
If you go now to the remote repo url, you should find your local repo
files there

16
Using Git: step-by-step
8. Pull changes from the remote repository: To pull the changes from the
remote repository to your local repository, use the following
command:

This command will pull the changes from the "master" branch of the
"origin" remote repository to your local repository.
This command is used when there are more than one developer pushing
changes to the same remote repo, so every time a developer wants to do
changes on the local, he should pull the changes from remote.
17
Using Git: step-by-step
• Pulling changes from the remote, if the remote is not in sync with the
local, will initiate an automatice merge.
• If conflicts were found, git will try to resolve those and perform an
automatic merge, if it could not, the developer will have to manually
remove the conflicts and then merge the changes.

18
Is that all about GIT?
• Of course NOT!
• Git has many advanced commands and sometimes it gets too
complicated!
• Many IDEs, including NetBeans, support Git
• Using NetBeans you will not have to write Git commands manually
• Almost everything can be done by a click of a button.

19

You might also like