Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 35 additions & 34 deletions git_tutorial.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
pwd : Present working directory
ls : List contents
cd : Change directory
git status : To check the status of git repository
git init : Create git repository
git add --a or git add . : Add all the files to the staging area
git add {{"filename"}} : Commit only single file
Git commit -m {{"message"}} : Create snapshot/commit
git log : Get the logs of commits
git log -p : Show all the logs like rename, deleted, etc
git log --stat : Gives short statistics of logs
git log -3 : Show latest 3 commits
git log --pretty=oneline : Show all the logs in one line
git log --pretty=short : Show logs in short
git log --pretty=full : Shows logs with full information
git log --since=2.days : Shows the logs of past 2 days(can write 2.weeks, 2.months, etc)
git log --pretty=format:{{}} : Format logs according to you(Visit https://git-scm.com/docs/git-log for more details)
rm -rf .git : Delete contents of a folder(repository)
git clone {{url}} : Clone any repository
git clone {{url}} {{folder name}} : Clone any repository and give name
touch {{filename}} : A linux command user to generate file
touch .gitignore : Ignore any file(have to add {{filename}} in git.ignore folder)
git diff : Compare working directory with staging area and show all the changes
git diff --staged : Compare new commited files of staging area with old commited files
git commit -a -m "Comment}}" : Skip staging area and commit directly
git rm {{filename}} : Remove/Delete the file
git mv {{oldfilename}} {{newfilename}} : Rename file
git rm --cached {{filename}} : Stop tracking the file
git commit --amend : Combine staged changes with the previous commit instead of creating an entire new commit
git restore --staged {{file name}} : Unstage file
git checkout -- {{file name}} : Undo uncommitted changes
git checkout -f : Go back to previous commit
git checkout -b {{branch name}} : Create new branch
git push -u origin master : Push code to Github
pwd : Present working directory
ls : List contents
cd : Change directory
git status : To check the status of git repository
git init : Create git repository
git add --a or git add . : Add all the files to the staging area
git add {{"filename"}} : Commit only single file
Git commit -m {{"message"}} : Create snapshot/commit
git log : Get the logs of commits
git log -p : Show all the logs like rename, deleted, etc
git log --stat : Gives short statistics of logs
git log -3 : Show latest 3 commits
git log --pretty=oneline : Show all the logs in one line
git log --pretty=short : Show logs in short
git log --pretty=full : Shows logs with full information
git log --since=2.days : Shows the logs of past 2 days(can write 2.weeks, 2.months, etc)
git log --pretty=format:{{}} : Format logs according to you(Visit https://git-scm.com/docs/git-log for more details)
rm -rf .git : Delete contents of a folder(repository)
git clone {{url}} : Clone any repository
git clone {{url}} {{folder name}} : Clone any repository and give name
touch {{filename}} : A linux command user to generate file
touch .gitignore : Ignore any file(have to add {{filename}} in git.ignore folder)
git diff : Compare working directory with staging area and show all the changes
git diff --staged : Compare new commited files of staging area with old commited files
git commit -a -m "Comment}}" : Skip staging area and commit directly
git rm {{filename}} : Remove/Delete the file
git mv {{oldfilename}} {{newfilename}} : Rename file
git rm --cached {{filename}} : Stop tracking the file
git commit --amend : Combine staged changes with the previous commit instead of creating an entire new commit
git restore --staged {{file name}} : Unstage file
git checkout -- {{file name}} : Undo uncommitted changes
git checkout -f : Go back to previous commit
git checkout -b {{branch name}} : Create new branch
git push -u origin master : Push code to Github
git config --global alias.{{shortcut}} {{long keyword}} : Create shortcut for any keyword (example: git st for git status)