Wednesday 16 February 2022

Git Branch :- create, switching, rename, delete, push, status, merge


#Create a GitHub repository

Go to github.com, and log in to your account.

Click on the New button to create a new repository, enter a repository name and click on Create Repository button.


#Clone the GitHub repository

git clone <https URL>

cd Newbranchrepo

git branch

#creating a new branch

git branch new_branch


#Rename from branch

git branch -m new_branch

#Rename from another branch

git branch -m new_branch rename_branch


#Delete branch locally

git branch -d rename_branch

#Delete branch remotely

git push origin --delete rename_branch

#enter Username and Personal Access Token


#Switch to the new branch

git checkout new_branch

#Switch to the new branch by creating

git checkout -b branch_name

git branch


#Create a file and commit the changes

vim index.html

git add index.html

git commit -m "commit index file"


#push a new branch

git remote -v

git push -u origin new_branc

#enter Username and Personal Access Token


#Check the status of the new branch

git status


#Switch back to the main branch

git checkout main

git branch


More  Git-branch 


#Git merge

git merge branch_name


3-way merge

#Start a new feature

git checkout -b new-feature main

# Edit some files

git add <file>

git commit -m "Start a feature"

# Edit some files

git add <file>

git commit -m "Finish a feature"

# Develop the main branch

git checkout main

# Edit some files

git add <file>

git commit -m "Make some super-stable changes to main"

# Merge in the new-feature branch

git merge new-feature

git branch -d new-feature


Learn Git


No comments:

Post a Comment