Git Product home page Git Product logo

git-and-github's Introduction

Git and Github

Configuaration

git config --list
to see configuaration of the git
git config --global user.email "[email protected]"
to set or change the email of the user in git
git config --global user.name "username"
to set or change the username in the git

Status

git status
shows the status of the action conducted on the git
git diff --staged
shows the difference between two version of the staged files

To Add File To Staging Area

git add filename
to add single file of particular filename in staging area
git add filename1 filename2
to add multiple files to staging area of particular name in git
git add .
to add all files in git

To commit changes in git

git commit -m "message"
to add file to local repository with a unique and distinctive message
git commit -am "message"
adds file to staging area and then to local repository

To View Commit History

git log
shows the detail history of commit
git log --oneline
shows the detail history of commit command in oneline

To Go To Previous Version Or Branch

git checkout #number
takes us to the version of the given hash number
git checkout branchname
takes us to the required branch

Add and remove remote origin

git remote add origin "url of the github"
adds the orgin or path of the github repo
git remote remove origin
removes the origin path of the github
git remote -v
git remote show origin
shows us the origin path of the github

Push The Files To The Github

git push origin main/master
pushes all the changes to the main branch in github
git push origin branch_name
pushes all the change in the code to the specified branch

Cloning The Project From Github

git clone "url of the github account"
clones the whole project in our computer

Branching In Git

git branch branch_name
creates new branch in the git
git branch
shows all the branch created in the git

Merging Files Of The Branch

git merge "branch_name"
note to make sure to go to the main branch where we want to merge the files
git merge --no-ff "branch_name"
merges the file with no fastforward
git branch --merged
shows merged branch
git branch --no-merged
shows not merged branch

Reset Our Head To Previous Version

git reset --head #number_of_previous_version
used when we want to discard all the changes and restart from the previous version

Deleting Branch In Git

git branch -d "branch_name"
deletes the branch but rejects if it is not merged
git branch -D "branchname"
deletes the branch even if it is not merged

Pulling The Files From The Github Repository

git pull origin main/master/branch_name
pulls the chnages done by other to our code

Tagging In Git

git tag -a tag_name -m "message"
adds tags in the git which is used to check milestones while coding

Stashing In Git

git stash
puts all your current changes in hold and allows you ro pull new data form other branch without pushing your code
git stash pop
pops all your stashed files after you pull the branch

Fetching In Git

git fetch --all
fetch all the branch from git hub similar to git pull

git-and-github's People

Contributors

yogijagdish avatar

Stargazers

Bijaya Poudel avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.