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

Git Commands From Begin To End - 221210 - 021009

The document provides instructions for using basic Git commands to initialize and configure a local repository, track changes to files, commit changes locally and to a remote repository, work with branches, resolve merge conflicts, and publish a local repository to GitHub. It covers commands for initializing a repo, adding/removing files, committing changes, viewing commit history and diffs, branching, merging, pushing changes to remote repos, resolving conflicts, and cloning from GitHub.

Uploaded by

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

Git Commands From Begin To End - 221210 - 021009

The document provides instructions for using basic Git commands to initialize and configure a local repository, track changes to files, commit changes locally and to a remote repository, work with branches, resolve merge conflicts, and publish a local repository to GitHub. It covers commands for initializing a repo, adding/removing files, committing changes, viewing commit history and diffs, branching, merging, pushing changes to remote repos, resolving conflicts, and cloning from GitHub.

Uploaded by

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

To clear code in terminal press "~"

1. git config --global user.name " "


2. git config --global user.email " "
3. git config --global init.default
branch main
4. git config -h (to get info about
commands)
5. git help config (same as in 4)
Choosing directory
6. cd c:/../..
İnitialising repo
7. git init
8. git status (to tell status of local
repo)
9. git add ./<file name> (to track
changes)
9.1.git rm --cached <file name> (to
remove untrack file)
9.2. git add --all(track all files)/
9.3. git restore --staged <file
name> (to remove from
commiting)
10. git commit -m "place for
comment"
10.1. git commit -m "..." --amend
(to change commit name)
10.2. git reset <hashtag> (to
choose certain commit, you get
hashtag of a commit by typing git
log)
11. git diff (shows differences
between modified and previous
files)
12. git log (to show history of
commits)
12.1. git log -p (more detailed)
12.2. q (to exit view mode)

creating and configuring gitignore


file in local network:
1. Create ".gitignore" file with
notepad.
2. type "# ignore all.txt files
*txt" (anyfile named txt will be
ignored)
3. When typed "git status" files
that end with

To restore deleted files:


git restore <file name>

Rename file name:


git mv <previous file name> <new
file name>
Branch:
1. git branch <name for branch>
(creating branch)
2. git branch (to know number of
branches in a given project)
3. git switch <branch name>
(switching to other branch)
4. git commit -a -m "comment for
changes" (to commit changes to a
switched branch)
5. git merge -m "comment for
merging" <branch name that
merging is going to happen from>
(in order to write this code, the
environment should be in different
branch)
6. git branch -d <branch name>
(to delete a branch)

Merging conflicts:
1. git switch -c <branch name>
(creating new branch and
switching to it atthe same time)
2. git commit -a -m "updated code
comment "
3. git switch <main branch>
<<making changes in same place
in main branch>>
4. git commit -a -m "updated main
branch code comment "
<<trying to merge from previous
branch using git merge -m
"comment for merging" <branch
name that merging is going to
happen from> >>
<<error message appears>>
<<in the code file 2 text of codes
are presented and you get to
choose only one of them>>
<<you delete one of the code
paragraph>>
5. git commit -a -m "update the
change to main branch code"

Publishing local repo to cloud repo


(github):
1. git remote add origin <url of
cloud repo> (to establish remote
connection with github)
2. git branch -M <name of
branch> (choosing target branch
to send to cloud repo)
3. git push -u origin main (push all
the contents from local repo to the
cloud)
3.1. git push --all (pushing all local
branches to cloud repo)

Working with github:


● In "Issues" section you create a
problem request to be solved
● You make edits in a file in
"Code" section
● Scroll down to "Commit
changes" box, you can either
choose "commit directly to the
main branch" or "create a new
branch for this commit and start a
pull request"
●When you choose pull request
the changes you made is
requested to someone so that
they will be viewing and later
submitting it to be merged with
their code
●After giving name to a branch in
pull request choice, an"open a pull
request" windows pops-up.
● after giving out comment on pull
request, you press to create pull
request.
● either you or team member sees
the pull request, after viewing your
changes he could either press
"merge pull request" or cancel it
● you can also tie this pull request
to problem request you made in
"Issues" section. In order to that
from aside under "Development"
title you choose your problem
request to tie them
● after pressing "merge pull
request" not only it will be merged
with the chosen branch, also the
issue request will be closed.
●on aside under "release" title you
can publish your source code and
give release title to it such as
"v1.0.0"

Getting changes from cloud repo


to local pc:
1. git fetch (downloading all the
history from all the remote
tracking branches)
2. git merge (merging with local
files)
Or 2 commands above is
combined under one command
1. git pull
repo yaratdiqdan sonr
git clone
https://github.com/LeilaZeinal/ders
2222.git
2. her hansi edit edirsiz
3. git add .
4. git commit -m "test"
5.git push

Changing directory (on linux):


cd /../../

You might also like