Results: 102
git push origin --delete new_branch
To delete branch
new_branch
on remote repository
git push origin --delete new_branch
Pushes commits to the remote branch
git push origin new_branch
If the branch does not exist on remote repository, first should be run this command:
git push --set-upstream origin new_branch
Alternative of the above command is this command:
git push -u origin new_branch
To delete branch
new_branch
on remote repository
git push origin new_branch --delete
Deletes the
login
branch
git branch -d login
Deletes the
login
branch (with force mode, which means - the branch will be deleted, even if it's not fully merged
git branch -D login
shows the difference between the working directory and index
git difftool HEAD
Shows the difference between the commits in some of the difftool apps (that is previously configured)
git difftool a8098222d481b2c4249e09cdf639427b237a1d8f 17d3352bd6486e4c34bbfc51053c7b86911458da
Shows the difference between
login.frm
files from different commits in default diff.tool
git difftool a8098222d481b2c4249e09cdf639427b237a1d8f 17d3352bd6486e4c34bbfc51053c7b86911458da login.frm
If the diff.tool is not configured, the default console diff tool
vimdiff
will be used instead. ... Shows what default diff.tool is
git config --global merge.tool
Shows what meld.path is
git config --global mergetool.meld.path
Configure merge tool and set
meld
as default
git config --global merge.tool "meld"
git config --global mergetool.meld.path "C:\Program Files (x86)\Meld\Meld.exe"
Configure difftool prompt to false
git config --global difftool.prompt false
Lists all commits of the local repository
git log
Lists all commits each on one line (only commit identifier and commit message)
git log --pretty=oneline
Almost the same as the above command. But the commit identifier is shortened (only the first several symbols)
git log --oneline
If we are on
master
and we want to see other branch's commits
git log another_branch
After fetching new commits from remote, we can see the new commits (even if we are on
master
)
git log origin/master --oneline
Shows some abbreviated stats for each commit
git log --stat
It shows all commits in the history of branches, tags and other refs, but it does not show commits that are not reachable from any ref
git log --all
We can even specify a format of the commits history
git log --pretty=format:"%h - %an, %ar : %s"
Where:
%h
is the commit identifier
%an
- author of the commit
%ar
- how much time ego was created
%s
- message of the commit The format result:
a11bef0 - Scott Chacon, 6 years ago : Initial commit
... Funny format which will result in:
54d459d by VLR, which created the commit 28 hours ago with comment: some messagee
git log --pretty=format:"%h by %an, which created the commit %ar with comment: %s"
git show
Shows changes of the commit
git show a8098222d481b2c4249e09cdf639427b237a1d8f
Shows only
index.html
changes from the commit
git show a8098222d481b2c4249e09cdf639427b237a1d8f index.html
Shows changes of the last commit (HEAD always points to the last commit if it is not detached)
git show HEAD
-u
flag adds a tracking reference to the upstream server that we are pushing to. This lets us do a
git push
without specifying other arguments. For example, once we do a
git push -u origin master
, we can later run
git push
and git will know that we meant
git push origin master
Merge
login
branch into
master
git merge login
Note:
we must be on master branch if we want some other branch to merge on it
Lists all local branches. Current branch is highlighted (with green color)
git branch
Lists all remote branches
git branch -r
Lists all local and remote branches
git branch -a
Creates new branch
login
to work on login functionality on the branch
git branch login
Shows branches that are merged already
git branch --merged
Deletes the
login
branch
git branch -d login
Deletes the
login
branch (with force mode, which means - the branch will be deleted, even if it's not fully merged
git branch -D login
Files or folders that we don't want to include, should be inside
.gitignore
file. For example, if we don't want to include any .txt files, any files inside /docs directory, and also any .html files inside /dir, then the file will contain:
*.txt
/docs
/dir/*.html
Results: 102