Wednesday, August 21, 2019

git


https://help.github.com/en/articles/adding-an-existing-project-to-github-using-the-command-line

  • Distributed Version Control System
  • Collaboration platform
  • Who made what changes and When
  • Reverse back
  • local and remote repository

git command  most used


echo "# xxxx" >> README.md

git init
Initialize a local Git repository(folder)
git add [file]
Add a file to the staging area, add file to index
git add .
Add all the files 
git rm -r [file-name.txt]
Remove a file (or folder)
git status
Check status of working tree
git commit -m "[commit message]"
Commit changes in index
(touch .gitignore)

git branch
List branches (the asterisk denotes the current branch)
git branch [branch name]
Create a new branch
git checkout [branch name]
Switch to a branch
git merge [source branch] [target branch]
Merge a branch into a target branch

git remote add origin  ssh://git@github.com/[username]/[repository-name].git
Add a remote repository
In Git, "origin" is a shorthand name for the remote repository that a project was originally cloned from. ... Note that origin is by no means a "magical" name, but just a standard convention.
$ git remote -v
# Verifies the new remote URL
git push origin [branch name]
Push a branch to your remote repository
git push -u origin [branch name]
Push changes to remote repository (and remember the branch)
-u option local branch is linked with the remote branch automatically. The advantage is, you may use git pull without any arguments.

git push
Push changes to remote repository (remembered branch)

git clone ssh://git@github.com/[username]/[repository-name].git
Create a local copy of a remote repository
git pull
Update local repository to the newest commit
git pull origin [branch name]
Pull changes from remote repository


git ls-tree --full-tree --name-only HEAD
list the files in branch

git diff
list the difference between branch

How to Contribute and Collaborate

fork the target repo to your own account->clone the remote repo to your local machine->work on your module or make some changes->add your work to the staging area (git add.)->commit your work(git commit -m 'message')->push your work to your fork->create a pull request from browser->pull request will be approved by the owner and added to the main branch






No comments:

Post a Comment

API interview questions

  https://www.katalon.com/resources-center/blog/web-api-testing-interview-questions/ Top 50+ Web API Testing Interview Questions [Ultimate l...