GithubHelp home page GithubHelp logo

useful-git-commands's Introduction

Useful-Git-Commands

Getting and Creating Projects on Githunb

Command Description
git init Initialize a local git repository
git clone ssh://[email protected]/[username]/[repository-name].git Create a local copy of a remote repository

Basic Command

Command Description
git status Check status
git add [file-name.txt] Add a file to the current repository area
git add . Add all new and changed files to the current repository area
git commit -m "[commit message]" Commit changes
git rm -r [file-name.txt] Remove a file (or folder)

Branching Command

Command Description
git branch List branches (The asterisk (*) indicates the current branch)
git branch -a List all branches (local and remote)
git branch [branch name] Create a new branch
git branch -d [branch name] Delete a branch
git push origin --delete [branch name] Delete a remote branch
git checkout -b [branch name] Create a new branch on the current repository
git checkout -b [branch name] origin/[branch name] Clone a remote branch and switch to it
git branch -m [old branch name] [new branch name] Rename a local branch
git checkout [branch name] Switch to a branch
git checkout - Switch to the branch last checked out
git checkout -- [file-name.txt] Discard changes to a file

Merging Command

Once your branch development is finished and fully functional, the last task is to merge it with the parent branch (dev or master) using the git merge command.

The git merge command combines the commits from your feature branch into the dev (or master) branch, effectively integrating your changes. To ensure a successful merge, make sure you are currently on the branch you want to merge your feature branch into.

Command Description
git merge [branch name] Merge a branch into the active branch
git merge [source branch] [target branch] Merge a branch into a target branch
git stash Stash changes in a dirty working directory
git stash clear Remove all stashed entries

Inspection and Comparison Command

Command Description
git log View changes
git log --summary View changes (detailed)
git log --oneline View changes (briefly)
git diff [source branch] [target branch] Preview changes before merging

Updating Projects on github

Command Description
git push origin [branch name] Push the current branch to the remote counterpart of that branch
git push -u origin [branch name] This creates a remote branch and sets it upstream of the current branch you are pushing
git push This command is used to upload local repository content to a remote repository.

useful-git-commands's People

Contributors

sujan-roy avatar

Watchers

 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.