mkdir myproject
cd myproject
git init
echo "# Lab2 Git" >> README.md
git add README.md
git commit -m "Initial commit"
// create SSH key
ssh-keygen -t ed25519 -C "andrew#########@gmail.com"
git remote add origin git@github.com:andrew/Git_Lab2.git
git push -u origin mastergit checkout -b dev
echo "This is file1, Created By Andrew Adel" >> file1.txt
echo "This is file2 Created By Andrew Adel" >> file2.txt
git add file1.txt file2.txt
git commit -m "Add file1 and file2 in dev branch"
git push -u origin dev
git branch --show-current
git switch master
git checkout -b test
git push -u origin testgit checkout master
git merge dev
git push -u origin mastergit branch -d dev
git branch -d test
git push origin --delete dev
git push origin --delete test
restore the branches
git reflog
git checkout -b dev 5b2d569
git checkout -b test 0e89d62
git tag -a v1.4 -m "Version 1.4"git push origin v1.4git tag//locally
git tag -d v1.4
//globally
git push origin --delete tag v1.4Git rebase is a way to integrate changes from one branch into another. It moves or "replays" the commits from one branch onto another, creating a linear project history.
A---B---C master
\
D---E feature
If you rebase feature onto master:
git checkout feature
git rebase master
it will act as
A---B---C---D'---E' feature
it is look like if D and E is commit after last update of master as if created and add after C update
A pull request is a way to request that another developer reviews and merges your changes into a branch of a repository. This is commonly used in collaborative projects to ensure code quality and manage contributions.
- Push your branch to the remote repository:
git push origin dev
- Navigate to the repository on GitHub (or your Git hosting service).
- Click the "Pull requests" tab.
- Click the "New pull request" button.
- Select the branch you want to merge into (e.g., main) and the branch you want to merge from (e.g., feature-branch).
- Add a title and description for your pull request.
- Click "Create pull request".

git clone <repository-url>- Clones a repository from a remote server (like GitHub, GitLab, etc.) to your local machine.
- Copies the entire repository, including all branches, commits, and history.
- Sets up a local working copy of the repository.
- Initializes a remote tracking branch (origin/master, origin/dev, etc.) that corresponds to the default branch (master or main) on the remote repository.
- Used to initially download a repository from a remote server to start working on it locally.
git fetch [<remote>]- Fetches changes from a remote repository to your local repository without merging them.
- Downloads new data (commits, branches, tags) from a remote repository.
- Updates the remote tracking branches (origin/master, origin/dev, etc.) to reflect the latest changes on the remote, but does not integrate those changes into your local branches.
- Used to see what changes are available from a remote repository before deciding to merge or pull them into your local branch.
git pull [<remote>] [<branch>]- Fetches changes from a remote repository and merges them into your current branch.
- Performs a git fetch to retrieve the latest changes from the remote repository.
- Automatically merges the retrieved changes into the current branch (by default, this is the branch you are currently on).
- Combines git fetch and git merge in a single command.
- Used to update your current branch with the latest changes from a remote repository. It is effectively git fetch followed by git merge.
-
Clone: Downloads an entire repository from a remote server to your local machine, including all branches and history.
-
Fetch: Downloads new commits, branches, and tags from a remote repository to your local repository. It updates the remote tracking branches but does not integrate these changes into your working directory.
-
Pull: Downloads new commits from a remote repository and integrates (merges) them into your current working branch. It effectively combines fetch and merge.





