0% found this document useful (0 votes)
3 views

Git and GitHub

Uploaded by

rajatsingh209
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Git and GitHub

Uploaded by

rajatsingh209
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Git and GitHub

Git is a Version control system.


GitHub is a online platform which allows us to host our git
repositories.
Other platforms available are bitbucket and gitlab.
Uses:
1. It helps to save the history of your project.

Some command prompt commands:


1. mkdir folder – creates a new folder

2. cd folder – we move to this folder

3. git init – initialize a empty git repository on the above folder

(This creates a .git file which is provided by git which store the
project history)

4. git status – If we make any changes to our local code it wont


reflect to others but we can see it using git status
Untracked files:
(use "git add <file>..." to include in what will be committed)
test.txt

5. git add filename – to add the changes made to the stage before
committing it for other to see we use git add

6. git add . – To add all the files


7. git commit -m “message” – to commit the changes for the
others to see it.

8. Now when we make changes to a file and to check which file


has been changed we do git status.
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: demo.txt

9. If we have added any file my mistake and want to remove it


from stage we use git restore –staged filename

10.git log – to check all the commits made to the project we use
git log. It gives us the commit history.

11.Each commit has a hash id and is built on top of each commit

12.To go back and see the code of any previous commit we use
git reset hashid for example. git reset
f0d43908da9c5fb24101f0bbea03166f4fcb68b3

13. git stash : This is used for changes that we want to make but
not move to commit at that time and save it somewhere.

14.To bring the changes done using git stash back to the surface
we use git pop
15.git stash clear to remove the changes stored in the stash

16.To link your project in your local to the git repository this is
the command
git remote add origin <git-url>
here remote means we are working with the url
add means we are adding a new url
origin means the name we are using for the url <git-url>, for
this we are using the name origin.

17. To move our code from local to the git repository we use
git push origin master
(here we are pushing the code to the master branch)

18.To create a new branch we use the command git branch


featureName. Now the head which is nothing but the pointer
will point to the feature branch instead of the main branch.

19.Fork: It is used to make a copy of the existing project in your


own account and then work on it. The url which we use to fork
the project is called the upstream url.

20.Cloning a existing project : To clone a existing project into your


local system we use git clone <git-url>

21. To create a new branch we use git branch featureName and to


move the head(pointer) to the new branch we use git checkout
featurename

22. To remember we use ACP(add commit push)


23.Pull request: When we make a copy of a project and make
changes to it. Now in order for the changes to be added to the
main project we create a pull request. Once the pull
request(PR) is reviewed and merged it will show the changes in
the main branch.

24.For every new feature we are working on we need to create a


new pull request(PR) that means we should create a new
branch for every feature.

25. One branch can open only ONE pull request.

26.If we want to remove a commit we use git reset hashid. Now


for this update to show in the github we need to force it using
git push origin features -f.

27.

You might also like