#36 Beginning Git — note

Ivan Lai
2 min readJul 29, 2021

--

Copy from “https://www.raywenderlich.com/4418-beginning-git

fork: Take an entire copy of the repo, and store it in your own personal user space.

git clone <URL>: Download the project from the URL.

git log: Show the most recent commits.

git init: Create a new Git repository.

git status: To check if there are changes in the working directory.

git add <file name>: Include the changes in the next commit.

git commit: Commit file from staging area to repository(index).

git remote add <remote name, like origin> <URL>: Add a remote repository

git push --set-upstream: set upstream argument ensures that my local branch will track the remote master branch.

git diff: Show changes between working directory and staging area.

git diff --staged: Show the changes between the staging area and the most recent commit in repository(index).

git add -i: Launch into a session that allows to curate which things need to stage.

git ignore: Need to create .gitignore file. Use vim to add the file you want to ignore into to .gitignore file.

git log --author=”<name>”: To see the commit from specific author.

git log --grep=”<message>”: To search the specific commit message.

git log -- <file name>: To search log of the particular file.

git log -S”<content>”: To search the content. Use -p flag to show the details.

git branch: Check the branch where we are.

git branch <new branch name>: Create new branch.

git checkout <branch name>: Switch to the branch.

git checkout <file name>: Rest to the last version.

git branch -d <branch name>: Delete the branch.

git remote -v: List all the remote that are associated with the current repo.

git branch -vv: List the branches and the remote that they’re tracking

git push <remote repo name> <local branch name>: Push a local branch to remote repo.

--

--