This post explains some of the basics of git (a simple refresher post to GIT commands).
SCENARIOS:
Git clone <git url> download a project from git remote repository
init
add <file> or .
commit -m <commit message> (Commit files to local repository)
status (list all new and modified files)
diff (Shows files modified)
fetch: fetches the remote repo into the local repo, but does not merge
pull: does and fetch and also does the merge into the local repo.
Remote: lists the remote
git remote
git remote -v
Log: logs all changes
git log
git log —all
git log —all —oneline —decorate —graph
SCENARIOS:
———————————————————
# Local folder to Git remote.
————————————————————
Steps to commit an already existing local project to git.
git init
git add README.md
Git commit -m “Initial commit”
Create a repository in git and get the
git remote add origin git@github.com:deiveehan/<reponame.git>
Git push -u origin master.
————————————————————
# Create a branch from command line.
————————————————————
git branch —list (shows all the branches).
git checkout -b develop (creates a local branch called develop)
change a file
perform git add and commit to the local code.
git push —set-upstream origin develop
————————————————————
# Switching branches.
————————————————————
Git branch (shows local branches)
Git checkout develop
————————————————————
# Merging with parent branch (say develop)
————————————————————
Master
- Develop
- A
commit A changes to local repository
git checkout develop
git merge A
git push
————————————————————
# Deleting remote branch
————————————————————
git branch -d A (Delete references of local branch)
git push origin -d A (delete remote branch)
————————————————————
No comments:
Post a Comment