- Linux commands
- Literature review
- Local repository
- Remote repository
- Git show
- Git checkout
- Undoing
- Help in git
- Connect with me
- Current directory
- Change directory
- Make new folder
- List current folder contents
- Make new file
- Clear terminal
Write about it.
pwd
cd [options]
Options:
<root>
:..
: Navigate back folder.../..
: Navigate twice back folder.<folder_name>
: Navigate forward folder.
Write about it.
mkdir [options]
Options:
<folder_name>
: Create new folder.
Write about it.
ls [options]
Options:
notthing
: List file(s) in current directory.
touch [options]
Options:
<file_name>+<format+name>
: Create file with desired format.
clear [options]
Options:
nothing
: clear terminal display.
- Working tree
- Commit
- Stage
- Tracked/Untracked file
- Modifed file
- Nothing added to commit
- Changes not staged for commit
- HEAD
- Local
- Origin
- Remote
- Both modified
- Clone
- Ahead of origin/master
- Behind of origin/master
- Your branch is up to date
- Origin/master & master
- Tag
- The working tree, or working directory, consists of files that you are currently working on.
- You can think of a working tree as a file system where you can view and modify files.
- save your file/files that put in stage, and after commit, git consider this file/files as a HEAD file. You will be availble call every commit in future.
- Git considers each commit change point or "save point". It is a point in the project you can go back to if you find a bug, or want to make a change.
- stage is a place that, 1. untracked files put in stage in order to in commit phase, tracked by git. or 2. modified/deleted/... files that already tracked by git, put in stage in order to save changed in commit phase.
- you have NEW file/files that if contents modified, git can't sense alterations.
- Untracked basically means that Git sees a file you didn't have in the previous snapshot (commit), and which hasn't yet been staged.
- Untracked files are most of the time files you don't want to be controlled, because for example they are generated by your compiler.
- Tracked - files that Git knows about and are added to the local repository.
- Untracked - files that are in your working directory, but not added to the local repository.
- git always check tracked file/files,when file/files contents has been changed, git label it/these to modified file.
- no file/files are in stage to commit.
- your tracked file/files has been modified, and NOT yet put in stage to commit.
- HEAD is last/final commit (last saved alterations).
- local meaning is in your personal computer.
- EX:
local commit : a written commit that has been write in your computer and has not yet push in remote repository.
- origin" is the name of the remote repository where you want to publish you commits. By convention, the default remote repository is called "origin", but you can work with several remotes (with different names) as the same time. More information here.
- A remote repository in Git, also called a remote, is a Git repository that's hosted on the Internet or another network.
- recommend you : commit and merege early early!
- recomend you : pull repository, and edited it and commit and push it.
- duplicate and download everything of remote repository when you use command clone in git, git create new folder with name as same as name of remote repo in github and copy and download everything and put it them on this folder.
- when you fetch remote repo on your local repo, this guide say you, remote repo have new commits so that you have not these commits in your local repository. and you "behind of origin/master" this meaning that, you are NOT update rather to origin remote on master branch.
- when pull (fetch and merge) remote branch with your local branch this guide showed.
- "remote name"/"remote branch name" & "local branch name"
- Git has the ability to tag specific points in a repository’s history as being important.
- Directory
- Initialize git
- Display status
- Track / Stage
- Save alterations
- Display commits
- Display differences
- Branches
- Merging
- Tagging
- Checkout in tagging
Write about it.
Count current directory to git and git folder create in current directory:
git init
Summery alterations in some frequent phrases:
git status [options]
Options:
--short
: Summery commit shortly
Frequent phrases:
Tracked file/files
Untracked file/files
Staged file/files
Unstaged file/files
NOTE:
git status
show only just alterations in local repository and not
show alterations in remote repository.
This means that, if anyone had been changed some file(s) of remote
repository (GitHub), git status
would not show it to you.
This command has two performance:
- Track new file/files that not yet added to git.
- Stage file/files that has been tracked by git.
git add [options]
Options:
<file_name>
: Stage/Track file(s)*.py
: Stage/Track all.py
file(s)--all
/-A
: Stage/Track all file(s)modules*
: Stage/Track all file(s) that name start withmodule
Save(Commit) your staged/tracked file(files) with message:
git commit -m "<your message>"
NOTE:
Message is require.
Show all commits:
git log
NOTE: If list of commit is long, you can press q
to exit.
Write about it.
git diff [options]
Options:
<nothing>
:HEAD
:--staged
:
Write about branches.
git branch [options]
Options:
nothing
: Show current branch<branch_name>
: Create new branch-d <branch_name>
: Delete branch
Write about checkout
git checkout <branch_name>
Write about merging
git merge <branch_name>
NOTE:
Sure that when you merge, your current branch in
main branch.
Write about it
git tag [options] -m "<tag_message>"
Options:
nothing
: Show all tags yoy have.-a <tag_name>
: Tag HEAD commit (last commit)
NOTE:
a
is annotation tag, if you didn't write it, you tag in lightweight tag.
-a <tag_name> <desired_commit>
:
Switch to desired tag.
git checkout <tag_name>
Write about remote
NOTE:
you can add multiple remotes and work with them at the same
time.
git remote [options]
Options:
nothing
: Show remotes (GitHub url) that you wish to push/pull your local repo commits to it).add <remote_name> <remote_url>
: Add new remote. This command simply means you are adding the location of your remote repository where you wish to push/pull your files. (e.g.git remote add asli "https://github.com/alirezakhodabakhsh/ hello"
)rm <remote_name>
: Remove specific remote.
If you had new commit(s) on your local remote, you can push these to remote repo:
git push [options]
Options:
<remote_name> <branch_name>
:<remote_name> --delete <branch_name>
: Delete remote branch<remote_name> <tag_name>
: Push specific tag to your remote repo.
NOTE:
In this case, git status
display:
Ahead of origin/master
This means that, you have new commit(s) than when you had pulled remote repo.
NOTE:
Recommend that current branch set on <branch_name> that you want
to push it (local repo branch and remote repo branch
be as same as).
NOTE:
If <branch_name> wasn't there in remote repository, new branch
has been created.
Pull is combination of Fetch and Merge.
Write about it.
git fetch [options]
Options:
<remote_name>
:
Write about it
git merge [options]
Options:
<remote_name>/<remote_branch_name>
: Merge remote branch- with your local branch.
Write about it.
git pull [options]
Options:
<remote_name> <remote_branch_name>
: Fetch and Merge respectively from remote branch name on local branch name.
NOTE:
Recommended, current local branch as same as repo branch.
Write about it.
git diff [options]
Options:
<remote_name> <remote_branch_name>
:Show difference master branch (remote repo) with master branch (local repo).
Clone remote repo:
git clone <remote_url>
Show local and remote branches.
git branch -a
NOTE:
If you pull and up-to-date local repo, new remote branches
wouldn't put in your local branches.
So you should use git checkout <remote branch>
and use again
git pull
to up-to-date.
When you create new branch, you duplicate master branch files and work on them. At this time, if someone (you) change master branch file(s) and commit changes, after that, you merge branch with master branch, you get conflict. In this time, you must get rid of this conflict. and then merge and commit.
RECOMMEND:
When you create new branch, don't edit master branch until wouldn't merge it.
You clone/pull remote repository and modify it, at same time, someone (you) clone/pull it and modify it simultaneously (modified in GitHub). Another one (you) push new commits on remote repo and after that you push your commits. In this time, git get into the conflict.
Write about it.
git show [options]
Options:
<commit_key>
: Put ingit log
<desired_tag>
:
Summery all checkout application in git.
git checkout [options]
Options:
<branch_name>
: Switch from current branch to desired branch.<file_name>
: Ignore all alteration that has been done on file(s).<tag_name>
: Switch to desired tag.'<commit_code>'
: Switch to desired commit.
Unstage file(s) already has been staged.
git reset
Write about this
git rm [options]
Options:
<file_name>
: Delete specific file or files from git.
Write about this
Ignore all alteration that has been done on file(s).
git checkout <file_name>
RECOMENDED:
Utilize this command, when you're working on file, and you wouldn't reach to valuable commit and want to back to last commit.
Write about this
git <command> -help