-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitcommands.txt
65 lines (42 loc) · 2.96 KB
/
gitcommands.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
mkdir foldername ---------> make folder in local
git remote add origin URL --> Add remote file to local
git innit ------> git start
clear --------> clear screen
touch filename.txt ------> create text file
cd /g/xampp/htdocs/gitpractice ---------> change file location
git clone https://github.com/topugit/gitonline.git ----------> download git file
git status ---------> to check changes in files
ls --------------> file list
pwd ---------> to check which directory working
cd ../ ------------>one step up
git add -all --------> ready everything to stage
git add * -------> ready evertything to stage except deleted file
git reset --------> reset all files back to local from stage
git add filename.txt ---------> upload single file
git add foldername/filename.txt ---> upload single file in specific folder.
git add *.txt/js/css/php ------> upload all text file
git commit -m "I have made some changes" --------> upload to repisitory
git reset HEAD~ ----------> reset everything after commit
git reset --hard ----------> bring back file after manually deleted
git rm filename.txt ---------> remove/delete file
git rm filename.txt -f ---------> forcefully delete file
git branch ----------> how many branches
git branch branchname ---------> create new branch
git checkout branchname ---------> enter into branch
git merge main ---------> merge branch file with main file
git push origin main/branchname ---------> upload file to github
git fetch -----------> download remote to local
git merge -----------> to see file change made on remote
git pull
If you don't have Git installed, see this article on how to set it up.
Open up a Windows command prompt.
Change into the directory where your source code is located in the command prompt.
First, create a new repository in this directory git init. This will say "Initialized empty git repository in ....git" (... is the path).
Now you need to tell Git about your files by adding them to your repository. Do this with git add filename. If you want to add all your files, you can do git add .
Now that you have added your files and made your changes, you need to commit your changes so Git can track them. Type git commit -m "adding files". -m lets you add the commit message in line.
So far, the above steps is what you would do even if you were not using GitHub. They are the normal steps to start a Git repository. Remember that Git is distributed (decentralized), meaning you don't need to have a "central server" (or even a network connection), to use Git.
Now you want to push the changes to your Git repository hosted with GitHub. You do this by telling Git to add a remote location, and you do that with this command:
git remote add origin https://github.com/yourusername/your-repo-name.git
*Note: your-repo-name should be created in GitHub before you do a git remote add origin ...
Once you have done that, Git now knows about your remote repository. You can then tell it to push (which is "upload") your committed files:
git push -u origin master