-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit_commands.txt
72 lines (68 loc) · 4.24 KB
/
git_commands.txt
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
git commands:
pwd :-present working directory
cd:
make user in git : git config --global user.name "naman"
attach email:git config --global user.email "[email protected]"
git config --list
to see name and email
git config user.name/email
git status: to check the status of git
git init :- to make the folder git repositories
git add --a :- means put all the files in staging area and comes to staging area
git status
git commit -m "message":- the snapshot of file will be created
git log: to see all the commits done
gi add first.txt :- to add only the single file in git
rm -rf .git :- to remove all the git repository
git clone https://github.com/pandas-dev/pandas.git mypanda : to fetch new dir from internet into fiolder mypanda
ls: contains the list in folder you are in
touch abc.txt:- creates the file in the same directory
touch .gitignore:- if we add any files in this file that it ignore all the files inside it and so we cannot see it in git status and it will not get commit
*.log:- if we write this inside the .gitignore file than it will ignore all the files having extension .log
dir/:- if we write this in the .gitignore file than it will ignore the directories also to commit in git, any type pf dir folder will be ignored weather it is inside the another folder does not matter it is ignored
/dir/:- if we want just outer folder to get ignored and not all the folders in the git with same name
we can give any path of file or directory to ignore in gitignored
git diff :- if we add a file to a git so a file is in a staged state
no we change in the file
so if we do git status than that fie comes in both i.e staged state as well as modified state
and comapres modifies with staged
git diff --staged:
It compares last commit with present staged
git commit -a -m "direct commit" := if we want to ignore the staging state and commit directly
but the files which are present before will only be commited and the new files created will not be commited
for new files yo 1st need to add them to git
git rm abc.txt :- to delete a file
git mv first.txt first_renamed.txt : to rename a file
git rm --cached db.accdb :- if my file is present from before and after some commit we put it in gitignore and if we do git add . than it will show that file in the staged but it must not show that is becaues it is in the cache so to rm it from cache we use this command
git log -p: To see all the commit with all the details like a line is removed and a line is added that means it is showing complete info
git log --stat: it shows the commits with limited info
git log --pretty=oneline/short/full :- shows all the commits in a single line,short,full
git log --since=2.days/weeks/months/years :- sees all the commits for last two days
git log --pretty=format:%h--%n (see git formats from this website https://git-scm.com/docs/pretty-formats)
git commit --amend :-It will open the vim editor and you can merge your message with the old commit
git restore --staged git_commands.txt :- it will remove the file from the staged area
git restore --staged :- it will restore the last commit stage
git checkout -- git_commands.txt :- it will restore the file specified for the last commit
git checkout -f :- it will restore the last commit for the complete directory
git remote :- to go into the remote repository
like github is a website which hold control of remote repo
git remote add origin https://github.com/namanjain98/git_commands.git : so we are adding it into github and giving it a name origin
git remote
we will se origin
git push -u origin master : it will not push anything since we donot have permission
-so go tosetting in your github account
-SSH and CPG keys
give title
-now we have to create ssh keys
so go to ssh keys github:
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
$ eval $(ssh-agent -s)
$ ssh-add ~/.ssh/id_rsa
add your ssh keys to github account
tail ~/.ssh/id_rsa.pub
now we need to copy the key generated
and paste it in the above file
git config --global alias.st status :- this alias command is use to replace status command with st
Create branching in github:
git checkout -b develop
git checkout master :- to go into the master branch again