-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_tutorial.txt
More file actions
34 lines (34 loc) · 1.99 KB
/
git_tutorial.txt
File metadata and controls
34 lines (34 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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