Github Basic



Clear basic doubts about Git 

 
 Some benefit of using Github.
  • Add projects.
  • Search any Projects.
  • Contribute in another projects. (like open source projects)


How to contribute another repository:

  • Fork the remote repository.
  •  Get the copy of the repo in your personal github account or local machine.
  • Make changes the repo as per your requirement.
  • Pull Request: It mean that you are requesting the owner of the repo that sir/madam I have taken your code and I feel that it's some scope of improvement, I am not only saying it's improvement, I also fix it. Would you like to review it?
    and if you find it genuine then please update your repo thanks.

    These are the 4 ways to contribute open source projects.

 
 
 Git has 2 parts:
  1. Local
    in the local, it have 2 parts.
    • CLI
    • GUI
    in the local it have 2 section.
    • create project from local and push to the remote.
    • another 1 is take the project from remote and then make changes locally and update it.
    How to make a folder and push to the remote.
    • first make a folder using mkdir folderName
    • go to folder and type git init . 
    • now run the git command git status.
    • git add .
    • git commit -m 'write message related to repo'


    rm -rf fileName or folderName and hit enter. (it will delete folder or file that you mention)


  2. Remote
 
 These are the 5 things only you do when deal with remote repository.
  1.  git init .    ( git start tracking the folder )
  2. add any file
  3. git status    (it will show file added but not track)
  4.  git add <fileName>
  5.  git commit -m <put message about what you did>

 
 
Whatever changes I do in my local, I want to push it github.com How do i do it.
  1.  First go to github.com and copy the url.
  2. git remote add origin <url>
    it will go to the remote and establish the connection between local and remote.
    This is the way to add the remote repo to the local.
  3. git remote -v
    it will tell you remote added or not.
 
 Note: git add .        (dot indicate all files)
            git add fileName         (only specific file name)
 
Some general topics to know about git:
  •  git branch
    it will check which branch is using.
  • git checkout -b branchName
    it will switched to a new branch branchName
  •  git branch
    it will show the all branches.
    Keep in mind difference branches have different files.



 
 
1. git pull:  
The git pull command is used to fetch and download content from a remote repository.
 
2. git push: 
The git push command is used to upload local repository content to a remote repository.

3. git merge: 
Git merge is a command that allows you to merge branches from Git. Merging is a common practice for developers. Whether branches are created for testing, bug fixes, or other reasons, merging commits changes to another branch. It takes the contents of a source branch and integrates it with a target branch.

4. git log:  
The git log command displays a record of the commits in a Git repository. 

5. git status :
The git status command displays the state of the working directory and the staging area. It lets you see which changes have been staged, which haven't, and which files aren't being tracked by Git. Status output does not show you any information regarding the committed project history.

6. git commit:
The git commit command is used to move files from the staging area to a commit. This command is run after git add, which is used to add files to the staging area. git commit creates a snapshot of the changes made to a Git repository which can then be pushed to the main repository when the developer is ready to do so.

7. git init:
The git init command creates a new Git repository. It can be used to convert an existing, unversioned project to a Git repository or initialize a new, empty repository. ... git sub directory in the current working directory, which contains all of the necessary Git metadata for the new repository.
 
8. git clone:
git clone is a Git command line utility which is used to target an existing repository and create a clone, or copy of the target repository. ... Cloning a local or remote repository.

9. git branch:
A branch represents an independent line of development. ... The git branch command lets you create, list, rename, and delete branches. It doesn't let you switch between branches or put a forked history back together again. For this reason, git branch is tightly integrated with the git checkout and git merge commands.

10. git checkout:
The git checkout command lets you navigate between the branches created by git branch . Checking out a branch updates the files in the working directory to match the version stored in that branch, and it tells Git to record all new commits on that branch.
 
11. Log in to git hub.

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

 
 
إرسال تعليق (0)
أحدث أقدم