Skip to content

imran-baitham/Git

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 

Repository files navigation

imran baitham

Star the repo like and share 🙏

😍 Git

( fast version control )

Git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed, non-linear workflows (thousands of parallel branches running on different systems.

imran baitham

Git Init

git init

Git Clone

git clone branch-name

“git clone” command and specify the copied URL to clone the selected Git repository.

Fetch all branchs

 git fetch --all

we have used the “–all” flag which will fetch all metadata of branches.

List Remote Branches

To display all remote branches, execute the “git branch” command:

 git branch -r

In the above-mentioned command, the “-r” indicates the remote branches. As you can see, currently, we have three branches in the remote repository

pull --all

git pull --all

shows that all remote branches are successfully pulled

1. Create Git branch using checkout

git checkout -b branch-name

Example

git checkout -b feature
Switched to new branch 'feature'

⭕️ You can inspect existing branches by running the “git branch” command with the “-a” option for all branches.

git branch -a

⭕️ To get commits SHA from your history, you have to use the “git log” with the “–oneline” option.

git log --oneline --graph

Git Delete Branch

git branch --delete branchname

The default branch has been renamed!

master is now named develop
If you have a local clone, you can update it by running the following commands.

git branch --delete branchname

Step 4: Create and Switch Branch

Now, create and switch to the new branch using the provided command.

 git switch -c branch-name

Step 5: List Branches

 git branch -a

“git branch” to display all branches with the help of the “-a” flag.

Step 6: Push Git Branch to Remote Repo

 git push –set-upstream origin branch-name

git push –set-upstream origin branch-name” command. This blog demonstrated the method to push a new Git branch to the remote repo on GitHub.

Step 7: View commit history

 git log

The commit history can be viewed in different ways by using the `git log` command. A local repository named bash has been used in this tutorial to test the commands used in this tutorial

Mearge local to main branch

If you wish to set tracking information for this branch you can do so with:

 git branch --set-upstream-to=origin/master branch-name