[go: up one dir, main page]

0% found this document useful (0 votes)
15 views4 pages

Git&Github

The document provides a comprehensive guide on using Git and GitHub, detailing commands for configuration, file management, branching, and remote operations. It includes specific steps for both students and developers, emphasizing the importance of initializing repositories, committing changes, and managing branches. Key commands such as 'git init', 'git add', 'git commit', and 'git push' are highlighted for effective version control.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

Git&Github

The document provides a comprehensive guide on using Git and GitHub, detailing commands for configuration, file management, branching, and remote operations. It includes specific steps for both students and developers, emphasizing the importance of initializing repositories, committing changes, and managing branches. Key commands such as 'git init', 'git add', 'git commit', and 'git push' are highlighted for effective version control.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Git & Github

Git works locally and GitHub is use globally


Step1:- git --version
Step2:-
Global configuration:-
git config --global user.name " "
git config --global user.email " "

check list :- git config --global --list

Set default editor:- git config --global core.editor "core --wait"

Step3:-
windows Line ending :- git config --global core.autocrlf "true"
Mackbook Line ending :- git config --global core.autocrlf "input"
Linux Line ending :- git config --global core.autocrlf " "

opens a .git config open :- git config --global -e


Step4:- git init (It create an empty .git Repository)
know the direcatry :- dir
add file:- git add file name
remove file :- git rm --cached
add two file :- git add file1 name file2 name
Step5:- git commit -m "Commit Message"

git reset --soft Head~1 (latest commit take back in Staging area)
git reset --mixed Head~1 (latest commit take back in Working area)
git reset --hard Head~(number of commit)
(it break the connection with other all mid commit )
git log --oneline (get the #id off all the commit)
git reset --head (commit id of that commit)

git commit --amend -m "NEW MSG"


git commit --amend --no-edit

close vim editor :- esc:wq


Way to merge a branch:-
1. Fast forword merge
2. Three way merge
Rename master branch :-
1. git branch -m BRANCH-NAME (branch name must in small later , It is also used
for rename the branch)
2. git branch -M BRANCH-NAME (branch name must in small later )
{it is use to rename forcefully}
Create a branch :- git branch BRANCH-NAME
Check branch :- git branch
To move from one branch to other branch :- git switch BRANCH-NAME
To merge a branch:- git merge BRANCH-NAME
To delete a branch :- git branch -d BRANCH-NAME
Create and switch in that branch:- git checkout -b BRANCH-NAME
Rebase Marge :- git rebase main
Check remote location :- Git remote
Set remote location :- Git remote add NAME <URL>
Check remote location :- git remote -v
Rename the location name :- git remote rename <OLD-NAME> <NEW-NAME>
Remove the path :- git remote remove origin
Push file in main branch :- git push -u origin main

Get the file :- git pull origin main


Make a clone :- git clone

For a students
Steps:-
1. git init
2. git add FILE-NAME
3. git commit -M “ MESSAGE”
4. git branch -M NEW-BRANCH-NAME
5. git remote -v
6. git remote add NAME <URL>
7. git pull origin main
8. git push origin main
For Developer

Steps:-
1. git clone <URL>
2. git branch NAME
3. git add FILE-NAME
4. git commit -M “MESSAGE”
5. git remote -v
6. git pull origin main
7. git push origin BRANCH-NAME

You might also like