GithubHelp home page GithubHelp logo

githubcli's Introduction

GithubCLI

Git hub commands step-by-step for beginers

Install Git

Refer following,

Git commands

Basic branching and merging

Stage-Commit-Pull-Push

  • Master
  • Developers: Pull (from Master), Change, Save, Stage, Commit, Pull (from Developer), Resolve conflicts and then Push (to Developer)

Configuring and connecting to a remote repository

Reference: https://www.computerhope.com/issues/ch001927.htm

  • Move to the project directory root

  • Type the following command to configure your Git username, where "your name" will be your GitHub username.

    $ git config --global user.name "your name"

  • After entering the above command, you should be returned to the command prompt. Next, enter your e-mail address by typing the following command, where "your e-mail" is your e-mail address.

    $ git config --global user.email "your e-mail"

  • Once the above steps have been completed, you'll be ready to connect to a remote repository. To find the repository address, go to a repository on GitHub and click the Clone or download repository link to get the address. For example, we've created a repository called "GithubCLI" at https://github.com/ArohanGit/GithubCLI.git address. Copy the address to your clipboard.

  • Once copied go back to the command line and type the following command, where URL is the address you copied. To paste that address into the command line right-click in the command line window and click paste.

    $ git clone "remote repository URL"

  • Once the Git repository is created local clone, you'll have a new directory in your current directory with the name of the Git repository.

  • Once the Git remote repository is cloned to your local repository, you should have a new folder in the current directory with the name of the Git repository. For example, in our "GithubCLI" Git we would have a new directory called "GithubCLI"". Use the cd command to change into the new directory.

  • Once in the new directory, type the following command to list the remote repositories.

    $ git remote

  • If successful, you should see "origin" that is the name of your master Git branch. To see the aliases (URL or path), type the following command.

    $ git remote -v

Adding an existing project to github repo using CLI

Reference: https://help.github.com/en/github/importing-your-projects-to-github/adding-an-existing-project-to-github-using-the-command-line

  • Initialises the git for the project root

    $ git init

  • Adds the remote repo origin

    $ git remote add origin "remote repository URL"

  • Verifies the new remote URL

    $ git remote -v

  • Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'.

    $ git add .

  • Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.

    $ git commit -m "First commit"

  • Pushes the changes in your local repository up to the remote repository you specified as the origin

    $ git push origin master

  • Other useful commands

    $ git config --list

    $ git config user.name

Cloning other repository to new repository

  • Create new repository on GitHub (new-repository)

    Url: https://github.com/other-account/new-repository.git

  • Clone the source repository to local machine (other-repository)

    $ git clone https://github.com/other-account/other-repository.git

  • Change directory to other-repository

  • Check github origin, this will be to other repository currently

    $ git remote -v

  • remove this origin by

    $ git remote rm origin

  • Confirm remote origin is removed by

    $ git remote -v

  • Add new origin

    $ git add origin https://github.com/other-account/new-repository.git

  • Confirm if remote origin is set to new repository

    $ git remote -v

  • Push to new repository master

    $ git push origin master

  • When gitignore files is changed, we need to give following commands to remove cached files from git index

    $ git rm -r --cached .

    $ git add .

And then commit using new ignore list

  • Visual Studio Code useful commands

    Refresh git bracnhes shown by VS Code

    $ git fetch --prune

  • **Protectting Master Branch **

    Settings -> branches -> Select branch -> Add Protection rule

  • Can owner push to master ?

githubcli's People

Contributors

arohangit avatar

Watchers

James Cloos 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.